Edit report at https://bugs.php.net/bug.php?id=60333&edit=1

 ID:                 60333
 User updated by:    danielc at analysisandsolutions dot com
 Reported by:        danielc at analysisandsolutions dot com
 Summary:            fetch_field() length multiplied by 3 in mysqlnd
 Status:             Open
 Type:               Bug
 Package:            MySQLi related
 Operating System:   linux
 PHP Version:        5.4SVN-2011-11-19 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

That may be the case, but having UTF-8 fields is legit and the answers from 
libmysql and mysqlnd should be the same.


Previous Comments:
------------------------------------------------------------------------
[2011-11-21 17:59:23] william dot bailey at cowboysfromhell dot co dot uk

I think this might be down to what encoding the connection is using.

The length in bytes of a mysql utf8 CHAR(2) field is 6.

If you issue a $db->query('SET NAMES latin1'); before the CREATE TABLE then you 
should get the results you are expecting.

------------------------------------------------------------------------
[2011-11-19 02:38:53] danielc at analysisandsolutions dot com

Description:
------------
Running PHP 5.4 compiled from svn earlier today.  The "length" values from 
fetch_field() are multiplied by 3 when building mysqli against mysqlnd.  The 
values are correct when building against libmysql.

Test script:
---------------
$db = new mysqli(null, $_ENV['MYSQL_TEST_USER'],
    $_ENV['MYSQL_TEST_PASSWD'], $_ENV['MYSQL_TEST_DB'],
    null, $_ENV['MYSQL_TEST_SOCKET']);

$result = $db->query("CREATE TEMPORARY TABLE phptest_fk (
    txt TEXT NULL,
    chr2 CHAR(2) default 'df' NOT NULL,
    chr10 CHAR(10) default 'df' NOT NULL)");
if (!$result) {
    echo "OOPS: $db->error\n";
    exit(1);
}

$result = $db->query("INSERT INTO phptest_fk VALUES ('One', 'c1')");
$result = $db->query("SELECT * FROM phptest_fk");

$info = $result->fetch_field();
echo "$info->name $info->length\n";
$info = $result->fetch_field();
echo "$info->name $info->length\n";
$info = $result->fetch_field();
echo "$info->name $info->length\n";


Expected result:
----------------
txt 65535
chr2 2
chr10 10

Actual result:
--------------
txt 196605
chr2 6
chr10 30


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60333&edit=1

Reply via email to