Skip to content

Commit 544f452

Browse files
committed
fixup! Disallow colocating tables when collations don't match
1 parent af16502 commit 544f452

File tree

4 files changed

+32
-61
lines changed

4 files changed

+32
-61
lines changed

src/test/regress/expected/upgrade_post_14_after.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ AS upgrade_test_old_citus_version_lt_14_0;
1414
\endif
1515
-- Make sure we still have different colocation groups.
1616
select result as colocationids_different from run_command_on_all_nodes($$
17-
select count(distinct(colocationid)) = 4
17+
select count(distinct(colocationid)) = 3
1818
from pg_dist_partition
1919
join pg_class on (logicalrelid = pg_class.oid)
2020
join pg_namespace on (relnamespace = pg_namespace.oid)
2121
join pg_dist_colocation using (colocationid)
22-
where pg_namespace.nspname = 'post_14_upgrade'
22+
where pg_namespace.nspname = 'Post_14_!''upgrade'
2323
$$);
2424
colocationids_different
2525
---------------------------------------------------------------------
@@ -32,12 +32,12 @@ $$);
3232
-- after the upgrade, the collations for each colocation group should
3333
-- be adjusted correctly now.
3434
select result as colocation_group_collations_same from run_command_on_all_nodes($$
35-
select count(distinct(distributioncolumncollation)) = 4
35+
select count(distinct(distributioncolumncollation)) = 3
3636
from pg_dist_partition
3737
join pg_class on (logicalrelid = pg_class.oid)
3838
join pg_namespace on (relnamespace = pg_namespace.oid)
3939
join pg_dist_colocation using (colocationid)
40-
where pg_namespace.nspname = 'post_14_upgrade'
40+
where pg_namespace.nspname = 'Post_14_!''upgrade'
4141
$$);
4242
colocation_group_collations_same
4343
---------------------------------------------------------------------

src/test/regress/expected/upgrade_post_14_before.out

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ AS upgrade_test_old_citus_version_lt_14_0;
1414
\endif
1515
SET citus.shard_replication_factor TO 1;
1616
SET client_min_messages TO WARNING;
17-
DROP SCHEMA IF EXISTS post_14_upgrade CASCADE;
18-
CREATE SCHEMA post_14_upgrade;
19-
SET search_path = post_14_upgrade;
17+
DROP SCHEMA IF EXISTS "Post_14_!'upgrade" CASCADE;
18+
CREATE SCHEMA "Post_14_!'upgrade";
19+
SET search_path = "Post_14_!'upgrade";
2020
create table test_c1_tbl_1(text_col text);
2121
create table test_c1_tbl_2(text_col text);
2222
create table test_c1_tbl_3(text_col text);
2323
create table test_c2_tbl_1(text_col text collate "en-x-icu");
2424
create table test_c2_tbl_2(text_col text collate "en-x-icu");
2525
create table test_c2_tbl_3(text_col text collate "en-x-icu");
26-
create table test_c3_tbl_1(text_col text collate "C");
27-
create table test_c3_tbl_2(text_col text collate "C");
28-
create table test_c3_tbl_3(text_col text collate "C");
2926
-- also some tables with weird names
30-
create table "test_c4_Tbl_!'@#_1" (text_col text collate "en_US.utf8");
31-
create table "test_c4_Tbl_!'@#_2" (text_col text collate "en_US.utf8");
32-
create table "test_c4_Tbl_!'@#_3" (text_col text collate "en_US.utf8");
27+
create table "test_c3_Tbl_!'@#_1" (text_col text collate "C");
28+
create table "test_c3_Tbl_!'@#_2" (text_col text collate "C");
29+
create table "test_c3_Tbl_!'@#_3" (text_col text collate "C");
3330
select create_distributed_table('test_c1_tbl_1', 'text_col', colocate_with => 'none');
3431
create_distributed_table
3532
---------------------------------------------------------------------
@@ -66,37 +63,19 @@ select create_distributed_table('test_c2_tbl_3', 'text_col', colocate_with => 't
6663

6764
(1 row)
6865

69-
select create_distributed_table('test_c3_tbl_1', 'text_col', colocate_with => 'none');
66+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_1"', 'text_col', colocate_with => 'none');
7067
create_distributed_table
7168
---------------------------------------------------------------------
7269

7370
(1 row)
7471

75-
select create_distributed_table('test_c3_tbl_2', 'text_col', colocate_with => 'test_c3_tbl_1');
72+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_2"', 'text_col', colocate_with => '"test_c3_Tbl_!''@#_1"');
7673
create_distributed_table
7774
---------------------------------------------------------------------
7875

7976
(1 row)
8077

81-
select create_distributed_table('test_c3_tbl_3', 'text_col', colocate_with => 'test_c3_tbl_1');
82-
create_distributed_table
83-
---------------------------------------------------------------------
84-
85-
(1 row)
86-
87-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_1"', 'text_col', colocate_with => 'none');
88-
create_distributed_table
89-
---------------------------------------------------------------------
90-
91-
(1 row)
92-
93-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_2"', 'text_col', colocate_with => '"test_c4_Tbl_!''@#_1"');
94-
create_distributed_table
95-
---------------------------------------------------------------------
96-
97-
(1 row)
98-
99-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_3"', 'text_col', colocate_with => '"test_c4_Tbl_!''@#_1"');
78+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_3"', 'text_col', colocate_with => '"test_c3_Tbl_!''@#_1"');
10079
create_distributed_table
10180
---------------------------------------------------------------------
10281

@@ -106,12 +85,12 @@ SELECT create_distributed_table('"test_c4_Tbl_!''@#_3"', 'text_col', colocate_wi
10685
-- to be so by providing colocate_with=>'none' for the first table in each
10786
-- group.
10887
select result as colocationids_different from run_command_on_all_nodes($$
109-
select count(distinct(colocationid)) = 4
88+
select count(distinct(colocationid)) = 3
11089
from pg_dist_partition
11190
join pg_class on (logicalrelid = pg_class.oid)
11291
join pg_namespace on (relnamespace = pg_namespace.oid)
11392
join pg_dist_colocation using (colocationid)
114-
where pg_namespace.nspname = 'post_14_upgrade'
93+
where pg_namespace.nspname = 'Post_14_!''upgrade'
11594
$$);
11695
colocationids_different
11796
---------------------------------------------------------------------
@@ -131,7 +110,7 @@ select result as colocation_group_collations_same from run_command_on_all_nodes(
131110
join pg_class on (logicalrelid = pg_class.oid)
132111
join pg_namespace on (relnamespace = pg_namespace.oid)
133112
join pg_dist_colocation using (colocationid)
134-
where pg_namespace.nspname = 'post_14_upgrade'
113+
where pg_namespace.nspname = 'Post_14_!''upgrade'
135114
$$);
136115
colocation_group_collations_same
137116
---------------------------------------------------------------------

src/test/regress/sql/upgrade_post_14_after.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ AS upgrade_test_old_citus_version_lt_14_0;
1010

1111
-- Make sure we still have different colocation groups.
1212
select result as colocationids_different from run_command_on_all_nodes($$
13-
select count(distinct(colocationid)) = 4
13+
select count(distinct(colocationid)) = 3
1414
from pg_dist_partition
1515
join pg_class on (logicalrelid = pg_class.oid)
1616
join pg_namespace on (relnamespace = pg_namespace.oid)
1717
join pg_dist_colocation using (colocationid)
18-
where pg_namespace.nspname = 'post_14_upgrade'
18+
where pg_namespace.nspname = 'Post_14_!''upgrade'
1919
$$);
2020

2121
-- However, since our test suite executed citus_finish_citus_upgrade()
2222
-- after the upgrade, the collations for each colocation group should
2323
-- be adjusted correctly now.
2424
select result as colocation_group_collations_same from run_command_on_all_nodes($$
25-
select count(distinct(distributioncolumncollation)) = 4
25+
select count(distinct(distributioncolumncollation)) = 3
2626
from pg_dist_partition
2727
join pg_class on (logicalrelid = pg_class.oid)
2828
join pg_namespace on (relnamespace = pg_namespace.oid)
2929
join pg_dist_colocation using (colocationid)
30-
where pg_namespace.nspname = 'post_14_upgrade'
30+
where pg_namespace.nspname = 'Post_14_!''upgrade'
3131
$$);

src/test/regress/sql/upgrade_post_14_before.sql

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ AS upgrade_test_old_citus_version_lt_14_0;
1111
SET citus.shard_replication_factor TO 1;
1212

1313
SET client_min_messages TO WARNING;
14-
DROP SCHEMA IF EXISTS post_14_upgrade CASCADE;
14+
DROP SCHEMA IF EXISTS "Post_14_!'upgrade" CASCADE;
1515

16-
CREATE SCHEMA post_14_upgrade;
17-
SET search_path = post_14_upgrade;
16+
CREATE SCHEMA "Post_14_!'upgrade";
17+
SET search_path = "Post_14_!'upgrade";
1818

1919
create table test_c1_tbl_1(text_col text);
2020
create table test_c1_tbl_2(text_col text);
@@ -24,14 +24,10 @@ create table test_c2_tbl_1(text_col text collate "en-x-icu");
2424
create table test_c2_tbl_2(text_col text collate "en-x-icu");
2525
create table test_c2_tbl_3(text_col text collate "en-x-icu");
2626

27-
create table test_c3_tbl_1(text_col text collate "C");
28-
create table test_c3_tbl_2(text_col text collate "C");
29-
create table test_c3_tbl_3(text_col text collate "C");
30-
3127
-- also some tables with weird names
32-
create table "test_c4_Tbl_!'@#_1" (text_col text collate "en_US.utf8");
33-
create table "test_c4_Tbl_!'@#_2" (text_col text collate "en_US.utf8");
34-
create table "test_c4_Tbl_!'@#_3" (text_col text collate "en_US.utf8");
28+
create table "test_c3_Tbl_!'@#_1" (text_col text collate "C");
29+
create table "test_c3_Tbl_!'@#_2" (text_col text collate "C");
30+
create table "test_c3_Tbl_!'@#_3" (text_col text collate "C");
3531

3632
select create_distributed_table('test_c1_tbl_1', 'text_col', colocate_with => 'none');
3733
select create_distributed_table('test_c1_tbl_2', 'text_col', colocate_with => 'test_c1_tbl_1');
@@ -41,24 +37,20 @@ select create_distributed_table('test_c2_tbl_1', 'text_col', colocate_with => 'n
4137
select create_distributed_table('test_c2_tbl_2', 'text_col', colocate_with => 'test_c2_tbl_1');
4238
select create_distributed_table('test_c2_tbl_3', 'text_col', colocate_with => 'test_c2_tbl_1');
4339

44-
select create_distributed_table('test_c3_tbl_1', 'text_col', colocate_with => 'none');
45-
select create_distributed_table('test_c3_tbl_2', 'text_col', colocate_with => 'test_c3_tbl_1');
46-
select create_distributed_table('test_c3_tbl_3', 'text_col', colocate_with => 'test_c3_tbl_1');
47-
48-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_1"', 'text_col', colocate_with => 'none');
49-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_2"', 'text_col', colocate_with => '"test_c4_Tbl_!''@#_1"');
50-
SELECT create_distributed_table('"test_c4_Tbl_!''@#_3"', 'text_col', colocate_with => '"test_c4_Tbl_!''@#_1"');
40+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_1"', 'text_col', colocate_with => 'none');
41+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_2"', 'text_col', colocate_with => '"test_c3_Tbl_!''@#_1"');
42+
SELECT create_distributed_table('"test_c3_Tbl_!''@#_3"', 'text_col', colocate_with => '"test_c3_Tbl_!''@#_1"');
5143

5244
-- Make sure we have different colocation groups as we forced them
5345
-- to be so by providing colocate_with=>'none' for the first table in each
5446
-- group.
5547
select result as colocationids_different from run_command_on_all_nodes($$
56-
select count(distinct(colocationid)) = 4
48+
select count(distinct(colocationid)) = 3
5749
from pg_dist_partition
5850
join pg_class on (logicalrelid = pg_class.oid)
5951
join pg_namespace on (relnamespace = pg_namespace.oid)
6052
join pg_dist_colocation using (colocationid)
61-
where pg_namespace.nspname = 'post_14_upgrade'
53+
where pg_namespace.nspname = 'Post_14_!''upgrade'
6254
$$);
6355

6456
-- However, given that right now we're on an older version Citus,
@@ -72,5 +64,5 @@ select result as colocation_group_collations_same from run_command_on_all_nodes(
7264
join pg_class on (logicalrelid = pg_class.oid)
7365
join pg_namespace on (relnamespace = pg_namespace.oid)
7466
join pg_dist_colocation using (colocationid)
75-
where pg_namespace.nspname = 'post_14_upgrade'
67+
where pg_namespace.nspname = 'Post_14_!''upgrade'
7668
$$);

0 commit comments

Comments
 (0)