Re: Fix number skipping in to_number

From: Oliver Ford <ojford(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix number skipping in to_number
Date: 2017-11-13 21:07:34
Message-ID: CAGMVOdup_3CN_EN0Asw8p51PX6EH8qinusW5kjGL0Qyd9r0T8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Monday, 13 November 2017, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Oliver Ford <ojford(at)gmail(dot)com <javascript:;>> writes:
> > On Sun, Nov 12, 2017 at 7:00 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <javascript:;>> wrote:
> >> * Don't we need to fix the NUM_L (currency symbol) case in the
> >> same manner? (The NUM_D and NUM_S cases are handled in
> >> NUM_numpart_from_char and seem ok at a quick glance.)
>
> > Yes you get the same skipping if you do:
>
> > select to_number('12','L99');
> > to_number
> > -----------
> > 2
>
> > However, this case is not as easy to fix as you can't do a simple
> > string comparison like with the group separator. The currency symbol
> > for the locale can be " " but if we do a comparison, it won't match if
> > the symbol specified is "$" or "£" (so will end up missing characters
> > at the end of the supplied string). Could we apply the attached patch
> > and then put fixing it for currency on the TODO list?
>
> I don't follow your concern? If "$" is not the correct currency
> symbol for the locale, we shouldn't accept it as a match to an L format.
> Your patch is tightening what we will accept as a match to a G format,
> so I don't see why you're concerned about backward compatibility in
> one case but not the other.
>
> regards, tom lane
>

It's a guess as to the likely use case. I would imagine that people are
likely to use a currency symbol different from the locale, but unlikely to
use a different group separator. Others might have a different opinion
though.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-11-13 21:09:40 Re: [HACKERS] parallelize queries containing initplans
Previous Message Jeremy Schneider 2017-11-13 21:00:52 Re: [HACKERS] pg_upgrade to clusters with a different WAL segment size