PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15456
PG Version11.0
OSUbuntu 14.04
Opened2018-10-24 12:26:53+00
Reported bySean Johnston
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15456
Logged by:          Sean Johnston
Email address:      (redacted)
PostgreSQL version: 11.0
Operating system:   Ubuntu 14.04
Description:        

-- 1. create trigger function

create or replace function trig() returns trigger as $$
begin
  if TG_OP = 'INSERT' then
    raise notice 'INSERT: %', ROW(NEW.*);
  end if;
  return null;
end $$ language plpgsql;

-- 2. create table

drop table if exists t;
create table t (id integer) tablespace pg_default;

-- 3. create a trigger on the table for each row

create trigger do_trig
after insert or update or delete on t
for each row
  execute procedure trig();

-- 4. insert a row

insert into t(id) values (1);

-- 5. add a column to the table

alter table t add val text;

-- 6. insert a new row referencing the new column

insert into t(id,val) values (2,'new');

------

Output from notices:
psql:1.sql:18: NOTICE:  INSERT: (1)
psql:1.sql:22: NOTICE:  INSERT: (2)

Expected output:
psql:1.sql:18: NOTICE:  INSERT: (1)
psql:1.sql:22: NOTICE:  INSERT: (2,new)

Note that if a new session is started before performing the second insert
then the expected output is produced.

Messages

DateAuthorSubject
2018-10-24 12:26:53+00=?utf-8?q?PG_Bug_reporting_form?=BUG #15456: Trigger function using ROW(NEW.*) has wrong columns if table is modified during a session