modifications to batch1
This commit is contained in:
parent
ade221f974
commit
37f294b6ad
@ -32,7 +32,10 @@ CREATE OR REPLACE FUNCTION exchange_do_batch_reserves_in_insert(
|
|||||||
OUT ruuid INT8)
|
OUT ruuid INT8)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
|
DECLARE
|
||||||
|
curs refcursor;
|
||||||
|
DECLARE
|
||||||
|
i RECORD;
|
||||||
BEGIN
|
BEGIN
|
||||||
ruuid= 0;
|
ruuid= 0;
|
||||||
out_reserve_found = TRUE;
|
out_reserve_found = TRUE;
|
||||||
@ -46,6 +49,8 @@ transaction_duplicate= TRUE;
|
|||||||
,in_payto_uri)
|
,in_payto_uri)
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
OPEN curs FOR
|
||||||
|
WITH reserve_changes AS (
|
||||||
INSERT INTO reserves
|
INSERT INTO reserves
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
,current_balance_val
|
,current_balance_val
|
||||||
@ -59,15 +64,20 @@ transaction_duplicate= TRUE;
|
|||||||
,in_expiration_date
|
,in_expiration_date
|
||||||
,in_gc_date)
|
,in_gc_date)
|
||||||
ON CONFLICT DO NOTHING
|
ON CONFLICT DO NOTHING
|
||||||
RETURNING reserves.reserve_uuid INTO ruuid;
|
RETURNING reserve_uuid, reserve_pub)
|
||||||
|
SELECT * FROM reserve_changes;
|
||||||
|
FETCH FROM curs INTO i;
|
||||||
IF FOUND
|
IF FOUND
|
||||||
THEN
|
THEN
|
||||||
-- We made a change, so the reserve did not previously exist.
|
-- We made a change, so the reserve did not previously exist.
|
||||||
|
IF in_reserve_pub = i.reserve_pub
|
||||||
|
THEN
|
||||||
out_reserve_found = FALSE;
|
out_reserve_found = FALSE;
|
||||||
ELSE
|
ruuid = i.reserve_uuid;
|
||||||
-- We made no change, which means the reserve existed.
|
|
||||||
out_reserve_found = TRUE;
|
|
||||||
END IF;
|
END IF;
|
||||||
|
END IF;
|
||||||
|
CLOSE curs;
|
||||||
|
|
||||||
PERFORM pg_notify(in_notify, NULL);
|
PERFORM pg_notify(in_notify, NULL);
|
||||||
INSERT INTO reserves_in
|
INSERT INTO reserves_in
|
||||||
(reserve_pub
|
(reserve_pub
|
||||||
@ -92,7 +102,7 @@ transaction_duplicate= TRUE;
|
|||||||
transaction_duplicate = FALSE;
|
transaction_duplicate = FALSE;
|
||||||
ELSE
|
ELSE
|
||||||
-- Unhappy...
|
-- 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;
|
transaction_duplicate = TRUE;
|
||||||
-- ROLLBACK;
|
-- ROLLBACK;
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -763,6 +763,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
|
|||||||
t_duplicate |= transaction_duplicate[i+1];
|
t_duplicate |= transaction_duplicate[i+1];
|
||||||
t_duplicate |= transaction_duplicate[i+2];
|
t_duplicate |= transaction_duplicate[i+2];
|
||||||
t_duplicate |= transaction_duplicate[i+3];
|
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;
|
i += 4;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
@ -792,6 +793,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
|
|||||||
results[i] = (t_duplicate)
|
results[i] = (t_duplicate)
|
||||||
? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
|
? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
|
||||||
: GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
: GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
||||||
|
// fprintf(stdout, "reserve_uuid : %ld %ld\n", reserve_uuid[i], reserve_uuid[i+1]);
|
||||||
i += 2;
|
i += 2;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user