public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: Bruce Momjian <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: David Rowley <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: James Coleman <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Should we document how column DEFAULT expressions work?
Date: Fri, 5 Jul 2024 14:04:38 -0700
Message-ID: <CAKFQuwZ883st30LHSh1O0=uSzhCEntMKW1n1VXYaRtWqvvwEMw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAApHDvouPRyga3-5ZYLt_RUhU942bk0WPVgro+U=R3cvBRXbeQ@mail.gmail.com>
<[email protected]>
<CAApHDvrURTcDn3GTsmXzm9VqT3acLh=T=aUYMuKrtozw0nq8Tg@mail.gmail.com>
<CAKFQuwbOOQ20=Pb5j-k+Sws22H5W9tnj-vve4MC-GQ9RmmtTxA@mail.gmail.com>
<CAApHDvogKE8RrHx=qmYfvpD_AiVLX14nLvvSrPbFCXWgiYrKxg@mail.gmail.com>
<CAKFQuwZjuQX4H48MbaHZAX3s__LoHgkXsf2Eg--E=qtWFss0bg@mail.gmail.com>
<CAApHDvrQ--Mzp00Yn=3SVB=YS_ZB15aeLywaK0n05-adk8WWmw@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
On Fri, Jul 5, 2024 at 1:55 PM Bruce Momjian <[email protected]> wrote:
> On Fri, Jul 5, 2024 at 04:50:32PM -0400, Tom Lane wrote:
> > Bruce Momjian <[email protected]> writes:
> > > Also interestingly, "now" without quotes requires parentheses to make
> it
> > > a function call:
> >
> > I'm not sure why you find that surprising, or why you think that
> > 'now()'::timestamptz is a function call.
I suspect mostly because SQL has a habit of adding functions that don't
require parentheses and it isn't obvious that "now" is not one of them.
select current_timestamp;
current_timestamp
-------------------------------
2024-07-05 13:55:12.521334-07
(1 row)
> (Well, it is a call of
> > timestamptz_in, but not of the SQL function now().) Documentation
> > that is equally confused won't help any.
>
> Well, 'now()' certainly _looks_ like a function call, though it isn't.
> The fact that 'now()'::timestamptz and 'now'::timestamptz generate
> volatile results via a function call was my point.
>
>
They generate volatile results during typed value construction. That such
things are implemented via functions are best left unreferenced here,
reserving mention of function calls to those things users explicitly add to
their query that are, and only are, function calls.
Whether we change going forward or not I'd be content to simply add a
warning that writing 'now()' in a default expression is invalid syntax that
fails-to-fails on backward compatibility grounds. If you want the function
don't quote it, if you want the literal, remove the parentheses.
David J.
view thread (2+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Should we document how column DEFAULT expressions work?
In-Reply-To: <CAKFQuwZ883st30LHSh1O0=uSzhCEntMKW1n1VXYaRtWqvvwEMw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox