gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: update of batch 2 test


From: gnunet
Subject: [taler-exchange] branch master updated: update of batch 2 test
Date: Wed, 21 Dec 2022 13:28:54 +0100

This is an automated email from the git hooks/post-receive script.

joseph-xu pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 2030d649 update of batch 2 test
2030d649 is described below

commit 2030d6491005cd6e714b4a4ef40b13a7dc1bdc74
Author: Joseph <Joseph.xu@efrei.net>
AuthorDate: Wed Dec 21 07:28:46 2022 -0500

    update of batch 2 test
---
 .../exchange_do_batch2_reserves_in_insert.sql      | 55 ++++++++++------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql 
b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
index 6a0cc6d7..0e2d37d8 100644
--- a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
@@ -46,20 +46,12 @@ LANGUAGE plpgsql
 AS $$
 DECLARE
   curs_reserve_exist REFCURSOR;
-
---  FOR SELECT reserve_pub
---  FROM reserves
---  WHERE in_reserve_pub = reserves.reserve_pub
---  OR in2_reserve_pub = reserves.reserve_pub;
 DECLARE
-  curs_transaction_exist CURSOR
-  FOR SELECT reserve_pub
-  FROM reserves_in
-  WHERE in_reserve_pub = reserves_in.reserve_pub
-  OR in2_reserve_pub = reserves_in.reserve_pub;
+  curs_transaction_exist refcursor;
 DECLARE
   i RECORD;
-
+DECLARE
+  r RECORD;
 BEGIN
   --SIMPLE INSERT ON CONFLICT DO NOTHING
   transaction_duplicate=FALSE;
@@ -138,6 +130,8 @@ BEGIN
   PERFORM pg_notify(in_notify, NULL);
   PERFORM pg_notify(in2_notify, NULL);
 
+  OPEN curs_transaction_exist FOR
+  WITH reserve_in_exist AS (
   INSERT INTO reserves_in
     (reserve_pub
     ,wire_reference
@@ -161,33 +155,34 @@ BEGIN
     ,in2_exchange_account_name
     ,in2_wire_source_h_payto
     ,in_expiration_date)
-    ON CONFLICT DO NOTHING;
+    ON CONFLICT DO NOTHING
+    RETURNING reserve_pub)
+  SELECT * FROM reserve_in_exist;
+  FETCH FROM curs_transaction_exist INTO r;
   IF FOUND
   THEN
-    transaction_duplicate = FALSE;  /*HAPPY PATH THERE IS NO DUPLICATE TRANS 
AND NEW RESERVE*/
-    transaction_duplicate2 = FALSE;
-    RETURN;
-  ELSE
-    FOR l IN curs_transaction_exist
-    LOOP
-      IF in_reserve_pub = l.reserve_pub
-      THEN
-         transaction_duplicate = TRUE;
-      END IF;
-
-      IF in2_reserve_pub = l.reserve_pub
+    IF in_reserve_pub = r.reserve_pub
+    THEN
+       transaction_duplicate = TRUE;
+    END IF;
+    IF in2_reserve_pub = i.reserve_pub
+    THEN
+       transaction_duplicate = TRUE;
+    END IF;
+    FETCH FROM curs_transaction_exist INTO r;
+    IF FOUND
+    THEN
+      IF in_reserve_pub = r.reserve_pub
       THEN
-         transaction_duplicate2 = TRUE;
+        transaction_duplicate = TRUE;
       END IF;
-
-      IF transaction_duplicate AND transaction_duplicate2
+      IF in2_reserve_pub = i.reserve_pub
       THEN
-        RETURN;
+        transaction_duplicate = TRUE;
       END IF;
-    END LOOP;
+    END IF;
   END IF;
 
-  CLOSE curs_reserve_exist;
   CLOSE curs_transaction_exist;
   RETURN;
 END $$;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]