Hi everybody,
I'm currently working on https://github.com/php/php-src/pull/186, which fixes a problem with PostgreSQL when passing a float to pg_query_params() with a locale setting that uses "," as a decimal point. pg_query_params() uses convert_to_string(), which uses %G as a format string for floats, which is locale sensitive (and therefore converts e.g. in hr_HR or de_DE to "1,1"). The proposed fix is to introduce a new API convert_to_cstring() in the Zend Engine to allow converting types to C-locale strings.
This kind of fix is very likely needed in other places, where floats are converted using convert_to_string(). I haven’t found time to try e.g. mysqlnd, but I suspect we’ll find similar issues there. I don’t think the proposed workaround of burden users with explicitly converting floats to a numeric representation is a good solution and I think we should fix bugs like that in places they occur.
What’s your take on the proposed fix of introducing convert_to_cstring() and using it where external protocols require a locale insensitive float conversion?
cu,
Lars
Hi,
Am 19.09.2012 um 20:35 schrieb Lars Strojny lars@strojny.net:
[...]
This kind of fix is very likely needed in other places, where floats are converted using convert_to_string(). I haven’t found time to try e.g. mysqlnd, but I suspect we’ll find similar issues there. I don’t think the proposed workaround of burden users with explicitly converting floats to a numeric representation is a good solution and I think we should fix bugs like that in places they occur.
[...]
Quick follow-up, PDO::quote() and mysqli::real_escape_string() suffer from the same issue.
cu,
Lars
Hi!
Quick follow-up, PDO::quote() and mysqli::real_escape_string() suffer from the same issue.
Why would you feed doubles to escape_sting functions? I don't think it's
the right thing to do.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
hi Lars,
I'm currently working on https://github.com/php/php-src/pull/186, which fixes a problem with PostgreSQL when passing a float to pg_query_params() with a locale setting that uses "," as a decimal point. pg_query_params() uses convert_to_string(), which uses %G as a format string for floats, which is locale sensitive (and therefore converts e.g. in hr_HR or de_DE to "1,1"). The proposed fix is to introduce a new API convert_to_cstring() in the Zend Engine to allow converting types to C-locale strings.
This kind of fix is very likely needed in other places, where floats are converted using convert_to_string(). I haven’t found time to try e.g. mysqlnd, but I suspect we’ll find similar issues there. I don’t think the proposed workaround of burden users with explicitly converting floats to a numeric representation is a good solution and I think we should fix bugs like that in places they occur.
What’s your take on the proposed fix of introducing convert_to_cstring() and using it where external protocols require a locale insensitive float conversion?
To me it looks like it is not something we should try to solve. The
application, database code (via connection options, queries, etc.)
should take care of.
About internals other usages, *printf functions allow to do what you
suggest easily without adding yet another conversion function.
Cheers,
Pierre
@pierrejoye