Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6PVn-0001Ch-QV for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Jan 2014 19:00:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W6PVn-0002ff-AD for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Jan 2014 19:00:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6O4U-0004Pc-D0 for pgsql-bugs@postgresql.org; Thu, 23 Jan 2014 17:28:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6O4R-0007K9-7V for pgsql-bugs@postgresql.org; Thu, 23 Jan 2014 17:28:05 +0000 MIME-Version: 1.0 Subject: BUG #8939: Cast to range type fails due to whitespaces in the text string To: pgsql-bugs@postgresql.org From: Sergei.Agalakov@gmail.com Date: Thu, 23 Jan 2014 17:27:03 +0000 Message-ID: <20140123172703.26702.69411@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) 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: 8939 Logged by: Sergei Agalakov Email address: Sergei.Agalakov@gmail.com PostgreSQL version: 9.3.2 Operating system: Windows Description: According to documentation http://www.postgresql.org/docs/9.3/interactive/rangetypes.html paragraph 8.17.5. Range Input/Output "Whitespace is allowed before and after the range value, but any whitespace between the parentheses or brackets is taken as part of the lower or upper bound value. (Depending on the element type, it might or might not be significant.)" The real behavior is different for bounded and unbounded ranges: SELECT '[10,)'::int4range; -- OK SELECT '[10, )'::int4range; -- Fails SELECT '[10,12 )'::int4range; -- OK SELECT '(, 10]'::int4range; -- OK SELECT '(,10 )'::int4range; -- OK SELECT '( ,10)'::int4range; -- Fails SELECT '( 8,10)'::int4range; -- OK Constructor works predictably all the time trimming whitespaces: SELECT int4range( 10 , null , '[)' ); -- OK I would expect that for range types where white spaces can't be significant for evaluating elements they would be trimmed before evaluating a SQL statement with casting to a range type. Currently an implementation of casting to range types is too peaky to the exact syntax of the text string. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs