Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17b715c

Browse files
committed
Add test case for EEOP_INNER_SYSVAR/EEOP_OUTER_SYSVAR executor opcodes.
The EEOP_INNER_SYSVAR and EEOP_OUTER_SYSVAR executor opcodes are notexercised by normal queries, because setrefs.c will resolve the referencesto system columns in the scan nodes already. Join nodes refer to them bytheir position in the child node's target list, like user columns.The only place where those opcodes are used, is in evaluating a trigger'sWHEN condition that references system columns. Trigger evaluation abusesthe INNER/OUTER Vars to refer to the OLD and NEW tuples. The code to handlethe opcodes is pretty straightforward, but it seems like a good idea tohave some test coverage for them, anyway, so that they don't get removed orbroken by accident.Author: Ashutosh Bapat, with some changes by me.Discussion:https://www.postgresql.org/message-id/CAFjFpRerUFX=T0nSnCoroXAJMoo-xah9J+pi7+xDUx86PtQmew@mail.gmail.com
1 parent1486f7f commit17b715c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎src/test/regress/expected/triggers.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,16 @@ DROP TRIGGER insert_a ON main_table;
440440
DROP TRIGGER delete_a ON main_table;
441441
DROP TRIGGER insert_when ON main_table;
442442
DROP TRIGGER delete_when ON main_table;
443+
-- Test WHEN condition accessing system columns.
444+
create table table_with_oids(a int) with oids;
445+
insert into table_with_oids values (1);
446+
create trigger oid_unchanged_trig after update on table_with_oids
447+
for each row
448+
when (new.oid = old.oid AND new.oid <> 0)
449+
execute procedure trigger_func('after_upd_oid_unchanged');
450+
update table_with_oids set a = a + 1;
451+
NOTICE: trigger_func(after_upd_oid_unchanged) called: action = UPDATE, when = AFTER, level = ROW
452+
drop table table_with_oids;
443453
-- Test column-level triggers
444454
DROP TRIGGER after_upd_row_trig ON main_table;
445455
CREATE TRIGGER before_upd_a_row_trig BEFORE UPDATE OF a ON main_table

‎src/test/regress/sql/triggers.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ DROP TRIGGER delete_a ON main_table;
291291
DROPTRIGGER insert_whenON main_table;
292292
DROPTRIGGER delete_whenON main_table;
293293

294+
-- Test WHEN condition accessing system columns.
295+
createtabletable_with_oids(aint) with oids;
296+
insert into table_with_oidsvalues (1);
297+
createtriggeroid_unchanged_trig afterupdateon table_with_oids
298+
for each row
299+
when (new.oid=old.oidANDnew.oid<>0)
300+
execute procedure trigger_func('after_upd_oid_unchanged');
301+
update table_with_oidsset a= a+1;
302+
droptable table_with_oids;
303+
294304
-- Test column-level triggers
295305
DROPTRIGGER after_upd_row_trigON main_table;
296306

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp