Skip to content

Commit 9578393

Browse files
committed
Add tests for domain-related information schema views
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://www.postgresql.org/message-id/flat/9ec24d7b-633d-463a-84c6-7acff769c9e8%40eisentraut.org
1 parent f69319f commit 9578393

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

src/test/regress/expected/domain.out

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,3 +1207,50 @@ create domain testdomain1 as int constraint unsigned check (value > 0);
12071207
alter domain testdomain1 rename constraint unsigned to unsigned_foo;
12081208
alter domain testdomain1 drop constraint unsigned_foo;
12091209
drop domain testdomain1;
1210+
--
1211+
-- Information schema
1212+
--
1213+
SELECT * FROM information_schema.column_domain_usage
1214+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
1215+
ORDER BY domain_name;
1216+
domain_catalog | domain_schema | domain_name | table_catalog | table_schema | table_name | column_name
1217+
----------------+---------------+-------------+---------------+--------------+------------+-------------
1218+
regression | public | con | regression | public | domcontest | col1
1219+
regression | public | dom | regression | public | domview | col1
1220+
regression | public | things | regression | public | thethings | stuff
1221+
(3 rows)
1222+
1223+
SELECT * FROM information_schema.domain_constraints
1224+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
1225+
ORDER BY constraint_name;
1226+
constraint_catalog | constraint_schema | constraint_name | domain_catalog | domain_schema | domain_name | is_deferrable | initially_deferred
1227+
--------------------+-------------------+-----------------+----------------+---------------+-------------+---------------+--------------------
1228+
regression | public | con_check | regression | public | con | NO | NO
1229+
regression | public | meow | regression | public | things | NO | NO
1230+
regression | public | pos_int_check | regression | public | pos_int | NO | NO
1231+
(3 rows)
1232+
1233+
SELECT * FROM information_schema.domains
1234+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
1235+
ORDER BY domain_name;
1236+
domain_catalog | domain_schema | domain_name | data_type | character_maximum_length | character_octet_length | character_set_catalog | character_set_schema | character_set_name | collation_catalog | collation_schema | collation_name | numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type | interval_precision | domain_default | udt_catalog | udt_schema | udt_name | scope_catalog | scope_schema | scope_name | maximum_cardinality | dtd_identifier
1237+
----------------+---------------+-------------+-----------+--------------------------+------------------------+-----------------------+----------------------+--------------------+-------------------+------------------+----------------+-------------------+-------------------------+---------------+--------------------+---------------+--------------------+----------------+-------------+------------+----------+---------------+--------------+------------+---------------------+----------------
1238+
regression | public | con | integer | | | | | | | | | 32 | 2 | 0 | | | | | regression | pg_catalog | int4 | | | | | 1
1239+
regression | public | dom | integer | | | | | | | | | 32 | 2 | 0 | | | | | regression | pg_catalog | int4 | | | | | 1
1240+
regression | public | pos_int | integer | | | | | | | | | 32 | 2 | 0 | | | | | regression | pg_catalog | int4 | | | | | 1
1241+
regression | public | things | integer | | | | | | | | | 32 | 2 | 0 | | | | | regression | pg_catalog | int4 | | | | | 1
1242+
(4 rows)
1243+
1244+
SELECT * FROM information_schema.check_constraints
1245+
WHERE (constraint_schema, constraint_name)
1246+
IN (SELECT constraint_schema, constraint_name
1247+
FROM information_schema.domain_constraints
1248+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things'))
1249+
ORDER BY constraint_name;
1250+
constraint_catalog | constraint_schema | constraint_name | check_clause
1251+
--------------------+-------------------+-----------------+--------------
1252+
regression | public | con_check | (VALUE > 0)
1253+
regression | public | meow | (VALUE < 11)
1254+
regression | public | pos_int_check | (VALUE > 0)
1255+
(3 rows)
1256+

src/test/regress/sql/domain.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,27 @@ create domain testdomain1 as int constraint unsigned check (value > 0);
809809
alter domain testdomain1 rename constraint unsigned to unsigned_foo;
810810
alter domain testdomain1 drop constraint unsigned_foo;
811811
drop domain testdomain1;
812+
813+
814+
--
815+
-- Information schema
816+
--
817+
818+
SELECT * FROM information_schema.column_domain_usage
819+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
820+
ORDER BY domain_name;
821+
822+
SELECT * FROM information_schema.domain_constraints
823+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
824+
ORDER BY constraint_name;
825+
826+
SELECT * FROM information_schema.domains
827+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')
828+
ORDER BY domain_name;
829+
830+
SELECT * FROM information_schema.check_constraints
831+
WHERE (constraint_schema, constraint_name)
832+
IN (SELECT constraint_schema, constraint_name
833+
FROM information_schema.domain_constraints
834+
WHERE domain_name IN ('con', 'dom', 'pos_int', 'things'))
835+
ORDER BY constraint_name;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy