mirror of https://github.com/citusdata/citus.git
Removes alter tablespace
parent
2ca4d3eba7
commit
5c5b19676b
|
@ -183,7 +183,7 @@ static bool ShouldCheckUndistributeCitusLocalTables(void);
|
|||
* Functions to support commands used to manage node-wide objects from non-main
|
||||
* databases.
|
||||
*/
|
||||
static bool IsCommandToCreateOrDropMainDB(Node *parsetree);
|
||||
static bool IsCommandMainDbDdlOperation(Node *parsetree);
|
||||
static void RunPreprocessMainDBCommand(Node *parsetree);
|
||||
static void RunPostprocessMainDBCommand(Node *parsetree);
|
||||
static bool IsStatementSupportedFromNonMainDb(Node *parsetree);
|
||||
|
@ -215,6 +215,7 @@ static const NonMainDbDistributedStatementInfo NonMainDbSupportedStatements[] =
|
|||
{ T_CreatedbStmt, NO_DIST_OBJECT_OPERATION, NULL },
|
||||
{ T_AlterDatabaseStmt, NO_DIST_OBJECT_OPERATION, NULL },
|
||||
{ T_AlterDatabaseSetStmt, NO_DIST_OBJECT_OPERATION, NULL },
|
||||
{ T_AlterDatabaseRefreshCollStmt, NO_DIST_OBJECT_OPERATION, NULL },
|
||||
{ T_DropdbStmt, NO_DIST_OBJECT_OPERATION, NULL },
|
||||
{ T_SecLabelStmt, NO_DIST_OBJECT_OPERATION,
|
||||
NonMainDbCheckSupportedObjectTypeForSecLabel },
|
||||
|
@ -360,12 +361,13 @@ citus_ProcessUtility(PlannedStmt *pstmt,
|
|||
* exercised by our test suite.
|
||||
*/
|
||||
if (!IsMainDB &&
|
||||
!IsCommandToCreateOrDropMainDB(parsetree))
|
||||
!IsCommandMainDbDdlOperation(parsetree))
|
||||
{
|
||||
RunPreprocessMainDBCommand(parsetree);
|
||||
|
||||
if (IsA(parsetree, CreatedbStmt) ||
|
||||
IsA(parsetree, DropdbStmt))
|
||||
IsA(parsetree, DropdbStmt) ||
|
||||
IsA(parsetree, AlterDatabaseStmt) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1720,12 +1722,12 @@ DropSchemaOrDBInProgress(void)
|
|||
|
||||
|
||||
/*
|
||||
* IsCommandToCreateOrDropMainDB checks if this query creates or drops the
|
||||
* IsCommandMainDbDdlOperation checks if this query creates, drops or alter the
|
||||
* main database, so we can make an exception and not send this query to
|
||||
* the main database.
|
||||
*/
|
||||
static bool
|
||||
IsCommandToCreateOrDropMainDB(Node *parsetree)
|
||||
IsCommandMainDbDdlOperation(Node *parsetree)
|
||||
{
|
||||
if (IsA(parsetree, CreatedbStmt))
|
||||
{
|
||||
|
@ -1736,6 +1738,12 @@ IsCommandToCreateOrDropMainDB(Node *parsetree)
|
|||
{
|
||||
DropdbStmt *dropdbStmt = castNode(DropdbStmt, parsetree);
|
||||
return strcmp(dropdbStmt->dbname, MainDb) == 0;
|
||||
}else if(IsA(parsetree,AlterDatabaseStmt)){
|
||||
AlterDatabaseStmt *alterdbStmt = castNode(AlterDatabaseStmt, parsetree);
|
||||
return strcmp(alterdbStmt->dbname, MainDb) == 0;
|
||||
}else if(IsA(parsetree,AlterDatabaseSetStmt)){
|
||||
AlterDatabaseSetStmt *alterdbSetStmt = castNode(AlterDatabaseSetStmt, parsetree);
|
||||
return strcmp(alterdbSetStmt->dbname, MainDb) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
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 REFRESH COLLATION VERSION;
|
||||
NOTICE: issuing SELECT citus_internal.execute_command_on_remote_nodes_as_user('ALTER DATABASE altered_database REFRESH COLLATION VERSION;', 'postgres')
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: version has not changed
|
||||
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;
|
|
@ -0,0 +1,87 @@
|
|||
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;
|
||||
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.enable_create_database_propagation=on;
|
||||
alter database altered_database owner to test_owner_non_main_db;
|
||||
alter database altered_database owner to CURRENT_USER;
|
||||
\c regression
|
||||
\set alter_db_tablespace_non_main :abs_srcdir '/tmp_check/ts3'
|
||||
CREATE TABLESPACE alter_db_tablespace_non_main LOCATION :'alter_db_tablespace_non_main';
|
||||
\c - - - :worker_1_port
|
||||
\set alter_db_tablespace_non_main :abs_srcdir '/tmp_check/ts4'
|
||||
CREATE TABLESPACE alter_db_tablespace_non_main LOCATION :'alter_db_tablespace_non_main';
|
||||
\c - - - :worker_2_port
|
||||
\set alter_db_tablespace_non_main :abs_srcdir '/tmp_check/ts5'
|
||||
CREATE TABLESPACE alter_db_tablespace_non_main LOCATION :'alter_db_tablespace_non_main';
|
||||
\c test_alter_db_from_nonmain_db
|
||||
set citus.log_remote_commands = true;
|
||||
set citus.enable_create_database_propagation=on;
|
||||
alter database altered_database set TABLESPACE alter_db_tablespace_non_main;
|
||||
ALTER DATABASE altered_database REFRESH COLLATION VERSION;
|
||||
NOTICE: version has not changed
|
||||
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;
|
||||
SELECT result FROM run_command_on_all_nodes(
|
||||
$$
|
||||
drop tablespace alter_db_tablespace_non_main
|
||||
$$
|
||||
);
|
||||
result
|
||||
---------------------------------------------------------------------
|
||||
DROP TABLESPACE
|
||||
DROP TABLESPACE
|
||||
DROP TABLESPACE
|
||||
(3 rows)
|
||||
|
|
@ -1,8 +1,65 @@
|
|||
|
||||
--SET citus.superuser TO 'postgres';
|
||||
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 REFRESH COLLATION VERSION;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue