106 Commits

Author SHA1 Message Date
Josh Kupershmidt
40626769d8 Since commit 742380f0429b6 included some of the same changes
already in 6a0af679e14d1d, go ahead and include a few more of
the error cleanup from 6a0af679e14d1d.
2012-11-16 15:27:53 +00:00
Josh Kupershmidt
34605aef27 Fix bogus use of table name parameters.
Mimic the original code, which used execute_elevel() with params to
pass in table names which are assumed to be quoted already by the user.
2012-11-16 15:27:53 +00:00
Josh Kupershmidt
00ddb1edf9 Improved error handling, particularly when processing multiple tables.
Previously, an error while processing any single table would cause
pg_reorg to cause exit() and bail out. Quick summary of fixes:
 * get rid of pgut_atexit_push() and pgut_atexit_pop() use, since
   we are no longer relying on calling exit() to handle mundane errors
 * remove lock_conn_pid variable; we can just use buffer instead
 * lock_exclusive() and lock_access_share() now return bool instead of
   bailing out on any error
 * ERROR-level ereport() or elog() calls now return WARNING instead,
   to avoid bailing out unnecessarily
 * signature of reorg_cleanup() changed; it no longer needs to take a
   void pointer
 * check return of strdup() for vxid
 * Use pgut_rollback() instead of sending ROLLBACK; command directly

There are still one or two FIXMEs left, including fixing table name
escaping, but I'm committing this much.
2012-11-16 15:25:41 +00:00
Josh Kupershmidt
ad75dcfbb1 Allow multiple --table options to be specified on the command-line.
Per Issue #18. SimpleStringList code borrowed from pg_dump and a
pending patch to add similar functionality to pg_restore,
clusterdb, vacuumdb, and reindexdb.

The error handling in reorg_one_table() could still be much improved,
so that an error processing a single table doesn't cause pg_reorg to
necessarily bail out and skip further tables, but I'll leave that for
another day.
2012-11-16 15:19:35 +00:00
Josh Kupershmidt
ad00eb181d Several fixes for concurrent-DDL guard.
* KILL_COMPETING_LOCKS was using pg_cancel_backend() instead of
   pg_terminate_backend()
 * create kill_ddl() function for canceling+terminating any pending
   unsafe concurrent DDL, i.e. anyone hanging out waiting for
   an ACCESS EXCLUSIVE lock on our table.
 * create lock_access_share() function for reliably obtaining an
   ACCESS SHARE lock on the target table, killing off any queued
   ACCESS EXCLUSIVE lockers in the process via kill_ddl()
 * Avoid deadlock possible before we run:
     CREATE TABLE reorg.table_xxx AS SELECT ... FROM ONLY ...
   by using lock_access_share()
 * Fix a few calls in lock_exclusive() which were forgetting to
   specify the passed-in connection.

These fixes are related to Issue #8. The main thing remaining AFAIK
is to review or fix some of the unlikely-error handling bits;
most of these should be marked with XXX now.
2012-11-16 15:18:25 +00:00
Josh Kupershmidt
cf25780575 Further improvements to concurrent-DDL guard.
Fix table locking so that race conditions don't exist between lock
release in primary conn, and lock acquisition in conn2. Also, have
conn2 be in charge of performing the table swap step, to avoid a
similar race.

Part of work for Issue #8.
2012-11-16 15:18:25 +00:00
Josh Kupershmidt
3606e0a957 Switch to using pgut_command() and pgut_execute() for conn2. 2012-11-16 15:14:12 +00:00
Josh Kupershmidt
78bae38718 Take an ACCESS SHARE LOCK on the target table, in an initial attempt to prevent concurrent DDL.
This is a first pass at Daniele's suggestion in Issue #8, although it is
definitely still buggy -- it is still possible for another transaction
to get in an AccessExclusive lock and perform DDL either before the
ACCESS SHARE lock is acquired or immediately after it is released.
2012-11-16 15:14:12 +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
Daniele Varrazzo
ffe5a2b323 Added git repos reference to the META info 2012-11-15 15:42:39 +00:00
Daniele Varrazzo
8b3f64f0fc Added PGXN URL for download and pgxn client usage docs 2012-11-15 15:40:50 +00:00
Daniele Varrazzo
77d27a14f3 Use the same title of README/docs for the extension 2012-11-15 13:53:06 +00:00
Daniele Varrazzo
258ca24986 Docs title and mission uniformed with the README
Also reduced excessive left padding in Contents box.
2012-11-15 12:04:49 +00:00
Daniele Varrazzo
292e00835e Use correct homepage link in pg_repack --help
Also fixed punctuation in help.
2012-11-15 11:53:00 +00:00
Daniele Varrazzo
b728d7b9dd README wordsmithing by Josh applied 2012-11-15 11:39:51 +00:00
Daniele Varrazzo
a926623e74 A few doc typos fixed 2012-11-15 00:58:58 +00:00
Daniele Varrazzo
ec28c2772f Mention partial index issue fixed in docs 2012-11-15 00:19:29 +00:00
Daniele Varrazzo
44bf1543be Don't choose a partial index as primary key
Fixes reorg/pg_reorg#22
2012-11-15 00:16:38 +00:00
Daniele Varrazzo
ef2c7da4a5 Doc page reordered in a more logical order
Requirements, Installation, Usage, Examples, etc.
2012-11-13 14:33:08 +00:00
Daniele Varrazzo
4f9269cab8 Improvements to the install section of the docs
Fixed cleanup procedure with EXTENSION, added uninstall section.
2012-11-13 14:07:43 +00:00
Daniele Varrazzo
673a8ea100 The repack schema is contained in the pg_repack extension
...not the other way around. This allows DROP EXTENSION ... CASCADE to
remove temporary directories, simplifying the cleanup procedure after an
error, and getting rid of the schema on uninstall.
2012-11-13 14:02:45 +00:00
Daniele Varrazzo
dd72e2ae99 Clarifying the pg_repack scope and its relation with pg_reorg 2012-11-12 12:46:51 +00:00
Daniele Varrazzo
6f8a8bab6d support for ENABLE TRIGGER renamed to enable_trigger from alter_table 2012-11-12 11:51:20 +00:00
Daniele Varrazzo
532be6ea25 Provide a single way to install pg_repack
Provide only CREATE EXTENSION support on PG >= 9.1 and only the sql script on
PG < 9.1.

Also dropped the /echo cruft in the extension script: it is broken on pg 9.1
and 9.1.1, and because the script is not installed on versions that don't
support CREATE EXTENSION it is just not terribly useful.
2012-11-12 01:04:46 +00:00
Daniele Varrazzo
ac068cc69b Script to create extension from loose objects dropped altogether
pg_repack doesn't create any object to depend on, so it is always possible drop
it and install a new version instead of upgrading. Creating a robust upgrade
path from loose objects which can be of any version to a target version is
hopelessly brittle, so I'd suggest the user just to drop a previous pg_repack
version and install the new one.
2012-11-12 00:20:41 +00:00
Daniele Varrazzo
390feca0e1 Dropped the last compatibility macros for PG 8.2 2012-11-11 23:51:46 +00:00
Daniele Varrazzo
a92fefab8a Silence error message during test
It is different across server versions.
2012-11-11 23:38:38 +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
71af7f20be Dropped support for building "in tree": always use PGXS 2012-11-11 17:17:41 +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
cc622aefae Project homepage set to http://reorg.github.com/pg_repack/ 2012-11-11 02:38:09 +00:00
Daniele Varrazzo
1707d3add2 Dropped mention to PG 8.2 in master 2012-11-11 01:30:12 +00:00
Daniele Varrazzo
b3a86e3fee Documentation converted to reST
I had to drop the Japanese doc, but I'd be happy to restore it in reST format.
2012-11-11 01:30:05 +00:00
Daniele Varrazzo
8bd08c4f73 README updated with the pg_repack info 2012-11-11 01:10:24 +00:00
Daniele Varrazzo
107a8b1324 Uppercase help metavars 2012-11-10 23:45:56 +00:00
Daniele Varrazzo
1852775c48 email and meta updated to pg_repack
For the moment we are advertising the pg_reorg email.
2012-11-10 22:57:22 +00:00
Daniele Varrazzo
b7799c1782 Fork the pg_repack extension 2012-11-10 22:33:57 +00:00
Daniele Varrazzo
0f8c33f72f Don't use a generic 'unpackaged' version
The behaviour of the script is not really predictable if it is run on the
loose objects of pg_reorg >= 1.1.8. So let's be explicit about what version
we expect as starting point.
2012-11-10 22:02:10 +00:00
Daniele Varrazzo
bd06ec0091 Program metadata version moved to 1.2dev0 2012-11-10 19:59:19 +00:00
Daniele Varrazzo
41f3c5c0f3 Ignore temporary test files 2012-11-10 19:52:50 +00:00
Daniele Varrazzo
16adb3359e Fixed cleanup of init test script 2012-11-10 19:52:43 +00:00
Daniele Varrazzo
883b9b5b28 Don't add the schema to the extension
It is an error to do so.
2012-11-10 19:52:35 +00:00
Daniele Varrazzo
8b8b859ad3 Create both the standalone and extension sql scripts from the same .in 2012-11-10 19:52:28 +00:00
Daniele Varrazzo
fd2d231b2c Added META.json for PGXN submission 2012-11-10 19:51:53 +00:00
Daniele Varrazzo
a2fa346eff Fixed create extension from unpackaged
Fixed syntax of create aggregate and an extra brace.
Schema added to the extension.
2012-11-10 19:51:47 +00:00
Masahiko Sakamoto
69cc976b39 Updated regression tests to use CREATE EXTENSION for PostgreSQL 9.1 or higher. 2012-11-10 19:51:40 +00:00
Masahiko Sakamoto
e9d4ef2557 Supports CREATE EXTENSION.
I've changed lib/Makefile to support CREATE EXTENSION.
In order to work with previeous PostgreSQL version (i.e. < 9.1),
this implementation installs both pg_reorg--1.0.sql and pg_reorg.sql.

This patch lacks regression testcases for CREATE EXTENSION, which I will commit soon.
2012-11-10 19:51:30 +00:00