Skip to content

Fix mysqlnd : number that is bigger than INT64_MAX will be casted to INT64_MAX rather than string. #7837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/mysqlnd/mysqlnd_wireprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,9 +1614,9 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fiel
} else {
uint64_t v =
#ifndef PHP_WIN32
(uint64_t) atoll((char *) p);
strtoull((char *) p, NULL, 10);
#else
(uint64_t) _atoi64((char *) p);
_strtoui64((char *) p, NULL, 10);
#endif
bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ temporarily */
Expand Down
49 changes: 49 additions & 0 deletions ext/pdo_mysql/tests/unsigned_bigint.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--TEST--
Fixed value that is bigger than INT64_MAX will be casted to INT64_MAX rather than string.
--EXTENSIONS--
pdo
pdo_mysql
mysqlnd
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
?>
--FILE--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
$pdo = MySQLPDOTest::factory();

$tbl = "test";
$pdo->query("DROP TABLE IF EXISTS $tbl");
$pdo->query("CREATE TABLE $tbl (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (18446744073709551615)");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (9223372036854775808)");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (1)");
$result = $pdo->query("SELECT ubigint FROM $tbl")->fetchAll(PDO::FETCH_ASSOC);
var_dump($result);
?>
--CLEAN--
<?php
require dirname(__FILE__) . '/mysql_pdo_test.inc';
MySQLPDOTest::dropTestTable();
?>
--EXPECT--
array(3) {
[0]=>
array(1) {
["ubigint"]=>
string(20) "18446744073709551615"
}
[1]=>
array(1) {
["ubigint"]=>
string(19) "9223372036854775808"
}
[2]=>
array(1) {
["ubigint"]=>
int(1)
}
}