From: Operating system: Linux, Slamd64 11.0 PHP version: 5.2.13 Package: ODBC related Bug Type: Bug Bug description:odbc_columns() fetching binary garbage with unixODBC on 64-bit platform
Description: ------------ Platform and versions: PHP 5.2.13, built from source unixODBC 2.2.14, built from source ODBC support compiled-in Configure line: ./configure --prefix=/usr --with-libdir=lib64 --with-config-file-path=/etc/apache --sysconfdir=/etc --enable-force-cgi-redirect --with-regex=system --with-freetype-dir=/usr --with-openssl --with-zlib --with-curl --enable-ftp --with-pgsql --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config --enable-dbase --enable-soap --with-gettext --enable-mbstring=all --enable-mbregex --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-ming --with-unixODBC=/usr/local/unixODBC Database servers: MySQL 5.0 Issue: Using odbc_columns() or odbc_columnprivileges() returns binary garbage in its fields. My guess, based on previous unixODBC-related bugs in other software (GDAL/OGR), is a integer range issue in unixODBC on 64-bit platforms. In the case of GDAL/OGR the developer noted that unixODCB was returning garbage as the first 4 bytes of a 8-byte integer; his fix was truncating and casting the values. Test script: --------------- <?php $dsn = sprintf("Driver=%s;Server=%s;Port=%d;Database=%s;", 'MySQL', 'db.hostgis.com', '3306', 'gregor'); $odbc = odbc_connect($dsn, 'gregor', 'mosheh', SQL_CUR_USE_ODBC ); if (!$odbc) die("Failed to connect\n"); // fetch all columns for the table "grid" // I know that these are id (integer, auto), title (varchar), latitude (float), and longitude (float) $columninfo = odbc_columns($odbc, '', '', 'grid', '%'); // fetch the column name and type for the columns // Note that there are 4 returns, which corresponds to 4 columns; but nothing is pritned while ($row = odbc_fetch_array($columninfo)) { print_r($row); print "<br/>\n"; } // do it again and print a table of the columns' info, and again see 4 rows // but note how theyre all identical binary garbage odbc_free_result($columninfo); $columninfo = odbc_columns($odbc, '', '', 'grid', '%'); odbc_result_all($columninfo); ?> Expected result: ---------------- It should report information about the 4 columns in the table, as described in odbc_columns() documentation. It should do this in 2 ways: a series of print_r() outputs and a HTML table. Actual result: -------------- For the first part, the series of print_r() statements, the appropriate number of rows (one per column) is printed, but they are all blank. For the second, the HTML table, the appropriate number of rows (one per column) is printed, but all information is binary garbage. -- Edit bug report at http://bugs.php.net/bug.php?id=51311&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51311&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51311&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51311&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51311&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51311&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51311&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51311&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51311&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51311&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51311&r=support Expected behavior: http://bugs.php.net/fix.php?id=51311&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51311&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51311&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51311&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51311&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51311&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51311&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51311&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51311&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51311&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51311&r=mysqlcfg