From: aavolkoff at gmail dot com
Operating system: Linux l9.in-solve.ru 2.6.26-r9-s
PHP version: 5.2.11
PHP Bug Type: MySQLi related
Bug description: Value of "length" column for fetch_fields() is incorrect.
Description:
------------
Value of "length" column for fetch_fields() is incorrect.
eg: MySQL version: 5.0.37
Reproduce code:
---------------
I have table "Users":
name = "id"; type = "INT"; length = 11.
name = "name"; type = "VARCHAR"; length = 200.
name = "description"; type = "VARCHAR"; length = 200.
Code:
//$mysqli defined earlier
$query = "SELECT * FROM `Users` LIMIT 0";
$query_result = $mysqli->real_query($query);
if ($query_result)
{
$mysqli_result = $mysqli->use_result();
$mysqli_fields = $mysqli_result->fetch_fields();
$mysqli_result->free_result();
print_r($mysqli_fields);
}
Expected result:
----------------
Array (
[0] => stdClass Object (
[name] => id
[orgname] => id
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 11
[charsetnr] => 63
[flags] => 49667
[type] => 3
[decimals] => 0 )
[1] => stdClass Object (
[name] => name
[orgname] => name
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 200
[charsetnr] => 33
[flags] => 0
[type] => 253
[decimals] => 0 )
[2] => stdClass Object (
[name] => description
[orgname] => description
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 200
[charsetnr] => 33
[flags] => 0
[type] => 253
[decimals] => 0 )
)
Actual result:
--------------
Array (
[0] => stdClass Object (
[name] => id
[orgname] => id
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 11
[charsetnr] => 63
[flags] => 49667
[type] => 3
[decimals] => 0 )
[1] => stdClass Object (
[name] => name
[orgname] => name
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 600
[charsetnr] => 33
[flags] => 0
[type] => 253
[decimals] => 0 )
[2] => stdClass Object (
[name] => description
[orgname] => description
[table] => Users
[orgtable] => Users
[def] =>
[max_length] => 0
[length] => 600
[charsetnr] => 33
[flags] => 0
[type] => 253
[decimals] => 0 )
)
Parameter "length" of array elements is incorrect (600, but not 200).
When I change length in PhpMyAdmin to 150 code "says" that length is
450.
When I change length in PhpMyAdmin to 1 code "says" that length is 3.
--
Edit bug report at http://bugs.php.net/?id=49961&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49961&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49961&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49961&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49961&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49961&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49961&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49961&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49961&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49961&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49961&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49961&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49961&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49961&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49961&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49961&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49961&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49961&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49961&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49961&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49961&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49961&r=mysqlcfg