Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bin/pg_repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,12 @@ preliminary_checks(char *errbuf, size_t errsize){
}

/* Query the extension version. Exit if no match */
res = execute_elevel("select repack.version(), repack.version_sql()",
res = execute_elevel("select repack.version(), repack.version_sql(), current_setting('server_version_num')::int >= 90600",
0, NULL, DEBUG2);
if (PQresultStatus(res) == PGRES_TUPLES_OK)
{
const char *libver;
const char *has_iitst;
char buf[64];

/* the string is something like "pg_repack 1.1.7" */
Expand All @@ -518,6 +519,13 @@ preliminary_checks(char *errbuf, size_t errsize){
buf, libver);
goto cleanup;
}

/* If Postgres version is 9.6 or newer, disable idle-in-transaction timeout */
has_iitst = getstr(res, 0, 2);
if (0 == strcmp("t", has_iitst))
{
command("SET idle_in_transaction_session_timeout = 0", 0, NULL);
}
}
else
{
Expand Down Expand Up @@ -1703,6 +1711,10 @@ lock_access_share(PGconn *conn, Oid relid, const char *target_name)

termStringInfo(&sql);
pgut_command(conn, "RESET statement_timeout", 0, NULL);
if (PQserverVersion(conn) >= 90600)
{
pgut_command(conn, "RESET idle_in_transaction_session_timeout", 0, NULL);
}
return ret;
}

Expand Down
3 changes: 1 addition & 2 deletions regress/expected/nosuper.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET client_min_messages = error;
DROP ROLE IF EXISTS nosuper;
SET client_min_messages = warning;
CREATE ROLE nosuper WITH LOGIN;
GRANT USAGE ON SCHEMA repack TO nosuper;
-- => OK
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
INFO: repacking table "public.tbl_cluster"
Expand All @@ -14,6 +15,4 @@ ERROR: pg_repack failed with error: You must be a superuser to use pg_repack
-- => ERROR
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper --no-superuser-check
ERROR: pg_repack failed with error: ERROR: permission denied for schema repack
LINE 1: select repack.version(), repack.version_sql()
^
DROP ROLE IF EXISTS nosuper;
3 changes: 3 additions & 0 deletions regress/expected/nosuper_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET client_min_messages = error;
DROP ROLE IF EXISTS nosuper;
SET client_min_messages = warning;
CREATE ROLE nosuper WITH LOGIN;
GRANT USAGE ON SCHEMA repack TO nosuper;
-- => OK
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
INFO: repacking table "public.tbl_cluster"
Expand All @@ -14,4 +15,6 @@ ERROR: pg_repack failed with error: You must be a superuser to use pg_repack
-- => ERROR
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper --no-superuser-check
ERROR: pg_repack failed with error: ERROR: permission denied for schema repack
LINE 1: select repack.version(), repack.version_sql(), current_setting('server_version_num')::int >= 90600
^
DROP ROLE IF EXISTS nosuper;
1 change: 1 addition & 0 deletions regress/sql/nosuper.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET client_min_messages = error;
DROP ROLE IF EXISTS nosuper;
SET client_min_messages = warning;
CREATE ROLE nosuper WITH LOGIN;
GRANT USAGE ON SCHEMA repack TO nosuper;
-- => OK
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
-- => ERROR
Expand Down