From 22e7dabef196b968ae78333cf7e760bef16b2490 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 29 Oct 2021 19:13:47 +0200 Subject: sql fixes --- src/exchangedb/drop0001.sql | 17 +++-------------- src/exchangedb/plugin_exchangedb_postgres.c | 13 +++++++------ 2 files changed, 10 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/exchangedb/drop0001.sql b/src/exchangedb/drop0001.sql index 507393e57..54338f02c 100644 --- a/src/exchangedb/drop0001.sql +++ b/src/exchangedb/drop0001.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2020 Taler Systems SA +-- Copyright (C) 2014--2021 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 @@ -22,25 +22,20 @@ BEGIN; -- Unlike the other SQL files, it SHOULD be updated to reflect the -- latest requirements for dropping tables. - --- Drops for exchange-0003.sql +-- Drops for exchange-0001.sql DROP TABLE IF EXISTS revolving_work_shards CASCADE; - - --- Drops for exchange-0002.sql DROP TABLE IF EXISTS auditors CASCADE; DROP TABLE IF EXISTS auditor_denom_sigs CASCADE; DROP TABLE IF EXISTS exchange_sign_keys CASCADE; DROP TABLE IF EXISTS wire_accounts CASCADE; DROP TABLE IF EXISTS signkey_revocations CASCADE; DROP TABLE IF EXISTS work_shards CASCADE; - --- Drops for 0001.sql DROP TABLE IF EXISTS prewire CASCADE; DROP TABLE IF EXISTS recoup CASCADE; DROP TABLE IF EXISTS recoup_refresh CASCADE; DROP TABLE IF EXISTS aggregation_tracking CASCADE; DROP TABLE IF EXISTS wire_out CASCADE; +DROP TABLE IF EXISTS wire_targets CASCADE; DROP TABLE IF EXISTS wire_fee CASCADE; DROP TABLE IF EXISTS deposits CASCADE; DROP TABLE IF EXISTS refunds CASCADE; @@ -59,11 +54,5 @@ DROP TABLE IF EXISTS denominations CASCADE; -- Unregister patch (exchange-0001.sql) SELECT _v.unregister_patch('exchange-0001'); --- Unregister patch (exchange-0002.sql) -SELECT _v.unregister_patch('exchange-0002'); - --- Unregister patch (exchange-0003.sql) -SELECT _v.unregister_patch('exchange-0003'); - -- And we're out of here... COMMIT; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 27870f524..ab84ddfc4 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -361,8 +361,9 @@ prepare_statements (struct PostgresClosure *pg) ",kyc_ok" ",wire_target_serial_id AS payment_target_uuid" " FROM reserves" - " JOIN reserves_in USING (reserve_uuid)" - " JOIN wire_targets USING (wire_target_serial_id)" + " JOIN reserves_in ri USING (reserve_uuid)" + " JOIN wire_targets wt " + " ON (ri.wire_source_serial_id = wt.wire_target_serial_id)" " WHERE reserve_pub=$1" " LIMIT 1;", 1), @@ -375,7 +376,7 @@ prepare_statements (struct PostgresClosure *pg) /* Used in #postgres_get_kyc_status() */ GNUNET_PQ_make_prepare ("get_kyc_status", "SELECT" - ",kyc_ok" + " kyc_ok" ",wire_target_serial_id AS payment_target_uuid" " FROM wire_targets" " WHERE payto_uri=$1" @@ -384,7 +385,7 @@ prepare_statements (struct PostgresClosure *pg) /* Used in #postgres_select_kyc_status() */ GNUNET_PQ_make_prepare ("select_kyc_status", "SELECT" - ",kyc_ok" + " kyc_ok" ",h_payto" " FROM wire_targets" " WHERE" @@ -400,10 +401,10 @@ prepare_statements (struct PostgresClosure *pg) ") VALUES " "($1)" " ON CONFLICT (wire_target_serial_id) DO " - " (SELECT " + "(SELECT " " kyc_ok" " ,wire_target_serial_id" - " )" + ")" " RETURNING " " FALSE AS kyc_ok" " wire_target_serial_id;", -- cgit v1.2.3