From 2768b80fd533400f2c3e242bd907a144f2246193 Mon Sep 17 00:00:00 2001 From: Nils Dijk Date: Tue, 25 Oct 2022 16:18:54 +0200 Subject: [PATCH] enforce not null constraint on shardgroupid for shards --- src/backend/distributed/sql/citus--11.2-1--11.3-1.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/sql/citus--11.2-1--11.3-1.sql b/src/backend/distributed/sql/citus--11.2-1--11.3-1.sql index f30b57db6..8ba6739ce 100644 --- a/src/backend/distributed/sql/citus--11.2-1--11.3-1.sql +++ b/src/backend/distributed/sql/citus--11.2-1--11.3-1.sql @@ -46,4 +46,9 @@ WHERE shard.logicalrelid = shardgroup.logicalrelid shard.shardmaxvalue = shardgroup.shardmaxvalue OR ( shard.shardmaxvalue IS NULL AND shardgroup.shardmaxvalue IS NULL) - ); \ No newline at end of file + ); + +-- risky, but we want to fail quickly here. If there are cases where a shard is not associated correctly with a +-- shardgroup we would not want the setup to use the new Citus version as it hard relies on the shardgroups being +-- correctly associated. +ALTER TABLE pg_catalog.pg_dist_shard ALTER COLUMN shardgroupid SET NOT NULL;