Due to compatibility break by the recent PostgreSQL core code changes
we need to split expected files into each minor releases rather than
each major releases.
Now the mapping between PostgreSQL version and expected file is
complicated as follows.
* version 10
* >= 10.3 : repack_3.out, tablespace_2.out
* < 10.3 : repack_2.out, tablespace.out
* version 9.6
* >= 9.6.8 : repack_4.out, tablespace_2.out
* < 9.6.8 : repack.out, tablespace.out
* version 9.5
* >= 9.5.12 : repack_4.out, tablespace_2.out
* < 9.5.12 : repack.out, tablespace_1.out
* version 9.4
* >= 9.4.17 : repack_5.out, tablespace_2.out
* < 9.4.17 : repack_1.out, tablespace_1.out
* version 9.3
* >= 9.3.22 : repack_6.out, tablespace_3.out
* < 9.3.22 : repack_1.out, tablespace_1.out
* version 9.2 : repack_1.out, tablespace_1.out
* version 9.1 : repack_1.out, tablespace_1.out
Due to change at PostgreSQL 10.3, 9.6.8, 9.5.12, 9.4.17 and 9.3.22,
relation names passed by PostgreSQL function such as
pg_get_indexdef_string() are schema-qualified, which could be cause
of a parse error.
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.
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.
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.
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.
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.
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.
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.
* 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
Makes injecting the target tablespace much easier and fixes interaction
between tablespace and WITH/WHERE clauses.
Added tests to check the correct indexes definition.
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.
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.