mirror of https://github.com/citusdata/citus.git
Merge pull request #1183 from citusdata/allow_drop_sequence_on_worker
Allow dropping sequences on mx workerspull/1182/head
commit
20139b9b1a
|
@ -235,15 +235,14 @@ master_drop_sequences(PG_FUNCTION_ARGS)
|
||||||
Datum sequenceText = 0;
|
Datum sequenceText = 0;
|
||||||
bool isNull = false;
|
bool isNull = false;
|
||||||
StringInfo dropSeqCommand = makeStringInfo();
|
StringInfo dropSeqCommand = makeStringInfo();
|
||||||
|
bool coordinator = IsCoordinator();
|
||||||
|
|
||||||
/* do nothing if DDL propagation is switched off */
|
/* do nothing if DDL propagation is switched off or this is not the coordinator */
|
||||||
if (!EnableDDLPropagation)
|
if (!EnableDDLPropagation || !coordinator)
|
||||||
{
|
{
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureCoordinator();
|
|
||||||
|
|
||||||
/* iterate over sequence names to build single command to DROP them all */
|
/* iterate over sequence names to build single command to DROP them all */
|
||||||
sequenceIterator = array_create_iterator(sequenceNamesArray, 0, NULL);
|
sequenceIterator = array_create_iterator(sequenceNamesArray, 0, NULL);
|
||||||
while (array_iterate(sequenceIterator, &sequenceText, &isNull))
|
while (array_iterate(sequenceIterator, &sequenceText, &isNull))
|
||||||
|
|
|
@ -385,6 +385,36 @@ DELETE FROM pg_dist_shard_placement WHERE nodeport = :worker_2_port AND shardid
|
||||||
SELECT master_get_new_placementid();
|
SELECT master_get_new_placementid();
|
||||||
ERROR: operation is not allowed on this node
|
ERROR: operation is not allowed on this node
|
||||||
HINT: Connect to the coordinator and run it again.
|
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
|
-- Cleanup
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
DROP TABLE mx_table;
|
DROP TABLE mx_table;
|
||||||
|
|
|
@ -204,6 +204,19 @@ DELETE FROM pg_dist_shard_placement WHERE nodeport = :worker_2_port AND shardid
|
||||||
-- master_get_new_placementid
|
-- master_get_new_placementid
|
||||||
SELECT 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
|
-- Cleanup
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
DROP TABLE mx_table;
|
DROP TABLE mx_table;
|
||||||
|
|
Loading…
Reference in New Issue