diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 12:16:02 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 12:16:02 +0200 |
commit | c0ec4a14441b3015bd23464084b3211c4f87d3dd (patch) | |
tree | 87fecae9cd413efec9579baba9d3d1285c18a4e7 /src | |
parent | a200dd5979d7b8ff869891c459c37b90e674b5ce (diff) | |
download | exchange-c0ec4a14441b3015bd23464084b3211c4f87d3dd.tar.xz |
add was_decided field and automatically set it via trigger
Diffstat (limited to 'src')
-rw-r--r-- | src/exchangedb/0002-purse_decision.sql | 5 | ||||
-rw-r--r-- | src/exchangedb/0002-purse_requests.sql | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/exchangedb/0002-purse_decision.sql b/src/exchangedb/0002-purse_decision.sql index 15a1de1b5..091bd468b 100644 --- a/src/exchangedb/0002-purse_decision.sql +++ b/src/exchangedb/0002-purse_decision.sql @@ -74,6 +74,9 @@ CREATE OR REPLACE FUNCTION purse_decision_insert_trigger() LANGUAGE plpgsql AS $$ BEGIN + UPDATE purse_requests + SET was_decided=TRUE + WHERE purse_pub=NEW.purse_pub; IF NEW.refunded THEN INSERT INTO coin_history @@ -101,7 +104,7 @@ BEGIN RETURN NEW; END $$; COMMENT ON FUNCTION purse_decision_insert_trigger() - IS 'Automatically generate coin history entry.'; + IS 'Automatically generate coin history entry and update decision status for the purse.'; CREATE FUNCTION master_table_purse_decision() diff --git a/src/exchangedb/0002-purse_requests.sql b/src/exchangedb/0002-purse_requests.sql index 3cc7eac93..0fa076338 100644 --- a/src/exchangedb/0002-purse_requests.sql +++ b/src/exchangedb/0002-purse_requests.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 @@ -34,6 +34,7 @@ BEGIN ',age_limit INT4 NOT NULL' ',flags INT4 NOT NULL' ',in_reserve_quota BOOLEAN NOT NULL DEFAULT(FALSE)' + ',was_decided BOOLEAN NOT NULL DEFAULT(FALSE)' ',amount_with_fee taler_amount NOT NULL' ',purse_fee taler_amount NOT NULL' ',balance taler_amount NOT NULL DEFAULT (0,0)' @@ -123,18 +124,16 @@ DECLARE BEGIN table_name = concat_ws('_', table_name, partition_suffix); - -- FIXME: change to materialized index by merge_pub! EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_merge_pub ' 'ON ' || table_name || ' ' '(merge_pub);' ); - -- FIXME: drop index on master (crosses partitions)? - -- Or use materialized index? (needed?) EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_purse_expiration ' 'ON ' || table_name || ' ' - '(purse_expiration);' + '(purse_expiration) ' || + 'WHERE NOT was_decided;' ); EXECUTE FORMAT ( 'ALTER TABLE ' || table_name || |