forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cross_module_fn.h
211 lines (192 loc) · 8.28 KB
/
cross_module_fn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* This file and its contents are licensed under the Apache License 2.0.
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#ifndef TIMESCALEDB_CROSS_MODULE_FN_H
#define TIMESCALEDB_CROSS_MODULE_FN_H
#include <postgres.h>
#include <fmgr.h>
#include <commands/event_trigger.h>
#include <optimizer/planner.h>
#include <utils/timestamp.h>
#include <utils/jsonb.h>
#include <utils/array.h>
#include "export.h"
#include "compat/compat.h"
#include "bgw/job.h"
#include "process_utility.h"
#include "with_clause_parser.h"
#include "ts_catalog/continuous_agg.h"
#include "planner/planner.h"
/*
* To define a cross-module function add it to this struct, add a default
* version in to ts_cm_functions_default cross_module_fn.c, and the overridden
* version to tsl_cm_functions tsl/src/init.c.
* This will allow the function to be called from this codebase as
* ts_cm_functions-><function name>
*/
typedef struct JsonbParseState JsonbParseState;
typedef struct Hypertable Hypertable;
typedef struct Chunk Chunk;
typedef struct CopyChunkState CopyChunkState;
typedef struct CompressSingleRowState CompressSingleRowState;
typedef struct CrossModuleFunctions
{
void (*add_tsl_telemetry_info)(JsonbParseState **parse_state);
PGFunction policy_compression_add;
PGFunction policy_compression_remove;
PGFunction policy_recompression_proc;
PGFunction policy_compression_check;
PGFunction policy_refresh_cagg_add;
PGFunction policy_refresh_cagg_proc;
PGFunction policy_refresh_cagg_check;
PGFunction policy_refresh_cagg_remove;
PGFunction policy_reorder_add;
PGFunction policy_reorder_proc;
PGFunction policy_reorder_check;
PGFunction policy_reorder_remove;
PGFunction policy_retention_add;
PGFunction policy_retention_proc;
PGFunction policy_retention_check;
PGFunction policy_retention_remove;
PGFunction policies_add;
PGFunction policies_remove;
PGFunction policies_remove_all;
PGFunction policies_alter;
PGFunction policies_show;
PGFunction job_add;
PGFunction job_alter;
PGFunction job_alter_set_hypertable_id;
PGFunction job_delete;
PGFunction job_run;
bool (*job_execute)(BgwJob *job);
void (*create_upper_paths_hook)(PlannerInfo *, UpperRelationKind, RelOptInfo *, RelOptInfo *,
TsRelType input_reltype, Hypertable *ht, void *extra);
void (*set_rel_pathlist_dml)(PlannerInfo *, RelOptInfo *, Index, RangeTblEntry *, Hypertable *);
void (*set_rel_pathlist_query)(PlannerInfo *, RelOptInfo *, Index, RangeTblEntry *,
Hypertable *);
void (*set_rel_pathlist)(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte);
/* gapfill */
PGFunction gapfill_marker;
PGFunction gapfill_int16_time_bucket;
PGFunction gapfill_int32_time_bucket;
PGFunction gapfill_int64_time_bucket;
PGFunction gapfill_date_time_bucket;
PGFunction gapfill_timestamp_time_bucket;
PGFunction gapfill_timestamptz_time_bucket;
PGFunction gapfill_timestamptz_timezone_time_bucket;
PGFunction reorder_chunk;
PGFunction move_chunk;
PGFunction move_chunk_proc;
PGFunction copy_chunk_proc;
PGFunction subscription_exec;
PGFunction copy_chunk_cleanup_proc;
void (*ddl_command_start)(ProcessUtilityArgs *args);
void (*ddl_command_end)(EventTriggerData *command);
void (*sql_drop)(List *dropped_objects);
/* Continuous Aggregates */
PGFunction partialize_agg;
PGFunction finalize_agg_sfunc;
PGFunction finalize_agg_ffunc;
DDLResult (*process_cagg_viewstmt)(Node *stmt, const char *query_string, void *pstmt,
WithClauseResult *with_clause_options);
PGFunction continuous_agg_invalidation_trigger;
void (*continuous_agg_call_invalidation_trigger)(int32 hypertable_id, Relation chunk_rel,
HeapTuple chunk_tuple,
HeapTuple chunk_newtuple, bool update,
bool is_distributed_hypertable_trigger,
int32 parent_hypertable_id);
PGFunction continuous_agg_refresh;
void (*continuous_agg_invalidate_raw_ht)(const Hypertable *raw_ht, int64 start, int64 end);
void (*continuous_agg_invalidate_mat_ht)(const Hypertable *raw_ht, const Hypertable *mat_ht,
int64 start, int64 end);
void (*continuous_agg_update_options)(ContinuousAgg *cagg,
WithClauseResult *with_clause_options);
PGFunction invalidation_cagg_log_add_entry;
PGFunction invalidation_hyper_log_add_entry;
void (*remote_invalidation_log_delete)(int32 raw_hypertable_id,
ContinuousAggHypertableStatus caggstatus);
PGFunction drop_dist_ht_invalidation_trigger;
void (*remote_drop_dist_ht_invalidation_trigger)(int32 raw_hypertable_id);
PGFunction invalidation_process_hypertable_log;
PGFunction invalidation_process_cagg_log;
PGFunction cagg_try_repair;
PGFunction compressed_data_send;
PGFunction compressed_data_recv;
PGFunction compressed_data_in;
PGFunction compressed_data_out;
bool (*process_compress_table)(AlterTableCmd *cmd, Hypertable *ht,
WithClauseResult *with_clause_options);
void (*process_altertable_cmd)(Hypertable *ht, const AlterTableCmd *cmd);
void (*process_rename_cmd)(Oid relid, Cache *hcache, const RenameStmt *stmt);
PGFunction create_compressed_chunk;
PGFunction compress_chunk;
PGFunction decompress_chunk;
/* The compression functions below are not installed in SQL as part of create extension;
* They are installed and tested during testing scripts. They are exposed in cross-module
* functions because they may be very useful for debugging customer problems if the sql
* stub is installed on the customer's machine.
*/
PGFunction compressed_data_decompress_forward;
PGFunction compressed_data_decompress_reverse;
PGFunction deltadelta_compressor_append;
PGFunction deltadelta_compressor_finish;
PGFunction gorilla_compressor_append;
PGFunction gorilla_compressor_finish;
PGFunction dictionary_compressor_append;
PGFunction dictionary_compressor_finish;
PGFunction array_compressor_append;
PGFunction array_compressor_finish;
PGFunction data_node_add;
PGFunction data_node_delete;
PGFunction data_node_attach;
PGFunction data_node_ping;
PGFunction data_node_detach;
PGFunction data_node_alter;
PGFunction data_node_allow_new_chunks;
PGFunction data_node_block_new_chunks;
PGFunction chunk_set_default_data_node;
PGFunction create_chunk;
PGFunction show_chunk;
List *(*get_and_validate_data_node_list)(ArrayType *nodearr);
void (*hypertable_make_distributed)(Hypertable *ht, List *data_node_names);
PGFunction timescaledb_fdw_handler;
PGFunction timescaledb_fdw_validator;
void (*cache_syscache_invalidate)(Datum arg, int cacheid, uint32 hashvalue);
PGFunction remote_txn_id_in;
PGFunction remote_txn_id_out;
PGFunction remote_txn_heal_data_node;
PGFunction remote_connection_cache_show;
void (*create_chunk_on_data_nodes)(const Chunk *chunk, const Hypertable *ht,
const char *remote_chunk_name, List *data_nodes);
Path *(*distributed_insert_path_create)(PlannerInfo *root, ModifyTablePath *mtpath,
Index hypertable_rti, int subpath_index);
uint64 (*distributed_copy)(const CopyStmt *stmt, CopyChunkState *ccstate, List *attnums);
bool (*set_distributed_id)(Datum id);
void (*set_distributed_peer_id)(Datum id);
bool (*is_access_node_session)(void);
bool (*remove_from_distributed_db)(void);
PGFunction dist_remote_hypertable_info;
PGFunction dist_remote_chunk_info;
PGFunction dist_remote_compressed_chunk_info;
PGFunction dist_remote_hypertable_index_info;
void (*validate_as_data_node)(void);
void (*func_call_on_data_nodes)(FunctionCallInfo fcinfo, List *data_node_oids);
PGFunction distributed_exec;
PGFunction create_distributed_restore_point;
PGFunction chunk_get_relstats;
PGFunction chunk_get_colstats;
PGFunction hypertable_distributed_set_replication_factor;
PGFunction chunk_create_empty_table;
PGFunction chunk_create_replica_table;
PGFunction chunk_drop_replica;
void (*update_compressed_chunk_relstats)(Oid uncompressed_relid, Oid compressed_relid);
CompressSingleRowState *(*compress_row_init)(int srcht_id, Relation in_rel, Relation out_rel);
TupleTableSlot *(*compress_row_exec)(CompressSingleRowState *cr, TupleTableSlot *slot);
void (*compress_row_end)(CompressSingleRowState *cr);
void (*compress_row_destroy)(CompressSingleRowState *cr);
} CrossModuleFunctions;
extern TSDLLEXPORT CrossModuleFunctions *ts_cm_functions;
extern TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default;
#endif /* TIMESCALEDB_CROSS_MODULE_FN_H */