diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-01-02 13:30:29 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-01-02 13:30:29 +0100 |
commit | c92a38927231949b4f5b9a133c6934b04031339c (patch) | |
tree | 0ec0f9f9e44acff62296597139620be8caf17395 | |
parent | 673edc82adea15b687cafac882f3f71409ac5aad (diff) |
fix reconnect commit statement problem
m--------- | contrib/wallet-core | 0 | ||||
m--------- | doc/prebuilt | 0 | ||||
-rw-r--r-- | src/backenddb/pg_delete_otp.c | 1 | ||||
-rw-r--r-- | src/backenddb/pg_helper.c | 23 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 11 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 27 |
6 files changed, 38 insertions, 24 deletions
diff --git a/contrib/wallet-core b/contrib/wallet-core -Subproject 2347be694c713959528ad59f3f157d866d7ad42 +Subproject 0c211082e0b8372f8fa1cef8102e477c7363d9b diff --git a/doc/prebuilt b/doc/prebuilt -Subproject 09a33a50d9b3b400f8a515082c888918cbf4e1b +Subproject 5e47a72e8a2b5086dfdae4078f695155f5ed7af diff --git a/src/backenddb/pg_delete_otp.c b/src/backenddb/pg_delete_otp.c index 7d32b3fb..b4c0687d 100644 --- a/src/backenddb/pg_delete_otp.c +++ b/src/backenddb/pg_delete_otp.c @@ -52,4 +52,3 @@ TMH_PG_delete_otp (void *cls, "delete_otp", params); } - diff --git a/src/backenddb/pg_helper.c b/src/backenddb/pg_helper.c index 2ac047b1..802abc21 100644 --- a/src/backenddb/pg_helper.c +++ b/src/backenddb/pg_helper.c @@ -38,6 +38,7 @@ TMH_PG_start (void *cls, GNUNET_PQ_EXECUTE_STATEMENT_END }; + GNUNET_assert (NULL != name); check_connection (pg); postgres_preflight (pg); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -66,6 +67,7 @@ TMH_PG_start_read_committed (void *cls, GNUNET_PQ_EXECUTE_STATEMENT_END }; + GNUNET_assert (NULL != name); check_connection (pg); postgres_preflight (pg); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -93,6 +95,8 @@ TMH_PG_rollback (void *cls) GNUNET_PQ_EXECUTE_STATEMENT_END }; + if (NULL == pg->transaction_name) + return; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Rolling back merchant DB transaction `%s'\n", pg->transaction_name); @@ -110,12 +114,25 @@ TMH_PG_commit (void *cls) struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_end }; + enum GNUNET_DB_QueryStatus qs; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Committing merchant DB transaction %s\n", pg->transaction_name); + check_connection (pg); + PREPARE (pg, + "merchant_commit", + "COMMIT"); + qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, + "merchant_commit", + params); + if (qs < 0) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to commit transaction\n"); + TMH_PG_rollback (pg); + return qs; + } pg->transaction_name = NULL; - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "end_transaction", - params); + return qs; } diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 38dd636e..30f5c169 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -300,21 +300,17 @@ check_connection (struct PostgresClosure *pg) GNUNET_PQ_reconnect_if_down (pg->conn); } + /** * Establish connection to the database. * * @param cls plugin context * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ -static int +static enum GNUNET_GenericReturnValue postgres_connect (void *cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_PreparedStatement ps[] = { - GNUNET_PQ_make_prepare ("end_transaction", - "COMMIT"), - GNUNET_PQ_PREPARED_STATEMENT_END - }; struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_try_execute ("SET search_path TO merchant;"), GNUNET_PQ_EXECUTE_STATEMENT_END @@ -324,7 +320,7 @@ postgres_connect (void *cls) "merchantdb-postgres", NULL, es, - ps); + NULL); pg->prep_gen++; if (NULL == pg->conn) return GNUNET_SYSERR; @@ -618,7 +614,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) = &TMH_PG_update_token_family; - return plugin; } diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 8df171fe..27950232 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -1101,12 +1101,13 @@ enum TALER_MERCHANTDB_TokenFamilyKind * @param expiration end time of the token family's validity period */ typedef void -(*TALER_MERCHANTDB_TokenFamiliesCallback)(void *cls, - const char *slug, - const char *name, - struct GNUNET_TIME_Timestamp start_time, - struct GNUNET_TIME_Timestamp expiration, - const char *kind); +(*TALER_MERCHANTDB_TokenFamiliesCallback)( + void *cls, + const char *slug, + const char *name, + struct GNUNET_TIME_Timestamp start_time, + struct GNUNET_TIME_Timestamp expiration, + const char *kind); /** @@ -1117,17 +1118,17 @@ struct TALER_MERCHANTDB_TokenFamilyDetails /** * Token family slug used for identification. */ - char* slug; + char *slug; /** * User readable name of the token family. */ - char* name; + char *name; /** * Description of the token family. */ - char* description; + char *description; /** * Internationalized token family description. @@ -1356,7 +1357,7 @@ struct TALER_MERCHANTDB_Plugin * Commit the current transaction of a database connection. * * @param cls the `struct PostgresClosure` with the plugin-specific state - * @return transaction status code + * @return transation status */ enum GNUNET_DB_QueryStatus (*commit)(void *cls); @@ -3623,7 +3624,8 @@ struct TALER_MERCHANTDB_Plugin (*update_token_family)(void *cls, const char *instance_id, const char *token_family_slug, - const struct TALER_MERCHANTDB_TokenFamilyDetails *details); + const struct + TALER_MERCHANTDB_TokenFamilyDetails *details); /** @@ -3639,7 +3641,8 @@ struct TALER_MERCHANTDB_Plugin (*insert_token_family)(void *cls, const char *instance_id, const char *token_family_slug, - const struct TALER_MERCHANTDB_TokenFamilyDetails *details); + const struct + TALER_MERCHANTDB_TokenFamilyDetails *details); }; |