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 1ggc26-0005MC-OJ for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 21:02:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ggc24-0002KF-KW for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 21:02:00 +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 1ggc24-0002K8-E8 for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 21:02:00 +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 1ggc20-0000PZ-M5 for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 21:02:00 +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 x07L1h3i004404; Mon, 7 Jan 2019 16:01:43 -0500 From: Tom Lane To: Andrew Dunstan cc: fredrik.widlert@digpro.se, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15579: Adding a column with default from configuration parameter fails on 11.1 In-reply-to: <9c74611f-b373-3269-04b0-0803a217e1f1@dunslane.net> References: <15579-c1494c68abb011ec@postgresql.org> <3336.1546873079@sss.pgh.pa.us> <9c74611f-b373-3269-04b0-0803a217e1f1@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Mon, 07 Jan 2019 12:36:13 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4402.1546894903.1@sss.pgh.pa.us> Date: Mon, 07 Jan 2019 16:01:43 -0500 Message-ID: <4403.1546894903@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Dunstan writes: > Stable expressions are quite ok for fast defaults. The expression is > evaluated once when the ALTER TABLE is done and the result (not the > expression) is stored in the catalog. The reason we check for volatile > expressions is precisely because we don't want all the existing rows to > get a single value in that case. This was discussed during the Postgres > 11 development cycle. Hmm. The issue here is that if the table is empty, the old behavior evaluated the expression zero times during ALTER TABLE. Now we evaluate it once, and if that throws an error, that's a user-visible behavior change. Perhaps it's okay to decide that that's an acceptable behavioral change, but it makes this feature less transparent than it was supposed to be. regards, tom lane