mirror of https://github.com/citusdata/citus.git
Adds set tablespace support
parent
a72e474c3a
commit
8d6d27a241
|
@ -182,30 +182,24 @@ PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
|
||||||
|
|
||||||
char *sql = DeparseTreeNode((Node *) stmt);
|
char *sql = DeparseTreeNode((Node *) stmt);
|
||||||
|
|
||||||
|
List *commands = NULL;
|
||||||
|
|
||||||
if (strstr(sql, "SET TABLESPACE") != NULL)
|
if (strstr(sql, "SET TABLESPACE") != NULL)
|
||||||
{
|
{
|
||||||
if (IsCoordinator())
|
commands = list_make5(DISABLE_DDL_PROPAGATION,
|
||||||
{
|
COMMIT_TRANSACTION,
|
||||||
ereport(NOTICE, (errmsg(
|
sql,
|
||||||
"Citus partially supports ALTER DATABASE SET TABLESPACE for "
|
BEGIN_TRANSACTION,
|
||||||
"distributed databases"),
|
ENABLE_DDL_PROPAGATION);
|
||||||
errdetail(
|
|
||||||
"Citus does not propagate ALTER DATABASE SET TABLESPACE "
|
|
||||||
"command to workers"),
|
|
||||||
errhint(
|
|
||||||
"You can manually alter a tablespace for a database and its "
|
|
||||||
"extensions on workers.")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List *commands = list_make3(DISABLE_DDL_PROPAGATION,
|
commands = list_make3(DISABLE_DDL_PROPAGATION,
|
||||||
(void *) sql,
|
(void *) sql,
|
||||||
ENABLE_DDL_PROPAGATION);
|
ENABLE_DDL_PROPAGATION);
|
||||||
|
|
||||||
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
|
||||||
}
|
}
|
||||||
return NIL;
|
|
||||||
|
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,8 @@ AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool
|
||||||
static void
|
static void
|
||||||
AppendAlterDatabaseSetTablespace(StringInfo buf, DefElem *def, char *dbname)
|
AppendAlterDatabaseSetTablespace(StringInfo buf, DefElem *def, char *dbname)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, "ALTER DATABASE %s SET TABLESPACE %s",
|
appendStringInfo(buf,
|
||||||
|
"ALTER DATABASE %s SET TABLESPACE %s",
|
||||||
quote_identifier(dbname), quote_identifier(defGetString(def)));
|
quote_identifier(dbname), quote_identifier(defGetString(def)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,8 @@ extern void SendInterTableRelationshipCommands(MetadataSyncContext *context);
|
||||||
"SELECT pg_catalog.worker_drop_sequence_dependency(%s);"
|
"SELECT pg_catalog.worker_drop_sequence_dependency(%s);"
|
||||||
|
|
||||||
#define DISABLE_DDL_PROPAGATION "SET citus.enable_ddl_propagation TO 'off'"
|
#define DISABLE_DDL_PROPAGATION "SET citus.enable_ddl_propagation TO 'off'"
|
||||||
|
#define BEGIN_TRANSACTION "BEGIN"
|
||||||
|
#define COMMIT_TRANSACTION "COMMIT"
|
||||||
#define ENABLE_DDL_PROPAGATION "SET citus.enable_ddl_propagation TO 'on'"
|
#define ENABLE_DDL_PROPAGATION "SET citus.enable_ddl_propagation TO 'on'"
|
||||||
#define DISABLE_METADATA_SYNC "SET citus.enable_metadata_sync TO 'off'"
|
#define DISABLE_METADATA_SYNC "SET citus.enable_metadata_sync TO 'off'"
|
||||||
#define ENABLE_METADATA_SYNC "SET citus.enable_metadata_sync TO 'on'"
|
#define ENABLE_METADATA_SYNC "SET citus.enable_metadata_sync TO 'on'"
|
||||||
|
|
|
@ -54,18 +54,25 @@ alter database regression2 with CONNECTION LIMIT 100;
|
||||||
alter database regression2 with IS_TEMPLATE true CONNECTION LIMIT 50;
|
alter database regression2 with IS_TEMPLATE true CONNECTION LIMIT 50;
|
||||||
alter database regression2 with IS_TEMPLATE false;
|
alter database regression2 with IS_TEMPLATE false;
|
||||||
|
|
||||||
alter database regression2 set TABLESPACE pg_default;
|
|
||||||
|
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts3'
|
||||||
|
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
|
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts4'
|
||||||
alter database regression2 set TABLESPACE pg_default;
|
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
|
||||||
|
|
||||||
\c - - - :worker_2_port
|
\c - - - :worker_2_port
|
||||||
|
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts5'
|
||||||
alter database regression2 set TABLESPACE pg_default;
|
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
|
||||||
|
set citus.log_remote_commands = true;
|
||||||
|
set citus.grep_remote_commands = '%ALTER DATABASE%';
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -73,3 +80,17 @@ drop database regression3;
|
||||||
|
|
||||||
set citus.log_remote_commands = false;
|
set citus.log_remote_commands = false;
|
||||||
set citus.enable_create_database_propagation=off;
|
set citus.enable_create_database_propagation=off;
|
||||||
|
|
||||||
|
drop tablespace alter_db_tablespace;
|
||||||
|
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
|
||||||
|
drop tablespace alter_db_tablespace;
|
||||||
|
|
||||||
|
\c - - - :worker_2_port
|
||||||
|
|
||||||
|
drop tablespace alter_db_tablespace;
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue