commit 927fdb9b9af74a595e4b696a32d75b7e6596a0eb
parent eaadcdebe8085e1085e5af896cd0aa42f4c684b6
Author: Florian Dold <florian@dold.me>
Date: Mon, 4 May 2026 20:47:50 +0200
fix SQL for insert_deposit_confirmation
The out_deposit_confirmation_serial was not set properly in the presence
of an existing deposit confirmation record.
Additionally, the WHERE clause of the update for an existing deposit
confirmation record was wrong.
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/backenddb/insert_deposit_confirmation.c b/src/backenddb/insert_deposit_confirmation.c
@@ -141,5 +141,6 @@ TALER_MERCHANTDB_insert_deposit_confirmation (struct TALER_MERCHANTDB_PostgresCo
GNUNET_break (0);
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
+ GNUNET_assert (0 != *deposit_confirmation_serial_id);
return qs;
}
diff --git a/src/backenddb/pg_insert_deposit_confirmation.sql b/src/backenddb/pg_insert_deposit_confirmation.sql
@@ -133,6 +133,7 @@ THEN
) RETURNING deposit_confirmation_serial
INTO out_deposit_confirmation_serial;
ELSE
+ out_deposit_confirmation_serial = my_record.deposit_confirmation_serial;
IF (in_deposit_timestamp,
in_wire_transfer_deadline,
in_wire_fee,
@@ -144,7 +145,6 @@ ELSE
my_record.account_serial)
THEN
out_conflict = TRUE;
- out_deposit_confirmation_serial = my_record.deposit_confirmation_serial;
RETURN;
END IF;
IF ( ((in_total_without_fee).val < (my_record.total_without_fee).val) OR
@@ -152,7 +152,6 @@ ELSE
((in_total_without_fee).frac <= (my_record.total_without_fee).frac) ) )
THEN
-- new amount smaller or did not change, do NOT update.
- out_deposit_confirmation_serial = my_record.deposit_confirmation_serial;
RETURN;
END IF;
@@ -161,7 +160,7 @@ ELSE
SET total_without_fee = in_total_without_fee
,exchange_sig = in_exchange_sig
,signkey_serial = my_signkey_serial
- WHERE out_deposit_confirmation_serial = my_record.deposit_confirmation_serial;
+ WHERE deposit_confirmation_serial = my_record.deposit_confirmation_serial;
END IF;