Hi hackers,
Here is a scenario that produces segfault during update (on version 12 and 13):
create table bdttrig (created_at timestamp without time zone not null default now(),col1 bool not null default false, col2 text not null default 'def', col3 char(6) not null default 'bdtbdt');
CREATE TABLE
CREATE or replace FUNCTION trigger_function()
RETURNS TRIGGER
LANGUAGE PLPGSQL
AS $$
BEGIN
IF (NEW != OLD) THEN
NEW.created_at = OLD.created_at;
RETURN NEW;
END IF;
RETURN OLD;
END;
$$
;
CREATE FUNCTION
create trigger bdt_trigger before update on bdttrig for each row EXECUTE function trigger_function();
CREATE TRIGGER
insert into bdttrig(col1) values (true);
INSERT 0 1
alter table bdttrig add column col4 text not null default 'default';
ALTER TABLE
alter table bdttrig drop column col2;
ALTER TABLE
update bdttrig set col1 = true;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I did some digging and found out and tested that the issue is fixed by this commit: https://github.com/postgres/postgres/commit/20d3fe9009ddbbbb3da3a2da298f922054b43f8c
So, we would need to back port this commit on 12 and 13.
Thanks
Bertrand