aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
diff options
context:
space:
mode:
authorJoseph <Joseph.xu@efrei.net>2022-12-21 08:06:47 -0500
committerJoseph <Joseph.xu@efrei.net>2022-12-21 08:06:47 -0500
commitf2b104192564711c48d7e7e9c264e2a72043e192 (patch)
tree39f1c6263ebe13a4b3cbd75a2ea88a2a3b3ff9e9 /src/exchangedb/exchange_do_batch_reserves_in_insert.sql
parent2030d6491005cd6e714b4a4ef40b13a7dc1bdc74 (diff)
downloadexchange-f2b104192564711c48d7e7e9c264e2a72043e192.tar.xz
fixing some bugs
Diffstat (limited to 'src/exchangedb/exchange_do_batch_reserves_in_insert.sql')
-rw-r--r--src/exchangedb/exchange_do_batch_reserves_in_insert.sql13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
index ef4c84aa7..d7efe01b9 100644
--- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
@@ -34,6 +34,9 @@ LANGUAGE plpgsql
AS $$
BEGIN
+ruuid= 0;
+out_reserve_found = TRUE;
+transaction_duplicate= FALSE;
--SIMPLE INSERT ON CONFLICT DO NOTHING
INSERT INTO wire_targets
(wire_target_h_payto
@@ -56,9 +59,7 @@ BEGIN
,in_expiration_date
,in_gc_date)
ON CONFLICT DO NOTHING
- RETURNING reserve_uuid INTO ruuid;
- PERFORM pg_notify(in_notify, NULL);
-
+ RETURNING reserves.reserve_uuid INTO ruuid;
IF FOUND
THEN
-- We made a change, so the reserve did not previously exist.
@@ -68,7 +69,7 @@ BEGIN
out_reserve_found = TRUE; /*RESERVE EXISTED BUT WE DO NOT KNOW ANY INFORMATIONS ABOUT TRANSACTION, RETURN*/
RETURN;
END IF;
-
+ PERFORM pg_notify(in_notify, NULL);
INSERT INTO reserves_in
(reserve_pub
,wire_reference
@@ -91,7 +92,9 @@ BEGIN
transaction_duplicate = FALSE; /*HAPPY PATH THERE IS NO DUPLICATE TRANS AND NEW RESERVE*/
RETURN;
ELSE
- transaction_duplicate = TRUE; /*HAPPY PATH IF THERE IS A DUPLICATE TRANS WE JUST NEED TO ROLLBACK COMPLAIN*/
+ transaction_duplicate = TRUE;
+ /*HAPPY PATH IF THERE IS A DUPLICATE TRANS WE JUST NEED TO ROLLBACK COMPLAIN*/
RETURN;
END IF;
+ RETURN;
END $$;