Fixes review comments

pull/7172/head
gindibay 2023-09-07 10:27:58 +03:00
parent 01fb7c7db3
commit 25d6e8d4d9
5 changed files with 86 additions and 138 deletions

View File

@ -121,14 +121,9 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
else else
{ {
ereport(ERROR, ereport(ERROR,
errmsg("unrecognized AlterDatabaseStmt option: %s", errmsg("unrecognized ALTER DATABASE option: %s",
def->defname)); def->defname));
} }
if (cell != list_tail(stmt->options))
{
appendStringInfo(buf, ", ");
}
} }
} }

View File

@ -1,3 +1,5 @@
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
--since ALLOW_CONNECTIONS alter option should be executed in a different database --since ALLOW_CONNECTIONS alter option should be executed in a different database
-- and since we don't have a multiple database support for now, -- and since we don't have a multiple database support for now,
-- this statement will get error -- this statement will get error
@ -5,61 +7,73 @@ alter database regression ALLOW_CONNECTIONS false;
ERROR: ALLOW_CONNECTIONS is not supported ERROR: ALLOW_CONNECTIONS is not supported
DO $$ DO $$
declare declare
v_connlimit numeric; v_connlimit_initial numeric;
v_connlimit_fetched int; v_connlimit_fetched int;
begin begin
select datconnlimit into v_connlimit from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_initial from pg_database where datname = 'regression';
alter database regression with CONNECTION LIMIT 100; alter database regression with CONNECTION LIMIT 100;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched; raise notice 'v_connlimit_initial: %, v_connlimit_fetched: %', v_connlimit_initial, v_connlimit_fetched;
execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit; execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit_initial;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched; raise notice 'v_connlimit_initial: %, v_connlimit_fetched: %', v_connlimit_initial, v_connlimit_fetched;
alter database regression with IS_TEMPLATE true CONNECTION LIMIT 100;
execute 'alter database regression with IS_TEMPLATE false CONNECTION LIMIT' || v_connlimit_initial;
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';
end; end;
$$ $$
language plpgsql; language plpgsql;
NOTICE: v_connlimit: -1, v_connlimit_fetched: 100 NOTICE: issuing ALTER DATABASE regression WITH CONNECTION LIMIT 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)
DO $$
DECLARE
v_version_num int;
BEGIN
SELECT current_setting('server_version_num')::numeric INTO v_version_num;
IF v_version_num >= 150000 THEN
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
execute 'alter database regression REFRESH COLLATION VERSION';
set citus.log_remote_commands = false;
ELSE
RAISE NOTICE 'Skipping alter database .. REFRESH COLLATION VERSION for PostgreSQL version < 15.';
END IF;
END;
$$
language plpgsql;
NOTICE: version has not changed
CONTEXT: SQL statement "alter database regression REFRESH COLLATION VERSION"
PL/pgSQL function inline_code_block line XX at EXECUTE
NOTICE: issuing ALTER DATABASE regression REFRESH COLLATION VERSION;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression REFRESH COLLATION VERSION" CONTEXT: SQL statement "alter database regression with CONNECTION LIMIT 100"
PL/pgSQL function inline_code_block line XX at EXECUTE PL/pgSQL function inline_code_block line XX at SQL statement
NOTICE: issuing ALTER DATABASE regression REFRESH COLLATION VERSION; NOTICE: issuing ALTER DATABASE regression WITH CONNECTION LIMIT 100;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression REFRESH COLLATION VERSION" CONTEXT: SQL statement "alter database regression with CONNECTION LIMIT 100"
PL/pgSQL function inline_code_block line XX at SQL statement
NOTICE: v_connlimit_initial: -1, v_connlimit_fetched: 100
CONTEXT: PL/pgSQL function inline_code_block line XX at RAISE
NOTICE: issuing ALTER DATABASE regression WITH CONNECTION LIMIT -1;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with CONNECTION LIMIT -1"
PL/pgSQL function inline_code_block line XX at EXECUTE PL/pgSQL function inline_code_block line XX at EXECUTE
NOTICE: issuing ALTER DATABASE regression WITH CONNECTION LIMIT -1;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with CONNECTION LIMIT -1"
PL/pgSQL function inline_code_block line XX at EXECUTE
NOTICE: v_connlimit_initial: -1, v_connlimit_fetched: -1
CONTEXT: PL/pgSQL function inline_code_block line XX at RAISE
NOTICE: issuing ALTER DATABASE regression WITH is_template 'true' CONNECTION LIMIT 100;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE true CONNECTION LIMIT 100"
PL/pgSQL function inline_code_block line XX at SQL statement
NOTICE: issuing ALTER DATABASE regression WITH is_template 'true' CONNECTION LIMIT 100;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE true CONNECTION LIMIT 100"
PL/pgSQL function inline_code_block line XX at SQL statement
NOTICE: issuing ALTER DATABASE regression WITH is_template 'false' CONNECTION LIMIT -1;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE false CONNECTION LIMIT-1"
PL/pgSQL function inline_code_block line XX at EXECUTE
NOTICE: issuing ALTER DATABASE regression WITH is_template 'false' CONNECTION LIMIT -1;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE false CONNECTION LIMIT-1"
PL/pgSQL function inline_code_block line XX at EXECUTE
NOTICE: issuing ALTER DATABASE regression WITH is_template 'true';
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE true"
PL/pgSQL function inline_code_block line XX at SQL statement
NOTICE: issuing ALTER DATABASE regression WITH is_template 'true';
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
CONTEXT: SQL statement "alter database regression with IS_TEMPLATE true"
PL/pgSQL function inline_code_block line XX at SQL statement
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function inline_code_block line XX at SQL statement
set citus.log_remote_commands = false;

View File

@ -1,56 +0,0 @@
--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)
DO $$
DECLARE
v_version_num int;
BEGIN
SELECT current_setting('server_version_num')::numeric INTO v_version_num;
IF v_version_num >= 150000 THEN
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
execute 'alter database regression REFRESH COLLATION VERSION';
set citus.log_remote_commands = false;
ELSE
RAISE NOTICE 'Skipping alter database .. REFRESH COLLATION VERSION for PostgreSQL version < 15.';
END IF;
END;
$$
language plpgsql;
NOTICE: Skipping alter database .. REFRESH COLLATION VERSION for PostgreSQL version < 15.
CONTEXT: PL/pgSQL function inline_code_block line XX at RAISE

View File

@ -1,3 +1,6 @@
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
--since ALLOW_CONNECTIONS alter option should be executed in a different database --since ALLOW_CONNECTIONS alter option should be executed in a different database
-- and since we don't have a multiple database support for now, -- and since we don't have a multiple database support for now,
-- this statement will get error -- this statement will get error
@ -6,41 +9,28 @@ alter database regression ALLOW_CONNECTIONS false;
DO $$ DO $$
declare declare
v_connlimit numeric; v_connlimit_initial numeric;
v_connlimit_fetched int; v_connlimit_fetched int;
begin begin
select datconnlimit into v_connlimit from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_initial from pg_database where datname = 'regression';
alter database regression with CONNECTION LIMIT 100; alter database regression with CONNECTION LIMIT 100;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched; raise notice 'v_connlimit_initial: %, v_connlimit_fetched: %', v_connlimit_initial, v_connlimit_fetched;
execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit; execute 'alter database regression with CONNECTION LIMIT ' || v_connlimit_initial;
select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression'; select datconnlimit into v_connlimit_fetched from pg_database where datname = 'regression';
raise notice 'v_connlimit: %, v_connlimit_fetched: %', v_connlimit, v_connlimit_fetched; raise notice 'v_connlimit_initial: %, v_connlimit_fetched: %', v_connlimit_initial, v_connlimit_fetched;
alter database regression with IS_TEMPLATE true CONNECTION LIMIT 100;
execute 'alter database regression with IS_TEMPLATE false CONNECTION LIMIT' || v_connlimit_initial;
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';
end; end;
$$ $$
language plpgsql; language plpgsql;
alter database regression with IS_TEMPLATE true; set citus.log_remote_commands = false;
select datistemplate from pg_database where datname = 'regression';
alter database regression with IS_TEMPLATE false;
select datistemplate from pg_database where datname = 'regression';
DO $$
DECLARE
v_version_num int;
BEGIN
SELECT current_setting('server_version_num')::numeric INTO v_version_num;
IF v_version_num >= 150000 THEN
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
execute 'alter database regression REFRESH COLLATION VERSION';
set citus.log_remote_commands = false;
ELSE
RAISE NOTICE 'Skipping alter database .. REFRESH COLLATION VERSION for PostgreSQL version < 15.';
END IF;
END;
$$
language plpgsql;

View File

@ -965,6 +965,11 @@ SELECT (groupid = 0) AS is_coordinator, result FROM run_command_on_all_nodes(
JOIN pg_dist_node USING (nodeid) JOIN pg_dist_node USING (nodeid)
ORDER BY is_coordinator DESC, result; ORDER BY is_coordinator DESC, result;
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;
-- Clean up -- Clean up
\set VERBOSITY terse \set VERBOSITY terse
SET client_min_messages TO ERROR; SET client_min_messages TO ERROR;