From: me at derrabus dot de
Operating system: Linux 2.6
PHP version: 5.0.3
PHP Bug Type: MySQL related
Bug description: mysql_fetch_field() reports weird table names on SHOW queries
Description:
------------
I am running php 5.0.3 and MySQL 5.0.2 on my machine. The MySQL extension
is compiled against a MySQL 5.0.2 client library.
The code below returns weird table names (like #sql_f85_0) although the
query should not affect any tables. So far, I could reproduce the problem
with "SHOW TABLES" and "SHOW TABLE STATUS".
If I do the same on my other machine (php 5.0.3, MySQL server & client API
4.0.22), the returned table name is empty (as it should, imho).
I don't know if this is a bug of the MySQL extension or MySQL's C API, but
since I cannot debug the C API right now, I'm posting this here.
Reproduce code:
---------------
<pre>
<?php
$dbh = mysql_connect('localhost', 'user', 'password');
mysql_select_db('test'); // this should be an existing DB with at least
one table.
$res = mysql_query('SHOW TABLES;', $dbh);
$field = mysql_fetch_field($res);
print_r($field);
mysql_free_result($res);
mysql_close($dbh);
?>
</pre>
Expected result:
----------------
[table] should be empty.
Actual result:
--------------
stdClass Object
(
[name] => Tables_in_test
[table] => #sql_f85_0
[def] =>
[max_length] => 2
[not_null] => 1
[primary_key] => 0
[multiple_key] => 0
[unique_key] => 0
[numeric] => 0
[blob] => 0
[type] => string
[unsigned] => 0
[zerofill] => 0
)
--
Edit bug report at http://bugs.php.net/?id=31967&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31967&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31967&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31967&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31967&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31967&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31967&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31967&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31967&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31967&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31967&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31967&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31967&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31967&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31967&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31967&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31967&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31967&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31967&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31967&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31967&r=mysqlcfg