Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #79596: MySQL FLOAT truncates to int some locales
We must not do locale aware float to string conversion here; instead we using our `snprintf()` implementation with the `F` specifier.
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
Bug #79596 (MySQL FLOAT truncates to int some locales) | ||
--SKIPIF-- | ||
<?php | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); | ||
MySQLPDOTest::skip(); | ||
if (!setlocale(LC_ALL, 'de_DE', 'de-DE')) die('skip German locale not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); | ||
|
||
setlocale(LC_ALL, 'de_DE', 'de-DE'); | ||
|
||
$pdo = MySQLPDOTest::factory(); | ||
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); | ||
$pdo->query('CREATE TABLE bug79596 (broken FLOAT(2,1))'); | ||
$pdo->query('INSERT INTO bug79596 VALUES(4.9)'); | ||
var_dump($pdo->query('SELECT broken FROM bug79596')->fetchColumn(0)); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); | ||
|
||
$pdo = MySQLPDOTest::factory(); | ||
$pdo->exec("DROP TABLE IF EXISTS bug79596"); | ||
?> | ||
--EXPECT-- | ||
float(4,9) |