Re: [DEPARSE] AT TIME ZONE and similar as a function in FROM do not read back

From: Henson Choi <assam258(at)gmail(dot)com>
To: Prashant Kumar <crprashant(at)hotmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [DEPARSE] AT TIME ZONE and similar as a function in FROM do not read back
Date: 2026-10-26 04:46:13
Message-ID: CAAAe_zAmTGGMcZZK7KwyVfP8_LTNQD2kr=E41KuftLecipoBnQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Prashant,

> One suggestion: the tests added to tt20v cover the timestamp and
> timestamptz forms, but not the timetz form of AT TIME ZONE, which
> is broken in the same way and fixed by the same list. Adding that
> one case would pin the timetz entries of the list against
> regressions.

Done in v2, attached. tt20v now also has

cast(current_time at time zone 'UTC' as timetz) as atzt

which goes through F_TIMEZONE_TEXT_TIMETZ.

While at it, I added one more column for ROWS FROM. The commit
message says the fix covers a function alone in FROM or in ROWS
FROM, but v1 only tested the first. ROWS FROM prints each of its
functions through the same get_rule_expr_funccall(), so it now gets
the CAST back the same way:

rows from(cast('foo' is normalized as boolean), now()) as rf(rfa, rfb)

before:
ROWS FROM(('foo'::text IS NORMALIZED), now()) rf(rfa, rfb)
after:
ROWS FROM(CAST(('foo'::text IS NORMALIZED) AS boolean), now()) rf(rfa,
rfb)

It has two functions because ROWS FROM() is printed only then; a
single function is printed alone.

The code in 0002 is unchanged from v1. 0001 has the two new
columns, with the output before the fix, and 0002 updates their
output along with the others.

Regards,
Henson

Attachment Content-Type Size
v2-0001-Add-tests-for-AT-TIME-ZONE-and-similar-as-FROM-cl.patch application/octet-stream 6.0 KB
v2-0002-Fix-deparsing-of-AT-TIME-ZONE-and-similar-as-FROM.patch application/octet-stream 14.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-26 04:57:45 Reject unassigned bytes in single-byte encodings
Previous Message Michael Paquier 2026-10-26 04:44:02 Re: Reject access to unlogged tables in contrib modules