diff --git a/src/pl/plpgsql/src/expected/plpgsql_trap.out b/src/pl/plpgsql/src/expected/plpgsql_trap.out index 881603f5c48..90cf6c28956 100644 --- a/src/pl/plpgsql/src/expected/plpgsql_trap.out +++ b/src/pl/plpgsql/src/expected/plpgsql_trap.out @@ -186,17 +186,17 @@ NOTICE: should see this only if -100 fits in smallint -- -- test foreign key error trapping -- -create temp table master(f1 int primary key); -create temp table slave(f1 int references master deferrable); -insert into master values(1); -insert into slave values(1); -insert into slave values(2); -- fails -ERROR: insert or update on table "slave" violates foreign key constraint "slave_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "master". +create temp table root(f1 int primary key); +create temp table leaf(f1 int references root deferrable); +insert into root values(1); +insert into leaf values(1); +insert into leaf values(2); -- fails +ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" +DETAIL: Key (f1)=(2) is not present in table "root". create function trap_foreign_key(int) returns int as $$ begin begin -- start a subtransaction - insert into slave values($1); + insert into leaf values($1); exception when foreign_key_violation then raise notice 'caught foreign_key_violation'; @@ -238,8 +238,8 @@ begin; savepoint x; set constraints all immediate; -- fails -ERROR: insert or update on table "slave" violates foreign key constraint "slave_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "master". +ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" +DETAIL: Key (f1)=(2) is not present in table "root". rollback to x; select trap_foreign_key_2(); -- detects FK violation NOTICE: caught foreign_key_violation @@ -249,7 +249,7 @@ NOTICE: caught foreign_key_violation (1 row) commit; -- still fails -ERROR: insert or update on table "slave" violates foreign key constraint "slave_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "master". +ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" +DETAIL: Key (f1)=(2) is not present in table "root". drop function trap_foreign_key(int); drop function trap_foreign_key_2(); diff --git a/src/pl/plpgsql/src/sql/plpgsql_trap.sql b/src/pl/plpgsql/src/sql/plpgsql_trap.sql index 7e75f469346..c6c1ad894b5 100644 --- a/src/pl/plpgsql/src/sql/plpgsql_trap.sql +++ b/src/pl/plpgsql/src/sql/plpgsql_trap.sql @@ -127,18 +127,18 @@ select test_variable_storage(); -- test foreign key error trapping -- -create temp table master(f1 int primary key); +create temp table root(f1 int primary key); -create temp table slave(f1 int references master deferrable); +create temp table leaf(f1 int references root deferrable); -insert into master values(1); -insert into slave values(1); -insert into slave values(2); -- fails +insert into root values(1); +insert into leaf values(1); +insert into leaf values(2); -- fails create function trap_foreign_key(int) returns int as $$ begin begin -- start a subtransaction - insert into slave values($1); + insert into leaf values($1); exception when foreign_key_violation then raise notice 'caught foreign_key_violation';