From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Jonathan Katz <jonathan(dot)katz(at)excoventures(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, David Steele <david(at)pgmasters(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Mark Dilger <hornschnorter(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Boolean partitions syntax |
Date: | 2018-04-11 04:39:45 |
Message-ID: | CAKJS1f-J41R2Runt=FusbeohJF4vVBzEjW_cfEAV9z0N-MQECA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 11 April 2018 at 05:22, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
>> On 11 April 2018 at 03:34, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Well, that just begs the question: why do these expressions need to
>>> be immutable? What we really want, I think, is to evaluate them
>>> and reduce them to constants. After that, it hardly matters whether
>>> the original expression was volatile. I see absolutely no moral
>>> difference between "for values in (random())" and cases like
>>> this, which works today:
>
>> I'd personally be pretty surprised if this worked.
>
> Well, my point is that we're *already* behaving that way in some cases,
> simply because of the existence of macro-like inputs for some of these
> datatypes. I'm not sure that users are going to perceive a big difference
> between 'now'::timestamptz and now(), for example. If we take one but
> not the other, I don't think anybody will see that as a feature.
To me, it seems a bit inconsistent to treat 'now'::timestamp and now()
the same way.
I found this in the 7.4 release notes [1]:
"String literals specifying time-varying date/time values, such as
'now' or 'today' will no longer work as expected in column default
expressions; they now cause the time of the table creation to be the
default, not the time of the insertion. Functions such as now(),
current_timestamp, or current_dateshould be used instead.
In previous releases, there was special code so that strings such as
'now' were interpreted at INSERT time and not at table creation time,
but this work around didn't cover all cases. Release 7.4 now requires
that defaults be defined properly using functions such as now() or
current_timestamp. These will work in all situations."
So isn't 'now' being different from now() in DDL something users
should be quite used to by now?
I've got to admit, I'm somewhat less concerned about evaluating
volatile functions in this case because you don't seem that concerned,
but if you happen to be wrong, then it's going to be a much harder
thing to fix. Really, is anyone going to complain if we don't
evaluate these and reject them with an error instead? It seems like a
safer option to me, also less work, and we're probably less likely to
regret it.
We also need to decide what of this we can backpatch to PG10 to fix
[2]. Ideally what goes into PG10 and PG11 would be the same, so
perhaps that's another reason to keep it more simple.
[1] https://www.postgresql.org/docs/current/static/release-7-4.html
[2] https://www.postgresql.org/message-id/CAKJS1f-BL%2Br5FXSejDu%3D%2BMAvzRARaawRnQ_ZFtbv_o6tha9NJw%40mail.gmail.com
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Huong Dangminh | 2018-04-11 04:42:04 | RE: power() function in Windows: "value out of range: underflow" |
Previous Message | Kyotaro HORIGUCHI | 2018-04-11 04:20:23 | Re: Boolean partitions syntax |