pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: nick.baxter@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7886: date_trunc(date) returning timestamptz instead of timestamp
Date: Fri, 15 Feb 2013 17:14:53 -0500
Message-ID: <18305.1360966493@sss.pgh.pa.us> (raw)
In-Reply-To: <20130215214217.GF12030@momjian.us>
References: <E1U6Som-0004Pz-RQ@wrigleys.postgresql.org>
	<20130215214217.GF12030@momjian.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Bruce Momjian <bruce@momjian.us> writes:
> On Fri, Feb 15, 2013 at 09:27:40PM +0000, nick.baxter@gmail.com wrote:
>> 9.9.2. indicates that date_trunc can be called with a date value (which will
>> be cast to a timestamp). And regardless of the input, that the result will
>> be of type timestamp. When I call it with a date, I get a timestamp with
>> time zone instead, as indicated by the psql output.

> That documentation often uses timestamp when it means timestamp with
> time zone.  Not sure why that is.

Well, what the subsection about date_trunc says is "source is a value
expression of type timestamp or interval".  Up at the very top of the
page, it says

	All the functions and operators described below that take time
	or timestamp inputs actually come in two variants: one that
	takes time with time zone or timestamp with time zone, and one
	that takes time without time zone or timestamp without time
	zone. For brevity, these variants are not shown separately.

So omitting mention of date_trunc(timestamptz) is not inconsistent.
If we wanted to fix that the page would get quite a bit longer, but
perhaps not much more illuminating.

It strikes me that the problem is in the parenthetical remark in 9.9.2:
"(Values of type date and time are cast automatically to timestamp or
interval, respectively.)".  Since there are both timestamp and
timestamptz alternatives available, the parser will actually prefer to
cast a date input to timestamptz, that being the preferred type in this
category.  Maybe we should say "timestamp with time zone" there, though
I can see that confusing people in a different way.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)

Message-ID: <18305.1360966493@sss.pgh.pa.us>
Permalink:  ../18305.1360966493@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18305.1360966493@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bruce@momjian.us, nick.baxter@gmail.com
  Subject: Re: BUG #7886: date_trunc(date) returning timestamptz instead of timestamp
  In-Reply-To: <18305.1360966493@sss.pgh.pa.us>
  References: <E1U6Som-0004Pz-RQ@wrigleys.postgresql.org> <20130215214217.GF12030@momjian.us> <18305.1360966493@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