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

 ID:                 51311
 Updated by:         fel...@php.net
 Reported by:        gregor at hostgis dot com
 Summary:            odbc_columns() fetching binary garbage with unixODBC
                     on 64-bit platform
-Status:             Open
+Status:             Assigned
 Type:               Bug
 Package:            ODBC related
 Operating System:   Linux, Slamd64 11.0
 PHP Version:        5.2.13
-Assigned To:        
+Assigned To:        felipe
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2010-03-17 01:13:18] gregor at hostgis dot com

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 this bug report at https://bugs.php.net/bug.php?id=51311&edit=1

Reply via email to