pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16512: Character considered as a number by regex but can not convert to numeric
2+ messages / 2 participants
[nested] [flat]

* BUG #16512: Character considered as a number by regex but can not convert to numeric
@ 2020-06-26 10:44  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-06-26 10:44 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: oytf@drivetagdev.com

The following bug has been logged on the website:

Bug reference:      16512
Logged by:          tester375
Email address:      oytf@drivetagdev.com
PostgreSQL version: 12.3
Operating system:   Windows 10
Description:        

When installed Postgresql 12.3 for testing purposes we have discovered
following possible bug:
Character "8" (different from standard number 8) is treated as a number by
regular expression
  ~'\d+' 
but can not be converted to numeric by
 ::numeric

How to reproduce the bug:
Command:
SELECT '8' ~ '\d+'
returns "false" for PostgreSQL 10.4 on both Windows 10 and CentOS Linux 7
returns "false" for PostgreSQL 11.5 on CentOS Linux 7
returns "true" for PostgreSQL 12.3 on Windows 10 - but in this case,
character still can not be converted to numeric.

This behavior causes obvious problems when using data type conversion
like:
CASE WHEN column1 ~ '\d+' THEN column1::numeric AS column2
Error: '8' can not be cast to numeric



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16512: Character considered as a number by regex but can not convert to numeric
@ 2020-06-26 13:33  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-06-26 13:33 UTC (permalink / raw)
  To: oytf@drivetagdev.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> When installed Postgresql 12.3 for testing purposes we have discovered
> following possible bug:
> Character "8" (different from standard number 8) is treated as a number by
> regular expression
>   ~'\d+' 
> but can not be converted to numeric by
>  ::numeric

I see no reason to consider this a bug.

The set of characters matched by \d is, as documented, dependent on
your collation choice or locale settings (LC_CTYPE in particular).
We are not going to try to guess at what random Unicode glyphs might
be included in a particular locale, much less make numeric_in take
them all.

If you want to know whether a string is acceptable to numeric_in
I'd suggest writing something based around [0-9] not \d.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-06-26 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26 10:44 BUG #16512: Character considered as a number by regex but can not convert to numeric PG Bug reporting form <noreply@postgresql.org>
2020-06-26 13:33 ` Tom Lane <tgl@sss.pgh.pa.us>

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