ID:               42414
 User updated by:  jhml at gmx dot net
 Reported By:      jhml at gmx dot net
 Status:           Open
 Bug Type:         ODBC related
 Operating System: Linux
 PHP Version:      5.2.3
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2007-08-25 11:08:41] jhml at gmx dot net

Argh. Same problem with odbc_primarykeys(). Will examine the other 
functions also and create a new patch...

------------------------------------------------------------------------

[2007-08-24 16:27:08] jhml at gmx dot net

Tested with MyODBC as well, no problems!

------------------------------------------------------------------------

[2007-08-24 13:38:16] 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 13:15:14] [EMAIL PROTECTED]

Are you sure it doesn't break the other possible drivers..?

------------------------------------------------------------------------

[2007-08-24 13:13:42] 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,

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42414

-- 
Edit this bug report at http://bugs.php.net/?id=42414&edit=1

Reply via email to