Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24368 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4204 invoked by uid 1010); 13 Jul 2006 16:50:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 4189 invoked from network); 13 Jul 2006 16:50:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2006 16:50:34 -0000 X-PHP-List-Original-Sender: gwynne@skytag.com X-Host-Fingerprint: 208.97.132.5 mailbigip.dreamhost.com Linux 2.4/2.6 Received: from ([208.97.132.5:40604] helo=spunkymail-a4.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id CF/00-63905-8D976B44 for ; Thu, 13 Jul 2006 12:50:33 -0400 Received: from [192.168.0.101] (c-66-31-91-125.hsd1.ma.comcast.net [66.31.91.125]) by spunkymail-a4.dreamhost.com (Postfix) with ESMTP id 350B9131A2F for ; Thu, 13 Jul 2006 09:50:27 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <28E23FD5-0764-4BF0-9306-CCB252101548@skytag.com> References: <28E23FD5-0764-4BF0-9306-CCB252101548@skytag.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: Content-Transfer-Encoding: 7bit Date: Thu, 13 Jul 2006 12:50:02 -0400 To: internals@lists.php.net X-Mailer: Apple Mail (2.752.2) Subject: Re: [PHP-DEV] BIT columns and MySQLi From: gwynne@skytag.com (Gwynne) On Jun 25, 2006, at 8:03 AM, Gwynne wrote: > Ilia and I have been bouncing back and forth on bug #37671 (MySQLi > extension fails to recognize BIT columns)[1] between "yes it's > fixed", "no it isn't!" for some time now. I'm curious which one of > us the experience of others agrees with. Ilia seems to be able to > get a working result with the current PHP_5_2 code, while I can't. > Can anyone share some insight into this? > > [1] http://bugs.php.net/bug.php?id=37671 I hate to bring this up again, but with 5.2 heading towards RC1 and no answers in sight, I really would like a resolution here. I've been patching my PHP builds ever since I switched to MySQL 5 databases just for this issue. The solution I'm using is at the end of this message (the same patch works against PHP_5_2 and HEAD; this one specifically was run against HEAD. It requires only a tiny modification to work against php_5_1_4, which is what I'm using now; against 5_1_4 there's no need to - out the incorrect handling). It seems to work in 100% of cases I've tested. The current code in 5_2 and HEAD, which folds it into LONG types, does NOT work correctly. Can someone please either commit something like this or tell me why they refuse to? --- mysqli_api.c 12 Jul 2006 10:15:30 -0000 1.129 +++ mysqli_api.c 13 Jul 2006 16:29:00 -0000 @@ -294,9 +294,6 @@ case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: case MYSQL_TYPE_YEAR: -#if MYSQL_VERSION_ID > 50002 - case MYSQL_TYPE_BIT: -#endif convert_to_long_ex(args[i]); stmt->result.buf[ofs].type = IS_LONG; /* don't set stmt->result.buf [ofs].buflen to 0, we used ecalloc */ @@ -308,10 +305,13 @@ break; case MYSQL_TYPE_LONGLONG: +#if MYSQL_VERSION_ID > 50002 + 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; // MYSQL_TYPE_LONGLONG; 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; @@ -695,7 +695,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 +#if MYSQL_VERSION_ID > 50002 + || 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