aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-10 00:54:12 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-10 00:54:12 +0100
commitca66a1d1af2412e3ad04c18150db7a259dc69b5e (patch)
tree83421873e49eec67f7012b4e21b21f31a3c9fa3a /src/exchangedb
parent02ecf68a3d9edde9ef48650f64b7332af845beee (diff)
fix major bug with SQL statement missing ORDER BY freshcoin_index resulting in possible link failures (but usually lucky with old DB schema)
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/exchange-0002.sql1
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c9
2 files changed, 7 insertions, 3 deletions
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 ==