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)
,payto_uri VARCHAR NOT NULL
,kyc_ok BOOLEAN NOT NULL DEFAULT (false)
,oauth_username VARCHAR NOT NULL
,oauth_username VARCHAR
,PRIMARY KEY (h_payto)
);
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),
TALER_PQ_query_param_absolute_time (
&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 (
&td->details.reserves_close.wire_target_serial_id),
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[] = {
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 (
&td->details.reserves_out.denom_sig),
GNUNET_PQ_query_param_uint64 (
&td->details.reserves_out.reserve_uuid),
GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_out.reserve_sig),
TALER_PQ_query_param_absolute_time (
&td->details.reserves_out.execution_date),
TALER_PQ_query_param_amount (&td->details.reserves_out.amount_with_fee),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_out.reserve_uuid),
GNUNET_PQ_query_param_uint64 (
&td->details.reserves_out.denominations_serial),
TALER_PQ_query_param_amount (
&td->details.reserves_out.amount_with_fee),
GNUNET_PQ_query_param_end
};
@ -365,7 +369,8 @@ irbt_cb_table_known_coins (struct PostgresClosure *pg,
{
struct GNUNET_PQ_QueryParam params[] = {
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 (
&td->details.known_coins.denom_sig),
GNUNET_PQ_query_param_uint64 (

View File

@ -46,37 +46,50 @@ lrbt_cb_table_denominations (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_uint32 ("denom_type",
&td.details.denominations.denom_type),
GNUNET_PQ_result_spec_uint32 ("age_restrictions",
&td.details.denominations.age_restrictions),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
GNUNET_PQ_result_spec_uint32 (
"denom_type",
&td.details.denominations.denom_type),
GNUNET_PQ_result_spec_uint32 (
"age_restrictions",
&td.details.denominations.age_restrictions),
TALER_PQ_result_spec_denom_pub (
"denom_pub",
&td.details.denominations.denom_pub),
GNUNET_PQ_result_spec_auto_from_type ("master_sig",
&td.details.denominations.master_sig),
TALER_PQ_result_spec_absolute_time ("valid_from",
&td.details.denominations.valid_from),
TALER_PQ_result_spec_absolute_time ("expire_withdraw",
&td.details.denominations.
expire_withdraw),
TALER_PQ_result_spec_absolute_time ("expire_deposit",
&td.details.denominations.
expire_deposit),
TALER_PQ_result_spec_absolute_time ("expire_legal",
&td.details.denominations.expire_legal),
TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
&td.details.denominations.coin),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
&td.details.denominations.fee_withdraw),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
&td.details.denominations.fee_deposit),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
&td.details.denominations.fee_refresh),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
&td.details.denominations.fee_refund),
GNUNET_PQ_result_spec_auto_from_type (
"master_sig",
&td.details.denominations.master_sig),
TALER_PQ_result_spec_absolute_time (
"valid_from",
&td.details.denominations.valid_from),
TALER_PQ_result_spec_absolute_time (
"expire_withdraw",
&td.details.denominations.
expire_withdraw),
TALER_PQ_result_spec_absolute_time (
"expire_deposit",
&td.details.denominations.
expire_deposit),
TALER_PQ_result_spec_absolute_time (
"expire_legal",
&td.details.denominations.expire_legal),
TALER_PQ_RESULT_SPEC_AMOUNT (
"coin",
&td.details.denominations.coin),
TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_withdraw",
&td.details.denominations.fee_withdraw),
TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_deposit",
&td.details.denominations.fee_deposit),
TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_refresh",
&td.details.denominations.fee_refresh),
TALER_PQ_RESULT_SPEC_AMOUNT (
"fee_refund",
&td.details.denominations.fee_refund),
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++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_uint64 ("wire_reference",
&td.details.reserves_in.wire_reference),
TALER_PQ_RESULT_SPEC_AMOUNT ("credit",
&td.details.reserves_in.credit),
GNUNET_PQ_result_spec_uint64 ("sender_account",
&td.details.reserves_in.sender_account),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
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),
TALER_PQ_RESULT_SPEC_AMOUNT (
"credit",
&td.details.reserves_in.credit),
GNUNET_PQ_result_spec_uint64 (
"wire_source_serial_id",
&td.details.reserves_in.sender_account),
GNUNET_PQ_result_spec_string (
"exchange_account_section",
&td.details.reserves_in.exchange_account_section),
TALER_PQ_result_spec_absolute_time ("execution_date",
&td.details.reserves_in.execution_date),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&td.details.reserves_in.reserve_uuid),
TALER_PQ_result_spec_absolute_time (
"execution_date",
&td.details.reserves_in.execution_date),
GNUNET_PQ_result_spec_end
};
@ -316,22 +335,27 @@ lrbt_cb_table_reserves_close (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&td.details.reserves_close.reserve_uuid),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
GNUNET_PQ_result_spec_uint64 (
"reserve_uuid",
&td.details.reserves_close.reserve_uuid),
TALER_PQ_result_spec_absolute_time (
"execution_date",
&td.details.reserves_close.execution_date),
GNUNET_PQ_result_spec_auto_from_type ("wtid",
&td.details.reserves_close.wtid),
GNUNET_PQ_result_spec_auto_from_type (
"wtid",
&td.details.reserves_close.wtid),
GNUNET_PQ_result_spec_uint64 (
"wire_target_serial_id",
&td.details.reserves_close.wire_target_serial_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&td.details.reserves_close.amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
&td.details.reserves_close.closing_fee),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount",
&td.details.reserves_close.amount),
TALER_PQ_RESULT_SPEC_AMOUNT (
"closing_fee",
&td.details.reserves_close.closing_fee),
GNUNET_PQ_result_spec_end
};
@ -641,15 +665,18 @@ lrbt_cb_table_known_coins (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
&td.details.known_coins.coin_pub),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"coin_pub",
&td.details.known_coins.coin_pub),
TALER_PQ_result_spec_denom_sig (
"denom_sig",
&td.details.known_coins.denom_sig),
GNUNET_PQ_result_spec_uint64 ("denominations_serial",
&td.details.known_coins.denominations_serial),
GNUNET_PQ_result_spec_uint64 (
"denominations_serial",
&td.details.known_coins.denominations_serial),
GNUNET_PQ_result_spec_end
};
@ -970,16 +997,21 @@ lrbt_cb_table_refunds (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type ("merchant_sig",
&td.details.refunds.merchant_sig),
GNUNET_PQ_result_spec_uint64 ("rtransaction_id",
&td.details.refunds.rtransaction_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
&td.details.refunds.amount_with_fee),
GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
&td.details.refunds.deposit_serial_id),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"merchant_sig",
&td.details.refunds.merchant_sig),
GNUNET_PQ_result_spec_uint64 (
"rtransaction_id",
&td.details.refunds.rtransaction_id),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
&td.details.refunds.amount_with_fee),
GNUNET_PQ_result_spec_uint64 (
"deposit_serial_id",
&td.details.refunds.deposit_serial_id),
GNUNET_PQ_result_spec_end
};
@ -1076,8 +1108,9 @@ lrbt_cb_table_aggregation_tracking (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
GNUNET_PQ_result_spec_uint64 (
"serial",
&td.serial),
GNUNET_PQ_result_spec_uint64 (
"deposit_serial_id",
&td.details.aggregation_tracking.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 !=
plugin->start (plugin->cls,
"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 !=
plugin->mark_deposit_done (plugin->cls,
deposit_rowid));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
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;
deposit2 = deposit;

View File

@ -2714,26 +2714,6 @@ struct TALER_EXCHANGEDB_Plugin
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
* executed at all anymore, and should no longer be returned by