pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Thom Brown <thom@linux.com>
To: PGSQL Mailing List <pgsql-general@postgresql.org>
Subject: Re: White space affecting parsing of range values
Date: Wed, 6 May 2020 09:13:19 -0700
Message-ID: <597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com> (raw)
In-Reply-To: <CAA-aLv7oUgi6RGJetZwuvoVz=wdcZBmWkY3wMOyW2fGVpN+ybQ@mail.gmail.com>
References: <CAA-aLv7oUgi6RGJetZwuvoVz=wdcZBmWkY3wMOyW2fGVpN+ybQ@mail.gmail.com>

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





view thread (7+ messages)  latest in thread

Message-ID: <597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com>
Permalink:  ../597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com/
Also on:    postgresql.org/message-id/597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, thom@linux.com
  Subject: Re: White space affecting parsing of range values
  In-Reply-To: <597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com>
  References: <CAA-aLv7oUgi6RGJetZwuvoVz=wdcZBmWkY3wMOyW2fGVpN+ybQ@mail.gmail.com> <597b7d3a-170c-5c17-00db-1702c69ac59a@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox