BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
Date
Msg-id 19019-962b23dc13723881@postgresql.org
Whole thread Raw
Responses Re: BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
Re: BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19019
Logged by:          Paolo Saggese
Email address:      spam@bit.bucket
PostgreSQL version: Unsupported/Unknown
Operating system:   Any
Description:

As it is possible in some other SQL RDBMS, it would be useful to allow the
use of column reference in DEFAULT expression.

That is, for example:

CREATE TABLE my_table
(
    my_column my_type NOT NULL DEFAULT (  my_expression ),
    -- some other columns, constraints, etc...
)

where "my_expression" uses values from some other column(s) of (the same row
of) the same table and may be allow (also) for even more generic references
to any other column of any table in the DB (in which case "my_expression"
would be a query returning a single value compatible with "my_type"...).

A possible equivalent alternative syntax would be e.g.:

GENERATED BY DEFAULT AS ( my_expression )

(where "STORED" would be obviously implied...).

Note that the (existing) syntax:

GENERATED ALWAYS AS ( my_expression ) STORED

obviously is not equivalent and does not provide the desired behavior (as of
course in such case the column would be read-only and would not allow to
replace the generated value with something else).


pgsql-bugs by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: "unexpected duplicate for tablespace" problem in logical replication
Next
From: Xuneng Zhou
Date:
Subject: Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer