mirror of https://github.com/citusdata/citus.git
Fixes drop force option
parent
52c9e92544
commit
3731c45c29
|
@ -329,8 +329,19 @@ AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
|
|||
|
||||
DefElem *option = NULL;
|
||||
|
||||
|
||||
foreach_ptr(option, stmt->options)
|
||||
{
|
||||
//if it is the first option then append with "WITH" else append with ","
|
||||
if (option == linitial(stmt->options))
|
||||
{
|
||||
appendStringInfo(buf, " WITH ( ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfo(buf, ", ");
|
||||
}
|
||||
|
||||
if (strcmp(option->defname, "force") == 0)
|
||||
{
|
||||
appendStringInfo(buf, "FORCE");
|
||||
|
@ -341,6 +352,13 @@ AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
|
|||
errmsg("unrecognized DROP DATABASE option \"%s\"",
|
||||
option->defname)));
|
||||
}
|
||||
|
||||
//if it is the last option then append with ")"
|
||||
if (option == llast(stmt->options))
|
||||
{
|
||||
appendStringInfo(buf, " )");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -477,6 +477,24 @@ SET citus.enable_create_database_propagation TO ON;
|
|||
DROP DATABASE test_node_activation;
|
||||
DROP DATABASE db_needs_escape;
|
||||
DROP USER "role-needs\!escape";
|
||||
-- drop database with force options test
|
||||
create database db_force_test;
|
||||
SET citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = '%DROP DATABASE%';
|
||||
drop database db_force_test with (force);
|
||||
NOTICE: issuing DROP DATABASE db_force_test WITH ( FORCE )
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
NOTICE: issuing DROP DATABASE db_force_test WITH ( FORCE )
|
||||
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||
reset citus.log_remote_commands;
|
||||
SELECT * FROM public.check_database_on_all_nodes('db_force_test') ORDER BY node_type;
|
||||
node_type | result
|
||||
---------------------------------------------------------------------
|
||||
coordinator (local) | {"database_properties": null, "pg_dist_object_record_for_db_exists": false, "stale_pg_dist_object_record_for_a_db_exists": false}
|
||||
worker node (remote) | {"database_properties": null, "pg_dist_object_record_for_db_exists": false, "stale_pg_dist_object_record_for_a_db_exists": false}
|
||||
worker node (remote) | {"database_properties": null, "pg_dist_object_record_for_db_exists": false, "stale_pg_dist_object_record_for_a_db_exists": false}
|
||||
(3 rows)
|
||||
|
||||
--clean up resources created by this test
|
||||
-- DROP TABLESPACE is not supported, so we need to drop it manually.
|
||||
SELECT result FROM run_command_on_all_nodes(
|
||||
|
|
|
@ -261,6 +261,20 @@ DROP DATABASE test_node_activation;
|
|||
DROP DATABASE db_needs_escape;
|
||||
DROP USER "role-needs\!escape";
|
||||
|
||||
-- drop database with force options test
|
||||
|
||||
create database db_force_test;
|
||||
|
||||
SET citus.log_remote_commands = true;
|
||||
set citus.grep_remote_commands = '%DROP DATABASE%';
|
||||
|
||||
drop database db_force_test with (force);
|
||||
|
||||
reset citus.log_remote_commands;
|
||||
|
||||
SELECT * FROM public.check_database_on_all_nodes('db_force_test') ORDER BY node_type;
|
||||
|
||||
|
||||
--clean up resources created by this test
|
||||
|
||||
-- DROP TABLESPACE is not supported, so we need to drop it manually.
|
||||
|
|
Loading…
Reference in New Issue