pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: spam@bit.bucket
Subject: BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
Date: Wed, 13 Aug 2025 11:36:19 +0000
Message-ID: <19019-962b23dc13723881@postgresql.org> (raw)

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).



view thread (3+ messages)  latest in thread

Message-ID: <19019-962b23dc13723881@postgresql.org>
Permalink:  ../19019-962b23dc13723881@postgresql.org/
Also on:    postgresql.org/message-id/19019-962b23dc13723881@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, spam@bit.bucket
  Subject: Re: BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
  In-Reply-To: <19019-962b23dc13723881@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox