mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
Fix #73396: bigint columns are returned as strings
This commit is contained in:
1
NEWS
1
NEWS
@@ -44,6 +44,7 @@ PHP NEWS
|
||||
- PDO_DBlib:
|
||||
. Fixed bug #73234 (Emulated statements let value dictate parameter type).
|
||||
(Adam Baratz)
|
||||
. Fixed bug #73396 (bigint columns are returned as strings).
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #69137 (Peer verification fails when using a proxy with SoapClient)
|
||||
|
||||
@@ -268,7 +268,9 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
|
||||
data_len = dbdatlen(H->link, colno+1);
|
||||
|
||||
if (data_len != 0 || data != NULL) {
|
||||
if (stmt->dbh->stringify) {
|
||||
/* force stringify if DBBIGINT won't fit in zend_long */
|
||||
/* this should only be an issue for 32-bit machines */
|
||||
if (stmt->dbh->stringify || (coltype == SQLINT8 && sizeof(zend_long) < sizeof(DBBIGINT))) {
|
||||
switch (coltype) {
|
||||
case SQLDECIMAL:
|
||||
case SQLNUMERIC:
|
||||
@@ -277,6 +279,7 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
|
||||
case SQLMONEYN:
|
||||
case SQLFLT4:
|
||||
case SQLFLT8:
|
||||
case SQLINT8:
|
||||
case SQLINT4:
|
||||
case SQLINT2:
|
||||
case SQLINT1:
|
||||
@@ -351,22 +354,28 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
|
||||
|
||||
break;
|
||||
}
|
||||
case SQLINT8: {
|
||||
zv = emalloc(sizeof(zval));
|
||||
ZVAL_LONG(zv, *(DBBIGINT *) data);
|
||||
|
||||
break;
|
||||
}
|
||||
case SQLINT4: {
|
||||
zv = emalloc(sizeof(zval));
|
||||
ZVAL_LONG(zv, (long) ((int) *(DBINT *) data));
|
||||
ZVAL_LONG(zv, *(DBINT *) data);
|
||||
|
||||
break;
|
||||
}
|
||||
case SQLINT2: {
|
||||
zv = emalloc(sizeof(zval));
|
||||
ZVAL_LONG(zv, (long) ((int) *(DBSMALLINT *) data));
|
||||
ZVAL_LONG(zv, *(DBSMALLINT *) data);
|
||||
|
||||
break;
|
||||
}
|
||||
case SQLINT1:
|
||||
case SQLBIT: {
|
||||
zv = emalloc(sizeof(zval));
|
||||
ZVAL_LONG(zv, (long) ((int) *(DBTINYINT *) data));
|
||||
ZVAL_LONG(zv, *(DBTINYINT *) data);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
# define SQLINT1 SYBINT1
|
||||
# define SQLINT2 SYBINT2
|
||||
# define SQLINT4 SYBINT4
|
||||
# define SQLINT8 SYBINT8
|
||||
# define SQLINTN SYBINTN
|
||||
# define SQLBIT SYBBIT
|
||||
# define SQLFLT4 SYBREAL
|
||||
|
||||
20
ext/pdo_dblib/tests/bug_73396.phpt
Normal file
20
ext/pdo_dblib/tests/bug_73396.phpt
Normal file
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
PDO_DBLIB: bigint columns are returned as strings
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('pdo_dblib')) die('skip not loaded');
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
|
||||
// on 64-bit machines, these columns should come back as ints
|
||||
// on 32-bit machines, they will come back as strings because zend_long isn't big enough
|
||||
$expected = PHP_INT_SIZE == 8 ? 1 : '1';
|
||||
|
||||
$stmt = $db->query('SELECT CAST(1 AS bigint)');
|
||||
var_dump($stmt->fetchColumn() === $expected);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
Reference in New Issue
Block a user