php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13628 error handling for odbc_execute()
Submitted: 2001-10-10 10:42 UTC Modified: 2001-12-07 12:22 UTC
From: cawa at csa dot ru Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.6 OS:
Private report: No CVE-ID: None
 [2001-10-10 10:42 UTC] cawa at csa dot ru
After odbc_execute() call odbc_error doesn't return SQLSTATE (returns last occured SQLSTATE).

The cause is that SQL_ERROR return code of SQLExecute() is not processed.

Please change php_odbc.c near
-------------------------
/*
 * Execute prepared SQL statement. Supports only input parameters.
 */
/* {{{ proto int odbc_execute(int result_id [, array parameters_array])
   Execute a prepared statement */
PHP_FUNCTION(odbc_execute)
-------------------------



-------------------------
	rc = SQLExecute(result->stmt);

	result->fetched = 0;
	if (rc == SQL_NEED_DATA) {
		char buf[4096];
		int fp, nbytes;
		while(rc == SQL_NEED_DATA) {
			rc = SQLParamData(result->stmt, (void*)&fp);
			if (rc == SQL_NEED_DATA) {
				while((nbytes = read(fp, &buf, 4096)) > 0)
					SQLPutData(result->stmt, (void*)&buf, nbytes);
			}
		}
	} else {
        switch (rc) {
        case SQL_SUCCESS:
            break;
        case SQL_NO_DATA_FOUND:
        case SQL_SUCCESS_WITH_INFO:
            odbc_sql_error(result->conn_ptr, result->stmt, "SQLExecute");
            break;
        default:
            RETVAL_FALSE;
        }
	}	
-------------------------

==========>

-------------------------
	rc = SQLExecute(result->stmt);

	result->fetched = 0;
	if (rc == SQL_NEED_DATA) {
		char buf[4096];
		int fp, nbytes;
		while(rc == SQL_NEED_DATA) {
			rc = SQLParamData(result->stmt, (void*)&fp);
			if (rc == SQL_NEED_DATA) {
				while((nbytes = read(fp, &buf, 4096)) > 0)
					SQLPutData(result->stmt, (void*)&buf, nbytes);
			}
		}
	} else {
        switch (rc) {
        case SQL_SUCCESS:
            break;
        case SQL_NO_DATA_FOUND:
        case SQL_SUCCESS_WITH_INFO:
            odbc_sql_error(result->conn_ptr, result->stmt, "SQLExecute");
            break;
        default:
            odbc_sql_error(result->conn_ptr, result->stmt, "SQLExecute");
            RETVAL_FALSE;
        }
	}	
-------------------------

With best regards,
   Alexander Veremyev.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-07 12:22 UTC] kalowsky@php.net
Fixed in CVS.  Thanks for your report!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC