php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34852 [PATCH] Failure in odbc_exec() using oracle-supplied odbc driver
Submitted: 2005-10-13 12:14 UTC Modified: 2009-12-06 18:53 UTC
Votes:29
Avg. Score:4.8 ± 0.5
Reproduced:29 of 29 (100.0%)
Same Version:6 (20.7%)
Same OS:19 (65.5%)
From: tim dot tassonis at trivadis dot com Assigned: felipe (profile)
Status: Closed Package: ODBC related
PHP Version: 5CVS-2005-11-03 (cvs) OS: Linux
Private report: No CVE-ID: None
 [2005-10-13 12:14 UTC] tim dot tassonis at trivadis dot com
Description:
------------
When using the oracle-supplied ODBC Driver under Linux, any odbc_exec() call fails with:
[unixODBC][Driver Manager]Driver does not support this function

The log files is a bit more verbose:
[unixODBC][Driver Manager]Driver does not support this function, SQL state IM001 in  SQLSetStmtOption

The offending code is in odbc_prepare(line 875) and odbc_exec (line 1276), when the module tries to set SQL_CURSOR_DYNAMIC via SQLSetStmtOption, which returns an error using the oracle driver.
The error goes away if I undefine HAVE_SQL_EXTENDED_FETCH, so the statements will not be reached.
Would it be possible to only issue a notice when this command fails and proceed with processing.
I can provide a patch to fix it, if that's appreciated.


Reproduce code:
---------------
$dsn="ANY_ORACLE_DSN";
$uid="ANY_VALID_USERID";
$pwd="ANY_VALID_PASSWORD";
$conn = odbc_connect ( $dsn, $uid, $pwd );
/* The connect succeeds */
if (!$conn) {
  printf("Error connecting to $database.<br>\n");
  return;
}
/* The exec will fail with the decribed error */
$cursor    = odbc_exec($conn,"SELECT tname from tab");
if (!$cursor) {
  printf("Failure in odbc_exe:<br>\n");
  printf("%s<br>\n",htmlentities(odbc_errormsg($conn)));
  return;
}


Actual result:
--------------
[unixODBC][Driver Manager]Driver does not support this function, SQL state IM001 in  SQLSetStmtOption


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-13 13:34 UTC] tim dot tassonis at trivadis dot com
Well, here is a patch. I dont know whether the formatting is preserved her properly, it should apply cleanly with "patch -p1 < patchfile" from whithing the php-5.0.5 directory.

The patch just stops odbc_exec and odbc_prepare from failing if the SQLSetStmtOption fails. The warning is still displayed in the error_log. It would be great if this could be applied.

So below follows the patch (created with diff -ruN):

diff -ruN php-5.0.5/ext/odbc/php_odbc.c php-5.0.5-ora/ext/odbc/php_odbc.c
--- php-5.0.5/ext/odbc/php_odbc.c	2005-07-03 00:50:01.000000000 +0200
+++ php-5.0.5-ora/ext/odbc/php_odbc.c	2005-10-13 12:20:55.000000000 +0200
@@ -875,9 +875,11 @@
 			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
 				== SQL_ERROR) {
 				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
+				/* Dont fail, but go on. This can happen 
 				SQLFreeStmt(result->stmt, SQL_DROP);
 				efree(result);
 				RETURN_FALSE;
+				*/
 			}
 		}
 	} else {
@@ -1296,9 +1298,11 @@
 			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
 				== SQL_ERROR) {
 				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
+				/* Dont fail, but go on. This can happen
 				SQLFreeStmt(result->stmt, SQL_DROP);
 				efree(result);
 				RETURN_FALSE;
+				*/
 			}
 		}
 	} else {
 [2005-11-04 01:49 UTC] wez@php.net
Tony: Check with Dan Scott before applying this patch; he's probably most current on this aspect of the odbc extension.

 [2005-11-30 21:09 UTC] sniper@php.net
Unfortunately Dan can not be involved in this. (some license thing)
 [2005-12-12 10:31 UTC] sniper@php.net
Can you repeat this error when using the PDO odbc ??
 [2005-12-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-03-31 06:56 UTC] adrian dot chadd at uwa dot edu dot au
We're having the same problem:

matrix:~# php5 -v
PHP 5.1.2-1 (cli) (built: Jan 18 2006 06:49:47)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

matrix:~# cat adri.php5 
<?php
$connect = odbc_connect(auth and db stuff goes here); 

$result = @odbc_data_source($connect, SQL_FETCH_FIRST);

while ($result) {
        print "result:\n";
        print_r($result); print "\n";
        $result = @odbc_data_source($connect, SQL_FETCH_NEXT);
}

$res = odbc_prepare($connect, "SELECT * FROM FOO");

odbc_close($connect);
?>

matrix:~# php5 adri.php5 
result:
Array
(
    [server] => HISDEV
    [description] => OracleODBC-10g
)


Warning: odbc_prepare(): SQL error: [unixODBC][Driver Manager]Driver does not support this function, SQL state IM001 in  SQLSetStmtOption in /root/adri.php5 on line 12

matrix:~# dpkg -l | grep odbc
rc  odbcinst1      2.2.4-11       Support library and helper program for acces
ii  odbcinst1debia 2.2.11-10      Support library and helper program for acces
ii  php5-odbc      5.1.2-1        ODBC module for php5
ii  unixodbc       2.2.11-10      ODBC tools libraries

Can someone shed some light on this? What can/should I try?



adrian
 [2006-05-17 11:03 UTC] david dot fuhr at web dot de
same problem with orcale XE-client supplied with the free oracle XE database...

$ php -v
PHP 4.4.2-0.dotdeb.1 (cli) (built: Jan 13 2006 16:48:04)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
$ uname -a
Linux pinocchio 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686 GNU/Linux
$ dpkg -l|grep odbc
ii  odbcinst1      2.2.4-11       Support library and helper program for acces
ii  php4-odbc      4.4.2-0.dotdeb ODBC module for php4
ii  unixodbc       2.2.4-11       ODBC tools libraries
 [2006-07-10 19:19 UTC] cwthomas at llu dot edu
Hello,
I have the same problem, but it might not be an issue with the Oracle supplied ODBC driver because I used isql (the unixODBC client) to connect to my oracle databases and it works great.

I'm running RHEL 4 Update 3 with php-4.3.9-3.12, php-odbc-4.3.9-3.12, unixODBC-2.2.11-1.RHEL4.1, and the Oracle Database 10g Client Release 2 10.2.0.1.0 (not the instant client).

It would be cool when this bug gets fixed to back port it so it will be included in the next EL update.
 [2007-02-08 22:08 UTC] rpowell at opriver dot com
Just wanted to say thinks for posting this patch.  The EasySoft version which worked out of the box cost over $1,500.  I just couldn't justify that expense when recompiling with this patch made the Oracle driver work.
 [2007-05-17 22:26 UTC] temerson at cyberitas dot com
RHEL 4 (up 2 date..)
PHP 4.3 (RHEL distro supplied)
error:
odbc_prepare(): SQL error: [unixODBC][Driver Manager]Driver does not support this function, SQL state IM001 in SQLSetStmtOption
 [2008-08-13 11:01 UTC] a dot zagli at comune dot scandicci dot fi dot it
i have the same problem with php 4.4.9 oracle client >= 10.1 (i didn't try with versions < 10.1)

i saw on msdn[1] that the function SQLSetStmtOption is deprecated starting from odbc 3.x in favor of SQLSetStmtAttr; it could be the problem.

furthermore, the same pieces of code are present also in php 5.2, but i can't try to see if the error persists :-(

[1]http://msdn.microsoft.com/en-us/library/ms713876(VS.85).aspx
 [2009-07-01 14:19 UTC] sebdeca at hotmail dot com
I have the same issue on that case:
php-4.4.9
RedHat RHEL 4 x86
php-odbc-4.3.9-3.22.12
unixodbc 2.2.11
oracle instant client 10.2.0.3

Has someone found a workaround for this?
 [2009-08-10 13:45 UTC] hendrik dot schmieder at jedox dot com
Still open with 5.2.10.

Debian 4

Oracle ODBC driver 10.2.0.3
 [2009-08-11 14:49 UTC] hendrik dot schmieder at jedox dot com
After compiling php against unixodbc 2.2.14 it works with Oracle ODBC driver 10.2.0.3 .

Even 11.1.0.7 works now.


Thanks go to 
<http://blog.computer-tipps.info/2008/05/>

(Sorry it is in German).
 [2009-12-06 18:53 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=291772
Log: - Fixed bug #50162 (Memory leak when fetching timestamp column from Oracle database)
- Fixed bug #34852 (Failure in odbc_exec() using oracle-supplied odbc driver) (patch by tim dot tassonis at trivadis dot com)
 [2009-12-06 18:53 UTC] felipe@php.net
This bug has been fixed in SVN.

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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC