Merge pull request #1183 from citusdata/allow_drop_sequence_on_worker

Allow dropping sequences on mx workers
pull/1182/head
Eren Başak 2017-01-31 14:59:29 -08:00 committed by GitHub
commit 20139b9b1a
3 changed files with 46 additions and 4 deletions

View File

@ -235,15 +235,14 @@ master_drop_sequences(PG_FUNCTION_ARGS)
Datum sequenceText = 0;
bool isNull = false;
StringInfo dropSeqCommand = makeStringInfo();
bool coordinator = IsCoordinator();
/* do nothing if DDL propagation is switched off */
if (!EnableDDLPropagation)
/* do nothing if DDL propagation is switched off or this is not the coordinator */
if (!EnableDDLPropagation || !coordinator)
{
PG_RETURN_VOID();
}
EnsureCoordinator();
/* iterate over sequence names to build single command to DROP them all */
sequenceIterator = array_create_iterator(sequenceNamesArray, 0, NULL);
while (array_iterate(sequenceIterator, &sequenceText, &isNull))

View File

@ -385,6 +385,36 @@ DELETE FROM pg_dist_shard_placement WHERE nodeport = :worker_2_port AND shardid
SELECT master_get_new_placementid();
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
-- Show that sequences can be created and dropped on worker nodes
CREATE TABLE some_table_with_sequence(a int, b BIGSERIAL, c BIGSERIAL);
DROP TABLE some_table_with_sequence;
CREATE SEQUENCE some_sequence;
DROP SEQUENCE some_sequence;
-- Show that dropping the sequence of an MX table with cascade harms the table and shards
BEGIN;
\d mx_table
Table "public.mx_table"
Column | Type | Modifiers
--------+---------+----------------------------------------------------------
col_1 | integer |
col_2 | text |
col_3 | bigint | not null default nextval('mx_table_col_3_seq'::regclass)
DROP SEQUENCE mx_table_col_3_seq CASCADE;
NOTICE: drop cascades to 4 other objects
DETAIL: drop cascades to default for table mx_table_1270000 column col_3
drop cascades to default for table mx_table_1270002 column col_3
drop cascades to default for table mx_table_1270004 column col_3
drop cascades to default for table mx_table column col_3
\d mx_table
Table "public.mx_table"
Column | Type | Modifiers
--------+---------+-----------
col_1 | integer |
col_2 | text |
col_3 | bigint | not null
ROLLBACK;
-- Cleanup
\c - - - :master_port
DROP TABLE mx_table;

View File

@ -204,6 +204,19 @@ DELETE FROM pg_dist_shard_placement WHERE nodeport = :worker_2_port AND shardid
-- master_get_new_placementid
SELECT master_get_new_placementid();
-- Show that sequences can be created and dropped on worker nodes
CREATE TABLE some_table_with_sequence(a int, b BIGSERIAL, c BIGSERIAL);
DROP TABLE some_table_with_sequence;
CREATE SEQUENCE some_sequence;
DROP SEQUENCE some_sequence;
-- Show that dropping the sequence of an MX table with cascade harms the table and shards
BEGIN;
\d mx_table
DROP SEQUENCE mx_table_col_3_seq CASCADE;
\d mx_table
ROLLBACK;
-- Cleanup
\c - - - :master_port
DROP TABLE mx_table;