Cosmetic changes.

This commit is contained in:
Andreas Karajannis 2000-05-28 12:48:12 +00:00
parent 44cf237a72
commit e50b33c240
2 changed files with 53 additions and 56 deletions

View file

@ -455,11 +455,7 @@ PHP_MINFO_FUNCTION(odbc)
}
#if defined ( HAVE_IBMDB2 ) || defined ( HAVE_UNIXODBC )
void ODBC_SQL_ERROR(SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func)
#else
void ODBC_SQL_ERROR(HENV henv, HDBC conn, HSTMT stmt, char *func)
#endif
void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
{
char state[6];
SDWORD error; /* Not used */
@ -488,7 +484,7 @@ void ODBC_SQL_ERROR(HENV henv, HDBC conn, HSTMT stmt, char *func)
*/
}
void php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
odbc_result *result;
pval **pv_res, **pv_flag;
@ -591,7 +587,7 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
rc = SQLTransact(conn->henv, conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
RETURN_FALSE;
}
@ -687,7 +683,7 @@ PHP_FUNCTION(odbc_close_all)
Handle binary column data */
PHP_FUNCTION(odbc_binmode)
{
php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
@ -695,7 +691,7 @@ PHP_FUNCTION(odbc_binmode)
Handle LONG columns */
PHP_FUNCTION(odbc_longreadlen)
{
php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
@ -734,13 +730,13 @@ PHP_FUNCTION(odbc_prepare)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
SQLFreeStmt(result->stmt, SQL_DROP);
RETURN_FALSE;
}
@ -878,7 +874,7 @@ PHP_FUNCTION(odbc_execute)
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
}
rc = SQLExecute(result->stmt);
@ -896,7 +892,7 @@ PHP_FUNCTION(odbc_execute)
}
} else {
if (rc != SQL_SUCCESS) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute");
RETVAL_FALSE;
}
}
@ -972,7 +968,7 @@ PHP_FUNCTION(odbc_cursor)
if (!strncmp(state,"S1015",5)) {
sprintf(cursorname,"php_curs_%d", (int)result->stmt);
if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc,
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLSetCursorName");
RETVAL_FALSE;
} else {
@ -1036,7 +1032,7 @@ PHP_FUNCTION(odbc_exec)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -1052,7 +1048,7 @@ PHP_FUNCTION(odbc_exec)
*/
if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
== SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption");
odbc_sql_error(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@ -1068,7 +1064,7 @@ PHP_FUNCTION(odbc_exec)
/* XXX FIXME we should really check out SQLSTATE with SQLError
* in case rc is SQL_SUCCESS_WITH_INFO here.
*/
ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect");
odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
@ -1203,7 +1199,7 @@ PHP_FUNCTION(odbc_fetch_into)
buf, result->longreadlen + 1, &result->values[i].vallen);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(buf);
RETURN_FALSE;
}
@ -1423,7 +1419,7 @@ PHP_FUNCTION(odbc_result)
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@ -1466,7 +1462,7 @@ PHP_FUNCTION(odbc_result)
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
@ -1572,7 +1568,7 @@ PHP_FUNCTION(odbc_result_all)
php_printf("<td>");
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
php_printf("</td></tr></table>");
efree(buf);
RETURN_FALSE;
@ -1671,7 +1667,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
if (cur_opt != SQL_CUR_DEFAULT) {
rc = SQLSetConnectOption((*conn)->hdbc, SQL_ODBC_CURSORS, cur_opt);
if (rc != SQL_SUCCESS) { /* && rc != SQL_SUCCESS_WITH_INFO ? */
ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
SQLFreeConnect((*conn)->hdbc);
pefree(*conn, persistent);
return FALSE;
@ -1709,7 +1705,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
#endif
#endif
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect");
odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect");
SQLFreeConnect((*conn)->hdbc);
pefree((*conn), persistent);
return FALSE;
@ -2152,7 +2148,7 @@ PHP_FUNCTION(odbc_autocommit)
((*pv_onoff)->value.lval) ?
SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
RETURN_FALSE;
}
RETVAL_TRUE;
@ -2161,7 +2157,7 @@ PHP_FUNCTION(odbc_autocommit)
rc = SQLGetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status");
RETURN_FALSE;
}
RETVAL_LONG((long)status);
@ -2218,7 +2214,7 @@ PHP_FUNCTION(odbc_setoption)
}
rc = SQLSetConnectOption(conn->hdbc, (unsigned short)((*pv_opt)->value.lval), (*pv_val)->value.lval);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
RETURN_FALSE;
}
break;
@ -2228,7 +2224,7 @@ PHP_FUNCTION(odbc_setoption)
rc = SQLSetStmtOption(result->stmt, (unsigned short)((*pv_opt)->value.lval), ((*pv_val)->value.lval));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
RETURN_FALSE;
}
break;
@ -2294,7 +2290,7 @@ PHP_FUNCTION(odbc_tables)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2306,7 +2302,7 @@ PHP_FUNCTION(odbc_tables)
type, SAFE_SQL_NTS(type));
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables");
efree(result);
RETURN_FALSE;
}
@ -2376,7 +2372,7 @@ PHP_FUNCTION(odbc_columns)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2388,7 +2384,7 @@ PHP_FUNCTION(odbc_columns)
column, SAFE_SQL_NTS(column));
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns");
efree(result);
RETURN_FALSE;
}
@ -2455,7 +2451,7 @@ PHP_FUNCTION(odbc_columnprivileges)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2467,7 +2463,7 @@ PHP_FUNCTION(odbc_columnprivileges)
column, SAFE_SQL_NTS(column));
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges");
efree(result);
RETURN_FALSE;
}
@ -2553,7 +2549,7 @@ PHP_FUNCTION(odbc_foreignkeys)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2567,7 +2563,7 @@ PHP_FUNCTION(odbc_foreignkeys)
ftable, SAFE_SQL_NTS(ftable) );
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys");
efree(result);
RETURN_FALSE;
}
@ -2632,7 +2628,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2640,7 +2636,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
rc = SQLGetTypeInfo(result->stmt, data_type );
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo");
efree(result);
RETURN_FALSE;
}
@ -2704,7 +2700,7 @@ PHP_FUNCTION(odbc_primarykeys)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2715,7 +2711,7 @@ PHP_FUNCTION(odbc_primarykeys)
table, SAFE_SQL_NTS(table) );
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys");
efree(result);
RETURN_FALSE;
}
@ -2786,7 +2782,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2798,7 +2794,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
col, SAFE_SQL_NTS(col) );
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns");
efree(result);
RETURN_FALSE;
}
@ -2868,7 +2864,7 @@ PHP_FUNCTION(odbc_procedures)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2879,7 +2875,7 @@ PHP_FUNCTION(odbc_procedures)
proc, SAFE_SQL_NTS(proc) );
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures");
efree(result);
RETURN_FALSE;
}
@ -2954,7 +2950,7 @@ PHP_FUNCTION(odbc_specialcolumns)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -2968,7 +2964,7 @@ PHP_FUNCTION(odbc_specialcolumns)
nullable);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns");
efree(result);
RETURN_FALSE;
}
@ -3039,7 +3035,7 @@ PHP_FUNCTION(odbc_statistics)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -3052,7 +3048,7 @@ PHP_FUNCTION(odbc_statistics)
reserved);
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
efree(result);
RETURN_FALSE;
}
@ -3117,7 +3113,7 @@ PHP_FUNCTION(odbc_tableprivileges)
}
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
@ -3128,7 +3124,7 @@ PHP_FUNCTION(odbc_tableprivileges)
table, SAFE_SQL_NTS(table));
if (rc == SQL_ERROR) {
ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges");
odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges");
efree(result);
RETURN_FALSE;
}

View file

@ -269,15 +269,16 @@ void odbc_del_result(HashTable *list, int count);
int odbc_add_conn(HashTable *list, HDBC conn);
odbc_connection *odbc_get_conn(HashTable *list, int count);
void odbc_del_conn(HashTable *list, int ind);
#define ODBC_SQL_ERROR odbc_sql_error
#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC )
void odbc_sql_error(SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func);
#else
void odbc_sql_error(HENV henv, HDBC conn, HSTMT stmt, char *func);
#endif
int odbc_bindcols(odbc_result *result);
#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC )
#define ODBC_SQL_ERROR_PARAMS SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func
#else
#define ODBC_SQL_ERROR_PARAMS HENV henv, HDBC conn, HSTMT stmt, char *func
#endif
void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)