#32832 [NEW]: SHOW TABLES doesn't work correctly

From: Date: Tue, 26 Apr 2005 09:40:43 +0000
Subject: #32832 [NEW]: SHOW TABLES doesn't work correctly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78200@lists.php.net to get a copy of this message
From: seusel73 at gmx dot de Operating system: Linux PHP version: 4.3.10 PHP Bug Type: MySQL related Bug description: SHOW TABLES doesn't work correctly Description: ------------ The SHOW TABLES command doesn't work on the currently selected database, but on the last selected one, even if that one has been executed on a different connection handle. In the example code, replace "host", "user", "password" with host, user and password of your mysql server, and "test1", "test2" with two names of two different databases on your mysql server - they should contain tables with different names so you can detect a different listing. The same problem comes up with "SHOW INDEX FROM table" and "SHOW COLUMNS FROM table" :-( They always put out information from the second db... Exchanging mysql_connect with mysql_pconnect() doesn't change anything. php.ini is without surprise: [MySQL] mysql.allow_persistent = On mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = The configureline shouldn't be problem either: './configure' '--prefix=/httpd' '--with-config-file-path=/httpd/lib' '--with-apxs=/httpd/bin/apxs' '--with-informix=/informix' '--with-ttf' '--with-ftp' '--with-sfw' '--with-hyperwave' '--with-snmp' '--with-bz2' '--with-mime-magic' '--with-gdbm' '--with-inifile' '--with-flatfile' '--enable-bcmath' '--enable-calendar' '--enable-sockets' '--enable-dba' '--enable-wddx' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-safe-mode' '--enable-memory-limit' '--enable-inline-optimization' '--enable-magic-quotes' '--with-zlib=yes' '--with-gd=yes' '--with-unixODBC=/usr/lib' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-imap' '--with-ssl=/usr' '--with-imap-ssl=/usr' '--with-openssl=/usr' Reproduce code: --------------- function connect ($name) { $res = @mysql_connect ("host", "user", "password"); mysql_select_db ($name, $res); return $res; } function list_tables ($db) { if ($retv = @mysql_query ("SHOW TABLES", $db)) { $res = array(); while ($v = @mysql_fetch_assoc ($retv)) { foreach ($v as $idx => $name) { $s = $name; break; } $res[] = $s; } @mysql_free_result ($retv); } return $res; } $db1 = connect ("test1"); $db2 = connect ("test2"); $qr1 = list_tables ($db1); $qr2 = list_tables ($db2); @mysql_close ($db1); @mysql_close ($db2); var_dump ($qr1); var_dump ($qr2); Expected result: ---------------- List of names of tables in database "test1" and "test2" Actual result: -------------- List of names of tables in database "test2" - twice -- Edit bug report at http://bugs.php.net/?id=32832&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32832&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32832&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32832&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32832&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32832&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32832&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32832&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32832&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32832&r=support Expected behavior: http://bugs.php.net/fix.php?id=32832&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32832&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32832&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32832&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32832&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32832&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32832&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32832&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32832&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32832&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32832&r=mysqlcfg

« previous php.bugs (#78200) next »