On Tue, Aug 27, 2019 at 01:48:52PM +0200, Michael Weiser wrote:
> On Mon, Aug 26, 2019 at 11:28:09PM -0700, Noah Misch wrote:

> > > > # LANG=C perl ~/t.pl
> > > > FOO: 1.1:1.100000 C
> > > > 1.1
> > > > # LANG=de_DE.UTF-8 perl ~/t.pl
> > > > FOO: 1.1:1,000000 de_DE.UTF-8
> > > > 1
> > > > - so far only macOS's system perl seems to be affected. A perl 5.29.9
> > > >   compiled myself on the same system does not exhibit the problem and
> > > >   neither does a Debian testing box.
> > I can reproduce it on RHEL 7 with DBD::Pg git head.
> 
> That's a relief for sure. :)
> 
> > That strtod() call is a
> > somewhat-recent addition (added in DBD::Pg 3.6.0, from 2017).  What is the
> > output of these two commands with each of those Perl installations?

> # /tmp/myperl/bin/perl5.29.9 -MDBD::Pg -e 'print $DBD::Pg::VERSION, "\n"'
> 3.7.4
> # /tmp/myperl/bin/perl5.29.9 -MPOSIX -e 'use strict; use warnings; 
> setlocale(LC_NUMERIC, ""); print join " ", strtod("1.1"), "\n"'
> 1.1 0 
> # LANG=de_DE.UTF-8 /tmp/myperl/bin/perl5.29.9 -MPOSIX -e 'use strict; use 
> warnings; setlocale(LC_NUMERIC, ""); print join " ", strtod("1.1"), "\n"'
> 1 2 
> 
> While this would seem to suggest that both use a locale-aware strtod in the
> POSIX module, the reproducer still holds:
> 
> # /usr/bin/perl -I/tmp/dbdpg/lib/perl5 t.pl
> 1.1
> # LANG=de_DE.UTF-8 /usr/bin/perl -I/tmp/dbdpg/lib/perl5 t.pl
> 1
> # /tmp/myperl/bin/perl5.29.9 t.pl
> 1.1
> # LANG=de_DE.UTF-8 /tmp/myperl/bin/perl5.29.9 t.pl
> 1.1
> 
> That would seem to suggest that DBD::Pg in my self-compiled perl uses another
> strtod than the POSIX module. The same seems to be the case on Debian testing

I now find https://perldoc.perl.org/perlxs.html explains this.  It writes,
'starting in v5.22, perl tries to keep LC_NUMERIC always set to "C"'.  Hence,
one will see the problem only with DBD::Pg >= 3.6.0 and Perl < 5.22.

> > > >         The text representation of values is whatever strings are
> > > >         produced and accepted by the input/output conversion functions
> > > >         for the particular data type.
> > PostgreSQL always prints ".", not a locale-specific radix character.  A
> > locale-ignorant strtod() would suffice in DBD::Pg.
> 
> Awesome. Is there anyway I can help with this?

Would you like to write a patch?

Reply via email to