fix errors

This commit is contained in:
Özgür Kesim 2022-10-14 20:09:39 +02:00
parent 15e8697ece
commit 29e5cd0ef5
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7

View File

@ -2207,8 +2207,8 @@ CREATE OR REPLACE FUNCTION insert_or_update_policy_details(
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
DECLARE DECLARE
cur_commiment_val INT8; cur_commitment_val INT8;
cur_commiment_frac INT4; cur_commitment_frac INT4;
cur_accumulated_total_val INT8; cur_accumulated_total_val INT8;
cur_accumulated_total_frac INT4; cur_accumulated_total_frac INT4;
BEGIN BEGIN
@ -2238,33 +2238,29 @@ BEGIN
in_transferable_val, in_transferable_val,
in_transferable_frac, in_transferable_frac,
in_fulfillment_state) in_fulfillment_state)
RETURNING (policy_details_serial_id, ON CONFLICT (policy_hash_code) DO NOTHING
accumulated_total_val, RETURNING policy_details_serial_id INTO out_policy_details_serial_id;
accumulated_total_frac,
fulfillment_state)
INTO (out_policy_details_serial_id,
out_accumulated_total_val,
out_accumulated_total_frac,
out_fulfillment_state)
ON CONFLICT (policy_hash_code) DO NOTHING;
-- If the insert was successful, return -- If the insert was successful, return
-- We assume that the fullfilment_state was correct in first place. -- We assume that the fullfilment_state was correct in first place.
IF FOUND THEN IF FOUND THEN
out_accumulated_total_val = in_accumulated_total_val;
out_accumulated_total_frac = in_accumulated_total_frac;
out_fulfillment_state = in_fulfillment_state;
RETURN; RETURN;
END IF; END IF;
-- We had a conflict, grab the parts we need to update. -- We had a conflict, grab the parts we need to update.
SELECT (policy_details_serial_id, SELECT policy_details_serial_id,
commitment_val, commitment_val,
commitment_frac, commitment_frac,
accumulated_total_val, accumulated_total_val,
accumulated_total_frac) accumulated_total_frac
INTO (out_policy_details_serial_id, INTO out_policy_details_serial_id,
cur_commitment_val, cur_commitment_val,
cur_commitment_frac, cur_commitment_frac,
cur_accumulated_total_val, cur_accumulated_total_val,
cur_accumulated_total_frac) cur_accumulated_total_frac
FROM policy_details FROM policy_details
WHERE policy_hash_code = in_policy_hash_code; WHERE policy_hash_code = in_policy_hash_code;
@ -2277,7 +2273,7 @@ BEGIN
IF (out_accumulated_total_val > (1 << 52)) IF (out_accumulated_total_val > (1 << 52))
THEN THEN
RAISE EXCEPTION "accumulation overflow"; RAISE EXCEPTION 'accumulation overflow';
END IF; END IF;