139 Commits

Author SHA1 Message Date
Daniele Varrazzo
4401bcf804 Merge branch 'fix-search-path' 2018-05-19 17:13:08 +01:00
Daniele Varrazzo
021d0b0393 Fixed broken library paths on recent ubuntu packages
Close #179
2018-05-19 17:12:39 +01:00
Masahiko Sawada
64cc2070ed Fix the broken behavior made by restricting the search path
This commit doesn't include the change of regression test files.
2018-04-06 14:50:40 +09:00
Josh Kupershmidt
02e6c5ce96
Merge pull request #166 from bashtanov/fix_lockup
Avoid excessive locking when table already being repacked by another instance
2018-03-21 14:35:33 -04:00
Daniele Varrazzo
c62d865c18 Choose schema name visibility from running server version
Guarantee the extension compiled on newer servers can be used on older
ones.
2018-03-19 19:41:46 +00:00
Daniele Varrazzo
07e944d9d1 Use the Postgres way to get the version number
Unsurprisingly, there was one.
2018-03-19 19:07:33 +00:00
Daniele Varrazzo
2fd0eb050a A more compact way to verify the identity of the test files 2018-03-09 15:32:26 +00:00
Masahiko Sawada
64c22ffc5f Add expected files for regression tests.
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
2018-03-09 14:00:04 +09:00
Masahiko Sawada
2f6196d654 Always qualify relation names.
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.
2018-03-09 10:53:43 +09:00
Alexey Bashtanov
731c4ee405 Avoid excessive locking when table already being repacked by another instance 2018-01-17 11:24:23 +00:00
Daniele Varrazzo
f996fd8fb3 Allow building with PostgreSQL 10rc1
This is what we get:

    $ pg_config --version
    PostgreSQL 10rc1
2017-09-25 02:33:13 +01: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
Nicola Murino
05fac2dac3 fix compilation with msvc
__attribute__ macro is not defined in msvc and it is not essential to
the implementation. All it does  is tell the compiler that this function
is similar to printf, and  expects a printf-like format string
So for MSVC we define __attribute__ as a macro that do nothing
2017-04-19 11:54:46 +01:00
Masahiko Sawada
a6b2b0e82e Fix a mistake of merging.
Also fix regression test failure.
2017-04-11 23:43:21 +09:00
Masahiko Sawada
d55a08fc1e Merge branch 'master' into toast_storage_param 2017-04-11 23:30:27 +09:00
Masahiko Sawada
b6ea2ca3c9 Fix the mix of tabs and space. 2017-04-10 23:26:58 +01:00
Masahiko Sawada
5adff6ff0b Set column storage type before first copying table.
Previously, even if the table whose column storage type has been
changed the pg_repack did first copy the data to table without changing
column storage paramater. This cause of that the existing data is
pushed out to its toast table even if actual column storage type is
"main".

Issue #94.
2017-04-10 23:25:49 +01:00
Masahiko Sawada
ca5ca11d4d Specify the storage option for TOAST table when create table.
The storage option such as AUTOVACUUM_VACUUM_SCALE_FACTOR can be
set to both heap table and TOAST table. But the storage parameter
for TOAST table had gone after repacked. This change create new
function get_storage_param which returns all storage paramters
including for TOAST table and OID setting.

Issue #10.
2017-04-10 23:20:50 +01:00
Daniele Varrazzo
7d752f2b4e Dropped C file now unused 2017-04-10 11:58:41 +01:00
Daniele Varrazzo
86eef300f1 Dropped C code used by unsupported PG versions 2017-04-10 11:44:17 +01:00
Daniele Varrazzo
2af90dced1 Dropped sql file for non-extension build 2017-03-29 04:39:02 +01:00
Dmitry Ivanov
839aec7e71 remove blank line 2017-03-24 16:56:27 +03: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
Daniel Cheng (鄭郁邦)
71f8833958 Do not repack unlogged tables (close #71) 2016-02-12 18:50:45 +08: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
949c0ad150 Avoid symbol conflict causing segfault when pg_statsinfo is installed.
Control symbol visibility for functions exported in the pg_repack
shared library, to avoid symbol conflicts with other libraries,
particularly those which may be loaded via shared_preload_libraries
and use conflicting function definitions of our common pgut code,
such as pg_statsinfo.

Verified this fix on my Debian x86_64 machine with PostgreSQL 9.4 and
pg_statsinfo 3.0.2. Would be nice to test this fix on a few other
platforms such as OS X, though I had some difficulty getting
pg_statsinfo to build on OS X. Hopefully closes Issue #43, thanks
to bwtakacy for the report and demonstration of the commited fix in
pg_reorg.
2015-05-31 18:59:05 -04: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
Daniele Varrazzo
564f061beb Use the right appendStringInfoVA interface
pgut version renamed to avoid confusion with the server version.

(I wonder why there is such a duplication of interfaces and
implementations there though...)
2015-03-10 11:48:16 +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
f0cd787bf5 Merge in Pull Request #20 from Steeve Lennmark.
Adds support for repacking only the tables in a specified schema. This
doesn't support --only-indexes mode, but that seems alright for now.

Fix merge conflicts, and make a few tweaks along the way:
 * bump version to 1.3-dev0
 * add Beena to list of maintainers
 * documentation wordsmithing
 * fix up the INFO message printed for each index in --index or
   --only-indexes mode, so that it is only printed once per index, and
   prints the name of the original index, not that of the transient
   index_%u name.
2014-05-24 15:42:24 -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
Steeve Lennmark
e16472419f Fix regression while refactoring patch 2014-01-22 14:55:07 +01:00