From ca66a1d1af2412e3ad04c18150db7a259dc69b5e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 10 Jan 2021 00:54:12 +0100 Subject: fix major bug with SQL statement missing ORDER BY freshcoin_index resulting in possible link failures (but usually lucky with old DB schema) --- src/exchangedb/exchange-0002.sql | 1 - src/exchangedb/plugin_exchangedb_postgres.c | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/exchange-0002.sql b/src/exchangedb/exchange-0002.sql index 3d17395bc..9b66d4d18 100644 --- a/src/exchangedb/exchange-0002.sql +++ b/src/exchangedb/exchange-0002.sql @@ -280,7 +280,6 @@ COMMENT ON COLUMN refunds.deposit_serial_id IS 'Identifies ONLY the merchant_pub, h_contract_terms and known_coin_id. Multiple deposits may match a refund, this only identifies one of them.'; - -- Create additional tables... CREATE TABLE IF NOT EXISTS auditors diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index d8dbd2241..b81fb7c1b 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -794,7 +794,7 @@ postgres_get_session (void *cls) ",h_coin_ev" ",ev_sig" ") SELECT rcx.melt_serial_id, $2, $3, " - " denominations_serial, $5, $6, $7 " + " denominations_serial, $5, $6, $7" " FROM denominations" " CROSS JOIN rcx" " WHERE denom_pub_hash=$4;", @@ -1108,7 +1108,7 @@ postgres_get_session (void *cls) " (SELECT known_coin_id " " FROM known_coins" " WHERE coin_pub=$1)" - " ORDER BY tp.transfer_pub", + " ORDER BY tp.transfer_pub, rrc.freshcoin_index ASC", 1), /* Used in #postgres_lookup_wire_transfer */ GNUNET_PQ_make_prepare ("lookup_transactions", @@ -2323,6 +2323,11 @@ postgres_preflight (void *cls, }; (void) cls; + if (NULL == session) + { + GNUNET_break (0); + return; + } if (NULL == session->transaction_name) return; /* all good */ if (GNUNET_OK == -- cgit v1.2.3