summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2005-11-08 13:50:50 +0000
committerAndrey Hristov <andrey@php.net>2005-11-08 13:50:50 +0000
commit00a9f063f8bbd165562fe7bd38c759393324fa84 (patch)
tree973a7efba656691961ffefdfbae37c9293e9af14
parent270640283e4bceee208b09a843c02b2e79b71e07 (diff)
downloadphp-git-00a9f063f8bbd165562fe7bd38c759393324fa84.tar.gz
on 32bit platform if the column is UNSIGNED INT(11) and the value
is greater than 2^31-1 then convert to string. on 64bit this is of no problem because there long inside zval is big enough to keep unsigned int(11)
-rw-r--r--ext/mysqli/mysqli_api.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 0d62e34487..8f6d778c01 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -609,6 +609,7 @@ PHP_FUNCTION(mysqli_stmt_fetch)
unsigned int i;
ulong ret;
int lval;
+ unsigned int ulval;
double dval;
my_ulonglong llval;
@@ -639,8 +640,23 @@ PHP_FUNCTION(mysqli_stmt_fetch)
if (!stmt->result.is_null[i]) {
switch (stmt->result.buf[i].type) {
case IS_LONG:
- memcpy(&lval, stmt->result.buf[i].val, sizeof(lval));
- ZVAL_LONG(stmt->result.vars[i], lval);
+ if ((sizeof(long) ==4) && (stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
+ && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
+ {
+ /* unsigned int (11) */
+ char tmp[12];
+ memcpy (&ulval, stmt->result.buf[i].val, sizeof(lval));
+ if (ulval > INT_MAX) {
+ sprintf((char *)&tmp, "%u", ulval);
+ ZVAL_STRING(stmt->result.vars[i], tmp, 1);
+ } else {
+ memcpy(&lval, stmt->result.buf[i].val, sizeof(lval));
+ ZVAL_LONG(stmt->result.vars[i], lval);
+ }
+ } else {
+ memcpy(&lval, stmt->result.buf[i].val, sizeof(lval));
+ ZVAL_LONG(stmt->result.vars[i], lval);
+ }
break;
case IS_DOUBLE:
memcpy(&dval, stmt->result.buf[i].val, sizeof(dval));