From 8cb5f81176e06dded88d49179debddab992ff1ce Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 29 Mar 2023 16:42:16 +0200 Subject: [PATCH 1/2] Add tests for information schema constraints views --- src/test/regress/sql/constraints.sql | 16 ++++++++++++++++ src/test/regress/sql/domain.sql | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/test/regress/sql/constraints.sql b/src/test/regress/sql/constraints.sql index ae427d25e9..0c8f681b51 100644 --- a/src/test/regress/sql/constraints.sql +++ b/src/test/regress/sql/constraints.sql @@ -589,6 +589,22 @@ CREATE TABLE notnull_tbl3 (a INTEGER NOT NULL, CHECK (a IS NOT NULL)); ALTER TABLE notnull_tbl3 DROP CONSTRAINT pk; \d notnull_tbl3 +-- +-- Information schema +-- + +SELECT * FROM information_schema.check_constraints + WHERE constraint_schema = 'public' + ORDER BY constraint_name; + +SELECT * FROM information_schema.constraint_column_usage + WHERE constraint_schema = 'public' + ORDER BY table_name, column_name, constraint_name; + +SELECT * FROM information_schema.table_constraints + WHERE constraint_schema = 'public' + ORDER BY constraint_name; + -- Comments -- Setup a low-level role to enforce non-superuser checks. CREATE ROLE regress_constraint_comments; diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql index 75703940f9..3096b377eb 100644 --- a/src/test/regress/sql/domain.sql +++ b/src/test/regress/sql/domain.sql @@ -812,3 +812,27 @@ CREATE TABLE thethings (stuff things); alter domain testdomain1 rename constraint unsigned to unsigned_foo; alter domain testdomain1 drop constraint unsigned_foo; drop domain testdomain1; + + +-- +-- Information schema +-- + +SELECT * FROM information_schema.column_domain_usage + WHERE domain_schema = 'public' AND table_schema = 'public' + ORDER BY domain_name; + +SELECT * FROM information_schema.domain_constraints + WHERE domain_schema = 'public' + ORDER BY constraint_name; + +SELECT * FROM information_schema.domains + WHERE domain_schema = 'public' + ORDER BY domain_name; + +SELECT * FROM information_schema.check_constraints + WHERE (constraint_schema, constraint_name) + IN (SELECT constraint_schema, constraint_name + FROM information_schema.domain_constraints + WHERE domain_schema = 'public') + ORDER BY constraint_name; -- 2.40.0