Add sequence tests to arbitrary config (#5771)

Add sequence tests to arbitrary config (#5771)
velioglu/unmark_objects
Ahmet Gedemenli 2022-03-14 19:16:24 +03:00 committed by GitHub
parent 41c6393e82
commit 36b33e2491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 0 deletions

View File

@ -4,3 +4,4 @@ test: dropped_columns_create_load distributed_planning_create_load
test: local_dist_join_load test: local_dist_join_load
test: partitioned_indexes_create test: partitioned_indexes_create
test: connectivity_checks test: connectivity_checks
test: sequences_create

View File

@ -0,0 +1,52 @@
SET search_path TO sequences_schema;
-- see the renamed sequence object
select count(*) from pg_sequence where seqrelid = 'renamed_seq'::regclass;
count
---------------------------------------------------------------------
1
(1 row)
TRUNCATE seq_test_0;
INSERT INTO seq_test_0 VALUES (1);
-- verify that sequence works properly
select max(z) into maxval_z from seq_test_0;
select max(y) into maxval_y from seq_test_0;
select max+1=nextval('renamed_seq') as check_sanity from maxval_z;
check_sanity
---------------------------------------------------------------------
t
(1 row)
select max+1=nextval('seq_1') as check_sanity from maxval_y;
check_sanity
---------------------------------------------------------------------
t
(1 row)
TRUNCATE seq_test_0;
INSERT INTO seq_test_0 VALUES (199999, DEFAULT, DEFAULT);
drop table maxval_z;
select max(z) into maxval_z from seq_test_0;
SELECT pg_sequence_last_value('renamed_seq'::regclass) = max FROM maxval_z;
?column?
---------------------------------------------------------------------
t
(1 row)
TRUNCATE seq_test_0;
BEGIN;
INSERT INTO seq_test_0 VALUES (2);
-- verify that sequence works properly
select max(z)+1=nextval('renamed_seq') as check_sanity from seq_test_0 ;
check_sanity
---------------------------------------------------------------------
t
(1 row)
select max(y)+1=nextval('seq_1') as check_sanity from seq_test_0 ;
check_sanity
---------------------------------------------------------------------
t
(1 row)
COMMIT;

View File

@ -0,0 +1,28 @@
CREATE SCHEMA sequences_schema;
SET search_path TO sequences_schema;
CREATE SEQUENCE seq_0;
ALTER SEQUENCE seq_0 AS smallint;
CREATE SEQUENCE seq_1;
ALTER SEQUENCE seq_1 AS bigint;
CREATE TABLE seq_test_0 (x bigint, y bigint);
SELECT create_distributed_table('seq_test_0','x');
create_distributed_table
---------------------------------------------------------------------
(1 row)
INSERT INTO seq_test_0 SELECT 1, s FROM generate_series(1, 50) s;
SELECT * FROM seq_test_0 ORDER BY 1, 2 LIMIT 5;
x | y
---------------------------------------------------------------------
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
(5 rows)
ALTER TABLE seq_test_0 ADD COLUMN z bigint;
ALTER TABLE seq_test_0 ALTER COLUMN z SET DEFAULT nextval('seq_0');
ALTER TABLE seq_test_0 ALTER COLUMN y SET DEFAULT nextval('seq_1');
ALTER SEQUENCE seq_0 RENAME TO renamed_seq;

View File

@ -0,0 +1,27 @@
SET search_path TO sequences_schema;
-- see the renamed sequence object
select count(*) from pg_sequence where seqrelid = 'renamed_seq'::regclass;
TRUNCATE seq_test_0;
INSERT INTO seq_test_0 VALUES (1);
-- verify that sequence works properly
select max(z) into maxval_z from seq_test_0;
select max(y) into maxval_y from seq_test_0;
select max+1=nextval('renamed_seq') as check_sanity from maxval_z;
select max+1=nextval('seq_1') as check_sanity from maxval_y;
TRUNCATE seq_test_0;
INSERT INTO seq_test_0 VALUES (199999, DEFAULT, DEFAULT);
drop table maxval_z;
select max(z) into maxval_z from seq_test_0;
SELECT pg_sequence_last_value('renamed_seq'::regclass) = max FROM maxval_z;
TRUNCATE seq_test_0;
BEGIN;
INSERT INTO seq_test_0 VALUES (2);
-- verify that sequence works properly
select max(z)+1=nextval('renamed_seq') as check_sanity from seq_test_0 ;
select max(y)+1=nextval('seq_1') as check_sanity from seq_test_0 ;
COMMIT;

View File

@ -0,0 +1,21 @@
CREATE SCHEMA sequences_schema;
SET search_path TO sequences_schema;
CREATE SEQUENCE seq_0;
ALTER SEQUENCE seq_0 AS smallint;
CREATE SEQUENCE seq_1;
ALTER SEQUENCE seq_1 AS bigint;
CREATE TABLE seq_test_0 (x bigint, y bigint);
SELECT create_distributed_table('seq_test_0','x');
INSERT INTO seq_test_0 SELECT 1, s FROM generate_series(1, 50) s;
SELECT * FROM seq_test_0 ORDER BY 1, 2 LIMIT 5;
ALTER TABLE seq_test_0 ADD COLUMN z bigint;
ALTER TABLE seq_test_0 ALTER COLUMN z SET DEFAULT nextval('seq_0');
ALTER TABLE seq_test_0 ALTER COLUMN y SET DEFAULT nextval('seq_1');
ALTER SEQUENCE seq_0 RENAME TO renamed_seq;

View File

@ -6,3 +6,4 @@ test: intermediate_result_pruning_queries_1 intermediate_result_pruning_queries_
test: dropped_columns_1 distributed_planning test: dropped_columns_1 distributed_planning
test: local_dist_join test: local_dist_join
test: connectivity_checks citus_run_command test: connectivity_checks citus_run_command
test: sequences