Re: White space affecting parsing of range values - Mailing list pgsql-general

From Adrian Klaver
Subject Re: White space affecting parsing of range values
Date
Msg-id 597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com
Whole thread Raw
In response to White space affecting parsing of range values  (Thom Brown <thom@linux.com>)
Responses Re: White space affecting parsing of range values  (Thom Brown <thom@linux.com>)
List pgsql-general
On 5/6/20 9:00 AM, Thom Brown wrote:
> Hi,
> 
> I noticed I'm getting an error when adding white space to a numeric
> range.  I can run this:
> 
> postgres=# SELECT 5::numeric <@ '(,10]'::numrange;
>   ?column?
> ----------
>   t
> (1 row)
> 
> But I can't run this:
> 
> postgres=# SELECT 5::numeric <@ '(  ,10]'::numrange;
> ERROR:  invalid input syntax for type numeric: "  "
> LINE 1: SELECT 5::numeric <@ '(  ,10]'::numrange;
>                               ^
> If one had constructed a series of ranges, and wanted to line them up
> vertically for easy comprehension, this wouldn't be possible.
> 
> This doesn't seem to be a problem with regular numeric values:
> 
> postgres=# SELECT ' 3 '::numeric;
>   numeric
> ---------
>         3
> (1 row)
> 
> 
> Shouldn't white space be ignored in range values?
> 

https://www.postgresql.org/docs/12/rangetypes.html

"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.)
"


SELECT 5::numeric <@ '(00,10]'::numrange;
  ?column?
----------
  t


-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Jasen Lentz
Date:
Subject: RE: pg_basebackup inconsistent performance
Next
From: Thom Brown
Date:
Subject: Re: White space affecting parsing of range values