summaryrefslogtreecommitdiff
path: root/src/exchangedb/0002-prewire.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/0002-prewire.sql')
-rw-r--r--src/exchangedb/0002-prewire.sql24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/exchangedb/0002-prewire.sql b/src/exchangedb/0002-prewire.sql
index fb8dc2212..396a27608 100644
--- a/src/exchangedb/0002-prewire.sql
+++ b/src/exchangedb/0002-prewire.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
@@ -15,20 +15,20 @@
--
CREATE FUNCTION create_table_prewire(
- IN partition_suffix VARCHAR DEFAULT NULL
+ IN partition_suffix TEXT DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
- table_name VARCHAR DEFAULT 'prewire';
+ table_name TEXT DEFAULT 'prewire';
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
'(prewire_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY'
',wire_method TEXT NOT NULL'
- ',finished BOOLEAN NOT NULL DEFAULT false'
- ',failed BOOLEAN NOT NULL DEFAULT false'
+ ',finished BOOLEAN NOT NULL DEFAULT FALSE'
+ ',failed BOOLEAN NOT NULL DEFAULT FALSE'
',buf BYTEA NOT NULL'
') %s ;'
,table_name
@@ -63,29 +63,31 @@ $$;
CREATE FUNCTION constrain_table_prewire(
- IN partition_suffix VARCHAR DEFAULT NULL
+ IN partition_suffix TEXT DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
- table_name VARCHAR DEFAULT 'prewire';
+ table_name TEXT DEFAULT 'prewire';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix);
EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_by_finished_index '
'ON ' || table_name || ' '
- '(finished);'
+ '(finished)'
+ ' WHERE finished;'
);
EXECUTE FORMAT (
'COMMENT ON INDEX ' || table_name || '_by_finished_index '
- 'IS ' || quote_literal('for gc_prewire') || ';'
+ 'IS ' || quote_literal('for do_gc') || ';'
);
- -- FIXME: find a way to combine these two indices?
EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_by_failed_finished_index '
'ON ' || table_name || ' '
- '(failed,finished);'
+ '(prewire_uuid)'
+ ' WHERE finished=FALSE'
+ ' AND failed=FALSE;'
);
EXECUTE FORMAT (
'COMMENT ON INDEX ' || table_name || '_by_failed_finished_index '