diff options
author | Marco Boss <bossm8@bfh.ch> | 2022-03-02 19:03:54 +0100 |
---|---|---|
committer | Marco Boss <bossm8@bfh.ch> | 2022-03-02 19:03:54 +0100 |
commit | 57e3864c095f7ac7ca2fe5744a7ec05feb7d56be (patch) | |
tree | bf58c563f59389902fc95fac227122dbb099e3fc /src/exchangedb/plugin_exchangedb_postgres.c | |
parent | 10d7d93ad8002b0ea70899d8cdb503b91ce20d74 (diff) | |
parent | 79d123d1b4a39e69cfbcb3820e71e805a623b8ad (diff) |
Include partitioning in dbinit
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index bb1f0b6f..74aa831a 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -199,6 +199,50 @@ postgres_create_tables (void *cls) /** + * Setup partitions of already existing tables + * + * @param cls the `struct PostgresClosure` with the plugin-specific state + * @param num the number of partitions to create for each partitioned table + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure + */ +static enum GNUNET_GenericReturnValue +postgres_setup_partitions (void *cls, + const uint32_t num) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_Context *conn; + enum GNUNET_GenericReturnValue ret; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint32 (&num), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_PreparedStatement ps[] = { + GNUNET_PQ_make_prepare ("setup_partitions", + "SELECT" + " create_partitions" + " ($1);", + 1), + GNUNET_PQ_PREPARED_STATEMENT_END + }; + + conn = GNUNET_PQ_connect_with_cfg (pg->cfg, + "exchangedb-postgres", + "partition-", + NULL, + ps); + if (NULL == conn) + return GNUNET_SYSERR; + ret = GNUNET_OK; + if (0 > GNUNET_PQ_eval_prepared_non_select (conn, + "setup_partitions", + params)) + ret = GNUNET_SYSERR; + GNUNET_PQ_disconnect (conn); + return ret; +} + + +/** * Initialize prepared statements for @a pg. * * @param[in,out] pg connection to initialize @@ -11717,6 +11761,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->cls = pg; plugin->drop_tables = &postgres_drop_tables; plugin->create_tables = &postgres_create_tables; + plugin->setup_partitions = &postgres_setup_partitions; plugin->start = &postgres_start; plugin->start_read_committed = &postgres_start_read_committed; plugin->commit = &postgres_commit; |