pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Issue with range types and casts?
Date: Fri, 29 Mar 2013 11:00:44 -0700
Message-ID: <1364580044.18894.42.camel@jdavis> (raw)
In-Reply-To: <513A73E6.2070405@agliodbs.com>
References: <513A73E6.2070405@agliodbs.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Fri, 2013-03-08 at 15:27 -0800, Josh Berkus wrote:
> create table tenmin as select * from sampledata where collect_ts <@
> '[2013-01-01 00:00:00,2013-01-01 00:10:00)';
> ERROR:  could not find range type for data type timestamp with time zone
> Time: 0.189 ms
> 
> This seems like it ought to be fixable.  Postgres has figured out that
> it needs to find the range type for timestamptz.  Why can't it?

The reason it's doing that is because there could be multiple range
types based on one element type. The workaround (which you are probably
already using) is to cast the second argument to a tstzrange.

We could try to be smarter about it, but the problem with relying on
that intelligence is that, when it doesn't work, your queries break. For
instance, someone else could add a new datatype "tstzrange2"[1], and
that would introduce ambiguity, and you'd get an error then (probably
breaking many existing queries baked into your application). Different
people have different opinions on how smart the type system should try
to be, and reasonable people may differ; I'm just saying what it does
currently.

That being said, perhaps the error message should be improved? I'm not
sure what it should say exactly, though.

Regards,
	Jeff Davis

[1] To make it more plausible, tstzrange2 might have a canonicalization
function that turns it into a discrete range (kind of like date but at a
resolution smaller than a day).



-- 
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 (2+ messages)

Message-ID: <1364580044.18894.42.camel@jdavis>
Permalink:  ../1364580044.18894.42.camel@jdavis/
Also on:    postgresql.org/message-id/1364580044.18894.42.camel@jdavis

 · 

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: pgsql@j-davis.com, josh@agliodbs.com
  Subject: Re: Issue with range types and casts?
  In-Reply-To: <1364580044.18894.42.camel@jdavis>
  References: <513A73E6.2070405@agliodbs.com> <1364580044.18894.42.camel@jdavis>

* 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