/* print error and exit with failure */ void do_error_exit(sqlo_db_handle_t dbh, const char * file, int line, const char * msg) { printf("%s (line: %d):\n%s: %s\n", file, line, msg, sqlo_geterror(dbh)); sqlo_rollback(dbh); sqlo_finish(dbh); exit(EXIT_FAILURE); }
int close_db(struct libdb *dbp) { int dbType = dbp->db_type; int result = 0; switch (dbType) { case DB_ORACLE: { if (is_open(dbp)) { int ret; ret = sqlo_finish(dbp->db_orap->ora_dbhp); if (SQLO_SUCCESS != ret) { result = 0; set_error_d(dbp, "shutdown oracle database is failure."); break; } free(dbp->db_orap); dbp->db_orap = NULL; result = 1; } } break; case DB_MYSQL: { if (is_open(dbp)) { mysql_close(dbp->db_sqlp->mys_sqlp); free(dbp->db_sqlp); dbp->db_sqlp = NULL; result = 1; } } break; default: { result = 0; set_error_d(dbp, "the database type is not supported"); } break; } return result; }
void zbx_db_close(void) { #ifdef HAVE_MYSQL mysql_close(conn); conn = NULL; #endif #ifdef HAVE_POSTGRESQL PQfinish(conn); conn = NULL; #endif #ifdef HAVE_ORACLE if (SQLO_SUCCESS != sqlo_finish(oracle)) zabbix_errlog(ERR_Z3004, 0, "sqlo_finish"); #endif #ifdef HAVE_SQLITE3 sqlite_transaction_started = 0; sqlite3_close(conn); conn = NULL; /* php_sem_remove(&sqlite_access);*/ #endif }