Merge branch 'pg94'

This commit is contained in:
Daniele Varrazzo 2015-03-10 15:22:00 +00:00
commit 4065470982
8 changed files with 30 additions and 18 deletions

View File

@ -2,7 +2,7 @@
"name": "pg_repack",
"abstract": "PostgreSQL module for data reorganization",
"description": "Reorganize tables in PostgreSQL databases with minimal locks",
"version": "1.3.0",
"version": "1.3.1-pg94",
"maintainer": [
"Josh Kupershmidt <schmiddy@gmail.com>",
"Daniele Varrazzo <daniele.varrazzo@gmail.com>",
@ -14,7 +14,7 @@
"provides": {
"pg_repack": {
"file": "lib/pg_repack.sql",
"version": "1.3.0",
"version": "1.3.1-pg94",
"abstract": "Reorganize tables in PostgreSQL databases with minimal locks"
}
},

View File

@ -29,10 +29,6 @@ ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
$(error $(EXTENSION) requires PostgreSQL 8.3 or later. This is $(VERSION))
endif
ifeq ($(shell echo $$(($(INTVERSION) >= 904))),1)
$(error $(EXTENSION) does not yet support PostgreSQL 9.4 or later. This is $(VERSION))
endif
SUBDIRS = bin lib regress
all install installdirs uninstall distprep clean distclean maintainer-clean debug:

View File

@ -840,7 +840,7 @@ elog(int elevel, const char *fmt, ...)
do
{
va_start(args, fmt);
ok = appendStringInfoVA(&edata->msg, fmt, args);
ok = pgut_appendStringInfoVA(&edata->msg, fmt, args);
va_end(args);
} while (!ok);
len = strlen(fmt);
@ -1005,7 +1005,7 @@ errmsg(const char *fmt,...)
do
{
va_start(args, fmt);
ok = appendStringInfoVA(&edata->msg, fmt, args);
ok = pgut_appendStringInfoVA(&edata->msg, fmt, args);
va_end(args);
} while (!ok);
len = strlen(fmt);
@ -1026,7 +1026,7 @@ errdetail(const char *fmt,...)
do
{
va_start(args, fmt);
ok = appendStringInfoVA(&edata->detail, fmt, args);
ok = pgut_appendStringInfoVA(&edata->detail, fmt, args);
va_end(args);
} while (!ok);
trimStringBuffer(&edata->detail);
@ -1212,7 +1212,7 @@ exit_or_abort(int exitcode)
* unlike the server code, this function automatically extend the buffer.
*/
bool
appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
pgut_appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
{
size_t avail;
int nprinted;

View File

@ -150,7 +150,7 @@ extern void CHECK_FOR_INTERRUPTS(void);
#define appendStringInfoChar appendPQExpBufferChar
#define appendBinaryStringInfo appendBinaryPQExpBuffer
extern bool appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
extern bool pgut_appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
__attribute__((format(printf, 2, 0)));
extern int appendStringInfoFile(StringInfo str, FILE *fp);
extern int appendStringInfoFd(StringInfo str, int fd);

View File

@ -441,6 +441,10 @@ the original index.
Releases
--------
* pg_repack 1.3.1
* Added support for PostgreSQL 9.4.
* pg_repack 1.3
* Added ``--schema`` to repack only the specified schema (issue #20).

View File

@ -172,7 +172,10 @@ CREATE VIEW repack.tables AS
SELECT R.oid::regclass AS relname,
R.oid AS relid,
R.reltoastrelid AS reltoastrelid,
CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE (SELECT reltoastidxid FROM pg_class WHERE oid = R.reltoastrelid) END AS reltoastidxid,
CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE (
SELECT indexrelid FROM pg_index
WHERE indrelid = R.reltoastrelid
AND indisvalid) END AS reltoastidxid,
N.nspname AS schemaname,
PK.indexrelid AS pkid,
CK.indexrelid AS ckid,

View File

@ -29,11 +29,20 @@ termStringInfo(StringInfo str)
static void
appendStringInfoVA_s(StringInfo str, const char *fmt, va_list args)
{
#if PG_VERSION_NUM >= 90400
int needed;
while ((needed = appendStringInfoVA(str, fmt, args)) > 0)
{
/* Double the buffer size and try again. */
enlargeStringInfo(str, needed);
}
#else
while (!appendStringInfoVA(str, fmt, args))
{
/* Double the buffer size and try again. */
enlargeStringInfo(str, str->maxlen);
}
#endif
}
/* simple execute */

View File

@ -784,12 +784,12 @@ repack_swap(PG_FUNCTION_ARGS)
/* swap relfilenode and dependencies for tables. */
values[0] = ObjectIdGetDatum(oid);
execute_with_args(SPI_OK_SELECT,
"SELECT X.reltoastrelid, TX.reltoastidxid, X.relowner,"
" Y.oid, Y.reltoastrelid, TY.reltoastidxid, Y.relowner"
" FROM pg_catalog.pg_class X LEFT JOIN pg_catalog.pg_class TX"
" ON X.reltoastrelid = TX.oid,"
" pg_catalog.pg_class Y LEFT JOIN pg_catalog.pg_class TY"
" ON Y.reltoastrelid = TY.oid"
"SELECT X.reltoastrelid, TX.indexrelid, X.relowner,"
" Y.oid, Y.reltoastrelid, TY.indexrelid, Y.relowner"
" FROM pg_catalog.pg_class X LEFT JOIN pg_catalog.pg_index TX"
" ON X.reltoastrelid = TX.indrelid AND TX.indisvalid,"
" pg_catalog.pg_class Y LEFT JOIN pg_catalog.pg_index TY"
" ON Y.reltoastrelid = TY.indrelid AND TY.indisvalid"
" WHERE X.oid = $1"
" AND Y.oid = ('repack.table_' || X.oid)::regclass",
1, argtypes, values, nulls);