Skip to content

Commit 4065470

Browse files
committed
Merge branch 'pg94'
2 parents f76fef9 + 74621ec commit 4065470

File tree

8 files changed

+30
-18
lines changed

8 files changed

+30
-18
lines changed

META.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pg_repack",
33
"abstract": "PostgreSQL module for data reorganization",
44
"description": "Reorganize tables in PostgreSQL databases with minimal locks",
5-
"version": "1.3.0",
5+
"version": "1.3.1-pg94",
66
"maintainer": [
77
"Josh Kupershmidt <schmiddy@gmail.com>",
88
"Daniele Varrazzo <daniele.varrazzo@gmail.com>",
@@ -14,7 +14,7 @@
1414
"provides": {
1515
"pg_repack": {
1616
"file": "lib/pg_repack.sql",
17-
"version": "1.3.0",
17+
"version": "1.3.1-pg94",
1818
"abstract": "Reorganize tables in PostgreSQL databases with minimal locks"
1919
}
2020
},

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ ifeq ($(shell echo $$(($(INTVERSION) < 803))),1)
2929
$(error $(EXTENSION) requires PostgreSQL 8.3 or later. This is $(VERSION))
3030
endif
3131

32-
ifeq ($(shell echo $$(($(INTVERSION) >= 904))),1)
33-
$(error $(EXTENSION) does not yet support PostgreSQL 9.4 or later. This is $(VERSION))
34-
endif
35-
3632
SUBDIRS = bin lib regress
3733

3834
all install installdirs uninstall distprep clean distclean maintainer-clean debug:

bin/pgut/pgut.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ elog(int elevel, const char *fmt, ...)
840840
do
841841
{
842842
va_start(args, fmt);
843-
ok = appendStringInfoVA(&edata->msg, fmt, args);
843+
ok = pgut_appendStringInfoVA(&edata->msg, fmt, args);
844844
va_end(args);
845845
} while (!ok);
846846
len = strlen(fmt);
@@ -1005,7 +1005,7 @@ errmsg(const char *fmt,...)
10051005
do
10061006
{
10071007
va_start(args, fmt);
1008-
ok = appendStringInfoVA(&edata->msg, fmt, args);
1008+
ok = pgut_appendStringInfoVA(&edata->msg, fmt, args);
10091009
va_end(args);
10101010
} while (!ok);
10111011
len = strlen(fmt);
@@ -1026,7 +1026,7 @@ errdetail(const char *fmt,...)
10261026
do
10271027
{
10281028
va_start(args, fmt);
1029-
ok = appendStringInfoVA(&edata->detail, fmt, args);
1029+
ok = pgut_appendStringInfoVA(&edata->detail, fmt, args);
10301030
va_end(args);
10311031
} while (!ok);
10321032
trimStringBuffer(&edata->detail);
@@ -1212,7 +1212,7 @@ exit_or_abort(int exitcode)
12121212
* unlike the server code, this function automatically extend the buffer.
12131213
*/
12141214
bool
1215-
appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
1215+
pgut_appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
12161216
{
12171217
size_t avail;
12181218
int nprinted;

bin/pgut/pgut.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ extern void CHECK_FOR_INTERRUPTS(void);
150150
#define appendStringInfoChar appendPQExpBufferChar
151151
#define appendBinaryStringInfo appendBinaryPQExpBuffer
152152

153-
extern bool appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
153+
extern bool pgut_appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
154154
__attribute__((format(printf, 2, 0)));
155155
extern int appendStringInfoFile(StringInfo str, FILE *fp);
156156
extern int appendStringInfoFd(StringInfo str, int fd);

doc/pg_repack.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ the original index.
441441
Releases
442442
--------
443443

444+
* pg_repack 1.3.1
445+
446+
* Added support for PostgreSQL 9.4.
447+
444448
* pg_repack 1.3
445449

446450
* Added ``--schema`` to repack only the specified schema (issue #20).

lib/pg_repack.sql.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ CREATE VIEW repack.tables AS
172172
SELECT R.oid::regclass AS relname,
173173
R.oid AS relid,
174174
R.reltoastrelid AS reltoastrelid,
175-
CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE (SELECT reltoastidxid FROM pg_class WHERE oid = R.reltoastrelid) END AS reltoastidxid,
175+
CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE (
176+
SELECT indexrelid FROM pg_index
177+
WHERE indrelid = R.reltoastrelid
178+
AND indisvalid) END AS reltoastidxid,
176179
N.nspname AS schemaname,
177180
PK.indexrelid AS pkid,
178181
CK.indexrelid AS ckid,

lib/pgut/pgut-spi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ termStringInfo(StringInfo str)
2929
static void
3030
appendStringInfoVA_s(StringInfo str, const char *fmt, va_list args)
3131
{
32+
#if PG_VERSION_NUM >= 90400
33+
int needed;
34+
while ((needed = appendStringInfoVA(str, fmt, args)) > 0)
35+
{
36+
/* Double the buffer size and try again. */
37+
enlargeStringInfo(str, needed);
38+
}
39+
#else
3240
while (!appendStringInfoVA(str, fmt, args))
3341
{
3442
/* Double the buffer size and try again. */
3543
enlargeStringInfo(str, str->maxlen);
3644
}
45+
#endif
3746
}
3847

3948
/* simple execute */

lib/repack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@ repack_swap(PG_FUNCTION_ARGS)
784784
/* swap relfilenode and dependencies for tables. */
785785
values[0] = ObjectIdGetDatum(oid);
786786
execute_with_args(SPI_OK_SELECT,
787-
"SELECT X.reltoastrelid, TX.reltoastidxid, X.relowner,"
788-
" Y.oid, Y.reltoastrelid, TY.reltoastidxid, Y.relowner"
789-
" FROM pg_catalog.pg_class X LEFT JOIN pg_catalog.pg_class TX"
790-
" ON X.reltoastrelid = TX.oid,"
791-
" pg_catalog.pg_class Y LEFT JOIN pg_catalog.pg_class TY"
792-
" ON Y.reltoastrelid = TY.oid"
787+
"SELECT X.reltoastrelid, TX.indexrelid, X.relowner,"
788+
" Y.oid, Y.reltoastrelid, TY.indexrelid, Y.relowner"
789+
" FROM pg_catalog.pg_class X LEFT JOIN pg_catalog.pg_index TX"
790+
" ON X.reltoastrelid = TX.indrelid AND TX.indisvalid,"
791+
" pg_catalog.pg_class Y LEFT JOIN pg_catalog.pg_index TY"
792+
" ON Y.reltoastrelid = TY.indrelid AND TY.indisvalid"
793793
" WHERE X.oid = $1"
794794
" AND Y.oid = ('repack.table_' || X.oid)::regclass",
795795
1, argtypes, values, nulls);

0 commit comments

Comments
 (0)