aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/0002-aggregation_transient.sql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-11-27 14:45:01 +0100
committerChristian Grothoff <christian@grothoff.org>2022-11-27 14:45:01 +0100
commit4f75bcdca35b1ce8aa1f3db444c63f4763e28301 (patch)
tree0db42c55f3d35806f1343ce8e9dfbd140ff180cb /src/exchangedb/0002-aggregation_transient.sql
parenta322770d290cae69e7d2f7629ee575e068254428 (diff)
more work on SQL refactoring
Diffstat (limited to 'src/exchangedb/0002-aggregation_transient.sql')
-rw-r--r--src/exchangedb/0002-aggregation_transient.sql41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/exchangedb/0002-aggregation_transient.sql b/src/exchangedb/0002-aggregation_transient.sql
index 4739379e8..2d77e63ca 100644
--- a/src/exchangedb/0002-aggregation_transient.sql
+++ b/src/exchangedb/0002-aggregation_transient.sql
@@ -14,7 +14,7 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
-CREATE OR REPLACE FUNCTION create_table_aggregation_transient(
+CREATE FUNCTION create_table_aggregation_transient(
IN shard_suffix VARCHAR DEFAULT NULL
)
RETURNS VOID
@@ -23,22 +23,37 @@ AS $$
DECLARE
table_name VARCHAR DEFAULT 'aggregation_transient';
BEGIN
-
PERFORM create_partitioned_table(
- 'CREATE TABLE IF NOT EXISTS %I '
- '(amount_val INT8 NOT NULL'
- ',amount_frac INT4 NOT NULL'
- ',wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)'
- ',merchant_pub BYTEA CHECK (LENGTH(merchant_pub)=32)'
- ',exchange_account_section TEXT NOT NULL'
- ',legitimization_requirement_serial_id INT8 NOT NULL DEFAULT(0)'
- ',wtid_raw BYTEA NOT NULL CHECK (LENGTH(wtid_raw)=32)'
- ') %s ;'
+ 'CREATE TABLE %I '
+ '(amount_val INT8 NOT NULL'
+ ',amount_frac INT4 NOT NULL'
+ ',wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)'
+ ',merchant_pub BYTEA CHECK (LENGTH(merchant_pub)=32)'
+ ',exchange_account_section TEXT NOT NULL'
+ ',legitimization_requirement_serial_id INT8 NOT NULL DEFAULT(0)'
+ ',wtid_raw BYTEA NOT NULL CHECK (LENGTH(wtid_raw)=32)'
+ ') %s ;'
+ ,table_name
+ ,'PARTITION BY HASH (wire_target_h_payto)'
+ ,shard_suffix
+ );
+ PERFORM comment_partitioned_table(
+ 'aggregations currently happening (lacking wire_out, usually because the amount is too low); this table is not replicated'
+ ,table_name
+ ,shard_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Sum of all of the aggregated deposits (without deposit fees)'
+ ,'amount_val'
+ ,table_name
+ ,shard_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'identifier of the wire transfer'
+ ,'wtid_raw'
,table_name
- ,'PARTITION BY HASH (wire_target_h_payto)'
,shard_suffix
);
-
END
$$;