Adds test for basic alter statements

pull/7178/head
gindibay 2023-09-04 18:44:26 +03:00
parent ae6c22606d
commit e1c06576cc
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,47 @@
--since ALLOW_CONNECTIONS alter option should be executed in a different database
-- and since we don't have a multiple database support for now,
-- this statement will get error
alter database regression ALLOW_CONNECTIONS false;
ERROR: ALLOW_CONNECTIONS is not supported
DO $$
declare
v_connlimit numeric;
v_connlimit_fetched int;
begin
select datconnlimit into v_connlimit from pg_database where datname = 'regression';
alter database regression with CONNECTION LIMIT 100;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched;
execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched;
end;
$$
language plpgsql;
NOTICE: v_connlimit: -1, v_connlimit_fetched: 100
CONTEXT: PL/pgSQL function inline_code_block line XX at RAISE
NOTICE: v_connlimit: -1, v_connlimit_fetched: -1
CONTEXT: PL/pgSQL function inline_code_block line XX at RAISE
alter database regression with IS_TEMPLATE true;
select datistemplate from pg_database where datname = 'regression';
datistemplate
---------------------------------------------------------------------
t
(1 row)
alter database regression with IS_TEMPLATE false;
select datistemplate from pg_database where datname = 'regression';
datistemplate
---------------------------------------------------------------------
f
(1 row)
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
alter database regression REFRESH COLLATION VERSION;
NOTICE: version has not changed
NOTICE: issuing ALTER DATABASE regression REFRESH COLLATION VERSION;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing ALTER DATABASE regression REFRESH COLLATION VERSION;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
set citus.log_remote_commands = false;

View File

@ -51,6 +51,7 @@ test: multi_metadata_attributes
test: multi_read_from_secondaries
test: grant_on_database_propagation
test: alter_database_propagation
# ----------
# multi_citus_tools tests utility functions written for citus tools

View File

@ -0,0 +1,38 @@
--since ALLOW_CONNECTIONS alter option should be executed in a different database
-- and since we don't have a multiple database support for now,
-- this statement will get error
alter database regression ALLOW_CONNECTIONS false;
DO $$
declare
v_connlimit numeric;
v_connlimit_fetched int;
begin
select datconnlimit into v_connlimit from pg_database where datname = 'regression';
alter database regression with CONNECTION LIMIT 100;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched;
execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched;
end;
$$
language plpgsql;
alter database regression with IS_TEMPLATE true;
select datistemplate from pg_database where datname = 'regression';
alter database regression with IS_TEMPLATE false;
select datistemplate from pg_database where datname = 'regression';
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
alter database regression REFRESH COLLATION VERSION;
set citus.log_remote_commands = false;