Re: Should we document how column DEFAULT expressions work?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Should we document how column DEFAULT expressions work?
Дата
Msg-id 503444.1729124288@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Should we document how column DEFAULT expressions work?  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> Does anyone like this patch?  I changed now()::timestamptz to
> now::timestamptz.

No, because you clearly didn't bother to test it:

regression=# select now::timestamptz;
ERROR:  column "now" does not exist
LINE 1: select now::timestamptz;
               ^

Also "a string that returns a volatile result once cast to a data
type" is pretty meaningless to my eyes, not least because the real
problem is that the construct is *not* volatile, but gets folded to
a constant at CREATE TABLE time.

The distinction we want to draw is that 'now'::timestamptz is a
parse-time constant and so is not equivalent to the function call
now() (which already produces timestamptz, so no need for a cast).
This is already covered at the end of section 9.9.5 Current Date/Time,
although I have no objection to repeating it in some form in the
CREATE TABLE docs.

            regards, tom lane



В списке pgsql-hackers по дате отправления: