429 Commits

Author SHA1 Message Date
Steeve Lennmark
e7b6719256 Add test for --schema (-c) 2014-01-30 12:19:21 +00:00
Steeve Lennmark
c7767ab10b Move --dry-run to 1.3 2014-01-26 10:28:29 +00:00
Steeve Lennmark
bf277a4e5f Add support for dry run -N (--dryrun) 2014-01-24 15:27:42 +01:00
Steeve Lennmark
c2fa3a02ef Add documentation for --schema 2014-01-24 15:14:16 +01:00
Steeve Lennmark
e16472419f Fix regression while refactoring patch 2014-01-22 14:55:07 +01:00
Steeve Lennmark
1a10df9049 Add support for repacking an entire schema
This adds the option -c (--schema).
2014-01-22 14:23:56 +01:00
Daniele Varrazzo
53906c4f18 Bumping version to 1.2.0-beta1
Remember to put back the release status to 'stable' before releasing
the final version.

I hope I got the right version number format for PGXN...
2013-11-05 02:24:42 +00: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
Daniele Varrazzo
57922b552c Docs cleanup before releasing 1.2 2013-11-05 01:39:07 +00:00
Daniele Varrazzo
81c99de210 README updated with pg_repack 1.1/1.2 differences 2013-11-05 01:38:47 +00:00
FIRST man
7487a775d5 skip transactions and locks in other databases when checking pg_locks' entries
problem: in case there are open transactions on other databases then the
         one pg_repack is working on and pg_locks doesn't contain any
         information about the affected database oid of the locked relation
         (e.g. there is no locked relation, only an open transaction),
         pg_repack will wait for that connection to release the lock
         (even if the relation that gets reorganized is held in an
         different database).

solution: join pg_database (via pg_stat_activity's datid) and check
          if the connection (of the conflicted transaction) is established
          on a different database than the relation treated by pg_repack
          and skip them.
          furthermore don't exclude transactions from other databases when
          shared objects are locked.
2013-08-02 15:22:16 +02:00
Josh Kupershmidt
d1ab1f7882 Check "relkind" instead of "reltype" in pg_class for clarity. 2013-07-08 09:20:40 -04:00
Josh Kupershmidt
27ea0fabe4 Several documentation updates for the pending 1.2 release:
* More mentions of new --only-indexes feature
 * Note we now support up to Postgres 9.3, and get rid of outdated list
   of supported operating systems. (As far as we know, pg_repack should
   build on any platforms supported by PostgreSQL itself, although no one
   has tested the Windows build in a long time.)
 * Remove most of the warnings about data corruption possible with concurrent
   DDL: this should no longer be a concern now that we hold an ACCESS SHARE
   lock during full-table repacks. Keep a short warning about old versions
   being susceptible to this problem, just to make clear that it's fixed now
   and as an enticement to upgrade.
 * A few grammar, phrasing, and typo fixes
2013-07-05 21:02:28 -04:00
Josh Kupershmidt
03015f8ee8 Regression tests for the new indexes-repacking features.
Patch from Beena Emerson.
2013-07-04 09:47:31 -04:00
Josh Kupershmidt
3f7a05162f Improved error message distinction for repack_table_indexes().
Previously, any error creating the temp index was blamed on a previous
temporary index existing. However, other errors could occur, e.g. if
--tablespace=pg_global was specified. Perform an explicit check for
whether an existing index_xxxxx already exists first, so that we
can give that error message only in the appropriate case.
2013-07-03 04:44:59 -04:00
Josh Kupershmidt
cd0b4ebf9d Improved error handling for repack_table_indexes()
If we do not successfully build any indexes on the target table, bail out
early instead of acquiring an ACCESS EXCLUSIVE lock on the table.
2013-07-01 21:11:37 -04:00
Josh Kupershmidt
fa9af9ddc0 A few more tweaks/fixes to repack_table_indexes()
* Avoid using create_idx from a PGresult that's already been PQclear'ed
 * Now that we're properly tracking which indexes have been repacked,
   don't bother with IF EXISTS in DROP INDEX. Better to make any errors
   here stand out.
2013-06-30 21:18:15 -04:00
Josh Kupershmidt
1c82aaefd9 Documentation updates for indexes-only mode.
Beena Emerson, with some additional cleanup from me.
2013-06-29 10:13:05 -04:00
Josh Kupershmidt
1e8ac21336 Several more fixes for indexes-only mode:
* Fix error handling in repack_table_indexes() to keep track of which
   indexes were actually rebuilt successfully by pg_repack, so that only
   those indexes will be dropped. Previously, we would issue an error
   message telling the user to use DROP INDEX but then just drop the
   index anyway.
 * DROP INDEX command needs to quote the schema name in case it is
   not simple.
 * missing CLEARPGRES() in repack_all_indexes()
2013-06-29 09:41:27 -04:00
Josh Kupershmidt
f0f36688f0 A few fixes to the indexes-only building.
Improve locking behavior in indexes-only mode so we only need one
ACCESS EXCLUSIVE lock per table instead of one per index. Support
multiple --index options. Fix for schema-name parsing.

Patch from Beena Emerson.
2013-06-29 09:32:18 -04:00
Josh Kupershmidt
df53964529 Rename --only-index to --only-indexes.
Hopefully makes more clear that all indexes of a table will be repacked.
2013-06-26 21:47:53 -04:00
Josh Kupershmidt
8337204ae6 Some error handling cleanup for index building.
Don't bother doing a 'goto cleanup;' after an ereport(ERROR, ...).
2013-06-22 16:45:57 -04:00
Josh Kupershmidt
61bf8acaf0 Use our own namespace for advisory locks.
Switch to using the two-input form of pg_advisory_lock(), so as
to avoid impacting other applications which might happen to lock
just the OID of the table. The REPACK_LOCK_PREFIX_STR is a decimal
version of the first three bytes of
  echo -n "pg_repack" | sha1sum
2013-06-22 09:56:44 -04:00
Josh Kupershmidt
bebe6ffb2b Factor out advisory locking code into advisory_lock()
Also, some further small fixes of error messages, comments,
marking dubious kludges (e.g. strchr() to determine schema name).
2013-06-22 09:35:19 -04:00
Josh Kupershmidt
673eac7b42 Change 'have_error' to 'ret' for simplicity. 2013-06-22 08:59:47 -04:00
Josh Kupershmidt
d79d342eea Add advisory locking to repack_one_table()
Avoids danger (or just pointlessness) of having someone run a
table-wide repack and an indexes-only repack of the same table
at the same time.
2013-06-22 08:41:41 -04:00
Josh Kupershmidt
62b5e4fb11 A few cosmetic fixes to pg_repack.c:
* fix old reference to --indexes-only
 * trailing whitespace and indentation cleanup to match rest of code
 * XXX note about improving advisory locking
2013-06-22 06:51:41 -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
5b6a162996 Shuffle sanity checks into preliminary_checks().
This refactoring helps pave the way for online indexes-only
repacking. Patch by Beena Emerson.
2013-06-20 21:11:25 -04:00
Josh Kupershmidt
a942042215 Fix up the --help output for --jobs. 2013-06-18 19:45:05 -04:00
Josh Kupershmidt
29023206b5 Fix lock_exclusive()'s behavior during swap step.
Since we are not starting a new transaction in conn2 during the
swap step, we need to make sure that if our LOCK query is canceled
due to statement_timeout that conn2's transaction is not left in
a useless error state. Use SAVEPOINT and ROLLBACK TO SAVEPOINT to
avoid this problem.
2013-06-16 20:17:24 -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
Josh Kupershmidt
dc31920616 Move regression tests from ./bin/ to ./regress/ 2013-05-09 21:15:48 -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
2b7e1b2f0c Ignore regression tests output 2013-05-04 13:31:11 +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
f886e0dba6 Fixed --order-by broken by namespaces refactoring
Also added a regression test for it.

Bug and patch from Beena Emerson, thany you.
2013-04-22 11:19:56 +01: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
52e7761343 Fixed doc formatting and dropped stale diagnostics entries 2013-04-18 02:49:56 +01:00
Daniele Varrazzo
fb07fad34a Make sure to close the transactions after repack_one_table
If we exit early (e.g. checking the triggers) repack_cleanup() is not called
but we must close the transactions anyway.
2013-04-18 02:29:51 +01:00
Daniele Varrazzo
54ba3c19cd Install plpgsql on test databases 8.3 and 8.4
Required by triggers tests
2013-04-18 01:32:46 +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