107 Commits

Author SHA1 Message Date
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
Daniele Varrazzo
18f75951e2 Remove generated blank lines from legacy .sql file
They appear cause portability problems.
Fixes issue #12.
2013-11-05 02:24:42 +00: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
Josh Kupershmidt
9c8d519415 Kludge to remove -lpam from LIBS in Makefiles.
Per Issue #7 from armanddp, it seems the RHEL/CentOS packages
of Postgres are built against libpam, which shows up in
the LIBS reported by pg_config. We don't actually need to
link in libpam for pg_repack, so manually remove it from
our LIBS. This helps a little bit for building on
RHEL/CentOS, though the issue of libpgport.a missing
on that platform still looms.
2013-05-23 20:31:56 -04:00
Josh Kupershmidt
95ce24c2a0 More sed tweaks to Makefile for portability.
The -E flag to specify extended regular expressions apparently is
not portable to all platforms, such as CentOS 4.5. Use an uglier
but hopefully more portable basic regular expression in Makefiles.
2013-05-21 21:45:47 -04:00
Daniele Varrazzo
20dea46184 Merge remote-tracking branch 'piro/master' 2013-05-05 00:19:22 +01:00
Daniele Varrazzo
98d304712c Merge branch 'funky-version-check'
Conflicts:
	bin/expected/repack.out
	bin/sql/repack.sql
2013-05-05 00:09:39 +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
a2138b6d7d Ignore AFTER triggers sorting after z_repack_trigger
They are not a problem, and they fore after the BEFORE trigger anyway.

To be checked against more PostgreSQL versions.
2013-04-18 01:22:24 +01:00
Daniele Varrazzo
477fba884c Ignore AFTER triggers sorting after z_repack_trigger
They are not a problem, and they fore after the BEFORE trigger anyway.

To be checked against more PostgreSQL versions.
2013-04-18 01:19:52 +01:00
Daniele Varrazzo
14c4d4653e Make the version number arith without using bc
Not as available as I thought.

Can't use the 0 prefix to make the 3rd number optional as $(()) parses is as
octal, so only use the first 2 numbers.

Also fixed collate test: not available on PG 9.0.
2013-04-18 01:10:22 +01:00
Daniele Varrazzo
c314cbda75 Check PostgreSQL version number as number in the makefile
Not entirely happy about the solution but I like the uniform tests.
2013-04-18 00:29:23 +01:00
Daniele Varrazzo
22762fce28 Fixed query for PG 8.3
The AS keyword was required.
2013-04-17 22:08:37 +01:00
Daniele Varrazzo
42c65d16f8 Merge branch 'change-tablespace'
Conflicts:
	bin/pg_repack.c
	doc/pg_repack.rst
2013-04-17 09:07:09 +01:00
Daniele Varrazzo
1d62d8d0c5 More helpful error messages in case of conflicting triggers
Closes issue #5.
2013-04-17 00:57:01 +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
a6e50515ce Merge branch 'master' into change-tablespace 2013-04-16 22:40:43 +01:00
Daniele Varrazzo
6710e514db Added --namespace option to set the namespace of repacked tables
Bumped version number to enforce extension re-creation as the SQL has
been modified.

Current limitations:

- Check for namespace existence: on error temp objects are left around
- What happens to the indexes?
- Tests needed.
- Should the default be the GUC default_tablespace instead of pg_default?
  This is actually an original pg_repack shortcoming, not a regression.
2013-02-21 17:20:54 +00: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
d402a73e42 No need to use strlen() with StringInfoData. 2012-11-26 20:08:47 -07:00
Daniele Varrazzo
d13f1b141d Merge branch 'version_check' 2012-11-16 21:32:45 +00:00
Daniele Varrazzo
deaae7dd72 Added version_sql() function and consistency check of sql version 2012-11-16 21:32:28 +00:00
Daniele Varrazzo
e02811689a Fixed non-portable use of sed to parse the version from META
Patch from Josh, with the help of RhodiumToad.
2012-11-16 10:36:16 +00:00
Daniele Varrazzo
0af231dff5 Use a single version number for program, library and SQL
Having the SQL on a different numbering scheme is useful to provide an ungrade
path. But pg_repack has no need of such a path as it can be uninstalled with
no problem, so we are not going to provide update script. Hence it's much
easier to have a single version number for everything.
2012-11-15 23:31:58 +00:00