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 1iIfnG-0004mv-90 for pgsql-committers@arkaria.postgresql.org; Thu, 10 Oct 2019 21:16:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIfnE-0007L8-OM for pgsql-committers@arkaria.postgresql.org; Thu, 10 Oct 2019 21:16:16 +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 1iIfnE-0007Kw-Gs for pgsql-committers@lists.postgresql.org; Thu, 10 Oct 2019 21:16:16 +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 1iIfnB-0004f7-IY for pgsql-committers@lists.postgresql.org; Thu, 10 Oct 2019 21:16:16 +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 x9ALG8EF004542; Thu, 10 Oct 2019 17:16:08 -0400 From: Tom Lane To: Andres Freund cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix table rewrites that include a column without a default. In-reply-to: <20191010205903.tj73q3qcyfft3izz@alap3.anarazel.de> References: <3328.1570740683@sss.pgh.pa.us> <20191010205903.tj73q3qcyfft3izz@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 10 Oct 2019 13:59:03 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4540.1570742168.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 10 Oct 2019 17:16:08 -0400 Message-ID: <4541.1570742168@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-10-10 16:51:23 -0400, Tom Lane wrote: >> Do you *really* need an event trigger to test this? > No. I added it to avoid the tests getting "accidentally" optimized away, > the next time somebody adds some ALTER TABLE optimizations. The fast > default stuff had removed coverage from a test that'd have uncovered > this bug. And an event trigger seemed to be the easiest way to achieve > that. > The only real alternative I can see to just removing the trigger is > embedding a check in the trigger that will cause it to only work in the > current session. Something like SET regress.log_table_rewrites, and a > IF current_setting('regress.log_table_rewrites')::bool in the function. If you just want to verify that a rewrite happened or didn't happen, seems like you could check whether the table's relfilenode changed. regression=3D# select relfilenode as oldfilenode from pg_class where relna= me =3D 'rewrite_test' regression-# \gset regression=3D# select relfilenode !=3D :oldfilenode as changed from pg_cla= ss where relname =3D 'rewrite_test'; changed = --------- f (1 row) regression=3D# alter table rewrite_test alter column notempty3_norewrite t= ype bigint; ALTER TABLE regression=3D# select relfilenode !=3D :oldfilenode as changed from pg_cla= ss where relname =3D 'rewrite_test'; changed = --------- t (1 row) I really really don't want an event trigger running in everything that runs in parallel with alter_table. That's a debugging nightmare of monster proportions. regards, tom lane