-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; struct GNUNET_TIME_Timestamp reserve_expiration;
uint64_t partner_id = 0; /* FIXME #7271: WAD support... */ uint64_t partner_id = 0; /* FIXME #7271: WAD support... */
struct GNUNET_PQ_QueryParam params[] = { 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), GNUNET_PQ_query_param_auto_from_type (purse_pub),
TALER_PQ_query_param_amount (amount), TALER_PQ_query_param_amount (amount),
GNUNET_PQ_query_param_auto_from_type (coin_pub), GNUNET_PQ_query_param_auto_from_type (coin_pub),

View File

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

View File

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