RETCODE SQL_API SQLAllocStmt(HDBC ConnectionHandle, HSTMT *StatementHandle) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; mylog("[SQLAllocStmt]"); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_AllocStmt(ConnectionHandle, StatementHandle); LEAVE_CONN_CS(conn); return ret; }
RETCODE SQL_API SQLAllocStmt(HDBC ConnectionHandle, HSTMT *StatementHandle) { RETCODE ret; ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; mylog("[SQLAllocStmt]"); CC_examine_global_transaction(conn); ENTER_CONN_CS(conn); CC_clear_error(conn); ret = PGAPI_AllocStmt(ConnectionHandle, StatementHandle, PODBC_EXTERNAL_STATEMENT | PODBC_INHERIT_CONNECT_OPTIONS); LEAVE_CONN_CS(conn); return ret; }
/* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */ RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE * OutputHandle) { CSTR func = "SQLAllocHandle"; RETCODE ret; ConnectionClass *conn; mylog("[[%s]]", func); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_AllocEnv(OutputHandle); break; case SQL_HANDLE_DBC: ENTER_ENV_CS((EnvironmentClass *) InputHandle); ret = PGAPI_AllocConnect(InputHandle, OutputHandle); LEAVE_ENV_CS((EnvironmentClass *) InputHandle); break; case SQL_HANDLE_STMT: ENTER_CONN_CS((ConnectionClass *) InputHandle); ret = PGAPI_AllocStmt(InputHandle, OutputHandle); LEAVE_CONN_CS((ConnectionClass *) InputHandle); break; case SQL_HANDLE_DESC: conn = (ConnectionClass *) InputHandle; ENTER_CONN_CS(conn); ret = PGAPI_AllocDesc(InputHandle, OutputHandle); LEAVE_CONN_CS(conn); inolog("OutputHandle=%p\n", *OutputHandle); break; default: ret = SQL_ERROR; break; } return ret; }
static char * CC_lookup_cs_old(ConnectionClass *self) { char *encstr = NULL; HSTMT hstmt; RETCODE result; result = PGAPI_AllocStmt(self, &hstmt); if (!SQL_SUCCEEDED(result)) return encstr; result = PGAPI_ExecDirect(hstmt, "Show Client_Encoding", SQL_NTS, 0); if (result == SQL_SUCCESS_WITH_INFO) { char sqlState[8], errormsg[128], enc[32]; if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, errormsg, sizeof(errormsg), NULL) == SQL_SUCCESS && sscanf(errormsg, "%*s %*s %*s %*s %*s %s", enc) > 0) encstr = strdup(enc); } PGAPI_FreeStmt(hstmt, SQL_DROP); return encstr; }