Merge pull request #114 from bossartn/no_superuser_check
Introduce --no-superuser-check option.
This commit is contained in:
commit
7c8e272b54
@ -250,6 +250,7 @@ static int jobs = 0; /* number of concurrent worker conns. */
|
|||||||
static bool dryrun = false;
|
static bool dryrun = false;
|
||||||
static unsigned int temp_obj_num = 0; /* temporary objects counter */
|
static unsigned int temp_obj_num = 0; /* temporary objects counter */
|
||||||
static bool no_kill_backend = false; /* abandon when timed-out */
|
static bool no_kill_backend = false; /* abandon when timed-out */
|
||||||
|
static bool no_superuser_check = false;
|
||||||
|
|
||||||
/* buffer should have at least 11 bytes */
|
/* buffer should have at least 11 bytes */
|
||||||
static char *
|
static char *
|
||||||
@ -276,6 +277,7 @@ static pgut_option options[] =
|
|||||||
{ 'B', 'Z', "no-analyze", &analyze },
|
{ 'B', 'Z', "no-analyze", &analyze },
|
||||||
{ 'i', 'j', "jobs", &jobs },
|
{ 'i', 'j', "jobs", &jobs },
|
||||||
{ 'b', 'D', "no-kill-backend", &no_kill_backend },
|
{ 'b', 'D', "no-kill-backend", &no_kill_backend },
|
||||||
|
{ 'b', 'k', "no-superuser-check", &no_superuser_check },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -378,6 +380,9 @@ is_superuser(void)
|
|||||||
{
|
{
|
||||||
const char *val;
|
const char *val;
|
||||||
|
|
||||||
|
if (no_superuser_check)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!connection)
|
if (!connection)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2094,4 +2099,5 @@ pgut_help(bool details)
|
|||||||
printf(" -T, --wait-timeout=SECS timeout to cancel other backends on conflict\n");
|
printf(" -T, --wait-timeout=SECS timeout to cancel other backends on conflict\n");
|
||||||
printf(" -D, --no-kill-backend don't kill other backends when timed out\n");
|
printf(" -D, --no-kill-backend don't kill other backends when timed out\n");
|
||||||
printf(" -Z, --no-analyze don't analyze at end\n");
|
printf(" -Z, --no-analyze don't analyze at end\n");
|
||||||
|
printf(" -k, --no-superuser-check skip superuser checks in client\n");
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,7 @@ Options:
|
|||||||
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
|
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
|
||||||
-D, --no-kill-backend don't kill other backends when timed out
|
-D, --no-kill-backend don't kill other backends when timed out
|
||||||
-Z, --no-analyze don't analyze at end
|
-Z, --no-analyze don't analyze at end
|
||||||
|
-k, --no-superuser-check skip superuser checks in client
|
||||||
|
|
||||||
Connection options:
|
Connection options:
|
||||||
-d, --dbname=DBNAME database to connect
|
-d, --dbname=DBNAME database to connect
|
||||||
@ -217,6 +218,10 @@ Reorg Options
|
|||||||
Disable ANALYZE after a full-table reorganization. If not specified, run
|
Disable ANALYZE after a full-table reorganization. If not specified, run
|
||||||
ANALYZE after the reorganization.
|
ANALYZE after the reorganization.
|
||||||
|
|
||||||
|
``-k``, ``--no-superuser-check``
|
||||||
|
Skip the superuser checks in the client. This setting is useful for using
|
||||||
|
pg_repack on platforms that support running it as non-superusers.
|
||||||
|
|
||||||
|
|
||||||
Connection Options
|
Connection Options
|
||||||
^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -386,3 +386,20 @@ ERROR: cannot repack specific schema(s) in all databases
|
|||||||
--
|
--
|
||||||
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend
|
||||||
INFO: repacking table "tbl_cluster"
|
INFO: repacking table "tbl_cluster"
|
||||||
|
--
|
||||||
|
-- no superuser check
|
||||||
|
--
|
||||||
|
DROP ROLE IF EXISTS nosuper;
|
||||||
|
CREATE ROLE nosuper WITH LOGIN;
|
||||||
|
-- => OK
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
|
||||||
|
INFO: repacking table "tbl_cluster"
|
||||||
|
-- => ERROR
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper
|
||||||
|
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;
|
||||||
|
@ -232,3 +232,16 @@ CREATE TABLE test_schema2.tbl2 (id INTEGER PRIMARY KEY);
|
|||||||
-- don't kill backend
|
-- don't kill backend
|
||||||
--
|
--
|
||||||
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend
|
||||||
|
|
||||||
|
--
|
||||||
|
-- no superuser check
|
||||||
|
--
|
||||||
|
DROP ROLE IF EXISTS nosuper;
|
||||||
|
CREATE ROLE nosuper WITH LOGIN;
|
||||||
|
-- => OK
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
|
||||||
|
-- => ERROR
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper
|
||||||
|
-- => ERROR
|
||||||
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper --no-superuser-check
|
||||||
|
DROP ROLE IF EXISTS nosuper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user