Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?
Дата
Msg-id 102377.1622757563@sss.pgh.pa.us
обсуждение исходный текст
Ответ на arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?  (Bryn Llewellyn <bryn@yugabyte.com>)
Ответы Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?  (Bryn Llewellyn <bryn@yugabyte.com>)
Список pgsql-general
Bryn Llewellyn <bryn@yugabyte.com> writes:
> The "at time zone" clause that can decorate a timetsamp[tz] value seems
> to allow an argument that’s an arbitrary expression that yields a value
> whose data type is "interval".

AT TIME ZONE is part of the SQL expression syntax, thus it's unsurprising
that its arguments can be arbitrary subexpressions.

> set time zone '-7 hours'::interval;
> brings a "42601: syntax error".

The SET statement, on the other hand, most definitely does not accept
expressions of any kind; only simple literals.  That's in line with most
other utility commands in Postgres, but there are particularly good
reasons to be wary of trying to generalize SET.  Cases such as
SET TRANSACTION ISOLATION LEVEL have to be able to execute without
a transaction context at all.

Yeah, it's asymmetric :-(.  But the SQL committee has gifted us with
a pretty asymmetric language, plus there are various implementation
constraints that are not that easy to get rid of.

            regards, tom lane



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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: possible license violations