-fix foreign key constraint issue

This commit is contained in:
Christian Grothoff 2022-11-27 22:00:24 +01:00
parent 68abe6d9fa
commit 1cdd999c96
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 32 additions and 39 deletions

View File

@ -42,7 +42,9 @@ TEH_PG_do_purse_deposit (
struct GNUNET_TIME_Timestamp reserve_expiration;
uint64_t partner_id = 0; /* FIXME #7271: WAD support... */
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&partner_id),
(0 == partner_id)
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_uint64 (&partner_id),
GNUNET_PQ_query_param_auto_from_type (purse_pub),
TALER_PQ_query_param_amount (amount),
GNUNET_PQ_query_param_auto_from_type (coin_pub),

View File

@ -63,28 +63,25 @@ TEH_PG_insert_purse_request (
};
*in_conflict = false;
PREPARE ( pg,
"insert_purse_request",
"INSERT INTO purse_requests"
" (purse_pub"
" ,merge_pub"
" ,purse_creation"
" ,purse_expiration"
" ,h_contract_terms"
" ,age_limit"
" ,flags"
" ,in_reserve_quota"
" ,amount_with_fee_val"
" ,amount_with_fee_frac"
" ,purse_fee_val"
" ,purse_fee_frac"
" ,purse_sig"
" ) VALUES "
" ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"
" ON CONFLICT DO NOTHING;");
PREPARE (pg,
"insert_purse_request",
"INSERT INTO purse_requests"
" (purse_pub"
" ,merge_pub"
" ,purse_creation"
" ,purse_expiration"
" ,h_contract_terms"
" ,age_limit"
" ,flags"
" ,in_reserve_quota"
" ,amount_with_fee_val"
" ,amount_with_fee_frac"
" ,purse_fee_val"
" ,purse_fee_frac"
" ,purse_sig"
" ) VALUES "
" ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"
" ON CONFLICT DO NOTHING;");
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_purse_request",
params);
@ -100,14 +97,14 @@ TEH_PG_insert_purse_request (
struct TALER_PurseContractSignatureP purse_sig2;
qs = TEH_PG_get_purse_request (pg,
purse_pub,
&merge_pub2,
&purse_expiration2,
&h_contract_terms2,
&age_limit2,
&amount2,
&balance,
&purse_sig2);
purse_pub,
&merge_pub2,
&purse_expiration2,
&h_contract_terms2,
&age_limit2,
&amount2,
&balance,
&purse_sig2);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
GNUNET_break (0);
@ -127,8 +124,3 @@ TEH_PG_insert_purse_request (
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
}

View File

@ -1654,7 +1654,7 @@ BEGIN
IF in_partner_url IS NULL
THEN
my_partner_serial_id=0;
my_partner_serial_id=NULL;
ELSE
SELECT
partner_serial_id
@ -1817,7 +1817,6 @@ ELSE
END IF;
RETURN;
END $$;
@ -1851,7 +1850,7 @@ INSERT INTO exchange.purse_merges
,merge_sig
,merge_timestamp)
VALUES
(0
(NULL
,in_reserve_pub
,in_purse_pub
,in_merge_sig