This commit is contained in:
Christian Grothoff 2023-05-21 19:20:09 +02:00
parent aa8d44aab3
commit d36f1b3b6a
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 25 additions and 25 deletions

View File

@ -1063,12 +1063,18 @@ main (int argc,
{ {
/* If we use the fakebank, we MUST reset the database as the fakebank /* If we use the fakebank, we MUST reset the database as the fakebank
will have forgotten everything... */ will have forgotten everything... */
GNUNET_assert (GNUNET_OK == if (GNUNET_OK !=
TALER_TESTING_prepare_exchange (cfg_filename, TALER_TESTING_prepare_exchange (cfg_filename,
(GNUNET_YES == use_fakebank) (GNUNET_YES == use_fakebank)
? GNUNET_YES ? GNUNET_YES
: GNUNET_NO, : GNUNET_NO,
&ec)); &ec))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to prepare the exchange for launch\n");
GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE;
}
} }
else else
{ {

View File

@ -975,6 +975,10 @@ END $$;
CREATE TYPE exchange_do_array_reserve_insert_return_type
AS
(transaction_duplicate BOOLEAN
,ruuid INT8);
CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert( CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert(
IN in_gc_date INT8, IN in_gc_date INT8,
@ -987,9 +991,8 @@ CREATE OR REPLACE FUNCTION exchange_do_array_reserves_insert(
IN ina_execution_date INT8[], IN ina_execution_date INT8[],
IN ina_wire_source_h_payto BYTEA[], IN ina_wire_source_h_payto BYTEA[],
IN ina_payto_uri VARCHAR[], IN ina_payto_uri VARCHAR[],
IN ina_notify TEXT[], IN ina_notify TEXT[])
OUT transaction_duplicate BOOLEAN, RETURNS SETOF exchange_do_array_reserve_insert_return_type
OUT ruuid INT8)
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
DECLARE DECLARE
@ -1015,8 +1018,7 @@ BEGIN
,UNNEST (ina_payto_uri) AS payto_uri ,UNNEST (ina_payto_uri) AS payto_uri
ON CONFLICT DO NOTHING; ON CONFLICT DO NOTHING;
OPEN curs FOR FOR i IN
WITH reserve_changes AS (
SELECT SELECT
reserve_pub reserve_pub
,wire_ref ,wire_ref
@ -1035,16 +1037,8 @@ BEGIN
,UNNEST (ina_exchange_account_name) AS exchange_account_name ,UNNEST (ina_exchange_account_name) AS exchange_account_name
,UNNEST (ina_execution_date) AS execution_date ,UNNEST (ina_execution_date) AS execution_date
,UNNEST (ina_wire_source_h_payto) AS wire_source_h_payto ,UNNEST (ina_wire_source_h_payto) AS wire_source_h_payto
,UNNEST (ina_notify) AS notify; ,UNNEST (ina_notify) AS notify
LOOP
<<loop>> LOOP
FETCH FROM curs INTO i;
IF NOT FOUND
THEN
EXIT loop;
END IF;
INSERT INTO reserves INSERT INTO reserves
(reserve_pub (reserve_pub
,current_balance_val ,current_balance_val
@ -1060,7 +1054,7 @@ BEGIN
) )
ON CONFLICT DO NOTHING ON CONFLICT DO NOTHING
RETURNING reserve_uuid RETURNING reserve_uuid
INTO uuid; INTO uuid;
conflict = NOT FOUND; conflict = NOT FOUND;
INSERT INTO reserves_in INSERT INTO reserves_in
@ -1079,6 +1073,7 @@ BEGIN
,i.exchange_account_section ,i.exchange_account_section
,i.wire_source_h_payto ,i.wire_source_h_payto
,i.execution_date ,i.execution_date
)
ON CONFLICT DO NOTHING; ON CONFLICT DO NOTHING;
IF NOT FOUND IF NOT FOUND
@ -1098,9 +1093,8 @@ BEGIN
END IF; END IF;
dup = FALSE; dup = FALSE;
END IF; END IF;
RETURN (dup,uuid); RETURN NEXT (dup,uuid);
END LOOP loop_reserve; END LOOP;
CLOSE curs;
RETURN; RETURN;
END $$; END $$;