Added version_sql() function and consistency check of sql version
This commit is contained in:
parent
1bcaf267b3
commit
deaae7dd72
@ -240,15 +240,18 @@ repack_one_database(const char *orderby, const char *table, char *errbuf, size_t
|
|||||||
reconnect(ERROR);
|
reconnect(ERROR);
|
||||||
|
|
||||||
/* Query the extension version. Exit if no match */
|
/* Query the extension version. Exit if no match */
|
||||||
res = execute_elevel("select repack.version()", 0, NULL, DEBUG2);
|
res = execute_elevel("select repack.version(), repack.version_sql()",
|
||||||
|
0, NULL, DEBUG2);
|
||||||
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
const char *libver;
|
const char *libver;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
/* the string is something like "pg_repack 1.1.7" */
|
/* the string is something like "pg_repack 1.1.7" */
|
||||||
libver = getstr(res, 0, 0);
|
|
||||||
snprintf(buf, sizeof(buf), "%s %s", PROGRAM_NAME, PROGRAM_VERSION);
|
snprintf(buf, sizeof(buf), "%s %s", PROGRAM_NAME, PROGRAM_VERSION);
|
||||||
|
|
||||||
|
/* check the version of the C library */
|
||||||
|
libver = getstr(res, 0, 0);
|
||||||
if (0 != strcmp(buf, libver))
|
if (0 != strcmp(buf, libver))
|
||||||
{
|
{
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
@ -257,6 +260,17 @@ repack_one_database(const char *orderby, const char *table, char *errbuf, size_t
|
|||||||
buf, libver);
|
buf, libver);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check the version of the SQL extension */
|
||||||
|
libver = getstr(res, 0, 1);
|
||||||
|
if (0 != strcmp(buf, libver))
|
||||||
|
{
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, errsize,
|
||||||
|
"extension '%s' required, found extension '%s'",
|
||||||
|
buf, libver);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -290,6 +290,13 @@ ERROR: program 'pg_repack V1' does not match database library 'pg_repack V2'
|
|||||||
database; if they are what expected you may need to repeat pg_repack
|
database; if they are what expected you may need to repeat pg_repack
|
||||||
installation.
|
installation.
|
||||||
|
|
||||||
|
ERROR: extension 'pg_repack V1' required, found extension 'pg_repack V2'
|
||||||
|
The SQL extension found in the database does not match the version
|
||||||
|
required by the pg_repack program.
|
||||||
|
|
||||||
|
You should drop the extension from the database and reload it as described
|
||||||
|
in the installation_ section.
|
||||||
|
|
||||||
ERROR: relation "table" has no primary key
|
ERROR: relation "table" has no primary key
|
||||||
The target table doesn't have PRIMARY KEY.
|
The target table doesn't have PRIMARY KEY.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ DATA_built = pg_repack.sql
|
|||||||
DATA = uninstall_pg_repack.sql
|
DATA = uninstall_pg_repack.sql
|
||||||
endif
|
endif
|
||||||
|
|
||||||
USE_PGXS = 1 # use pgxs if not in contrib directory
|
USE_PGXS = 1
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
|
|
||||||
@ -40,11 +40,12 @@ LIBS := $(filter-out -lxslt, $(LIBS))
|
|||||||
|
|
||||||
pg_repack.sql: pg_repack.sql.in
|
pg_repack.sql: pg_repack.sql.in
|
||||||
echo "BEGIN;\n" > $@; \
|
echo "BEGIN;\n" > $@; \
|
||||||
sed 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' $< >> $@; \
|
sed 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' $< \
|
||||||
|
| sed 's,REPACK_VERSION,$(REPACK_VERSION),g' >> $@; \
|
||||||
echo "\nCOMMIT;" >> $@;
|
echo "\nCOMMIT;" >> $@;
|
||||||
|
|
||||||
pg_repack--$(REPACK_VERSION).sql: pg_repack.sql.in
|
pg_repack--$(REPACK_VERSION).sql: pg_repack.sql.in
|
||||||
cat $< > $@;
|
sed 's,REPACK_VERSION,$(REPACK_VERSION),g' $< > $@;
|
||||||
|
|
||||||
pg_repack.control: pg_repack.control.in
|
pg_repack.control: pg_repack.control.in
|
||||||
sed 's,REPACK_VERSION,$(REPACK_VERSION),g' $< > $@
|
sed 's,REPACK_VERSION,$(REPACK_VERSION),g' $< > $@
|
||||||
|
@ -12,6 +12,10 @@ CREATE FUNCTION repack.version() RETURNS text AS
|
|||||||
'MODULE_PATHNAME', 'repack_version'
|
'MODULE_PATHNAME', 'repack_version'
|
||||||
LANGUAGE C IMMUTABLE STRICT;
|
LANGUAGE C IMMUTABLE STRICT;
|
||||||
|
|
||||||
|
CREATE FUNCTION repack.version_sql() RETURNS text AS
|
||||||
|
$$SELECT 'pg_repack REPACK_VERSION'::text$$
|
||||||
|
LANGUAGE SQL IMMUTABLE STRICT;
|
||||||
|
|
||||||
CREATE AGGREGATE repack.array_accum (
|
CREATE AGGREGATE repack.array_accum (
|
||||||
sfunc = array_append,
|
sfunc = array_append,
|
||||||
basetype = anyelement,
|
basetype = anyelement,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user