304 Commits

Author SHA1 Message Date
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
89031f9cc5 Dropped unused indexes info 2013-02-21 17:20:28 +00:00
Daniele Varrazzo
f9dc02191d Dropped bogus check and unused parameters allocation 2013-02-21 15:06:39 +00:00
Josh Kupershmidt
7a31f4fbf6 comment typofix. 2013-02-20 20:26:48 -07:00
Josh Kupershmidt
f551b56f1a Merge branch 'master' into concurrent_indexes.
Conflicts:
	bin/pg_repack.c
2012-12-14 22:17:36 -07:00
Josh Kupershmidt
7213e2fe7b Use CLEARPGRES() macro to call PQclear() and set res to NULL.
This simplifies some of the error handling blocks, as now
we can unconditionally use this macro without worrying about multiple
PQclear() calls causing a double-free().

Per discussion with Daniele.
2012-12-14 20:13:23 -07:00
Josh Kupershmidt
aa428b68c8 Merge branch 'concurrent_indexes' of github.com:schmiddy/pg_repack into concurrent_indexes 2012-12-14 18:52:16 -07:00
Josh Kupershmidt
2e4ac733c1 Fix up buggy initialization code for poll() and select().
Also some logging and variable name cleanup.
2012-12-14 18:49:00 -07:00
Josh Kupershmidt
d43ff3cd24 Add description of --jobs to the docs. Also, add missing newline in --help output. 2012-12-14 18:49:00 -07:00
Josh Kupershmidt
4f25c26284 restore the warning message about invalid indexes, to match old behavior and pass installcheck. 2012-12-14 18:49:00 -07:00
Josh Kupershmidt
a1821e3dcb Several fixes for concurrent index builds:
* Use poll() if it is available, or select() otherwise, to
   efficiently wait on index builds in worker queries to finish.
 * fix off-by-one error when initially assigning workers
 * move PQsetnonblocking() calls to setup_workers()
2012-12-14 18:49:00 -07:00
Josh Kupershmidt
8ab54cc803 Small fixes related to the concurrent_indexes changes.
Move PQsetnonblocking() call to setup_workers(), and make
sure we're not forgetting any workers.
2012-12-14 18:49:00 -07:00
Josh Kupershmidt
509e568c52 First pass at implementing concurrent index builds using multiple connections.
Adds a new --jobs command-line argument to specify how many worker
connections you want. These worker connections should stick around
while processing table(s) in a single database. For each table,
parcel out the indexes to be built among these worker conns,
submitting each CREATE INDEX ... request using PQsendQuery() i.e.
in non-blocking fashion.

Most of this is still rather crude, in particular the
while (num_active_workers) ... loop in rebuild_indexes(), but
it seems to be working, so I'm committing here.
2012-12-14 18:49:00 -07:00
Josh Kupershmidt
962fdff1af Fix up buggy initialization code for poll() and select().
Also some logging and variable name cleanup.
2012-12-14 18:17:45 -07:00
Josh Kupershmidt
b9c7189fa9 Add description of --jobs to the docs. Also, add missing newline in --help output. 2012-12-13 21:10:59 -07:00
Josh Kupershmidt
4c0c2f3618 restore the warning message about invalid indexes, to match old behavior and pass installcheck. 2012-12-13 19:56:44 -07:00
Josh Kupershmidt
42357353a7 Several fixes for concurrent index builds:
* Use poll() if it is available, or select() otherwise, to
   efficiently wait on index builds in worker queries to finish.
 * fix off-by-one error when initially assigning workers
 * move PQsetnonblocking() calls to setup_workers()
2012-12-13 19:12:05 -07:00
Josh Kupershmidt
b4d8a90437 Don't perform repack_cleanup() if we haven't actually set up z_repack_trigger etc.
Fixes a regression introduced in master (by the multiple --tables
changes, I think).
2012-12-13 18:55:19 -07:00
Josh Kupershmidt
8c2dd16608 Small fixes related to the concurrent_indexes changes.
Move PQsetnonblocking() call to setup_workers(), and make
sure we're not forgetting any workers.
2012-12-11 19:46:49 -07:00
Josh Kupershmidt
0bdb4bb96f Missing PQclear(). 2012-12-11 19:12:57 -07:00
Josh Kupershmidt
0d984ed3e5 First pass at implementing concurrent index builds using multiple connections.
Adds a new --jobs command-line argument to specify how many worker
connections you want. These worker connections should stick around
while processing table(s) in a single database. For each table,
parcel out the indexes to be built among these worker conns,
submitting each CREATE INDEX ... request using PQsendQuery() i.e.
in non-blocking fashion.

Most of this is still rather crude, in particular the
while (num_active_workers) ... loop in rebuild_indexes(), but
it seems to be working, so I'm committing here.
2012-12-10 21:08:01 -07:00
Daniele Varrazzo
fcd3f7eaae Added pg_repack runs to check the get_order_by definitions work 2012-12-09 12:11:10 +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
Josh Kupershmidt
9d776b3980 Likely fix for Issue #4 -- make sure params[] is long enough for two strings. 2012-12-08 18:57:27 -07: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
6fc41e9c1a Fix 'installcheck', since the last commit broke the expected output when the table is missing a valid primary/unique key. 2012-12-06 21:26:12 -07:00
Josh Kupershmidt
66ae2f33a7 Downgrade ERROR to WARNING in the case where a table does not have a primary key or not-null unique key.
We want to be able to keep processing further tables if we
encounter this problem on one of many --tables.
2012-12-06 21:05:54 -07:00
Josh Kupershmidt
f6ca290fb2 Support for multiple --tables, as well as Concurrent DDL Guard.
Code merged in, with a few more changes, from the multiple_tables branch.

The multiple --table support and SimpleStringList code is largely
borrowed from pg_dump. (pg_reorg Issue #18).

The concurrent DDL guard is implemented using an auxiliary
database connection (pg_reorg Issue #8) which holds an ACCESS SHARE
lock on the target table while pg_repack conducts the rest of its work.
2012-12-06 20:58:33 -07:00
Josh Kupershmidt
a072cc9812 Ignore other pg_repack clients which may be running concurrently for the purposes of SQL_XID_SNAPSHOT.
Use application_name from pg_stat_activity, if available, to identify
other pg_repack clients. Fixes Issue #1.
2012-12-06 16:11:55 -07:00
Daniele Varrazzo
1a0a28d3f8 Bugtrack url changed to pg_repack's one 2012-12-01 12:58:50 +00:00
Daniele Varrazzo
c395f72a1c Some docs clarification if you find a stray trigger 2012-12-01 12:50:27 +00:00
Josh Kupershmidt
fbcd24b4e0 Have the client double-check that it is connected as a database superuser before plowing through initialization steps.
Addresses Issue #2.
2012-11-30 20:09:22 -07:00
Josh Kupershmidt
3b856623fd Add comment explaining how race condition between CREATE TABLE ... AS SELECT and recording of log entries is avoided. 2012-11-29 20:27:33 -07:00
Josh Kupershmidt
d402a73e42 No need to use strlen() with StringInfoData. 2012-11-26 20:08:47 -07:00
Daniele Varrazzo
7e4f811381 Style of definitions lists in the docs improved 2012-11-22 23:23:30 +00:00
Josh Kupershmidt
06a38f4a99 Typofix from last commit. 2012-11-19 07:42:21 -07:00
Daniele Varrazzo
c756d13a55 Docs cleanup by Josh 2012-11-19 11:13:33 +00:00
Daniele Varrazzo
520870ca2e Try rst2html.py too to render the docs 2012-11-19 11:07:00 +00:00
Josh Kupershmidt
3c13a0d05e Don't forget to disconnect conn2 when disconnect() is called, otherwise
we leave a connection hanging open for every database processed
via pg_repack -a.
2012-11-18 14:36:09 -07:00
Daniele Varrazzo
580307f79e Mention Slony fix for pg_repack 1.1.8 (issue #4) 2012-11-16 22:32:59 +00: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
Josh Kupershmidt
3c73a0204a More consistent error reporting
This patch is a port of Daniele's commit 0be414ad10c32d from his own fork,
"error_reporting" branch.

reorg_all_database can return an error message: in case of any error different
from "missing schema" return the error and keep processing the other databases
instead of printing and stopping the program.

The output of the program is now something like:

    $ pg_reorg --all
    pg_reorg: reorg database "contrib_regression"
    pg_reorg: reorg database "template1" ... skipped: pg_reorg is not installed in the database
2012-11-16 15:37:31 +00:00
Josh Kupershmidt
8ba92a1f49 Rename argument to simple_string_list_size() for consistency. 2012-11-16 15:27:53 +00:00
Josh Kupershmidt
decd822393 Move simple_string_list_size() into pgut.c, with the rest of these string functions.
Also, fix an error with this function not actually using its string_list argument.
2012-11-16 15:27:53 +00:00
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