Hi,
I am attaching here a small patch for this bug. The original error for
the reproduction script in this bug was:
*Warning*: odbc_execute() [function.odbc-execute <http://10.1.2.195/function.odbc-execute>]: SQL error: [Microsoft][ODBC
Microsoft Access Driver]COUNT field incorrect , SQL state 07001 in SQLExecute in *C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\odbc2.php* on line *33
This is not the right error. since we did not check the return codes from
SQLDescribeParam php_odbc.php:1000
we did not see that the real error is:
**Warning*: odbc_execute() [function.odbc-execute <http://10.1.2.195/function.odbc-execute>]: SQL error: [Microsoft][ODBC
Driver Manager] Driver does not support this function, SQL state IM001 in hello - SQL_ERROR in *C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\odbc2.php* on line *33
Please review the patch
Alexandra Shpindovsky
--- php_odbc.c 2007-03-13 02:04:38.000000000 +0200
+++ php_odbc.c 2007-09-20 10:13:00.000000000 +0200
@@ -997,8 +997,21 @@
RETURN_FALSE;
}
- SQLDescribeParam(result->stmt, (UWORD)i, &sqltype,
&precision,
+ rc = SQLDescribeParam(result->stmt, (UWORD)i, &sqltype,
&precision,
&scale, &nullable);
+
+ if (rc == SQL_INVALID_HANDLE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"SQLDescribeParam error 'Invalid Handle'");
+ efree(result);
+ RETURN_FALSE;
+ }
+
+ if (rc == SQL_ERROR) {
+ odbc_sql_error(result->conn_ptr, result->stmt,
"SQLDescribeParam");
+ efree(result);
+ RETURN_FALSE;
+ }
+
params[i-1].vallen = Z_STRLEN_PP(tmp);
params[i-1].fp = -1;
@@ -1048,6 +1061,17 @@
ctype, sqltype, precision, scale,
(void
*)params[i-1].fp, 0,
¶ms[i-1].vallen);
+ if (rc == SQL_INVALID_HANDLE) {
+ php_error_docref(NULL TSRMLS_CC,
E_WARNING, "SQLBindParameter error 'Invalid Handle'");
+ efree(result);
+ RETURN_FALSE;
+ }
+
+ if (rc == SQL_ERROR) {
+ odbc_sql_error(result->conn_ptr,
result->stmt, "SQLBindParameter");
+ efree(result);
+ RETURN_FALSE;
+ }
} else {
#ifdef HAVE_DBMAKER
precision = params[i-1].vallen;
@@ -1060,6 +1084,18 @@
ctype, sqltype, precision, scale,
Z_STRVAL_PP(tmp), 0,
¶ms[i-1].vallen);
+
+ if (rc == SQL_INVALID_HANDLE) {
+ php_error_docref(NULL TSRMLS_CC,
E_WARNING, "SQLBindParameter error 'Invalid Handle'");
+ efree(result);
+ RETURN_FALSE;
+ }
+
+ if (rc == SQL_ERROR) {
+ odbc_sql_error(result->conn_ptr,
result->stmt, "SQLBindParameter");
+ efree(result);
+ RETURN_FALSE;
+ }
}
zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr));
}
/* }}} */
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php