pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <bdrouvot@amazon.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: [BUG]: segfault during update
Date: Sun, 8 Nov 2020 17:30:15 +0100
Message-ID: <db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com> (raw)

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

view thread (6+ messages)  latest in thread

Message-ID: <db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com>
Permalink:  ../db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com/
Also on:    postgresql.org/message-id/db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bdrouvot@amazon.com
  Subject: Re: [BUG]: segfault during update
  In-Reply-To: <db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox