Hi Noah, On Sat, Aug 31, 2019 at 12:59:43AM -0700, Noah Misch wrote:
> > 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. Ah. > > > 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? Happy to. While pondering whether to fiddle with LANG/setlocale() around a standard strtod() or adding a custom locale-unaware strtod() I found the STORE_*_LC_NUMERIC macros in perl.h (https://github.com/Perl/perl5/blob/blead/perl.h#L6361), particularly STORE_LC_NUMERIC_SET_STANDARD. This is used at least in Perl's own sv.c and dump.c to get dotted decimals in debug output. More details are given in perlxs CAVEATS (https://perldoc.perl.org/perlxs.html#CAVEATS) and perlapi (https://perldoc.perl.org/perlapi.html#STORE_LC_NUMERIC_SET_TO_NEEDED). Unfortunately, it seems the whole mechanism was introduced only in perl 5.20, so would be unavailable in macOS's system perl 5.18, making the point moot. There does not seem to be a locale-unaware strtod() in perl already we could use. So we're back to the first two choices of fiddling with LANG/setlocale() or implementing a custom strtod(). I'd prefer the latter. What are your thoughts on this, particularly license-wise where to grab an implementation from (BSD?)? -- Thanks, Michael
