@@ -1903,20 +1903,20 @@ ALTER TABLE fk_notpartitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_partitione
1903
1903
-- Constraint will be invalid.
1904
1904
SELECT conname, convalidated FROM pg_constraint
1905
1905
WHERE conrelid = 'fk_notpartitioned_fk'::regclass ORDER BY oid::regclass::text;
1906
- conname | convalidated
1907
- --------------------------------+--------------
1908
- fk_notpartitioned_fk_a_b_fkey | f
1909
- fk_notpartitioned_fk_a_b_fkey1 | f
1906
+ conname | convalidated
1907
+ --------------------------------- +--------------
1908
+ fk_notpartitioned_fk_a_b_fkey | f
1909
+ fk_notpartitioned_fk_a_b_fkey_1 | f
1910
1910
(2 rows)
1911
1911
1912
1912
ALTER TABLE fk_notpartitioned_fk VALIDATE CONSTRAINT fk_notpartitioned_fk_a_b_fkey;
1913
1913
-- All constraints are now valid.
1914
1914
SELECT conname, convalidated FROM pg_constraint
1915
1915
WHERE conrelid = 'fk_notpartitioned_fk'::regclass ORDER BY oid::regclass::text;
1916
- conname | convalidated
1917
- --------------------------------+--------------
1918
- fk_notpartitioned_fk_a_b_fkey | t
1919
- fk_notpartitioned_fk_a_b_fkey1 | t
1916
+ conname | convalidated
1917
+ --------------------------------- +--------------
1918
+ fk_notpartitioned_fk_a_b_fkey | t
1919
+ fk_notpartitioned_fk_a_b_fkey_1 | t
1920
1920
(2 rows)
1921
1921
1922
1922
DROP TABLE fk_notpartitioned_fk, fk_partitioned_pk;
@@ -2589,40 +2589,40 @@ INSERT into pk VALUES (1), (1000), (2000), (3000), (4000), (4500);
2589
2589
INSERT into fk VALUES (1), (1000), (2000), (3000), (4000), (4500);
2590
2590
-- should fail: referencing value present
2591
2591
DELETE FROM pk WHERE a = 1;
2592
- ERROR: update or delete on table "pk1" violates foreign key constraint "fk_a_fkey1 " on table "fk"
2592
+ ERROR: update or delete on table "pk1" violates foreign key constraint "fk_a_fkey_1 " on table "fk"
2593
2593
DETAIL: Key (a)=(1) is still referenced from table "fk".
2594
2594
DELETE FROM pk WHERE a = 1000;
2595
- ERROR: update or delete on table "pk2" violates foreign key constraint "fk_a_fkey2 " on table "fk"
2595
+ ERROR: update or delete on table "pk2" violates foreign key constraint "fk_a_fkey_2 " on table "fk"
2596
2596
DETAIL: Key (a)=(1000) is still referenced from table "fk".
2597
2597
DELETE FROM pk WHERE a = 2000;
2598
- ERROR: update or delete on table "pk3" violates foreign key constraint "fk_a_fkey3 " on table "fk"
2598
+ ERROR: update or delete on table "pk3" violates foreign key constraint "fk_a_fkey_3 " on table "fk"
2599
2599
DETAIL: Key (a)=(2000) is still referenced from table "fk".
2600
2600
DELETE FROM pk WHERE a = 3000;
2601
- ERROR: update or delete on table "pk4" violates foreign key constraint "fk_a_fkey4 " on table "fk"
2601
+ ERROR: update or delete on table "pk4" violates foreign key constraint "fk_a_fkey_4 " on table "fk"
2602
2602
DETAIL: Key (a)=(3000) is still referenced from table "fk".
2603
2603
DELETE FROM pk WHERE a = 4000;
2604
- ERROR: update or delete on table "pk51" violates foreign key constraint "fk_a_fkey6 " on table "fk"
2604
+ ERROR: update or delete on table "pk51" violates foreign key constraint "fk_a_fkey_6 " on table "fk"
2605
2605
DETAIL: Key (a)=(4000) is still referenced from table "fk".
2606
2606
DELETE FROM pk WHERE a = 4500;
2607
- ERROR: update or delete on table "pk52" violates foreign key constraint "fk_a_fkey7 " on table "fk"
2607
+ ERROR: update or delete on table "pk52" violates foreign key constraint "fk_a_fkey_7 " on table "fk"
2608
2608
DETAIL: Key (a)=(4500) is still referenced from table "fk".
2609
2609
UPDATE pk SET a = 2 WHERE a = 1;
2610
- ERROR: update or delete on table "pk1" violates foreign key constraint "fk_a_fkey1 " on table "fk"
2610
+ ERROR: update or delete on table "pk1" violates foreign key constraint "fk_a_fkey_1 " on table "fk"
2611
2611
DETAIL: Key (a)=(1) is still referenced from table "fk".
2612
2612
UPDATE pk SET a = 1002 WHERE a = 1000;
2613
- ERROR: update or delete on table "pk2" violates foreign key constraint "fk_a_fkey2 " on table "fk"
2613
+ ERROR: update or delete on table "pk2" violates foreign key constraint "fk_a_fkey_2 " on table "fk"
2614
2614
DETAIL: Key (a)=(1000) is still referenced from table "fk".
2615
2615
UPDATE pk SET a = 2002 WHERE a = 2000;
2616
- ERROR: update or delete on table "pk3" violates foreign key constraint "fk_a_fkey3 " on table "fk"
2616
+ ERROR: update or delete on table "pk3" violates foreign key constraint "fk_a_fkey_3 " on table "fk"
2617
2617
DETAIL: Key (a)=(2000) is still referenced from table "fk".
2618
2618
UPDATE pk SET a = 3002 WHERE a = 3000;
2619
- ERROR: update or delete on table "pk4" violates foreign key constraint "fk_a_fkey4 " on table "fk"
2619
+ ERROR: update or delete on table "pk4" violates foreign key constraint "fk_a_fkey_4 " on table "fk"
2620
2620
DETAIL: Key (a)=(3000) is still referenced from table "fk".
2621
2621
UPDATE pk SET a = 4002 WHERE a = 4000;
2622
- ERROR: update or delete on table "pk51" violates foreign key constraint "fk_a_fkey6 " on table "fk"
2622
+ ERROR: update or delete on table "pk51" violates foreign key constraint "fk_a_fkey_6 " on table "fk"
2623
2623
DETAIL: Key (a)=(4000) is still referenced from table "fk".
2624
2624
UPDATE pk SET a = 4502 WHERE a = 4500;
2625
- ERROR: update or delete on table "pk52" violates foreign key constraint "fk_a_fkey7 " on table "fk"
2625
+ ERROR: update or delete on table "pk52" violates foreign key constraint "fk_a_fkey_7 " on table "fk"
2626
2626
DETAIL: Key (a)=(4500) is still referenced from table "fk".
2627
2627
-- now they should work
2628
2628
DELETE FROM fk;
@@ -2661,19 +2661,19 @@ CREATE TABLE dropfk (a int REFERENCES droppk);
2661
2661
INSERT into dropfk VALUES (1), (1000), (1500), (2000);
2662
2662
-- these should all fail
2663
2663
ALTER TABLE droppk DETACH PARTITION droppk_d;
2664
- ERROR: removing partition "droppk_d" violates foreign key constraint "dropfk_a_fkey5 "
2664
+ ERROR: removing partition "droppk_d" violates foreign key constraint "dropfk_a_fkey_5 "
2665
2665
DETAIL: Key (a)=(2000) is still referenced from table "dropfk".
2666
2666
ALTER TABLE droppk2 DETACH PARTITION droppk2_d;
2667
- ERROR: removing partition "droppk2_d" violates foreign key constraint "dropfk_a_fkey4 "
2667
+ ERROR: removing partition "droppk2_d" violates foreign key constraint "dropfk_a_fkey_4 "
2668
2668
DETAIL: Key (a)=(1500) is still referenced from table "dropfk".
2669
2669
ALTER TABLE droppk DETACH PARTITION droppk1;
2670
- ERROR: removing partition "droppk1" violates foreign key constraint "dropfk_a_fkey1 "
2670
+ ERROR: removing partition "droppk1" violates foreign key constraint "dropfk_a_fkey_1 "
2671
2671
DETAIL: Key (a)=(1) is still referenced from table "dropfk".
2672
2672
ALTER TABLE droppk DETACH PARTITION droppk2;
2673
- ERROR: removing partition "droppk2" violates foreign key constraint "dropfk_a_fkey2 "
2673
+ ERROR: removing partition "droppk2" violates foreign key constraint "dropfk_a_fkey_2 "
2674
2674
DETAIL: Key (a)=(1000) is still referenced from table "dropfk".
2675
2675
ALTER TABLE droppk2 DETACH PARTITION droppk21;
2676
- ERROR: removing partition "droppk21" violates foreign key constraint "dropfk_a_fkey3 "
2676
+ ERROR: removing partition "droppk21" violates foreign key constraint "dropfk_a_fkey_3 "
2677
2677
DETAIL: Key (a)=(1000) is still referenced from table "dropfk".
2678
2678
-- dropping partitions is disallowed
2679
2679
DROP TABLE droppk_d;
@@ -2742,15 +2742,15 @@ SELECT pg_describe_object('pg_constraint'::regclass, oid, 0), confrelid::regclas
2742
2742
FROM pg_catalog.pg_constraint
2743
2743
WHERE conrelid IN (SELECT relid FROM pg_partition_tree('fk'))
2744
2744
ORDER BY conrelid::regclass::text, conname;
2745
- pg_describe_object | confrelid | case
2746
- ------------------------------------+-----------+-----------------------------------
2745
+ pg_describe_object | confrelid | case
2746
+ ------------------------------------+-----------+------------------------------------
2747
2747
constraint fk_a_fkey on table fk | pk | TOP
2748
- constraint fk_a_fkey1 on table fk | pk1 | constraint fk_a_fkey on table fk
2749
- constraint fk_a_fkey2 on table fk | pk11 | constraint fk_a_fkey1 on table fk
2750
- constraint fk_a_fkey3 on table fk | pk2 | constraint fk_a_fkey on table fk
2751
- constraint fk_a_fkey4 on table fk | pk3 | constraint fk_a_fkey on table fk
2752
- constraint fk_a_fkey5 on table fk | pk31 | constraint fk_a_fkey4 on table fk
2753
- constraint fk_a_fkey6 on table fk | pk32 | constraint fk_a_fkey4 on table fk
2748
+ constraint fk_a_fkey_1 on table fk | pk1 | constraint fk_a_fkey on table fk
2749
+ constraint fk_a_fkey_2 on table fk | pk11 | constraint fk_a_fkey_1 on table fk
2750
+ constraint fk_a_fkey_3 on table fk | pk2 | constraint fk_a_fkey on table fk
2751
+ constraint fk_a_fkey_4 on table fk | pk3 | constraint fk_a_fkey on table fk
2752
+ constraint fk_a_fkey_5 on table fk | pk31 | constraint fk_a_fkey_4 on table fk
2753
+ constraint fk_a_fkey_6 on table fk | pk32 | constraint fk_a_fkey_4 on table fk
2754
2754
constraint fk_a_fkey on table fk1 | pk | constraint fk_a_fkey on table fk
2755
2755
constraint fk_a_fkey on table fk11 | pk | constraint fk_a_fkey on table fk1
2756
2756
constraint fk_a_fkey on table fk2 | pk | constraint fk_a_fkey on table fk
@@ -2853,10 +2853,10 @@ CREATE TABLE pt1 PARTITION OF pt1_2 FOR VALUES IN (1);
2853
2853
CREATE TABLE pt2 PARTITION OF pt1_2 FOR VALUES IN (2);
2854
2854
CREATE TABLE ref(f1 int, f2 int, f3 int);
2855
2855
ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt;
2856
- ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey1
2856
+ ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey_1
2857
2857
DEFERRABLE INITIALLY DEFERRED; -- fails
2858
- ERROR: cannot alter constraint "ref_f1_f2_fkey1 " on relation "ref"
2859
- DETAIL: Constraint "ref_f1_f2_fkey1 " is derived from constraint "ref_f1_f2_fkey" of relation "ref".
2858
+ ERROR: cannot alter constraint "ref_f1_f2_fkey_1 " on relation "ref"
2859
+ DETAIL: Constraint "ref_f1_f2_fkey_1 " is derived from constraint "ref_f1_f2_fkey" of relation "ref".
2860
2860
HINT: You may alter the constraint it derives from instead.
2861
2861
ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey
2862
2862
DEFERRABLE INITIALLY DEFERRED;
@@ -2958,7 +2958,7 @@ ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE RESTRICT ON DELETE RE
2958
2958
CREATE TABLE fk_d PARTITION OF fk DEFAULT;
2959
2959
INSERT INTO fk VALUES (20), (30);
2960
2960
DELETE FROM pk WHERE a = 20;
2961
- ERROR: update or delete on table "pk11" violates RESTRICT setting of foreign key constraint "fk_a_fkey2 " on table "fk"
2961
+ ERROR: update or delete on table "pk11" violates RESTRICT setting of foreign key constraint "fk_a_fkey_2 " on table "fk"
2962
2962
DETAIL: Key (a)=(20) is referenced from table "fk".
2963
2963
UPDATE pk SET a = 90 WHERE a = 30;
2964
2964
ERROR: update or delete on table "pk" violates RESTRICT setting of foreign key constraint "fk_a_fkey" on table "fk"
@@ -3306,7 +3306,7 @@ INSERT INTO fk_r_1 (id, p_id, p_jd) VALUES (2, 1, 2); -- should fail
3306
3306
ERROR: insert or update on table "fk_r_1" violates foreign key constraint "fk_r_p_id_p_jd_fkey"
3307
3307
DETAIL: Key (p_id, p_jd)=(1, 2) is not present in table "fk_p".
3308
3308
DELETE FROM fk_p; -- should fail
3309
- ERROR: update or delete on table "fk_p_1_1" violates foreign key constraint "fk_r_1_p_id_p_jd_fkey1 " on table "fk_r_1"
3309
+ ERROR: update or delete on table "fk_p_1_1" violates foreign key constraint "fk_r_p_id_p_jd_fkey_7 " on table "fk_r_1"
3310
3310
DETAIL: Key (id, jd)=(1, 1) is still referenced from table "fk_r_1".
3311
3311
ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1);
3312
3312
ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2);
@@ -3326,13 +3326,13 @@ Foreign-key constraints:
3326
3326
Number of partitions: 1 (Use \d+ to list them.)
3327
3327
3328
3328
DELETE FROM fk_p; -- should fail
3329
- ERROR: update or delete on table "fk_p_1_1" violates foreign key constraint "fk_r_p_id_p_jd_fkey2 " on table "fk_r"
3329
+ ERROR: update or delete on table "fk_p_1_1" violates foreign key constraint "fk_r_p_id_p_jd_fkey_2 " on table "fk_r"
3330
3330
DETAIL: Key (id, jd)=(1, 1) is still referenced from table "fk_r".
3331
3331
-- these should all fail
3332
3332
ALTER TABLE fk_r_1 DROP CONSTRAINT fk_r_p_id_p_jd_fkey;
3333
3333
ERROR: cannot drop inherited constraint "fk_r_p_id_p_jd_fkey" of relation "fk_r_1"
3334
- ALTER TABLE fk_r DROP CONSTRAINT fk_r_p_id_p_jd_fkey1 ;
3335
- ERROR: cannot drop inherited constraint "fk_r_p_id_p_jd_fkey1 " of relation "fk_r"
3334
+ ALTER TABLE fk_r DROP CONSTRAINT fk_r_p_id_p_jd_fkey_1 ;
3335
+ ERROR: cannot drop inherited constraint "fk_r_p_id_p_jd_fkey_1 " of relation "fk_r"
3336
3336
ALTER TABLE fk_r_2 DROP CONSTRAINT fk_r_p_id_p_jd_fkey;
3337
3337
ERROR: cannot drop inherited constraint "fk_r_p_id_p_jd_fkey" of relation "fk_r_2"
3338
3338
SET client_min_messages TO warning;
0 commit comments