~MXStatement() { if (initialized_) { SQL_EXEC_ClearDiagnostics(NULL); SQL_EXEC_DeallocDesc(&outDesc_); SQL_EXEC_DeallocDesc(&inDesc_); SQL_EXEC_DeallocDesc(&stmtTextDesc_); SQL_EXEC_DeallocStmt(&stmtId_); } delete [] stmtText_; }
// returns -1, if a transaction is active; 0, otherwise. // Optionally returns the transaction identifier, if transid is passed in. short SqlciEnv::statusTransaction(Int64 * transid) { // if a transaction is active, get the transid by calling the CLI procedure. SQLDESC_ID transid_desc; // added for multi charset module names SQLMODULE_ID module; init_SQLCLI_OBJ_ID(&transid_desc); init_SQLMODULE_ID(&module); module.module_name = 0; transid_desc.module = &module; transid_desc.name_mode = desc_handle; HandleCLIErrorInit(); Lng32 rc = SQL_EXEC_AllocDesc(&transid_desc, 1); HandleCLIError(rc, this); Int64 transid_; rc = SQL_EXEC_SetDescItem(&transid_desc, 1, SQLDESC_VAR_PTR, (Long)&transid_, 0); if (rc) SQL_EXEC_DeallocDesc(&transid_desc); HandleCLIError(rc, this); rc = SQL_EXEC_Xact(SQLTRANS_STATUS, &transid_desc); if (rc == 0) { if (transid) *transid = transid_; // return transID if arg was passed in. rc = -1; // transaction is active. } else rc = 0; SQL_EXEC_DeallocDesc(&transid_desc); return (short)rc; }
// LCOV_EXCL_START Lng32 init(const char *&status) { Lng32 result = 0; status = "OK"; if (initialized_) return result; stmtText_ = NULL; if (result == 0) { result = SQL_EXEC_ClearDiagnostics(NULL); if (result != 0) { status = "SQL_EXEC_ClearDiagnostics failed"; } } if (result == 0) { result = SQL_EXEC_AllocStmt(&stmtId_, 0); if (result != 0) { status = "SQL_EXEC_AllocStmt failed"; } } if (result == 0) { result = SQL_EXEC_AllocDesc(&stmtTextDesc_, 1); if (result != 0) { status = "SQL_EXEC_AllocDesc failed for statement text"; SQL_EXEC_DeallocStmt(&stmtId_); } } if (result == 0) { result = SQL_EXEC_AllocDesc(&inDesc_, MAX_COLUMNS_IN_DESC); SQL_ERROR_HANDLER(result); if (result != 0) { status = "SQL_EXEC_AllocDesc failed for input descriptor"; SQL_EXEC_DeallocDesc(&stmtTextDesc_); SQL_EXEC_DeallocStmt(&stmtId_); } } if (result == 0) { result = SQL_EXEC_AllocDesc(&outDesc_, MAX_COLUMNS_IN_DESC); SQL_ERROR_HANDLER(result); if (result != 0) { status = "SQL_EXEC_AllocDesc failed for output descriptor"; SQL_EXEC_DeallocDesc(&inDesc_); SQL_EXEC_DeallocDesc(&stmtTextDesc_); SQL_EXEC_DeallocStmt(&stmtId_); } } if (result == 0) initialized_ = true; SQL_ERROR_HANDLER(result); return result; }