pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?
Date: Thu, 03 Jun 2021 17:59:23 -0400
Message-ID: <102377.1622757563@sss.pgh.pa.us> (raw)
In-Reply-To: <97334D92-03D8-4066-A807-DEAC9EBF87F5@yugabyte.com>
References: <97334D92-03D8-4066-A807-DEAC9EBF87F5@yugabyte.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <102377.1622757563@sss.pgh.pa.us>
Permalink:  ../102377.1622757563@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/102377.1622757563@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bryn@yugabyte.com
  Subject: Re: arbitrary "interval" expression OK with "at time zone" but not with "set time zone" — Why?
  In-Reply-To: <102377.1622757563@sss.pgh.pa.us>
  References: <97334D92-03D8-4066-A807-DEAC9EBF87F5@yugabyte.com> <102377.1622757563@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox