Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbnar-0001eI-8h for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Nov 2020 16:31:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kbnao-00009O-Su for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Nov 2020 16:31:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbnao-00009H-Jy for pgsql-hackers@lists.postgresql.org; Sun, 08 Nov 2020 16:31:02 +0000 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbnal-0008JT-C8 for pgsql-hackers@postgresql.org; Sun, 08 Nov 2020 16:31:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1604853059; x=1636389059; h=from:subject:to:message-id:date:mime-version; bh=RHYwlcl9MzQ1tXC2rtP8Uii1yH3b3JDzx8DION5QeH8=; b=lr2mKcVOyQDNh8jmyPkRQQLkxpKsl7RQaG/CnNlFS/9ElQ4OJuOCSESr Dm3s3+mScKYAGz0whmqne2Sdu6O4GPOMczS/F0ZabLy8M0KzJMH7yaPnQ qu5Y+WhZGkA4/W+xWncv+GdIEDrT+1CB0WN7/JLBoos+9g3wD3pdBNpHs o=; X-IronPort-AV: E=Sophos;i="5.77,461,1596499200"; d="scan'208,217";a="84766365" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 08 Nov 2020 16:30:48 +0000 Received: from EX13D03EUC003.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id ADDE3A07C5 for ; Sun, 8 Nov 2020 16:30:47 +0000 (UTC) Received: from 38f9d36c4abb.ant.amazon.com (10.43.161.34) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 8 Nov 2020 16:30:19 +0000 From: "Drouvot, Bertrand" Subject: [BUG]: segfault during update To: PostgreSQL-development Message-ID: Date: Sun, 8 Nov 2020 17:30:15 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------86ABEC619A07B61F84471A41" Content-Language: en-US X-Originating-IP: [10.43.161.34] X-ClientProxiedBy: EX13D02UWB004.ant.amazon.com (10.43.161.11) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --------------86ABEC619A07B61F84471A41 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit 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 --------------86ABEC619A07B61F84471A41 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit

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

--------------86ABEC619A07B61F84471A41--