mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
Merge branch 'PHP-7.0' into PHP-7.1
This commit is contained in:
commit
32123167d1
2
NEWS
2
NEWS
@ -2,6 +2,8 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 7.1.0RC5
|
||||
|
||||
- SQLite3:
|
||||
. Fixed bug #73333 (2147483647 is fetched as string). (cmb)
|
||||
|
||||
19 Oct 2016, PHP 7.1.0RC4
|
||||
|
||||
|
@ -567,13 +567,20 @@ PHP_METHOD(sqlite3, query)
|
||||
|
||||
static void sqlite_value_to_zval(sqlite3_stmt *stmt, int column, zval *data) /* {{{ */
|
||||
{
|
||||
sqlite3_int64 val;
|
||||
|
||||
switch (sqlite3_column_type(stmt, column)) {
|
||||
case SQLITE_INTEGER:
|
||||
if ((sqlite3_column_int64(stmt, column)) >= INT_MAX || sqlite3_column_int64(stmt, column) <= INT_MIN) {
|
||||
val = sqlite3_column_int64(stmt, column);
|
||||
#if LONG_MAX <= 2147483647
|
||||
if (val > ZEND_LONG_MAX || val < ZEND_LONG_MIN) {
|
||||
ZVAL_STRINGL(data, (char *)sqlite3_column_text(stmt, column), sqlite3_column_bytes(stmt, column));
|
||||
} else {
|
||||
ZVAL_LONG(data, sqlite3_column_int64(stmt, column));
|
||||
#endif
|
||||
ZVAL_LONG(data, val);
|
||||
#if LONG_MAX <= 2147483647
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SQLITE_FLOAT:
|
||||
|
@ -24,4 +24,4 @@ var_dump($num,$result[0]);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(2147483647)
|
||||
string(10) "2147483647"
|
||||
int(2147483647)
|
||||
|
@ -24,4 +24,4 @@ var_dump($num,$result[0]);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(100004313234244)
|
||||
string(15) "100004313234244"
|
||||
int(100004313234244)
|
||||
|
26
ext/sqlite3/tests/bug73333.phpt
Normal file
26
ext/sqlite3/tests/bug73333.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #73333 (2147483647 is fetched as string)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('sqlite3')) die('skip sqlite3 extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
if (!defined('PHP_INT_MIN')) define('PHP_INT_MIN', -PHP_INT_MAX-1);
|
||||
|
||||
$db = new SQLite3(':memory:');
|
||||
$db->exec('CREATE TABLE foo (bar INT)');
|
||||
foreach ([PHP_INT_MIN, PHP_INT_MAX] as $value) {
|
||||
$db->exec("INSERT INTO foo VALUES ($value)");
|
||||
}
|
||||
|
||||
$res = $db->query('SELECT bar FROM foo');
|
||||
while (($row = $res->fetchArray(SQLITE3_NUM)) !== false) {
|
||||
echo gettype($row[0]), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
integer
|
||||
integer
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user