Skip to content

asymmetric conversion with de_DE.utf8 [CORE2491] #2904

Open
@firebird-automations

Description

@firebird-automations

Submitted by: Frank Schlottmann-Goedde (fsg)

I stumbled over a strange behaviour using an UDF written in Kylix.
A shared object written in Kylix scans the environment and if a value
for LC_whatever is found sets it via calls to setlocale. This results
later on in casting errors at totally unrelated places.

BTW. This doesn't affect the windows versions.

To reproduce these errors without the need for Kylix I have added

#⁠include <locale.h>
...
ISC_LONG EXPORT IB_UDF_setsystemlocale()
{
setlocale (LC_ALL,"");
return 0;
}

to ib_udf.cpp

and declared it via:

DECLARE EXTERNAL FUNCTION setsystemlocale
RETURNS integer BY VALUE
ENTRY_POINT 'IB_UDF_setsystemlocale' MODULE_NAME 'ib_udf';

and now for the fun part of it:

We need a locale that doesn't use '.' as a decimal separator, so first
of all:
root@dev2server:/opt/BVMP36/Daten/securon#⁠ export LC_ALL=de_DE.utf8
root@dev2server:/opt/BVMP36/Daten/securon#⁠ isql bvmp.fdb
Database: bvmp.fdb
SQL> select cast(cast(cast(cast(1.0 as varchar(20)) as float) as
varchar(20)) as float) from rdb$database;

      CAST

==============
1.0000000

SQL> select setsystemlocale() from rdb$database;

SETSYSTEMLOCALE

          0

SQL> select cast(cast(cast(cast(1.0 as varchar(20)) as float) as
varchar(20)) as float) from rdb$database;

      CAST

==============
Statement failed, SQLSTATE = 22018
conversion error from string "1,0000000"
SQL> select cast(cast(cast(1.0 as varchar(20)) as float) as varchar(20))
from rdb$database;

CAST

1,0000000

These are the results with the 2.5 version of the engine.
It's worse with 2.0 as it doesn't throw an exception but returns wrong
results.