fixing some bugs
This commit is contained in:
parent
2030d64910
commit
f2b1041925
@ -150,27 +150,24 @@ BEGIN
|
||||
THEN
|
||||
out_reserve_found = FALSE;
|
||||
ruuid = i.reserve_uuid;
|
||||
k = k+1;
|
||||
END IF;
|
||||
IF in2_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found2 = FALSE;
|
||||
ruuid2 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in3_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found3 = FALSE;
|
||||
ruuid3 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in4_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found4 = FALSE;
|
||||
ruuid4 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
END IF;
|
||||
k=k+1;
|
||||
END LOOP;
|
||||
CLOSE curs_reserve_exist;
|
||||
IF out_reserve_found
|
||||
@ -236,24 +233,21 @@ BEGIN
|
||||
IF in_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in2_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate2 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in3_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate3 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in4_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate4 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
END IF;
|
||||
k=k+1;
|
||||
END LOOP;
|
||||
CLOSE curs_transaction_exist;
|
||||
|
||||
|
@ -248,52 +248,44 @@ BEGIN
|
||||
THEN
|
||||
out_reserve_found = FALSE;
|
||||
ruuid = i.reserve_uuid;
|
||||
k = k+1;
|
||||
END IF;
|
||||
IF in2_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found2 = FALSE;
|
||||
ruuid2 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in3_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found3 = FALSE;
|
||||
ruuid3 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in4_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found4 = FALSE;
|
||||
ruuid4 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in5_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found5 = FALSE;
|
||||
ruuid5 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in6_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found6 = FALSE;
|
||||
ruuid6 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in7_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found7 = FALSE;
|
||||
ruuid7 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in8_reserve_pub = i.reserve_pub
|
||||
THEN
|
||||
out_reserve_found8 = FALSE;
|
||||
ruuid8 = i.reserve_uuid;
|
||||
k=k+1;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
k=k+1;
|
||||
END LOOP;
|
||||
|
||||
CLOSE curs_reserve_existed;
|
||||
@ -397,46 +389,38 @@ BEGIN
|
||||
IF in_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in2_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate2 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in3_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate3 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in4_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate4 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in5_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate5 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in6_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate6 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in7_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate7 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
IF in8_reserve_pub = r.reserve_pub
|
||||
THEN
|
||||
transaction_duplicate8 = TRUE;
|
||||
k=k+1;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
k=k+1;
|
||||
END LOOP;
|
||||
|
||||
CLOSE curs_transaction_existed;
|
||||
|
@ -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 $$;
|
||||
|
Loading…
Reference in New Issue
Block a user