zabbix-agent2/src/libs/zbxdb/db.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_db_rollback                                                  *
 *                                                                            *
 * Purpose: rollback transaction                                              *
 *                                                                            *
 * Comments: do nothing if DB does not support transactions                   *
 *                                                                            *
 ******************************************************************************/
zbx_db_rollback

Purpose: rollback transaction

Comments: do nothing if DB does not support transactions
zbx_db_rollback Purpose : rollback transaction Comments : do nothing if DB does not support transactions
int	zbx_db_rollback(void)
{
	int	rc = ZBX_DB_OK, last_txn_error;
#ifdef HAVE_ORACLE
	sword	err;
#endif
	if (0 == txn_level)
	{
		zabbix_log(LOG_LEVEL_CRIT, "ERROR: rollback without transaction."
				" Please report it to Zabbix Team.");
		assert(0);
	}
	last_txn_error = txn_error;
	txn_error = ZBX_DB_OK;
#if defined(HAVE_MYSQL) || defined(HAVE_POSTGRESQL)
	rc = zbx_db_execute("rollback;");
#elif defined(HAVE_ORACLE)
	if (OCI_SUCCESS != (err = OCITransRollback(oracle.svchp, oracle.errhp, OCI_DEFAULT)))
		rc = OCI_handle_sql_error(ERR_Z3005, err, "rollback failed");
#elif defined(HAVE_SQLITE3)
	rc = zbx_db_execute("rollback;");
	zbx_mutex_unlock(sqlite_access);
#endif
	txn_level = 0;
	txn_error = ZBX_DB_OK;
	if (ZBX_DB_FAIL == rc)
		txn_end_error = ZBX_DB_FAIL;
	else
		txn_end_error = last_txn_error;	
	return rc;
}
int zbx_db_rollback ( void ) { int rc = ZBX_DB_OK , last_txn_error ; #ifdef HAVE_ORACLE sword err ; #endif if ( 0 == txn_level ) { zabbix_log ( LOG_LEVEL_CRIT , " " " " ) ; assert ( 0 ) ; } last_txn_error = txn_error ; txn_error = ZBX_DB_OK ; #if defined ( HAVE_MYSQL ) || defined ( HAVE_POSTGRESQL ) rc = zbx_db_execute ( " " ) ; #elif defined ( HAVE_ORACLE ) if ( OCI_SUCCESS != ( err = OCITransRollback ( oracle . svchp , oracle . errhp , OCI_DEFAULT ) ) ) rc = OCI_handle_sql_error ( ERR_Z3005 , err , " " ) ; #elif defined ( HAVE_SQLITE3 ) rc = zbx_db_execute ( " " ) ; zbx_mutex_unlock ( sqlite_access ) ; #endif txn_level = 0 ; txn_error = ZBX_DB_OK ; if ( ZBX_DB_FAIL == rc ) txn_end_error = ZBX_DB_FAIL ; else txn_end_error = last_txn_error ; return rc ; }
Function: zbx_db_rollback                                                  
                                                                            
 Purpose: rollback transaction                                              
                                                                            
 Comments: do nothing if DB does not support transactions
Function : zbx_db_rollback Purpose : rollback transaction Comments : do nothing if DB does not support transactions
/* allow rollback of failed transaction */ /* There is no way to recover from rollback errors, so there is no need to preserve transaction level / error. */ /* error that caused rollback */