Add sequence tests

velioglu/temp_two_pro
Burak Velioglu 2022-01-30 21:05:55 +03:00
parent f9ff59c6ba
commit 105f136b64
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
3 changed files with 82 additions and 8 deletions

View File

@ -1927,11 +1927,13 @@ ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes when met
List of relations
Schema | Name | Type | Owner
---------------------------------------------------------------------
public | mx_test_sequence_0 | sequence | postgres
public | mx_test_sequence_1 | sequence | postgres
public | mx_test_table_col_3_seq | sequence | postgres
public | user_defined_seq | sequence | postgres
(4 rows)
public | mx_test_sequence_0 | sequence | postgres
public | mx_test_sequence_1 | 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
(6 rows)
\c - - - :master_port
CREATE SEQUENCE local_sequence;
@ -1946,9 +1948,11 @@ drop cascades to default value for column id of table test_table
List of relations
Schema | Name | Type | Owner
---------------------------------------------------------------------
public | mx_test_table_col_3_seq | sequence | postgres
public | user_defined_seq | sequence | postgres
(2 rows)
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
(4 rows)
\c - - - :master_port
DROP TABLE test_table CASCADE;

View File

@ -946,6 +946,49 @@ SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dis
(schema,{test_schema_for_sequence_default_propagation},{})
(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
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
NOTICE: drop cascades to 2 other objects

View File

@ -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'::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
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
DROP TABLE test_seq_dist;