mirror of https://github.com/citusdata/citus.git
Add sequence tests
parent
f9ff59c6ba
commit
105f136b64
|
@ -1930,8 +1930,10 @@ ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes when met
|
||||||
public | mx_test_sequence_0 | sequence | postgres
|
public | mx_test_sequence_0 | sequence | postgres
|
||||||
public | mx_test_sequence_1 | sequence | postgres
|
public | mx_test_sequence_1 | sequence | postgres
|
||||||
public | mx_test_table_col_3_seq | sequence | postgres
|
public | mx_test_table_col_3_seq | sequence | postgres
|
||||||
|
public | sequence_rollback | sequence | postgres
|
||||||
|
public | sequence_rollback(citus_backup_0) | sequence | postgres
|
||||||
public | user_defined_seq | sequence | postgres
|
public | user_defined_seq | sequence | postgres
|
||||||
(4 rows)
|
(6 rows)
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
CREATE SEQUENCE local_sequence;
|
CREATE SEQUENCE local_sequence;
|
||||||
|
@ -1947,8 +1949,10 @@ drop cascades to default value for column id of table test_table
|
||||||
Schema | Name | Type | Owner
|
Schema | Name | Type | Owner
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
public | mx_test_table_col_3_seq | sequence | postgres
|
public | mx_test_table_col_3_seq | sequence | postgres
|
||||||
|
public | sequence_rollback | sequence | postgres
|
||||||
|
public | sequence_rollback(citus_backup_0) | sequence | postgres
|
||||||
public | user_defined_seq | sequence | postgres
|
public | user_defined_seq | sequence | postgres
|
||||||
(2 rows)
|
(4 rows)
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
DROP TABLE test_table CASCADE;
|
DROP TABLE test_table CASCADE;
|
||||||
|
|
|
@ -946,6 +946,49 @@ SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dis
|
||||||
(schema,{test_schema_for_sequence_default_propagation},{})
|
(schema,{test_schema_for_sequence_default_propagation},{})
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Show that sequence can stay on the worker node if the transaction is
|
||||||
|
-- rollbacked after distributing the table
|
||||||
|
BEGIN;
|
||||||
|
CREATE SEQUENCE sequence_rollback;
|
||||||
|
CREATE TABLE sequence_rollback_table(id int, val_1 int default nextval('sequence_rollback'));
|
||||||
|
SELECT create_distributed_table('sequence_rollback_table', 'id');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
-- Show that there is a sequence on the worker with the sequence type int
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
SELECT seqtypid::regtype, seqmax, seqmin FROM pg_sequence WHERE seqrelid::regclass::text = 'sequence_rollback';
|
||||||
|
seqtypid | seqmax | seqmin
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
integer | 2147483647 | 1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
-- Show that we can create a sequence with the same name and different data type
|
||||||
|
BEGIN;
|
||||||
|
CREATE SEQUENCE sequence_rollback;
|
||||||
|
CREATE TABLE sequence_rollback_table(id int, val_1 bigint default nextval('sequence_rollback'));
|
||||||
|
SELECT create_distributed_table('sequence_rollback_table', 'id');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
-- Show that existing sequence has been renamed and a new sequence with the same name
|
||||||
|
-- created for another type
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
SELECT seqrelid::regclass, seqtypid::regtype, seqmax, seqmin FROM pg_sequence WHERE seqrelid::regclass::text like '%sequence_rollback%';
|
||||||
|
seqrelid | seqtypid | seqmax | seqmin
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
"sequence_rollback(citus_backup_0)" | integer | 2147483647 | 1
|
||||||
|
sequence_rollback | bigint | 562949953421313 | 281474976710657
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
-- clean up
|
-- clean up
|
||||||
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
|
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
|
||||||
NOTICE: drop cascades to 2 other objects
|
NOTICE: drop cascades to 2 other objects
|
||||||
|
|
|
@ -454,6 +454,33 @@ SELECT create_distributed_table('test_seq_dist', 'a');
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation.seq_10'::regclass);
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation.seq_10'::regclass);
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation'::regnamespace);
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation'::regnamespace);
|
||||||
|
|
||||||
|
-- Show that sequence can stay on the worker node if the transaction is
|
||||||
|
-- rollbacked after distributing the table
|
||||||
|
BEGIN;
|
||||||
|
CREATE SEQUENCE sequence_rollback;
|
||||||
|
CREATE TABLE sequence_rollback_table(id int, val_1 int default nextval('sequence_rollback'));
|
||||||
|
SELECT create_distributed_table('sequence_rollback_table', 'id');
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- Show that there is a sequence on the worker with the sequence type int
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
SELECT seqtypid::regtype, seqmax, seqmin FROM pg_sequence WHERE seqrelid::regclass::text = 'sequence_rollback';
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
-- Show that we can create a sequence with the same name and different data type
|
||||||
|
BEGIN;
|
||||||
|
CREATE SEQUENCE sequence_rollback;
|
||||||
|
CREATE TABLE sequence_rollback_table(id int, val_1 bigint default nextval('sequence_rollback'));
|
||||||
|
SELECT create_distributed_table('sequence_rollback_table', 'id');
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- Show that existing sequence has been renamed and a new sequence with the same name
|
||||||
|
-- created for another type
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
SELECT seqrelid::regclass, seqtypid::regtype, seqmax, seqmin FROM pg_sequence WHERE seqrelid::regclass::text like '%sequence_rollback%';
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
|
||||||
-- clean up
|
-- clean up
|
||||||
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
|
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
|
||||||
DROP TABLE test_seq_dist;
|
DROP TABLE test_seq_dist;
|
||||||
|
|
Loading…
Reference in New Issue