Bug #51311 [Fbk->NoF]: odbc_columns() fetching binary garbage with unixODBC on 64-bit platform
| From: | php-bugs at lists dot php dot net | Date: | Sun, 18 Oct 2020 04:22:08 +0000 |
| Subject: | Bug #51311 [Fbk->NoF]: odbc_columns() fetching binary garbage with unixODBC on 64-bit platform | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229703@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51311&edit=1
ID: 51311
Updated by: php-bugs@lists.php.net
Reported by: gregor at hostgis dot com
Summary: odbc_columns() fetching binary garbage with unixODBC
on 64-bit platform
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: ODBC related
Operating System: Linux, Slamd64 11.0
PHP Version: 5.2.13
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-10-06 16:11:17] cmb@php.net
Can you still reproduce this issue with any of the actively
supported PHP versions[1]?
[1] <https://www.php.net/supported-versions.php>
------------------------------------------------------------------------
[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