aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-05-21 19:20:09 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-05-21 19:20:09 +0200
commitd36f1b3b6a6f99b3393eeefe61b23d18c710c1c2 (patch)
tree283f421a3a61d63eadbf7666f4db468ff4ede9ce
parentaa8d44aab3af79429247b6cf74da59398600cde3 (diff)
downloadexchange-d36f1b3b6a6f99b3393eeefe61b23d18c710c1c2.tar.xz
-fix SQL
-rw-r--r--src/benchmark/taler-exchange-benchmark.c18
-rw-r--r--src/exchangedb/exchange_do_reserves_in_insert.sql32
2 files changed, 25 insertions, 25 deletions
diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c
index 7170648f9..d076fb806 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -1063,12 +1063,18 @@ main (int argc,
{
/* If we use the fakebank, we MUST reset the database as the fakebank
will have forgotten everything... */
- GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_prepare_exchange (cfg_filename,
- (GNUNET_YES == use_fakebank)
- ? GNUNET_YES
- : GNUNET_NO,
- &ec));
+ if (GNUNET_OK !=
+ TALER_TESTING_prepare_exchange (cfg_filename,
+ (GNUNET_YES == use_fakebank)
+ ? GNUNET_YES
+ : GNUNET_NO,
+ &ec))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to prepare the exchange for launch\n");
+ GNUNET_free (cfg_filename);
+ return BAD_CONFIG_FILE;
+ }
}
else
{
diff --git a/src/exchangedb/exchange_do_reserves_in_insert.sql b/src/exchangedb/exchange_do_reserves_in_insert.sql
index bc1431ad5..20d1c55a2 100644
--- a/src/exchangedb/exchange_do_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_reserves_in_insert.sql
@@ -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(
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_wire_source_h_payto BYTEA[],
IN ina_payto_uri VARCHAR[],
- IN ina_notify TEXT[],
- OUT transaction_duplicate BOOLEAN,
- OUT ruuid INT8)
+ IN ina_notify TEXT[])
+RETURNS SETOF exchange_do_array_reserve_insert_return_type
LANGUAGE plpgsql
AS $$
DECLARE
@@ -1015,8 +1018,7 @@ BEGIN
,UNNEST (ina_payto_uri) AS payto_uri
ON CONFLICT DO NOTHING;
- OPEN curs FOR
- WITH reserve_changes AS (
+ FOR i IN
SELECT
reserve_pub
,wire_ref
@@ -1035,16 +1037,8 @@ BEGIN
,UNNEST (ina_exchange_account_name) AS exchange_account_name
,UNNEST (ina_execution_date) AS execution_date
,UNNEST (ina_wire_source_h_payto) AS wire_source_h_payto
- ,UNNEST (ina_notify) AS notify;
-
-
- <<loop>> LOOP
- FETCH FROM curs INTO i;
- IF NOT FOUND
- THEN
- EXIT loop;
- END IF;
-
+ ,UNNEST (ina_notify) AS notify
+ LOOP
INSERT INTO reserves
(reserve_pub
,current_balance_val
@@ -1060,7 +1054,7 @@ BEGIN
)
ON CONFLICT DO NOTHING
RETURNING reserve_uuid
- INTO uuid;
+ INTO uuid;
conflict = NOT FOUND;
INSERT INTO reserves_in
@@ -1079,6 +1073,7 @@ BEGIN
,i.exchange_account_section
,i.wire_source_h_payto
,i.execution_date
+ )
ON CONFLICT DO NOTHING;
IF NOT FOUND
@@ -1098,9 +1093,8 @@ BEGIN
END IF;
dup = FALSE;
END IF;
- RETURN (dup,uuid);
- END LOOP loop_reserve;
- CLOSE curs;
+ RETURN NEXT (dup,uuid);
+ END LOOP;
RETURN;
END $$;