andrey Tue Nov 8 08:50:54 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src/ext/mysqli mysqli_api.c
Log:
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)
http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.118.2.5&r2=1.118.2.6&ty=u
Index: php-src/ext/mysqli/mysqli_api.c
diff -u php-src/ext/mysqli/mysqli_api.c:1.118.2.5
php-src/ext/mysqli/mysqli_api.c:1.118.2.6
--- php-src/ext/mysqli/mysqli_api.c:1.118.2.5 Sat Oct 15 02:32:26 2005
+++ php-src/ext/mysqli/mysqli_api.c Tue Nov 8 08:50:50 2005
@@ -15,7 +15,7 @@
| Author: Georg Richter <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
- $Id: mysqli_api.c,v 1.118.2.5 2005/10/15 06:32:26 georg Exp $
+ $Id: mysqli_api.c,v 1.118.2.6 2005/11/08 13:50:50 andrey Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -609,6 +609,7 @@
unsigned int i;
ulong ret;
int lval;
+ unsigned int ulval;
double dval;
my_ulonglong llval;
@@ -639,8 +640,23 @@
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));
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php