Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ycznh-0004hn-JU for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Mar 2015 17:18:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Ycznh-0000TD-1U for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Mar 2015 17:18:05 +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 1Ycznf-0000RR-VQ for pgsql-bugs@postgresql.org; Tue, 31 Mar 2015 17:18:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ycznc-0001XZ-CT for pgsql-bugs@postgresql.org; Tue, 31 Mar 2015 17:18:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t2VHHwhb021190; Tue, 31 Mar 2015 13:17:58 -0400 From: Tom Lane To: rward@uberlogik.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12908: tstzrange constructor fails when used in WHERE clause In-reply-to: <20150327045255.2492.93419@wrigleys.postgresql.org> References: <20150327045255.2492.93419@wrigleys.postgresql.org> Comments: In-reply-to rward@uberlogik.com message dated "Fri, 27 Mar 2015 04:52:55 -0000" Date: Tue, 31 Mar 2015 13:17:58 -0400 Message-ID: <21189.1427822278@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 rward@uberlogik.com writes: > 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. I'm suspicious that the triggering event for this is a type cache flush; but it's hard to see how that would work exactly, because typcache.c never flushes the cache fields for range-type properties. Still, you might work on the assumption that the user-level triggering event is some DDL operation that affects a type definition --- not necessarily one with any direct connection to the failing query --- and see if you can get to a repeatable way to reproduce the issue. Also, once you've gotten a backend into the failing state, it would be useful to attach to it with gdb, set a breakpoint at errfinish, and get a stack trace from the point of the error report. The error must be coming from range_serialize, but it might be a mistake to assume that the direct caller of that is the tstzrange() constructor. (This line of thought would lead to the idea that there's bad statistics for a range column, or some other mechanism that would cause the planner to try to construct a bogus range value on its way to calculating selectivity estimates. In that case, just doing an ANALYZE might cause the error to appear or disappear.) 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