Re: Expected behaviour of \d in regexp with exponent numbers ?

From: Arnaud Lesauvage <arnaud(dot)listes(at)codata(dot)eu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Expected behaviour of \d in regexp with exponent numbers ?
Date: 2014-09-02 08:01:21
Message-ID: 54057951.4070601@codata.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le 1/09/2014 18:11, Tom Lane a écrit :
> Arnaud Lesauvage <arnaud(dot)listes(at)codata(dot)eu> writes:
>> Le 1/09/2014 17:39, Tom Lane a écrit :
>>> Not necessarily. \d will match any character that iswdigit() returns true
>>> for. It looks like your new server is using a locale that considers "²"
>>> to be a digit.
>
>> Since both PostgreSQL servers run on the same computer, can I assume
>> that this is a collation problem ?
>
> Ah: after consulting the commit history I realized that the regex
> operators only base \d on iswdigit() in 9.2 and later. Before that
> it was hardwired as [0-9]. So there might not be any difference
> in the locale environment after all.
>
> I wonder whether this was a bad idea. I think it's unsurprising for the
> definition of "alphanumeric" to depend on locale, but I bet most people
> are not expecting \d to vary that way.

I guess the change in the way \d is behaving is OK as long as it is
documented in a changelog. I saw something about syncing the regexp code
with TCL somewhere, but I think there was a mention that this should not
change the regexp behaviour and that it was only to keep the code base
in sync.

The problem in my case is just that I expected any character in the
"digit" class to be a valid integer, which is wrong since the doc states
that numbers should be written with "decimal digits", not "locale digits".
So I guess I should just rewrite this regexp as [0-9]+ instead.

Thanks for the feedback !
Regards

--
Arnaud

In response to

Browse pgsql-general by date

  From Date Subject
Next Message swaroop 2014-09-02 08:28:08 Re: copymanager question
Previous Message Craig Ringer 2014-09-02 04:40:59 Re: copymanager question