@@ -970,6 +970,126 @@ DETAIL: drop cascades to table inht2
970
970
drop cascades to table inhts
971
971
drop cascades to table inht3
972
972
drop cascades to table inht4
973
+ -- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints
974
+ CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2));
975
+ NOTICE: CREATE TABLE / UNIQUE will create implicit index "test_constraints_val1_val2_key" for table "test_constraints"
976
+ CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
977
+ \d+ test_constraints
978
+ Table "public.test_constraints"
979
+ Column | Type | Modifiers | Storage | Stats target | Description
980
+ --------+-------------------+-----------+----------+--------------+-------------
981
+ id | integer | | plain | |
982
+ val1 | character varying | | extended | |
983
+ val2 | integer | | plain | |
984
+ Indexes:
985
+ "test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
986
+ Child tables: test_constraints_inh
987
+ Has OIDs: no
988
+
989
+ ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
990
+ \d+ test_constraints
991
+ Table "public.test_constraints"
992
+ Column | Type | Modifiers | Storage | Stats target | Description
993
+ --------+-------------------+-----------+----------+--------------+-------------
994
+ id | integer | | plain | |
995
+ val1 | character varying | | extended | |
996
+ val2 | integer | | plain | |
997
+ Child tables: test_constraints_inh
998
+ Has OIDs: no
999
+
1000
+ \d+ test_constraints_inh
1001
+ Table "public.test_constraints_inh"
1002
+ Column | Type | Modifiers | Storage | Stats target | Description
1003
+ --------+-------------------+-----------+----------+--------------+-------------
1004
+ id | integer | | plain | |
1005
+ val1 | character varying | | extended | |
1006
+ val2 | integer | | plain | |
1007
+ Inherits: test_constraints
1008
+ Has OIDs: no
1009
+
1010
+ DROP TABLE test_constraints_inh;
1011
+ DROP TABLE test_constraints;
1012
+ CREATE TABLE circles (
1013
+ c circle,
1014
+ EXCLUDE USING gist (c WITH &&)
1015
+ );
1016
+ NOTICE: CREATE TABLE / EXCLUDE will create implicit index "circles_c_excl" for table "circles"
1017
+ CREATE TABLE circles_inh () INHERITS (circles);
1018
+ \d+ circles
1019
+ Table "public.circles"
1020
+ Column | Type | Modifiers | Storage | Stats target | Description
1021
+ --------+--------+-----------+---------+--------------+-------------
1022
+ c | circle | | plain | |
1023
+ Indexes:
1024
+ "circles_c_excl" EXCLUDE USING gist (c WITH &&)
1025
+ Child tables: circles_inh
1026
+ Has OIDs: no
1027
+
1028
+ ALTER TABLE circles DROP CONSTRAINT circles_c_excl;
1029
+ \d+ circles
1030
+ Table "public.circles"
1031
+ Column | Type | Modifiers | Storage | Stats target | Description
1032
+ --------+--------+-----------+---------+--------------+-------------
1033
+ c | circle | | plain | |
1034
+ Child tables: circles_inh
1035
+ Has OIDs: no
1036
+
1037
+ \d+ circles_inh
1038
+ Table "public.circles_inh"
1039
+ Column | Type | Modifiers | Storage | Stats target | Description
1040
+ --------+--------+-----------+---------+--------------+-------------
1041
+ c | circle | | plain | |
1042
+ Inherits: circles
1043
+ Has OIDs: no
1044
+
1045
+ DROP TABLE circles_inh;
1046
+ DROP TABLE circles;
1047
+ -- Test non-inheritable foreign key contraints
1048
+ CREATE TABLE test_primary_constraints(id int PRIMARY KEY);
1049
+ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_primary_constraints_pkey" for table "test_primary_constraints"
1050
+ CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id));
1051
+ CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints);
1052
+ \d+ test_primary_constraints
1053
+ Table "public.test_primary_constraints"
1054
+ Column | Type | Modifiers | Storage | Stats target | Description
1055
+ --------+---------+-----------+---------+--------------+-------------
1056
+ id | integer | not null | plain | |
1057
+ Indexes:
1058
+ "test_primary_constraints_pkey" PRIMARY KEY, btree (id)
1059
+ Referenced by:
1060
+ TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
1061
+ Has OIDs: no
1062
+
1063
+ \d+ test_foreign_constraints
1064
+ Table "public.test_foreign_constraints"
1065
+ Column | Type | Modifiers | Storage | Stats target | Description
1066
+ --------+---------+-----------+---------+--------------+-------------
1067
+ id1 | integer | | plain | |
1068
+ Foreign-key constraints:
1069
+ "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
1070
+ Child tables: test_foreign_constraints_inh
1071
+ Has OIDs: no
1072
+
1073
+ ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
1074
+ \d+ test_foreign_constraints
1075
+ Table "public.test_foreign_constraints"
1076
+ Column | Type | Modifiers | Storage | Stats target | Description
1077
+ --------+---------+-----------+---------+--------------+-------------
1078
+ id1 | integer | | plain | |
1079
+ Child tables: test_foreign_constraints_inh
1080
+ Has OIDs: no
1081
+
1082
+ \d+ test_foreign_constraints_inh
1083
+ Table "public.test_foreign_constraints_inh"
1084
+ Column | Type | Modifiers | Storage | Stats target | Description
1085
+ --------+---------+-----------+---------+--------------+-------------
1086
+ id1 | integer | | plain | |
1087
+ Inherits: test_foreign_constraints
1088
+ Has OIDs: no
1089
+
1090
+ DROP TABLE test_foreign_constraints_inh;
1091
+ DROP TABLE test_foreign_constraints;
1092
+ DROP TABLE test_primary_constraints;
973
1093
--
974
1094
-- Test parameterized append plans for inheritance trees
975
1095
--
0 commit comments