|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69526 odbc_execute can't be executed twice on some drivers
Submitted: 2015-04-24 16:43 UTC Modified: 2016-02-24 12:50 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: einavitamar at gmail dot com Assigned: ab (profile)
Status: Closed Package: ODBC related
PHP Version: 5.6.8 OS: Windows
Private report: No CVE-ID: None
 [2015-04-24 16:43 UTC] einavitamar at gmail dot com
After odbc_prepare, when executing odbc_execute more than once, it fails starting the second time.
It happens only in drivers that does not allow SQLDescribeParam to be called on a statement after its execution.

By looking at the php odbc code, the reason is that SQLDescribeParam is called in odbc_execute instead of in odbc_prepare.

It should be called only once per bound parameter, and it does not depend on the parameter value itself, so it should be called in odbc_prepare.

This failure happens when using odbc both in TeraData and in Vertica.
This failure happens only if there is parameter binding (for statements without variables it does not happen).

The test script is for TeraData driver under windows.

Test script:
$conn = odbc_connect("driver={Teradata};DBCName=;PortNumber=1025;DATABASE=dbname;",'user', 'pwd');

$sql = "SELECT * FROM einav where a >= ?;";

$stmt = odbc_prepare($conn,$sql);

$params = array("abc");



Expected result:
Expected result:


Actual result:
PHP Warning:  odbc_execute(): SQL error: [Teradata][ODBC Teradata Driver] Functi
on Sequence Error, SQL state S1010 in SQLDescribeParameter in C:\Users\einav.000
\b.php on line 37
<h2>No rows found</h2>


odbc_diff.txt (last revision 2015-04-27 13:39 UTC by einavitamar at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-28 13:46 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: ab
 [2015-04-28 13:46 UTC]
Could you supply some test data please. Some driver bins probably, as well, if they aren't freely downloadable.

 [2015-05-04 10:31 UTC] einavitamar at gmail dot com
-Status: Feedback +Status: Assigned
 [2015-05-04 10:31 UTC] einavitamar at gmail dot com
I supplied a test script when I submitted the ticket.
The TeraData driver is freely downloadable from teradata web site

You can also download the server as a virtual machine:

For data that matches the test script, simply create a table called einav with one column called "a":

CREATE TABLE einav (a varchar);
 [2016-02-24 07:58 UTC]
Now, it looks like same issue in regard to bug #47803. I think your patch is reasonable. Testing this currently.

 [2016-02-24 11:13 UTC]
-Status: Assigned +Status: Closed
 [2016-02-24 11:13 UTC]
The patch was applied to 5.6+, please see also the linked ticket.

Thanks for your work, @einavitamar!

 [2016-02-24 12:50 UTC] einavitamar at gmail dot com
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 18:01:29 2024 UTC