gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (ade221f9 -> 1a94db3d)


From: gnunet
Subject: [taler-exchange] branch master updated (ade221f9 -> 1a94db3d)
Date: Fri, 06 Jan 2023 17:06:11 +0100

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

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

    from ade221f9 -fix crash in wirewatch if badly configured
     new 37f294b6 modifications to batch1
     new 1a94db3d some changes to batchtest

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../exchange_do_batch2_reserves_in_insert.sql      |  1 -
 .../exchange_do_batch4_reserves_in_insert.sql      |  2 +-
 .../exchange_do_batch_reserves_in_insert.sql       | 50 +++++++++++++---------
 src/exchangedb/pg_batch2_reserves_in_insert.c      |  2 +
 src/exchangedb/test_exchangedb_by_j.c              |  2 +-
 5 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql 
b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
index bda644ec..932f7d81 100644
--- a/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch2_reserves_in_insert.sql
@@ -55,7 +55,6 @@ DECLARE
 DECLARE
   k INT8;
 BEGIN
-  --SIMPLE INSERT ON CONFLICT DO NOTHING
   transaction_duplicate=TRUE;
   transaction_duplicate2=TRUE;
   out_reserve_found = TRUE;
diff --git a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql 
b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql
index c2157f7d..a70521bc 100644
--- a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql
@@ -267,7 +267,7 @@ BEGIN
     END IF;
   k=k+1;
   END LOOP;
-
+ /**ROLLBACK TRANSACTION IN SOTRED PROCEDURE IS IT PROSSIBLE ?**/
   /*IF transaction_duplicate
   OR transaction_duplicate2
   OR transaction_duplicate3
diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql 
b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
index 4e0383f6..d1cc35d3 100644
--- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
+++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql
@@ -32,7 +32,10 @@ CREATE OR REPLACE FUNCTION 
exchange_do_batch_reserves_in_insert(
   OUT ruuid INT8)
 LANGUAGE plpgsql
 AS $$
-
+DECLARE
+  curs refcursor;
+DECLARE
+  i RECORD;
 BEGIN
 ruuid= 0;
 out_reserve_found = TRUE;
@@ -46,28 +49,35 @@ transaction_duplicate= TRUE;
     ,in_payto_uri)
   ON CONFLICT DO NOTHING;
 
-  INSERT INTO reserves
-    (reserve_pub
-    ,current_balance_val
-    ,current_balance_frac
-    ,expiration_date
-    ,gc_date)
-    VALUES
-    (in_reserve_pub
-    ,in_credit_val
-    ,in_credit_frac
-    ,in_expiration_date
-    ,in_gc_date)
-   ON CONFLICT DO NOTHING
-   RETURNING reserves.reserve_uuid INTO ruuid;
+  OPEN curs FOR
+  WITH reserve_changes AS (
+    INSERT INTO reserves
+      (reserve_pub
+      ,current_balance_val
+      ,current_balance_frac
+      ,expiration_date
+      ,gc_date)
+      VALUES
+      (in_reserve_pub
+      ,in_credit_val
+      ,in_credit_frac
+      ,in_expiration_date
+      ,in_gc_date)
+     ON CONFLICT DO NOTHING
+     RETURNING reserve_uuid, reserve_pub)
+   SELECT * FROM reserve_changes;
+  FETCH FROM curs INTO i;
   IF FOUND
   THEN
     -- We made a change, so the reserve did not previously exist.
-    out_reserve_found = FALSE;
-  ELSE
-    -- We made no change, which means the reserve existed.
-    out_reserve_found = TRUE;
+    IF in_reserve_pub = i.reserve_pub
+    THEN
+        out_reserve_found = FALSE;
+        ruuid = i.reserve_uuid;
+    END IF;
   END IF;
+  CLOSE curs;
+
   PERFORM pg_notify(in_notify, NULL);
   INSERT INTO reserves_in
     (reserve_pub
@@ -92,7 +102,7 @@ transaction_duplicate= TRUE;
     transaction_duplicate = FALSE;
   ELSE
     -- Unhappy...
---    RAISE EXCEPTION 'Reserve did not exist, but INSERT into reserves_in gave 
conflict';
+    RAISE EXCEPTION 'Reserve did not exist, but INSERT into reserves_in gave 
conflict';
     transaction_duplicate = TRUE;
 --    ROLLBACK;
   END IF;
diff --git a/src/exchangedb/pg_batch2_reserves_in_insert.c 
b/src/exchangedb/pg_batch2_reserves_in_insert.c
index a55c518c..e0208f09 100644
--- a/src/exchangedb/pg_batch2_reserves_in_insert.c
+++ b/src/exchangedb/pg_batch2_reserves_in_insert.c
@@ -763,6 +763,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
       t_duplicate |= transaction_duplicate[i+1];
       t_duplicate |= transaction_duplicate[i+2];
       t_duplicate |= transaction_duplicate[i+3];
+      //  fprintf(stdout, "reserve_uuid : %ld %ld %ld %ld\n", reserve_uuid[i], 
reserve_uuid[i+1], reserve_uuid[i+2], reserve_uuid[i+3]);
       i += 4;
       break;
     case 3:
@@ -792,6 +793,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
       results[i] = (t_duplicate)
       ? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
       : GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
+      //   fprintf(stdout, "reserve_uuid : %ld %ld\n", reserve_uuid[i], 
reserve_uuid[i+1]);
       i += 2;
       break;
     case 1:
diff --git a/src/exchangedb/test_exchangedb_by_j.c 
b/src/exchangedb/test_exchangedb_by_j.c
index 9769d964..533871cc 100644
--- a/src/exchangedb/test_exchangedb_by_j.c
+++ b/src/exchangedb/test_exchangedb_by_j.c
@@ -107,7 +107,7 @@ run (void *cls)
         const char *sndr = "payto://x-taler-bank/localhost:8080/1";
         struct TALER_Amount value;
         unsigned int batch_size = batches[i];
-        unsigned int iterations = 16;//1024*10;
+        unsigned int iterations = 10000;//1024*10;
         struct TALER_ReservePublicKeyP reserve_pubs[iterations];
         struct GNUNET_TIME_Absolute now;
         struct GNUNET_TIME_Timestamp ts;

-- 
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]