95 Commits

Author SHA1 Message Date
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
Daniele Varrazzo
77d27a14f3 Use the same title of README/docs for the extension 2012-11-15 13:53:06 +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
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
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
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