[BUG]: segfault during update

From: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: [BUG]: segfault during update
Date: 2020-11-08 16:30:15
Message-ID: db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-11-08 17:18:19 Re: [BUG]: segfault during update
Previous Message Jürgen Purtz 2020-11-08 15:55:56 Re: Additional Chapter for Tutorial