From 27ad46df6ed780eb977928aa8b77494ecb3f8582 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Wed, 21 Oct 2026 19:36:12 +0900 Subject: [PATCH v1 1/2] Add tests for AT TIME ZONE and similar as FROM-clause functions AT TIME ZONE, AT LOCAL, OVERLAPS and IS NORMALIZED are not function calls in the grammar, so they can be used as a function in FROM only inside a CAST. When the CAST does not change the type, the parser drops it, and the view is printed with the bare expression, which cannot be read back: (LOCALTIMESTAMP AT TIME ZONE 'UTC'::text) atz(atz) (LOCALTIMESTAMP AT LOCAL) atl(atl) ((LOCALTIMESTAMP, LOCALTIMESTAMP) OVERLAPS (LOCALTIMESTAMP, LOCALTIMESTAMP)) o(o) ('foo'::text IS NORMALIZED) isn(isn) Extend tt20v with these. The expected output shows the behavior before the fix. The next commit fixes it and updates the output. --- src/test/regress/expected/create_view.out | 43 +++++++++++++++-------- src/test/regress/sql/create_view.sql | 7 +++- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out index 85ffca793f2..ad643cbc743 100644 --- a/src/test/regress/expected/create_view.out +++ b/src/test/regress/expected/create_view.out @@ -1969,22 +1969,35 @@ select * from current_date as d, localtimestamp(3) as t, cast(1+2 as int4) as i4, - cast(1+2 as int8) as i8; + cast(1+2 as int8) as i8, + cast(localtimestamp at time zone 'UTC' as timestamptz) as atz, + cast(localtimestamp at local as timestamptz) as atl, + cast((localtimestamp, localtimestamp) overlaps + (localtimestamp, localtimestamp) as boolean) as o, + cast('foo' is normalized as boolean) as isn; select pg_get_viewdef('tt20v', true); - pg_get_viewdef ---------------------------------------------- - SELECT c.c, + - col.col, + - d.d, + - t.t, + - i4.i4, + - i8.i8 + - FROM COALESCE(1, 2) c(c), + - COLLATION FOR ('x'::text) col(col), + - CURRENT_DATE d(d), + - LOCALTIMESTAMP(3) t(t), + - CAST(1 + 2 AS integer) i4(i4), + - CAST((1 + 2)::bigint AS bigint) i8(i8); + pg_get_viewdef +---------------------------------------------------------------------------------------- + SELECT c.c, + + col.col, + + d.d, + + t.t, + + i4.i4, + + i8.i8, + + atz.atz, + + atl.atl, + + o.o, + + isn.isn + + FROM COALESCE(1, 2) c(c), + + COLLATION FOR ('x'::text) col(col), + + CURRENT_DATE d(d), + + LOCALTIMESTAMP(3) t(t), + + CAST(1 + 2 AS integer) i4(i4), + + CAST((1 + 2)::bigint AS bigint) i8(i8), + + (LOCALTIMESTAMP AT TIME ZONE 'UTC'::text) atz(atz), + + (LOCALTIMESTAMP AT LOCAL) atl(atl), + + ((LOCALTIMESTAMP, LOCALTIMESTAMP) OVERLAPS (LOCALTIMESTAMP, LOCALTIMESTAMP)) o(o),+ + ('foo'::text IS NORMALIZED) isn(isn); (1 row) -- reverse-listing of various special function syntaxes required by SQL diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql index 82b8d8ab395..5cdf05079e9 100644 --- a/src/test/regress/sql/create_view.sql +++ b/src/test/regress/sql/create_view.sql @@ -712,7 +712,12 @@ select * from current_date as d, localtimestamp(3) as t, cast(1+2 as int4) as i4, - cast(1+2 as int8) as i8; + cast(1+2 as int8) as i8, + cast(localtimestamp at time zone 'UTC' as timestamptz) as atz, + cast(localtimestamp at local as timestamptz) as atl, + cast((localtimestamp, localtimestamp) overlaps + (localtimestamp, localtimestamp) as boolean) as o, + cast('foo' is normalized as boolean) as isn; select pg_get_viewdef('tt20v', true); -- reverse-listing of various special function syntaxes required by SQL -- 2.54.0 (Apple Git-157)