exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit b8f4af3c492ba5a4f513ab1a23921c634b7c7ba6
parent fd0d9c9a53048ce1c6a67f8cec2666d06c745c6c
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Mon, 17 Aug 2026 17:25:20 +0200

handle NULL fields in DB

Diffstat:
Msrc/auditor/taler-auditor-httpd_get-monitoring-balances.c | 8++++++--
Msrc/auditor/taler-auditor-httpd_get-monitoring-reserve-not-closed-inconsistency.c | 5+++--
Msrc/auditordb/iterate_balances.c | 9+++++++--
Msrc/auditordb/iterate_denominations_without_sigs.c | 13++++++++++---
Msrc/auditordb/iterate_reserve_not_closed_inconsistencies.c | 20+++++++++++++++-----
5 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/src/auditor/taler-auditor-httpd_get-monitoring-balances.c b/src/auditor/taler-auditor-httpd_get-monitoring-balances.c @@ -43,8 +43,12 @@ process_balances ( obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("balance_key", dc->balance_key), - TALER_JSON_pack_amount ("balance_value", - &dc->balance_value) + GNUNET_JSON_pack_allow_null ( + TALER_JSON_pack_amount ("balance_value", + (GNUNET_OK == + TALER_amount_is_valid (&dc->balance_value)) + ? &dc->balance_value + : NULL)) ); GNUNET_break (0 == json_array_append_new (list, diff --git a/src/auditor/taler-auditor-httpd_get-monitoring-reserve-not-closed-inconsistency.c b/src/auditor/taler-auditor-httpd_get-monitoring-reserve-not-closed-inconsistency.c @@ -50,8 +50,9 @@ process_reserve_not_closed_inconsistency ( &dc->balance), TALER_JSON_pack_time_abs_human ("expiration_time", dc->expiration_time), - GNUNET_JSON_pack_string ("diagnostic", - dc->diagnostic), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("diagnostic", + dc->diagnostic)), GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) ); diff --git a/src/auditordb/iterate_balances.c b/src/auditordb/iterate_balances.c @@ -66,8 +66,13 @@ balances_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("balance_key", &dc.balance_key), - TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", - &dc.balance_value), + /* 'balance_value' is nullable in the schema; on NULL the amount + is left invalid instead of failing the extraction for the + entire page. */ + GNUNET_PQ_result_spec_allow_null ( + TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", + &dc.balance_value), + NULL), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; diff --git a/src/auditordb/iterate_denominations_without_sigs.c b/src/auditordb/iterate_denominations_without_sigs.c @@ -70,7 +70,12 @@ denominations_without_sigs_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - struct TALER_AUDITORDB_DenominationsWithoutSigs dc; + /* 'end_time' is nullable in the schema; initialize it so that a + NULL yields "never" instead of failing the extraction for the + entire page. */ + struct TALER_AUDITORDB_DenominationsWithoutSigs dc = { + .end_time = GNUNET_TIME_UNIT_FOREVER_ABS + }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("row_id", &dc.row_id), @@ -80,8 +85,10 @@ denominations_without_sigs_cb (void *cls, &dc.value), GNUNET_PQ_result_spec_absolute_time ("start_time", &dc.start_time), - GNUNET_PQ_result_spec_absolute_time ("end_time", - &dc.end_time), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_absolute_time ("end_time", + &dc.end_time), + NULL), GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), GNUNET_PQ_result_spec_end diff --git a/src/auditordb/iterate_reserve_not_closed_inconsistencies.c b/src/auditordb/iterate_reserve_not_closed_inconsistencies.c @@ -69,7 +69,13 @@ reserve_not_closed_inconsistency_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc; + /* 'expiration_time' and 'diagnostic' are nullable in the schema; + initialize them so that a NULL yields "never"/absent instead of + failing the extraction for the entire page. */ + struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc = { + .expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS, + .diagnostic = NULL + }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("row_id", &dc.row_id), @@ -77,10 +83,14 @@ reserve_not_closed_inconsistency_cb (void *cls, &dc.reserve_pub), TALER_PQ_RESULT_SPEC_AMOUNT ("balance", &dc.balance), - GNUNET_PQ_result_spec_absolute_time ("expiration_time", - &dc.expiration_time), - GNUNET_PQ_result_spec_string ("diagnostic", - &dc.diagnostic), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_absolute_time ("expiration_time", + &dc.expiration_time), + NULL), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), + NULL), GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), GNUNET_PQ_result_spec_end