php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42414 some odbc_*() functions incompatible with Oracle ODBC driver
Submitted: 2007-08-24 13:11 UTC Modified: 2012-02-28 17:53 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jhml at gmx dot net Assigned: sixd
Status: Closed Package: ODBC related
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID:
 [2007-08-24 13:11 UTC] jhml at gmx dot net
Description:
------------
The Oracle ODBC driver expects NULL as the second parameter to the 
SQLColumns() C function, otherwise, it will throw an error. With PHP 
5.2.3 it's not possibly to specify NULL, though.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-24 13:13 UTC] jhml at gmx dot net
Proposed patch:

--- php-5.2.3/ext/odbc/php_odbc.c       2007-03-13 
01:04:38.000000000 +0100
+++ php-5.2.3-fix_odbc_columns/ext/odbc/php_odbc.c      2007-08-24 
14:57:41.000000000 +0200
@@ -2947,6 +2947,11 @@
         */
        if (table && strlen(table) && schema && !strlen(schema)) 
schema = NULL;

+        /*
+         * Needed to make Oracle happy (Johann Hanne)
+         */
+       if (cat && !strlen(cat)) cat = NULL;
+
        rc = SQLColumns(result->stmt,
                        cat, cat_len,
                        schema, schema_len,
 [2007-08-24 13:15 UTC] jani@php.net
Are you sure it doesn't break the other possible drivers..?
 [2007-08-24 13:38 UTC] jhml at gmx dot net
I've tested IBM DB2 (iSeries ODBC driver from IBM), MS SQL 
(FreeTDS), Sybase (FreeTDS) and Oracle (native ODBC driver from 
Oracle). Moreover, NULL is also already passed when odbc_columns() 
is called with only one parameter.

The patch may appear ugly but it's the same style as the Access 
workaround. IMHO it would be cleaner to allow passing a PHP-null to 
actually become a C-NULL, i.e. not forcing the String cast for null 
values, but that would be much more intrusive!
 [2007-08-24 16:27 UTC] jhml at gmx dot net
Tested with MyODBC as well, no problems!
 [2007-08-25 11:08 UTC] jhml at gmx dot net
Argh. Same problem with odbc_primarykeys(). Will examine the other 
functions also and create a new patch...
 [2007-08-28 09:12 UTC] jhml at gmx dot net
I have examined all functions which take the cat argument now, which 
are:
- odbc_tables
- odbc_columns
- odbc_columnprivileges
- odbc_foreignkeys
- odbc_primarykeys
- odbc_procedurecolumns
- odbc_procedures
- odbc_specialcolumns
- odbc_statistics
- odbc_tableprivileges

Most of these functions need to have cat == NULL (as long as one 
doesn't want to specify a catalog) with the Oracle ODBC driver. 
Interestingly, the follow functions don't have this requirement:
- odbc_tables
- odbc_procedurecolumns
- odbc_procedures

So I have created a patch now which sets cat to NULL for the 
functions which require it. The patch is available at 
http://www.bettina-attack.de/jonny/php-5.2.3-oracle_compat.diff
 [2009-05-14 01:32 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for the patch.
 [2009-05-14 17:31 UTC] felipe@php.net
I've committed a better fix, now it's allowed to pass NULL.
 [2012-02-28 17:53 UTC] sixd@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: sixd
 [2012-02-28 17:53 UTC] sixd@php.net
Closing based on Felipe's comment that he committed a fix.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 10:02:10 2014 UTC