ID: 37671
Updated by: iliaa@php.net
Reported By: squasar at eternalviper dot net
-Status: Assigned
+Status: Closed
Bug Type: MySQLi related
Operating System: *
PHP Version: 5.1.4
Assigned To: iliaa
New Comment:
With latest CVS your code returns the following results:
long(1) refcount(1)
long(0) refcount(1)
long(1) refcount(1)
long(0) refcount(1)
Previous Comments:
------------------------------------------------------------------------
[2006-06-08 06:27:06] squasar at eternalviper dot net
That sample from the manual is irrelevant. Re-examine the
reproduce code I provided. It FAILS using the patch that was
applied to CVS; the result is always zero regardless of the
values in the column, even though it's a BIT(1).
------------------------------------------------------------------------
[2006-06-07 13:08:32] iliaa@php.net
BIT[(M)]
A bit-field type. M indicates the number of bits per value,
from 1 to 64. The default is 1 if M is omitted.
(From MySQL manual)
------------------------------------------------------------------------
[2006-06-07 04:43:39] squasar at eternalviper dot net
The patch applied to CVS does NOT fix the bug. The CVS patch
folds BIT handling into LONG types. This does not work; BIT
columns take a 64-bit type, NOT a 32-bit type. Please re-
examine the patch I supplied, which folds BIT handling into
LONGLONG types.
------------------------------------------------------------------------
[2006-06-04 14:57:14] iliaa@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2006-06-02 20:03:38] squasar at eternalviper dot net
With apologies for all the extra comments, here is a
somewhat better patch that allows for arbitrary values in a
BIT column. However, I do not believe this is ideal for a
bitfield type.
Index: ext/mysqli/mysqli_api.c
============================================================
=======
RCS file: /repository/php-src/ext/mysqli/mysqli_api.c,v
retrieving revision 1.118.2.22
diff -u -r1.118.2.22 mysqli_api.c
--- ext/mysqli/mysqli_api.c 5 Apr 2006 12:17:08 -0000
1.118.2.22
+++ ext/mysqli/mysqli_api.c 2 Jun 2006 20:02:17 -0000
@@ -303,10 +303,13 @@
break;
case MYSQL_TYPE_LONGLONG:
+#ifdef FIELD_TYPE_BIT
+ case MYSQL_TYPE_BIT:
+#endif
stmt->result.buf[ofs].type =
IS_STRING;
stmt->result.buf[ofs].buflen
= sizeof(my_ulonglong);
stmt->result.buf[ofs].val =
(char *)emalloc(stmt->result.buf[ofs].buflen);
- bind[ofs].buffer_type =
MYSQL_TYPE_LONGLONG;
+ bind[ofs].buffer_type =
col_type;
bind[ofs].buffer = stmt-
>result.buf[ofs].val;
bind[ofs].is_null = &stmt-
>result.is_null[ofs];
bind[ofs].buffer_length =
stmt->result.buf[ofs].buflen;
@@ -693,7 +696,11 @@
ZVAL_DOUBLE
(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
break;
case IS_STRING:
- if (stmt-
>stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) {
+ if (stmt-
>stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
+#ifdef FIELD_TYPE_BIT
+
|| stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
+#endif
+ ) {
my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)?
1:0;
llval= *(my_ulonglong *) stmt->result.buf[i].val;
#if SIZEOF_LONG==8
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/37671--
Edit this bug report at http://bugs.php.net/?id=37671&edit=1