From 6b6d959facac53aa49e21dc0751b48f75561d117 Mon Sep 17 00:00:00 2001 From: Mehmet YILMAZ Date: Fri, 8 Aug 2025 13:46:11 +0300 Subject: [PATCH] PG18 - pg17.sql Simplify step 10 verification to use COUNT(*) instead of SELECT * (#8111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #8096 PostgreSQL 18 adds a `conenforced` flag allowing `CHECK` constraints to be declared `NOT ENFORCED`. https://github.com/postgres/postgres/commit/ca87c415e2fccf81cec6fd45698dde9fae0ab570 ```diff @@ -1256,26 +1278,26 @@ distributed_partitioned_table_id_partition_col_excl | x (2 rows) -- Step 9: Drop the exclusion constraints from both tables \c - - :master_host :master_port SET search_path TO pg17; ALTER TABLE distributed_partitioned_table DROP CONSTRAINT dist_exclude_named; ALTER TABLE local_partitioned_table DROP CONSTRAINT local_exclude_named; -- Step 10: Verify the constraints were dropped SELECT * FROM pg_constraint WHERE conname = 'dist_exclude_named' AND contype = 'x'; - oid | conname | connamespace | contype | condeferrable | condeferred | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin + oid | conname | connamespace | contype | condeferrable | condeferred | conenforced | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conperiod | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin -----+---------+--------------+---------+---------------+-------------+-------------+--------------+----------+----------+----------+-------------+-----------+-------------+-------------+---------------+------------+-------------+--------------+-----------+--------+---------+-----------+-----------+-----------+----------------+-----------+-------- (0 rows) SELECT * FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = 'x'; - oid | conname | connamespace | contype | condeferrable | condeferred | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin + oid | conname | connamespace | contype | condeferrable | condeferred | conenforced | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conperiod | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin -----+---------+--------------+---------+---------------+-------------+-------------+--------------+----------+----------+----------+-------------+-----------+-------------+-------------+---------------+------------+-------------+--------------+-----------+--------+---------+-----------+-----------+-----------+----------------+-----------+-------- (0 rows) ``` The purpose of step 10 is merely to confirm that the exclusion constraints dist_exclude_named and local_exclude_named have been dropped. There’s no need to pull back every column from pg_constraint—we only care about whether any matching row remains. - Reduces noise in the output - Eliminates dependence on the full set of pg_constraint columns (which can drift across Postgres versions) - Resolves the pg18 regression diff without altering test expectations --- src/test/regress/expected/pg17.out | 14 ++++++++------ src/test/regress/sql/pg17.sql | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/regress/expected/pg17.out b/src/test/regress/expected/pg17.out index 721087d3d..41b82b067 100644 --- a/src/test/regress/expected/pg17.out +++ b/src/test/regress/expected/pg17.out @@ -1262,15 +1262,17 @@ SET search_path TO pg17; ALTER TABLE distributed_partitioned_table DROP CONSTRAINT dist_exclude_named; ALTER TABLE local_partitioned_table DROP CONSTRAINT local_exclude_named; -- Step 10: Verify the constraints were dropped -SELECT * FROM pg_constraint WHERE conname = 'dist_exclude_named' AND contype = 'x'; - oid | conname | connamespace | contype | condeferrable | condeferred | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin +SELECT COUNT(*) FROM pg_constraint WHERE conname = 'dist_exclude_named' AND contype = 'x'; + count --------------------------------------------------------------------- -(0 rows) + 0 +(1 row) -SELECT * FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = 'x'; - oid | conname | connamespace | contype | condeferrable | condeferred | convalidated | conrelid | contypid | conindid | conparentid | confrelid | confupdtype | confdeltype | confmatchtype | conislocal | coninhcount | connoinherit | conkey | confkey | conpfeqop | conppeqop | conffeqop | confdelsetcols | conexclop | conbin +SELECT COUNT(*) FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = 'x'; + count --------------------------------------------------------------------- -(0 rows) + 0 +(1 row) -- Step 11: Clean up - Drop the tables DROP TABLE distributed_partitioned_table CASCADE; diff --git a/src/test/regress/sql/pg17.sql b/src/test/regress/sql/pg17.sql index 60ea6d9e7..713b58952 100644 --- a/src/test/regress/sql/pg17.sql +++ b/src/test/regress/sql/pg17.sql @@ -669,8 +669,8 @@ ALTER TABLE distributed_partitioned_table DROP CONSTRAINT dist_exclude_named; ALTER TABLE local_partitioned_table DROP CONSTRAINT local_exclude_named; -- Step 10: Verify the constraints were dropped -SELECT * FROM pg_constraint WHERE conname = 'dist_exclude_named' AND contype = 'x'; -SELECT * FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = 'x'; +SELECT COUNT(*) FROM pg_constraint WHERE conname = 'dist_exclude_named' AND contype = 'x'; +SELECT COUNT(*) FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = 'x'; -- Step 11: Clean up - Drop the tables DROP TABLE distributed_partitioned_table CASCADE;