Hi hackers!
I'm toying with Windows machine. It's nice, fast, run cool games, so I decided to keep it and make a BF animal on top.
Theproblem is I have RU locale.
PostgreSQL::Test::Utils.pm (lines 113-115) explicitly sets:
$ENV{LC_NUMERIC} = 'C';
setlocale(LC_ALL, "");
This makes Perl format numbers with . as the decimal separator.
Windows MSVC strtod(): seems to ignore environment variables entirely and use the system's regional settings (Russian
locale,)
On Unix, environment variables like LC_NUMERIC control both Perl and C library functions like strtod(). Looks like on
Windowswith MSVC, the C runtime gets its locale from the Windows regional settings, not from environment variables.
FWIW I used strawberry perl 5, version 42, subversion 0 (v5.42.0) built for MSWin32-x64-multi-thread. Windows 11 Pro
23H2build 22631.4890.
I propose attached ugly fix, it makes my box happy and works on CI machines.
In pg_test_timing fix is easy. It just accept [,.] as a decimal separator. AFAIK that would solve the problem for
Russian,Brazilian, Indonesia, German, Italian, Polish etc locales. There are some other separators, but with really
smallfraction, I could add them into regex, but with a wiki-page-like comment... so here's [,.]
For \watch tests we need to format number that would be acceptable to strtod(), so I resorted to printing this number
bypsql. Luckily in standard SQL syntax so far, the period (.) is the universal decimal separator for numeric literals
ina query.
Perhaps, I should just switch my machine to locale with dot too. But just in case if we really want tests on Windows
withlocales, PFA.
I did not consider seriously bashing with Utils.pm setlocale(). But maybe I should try.
WDYT?
Best regards, Andrey Borodin.