-sql fixes
This commit is contained in:
parent
60c08dccec
commit
06bfbd9150
@ -233,8 +233,8 @@ create_transaction (void *cls,
|
||||
&pcc->h_contract_terms,
|
||||
pcc->min_age,
|
||||
TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
|
||||
&pcc->amount,
|
||||
&purse_fee,
|
||||
&pcc->amount,
|
||||
&pcc->purse_sig,
|
||||
&in_conflict);
|
||||
if (qs < 0)
|
||||
|
@ -220,7 +220,7 @@ deposit_transaction (void *cls,
|
||||
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_GENERIC_DB_STORE_FAILED,
|
||||
"purse deposit deposit");
|
||||
"do purse deposit");
|
||||
return qs;
|
||||
}
|
||||
if (! balance_ok)
|
||||
|
@ -2854,6 +2854,10 @@ DECLARE
|
||||
was_merged BOOLEAN;
|
||||
DECLARE
|
||||
psi INT8; -- partner's serial ID (set if merged)
|
||||
DECLARE
|
||||
my_amount_val INT8; -- total in purse
|
||||
DECLARE
|
||||
my_amount_frac INT4; -- total in purse
|
||||
DECLARE
|
||||
was_paid BOOLEAN;
|
||||
DECLARE
|
||||
@ -2881,8 +2885,7 @@ IF NOT FOUND
|
||||
THEN
|
||||
-- Idempotency check: check if coin_sig is the same,
|
||||
-- if so, success, otherwise conflict!
|
||||
SELECT
|
||||
1
|
||||
PERFORM
|
||||
FROM purse_deposits
|
||||
WHERE coin_pub = in_coin_pub
|
||||
AND purse_pub = in_purse_pub
|
||||
@ -2961,7 +2964,11 @@ THEN
|
||||
END IF;
|
||||
|
||||
SELECT
|
||||
1
|
||||
amount_with_fee_val
|
||||
,amount_with_fee_frac
|
||||
INTO
|
||||
my_amount_val
|
||||
,my_amount_frac
|
||||
FROM purse_requests
|
||||
WHERE (purse_pub=in_purse_pub)
|
||||
AND ( ( ( (amount_with_fee_val <= balance_val)
|
||||
@ -2983,15 +2990,15 @@ ELSE
|
||||
-- This is a local reserve, update balance immediately.
|
||||
UPDATE reserves
|
||||
SET
|
||||
current_balance_frac=current_balance_frac+amount_frac
|
||||
current_balance_frac=current_balance_frac+my_amount_frac
|
||||
- CASE
|
||||
WHEN current_balance_frac + amount_frac >= 100000000
|
||||
WHEN current_balance_frac + my_amount_frac >= 100000000
|
||||
THEN 100000000
|
||||
ELSE 0
|
||||
END,
|
||||
current_balance_val=current_balance_val+amount_val
|
||||
current_balance_val=current_balance_val+my_amount_val
|
||||
+ CASE
|
||||
WHEN current_balance_frac + amount_frac >= 100000000
|
||||
WHEN current_balance_frac + my_amount_frac >= 100000000
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
|
@ -3538,6 +3538,7 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
"INSERT INTO purse_requests"
|
||||
" (purse_pub"
|
||||
" ,merge_pub"
|
||||
" ,purse_creation"
|
||||
" ,purse_expiration"
|
||||
" ,h_contract_terms"
|
||||
" ,age_limit"
|
||||
@ -3549,9 +3550,9 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
" ,purse_fee_frac"
|
||||
" ,purse_sig"
|
||||
" ) VALUES "
|
||||
" ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)"
|
||||
" ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"
|
||||
" ON CONFLICT DO NOTHING;",
|
||||
12),
|
||||
13),
|
||||
/* Used in #postgres_select_purse */
|
||||
GNUNET_PQ_make_prepare (
|
||||
"select_purse",
|
||||
@ -13511,12 +13512,14 @@ postgres_insert_purse_request (
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
|
||||
uint32_t flags32 = (uint32_t) flags;
|
||||
bool in_reserve_quota = (TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
|
||||
== (flags & TALER_WAMF_MERGE_MODE_MASK));
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (purse_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (merge_pub),
|
||||
GNUNET_PQ_query_param_timestamp (&now),
|
||||
GNUNET_PQ_query_param_timestamp (&purse_expiration),
|
||||
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
|
||||
GNUNET_PQ_query_param_uint32 (&age_limit),
|
||||
|
Loading…
Reference in New Issue
Block a user