php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51311 odbc_columns() fetching binary garbage with unixODBC on 64-bit platform
Submitted: 2010-03-17 01:13 UTC Modified: 2017-10-24 07:08 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gregor at hostgis dot com Assigned:
Status: Open Package: ODBC related
PHP Version: 5.2.13 OS: Linux, Slamd64 11.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gregor at hostgis dot com
New email:
PHP Version: OS:

 

 [2010-03-17 01:13 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-16 00:37 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: felipe
 [2017-10-24 07:08 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: felipe +Assigned To:
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed May 27 16:01:25 2020 UTC