diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-07-30 12:01:51 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-07-30 12:02:04 +0200 |
commit | b9ecc4113db28da3dce9c5d9c15ac2d0317dc2fd (patch) | |
tree | 99b71aede2ffce5efce4593f77ff10876fae9fa6 | |
parent | eb8f0be35dc2e058df213e183a935772d172e6c3 (diff) |
migrating auditordb to use amount tuples
33 files changed, 312 insertions, 392 deletions
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql index 01214d53e..f397f0569 100644 --- a/src/auditordb/auditor-0001.sql +++ b/src/auditordb/auditor-0001.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2022 Taler Systems SA +-- Copyright (C) 2014--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 @@ -20,12 +20,19 @@ BEGIN; -- Check patch versioning is in place. SELECT _v.register_patch('auditor-0001', NULL, NULL); - CREATE SCHEMA auditor; COMMENT ON SCHEMA auditor IS 'taler-auditor data'; SET search_path TO auditor; +CREATE TYPE taler_amount + AS + (val INT8 + ,frac INT4 + ); +COMMENT ON TYPE taler_amount + IS 'Stores an amount, fraction is in units of 1/100000000 of the base value'; + CREATE TABLE IF NOT EXISTS auditor_exchanges (master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32) @@ -141,20 +148,13 @@ CREATE TABLE IF NOT EXISTS wire_auditor_progress CREATE TABLE IF NOT EXISTS auditor_reserves (reserve_pub BYTEA NOT NULL CHECK(LENGTH(reserve_pub)=32) ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,reserve_balance_val INT8 NOT NULL - ,reserve_balance_frac INT4 NOT NULL - ,reserve_loss_val INT8 NOT NULL - ,reserve_loss_frac INT4 NOT NULL - ,withdraw_fee_balance_val INT8 NOT NULL - ,withdraw_fee_balance_frac INT4 NOT NULL - ,close_fee_balance_val INT8 NOT NULL - ,close_fee_balance_frac INT4 NOT NULL - ,purse_fee_balance_val INT8 NOT NULL - ,purse_fee_balance_frac INT4 NOT NULL - ,open_fee_balance_val INT8 NOT NULL - ,open_fee_balance_frac INT4 NOT NULL - ,history_fee_balance_val INT8 NOT NULL - ,history_fee_balance_frac INT4 NOT NULL + ,reserve_balance taler_amount NOT NULL + ,reserve_loss taler_amount NOT NULL + ,withdraw_fee_balance taler_amount NOT NULL + ,close_fee_balance taler_amount NOT NULL + ,purse_fee_balance taler_amount NOT NULL + ,open_fee_balance taler_amount NOT NULL + ,history_fee_balance taler_amount NOT NULL ,expiration_date INT8 NOT NULL ,auditor_reserves_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE ,origin_account TEXT @@ -170,10 +170,8 @@ CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub CREATE TABLE IF NOT EXISTS auditor_purses (purse_pub BYTEA NOT NULL CHECK(LENGTH(purse_pub)=32) ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,balance_val INT8 NOT NULL DEFAULT(0) - ,balance_frac INT4 NOT NULL DEFAULT(0) - ,target_val INT8 NOT NULL - ,target_frac INT4 NOT NULL + ,balance taler_amount NOT NULL DEFAULT(0,0) + ,target taler_amount NOT NULL ,expiration_date INT8 NOT NULL ,auditor_purses_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE ); @@ -187,8 +185,7 @@ CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub CREATE TABLE IF NOT EXISTS auditor_purse_summary (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,balance_val INT8 NOT NULL - ,balance_frac INT4 NOT NULL + ,balance taler_amount NOT NULL ,open_purses INT8 NOT NULL ); COMMENT ON TABLE auditor_purse_summary @@ -196,20 +193,13 @@ COMMENT ON TABLE auditor_purse_summary CREATE TABLE IF NOT EXISTS auditor_reserve_balance (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,reserve_balance_val INT8 NOT NULL - ,reserve_balance_frac INT4 NOT NULL - ,reserve_loss_val INT8 NOT NULL - ,reserve_loss_frac INT4 NOT NULL - ,withdraw_fee_balance_val INT8 NOT NULL - ,withdraw_fee_balance_frac INT4 NOT NULL - ,close_fee_balance_val INT8 NOT NULL - ,close_fee_balance_frac INT4 NOT NULL - ,purse_fee_balance_val INT8 NOT NULL - ,purse_fee_balance_frac INT4 NOT NULL - ,open_fee_balance_val INT8 NOT NULL - ,open_fee_balance_frac INT4 NOT NULL - ,history_fee_balance_val INT8 NOT NULL - ,history_fee_balance_frac INT4 NOT NULL + ,reserve_balance taler_amount NOT NULL + ,reserve_loss taler_amount NOT NULL + ,withdraw_fee_balance taler_amount NOT NULL + ,close_fee_balance taler_amount NOT NULL + ,purse_fee_balance taler_amount NOT NULL + ,open_fee_balance taler_amount NOT NULL + ,history_fee_balance taler_amount NOT NULL ); COMMENT ON TABLE auditor_reserve_balance IS 'sum of the balances of all customer reserves (by exchange master public key)'; @@ -217,8 +207,7 @@ COMMENT ON TABLE auditor_reserve_balance CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,wire_fee_balance_val INT8 NOT NULL - ,wire_fee_balance_frac INT4 NOT NULL + ,wire_fee_balance taler_amount NOT NULL ); COMMENT ON TABLE auditor_wire_fee_balance IS 'sum of the balances of all wire fees (by exchange master public key)'; @@ -226,52 +215,39 @@ COMMENT ON TABLE auditor_wire_fee_balance CREATE TABLE IF NOT EXISTS auditor_denomination_pending (denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) - ,denom_balance_val INT8 NOT NULL - ,denom_balance_frac INT4 NOT NULL - ,denom_loss_val INT8 NOT NULL - ,denom_loss_frac INT4 NOT NULL + ,denom_balance taler_amount NOT NULL + ,denom_loss taler_amount NOT NULL ,num_issued INT8 NOT NULL - ,denom_risk_val INT8 NOT NULL - ,denom_risk_frac INT4 NOT NULL - ,recoup_loss_val INT8 NOT NULL - ,recoup_loss_frac INT4 NOT NULL + ,denom_risk taler_amount NOT NULL + ,recoup_loss taler_amount NOT NULL ); COMMENT ON TABLE auditor_denomination_pending IS 'outstanding denomination coins that the exchange is aware of and what the respective balances are (outstanding as well as issued overall which implies the maximum value at risk).'; COMMENT ON COLUMN auditor_denomination_pending.num_issued IS 'counts the number of coins issued (withdraw, refresh) of this denomination'; -COMMENT ON COLUMN auditor_denomination_pending.denom_risk_val +COMMENT ON COLUMN auditor_denomination_pending.denom_risk IS 'amount that could theoretically be lost in the future due to recoup operations'; -COMMENT ON COLUMN auditor_denomination_pending.denom_loss_val +COMMENT ON COLUMN auditor_denomination_pending.denom_loss IS 'amount that was lost due to failures by the exchange'; -COMMENT ON COLUMN auditor_denomination_pending.recoup_loss_val +COMMENT ON COLUMN auditor_denomination_pending.recoup_loss IS 'amount actually lost due to recoup operations after a revocation'; CREATE TABLE IF NOT EXISTS auditor_balance_summary (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,denom_balance_val INT8 NOT NULL - ,denom_balance_frac INT4 NOT NULL - ,deposit_fee_balance_val INT8 NOT NULL - ,deposit_fee_balance_frac INT4 NOT NULL - ,melt_fee_balance_val INT8 NOT NULL - ,melt_fee_balance_frac INT4 NOT NULL - ,refund_fee_balance_val INT8 NOT NULL - ,refund_fee_balance_frac INT4 NOT NULL - ,purse_fee_balance_val INT8 NOT NULL - ,purse_fee_balance_frac INT4 NOT NULL - ,open_deposit_fee_balance_val INT8 NOT NULL - ,open_deposit_fee_balance_frac INT4 NOT NULL - ,risk_val INT8 NOT NULL - ,risk_frac INT4 NOT NULL - ,loss_val INT8 NOT NULL - ,loss_frac INT4 NOT NULL - ,irregular_loss_val INT8 NOT NULL - ,irregular_loss_frac INT4 NOT NULL + ,denom_balance taler_amount NOT NULL + ,deposit_fee_balance taler_amount NOT NULL + ,melt_fee_balance taler_amount NOT NULL + ,refund_fee_balance taler_amount NOT NULL + ,purse_fee_balance taler_amount NOT NULL + ,open_deposit_fee_balance taler_amount NOT NULL + ,risk taler_amount NOT NULL + ,loss taler_amount NOT NULL + ,irregular_loss taler_amount NOT NULL ); COMMENT ON TABLE auditor_balance_summary IS 'the sum of the outstanding coins from auditor_denomination_pending (denom_pubs must belong to the respectives exchange master public key); it represents the auditor_balance_summary of the exchange at this point (modulo unexpected historic_loss-style events where denomination keys are compromised)'; -COMMENT ON COLUMN auditor_balance_summary.denom_balance_frac +COMMENT ON COLUMN auditor_balance_summary.denom_balance IS 'total amount we should have in escrow for all denominations'; @@ -279,14 +255,12 @@ CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE ,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) ,revenue_timestamp INT8 NOT NULL - ,revenue_balance_val INT8 NOT NULL - ,revenue_balance_frac INT4 NOT NULL - ,loss_balance_val INT8 NOT NULL - ,loss_balance_frac INT4 NOT NULL + ,revenue_balance taler_amount NOT NULL + ,loss_balance taler_amount NOT NULL ); COMMENT ON TABLE auditor_historic_denomination_revenue IS 'Table with historic profits; basically, when a denom_pub has expired and everything associated with it is garbage collected, the final profits end up in here; note that the denom_pub here is not a foreign key, we just keep it as a reference point.'; -COMMENT ON COLUMN auditor_historic_denomination_revenue.revenue_balance_val +COMMENT ON COLUMN auditor_historic_denomination_revenue.revenue_balance IS 'the sum of all of the profits we made on the coin except for withdraw fees (which are in historic_reserve_revenue); so this includes the deposit, melt and refund fees'; @@ -294,8 +268,7 @@ CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE ,start_date INT8 NOT NULL ,end_date INT8 NOT NULL - ,reserve_profits_val INT8 NOT NULL - ,reserve_profits_frac INT4 NOT NULL + ,reserve_profits taler_amount NOT NULL ); COMMENT ON TABLE auditor_historic_reserve_summary IS 'historic profits from reserves; we eventually GC auditor_historic_reserve_revenue, and then store the totals in here (by time intervals).'; @@ -315,8 +288,7 @@ CREATE TABLE IF NOT EXISTS deposit_confirmations ,exchange_timestamp INT8 NOT NULL ,refund_deadline INT8 NOT NULL ,wire_deadline INT8 NOT NULL - ,amount_without_fee_val INT8 NOT NULL - ,amount_without_fee_frac INT4 NOT NULL + ,amount_without_fee taler_amount NOT NULL ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32) ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32) ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) @@ -330,10 +302,8 @@ COMMENT ON TABLE deposit_confirmations CREATE TABLE IF NOT EXISTS auditor_predicted_result (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,balance_val INT8 NOT NULL - ,balance_frac INT4 NOT NULL - ,drained_val INT8 NOT NULL - ,drained_frac INT4 NOT NULL + ,balance taler_amount NOT NULL + ,drained taler_amount NOT NULL ); COMMENT ON TABLE auditor_predicted_result IS 'Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance and the drained profits. This is the final amount that the exchange should have in its bank account right now (and the total amount drained as profits to non-escrow accounts).'; diff --git a/src/auditordb/pg_get_balance_summary.c b/src/auditordb/pg_get_balance_summary.c index a8ba733bb..b2706aeb0 100644 --- a/src/auditordb/pg_get_balance_summary.c +++ b/src/auditordb/pg_get_balance_summary.c @@ -62,24 +62,15 @@ TAH_PG_get_balance_summary ( PREPARE (pg, "auditor_balance_summary_select", "SELECT" - " denom_balance_val" - ",denom_balance_frac" - ",deposit_fee_balance_val" - ",deposit_fee_balance_frac" - ",melt_fee_balance_val" - ",melt_fee_balance_frac" - ",refund_fee_balance_val" - ",refund_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_deposit_fee_balance_val" - ",open_deposit_fee_balance_frac" - ",risk_val" - ",risk_frac" - ",loss_val" - ",loss_frac" - ",irregular_loss_val" - ",irregular_loss_frac" + " denom_balance" + ",deposit_fee_balance" + ",melt_fee_balance" + ",refund_fee_balance" + ",purse_fee_balance" + ",open_deposit_fee_balance" + ",risk" + ",loss" + ",irregular_loss" " FROM auditor_balance_summary" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_get_denomination_balance.c b/src/auditordb/pg_get_denomination_balance.c index 10d5a4be7..40af766cd 100644 --- a/src/auditordb/pg_get_denomination_balance.c +++ b/src/auditordb/pg_get_denomination_balance.c @@ -54,15 +54,11 @@ TAH_PG_get_denomination_balance ( PREPARE (pg, "auditor_denomination_pending_select", "SELECT" - " denom_balance_val" - ",denom_balance_frac" - ",denom_loss_val" - ",denom_loss_frac" + " denom_balance" + ",denom_loss" ",num_issued" - ",denom_risk_val" - ",denom_risk_frac" - ",recoup_loss_val" - ",recoup_loss_frac" + ",denom_risk" + ",recoup_loss" " FROM auditor_denomination_pending" " WHERE denom_pub_hash=$1"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index 3f0bd1e2f..56306e105 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -163,8 +163,7 @@ TAH_PG_get_deposit_confirmations ( ",exchange_timestamp" ",wire_deadline" ",refund_deadline" - ",amount_without_fee_val" - ",amount_without_fee_frac" + ",amount_without_fee" ",coin_pub" ",merchant_pub" ",exchange_sig" diff --git a/src/auditordb/pg_get_predicted_balance.c b/src/auditordb/pg_get_predicted_balance.c index 07d1faae4..583a63fd4 100644 --- a/src/auditordb/pg_get_predicted_balance.c +++ b/src/auditordb/pg_get_predicted_balance.c @@ -48,10 +48,8 @@ TAH_PG_get_predicted_balance (void *cls, PREPARE (pg, "auditor_predicted_result_select", "SELECT" - " balance_val" - ",balance_frac" - ",drained_val" - ",drained_frac" + " balance" + ",drained" " FROM auditor_predicted_result" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_get_purse_info.c b/src/auditordb/pg_get_purse_info.c index aa0f3027d..df11bdbc9 100644 --- a/src/auditordb/pg_get_purse_info.c +++ b/src/auditordb/pg_get_purse_info.c @@ -54,8 +54,7 @@ TAH_PG_get_purse_info ( "auditor_get_purse_info", "SELECT" " expiration_date" - ",balance_val" - ",balance_frac" + ",balance" " FROM auditor_purses" " WHERE purse_pub=$1" " AND master_pub=$2;"); diff --git a/src/auditordb/pg_get_purse_summary.c b/src/auditordb/pg_get_purse_summary.c index 1c5e8a36f..cc40a21e1 100644 --- a/src/auditordb/pg_get_purse_summary.c +++ b/src/auditordb/pg_get_purse_summary.c @@ -48,8 +48,7 @@ TAH_PG_get_purse_summary (void *cls, "auditor_get_purse_summary", "SELECT" " open_purses" - ",balance_val" - ",balance_frac" + ",balance" " FROM auditor_purse_summary" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_get_reserve_info.c b/src/auditordb/pg_get_reserve_info.c index 6beb0c8de..3cfc3a613 100644 --- a/src/auditordb/pg_get_reserve_info.c +++ b/src/auditordb/pg_get_reserve_info.c @@ -71,20 +71,13 @@ TAH_PG_get_reserve_info (void *cls, PREPARE (pg, "auditor_reserves_select", "SELECT" - " reserve_balance_val" - ",reserve_balance_frac" - ",reserve_loss_val" - ",reserve_loss_frac" - ",withdraw_fee_balance_val" - ",withdraw_fee_balance_frac" - ",close_fee_balance_val" - ",close_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_fee_balance_val" - ",open_fee_balance_frac" - ",history_fee_balance_val" - ",history_fee_balance_frac" + " reserve_balance" + ",reserve_loss" + ",withdraw_fee_balance" + ",close_fee_balance" + ",purse_fee_balance" + ",open_fee_balance" + ",history_fee_balance" ",expiration_date" ",auditor_reserves_rowid" ",origin_account" diff --git a/src/auditordb/pg_get_reserve_summary.c b/src/auditordb/pg_get_reserve_summary.c index 225d7e6a8..e314afa1a 100644 --- a/src/auditordb/pg_get_reserve_summary.c +++ b/src/auditordb/pg_get_reserve_summary.c @@ -65,20 +65,13 @@ TAH_PG_get_reserve_summary (void *cls, PREPARE (pg, "auditor_reserve_balance_select", "SELECT" - " reserve_balance_val" - ",reserve_balance_frac" - ",reserve_loss_val" - ",reserve_loss_frac" - ",withdraw_fee_balance_val" - ",withdraw_fee_balance_frac" - ",close_fee_balance_val" - ",close_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_fee_balance_val" - ",open_fee_balance_frac" - ",history_fee_balance_val" - ",history_fee_balance_frac" + " reserve_balance" + ",reserve_loss" + ",withdraw_fee_balance" + ",close_fee_balance" + ",purse_fee_balance" + ",open_fee_balance" + ",history_fee_balance" " FROM auditor_reserve_balance" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_get_wire_fee_summary.c b/src/auditordb/pg_get_wire_fee_summary.c index 8b48a4d47..36ed19996 100644 --- a/src/auditordb/pg_get_wire_fee_summary.c +++ b/src/auditordb/pg_get_wire_fee_summary.c @@ -53,8 +53,7 @@ TAH_PG_get_wire_fee_summary (void *cls, PREPARE (pg, "auditor_wire_fee_balance_select", "SELECT" - " wire_fee_balance_val" - ",wire_fee_balance_frac" + " wire_fee_balance" " FROM auditor_wire_fee_balance" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_helper.h b/src/auditordb/pg_helper.h index 7ebe5a179..3672a2a55 100644 --- a/src/auditordb/pg_helper.h +++ b/src/auditordb/pg_helper.h @@ -111,19 +111,8 @@ struct PostgresClosure * @param field name of the database field to fetch amount from * @param[out] amountp pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount ( \ - field,pg->currency,amountp) - - -/** - * Wrapper macro to add the currency from the plugin's state - * when fetching amounts from the database. NBO variant. - * - * @param field name of the database field to fetch amount from - * @param[out] amountp pointer to amount to set - */ -#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field, \ - amountp) TALER_PQ_result_spec_amount_nbo ( \ +#define TALER_PQ_RESULT_SPEC_AMOUNT(field, \ + amountp) TALER_PQ_result_spec_amount_tuple ( \ field,pg->currency,amountp) diff --git a/src/auditordb/pg_insert_balance_summary.c b/src/auditordb/pg_insert_balance_summary.c index a965eefa6..048449da1 100644 --- a/src/auditordb/pg_insert_balance_summary.c +++ b/src/auditordb/pg_insert_balance_summary.c @@ -35,15 +35,24 @@ TAH_PG_insert_balance_summary ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (&dfb->total_escrowed), - TALER_PQ_query_param_amount (&dfb->deposit_fee_balance), - TALER_PQ_query_param_amount (&dfb->melt_fee_balance), - TALER_PQ_query_param_amount (&dfb->refund_fee_balance), - TALER_PQ_query_param_amount (&dfb->purse_fee_balance), - TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance), - TALER_PQ_query_param_amount (&dfb->risk), - TALER_PQ_query_param_amount (&dfb->loss), - TALER_PQ_query_param_amount (&dfb->irregular_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->total_escrowed), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->deposit_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->melt_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->refund_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->open_deposit_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->risk), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->irregular_loss), GNUNET_PQ_query_param_end }; @@ -51,26 +60,16 @@ TAH_PG_insert_balance_summary ( "auditor_balance_summary_insert", "INSERT INTO auditor_balance_summary " "(master_pub" - ",denom_balance_val" - ",denom_balance_frac" - ",deposit_fee_balance_val" - ",deposit_fee_balance_frac" - ",melt_fee_balance_val" - ",melt_fee_balance_frac" - ",refund_fee_balance_val" - ",refund_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_deposit_fee_balance_val" - ",open_deposit_fee_balance_frac" - ",risk_val" - ",risk_frac" - ",loss_val" - ",loss_frac" - ",irregular_loss_val" - ",irregular_loss_frac" - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10," - " $11,$12,$13,$14,$15,$16,$17,$18,$19);"); + ",denom_balance" + ",deposit_fee_balance" + ",melt_fee_balance" + ",refund_fee_balance" + ",purse_fee_balance" + ",open_deposit_fee_balance" + ",risk" + ",loss" + ",irregular_loss" + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_balance_summary_insert", params); diff --git a/src/auditordb/pg_insert_denomination_balance.c b/src/auditordb/pg_insert_denomination_balance.c index 324c872a4..e860ff578 100644 --- a/src/auditordb/pg_insert_denomination_balance.c +++ b/src/auditordb/pg_insert_denomination_balance.c @@ -35,11 +35,15 @@ TAH_PG_insert_denomination_balance ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), - TALER_PQ_query_param_amount (&dcd->denom_balance), - TALER_PQ_query_param_amount (&dcd->denom_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_loss), GNUNET_PQ_query_param_uint64 (&dcd->num_issued), - TALER_PQ_query_param_amount (&dcd->denom_risk), - TALER_PQ_query_param_amount (&dcd->recoup_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_risk), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->recoup_loss), GNUNET_PQ_query_param_end }; @@ -47,17 +51,13 @@ TAH_PG_insert_denomination_balance ( "auditor_denomination_pending_insert", "INSERT INTO auditor_denomination_pending " "(denom_pub_hash" - ",denom_balance_val" - ",denom_balance_frac" - ",denom_loss_val" - ",denom_loss_frac" + ",denom_balance" + ",denom_loss" ",num_issued" - ",denom_risk_val" - ",denom_risk_frac" - ",recoup_loss_val" - ",recoup_loss_frac" + ",denom_risk" + ",recoup_loss" ") VALUES (" - "$1,$2,$3,$4,$5,$6,$7,$8,$9,$10" + "$1,$2,$3,$4,$5,$6" ");"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_denomination_pending_insert", diff --git a/src/auditordb/pg_insert_deposit_confirmation.c b/src/auditordb/pg_insert_deposit_confirmation.c index 675f8ed0d..31d4ea982 100644 --- a/src/auditordb/pg_insert_deposit_confirmation.c +++ b/src/auditordb/pg_insert_deposit_confirmation.c @@ -40,7 +40,8 @@ TAH_PG_insert_deposit_confirmation ( GNUNET_PQ_query_param_timestamp (&dc->exchange_timestamp), GNUNET_PQ_query_param_timestamp (&dc->wire_deadline), GNUNET_PQ_query_param_timestamp (&dc->refund_deadline), - TALER_PQ_query_param_amount (&dc->amount_without_fee), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dc->amount_without_fee), GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub), GNUNET_PQ_query_param_auto_from_type (&dc->merchant), GNUNET_PQ_query_param_auto_from_type (&dc->exchange_sig), @@ -59,14 +60,13 @@ TAH_PG_insert_deposit_confirmation ( ",exchange_timestamp" ",wire_deadline" ",refund_deadline" - ",amount_without_fee_val" - ",amount_without_fee_frac" + ",amount_without_fee" ",coin_pub" ",merchant_pub" ",exchange_sig" ",exchange_pub" ",master_sig" /* master_sig could be normalized... */ - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);"); + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_deposit_confirmation_insert", params); diff --git a/src/auditordb/pg_insert_historic_denom_revenue.c b/src/auditordb/pg_insert_historic_denom_revenue.c index d44d37340..730904419 100644 --- a/src/auditordb/pg_insert_historic_denom_revenue.c +++ b/src/auditordb/pg_insert_historic_denom_revenue.c @@ -40,8 +40,10 @@ TAH_PG_insert_historic_denom_revenue ( GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), GNUNET_PQ_query_param_timestamp (&revenue_timestamp), - TALER_PQ_query_param_amount (revenue_balance), - TALER_PQ_query_param_amount (loss_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + revenue_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + loss_balance), GNUNET_PQ_query_param_end }; @@ -51,11 +53,9 @@ TAH_PG_insert_historic_denom_revenue ( "(master_pub" ",denom_pub_hash" ",revenue_timestamp" - ",revenue_balance_val" - ",revenue_balance_frac" - ",loss_balance_val" - ",loss_balance_frac" - ") VALUES ($1,$2,$3,$4,$5,$6,$7);"); + ",revenue_balance" + ",loss_balance" + ") VALUES ($1,$2,$3,$4,$5);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_historic_denomination_revenue_insert", params); diff --git a/src/auditordb/pg_insert_historic_reserve_revenue.c b/src/auditordb/pg_insert_historic_reserve_revenue.c index 8218aab70..43fc7e343 100644 --- a/src/auditordb/pg_insert_historic_reserve_revenue.c +++ b/src/auditordb/pg_insert_historic_reserve_revenue.c @@ -38,7 +38,8 @@ TAH_PG_insert_historic_reserve_revenue ( GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_timestamp (&start_time), GNUNET_PQ_query_param_timestamp (&end_time), - TALER_PQ_query_param_amount (reserve_profits), + TALER_PQ_query_param_amount_tuple (pg->conn, + reserve_profits), GNUNET_PQ_query_param_end }; @@ -48,9 +49,8 @@ TAH_PG_insert_historic_reserve_revenue ( "(master_pub" ",start_date" ",end_date" - ",reserve_profits_val" - ",reserve_profits_frac" - ") VALUES ($1,$2,$3,$4,$5);"); + ",reserve_profits" + ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_historic_reserve_summary_insert", params); diff --git a/src/auditordb/pg_insert_predicted_result.c b/src/auditordb/pg_insert_predicted_result.c index 4e8e54201..070c7b76e 100644 --- a/src/auditordb/pg_insert_predicted_result.c +++ b/src/auditordb/pg_insert_predicted_result.c @@ -36,8 +36,10 @@ TAH_PG_insert_predicted_result ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (balance), - TALER_PQ_query_param_amount (drained), + TALER_PQ_query_param_amount_tuple (pg->conn, + balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + drained), GNUNET_PQ_query_param_end }; @@ -45,11 +47,9 @@ TAH_PG_insert_predicted_result ( "auditor_predicted_result_insert", "INSERT INTO auditor_predicted_result" "(master_pub" - ",balance_val" - ",balance_frac" - ",drained_val" - ",drained_frac" - ") VALUES ($1,$2,$3,$4,$5);"); + ",balance" + ",drained" + ") VALUES ($1,$2,$3);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_predicted_result_insert", params); diff --git a/src/auditordb/pg_insert_purse_info.c b/src/auditordb/pg_insert_purse_info.c index f82f9e1de..4c3a6f066 100644 --- a/src/auditordb/pg_insert_purse_info.c +++ b/src/auditordb/pg_insert_purse_info.c @@ -38,7 +38,8 @@ TAH_PG_insert_purse_info ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (purse_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + balance), GNUNET_PQ_query_param_timestamp (&expiration_date), GNUNET_PQ_query_param_end }; @@ -48,10 +49,9 @@ TAH_PG_insert_purse_info ( "INSERT INTO auditor_purses " "(purse_pub" ",master_pub" - ",target_val" - ",target_frac" + ",target" ",expiration_date" - ") VALUES ($1,$2,$3,$4,$5);"); + ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_purses_insert", params); diff --git a/src/auditordb/pg_insert_purse_summary.c b/src/auditordb/pg_insert_purse_summary.c index f058815f4..4c848c2dc 100644 --- a/src/auditordb/pg_insert_purse_summary.c +++ b/src/auditordb/pg_insert_purse_summary.c @@ -35,7 +35,8 @@ TAH_PG_insert_purse_summary ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (&sum->balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &sum->balance), GNUNET_PQ_query_param_uint64 (&sum->open_purses), GNUNET_PQ_query_param_end }; @@ -44,10 +45,9 @@ TAH_PG_insert_purse_summary ( "auditor_purse_summary_insert", "INSERT INTO auditor_purse_summary " "(master_pub" - ",balance_val" - ",balance_frac" + ",balance" ",open_purses" - ") VALUES ($1,$2,$3,$4);"); + ") VALUES ($1,$2,$3);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_purse_summary_insert", params); diff --git a/src/auditordb/pg_insert_reserve_info.c b/src/auditordb/pg_insert_reserve_info.c index 22b17819e..782f6534b 100644 --- a/src/auditordb/pg_insert_reserve_info.c +++ b/src/auditordb/pg_insert_reserve_info.c @@ -39,13 +39,20 @@ TAH_PG_insert_reserve_info ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (&rfb->reserve_balance), - TALER_PQ_query_param_amount (&rfb->reserve_loss), - TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance), - TALER_PQ_query_param_amount (&rfb->close_fee_balance), - TALER_PQ_query_param_amount (&rfb->purse_fee_balance), - TALER_PQ_query_param_amount (&rfb->open_fee_balance), - TALER_PQ_query_param_amount (&rfb->history_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->withdraw_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->close_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->open_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->history_fee_balance), GNUNET_PQ_query_param_timestamp (&expiration_date), NULL == origin_account ? GNUNET_PQ_query_param_null () @@ -58,26 +65,18 @@ TAH_PG_insert_reserve_info ( "INSERT INTO auditor_reserves " "(reserve_pub" ",master_pub" - ",reserve_balance_val" - ",reserve_balance_frac" - ",reserve_loss_val" - ",reserve_loss_frac" - ",withdraw_fee_balance_val" - ",withdraw_fee_balance_frac" - ",close_fee_balance_val" - ",close_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_fee_balance_val" - ",open_fee_balance_frac" - ",history_fee_balance_val" - ",history_fee_balance_frac" + ",reserve_balance" + ",reserve_loss" + ",withdraw_fee_balance" + ",close_fee_balance" + ",purse_fee_balance" + ",open_fee_balance" + ",history_fee_balance" ",expiration_date" ",origin_account" ") VALUES " - "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18);"); - + "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserves_insert", params); diff --git a/src/auditordb/pg_insert_reserve_summary.c b/src/auditordb/pg_insert_reserve_summary.c index bcae388f5..a6c0985f9 100644 --- a/src/auditordb/pg_insert_reserve_summary.c +++ b/src/auditordb/pg_insert_reserve_summary.c @@ -35,13 +35,20 @@ TAH_PG_insert_reserve_summary ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (&rfb->reserve_balance), - TALER_PQ_query_param_amount (&rfb->reserve_loss), - TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance), - TALER_PQ_query_param_amount (&rfb->close_fee_balance), - TALER_PQ_query_param_amount (&rfb->purse_fee_balance), - TALER_PQ_query_param_amount (&rfb->open_fee_balance), - TALER_PQ_query_param_amount (&rfb->history_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->withdraw_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->close_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->open_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->history_fee_balance), GNUNET_PQ_query_param_end }; @@ -49,22 +56,15 @@ TAH_PG_insert_reserve_summary ( "auditor_reserve_balance_insert", "INSERT INTO auditor_reserve_balance" "(master_pub" - ",reserve_balance_val" - ",reserve_balance_frac" - ",reserve_loss_val" - ",reserve_loss_frac" - ",withdraw_fee_balance_val" - ",withdraw_fee_balance_frac" - ",close_fee_balance_val" - ",close_fee_balance_frac" - ",purse_fee_balance_val" - ",purse_fee_balance_frac" - ",open_fee_balance_val" - ",open_fee_balance_frac" - ",history_fee_balance_val" - ",history_fee_balance_frac" + ",reserve_balance" + ",reserve_loss" + ",withdraw_fee_balance" + ",close_fee_balance" + ",purse_fee_balance" + ",open_fee_balance" + ",history_fee_balance" ") VALUES " - "($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)"); + "($1,$2,$3,$4,$5,$6,$7,$8)"); GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency (&rfb->reserve_balance, &rfb->withdraw_fee_balance)); diff --git a/src/auditordb/pg_insert_wire_fee_summary.c b/src/auditordb/pg_insert_wire_fee_summary.c index 2de51a7c8..5c01e11b8 100644 --- a/src/auditordb/pg_insert_wire_fee_summary.c +++ b/src/auditordb/pg_insert_wire_fee_summary.c @@ -35,7 +35,8 @@ TAH_PG_insert_wire_fee_summary ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (wire_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + wire_fee_balance), GNUNET_PQ_query_param_end }; @@ -43,9 +44,8 @@ TAH_PG_insert_wire_fee_summary ( "auditor_wire_fee_balance_insert", "INSERT INTO auditor_wire_fee_balance" "(master_pub" - ",wire_fee_balance_val" - ",wire_fee_balance_frac" - ") VALUES ($1,$2,$3)"); + ",wire_fee_balance" + ") VALUES ($1,$2)"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_wire_fee_balance_insert", params); diff --git a/src/auditordb/pg_select_historic_denom_revenue.c b/src/auditordb/pg_select_historic_denom_revenue.c index 1812bb5d2..6005b915f 100644 --- a/src/auditordb/pg_select_historic_denom_revenue.c +++ b/src/auditordb/pg_select_historic_denom_revenue.c @@ -134,10 +134,8 @@ TAH_PG_select_historic_denom_revenue ( "SELECT" " denom_pub_hash" ",revenue_timestamp" - ",revenue_balance_val" - ",revenue_balance_frac" - ",loss_balance_val" - ",loss_balance_frac" + ",revenue_balance" + ",loss_balance" " FROM auditor_historic_denomination_revenue" " WHERE master_pub=$1;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, diff --git a/src/auditordb/pg_select_historic_reserve_revenue.c b/src/auditordb/pg_select_historic_reserve_revenue.c index a381cf41c..a05cc8a1f 100644 --- a/src/auditordb/pg_select_historic_reserve_revenue.c +++ b/src/auditordb/pg_select_historic_reserve_revenue.c @@ -129,8 +129,7 @@ TAH_PG_select_historic_reserve_revenue ( "SELECT" " start_date" ",end_date" - ",reserve_profits_val" - ",reserve_profits_frac" + ",reserve_profits" " FROM auditor_historic_reserve_summary" " WHERE master_pub=$1;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, diff --git a/src/auditordb/pg_select_purse_expired.c b/src/auditordb/pg_select_purse_expired.c index 49a8c5a97..95ba5ff37 100644 --- a/src/auditordb/pg_select_purse_expired.c +++ b/src/auditordb/pg_select_purse_expired.c @@ -133,8 +133,7 @@ TAH_PG_select_purse_expired ( "SELECT" " purse_pub" ",expiration_date" - ",balance_val" - ",balance_frac" + ",balance" " FROM auditor_purses" " WHERE master_pub=$1" " AND expiration_date<$2;"); diff --git a/src/auditordb/pg_update_balance_summary.c b/src/auditordb/pg_update_balance_summary.c index 96f074cba..a2e0c409a 100644 --- a/src/auditordb/pg_update_balance_summary.c +++ b/src/auditordb/pg_update_balance_summary.c @@ -34,15 +34,24 @@ TAH_PG_update_balance_summary ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (&dfb->total_escrowed), - TALER_PQ_query_param_amount (&dfb->deposit_fee_balance), - TALER_PQ_query_param_amount (&dfb->melt_fee_balance), - TALER_PQ_query_param_amount (&dfb->refund_fee_balance), - TALER_PQ_query_param_amount (&dfb->purse_fee_balance), - TALER_PQ_query_param_amount (&dfb->open_deposit_fee_balance), - TALER_PQ_query_param_amount (&dfb->risk), - TALER_PQ_query_param_amount (&dfb->loss), - TALER_PQ_query_param_amount (&dfb->irregular_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->total_escrowed), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->deposit_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->melt_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->refund_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->open_deposit_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->risk), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dfb->irregular_loss), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -50,25 +59,16 @@ TAH_PG_update_balance_summary ( PREPARE (pg, "auditor_balance_summary_update", "UPDATE auditor_balance_summary SET" - " denom_balance_val=$1" - ",denom_balance_frac=$2" - ",deposit_fee_balance_val=$3" - ",deposit_fee_balance_frac=$4" - ",melt_fee_balance_val=$5" - ",melt_fee_balance_frac=$6" - ",refund_fee_balance_val=$7" - ",refund_fee_balance_frac=$8" - ",purse_fee_balance_val=$9" - ",purse_fee_balance_frac=$10" - ",open_deposit_fee_balance_val=$11" - ",open_deposit_fee_balance_frac=$12" - ",risk_val=$13" - ",risk_frac=$14" - ",loss_val=$15" - ",loss_frac=$16" - ",irregular_loss_val=$17" - ",irregular_loss_frac=$18" - " WHERE master_pub=$19;"); + " denom_balance=$1" + ",deposit_fee_balance=$2" + ",melt_fee_balance=$3" + ",refund_fee_balance=$4" + ",purse_fee_balance=$5" + ",open_deposit_fee_balance=$6" + ",risk=$7" + ",loss=$8" + ",irregular_loss=$9" + " WHERE master_pub=$10;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_balance_summary_update", params); diff --git a/src/auditordb/pg_update_denomination_balance.c b/src/auditordb/pg_update_denomination_balance.c index 2fb0f5647..c7f8f5d5a 100644 --- a/src/auditordb/pg_update_denomination_balance.c +++ b/src/auditordb/pg_update_denomination_balance.c @@ -34,11 +34,15 @@ TAH_PG_update_denomination_balance ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (&dcd->denom_balance), - TALER_PQ_query_param_amount (&dcd->denom_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_loss), GNUNET_PQ_query_param_uint64 (&dcd->num_issued), - TALER_PQ_query_param_amount (&dcd->denom_risk), - TALER_PQ_query_param_amount (&dcd->recoup_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->denom_risk), + TALER_PQ_query_param_amount_tuple (pg->conn, + &dcd->recoup_loss), GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), GNUNET_PQ_query_param_end }; @@ -46,16 +50,12 @@ TAH_PG_update_denomination_balance ( PREPARE (pg, "auditor_denomination_pending_update", "UPDATE auditor_denomination_pending SET" - " denom_balance_val=$1" - ",denom_balance_frac=$2" - ",denom_loss_val=$3" - ",denom_loss_frac=$4" - ",num_issued=$5" - ",denom_risk_val=$6" - ",denom_risk_frac=$7" - ",recoup_loss_val=$8" - ",recoup_loss_frac=$9" - " WHERE denom_pub_hash=$10"); + " denom_balance=$1" + ",denom_loss=$2" + ",num_issued=$3" + ",denom_risk=$4" + ",recoup_loss=$5" + " WHERE denom_pub_hash=$6"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_denomination_pending_update", params); diff --git a/src/auditordb/pg_update_predicted_result.c b/src/auditordb/pg_update_predicted_result.c index 5c9618adf..207b27930 100644 --- a/src/auditordb/pg_update_predicted_result.c +++ b/src/auditordb/pg_update_predicted_result.c @@ -35,8 +35,10 @@ TAH_PG_update_predicted_result ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (balance), - TALER_PQ_query_param_amount (drained), + TALER_PQ_query_param_amount_tuple (pg->conn, + balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + drained), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -44,11 +46,9 @@ TAH_PG_update_predicted_result ( PREPARE (pg, "auditor_predicted_result_update", "UPDATE auditor_predicted_result SET" - " balance_val=$1" - ",balance_frac=$2" - ",drained_val=$3" - ",drained_frac=$4" - " WHERE master_pub=$5;"); + " balance=$1" + ",drained=$2" + " WHERE master_pub=$3;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_predicted_result_update", params); diff --git a/src/auditordb/pg_update_purse_info.c b/src/auditordb/pg_update_purse_info.c index 87c507b45..a9c9e5d3f 100644 --- a/src/auditordb/pg_update_purse_info.c +++ b/src/auditordb/pg_update_purse_info.c @@ -38,15 +38,15 @@ TAH_PG_update_purse_info ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (purse_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + balance), GNUNET_PQ_query_param_end }; PREPARE (pg, "auditor_purses_update", "UPDATE auditor_purses SET " - " balance_val=$3" - ",balance_frac=$4" + " balance=$3" " WHERE purse_pub=$1" " AND master_pub=$2;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, diff --git a/src/auditordb/pg_update_purse_summary.c b/src/auditordb/pg_update_purse_summary.c index 45afe2c8c..3415b9555 100644 --- a/src/auditordb/pg_update_purse_summary.c +++ b/src/auditordb/pg_update_purse_summary.c @@ -35,7 +35,8 @@ TAH_PG_update_purse_summary ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - TALER_PQ_query_param_amount (&sum->balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &sum->balance), GNUNET_PQ_query_param_uint64 (&sum->open_purses), GNUNET_PQ_query_param_end }; @@ -43,9 +44,8 @@ TAH_PG_update_purse_summary ( PREPARE (pg, "auditor_purse_summary_update", "UPDATE auditor_purse_summary SET" - " balance_val=$2" - ",balance_frac=$3" - ",open_purses=$4" + " balance=$2" + ",open_purses=$3" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_purse_summary_update", diff --git a/src/auditordb/pg_update_reserve_info.c b/src/auditordb/pg_update_reserve_info.c index 49d4f0256..2c9632354 100644 --- a/src/auditordb/pg_update_reserve_info.c +++ b/src/auditordb/pg_update_reserve_info.c @@ -36,12 +36,18 @@ TAH_PG_update_reserve_info ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (&rfb->reserve_balance), - TALER_PQ_query_param_amount (&rfb->reserve_loss), - TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance), - TALER_PQ_query_param_amount (&rfb->purse_fee_balance), - TALER_PQ_query_param_amount (&rfb->open_fee_balance), - TALER_PQ_query_param_amount (&rfb->history_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->withdraw_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->open_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->history_fee_balance), GNUNET_PQ_query_param_timestamp (&expiration_date), GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -51,21 +57,15 @@ TAH_PG_update_reserve_info ( PREPARE (pg, "auditor_reserves_update", "UPDATE auditor_reserves SET" - " reserve_balance_val=$1" - ",reserve_balance_frac=$2" - ",reserve_loss_val=$3" - ",reserve_loss_frac=$4" - ",withdraw_fee_balance_val=$5" - ",withdraw_fee_balance_frac=$6" - ",purse_fee_balance_val=$7" - ",purse_fee_balance_frac=$8" - ",open_fee_balance_val=$9" - ",open_fee_balance_frac=$10" - ",history_fee_balance_val=$11" - ",history_fee_balance_frac=$12" - ",expiration_date=$13" - " WHERE reserve_pub=$14" - " AND master_pub=$15;"); + " reserve_balance=$1" + ",reserve_loss=$2" + ",withdraw_fee_balance=$3" + ",purse_fee_balance=$4" + ",open_fee_balance=$5" + ",history_fee_balance=$6" + ",expiration_date=$7" + " WHERE reserve_pub=$8" + " AND master_pub=$9;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserves_update", params); diff --git a/src/auditordb/pg_update_reserve_summary.c b/src/auditordb/pg_update_reserve_summary.c index 3cb18ea5e..42c3e55fc 100644 --- a/src/auditordb/pg_update_reserve_summary.c +++ b/src/auditordb/pg_update_reserve_summary.c @@ -34,13 +34,20 @@ TAH_PG_update_reserve_summary ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (&rfb->reserve_balance), - TALER_PQ_query_param_amount (&rfb->reserve_loss), - TALER_PQ_query_param_amount (&rfb->withdraw_fee_balance), - TALER_PQ_query_param_amount (&rfb->close_fee_balance), - TALER_PQ_query_param_amount (&rfb->purse_fee_balance), - TALER_PQ_query_param_amount (&rfb->open_fee_balance), - TALER_PQ_query_param_amount (&rfb->history_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->reserve_loss), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->withdraw_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->close_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->purse_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->open_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + &rfb->history_fee_balance), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -48,21 +55,14 @@ TAH_PG_update_reserve_summary ( PREPARE (pg, "auditor_reserve_balance_update", "UPDATE auditor_reserve_balance SET" - " reserve_balance_val=$1" - ",reserve_balance_frac=$2" - ",reserve_loss_val=$3" - ",reserve_loss_frac=$4" - ",withdraw_fee_balance_val=$5" - ",withdraw_fee_balance_frac=$6" - ",close_fee_balance_val=$7" - ",close_fee_balance_frac=$8" - ",purse_fee_balance_val=$9" - ",purse_fee_balance_frac=$10" - ",open_fee_balance_val=$11" - ",open_fee_balance_frac=$12" - ",history_fee_balance_val=$13" - ",history_fee_balance_frac=$14" - " WHERE master_pub=$15;"); + " reserve_balance=$1" + ",reserve_loss=$2" + ",withdraw_fee_balance=$3" + ",close_fee_balance=$4" + ",purse_fee_balance=$5" + ",open_fee_balance=$6" + ",history_fee_balance=$7" + " WHERE master_pub=$8;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserve_balance_update", params); diff --git a/src/auditordb/pg_update_wire_fee_summary.c b/src/auditordb/pg_update_wire_fee_summary.c index 28ee39c44..b0a343711 100644 --- a/src/auditordb/pg_update_wire_fee_summary.c +++ b/src/auditordb/pg_update_wire_fee_summary.c @@ -34,7 +34,8 @@ TAH_PG_update_wire_fee_summary ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - TALER_PQ_query_param_amount (wire_fee_balance), + TALER_PQ_query_param_amount_tuple (pg->conn, + wire_fee_balance), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -42,9 +43,8 @@ TAH_PG_update_wire_fee_summary ( PREPARE (pg, "auditor_wire_fee_balance_update", "UPDATE auditor_wire_fee_balance SET" - " wire_fee_balance_val=$1" - ",wire_fee_balance_frac=$2" - " WHERE master_pub=$3;"); + " wire_fee_balance=$1" + " WHERE master_pub=$2;"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_wire_fee_balance_update", params); |