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 1ggWM3-0004TM-2k for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 14:58:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ggWM0-0000I4-To for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2019 14:58:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ggWM0-0000HJ-Jw for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 14:58:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ggWLx-0005iM-W6 for pgsql-bugs@lists.postgresql.org; Mon, 07 Jan 2019 14:58:11 +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 x07EvxdD003338; Mon, 7 Jan 2019 09:57:59 -0500 From: Tom Lane To: fredrik.widlert@digpro.se cc: pgsql-bugs@lists.postgresql.org, Andrew Dunstan Subject: Re: BUG #15579: Adding a column with default from configuration parameter fails on 11.1 In-reply-to: <15579-c1494c68abb011ec@postgresql.org> References: <15579-c1494c68abb011ec@postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Mon, 07 Jan 2019 12:14:17 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3335.1546873079.1@sss.pgh.pa.us> Date: Mon, 07 Jan 2019 09:57:59 -0500 Message-ID: <3336.1546873079@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > ... creating the table first and then adding the column does not > work on 11.1. It used to work at least from version 9.3 to 10. > create table t (x int); > alter table t add c varchar(50) default > current_setting('public.some_setting'); > ERROR: unrecognized configuration parameter "public.some_setting" I think this is a brown-paper-bag bug in the fast-column-default feature. current_setting() is stable, and should certainly not be treated as a fast default, but behold the test looks like this: /* If the DEFAULT is volatile we cannot use a missing value */ if (colDef->missingMode && contain_volatile_functions((Node *) expr)) colDef->missingMode = false; Of course, it should be insisting that the expression be immutable, not just that it not be volatile. - /* If the DEFAULT is volatile we cannot use a missing value */ - if (colDef->missingMode && contain_volatile_functions((Node *) expr)) + /* missingMode can only be used for immutable defaults */ + if (colDef->missingMode && contain_mutable_functions((Node *) expr)) colDef->missingMode = false; regards, tom lane