diff options
Diffstat (limited to 'src/exchangedb/pg_select_refunds_by_coin.c')
-rw-r--r-- | src/exchangedb/pg_select_refunds_by_coin.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/src/exchangedb/pg_select_refunds_by_coin.c b/src/exchangedb/pg_select_refunds_by_coin.c index 84b63a719..d9cd6dd3c 100644 --- a/src/exchangedb/pg_select_refunds_by_coin.c +++ b/src/exchangedb/pg_select_refunds_by_coin.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -49,7 +49,7 @@ struct SelectRefundContext /** * Set to #GNUNET_SYSERR on error. */ - int status; + enum GNUNET_GenericReturnValue status; }; @@ -118,42 +118,22 @@ TEH_PG_select_refunds_by_coin ( .pg = pg, .status = GNUNET_OK }; + const char *query = "get_refunds_by_coin_and_contract"; - if (NULL == getenv ("NEW_LOGIC")) - { - PREPARE (pg, - "get_refunds_by_coin_and_contract", - "SELECT" - " ref.amount_with_fee_val" - ",ref.amount_with_fee_frac" - " FROM refunds ref" - " JOIN deposits dep" - " USING (coin_pub,deposit_serial_id)" - " WHERE ref.coin_pub=$1" - " AND dep.merchant_pub=$2" - " AND dep.h_contract_terms=$3;"); - } - else - { - // FIXME-Joseph - PREPARE (pg, - "get_refunds_by_coin_and_contract", - "WITH rc AS MATERIALIZED(" - "SELECT" - " * FROM refunds ref" - "WHERE ref.coin_pub=$1" - "AND dep.merchant_pub=$2" - "AND dep.h_contract_terms=$3" - ")" - "SELECT" - " ref.amount_with_fee_val" - " ,ref.amount_with_fee_frac" - "FROM deposits dep" - "JOIN rc" - " USING (coin_pub,deposit_serial_id)"); - } + PREPARE (pg, + query, + "SELECT" + " ref.amount_with_fee" + " FROM refunds ref" + " JOIN coin_deposits cdep" + " USING (coin_pub,batch_deposit_serial_id)" + " JOIN batch_deposits bdep" + " ON (ref.batch_deposit_serial_id = bdep.batch_deposit_serial_id)" + " WHERE ref.coin_pub=$1" + " AND bdep.merchant_pub=$2" + " AND bdep.h_contract_terms=$3;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "get_refunds_by_coin_and_contract", + query, params, &get_refunds_cb, &srctx); |