fixing SQL statements

This commit is contained in:
Christian Grothoff 2021-10-31 13:27:50 +01:00
parent 43ee9da01d
commit 35e3506660
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 2410 additions and 2274 deletions

View File

@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS wire_targets
,h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=64) ,h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=64)
,payto_uri VARCHAR NOT NULL ,payto_uri VARCHAR NOT NULL
,kyc_ok BOOLEAN NOT NULL DEFAULT (false) ,kyc_ok BOOLEAN NOT NULL DEFAULT (false)
,oauth_username VARCHAR NOT NULL ,oauth_username VARCHAR
,PRIMARY KEY (h_payto) ,PRIMARY KEY (h_payto)
); );
COMMENT ON TABLE wire_targets COMMENT ON TABLE wire_targets

View File

@ -198,7 +198,8 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
TALER_PQ_query_param_absolute_time ( TALER_PQ_query_param_absolute_time (
&td->details.reserves_close.execution_date), &td->details.reserves_close.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_close.wtid), GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_close.wtid),
GNUNET_PQ_query_param_uint64 ( GNUNET_PQ_query_param_uint64 (
&td->details.reserves_close.wire_target_serial_id), &td->details.reserves_close.wire_target_serial_id),
TALER_PQ_query_param_amount (&td->details.reserves_close.amount), TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
@ -225,17 +226,20 @@ irbt_cb_table_reserves_out (struct PostgresClosure *pg,
{ {
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_out.h_blind_ev), GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_out.h_blind_ev),
GNUNET_PQ_query_param_uint64 (
&td->details.reserves_out.denominations_serial),
TALER_PQ_query_param_denom_sig ( TALER_PQ_query_param_denom_sig (
&td->details.reserves_out.denom_sig), &td->details.reserves_out.denom_sig),
GNUNET_PQ_query_param_uint64 (
&td->details.reserves_out.reserve_uuid),
GNUNET_PQ_query_param_auto_from_type ( GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_out.reserve_sig), &td->details.reserves_out.reserve_sig),
TALER_PQ_query_param_absolute_time ( TALER_PQ_query_param_absolute_time (
&td->details.reserves_out.execution_date), &td->details.reserves_out.execution_date),
TALER_PQ_query_param_amount (&td->details.reserves_out.amount_with_fee), TALER_PQ_query_param_amount (
GNUNET_PQ_query_param_uint64 (&td->details.reserves_out.reserve_uuid), &td->details.reserves_out.amount_with_fee),
GNUNET_PQ_query_param_uint64 (
&td->details.reserves_out.denominations_serial),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -365,7 +369,8 @@ irbt_cb_table_known_coins (struct PostgresClosure *pg,
{ {
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&td->details.known_coins.coin_pub), GNUNET_PQ_query_param_auto_from_type (
&td->details.known_coins.coin_pub),
TALER_PQ_query_param_denom_sig ( TALER_PQ_query_param_denom_sig (
&td->details.known_coins.denom_sig), &td->details.known_coins.denom_sig),
GNUNET_PQ_query_param_uint64 ( GNUNET_PQ_query_param_uint64 (

View File

@ -46,36 +46,49 @@ lrbt_cb_table_denominations (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_uint32 ("denom_type", GNUNET_PQ_result_spec_uint32 (
"denom_type",
&td.details.denominations.denom_type), &td.details.denominations.denom_type),
GNUNET_PQ_result_spec_uint32 ("age_restrictions", GNUNET_PQ_result_spec_uint32 (
"age_restrictions",
&td.details.denominations.age_restrictions), &td.details.denominations.age_restrictions),
TALER_PQ_result_spec_denom_pub ( TALER_PQ_result_spec_denom_pub (
"denom_pub", "denom_pub",
&td.details.denominations.denom_pub), &td.details.denominations.denom_pub),
GNUNET_PQ_result_spec_auto_from_type ("master_sig", GNUNET_PQ_result_spec_auto_from_type (
"master_sig",
&td.details.denominations.master_sig), &td.details.denominations.master_sig),
TALER_PQ_result_spec_absolute_time ("valid_from", TALER_PQ_result_spec_absolute_time (
"valid_from",
&td.details.denominations.valid_from), &td.details.denominations.valid_from),
TALER_PQ_result_spec_absolute_time ("expire_withdraw", TALER_PQ_result_spec_absolute_time (
"expire_withdraw",
&td.details.denominations. &td.details.denominations.
expire_withdraw), expire_withdraw),
TALER_PQ_result_spec_absolute_time ("expire_deposit", TALER_PQ_result_spec_absolute_time (
"expire_deposit",
&td.details.denominations. &td.details.denominations.
expire_deposit), expire_deposit),
TALER_PQ_result_spec_absolute_time ("expire_legal", TALER_PQ_result_spec_absolute_time (
"expire_legal",
&td.details.denominations.expire_legal), &td.details.denominations.expire_legal),
TALER_PQ_RESULT_SPEC_AMOUNT ("coin", TALER_PQ_RESULT_SPEC_AMOUNT (
"coin",
&td.details.denominations.coin), &td.details.denominations.coin),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw", TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_withdraw",
&td.details.denominations.fee_withdraw), &td.details.denominations.fee_withdraw),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_deposit",
&td.details.denominations.fee_deposit), &td.details.denominations.fee_deposit),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh", TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_refresh",
&td.details.denominations.fee_refresh), &td.details.denominations.fee_refresh),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund", TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_refund",
&td.details.denominations.fee_refund), &td.details.denominations.fee_refund),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -261,21 +274,27 @@ lrbt_cb_table_reserves_in (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_uint64 ("wire_reference", GNUNET_PQ_result_spec_uint64 (
"reserve_uuid",
&td.details.reserves_in.reserve_uuid),
GNUNET_PQ_result_spec_uint64 (
"wire_reference",
&td.details.reserves_in.wire_reference), &td.details.reserves_in.wire_reference),
TALER_PQ_RESULT_SPEC_AMOUNT ("credit", TALER_PQ_RESULT_SPEC_AMOUNT (
"credit",
&td.details.reserves_in.credit), &td.details.reserves_in.credit),
GNUNET_PQ_result_spec_uint64 ("sender_account", GNUNET_PQ_result_spec_uint64 (
"wire_source_serial_id",
&td.details.reserves_in.sender_account), &td.details.reserves_in.sender_account),
GNUNET_PQ_result_spec_string ( GNUNET_PQ_result_spec_string (
"exchange_account_section", "exchange_account_section",
&td.details.reserves_in.exchange_account_section), &td.details.reserves_in.exchange_account_section),
TALER_PQ_result_spec_absolute_time ("execution_date", TALER_PQ_result_spec_absolute_time (
"execution_date",
&td.details.reserves_in.execution_date), &td.details.reserves_in.execution_date),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&td.details.reserves_in.reserve_uuid),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -316,21 +335,26 @@ lrbt_cb_table_reserves_close (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid", GNUNET_PQ_result_spec_uint64 (
"reserve_uuid",
&td.details.reserves_close.reserve_uuid), &td.details.reserves_close.reserve_uuid),
TALER_PQ_result_spec_absolute_time ( TALER_PQ_result_spec_absolute_time (
"execution_date", "execution_date",
&td.details.reserves_close.execution_date), &td.details.reserves_close.execution_date),
GNUNET_PQ_result_spec_auto_from_type ("wtid", GNUNET_PQ_result_spec_auto_from_type (
"wtid",
&td.details.reserves_close.wtid), &td.details.reserves_close.wtid),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_uint64 (
"wire_target_serial_id", "wire_target_serial_id",
&td.details.reserves_close.wire_target_serial_id), &td.details.reserves_close.wire_target_serial_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount", TALER_PQ_RESULT_SPEC_AMOUNT (
"amount",
&td.details.reserves_close.amount), &td.details.reserves_close.amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", TALER_PQ_RESULT_SPEC_AMOUNT (
"closing_fee",
&td.details.reserves_close.closing_fee), &td.details.reserves_close.closing_fee),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -641,14 +665,17 @@ lrbt_cb_table_known_coins (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_auto_from_type ("coin_pub", GNUNET_PQ_result_spec_auto_from_type (
"coin_pub",
&td.details.known_coins.coin_pub), &td.details.known_coins.coin_pub),
TALER_PQ_result_spec_denom_sig ( TALER_PQ_result_spec_denom_sig (
"denom_sig", "denom_sig",
&td.details.known_coins.denom_sig), &td.details.known_coins.denom_sig),
GNUNET_PQ_result_spec_uint64 ("denominations_serial", GNUNET_PQ_result_spec_uint64 (
"denominations_serial",
&td.details.known_coins.denominations_serial), &td.details.known_coins.denominations_serial),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -970,15 +997,20 @@ lrbt_cb_table_refunds (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_auto_from_type ("merchant_sig", GNUNET_PQ_result_spec_auto_from_type (
"merchant_sig",
&td.details.refunds.merchant_sig), &td.details.refunds.merchant_sig),
GNUNET_PQ_result_spec_uint64 ("rtransaction_id", GNUNET_PQ_result_spec_uint64 (
"rtransaction_id",
&td.details.refunds.rtransaction_id), &td.details.refunds.rtransaction_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
&td.details.refunds.amount_with_fee), &td.details.refunds.amount_with_fee),
GNUNET_PQ_result_spec_uint64 ("deposit_serial_id", GNUNET_PQ_result_spec_uint64 (
"deposit_serial_id",
&td.details.refunds.deposit_serial_id), &td.details.refunds.deposit_serial_id),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -1076,7 +1108,8 @@ lrbt_cb_table_aggregation_tracking (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_uint64 (
"deposit_serial_id", "deposit_serial_id",

File diff suppressed because it is too large Load Diff

View File

@ -1893,21 +1893,11 @@ run (void *cls)
FAILIF (GNUNET_OK != FAILIF (GNUNET_OK !=
plugin->start (plugin->cls, plugin->start (plugin->cls,
"test-3")); "test-3"));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->test_deposit_done (plugin->cls,
&deposit.coin.coin_pub,
&deposit.merchant_pub,
&deposit.h_contract_terms));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->mark_deposit_done (plugin->cls, plugin->mark_deposit_done (plugin->cls,
deposit_rowid)); deposit_rowid));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->commit (plugin->cls)); plugin->commit (plugin->cls));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->test_deposit_done (plugin->cls,
&deposit.coin.coin_pub,
&deposit.merchant_pub,
&deposit.h_contract_terms));
result = 10; result = 10;
deposit2 = deposit; deposit2 = deposit;

View File

@ -2714,26 +2714,6 @@ struct TALER_EXCHANGEDB_Plugin
uint64_t rowid); uint64_t rowid);
/**
* Test if a deposit was marked as done, thereby declaring that it
* cannot be refunded anymore.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param coin_pub the coin to check for deposit
* @param merchant_pub merchant to receive the deposit
* @param h_contract_terms contract terms of the deposit
* @return #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if is is marked done,
* #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if not,
* otherwise transaction error status (incl. deposit unknown)
*/
enum GNUNET_DB_QueryStatus
(*test_deposit_done)(void *cls,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct
TALER_PrivateContractHash *h_contract_terms);
/** /**
* Mark a deposit as done, thereby declaring that it cannot be * Mark a deposit as done, thereby declaring that it cannot be
* executed at all anymore, and should no longer be returned by * executed at all anymore, and should no longer be returned by