diff options
Diffstat (limited to 'src/exchangedb')
| -rw-r--r-- | src/exchangedb/perf_taler_exchangedb_interpreter.c | 6 | ||||
| -rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 112 | ||||
| -rw-r--r-- | src/exchangedb/test_exchangedb.c | 24 | 
3 files changed, 67 insertions, 75 deletions
| diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 661cfeef..5a2eed95 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -1856,11 +1856,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,    }    /* Drop tables */    { -    struct TALER_EXCHANGEDB_Session *session; - -    session = plugin->get_session (plugin->cls); -    ret = plugin->drop_tables (plugin->cls, -                               session); +    ret = plugin->drop_tables (plugin->cls);      if (GNUNET_OK != ret)      {        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index cda2df0d..44096f17 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -128,55 +128,6 @@ struct PostgresClosure  }; - - -/** - * Drop all Taler tables.  This should only be used by testcases. - * - * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param session database session to use - * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure - */ -static int -postgres_drop_tables (void *cls, -                      struct TALER_EXCHANGEDB_Session *session) -{ -  GNUNET_log (GNUNET_ERROR_TYPE_INFO, -              "Dropping ALL tables\n"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS prewire;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS aggregation_tracking;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS deposits;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refresh_out;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refresh_commit_coin;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refresh_commit_link;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refunds;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refresh_order;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS refresh_sessions;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS known_coins;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS reserves_out;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS reserves_in;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS reserves;"); -  SQLEXEC_ (session->conn, -            "DROP TABLE IF EXISTS denominations;"); -  return GNUNET_OK; - SQLEXEC_fail: -  return GNUNET_SYSERR; -} - -  /**   * Function called by libpq whenever it wants to log something.   * We already log whenever we care, so this function does nothing @@ -212,6 +163,69 @@ pq_notice_processor_cb (void *arg,  /** + * Drop all Taler tables.  This should only be used by testcases. + * + * @param cls the `struct PostgresClosure` with the plugin-specific state + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure + */ +static int +postgres_drop_tables (void *cls) +{ +  struct PostgresClosure *pc = cls; +  PGconn *conn; + +  conn = PQconnectdb (pc->connection_cfg_str); +  if (CONNECTION_OK != +      PQstatus (conn)) +  { +    TALER_LOG_ERROR ("Database connection failed: %s\n", +                     PQerrorMessage (conn)); +    GNUNET_break (0); +    return GNUNET_SYSERR; +  } +  PQsetNoticeReceiver (conn, +                       &pq_notice_receiver_cb, +                       NULL); +  PQsetNoticeProcessor (conn, +                        &pq_notice_processor_cb, +                        NULL); +  GNUNET_log (GNUNET_ERROR_TYPE_INFO, +              "Dropping ALL tables\n"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS prewire;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS aggregation_tracking;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS deposits;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refresh_out;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refresh_commit_coin;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refresh_commit_link;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refunds;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refresh_order;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS refresh_sessions CASCADE;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS known_coins CASCADE;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS reserves_out;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS reserves_in;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS reserves;"); +  SQLEXEC_ (conn, +            "DROP TABLE IF EXISTS denominations CASCADE;"); +  return GNUNET_OK; + SQLEXEC_fail: +  return GNUNET_SYSERR; +} + + +/**   * Create the necessary tables if they are not present   *   * @param cls the `struct PostgresClosure` with the plugin-specific state diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 3169f06d..9b84d739 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -846,23 +846,7 @@ run (void *cls)      result = 77;      return;    } -  if (GNUNET_OK != -      plugin->create_tables (plugin->cls)) -  { -    result = 77; -    goto drop; -  } -  if (NULL != -      (session = plugin->get_session (plugin->cls))) -  { -    if (GNUNET_OK != -        plugin->drop_tables (plugin->cls, -                             session)) -    { -      result = 77; -      goto drop; -    } -  } +  (void) plugin->drop_tables (plugin->cls);    if (GNUNET_OK !=        plugin->create_tables (plugin->cls))    { @@ -1283,10 +1267,8 @@ run (void *cls)      plugin->free_reserve_history (plugin->cls,                                    rh);    rh = NULL; -  if (NULL != session) -    GNUNET_break (GNUNET_OK == -                  plugin->drop_tables (plugin->cls, -                                       session)); +  GNUNET_break (GNUNET_OK == +                plugin->drop_tables (plugin->cls));    if (NULL != dkp)      destroy_denom_key_pair (dkp);    if (NULL != cbc.sig.rsa_signature) | 
