mirror of https://github.com/citusdata/citus.git
Do distributed check first, for DropSchema stmts
parent
24bdb287ed
commit
c1d5ca9896
|
@ -86,13 +86,6 @@ PreprocessDropSchemaStmt(Node *node, const char *queryString,
|
|||
DropStmt *dropStatement = castNode(DropStmt, node);
|
||||
Assert(dropStatement->removeType == OBJECT_SCHEMA);
|
||||
|
||||
if (!ShouldPropagate())
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
EnsureCoordinator();
|
||||
|
||||
List *distributedSchemas = FilterDistributedSchemas(dropStatement->objects);
|
||||
|
||||
if (list_length(distributedSchemas) < 1)
|
||||
|
@ -100,6 +93,13 @@ PreprocessDropSchemaStmt(Node *node, const char *queryString,
|
|||
return NIL;
|
||||
}
|
||||
|
||||
if (!ShouldPropagate())
|
||||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
EnsureCoordinator();
|
||||
|
||||
EnsureSequentialMode(OBJECT_SCHEMA);
|
||||
|
||||
Value *schemaVal = NULL;
|
||||
|
|
|
@ -515,12 +515,30 @@ SELECT table_schema AS "Shards' Schema"
|
|||
mx_new_schema
|
||||
(1 row)
|
||||
|
||||
-- check that we can drop a user-defined schema from workers
|
||||
SET citus.enable_ddl_propagation TO OFF;
|
||||
CREATE SCHEMA localschema;
|
||||
RESET citus.enable_ddl_propagation;
|
||||
DROP SCHEMA localschema;
|
||||
\c - - - :master_port
|
||||
SELECT * FROM mx_new_schema.table_set_schema;
|
||||
id
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- verify local schema does not exist on the worker
|
||||
-- worker errors out as "schema does not exist"
|
||||
SET citus.enable_ddl_propagation TO OFF;
|
||||
CREATE SCHEMA localschema;
|
||||
-- should error out
|
||||
SELECT run_command_on_workers($$DROP SCHEMA localschema;$$);
|
||||
run_command_on_workers
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,f,"ERROR: schema ""localschema"" does not exist")
|
||||
(localhost,57638,f,"ERROR: schema ""localschema"" does not exist")
|
||||
(2 rows)
|
||||
|
||||
RESET citus.enable_ddl_propagation;
|
||||
DROP SCHEMA mx_old_schema CASCADE;
|
||||
DROP SCHEMA mx_new_schema CASCADE;
|
||||
NOTICE: drop cascades to table mx_new_schema.table_set_schema
|
||||
|
|
|
@ -333,8 +333,25 @@ SELECT table_schema AS "Shards' Schema"
|
|||
FROM information_schema.tables
|
||||
WHERE table_name LIKE 'table\_set\_schema\_%'
|
||||
GROUP BY table_schema;
|
||||
|
||||
-- check that we can drop a user-defined schema from workers
|
||||
SET citus.enable_ddl_propagation TO OFF;
|
||||
CREATE SCHEMA localschema;
|
||||
RESET citus.enable_ddl_propagation;
|
||||
DROP SCHEMA localschema;
|
||||
|
||||
\c - - - :master_port
|
||||
SELECT * FROM mx_new_schema.table_set_schema;
|
||||
|
||||
-- verify local schema does not exist on the worker
|
||||
-- worker errors out as "schema does not exist"
|
||||
SET citus.enable_ddl_propagation TO OFF;
|
||||
CREATE SCHEMA localschema;
|
||||
|
||||
-- should error out
|
||||
SELECT run_command_on_workers($$DROP SCHEMA localschema;$$);
|
||||
|
||||
RESET citus.enable_ddl_propagation;
|
||||
|
||||
DROP SCHEMA mx_old_schema CASCADE;
|
||||
DROP SCHEMA mx_new_schema CASCADE;
|
||||
|
|
Loading…
Reference in New Issue