Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YcxBX-0006do-9o for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Mar 2015 14:30:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YcxBW-0003Xt-3p for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Mar 2015 14:30:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YbMGf-0006Pv-Il for pgsql-bugs@postgresql.org; Fri, 27 Mar 2015 04:53:13 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YbMGW-0001NV-Kk for pgsql-bugs@postgresql.org; Fri, 27 Mar 2015 04:53:11 +0000 MIME-Version: 1.0 Subject: BUG #12908: tstzrange constructor fails when used in WHERE clause To: pgsql-bugs@postgresql.org From: rward@uberlogik.com Date: Fri, 27 Mar 2015 04:52:55 +0000 Message-ID: <20150327045255.2492.93419@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following bug has been logged on the website: Bug reference: 12908 Logged by: Rob Ward Email address: rward@uberlogik.com PostgreSQL version: 9.4.1 Operating system: Windows 8.1 Description: Summary: Under certain conditions, when I use a tstzrange constructor in the WHERE clause of a query, Postgresql incorrectly gives the error: ERROR: range lower bound must be less than or equal to range upper bound Details: Two days ago, I switched a new app's database from PostgreSQL 9.3 to 9.4.1. It's a new app, so was no legacy data, so I just recreated the schema on the new server (on my local development machine running Win 8.1). There were no changes to the schema, but I quickly began running into a showstopper bug: Queries that construct a tstzrange in the where clause fail with the error message "ERROR: range lower bound must be less than or equal to range upper bound. SQL state: 2200". This error happens despite the fact that the range bounds are correct (i.e. lower bound < upper). Simplest example of a query that would fail with this error: select period from foo where period && tstzrange('2015-03-25 12:00:00+00'::timestamptz, '2015-03-26 12:00:00+00'::timestamptz, '[]') However, I can't seem to reproduce the conditions that trigger this bug. Once that unknown condition is triggered though, the incorrect behavior described above happens every time. Clues that may help: 1) The queries in question have been working fine under months of intensive testing on Postgres 9.3 2) When a query fails, it will always fail no matter what dates/times I put in the constructor. The problem will only go away if I drop the schema and recreate all the tables and start again. 3) If a query fails as described, the same query in a different database on the same server will work ok. 4) If I copy the constructor and run it stand-alone, that constructor will work correctly as expected - e.g. select tstzrange('2015-03-25 12:00:00+00'::timestamptz, '2015-03-26 12:00:00+00'::timestamptz, '[]') I appreciate that this is a tough bug to diagnose with no clear way to reproduce it. Unfortunately given that it's a showstopper I have to revert back to 9.3 for the moment, but am happy to do any diagnostics, etc to help track this one down. Thanks, Rob -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs