mirror of https://github.com/citusdata/citus.git
Moves code from the branch
parent
312051e93d
commit
7ad5a2479b
|
@ -159,6 +159,25 @@ static const NonMainDbDistributeObjectOps Any_DropDatabase = {
|
|||
.getUnmarkDistributedParams = NULL,
|
||||
.cannotBeExecutedInTransaction = true
|
||||
};
|
||||
|
||||
static const NonMainDbDistributeObjectOps Any_AlterDatabase = {
|
||||
.getMarkDistributedParams = NULL,
|
||||
.getUnmarkDistributedParams = NULL,
|
||||
.cannotBeExecutedInTransaction = true
|
||||
};
|
||||
|
||||
static const NonMainDbDistributeObjectOps Any_AlterDatabaseSet = {
|
||||
.getMarkDistributedParams = NULL,
|
||||
.getUnmarkDistributedParams = NULL,
|
||||
.cannotBeExecutedInTransaction = true
|
||||
};
|
||||
|
||||
static const NonMainDbDistributeObjectOps Any_AlterDatabaseRefreshColl = {
|
||||
.getMarkDistributedParams = NULL,
|
||||
.getUnmarkDistributedParams = NULL,
|
||||
.cannotBeExecutedInTransaction = false
|
||||
};
|
||||
|
||||
static const NonMainDbDistributeObjectOps Database_Grant = {
|
||||
.getMarkDistributedParams = NULL,
|
||||
.getUnmarkDistributedParams = NULL,
|
||||
|
@ -329,6 +348,35 @@ GetNonMainDbDistributeObjectOps(Node *parsetree)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
case T_AlterDatabaseStmt:
|
||||
{
|
||||
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, parsetree);
|
||||
|
||||
/*
|
||||
* We don't try to send the query to the main database if the ALTER
|
||||
* DATABASE command is for the main database itself, this is a very
|
||||
* rare case but it's exercised by our test suite.
|
||||
*/
|
||||
if (strcmp(stmt->dbname, MainDb) != 0)
|
||||
{
|
||||
return &Any_AlterDatabase;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
case T_AlterDatabaseSetStmt:
|
||||
{
|
||||
return &Any_AlterDatabaseSet;
|
||||
|
||||
}
|
||||
#if PG_VERSION_NUM >= PG_VERSION_15
|
||||
case T_AlterDatabaseRefreshCollStmt:
|
||||
{
|
||||
return &Any_AlterDatabaseRefreshColl;
|
||||
}
|
||||
#endif
|
||||
|
||||
case T_GrantStmt:
|
||||
{
|
||||
GrantStmt *stmt = castNode(GrantStmt, parsetree);
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
SET citus.superuser TO 'postgres';
|
||||
set citus.enable_create_database_propagation=on;
|
||||
create database test_alter_db_from_nonmain_db;
|
||||
create database altered_database;
|
||||
reset citus.enable_create_database_propagation;
|
||||
\c regression;
|
||||
set citus.enable_create_database_propagation=on;
|
||||
\c test_alter_db_from_nonmain_db
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = "%ALTER DATABASE%";
|
||||
alter database altered_database rename to altered_database_renamed;
|
||||
alter database altered_database_renamed rename to altered_database;
|
||||
alter database altered_database with
|
||||
ALLOW_CONNECTIONS false
|
||||
CONNECTION LIMIT 1
|
||||
IS_TEMPLATE true;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS false CONNECTION LIMIT 1 IS_TEMPLATE true;', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database with
|
||||
ALLOW_CONNECTIONS true
|
||||
CONNECTION LIMIT 0
|
||||
IS_TEMPLATE false;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database WITH ALLOW_CONNECTIONS true CONNECTION LIMIT 0 IS_TEMPLATE false;', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
\c regression
|
||||
create role test_owner_non_main_db;
|
||||
\c test_alter_db_from_nonmain_db
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = "%ALTER DATABASE%";
|
||||
set citus.enable_create_database_propagation=on;
|
||||
alter database altered_database owner to test_owner_non_main_db;
|
||||
alter database altered_database owner to CURRENT_USER;
|
||||
alter database altered_database set default_transaction_read_only = true;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only = ''true''', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
set default_transaction_read_only = false;
|
||||
alter database altered_database set default_transaction_read_only from current;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only FROM CURRENT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set default_transaction_read_only to DEFAULT;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_read_only TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET default_transaction_read_only;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET default_transaction_read_only', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database SET TIME ZONE '-7';
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone = ''-7''', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set TIME ZONE LOCAL;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set TIME ZONE DEFAULT;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET timezone TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET TIME ZONE;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET timezone', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET TIME ZONE INTERVAL ''@ 8 hours ago''', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET TIME ZONE;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET timezone', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set default_transaction_isolation = 'serializable';
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation = ''serializable''', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
set default_transaction_isolation = 'read committed';
|
||||
alter database altered_database set default_transaction_isolation from current;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation FROM CURRENT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set default_transaction_isolation to DEFAULT;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET default_transaction_isolation TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET default_transaction_isolation;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET default_transaction_isolation', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set statement_timeout = 1000;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout = 1000', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
set statement_timeout = 2000;
|
||||
alter database altered_database set statement_timeout from current;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout FROM CURRENT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set statement_timeout to DEFAULT;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET statement_timeout TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET statement_timeout;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET statement_timeout', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set lock_timeout = 1201.5;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout = 1201.5', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
set lock_timeout = 1202.5;
|
||||
alter database altered_database set lock_timeout from current;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout FROM CURRENT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database set lock_timeout to DEFAULT;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database SET lock_timeout TO DEFAULT', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
alter database altered_database RESET lock_timeout;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET lock_timeout', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
ALTER DATABASE altered_database RESET ALL;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database RESET ALL', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
\c regression
|
||||
set citus.enable_create_database_propagation=on;
|
||||
drop database altered_database;
|
||||
drop database test_alter_db_from_nonmain_db;
|
||||
reset citus.enable_create_database_propagation;
|
||||
drop role test_owner_non_main_db;
|
|
@ -1546,3 +1546,19 @@ SET client_min_messages TO ERROR;
|
|||
DROP SCHEMA pg15 CASCADE;
|
||||
DROP ROLE rls_tenant_1;
|
||||
DROP ROLE rls_tenant_2;
|
||||
-- test refresh collation version on non-main databases
|
||||
SET citus.enable_create_database_propagation TO on;
|
||||
create database alter_db_from_nonmain_db_pg15;
|
||||
\c alter_db_from_nonmain_db_pg15
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = '%ALTER DATABASE%';
|
||||
ALTER DATABASE alter_db_from_nonmain_db_pg15 REFRESH COLLATION VERSION;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE alter_db_from_nonmain_db_pg15 REFRESH COLLATION VERSION;', 'postgres')
|
||||
NOTICE: version has not changed
|
||||
reset citus.log_remote_commands;
|
||||
reset citus.grep_remote_commands;
|
||||
\c regression
|
||||
SET citus.enable_create_database_propagation TO on;
|
||||
drop database alter_db_from_nonmain_db_pg15;
|
||||
reset citus.enable_create_database_propagation;
|
||||
SET citus.enable_create_database_propagation TO OFF;
|
||||
|
|
|
@ -63,6 +63,7 @@ test: alter_database_propagation
|
|||
|
||||
test: citus_shards
|
||||
test: reassign_owned
|
||||
test: alter_database_from_nonmain_db
|
||||
|
||||
# ----------
|
||||
# multi_citus_tools tests utility functions written for citus tools
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
SET citus.superuser TO 'postgres';
|
||||
set citus.enable_create_database_propagation=on;
|
||||
create database test_alter_db_from_nonmain_db;
|
||||
create database altered_database;
|
||||
reset citus.enable_create_database_propagation;
|
||||
\c regression;
|
||||
set citus.enable_create_database_propagation=on;
|
||||
\c test_alter_db_from_nonmain_db
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = "%ALTER DATABASE%";
|
||||
alter database altered_database rename to altered_database_renamed;
|
||||
alter database altered_database_renamed rename to altered_database;
|
||||
|
||||
alter database altered_database with
|
||||
ALLOW_CONNECTIONS false
|
||||
CONNECTION LIMIT 1
|
||||
IS_TEMPLATE true;
|
||||
alter database altered_database with
|
||||
ALLOW_CONNECTIONS true
|
||||
CONNECTION LIMIT 0
|
||||
IS_TEMPLATE false;
|
||||
|
||||
\c regression
|
||||
create role test_owner_non_main_db;
|
||||
\c test_alter_db_from_nonmain_db
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = "%ALTER DATABASE%";
|
||||
set citus.enable_create_database_propagation=on;
|
||||
alter database altered_database owner to test_owner_non_main_db;
|
||||
alter database altered_database owner to CURRENT_USER;
|
||||
alter database altered_database set default_transaction_read_only = true;
|
||||
set default_transaction_read_only = false;
|
||||
alter database altered_database set default_transaction_read_only from current;
|
||||
alter database altered_database set default_transaction_read_only to DEFAULT;
|
||||
alter database altered_database RESET default_transaction_read_only;
|
||||
alter database altered_database SET TIME ZONE '-7';
|
||||
alter database altered_database set TIME ZONE LOCAL;
|
||||
alter database altered_database set TIME ZONE DEFAULT;
|
||||
alter database altered_database RESET TIME ZONE;
|
||||
alter database altered_database SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE;
|
||||
alter database altered_database RESET TIME ZONE;
|
||||
alter database altered_database set default_transaction_isolation = 'serializable';
|
||||
set default_transaction_isolation = 'read committed';
|
||||
alter database altered_database set default_transaction_isolation from current;
|
||||
alter database altered_database set default_transaction_isolation to DEFAULT;
|
||||
alter database altered_database RESET default_transaction_isolation;
|
||||
alter database altered_database set statement_timeout = 1000;
|
||||
set statement_timeout = 2000;
|
||||
alter database altered_database set statement_timeout from current;
|
||||
alter database altered_database set statement_timeout to DEFAULT;
|
||||
alter database altered_database RESET statement_timeout;
|
||||
alter database altered_database set lock_timeout = 1201.5;
|
||||
set lock_timeout = 1202.5;
|
||||
alter database altered_database set lock_timeout from current;
|
||||
alter database altered_database set lock_timeout to DEFAULT;
|
||||
alter database altered_database RESET lock_timeout;
|
||||
ALTER DATABASE altered_database RESET ALL;
|
||||
\c regression
|
||||
set citus.enable_create_database_propagation=on;
|
||||
drop database altered_database;
|
||||
drop database test_alter_db_from_nonmain_db;
|
||||
reset citus.enable_create_database_propagation;
|
||||
|
||||
drop role test_owner_non_main_db;
|
|
@ -989,3 +989,21 @@ SET client_min_messages TO ERROR;
|
|||
DROP SCHEMA pg15 CASCADE;
|
||||
DROP ROLE rls_tenant_1;
|
||||
DROP ROLE rls_tenant_2;
|
||||
|
||||
-- test refresh collation version on non-main databases
|
||||
SET citus.enable_create_database_propagation TO on;
|
||||
create database alter_db_from_nonmain_db_pg15;
|
||||
|
||||
\c alter_db_from_nonmain_db_pg15
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = '%ALTER DATABASE%';
|
||||
ALTER DATABASE alter_db_from_nonmain_db_pg15 REFRESH COLLATION VERSION;
|
||||
|
||||
reset citus.log_remote_commands;
|
||||
reset citus.grep_remote_commands;
|
||||
|
||||
\c regression
|
||||
SET citus.enable_create_database_propagation TO on;
|
||||
drop database alter_db_from_nonmain_db_pg15;
|
||||
reset citus.enable_create_database_propagation;
|
||||
SET citus.enable_create_database_propagation TO OFF;
|
||||
|
|
Loading…
Reference in New Issue