Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPTO7-0006oa-Aq for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2019 15:26:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iPTO5-00025e-Os for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2019 15:26:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPTO5-00025V-HC for pgsql-bugs@lists.postgresql.org; Tue, 29 Oct 2019 15:26:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPTNx-0001bI-Ta for pgsql-bugs@lists.postgresql.org; Tue, 29 Oct 2019 15:26:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9TFQEB5023032; Tue, 29 Oct 2019 11:26:14 -0400 From: Tom Lane To: ariel@mashraki.co.il cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16087: Segmentation fault on ALTER TABLE In-reply-to: <16087-c583d912ecb36614@postgresql.org> References: <16087-c583d912ecb36614@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 29 Oct 2019 15:16:29 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23030.1572362774.1@sss.pgh.pa.us> Date: Tue, 29 Oct 2019 11:26:14 -0400 Message-ID: <23031.1572362774@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > Running ALTER TABLE with both ALTER COLUMN and ADD COLUMN causes a database > segfault. It happens constantly on version 12 and doesn't reproduce on > version 11 and 10. > Attaching here a set of commands (and their output) to help reproducing the > issue ($ means start of a command). > $ create table "users" (id bigint not null generated by default as identity, > age int not null, primary key(id)); > $ insert into users (age) values(1); > $ alter table "users" alter column "age" type bigint, add column "nickname" > text; Thanks for the report! I failed to reproduce a crash here, but I think that means that the bug is already fixed. It looks like this probably matches this recent commit: Author: Andres Freund Branch: master [93765bd95] 2019-10-09 22:00:50 -0700 Branch: REL_12_STABLE [f224c7c11] 2019-10-09 22:13:48 -0700 Fix table rewrites that include a column without a default. In c2fe139c201c I made ATRewriteTable() use tuple slots. Unfortunately I did not notice that columns can be added in a rewrite that do not have a default, when another column is added/altered requiring one. Initialize columns to NULL again, and add tests. Bug: #16038 Reported-By: anonymous Author: Andres Freund Discussion: https://postgr.es/m/16038-5c974541f2bf6749@postgresql.org Backpatch: 12, where the bug was introduced in c2fe139c201c regards, tom lane