Re: Should we document how column DEFAULT expressions work? - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Should we document how column DEFAULT expressions work?
Date
Msg-id CAKFQuwbOOQ20=Pb5j-k+Sws22H5W9tnj-vve4MC-GQ9RmmtTxA@mail.gmail.com
Whole thread Raw
In response to Re: Should we document how column DEFAULT expressions work?  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Should we document how column DEFAULT expressions work?
Re: Should we document how column DEFAULT expressions work?
List pgsql-hackers
On Sun, Jun 30, 2024 at 4:55 PM David Rowley <dgrowleyml@gmail.com> wrote:

I'd like to know what led someone down the path of doing something
like DEFAULT 'now()'::timestamp in a CREATE TABLE. Could it be a
faulty migration tool that created these and people copy them thinking
it's a legitimate syntax?


My thought process on this used to be:  Provide a text string of the expression that is then stored within the catalog and eval'd during runtime.  If the only thing you are providing is a single literal and not some compound expression it isn't that obvious that you are supposed to provide an unquoted expression - which feels like it should be immediately evaluated - versus something that is a constant.  Kinda like dynamic SQL.

David J.

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Should we document how column DEFAULT expressions work?
Next
From: Thomas Munro
Date:
Subject: Re: PostgreSQL does not compile on macOS SDK 15.0