Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULdbi-0001Hq-Ce for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Mar 2013 18:00:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ULdbh-00031x-SH for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Mar 2013 18:00:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULdbh-00031s-AF for pgsql-bugs@postgresql.org; Fri, 29 Mar 2013 18:00:53 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ULdba-0001SA-97 for pgsql-bugs@postgresql.org; Fri, 29 Mar 2013 18:00:52 +0000 Received: by mail-pa0-f46.google.com with SMTP id rl6so438893pac.5 for ; Fri, 29 Mar 2013 11:00:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:x-mailer:mime-version :content-transfer-encoding:x-gm-message-state; bh=8xuZ28Yo5xkN2idQdSkwpUJcZ+3xm+QYIHoh4GJGmkY=; b=YcpXtyfyOOEcIydHJTk4gosiSt4zcOixpp7ECrbwGG24IvMEZnfG+OCvt4yAJBu1aP vx8B5yDakeWLS28qV4mlasoIgU9x3PFXmq5CtHnInS9e5SJMH3lX6qmIgbbac4v92Y/D Ywt7l0uIez6IZdxetOsow+uAmS5X1yMwM44aiAzDJOvf1Jebf7Zw6vDE3pStZu+W6lqM s/ock5L2ykP9LkFUVHNrqsh7ZOs/ojXzQSeghRAKG7aPWNhh8zY8/Pxd7DtgILAXCe7z 5B/p+TSYX/c4yVe3AyNhTlo2epBoT4h9ZsLHzhJqUODJDsuMQcqF6GtFgaESS0cMXzBd hA3A== X-Received: by 10.66.160.225 with SMTP id xn1mr5816061pab.136.1364580044038; Fri, 29 Mar 2013 11:00:44 -0700 (PDT) Received: from [192.168.0.104] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPS id tf8sm3566865pbc.42.2013.03.29.11.00.41 (version=SSLv3 cipher=RC4-SHA bits=128/128); Fri, 29 Mar 2013 11:00:42 -0700 (PDT) Message-ID: <1364580044.18894.42.camel@jdavis> Subject: Re: Issue with range types and casts? From: Jeff Davis To: Josh Berkus Cc: pgsql-bugs@postgresql.org Date: Fri, 29 Mar 2013 11:00:44 -0700 In-Reply-To: <513A73E6.2070405@agliodbs.com> References: <513A73E6.2070405@agliodbs.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.6.2-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmiHGZEMkanQsQYGk7PdfEaoxfbJfAslP6ZaFonnAAvgcCeR3LG8mhsi0znMisDIs0JBnCO X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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