T_CCI_ERROR_CODE hm_get_statement (int mapped_id, T_CON_HANDLE ** connection, T_REQ_HANDLE ** statement) { int connection_id; int statement_id; T_CON_HANDLE *conn; T_CCI_ERROR_CODE error; if (connection != NULL) { *connection = NULL; } if (statement == NULL) { return CCI_ER_REQ_HANDLE; } *statement = NULL; error = map_get_ots_value (mapped_id, &statement_id, false); if (error != CCI_ER_NO_ERROR) { return error; } connection_id = GET_CON_ID (statement_id); statement_id = GET_REQ_ID (statement_id); if (connection_id < 1 || statement_id < 1) { return CCI_ER_REQ_HANDLE; } conn = con_handle_table[connection_id - 1]; if (conn == NULL) { return CCI_ER_REQ_HANDLE; } if (statement_id > conn->max_req_handle) { return CCI_ER_REQ_HANDLE; } *statement = conn->req_handle_table[statement_id - 1]; if (connection != NULL) { *connection = conn; } assert (*statement != NULL); return CCI_ER_NO_ERROR; }
T_CCI_ERROR_CODE map_get_ots_value (T_CCI_REQ mapped_stmt_id, T_CCI_REQ *statement_id, bool force) { T_CCI_ERROR_CODE error; if (statement_id == NULL) { return CCI_ER_REQ_HANDLE; } mutexStatement.lock (); IteratorMapStatement it = mapStatement.find (mapped_stmt_id); if (it == mapStatement.end ()) { error = CCI_ER_REQ_HANDLE; } else { *statement_id = it->second; error = CCI_ER_NO_ERROR; if (force == false) { T_CON_HANDLE *connection; T_CCI_CONN connection_id = GET_CON_ID (*statement_id); error = hm_get_connection_by_resolved_id (connection_id, &connection); if (error == CCI_ER_NO_ERROR) { if (connection->used) { error = CCI_ER_USED_CONNECTION; } else { connection->used = true; } } } } mutexStatement.unlock (); return error; }