=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> 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