From d3fb16b38049d61ad5bb5271e43420421dd10d91 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 17 Jan 2020 12:22:11 +0100 Subject: also cover drop/restart cases with psql logic --- src/auditordb/plugin_auditordb_postgres.c | 61 +++---------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) (limited to 'src/auditordb/plugin_auditordb_postgres.c') diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 52488fd2c..0d552ff12 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -113,69 +113,20 @@ postgres_drop_tables (void *cls, int drop_exchangelist) { struct PostgresClosure *pc = cls; - struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_execute ("DELETE FROM auditor_predicted_result;"), - GNUNET_PQ_make_execute ( - "DELETE FROM auditor_historic_denomination_revenue;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_balance_summary;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_denomination_pending;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_reserve_balance;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_wire_fee_balance;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_reserves;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_progress_reserve;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_progress_aggregation;"), - GNUNET_PQ_make_execute ( - "DELETE FROM auditor_progress_deposit_confirmation;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_progress_coin;"), - GNUNET_PQ_make_execute ("DELETE FROM wire_auditor_progress;"), - GNUNET_PQ_make_execute ("DELETE FROM wire_auditor_account_progress;"), - GNUNET_PQ_make_execute ("DELETE FROM auditor_historic_reserve_summary;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; - struct GNUNET_PQ_ExecuteStatement esx[] = { - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_predicted_result;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_balance_summary;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_denomination_pending;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserve_balance;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_wire_fee_balance;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserves;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_reserve;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_progress_aggregation;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_coin;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_progress;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS wire_auditor_account_progress;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_historic_reserve_summary CASCADE;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS auditor_denominations CASCADE;"), - GNUNET_PQ_make_execute ( - "DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_exchanges CASCADE;"), - GNUNET_PQ_make_execute ("DROP SCHEMA IF EXISTS _v CASCADE;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; struct GNUNET_PQ_Context *conn; - int ret; + char *exec_dir; + GNUNET_asprintf (&exec_dir, + (drop_exchangelist) ? "%sdrop" : "%srestart", + pc->sql_dir); conn = GNUNET_PQ_connect (pc->connection_cfg_str, + exec_dir, NULL, - es, NULL); if (NULL == conn) return GNUNET_SYSERR; - ret = GNUNET_OK; - if (drop_exchangelist) - ret = GNUNET_PQ_exec_statements (conn, - esx); GNUNET_PQ_disconnect (conn); - return ret; + return GNUNET_OK; } -- cgit v1.2.3