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 1iIfWk-0004C3-FT for pgsql-committers@arkaria.postgresql.org; Thu, 10 Oct 2019 20:59:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIfWj-0005SZ-4a for pgsql-committers@arkaria.postgresql.org; Thu, 10 Oct 2019 20:59:13 +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 1iIfWi-0005SQ-Tv for pgsql-committers@lists.postgresql.org; Thu, 10 Oct 2019 20:59:12 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIfWe-0004Rv-PV for pgsql-committers@lists.postgresql.org; Thu, 10 Oct 2019 20:59:12 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 78F58220E2; Thu, 10 Oct 2019 16:59:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 10 Oct 2019 16:59:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=SFH3y4u2vg3+dQiKCkcsYKuxgth /4jsJSUVZEGEN5MA=; b=h8qxUeqFMzY5XULxhOtnbkQtcRtWYgMtvh+y30asKds zrrLXgYPH0AUIdmJ2zQmFFnst9AfPm8KPHV7lR0L5atQPKIhtd+V/7bt8vd9x/uR qL6pGy6i74qq9wpso6W19xYp41SQ7iXd9nJG3pnfo+JyFGzhQbNuMtIYASdvC0NG CZ6F9ukZyRIsKda74zolo/2Kagu0+aDXL76uerriOY7en2QfDBjRVeCYZ/PDuWkA +CKnDDCB9EaR0YAXwCfP00JNyZI3ZmXhy48WGtbYyt7Ty61o+eNtlhY5dBof0tEF byqdT3Vioo6dedw2hONOnpyf/DRg+oeF/oYcP+blfmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=SFH3y4 u2vg3+dQiKCkcsYKuxgth/4jsJSUVZEGEN5MA=; b=SQNoOoPKOjEs6hxvnMh2vq XZ0IffUmNFbJQBzeXT+EuBoLS3brT3k3zEIMTOnxEFntmqtqyKei/8/AnlPNxcGH MlldkExO5TVS6Hu21E/46uRSb4R3ddC/e0qA4D4TBBFT5tQtMLcX72JztDSeRHfH 0cP7/j0YnSVM3csRyDR1L277lbf9+t1RcjAUno+hsyImgQNUO9WA0tVPx3m3mrY/ phEe6nIP5UV1u3fxbawZei5olaE5gSVmsybizA8qVu0gts5aOjX32kxOM1d6GV9f qGXgQUsflQILbUvEenR9U9KjWwU5Khq4QfEnnmWsUnMcwFjxnAHuDL2YoNEtTJtA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieefgdduiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghn rghrrgiivghlrdguvgeqnecuffhomhgrihhnpehpghhsqhhlrdgsuhhilhgupdhpohhsth hgrhgvshhqlhdrohhrghdpshhqlhdrrghsnecukfhppeeijedrudeitddrvddukedrvdef jeenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdrug gvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-218-237.hsd1.ca.comcast.net [67.160.218.237]) by mail.messagingengine.com (Postfix) with ESMTPA id 1C592D6005A; Thu, 10 Oct 2019 16:59:05 -0400 (EDT) Date: Thu, 10 Oct 2019 13:59:03 -0700 From: Andres Freund To: Tom Lane Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix table rewrites that include a column without a default. Message-ID: <20191010205903.tj73q3qcyfft3izz@alap3.anarazel.de> References: <3328.1570740683@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3328.1570740683@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-10-10 16:51:23 -0400, Tom Lane wrote: > Andres Freund writes: > > Fix table rewrites that include a column without a default. > > This patch added use of an event trigger in alter_table.sql. > As we have learned the hard way, it's not acceptable to create event > triggers in test scripts that run in parallel with anything else, > because they will intermittently screw up DDL happening in the > parallel scripts. As seen just now on clam: Dang :( > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=clam&dt=2019-10-10%2020%3A16%3A19 > > diff -U3 /home/pgbfarm/buildroot/HEAD/pgsql.build/src/test/regress/expected/plpgsql.out /home/pgbfarm/buildroot/HEAD/pgsql.build/src/test/regress/results/plpgsql.out > --- /home/pgbfarm/buildroot/HEAD/pgsql.build/src/test/regress/expected/plpgsql.out 2019-05-09 09:00:10.653795677 +0100 > +++ /home/pgbfarm/buildroot/HEAD/pgsql.build/src/test/regress/results/plpgsql.out 2019-10-10 21:21:46.406007734 +0100 > @@ -5419,6 +5419,7 @@ > -- now change 'name' to an integer to see what happens... > ALTER TABLE alter_table_under_transition_tables > ALTER COLUMN name TYPE int USING name::integer; > +WARNING: rewriting table alter_table_under_transition_tables > UPDATE alter_table_under_transition_tables > SET name = (name::text || name::text)::integer; > WARNING: old table = 1=11,2=22,3=33, new table = 1=1111,2=2222,3=3333 > > > 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. Greetings, Andres Freund