diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-28 23:18:40 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-28 23:18:40 +0100 |
commit | e24a6369aae5c2ab6ccec4ecdd269a280078f790 (patch) | |
tree | a771278300d1aafc77f95afed32d2837c099bbfe /src/exchangedb | |
parent | a8d9e7e0a61cd9f23371d09bec244a6e11683efc (diff) | |
download | exchange-e24a6369aae5c2ab6ccec4ecdd269a280078f790.tar.xz |
test-sync passes again
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/irbt_callbacks.c | 5 | ||||
-rw-r--r-- | src/exchangedb/lrbt_callbacks.c | 7 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 41 |
3 files changed, 50 insertions, 3 deletions
diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c index a994c611b..97ce2c094 100644 --- a/src/exchangedb/irbt_callbacks.c +++ b/src/exchangedb/irbt_callbacks.c @@ -115,12 +115,15 @@ irbt_cb_table_wire_targets (struct PostgresClosure *pg, { struct TALER_PaytoHashP payto_hash; struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_auto_from_type (&payto_hash), GNUNET_PQ_query_param_string ( td->details.wire_targets.payto_uri), GNUNET_PQ_query_param_auto_from_type ( &td->details.wire_targets.kyc_ok), - GNUNET_PQ_query_param_string ( + NULL == td->details.wire_targets.external_id + ? GNUNET_PQ_query_param_null () + : GNUNET_PQ_query_param_string ( td->details.wire_targets.external_id), GNUNET_PQ_query_param_end }; diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c index f8c93a384..01eddc5a6 100644 --- a/src/exchangedb/lrbt_callbacks.c +++ b/src/exchangedb/lrbt_callbacks.c @@ -175,6 +175,7 @@ lrbt_cb_table_wire_targets (void *cls, for (unsigned int i = 0; i<num_results; i++) { + bool no_xid; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), @@ -182,8 +183,10 @@ lrbt_cb_table_wire_targets (void *cls, &td.details.wire_targets.payto_uri), GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", &td.details.wire_targets.kyc_ok), - GNUNET_PQ_result_spec_string ("external_id", - &td.details.wire_targets.external_id), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_string ("external_id", + &td.details.wire_targets.external_id), + &no_xid), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 12f18d0be..c8c0c2968 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1924,6 +1924,14 @@ prepare_statements (struct PostgresClosure *pg) " LIMIT 1;", 0), GNUNET_PQ_make_prepare ( + "select_serial_by_table_wire_targets", + "SELECT" + " wire_target_serial_id AS serial" + " FROM wire_targets" + " ORDER BY wire_target_serial_id DESC" + " LIMIT 1;", + 0), + GNUNET_PQ_make_prepare ( "select_serial_by_table_reserves", "SELECT" " reserve_uuid AS serial" @@ -2113,6 +2121,17 @@ prepare_statements (struct PostgresClosure *pg) " ORDER BY denom_revocations_serial_id ASC;", 1), GNUNET_PQ_make_prepare ( + "select_above_serial_by_table_wire_targets", + "SELECT" + " wire_target_serial_id AS serial" + ",payto_uri" + ",kyc_ok" + ",external_id" + " FROM wire_targets" + " WHERE wire_target_serial_id > $1" + " ORDER BY wire_target_serial_id ASC;", + 1), + GNUNET_PQ_make_prepare ( "select_above_serial_by_table_reserves", "SELECT" " reserve_uuid AS serial" @@ -2419,6 +2438,17 @@ prepare_statements (struct PostgresClosure *pg) "($1, $2, $3);", 3), GNUNET_PQ_make_prepare ( + "insert_into_table_wire_targets", + "INSERT INTO wire_targets" + "(wire_target_serial_id" + ",h_payto" + ",payto_uri" + ",kyc_ok" + ",external_id" + ") VALUES " + "($1, $2, $3, $4, $5);", + 5), + GNUNET_PQ_make_prepare ( "insert_into_table_reserves", "INSERT INTO reserves" "(reserve_uuid" @@ -10673,6 +10703,9 @@ postgres_lookup_serial_by_table (void *cls, case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS: statement = "select_serial_by_table_denomination_revocations"; break; + case TALER_EXCHANGEDB_RT_WIRE_TARGETS: + statement = "select_serial_by_table_wire_targets"; + break; case TALER_EXCHANGEDB_RT_RESERVES: statement = "select_serial_by_table_reserves"; break; @@ -10906,9 +10939,17 @@ postgres_lookup_records_by_table (void *cls, rh, &ctx); if (qs < 0) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to run `%s'\n", + statement); return qs; + } if (ctx.error) + { + GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; + } return qs; } |