mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
Require superuser for BGW start/stop/restart
Start requiring superuser privileges to start/stop/restart background workers.
This commit is contained in:
parent
e049238a07
commit
afdb3269a8
@ -61,17 +61,32 @@ ts_bgw_num_unreserved(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
ts_bgw_db_workers_start(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to start background workers"))));
|
||||
|
||||
PG_RETURN_BOOL(ts_bgw_message_send_and_wait(START, MyDatabaseId));
|
||||
}
|
||||
|
||||
Datum
|
||||
ts_bgw_db_workers_stop(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to stop background workers"))));
|
||||
|
||||
PG_RETURN_BOOL(ts_bgw_message_send_and_wait(STOP, MyDatabaseId));
|
||||
}
|
||||
|
||||
Datum
|
||||
ts_bgw_db_workers_restart(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to restart background workers"))));
|
||||
|
||||
PG_RETURN_BOOL(ts_bgw_message_send_and_wait(RESTART, MyDatabaseId));
|
||||
}
|
||||
|
@ -901,13 +901,21 @@ SELECT * FROM sorted_bgw_log;
|
||||
|
||||
-- Test updating jobs list
|
||||
TRUNCATE bgw_log;
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT _timescaledb_internal.stop_background_workers();
|
||||
ERROR: must be superuser to stop background workers
|
||||
SELECT _timescaledb_internal.restart_background_workers();
|
||||
ERROR: must be superuser to restart background workers
|
||||
SELECT _timescaledb_internal.start_background_workers();
|
||||
ERROR: must be superuser to start background workers
|
||||
\set ON_ERROR_STOP 1
|
||||
\c :TEST_DBNAME :ROLE_SUPERUSER
|
||||
SELECT _timescaledb_internal.stop_background_workers();
|
||||
stop_background_workers
|
||||
-------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
\c :TEST_DBNAME :ROLE_SUPERUSER
|
||||
CREATE OR REPLACE FUNCTION ts_test_job_refresh() RETURNS TABLE(
|
||||
id INTEGER,
|
||||
application_name NAME,
|
||||
|
@ -381,9 +381,16 @@ SELECT * FROM sorted_bgw_log;
|
||||
|
||||
-- Test updating jobs list
|
||||
TRUNCATE bgw_log;
|
||||
|
||||
\set ON_ERROR_STOP 0
|
||||
SELECT _timescaledb_internal.stop_background_workers();
|
||||
SELECT _timescaledb_internal.restart_background_workers();
|
||||
SELECT _timescaledb_internal.start_background_workers();
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
\c :TEST_DBNAME :ROLE_SUPERUSER
|
||||
SELECT _timescaledb_internal.stop_background_workers();
|
||||
|
||||
CREATE OR REPLACE FUNCTION ts_test_job_refresh() RETURNS TABLE(
|
||||
id INTEGER,
|
||||
application_name NAME,
|
||||
|
Loading…
x
Reference in New Issue
Block a user