Bug #48122 [Fbk]: odbc_cursor() returns empty name
| From: | kalle@php.net | Date: | Sat, 20 Aug 2011 18:05:11 +0000 |
| Subject: | Bug #48122 [Fbk]: odbc_cursor() returns empty name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162726@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48122&edit=1
ID: 48122
Updated by: kalle@php.net
Reported by: theodoreb at goshen dot edu
Summary: odbc_cursor() returns empty name
Status: Feedback
Type: Bug
Package: ODBC related
Operating System: Gentoo Linux
PHP Version: 5.2.9
Assigned To: kalle
Block user comment: N
Private report: N
New Comment:
Does this apply to 5.3 too?
Previous Comments:
------------------------------------------------------------------------
[2011-05-05 17:37:43] theodoreb at goshen dot edu
patch failed to apply with the following error:
patching file php_odbc.c
Hunk #1 FAILED at 1470.
Hunk #2 succeeded at 1205 (offset -274 lines).
1 out of 2 hunks FAILED -- saving rejects to file php_odbc.c.rej
and from the php_odbc.c.rej file:
***************
*** 1470,1477 ****
if (max_len > 0) {
cursorname = emalloc(max_len + 1);
rc = SQLGetCursorName(result->stmt,cursorname,(SQLSMALLINT)max_len,&len);
- if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- char state[6]; /* Not used */
SQLINTEGER error; /* Not used */
char errormsg[SQL_MAX_MESSAGE_LENGTH];
SQLSMALLINT errormsgsize; /* Not used */
--- 1470,1477 ----
if (max_len > 0) {
cursorname = emalloc(max_len + 1);
rc = SQLGetCursorName(result->stmt,cursorname,(SQLSMALLINT)max_len,&len);
+ if ((rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) || !cursorname) {
+ char state[6];
SQLINTEGER error; /* Not used */
char errormsg[SQL_MAX_MESSAGE_LENGTH];
SQLSMALLINT errormsgsize; /* Not used */
------------------------------------------------------------------------
[2011-01-17 16:50:34] kalle@php.net
Could you try the attached patch?
According to the ODBC specification available at MSDN, then its possible for the SQLGetCursorName
function to point to a NULL name where the length and return codes still are correct, so if thats
the case it would fallback to the PHP cursor name which hopefully is the cause of this as I'm
unable to reproduce it
------------------------------------------------------------------------
[2011-01-17 16:48:41] kalle@php.net
The following patch has been added/updated:
Patch Name: odbc-bug-48122
Revision: 1295279320
URL: http://bugs.php.net/patch-display.php?bug=48122&patch=odbc-bug-48122&revision=1295279320
------------------------------------------------------------------------
[2009-05-06 22:13:31] theodoreb at goshen dot edu
Thanks for responding.
I tried your code as follow:
error_reporting(E_ALL);
$conn = odbc_connect("mssql", "login", "passwd",SQL_CUR_USE_ODBC);
var_dump($conn, odbc_errormsg($conn));
$query = "SELECT * FROM tablename";
$cur = odbc_exec($conn,$query);
var_dump(odbc_errormsg($conn));
echo odbc_cursor($cur);
var_dump(odbc_errormsg($conn));
Here is the result:
resource(16) of type (odbc link) string(0) "" string(0) "" string(0)
""
------------------------------------------------------------------------
[2009-05-06 21:37:31] jani@php.net
Try this:
<?php
error_reporting(E_ALL);
$conn = odbc_connect("mssql", "login", "passwd",SQL_CUR_USE_ODBC);
var_dump($conn, odbc_errormsg($conn));
$query = "SELECT * FROM tablename";
$cur = odbc_exec($conn,$query);
var_dump(odbc_errormsg($conn));
echo odbc_cursor($cur);
var_dump(odbc_errormsg($conn));
?>
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=48122
--
Edit this bug report at https://bugs.php.net/bug.php?id=48122&edit=1