aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
diff options
context:
space:
mode:
authorJoseph <Joseph.xu@efrei.net>2023-01-04 07:31:08 -0500
committerJoseph <Joseph.xu@efrei.net>2023-01-04 07:31:08 -0500
commit6457ee56dfb148773167e45fb408176e7370f817 (patch)
tree56e61f6fe0cd3d743cb267365a0c737eacabcc07 /src/exchangedb/exchange_do_batch_reserves_in_insert.sql
parent31fefec5ddc49ef9b2aab677084d1cf4ab76bba6 (diff)
downloadexchange-6457ee56dfb148773167e45fb408176e7370f817.tar.xz
corrections applied to batch_test
Diffstat (limited to 'src/exchangedb/exchange_do_batch_reserves_in_insert.sql')
-rw-r--r--src/exchangedb/exchange_do_batch_reserves_in_insert.sql11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
index 56cae3d91..4ae7f68a2 100644
--- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
@@ -36,7 +36,7 @@ AS $$
BEGIN
ruuid= 0;
out_reserve_found = TRUE;
-transaction_duplicate= FALSE;
+transaction_duplicate= TRUE;
--SIMPLE INSERT ON CONFLICT DO NOTHING
INSERT INTO wire_targets
(wire_target_h_payto
@@ -66,7 +66,7 @@ transaction_duplicate= FALSE;
out_reserve_found = FALSE;
ELSE
-- We made no change, which means the reserve existed.
- out_reserve_found = TRUE; /*RESERVE EXISTED BUT WE DO NOT HAVE ANY INFORMATION ABOUT TRANSACTION, RETURN*/
+ out_reserve_found = TRUE;
RETURN;
END IF;
PERFORM pg_notify(in_notify, NULL);
@@ -89,11 +89,14 @@ transaction_duplicate= FALSE;
ON CONFLICT DO NOTHING;
IF FOUND
THEN
- transaction_duplicate = FALSE; /*HAPPY PATH THERE IS NO DUPLICATE TRANS AND NEW RESERVE*/
+ -- HAPPY PATH THERE IS NO DUPLICATE TRANS
+ transaction_duplicate = FALSE;
RETURN;
ELSE
+ -- Unhappy...
+ RAISE EXCEPTION 'Reserve did not exist, but INSERT into reserves_in gave conflict';
transaction_duplicate = TRUE;
- /*HAPPY PATH IF THERE IS A DUPLICATE TRANS WE JUST NEED TO ROLLBACK COMPLAIN*/
+ ROLLBACK;
RETURN;
END IF;
RETURN;