45 Commits

Author SHA1 Message Date
Alexey Bashtanov
731c4ee405 Avoid excessive locking when table already being repacked by another instance 2018-01-17 11:24:23 +00:00
Daniele Varrazzo
773dc5349d Work around CatalogIndexInsert no more exported in PG 10
The CatalogTupleUpdateWithInfo performs the two operation
simple_heap_update and CatalogIndexInsert.
2017-04-25 15:09:27 +01:00
Dmitry Ivanov
94679ee83a add a comment regarding AccessShareLocks in repack_get_table_and_inheritors() 2017-04-24 13:26:28 +03:00
Dmitry Ivanov
0901b82588 acquire AccessShareLock on parent and children in repack_get_table_and_inheritors() 2017-04-23 21:22:54 +03:00
Dmitry Ivanov
7dca19d7e0 add docs for repack_get_table_and_inheritors() 2017-04-19 14:09:30 +03:00
Dmitry Ivanov
e1f362e831 resolve conflicts 2017-04-19 14:05:53 +03:00
Daniele Varrazzo
86eef300f1 Dropped C code used by unsupported PG versions 2017-04-10 11:44:17 +01:00
Dmitry Ivanov
68dc592545 introduce option --parent-table (-I, stands for 'inheritance'), fix function repack_one_database(), introduce function repack.get_table_and_inheritors() 2017-03-20 23:05:26 +03:00
masahiko
5781aabb61 Merge pull request #107 from MasahikoSawada/change_to_after_trigger
Change trigger type to AFTER trigger.
2017-02-22 12:08:32 +09:00
Masahiko Sawada
b9219be7d8 Change format identifier to UINT64_FORMAT.
Change it for portability.
2017-02-21 16:20:38 +09:00
Masahiko Sawada
bacf197a7b Change format identifier of SPI_processed to uint64.
Because commit 23a27b039d94ba359286694831eafe03cd970eef has extended the
type of SPI_processed from uint32 to uint64, pg_repack emit warning when
compiling with PostgreSQL 9.6 or later. To fix that, we cast it to uint64
and change format identifier from %d to %lu.
2017-02-02 23:42:44 +09:00
Masahiko Sawada
375f03c0c3 Change trigger name from a_repack_trigger to repack_trigger.
In AFTER trigger context, since triggered tuple is not changed by
any other triggers we can call it just repack_trigger.
2017-01-24 14:09:05 +09:00
Masahiko Sawada
d83ee3d6a0 Change trigger type to AFTER trigger.
During repacking table, if a transaction executes INSERT CONFLICT
ON UPDATE/DO NOTHING, because we define BEFORE trigger on target
table, the contents of operation log table becomes inconsistent
easliy. As a result, pg_reapck fails with a high probability.

To resolve this issue, this changes the trigger type from BEFORE
to AFTER. We define AFTER trigger that is the first of the AFTER
trigger to fire on the table.
2017-01-19 16:32:54 +09:00
amit
e4033c273e Need to #include pg_am.h directly now to use BTREE_AM_OID.
Due to upstream changes to the index AM API definitions.
2016-01-18 20:55:57 +09:00
amit
cbe027289a Consider schemaname too when doing LOCK TABLE in repack_drop().
This was an oversight in a previous commit to fix the deadlock reported
in Github issue #55.
2015-12-03 13:32:03 +09:00
amit
94232991b9 Expand a comment in repack_drop().
Previous text did not sufficiently explain why taking a lock on the
target table would be necessary.
2015-11-09 15:23:45 +09:00
amit
5317f527f4 Make repack_drop() processing robust against deadlocks.
Concurrent activity on the target table can cause deadlocks when
repack_drop() is doing its job, ie, dropping the temporary objects
created. It is highly likely to occur when pg_repack is interrupted
midway through its processing.
2015-11-06 17:10:13 +09:00
Josh Kupershmidt
5476a416fc Merge branch 'Fix-repack_apply-count-bug' of https://github.com/decibel/pg_repack into decibel-Fix-repack_apply-count-bug 2015-10-14 09:39:46 -04:00
Jim Nasby
0e24283856 repack_apply(): Use default if count is negative
Per documentation, a negative value for count should result in using DEFAULT_PEEK_COUNT.
2015-10-11 16:39:35 -05:00
bwtakacy
c3960cd118 Include a new header file to build with PostgreSQL 9.5
By commit 7b1c2a0f2066672b24f6257ec9b8d78a1754f494 in PostgreSQL,
builtins.h is splitted to a new header file ruleutils.h.
The usage of pg_get_indexdef_string in lib/repack.c is affected.
2015-10-09 13:15:30 +09:00
Josh Kupershmidt
8fc8b656a2 Some comments about our new atexit handling. 2015-05-25 16:56:44 -04:00
kotsachin
ad109edb5b This patch contains repack_cleanup_callback() which calls to repack_drop() for cleaning temporary objects. repack_cleanup_callback() will be pushed on stack using pgut_atexit_push() at beginning so that it will pop on abort or exit of program.
This patch includes one global counter (temp_obj_num) which counts number of temporary objects created by pg_repack. Correct order of deletion of temporary object as per count avoids unintentional error messages.
2015-04-17 13:07:01 +09:00
Daniele Varrazzo
a49bb41822 Dropped use of reltoastidxid field
The same index can be reached going through reltoastrelid and
pg_index.indrelid: checked at least on PG 9.1.
2015-03-10 14:53:49 +00:00
Josh Kupershmidt
080ebd3ed6 Bump up Copyright notices for 2015 2015-01-11 19:01:37 -05:00
Josh Kupershmidt
e2c720b89c Perform sql_pop delete in bulk instead of one-at-a-time.
Prior to 506104686b these DELETEs had been done in large batches (of
DEFAULT_PEEK_COUNT size), but that naive method of choosing rows to
delete was unsafe. Here we continue to keep track of which rows must
be deleted as we process them.
2014-05-25 22:04:13 -04:00
Josh Kupershmidt
506104686b Fix a nasty data loss/corruption bug from the sql_pop query.
It is not safe to assume that we can bulk-delete all entries from the
log table based on their "id" being less than the largest "id" we have
processed so far, as we may unintentionally delete some tuples from the
log which we haven't actually processed yet in the case of concurrent
transactions adding tuples into the log table.
2014-04-22 10:56:24 -04:00
Josh Kupershmidt
d1ab1f7882 Check "relkind" instead of "reltype" in pg_class for clarity. 2013-07-08 09:20:40 -04:00
Josh Kupershmidt
b804c150ac Fix existing 'tablespace' regression test so it passes again.
Changes to repack_indexdef() had broken this test.
2013-06-22 06:47:06 -04:00
Josh Kupershmidt
f3fa2fa563 Fixes and cleanup of the new repack_index_swap():
* Make sure we don't crash if this function is fed a bogus OID
 * rename idx1, idx2 variables for clarity
 * tweak query against pg_class to specify reltype = 0
 * CommandCounterIncrement() is probably unnecessary, removed
2013-06-21 20:58:54 -04:00
Josh Kupershmidt
ee23ec8ffd Initial import of indexes-only building patch.
Patch from Beena Emerson.
2013-06-21 18:41:09 -04:00
Daniele Varrazzo
20dea46184 Merge remote-tracking branch 'piro/master' 2013-05-05 00:19:22 +01:00
Daniele Varrazzo
a561c924f7 Parse tablespace/where in parse_indexdef
Makes injecting the target tablespace much easier and fixes interaction
between tablespace and WITH/WHERE clauses.

Added tests to check the correct indexes definition.
2013-05-05 00:07:14 +01:00
Daniele Varrazzo
cc2abf4b25 Fixed tablespace assignment in index with WITH clause
Reported by Beena Emerson.
2013-05-02 23:32:30 +01:00
Josh Kupershmidt
c55c613e44 Update RENAME_REL macro to work with 9.3. We now need to pass the
"is_internal" boolean to this function; for our purposes it should
be acceptable to always pass true.
2013-04-23 21:32:30 -04:00
Daniele Varrazzo
109689586e Fixed access to uninit'd mem in repack_indexdef
If the tablespace is the last token in the indexdef, skip_ident returns a
pointer *after* the term zero, so garbage may end up after the statement.
2013-04-22 00:48:53 +01:00
Daniele Varrazzo
d98a14bb55 Fixed index definition tokenization
In the previous commit skip_const was going ahead the space thus removing the
starting quote. Also fixed (and tested) trailing part after the tablespace
name, e.g. the WHERE clause.
2013-04-16 23:23:26 +01:00
Daniele Varrazzo
83fdb2a9e0 Added implementation for --moveidx
Note: if original namespace is "foo bar", repack_indexdef gives a bad
result. This is weird as apparently skip_ident can deal with spaces in
a quoted identifier. Committing as I'm going home, will deal with that
later.
2013-04-16 22:42:23 +01:00
Daniele Varrazzo
13cf8679db Added support for COLLATE to index keys 2012-12-09 12:02:49 +00:00
Daniele Varrazzo
4bcb7641c9 Function get_index_keys() renamed to get_order_by()
It was a FIXME item in the source. Reasonably so.
2012-12-09 11:35:52 +00:00
Daniele Varrazzo
a47686a7ee Added support for DESC and NULLS FIRST/LAST to index keys
Fixes issue #3
2012-12-09 01:11:39 +00:00
Josh Kupershmidt
95c196dd33 Have get_quoted_relname(), get_quoted_nspname(), and reorg_drop() sanity check arguments to prevent NULL pointer dereferencing and backend crash.
Fix for Issue #20.
2012-11-11 23:09:59 +00:00
Daniele Varrazzo
7b84eeb010 Get the program and library version from the META file 2012-11-11 18:30:27 +00:00
Daniele Varrazzo
1d60a946ff Added The Reorg Development Team copyright 2012-11-11 03:00:00 +00:00
Daniele Varrazzo
db1c554f60 Dropped executable flags 2012-11-11 02:48:46 +00:00
Daniele Varrazzo
b7799c1782 Fork the pg_repack extension 2012-11-10 22:33:57 +00:00