Surprise AT TIME ZONE behaviour (buglet?)? - Mailing list pgsql-general

From Allan Engelhardt
Subject Surprise AT TIME ZONE behaviour (buglet?)?
Date
Msg-id 3C5EDA47.4070303@cybaea.com
Whole thread Raw
List pgsql-general
test=# select version();
                            version
-------------------------------------------------------------
  PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.96
(1 row)
test=# create table tz (t timestamp, tz text);
CREATE
test=# insert into tz values (now(), 'GMT');
INSERT 340574 1
test=# insert into tz values (now(), 'PST');
INSERT 340575 1
test=# select t at time zone tz from tz;
         timezone
------------------------
  2002-02-04 18:43:55+00
  2002-02-04 10:44:00-08
(2 rows)


Can I first say that I am dead-impressed that this select statement works!!
Well done and a million thanks to whoever implemented it such that the argument
to AT TIME ZONE is a SQL statement.

Also thanks to the authors of "Practical PostgreSQL" (O'Reilly 2002) for
pointing this feature out to me in the first place.  It is a fine book, even if
they do get the definition of PST wrong (John and Joshua: it is GMT-8, cf. above).

Two questions:

1. Am I the only one who is surprised by the column name ('timezone' instead of
't')?  A parser buglet (assuming noise after column name is AS)?

2. Is this really supposed to work?  More precisely: can I count on it if future
releases?  The documentation
(http://candle.pha.pa.us/main/writings/pgsql/sgml/sql-select.html) does not
mention it....


Allan.


pgsql-general by date:

Previous
From: Frank Bax
Date:
Subject: Re: Change size of varchar(20) field
Next
From: Thomas Lockhart
Date:
Subject: Re: Surprise AT TIME ZONE behaviour (buglet?)?