mirror of https://github.com/citusdata/citus.git
Adds distributed check for rename and alter db
parent
18a8783e96
commit
dd41c729f4
|
@ -231,15 +231,18 @@ List *
|
||||||
PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
|
PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
|
||||||
ProcessUtilityContext processUtilityContext)
|
ProcessUtilityContext processUtilityContext)
|
||||||
{
|
{
|
||||||
if (!ShouldPropagate())
|
bool missingOk = false;
|
||||||
|
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
|
||||||
|
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->dbname,
|
||||||
|
missingOk);
|
||||||
|
|
||||||
|
if (!ShouldPropagate() || !IsAnyObjectDistributed(list_make1(dbAddress)))
|
||||||
{
|
{
|
||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureCoordinator();
|
EnsureCoordinator();
|
||||||
|
|
||||||
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
|
|
||||||
|
|
||||||
char *sql = DeparseTreeNode((Node *) stmt);
|
char *sql = DeparseTreeNode((Node *) stmt);
|
||||||
|
|
||||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||||
|
@ -305,15 +308,18 @@ PreprocessAlterDatabaseRefreshCollStmt(Node *node, const char *queryString,
|
||||||
List *
|
List *
|
||||||
PostprocessAlterDatabaseRenameStmt(Node *node, const char *queryString)
|
PostprocessAlterDatabaseRenameStmt(Node *node, const char *queryString)
|
||||||
{
|
{
|
||||||
if (!ShouldPropagate())
|
bool missingOk = false;
|
||||||
|
RenameStmt *stmt = castNode(RenameStmt, node);
|
||||||
|
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->newname,
|
||||||
|
missingOk);
|
||||||
|
|
||||||
|
if (!ShouldPropagate() || !IsAnyObjectDistributed(list_make1(dbAddress)))
|
||||||
{
|
{
|
||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureCoordinator();
|
EnsureCoordinator();
|
||||||
|
|
||||||
RenameStmt *stmt = castNode(RenameStmt, node);
|
|
||||||
|
|
||||||
char *sql = DeparseTreeNode((Node *) stmt);
|
char *sql = DeparseTreeNode((Node *) stmt);
|
||||||
|
|
||||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||||
|
|
|
@ -178,6 +178,16 @@ NOTICE: issuing ALTER DATABASE regression2 RENAME TO regression3
|
||||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
NOTICE: issuing ALTER DATABASE regression2 RENAME TO regression3
|
NOTICE: issuing ALTER DATABASE regression2 RENAME TO regression3
|
||||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
-- check that the local database rename and alter comnmand is not propagated
|
||||||
|
set citus.enable_create_database_propagation=off;
|
||||||
|
CREATE database local_regression;
|
||||||
|
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||||
|
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||||
|
HINT: You can manually create a database and its extensions on workers.
|
||||||
|
alter DATABASE local_regression with CONNECTION LIMIT 100;
|
||||||
|
alter DATABASE local_regression rename to local_regression2;
|
||||||
|
drop database local_regression2;
|
||||||
|
set citus.enable_create_database_propagation=on;
|
||||||
drop database regression3;
|
drop database regression3;
|
||||||
create database regression4;
|
create database regression4;
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
|
|
|
@ -76,6 +76,16 @@ alter database regression2 set TABLESPACE alter_db_tablespace;
|
||||||
set citus.enable_create_database_propagation=on;
|
set citus.enable_create_database_propagation=on;
|
||||||
alter database regression2 rename to regression3;
|
alter database regression2 rename to regression3;
|
||||||
|
|
||||||
|
-- check that the local database rename and alter comnmand is not propagated
|
||||||
|
set citus.enable_create_database_propagation=off;
|
||||||
|
CREATE database local_regression;
|
||||||
|
|
||||||
|
alter DATABASE local_regression with CONNECTION LIMIT 100;
|
||||||
|
alter DATABASE local_regression rename to local_regression2;
|
||||||
|
drop database local_regression2;
|
||||||
|
|
||||||
|
set citus.enable_create_database_propagation=on;
|
||||||
|
|
||||||
drop database regression3;
|
drop database regression3;
|
||||||
|
|
||||||
create database regression4;
|
create database regression4;
|
||||||
|
|
Loading…
Reference in New Issue