forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catalog.h
1480 lines (1241 loc) · 40.2 KB
/
catalog.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* 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_CATALOG_H
#define TIMESCALEDB_CATALOG_H
#include <postgres.h>
#include <utils/jsonb.h>
#include <utils/rel.h>
#include <nodes/nodes.h>
#include <access/heapam.h>
#include "export.h"
#include "extension_constants.h"
#include "scanner.h"
/*
* TimescaleDB catalog.
*
* The TimescaleDB catalog contains schema metadata for hypertables, among other
* things. The metadata is stored in regular tables. This header file contains
* definitions for those tables and should match any table declarations in
* sql/pre_install/tables.sql.
*
* A source file that includes this header has access to a catalog object,
* which contains cached information about catalog tables, such as relation
* OIDs.
*
* Generally, definitions and naming should roughly follow how things are done
* in Postgres internally.
*/
typedef enum CatalogTable
{
HYPERTABLE = 0,
HYPERTABLE_DATA_NODE,
DIMENSION,
DIMENSION_PARTITION,
DIMENSION_SLICE,
CHUNK,
CHUNK_CONSTRAINT,
CHUNK_INDEX,
CHUNK_DATA_NODE,
TABLESPACE,
BGW_JOB,
BGW_JOB_STAT,
METADATA,
BGW_POLICY_CHUNK_STATS,
CONTINUOUS_AGG,
CONTINUOUS_AGGS_HYPERTABLE_INVALIDATION_LOG,
CONTINUOUS_AGGS_INVALIDATION_THRESHOLD,
CONTINUOUS_AGGS_MATERIALIZATION_INVALIDATION_LOG,
HYPERTABLE_COMPRESSION,
COMPRESSION_CHUNK_SIZE,
REMOTE_TXN,
CHUNK_COPY_OPERATION,
CONTINUOUS_AGGS_BUCKET_FUNCTION,
JOB_ERRORS,
/* Don't forget updating catalog.c when adding new tables! */
_MAX_CATALOG_TABLES,
} CatalogTable;
typedef struct TableInfoDef
{
const char *schema_name;
const char *table_name;
} TableInfoDef;
typedef struct TableIndexDef
{
int length;
char **names;
} TableIndexDef;
#define INVALID_CATALOG_TABLE _MAX_CATALOG_TABLES
#define INVALID_INDEXID -1
#define CATALOG_INTERNAL_FUNC(catalog, func) (catalog->functions[func].function_id)
#define CatalogInternalCall1(func, datum1) \
OidFunctionCall1(CATALOG_INTERNAL_FUNC(ts_catalog_get(), func), datum1)
#define CatalogInternalCall2(func, datum1, datum2) \
OidFunctionCall2(CATALOG_INTERNAL_FUNC(ts_catalog_get(), func), datum1, datum2)
#define CatalogInternalCall3(func, datum1, datum2, datum3) \
OidFunctionCall3(CATALOG_INTERNAL_FUNC(ts_catalog_get(), func), datum1, datum2, datum3)
#define CatalogInternalCall4(func, datum1, datum2, datum3, datum4) \
OidFunctionCall4(CATALOG_INTERNAL_FUNC(ts_catalog_get(), func), datum1, datum2, datum3, datum4)
typedef enum InternalFunction
{
DDL_ADD_CHUNK_CONSTRAINT,
DDL_ADD_HYPERTABLE_FK_CONSTRAINT,
_MAX_INTERNAL_FUNCTIONS,
} InternalFunction;
/******************************
*
* Hypertable table definitions
*
******************************/
#define HYPERTABLE_TABLE_NAME "hypertable"
/* Hypertable table attribute numbers */
enum Anum_hypertable
{
Anum_hypertable_id = 1,
Anum_hypertable_schema_name,
Anum_hypertable_table_name,
Anum_hypertable_associated_schema_name,
Anum_hypertable_associated_table_prefix,
Anum_hypertable_num_dimensions,
Anum_hypertable_chunk_sizing_func_schema,
Anum_hypertable_chunk_sizing_func_name,
Anum_hypertable_chunk_target_size,
Anum_hypertable_compression_state,
Anum_hypertable_compressed_hypertable_id,
Anum_hypertable_replication_factor,
_Anum_hypertable_max,
};
#define Natts_hypertable (_Anum_hypertable_max - 1)
typedef struct FormData_hypertable
{
int32 id;
NameData schema_name;
NameData table_name;
NameData associated_schema_name;
NameData associated_table_prefix;
int16 num_dimensions;
NameData chunk_sizing_func_schema;
NameData chunk_sizing_func_name;
int64 chunk_target_size;
int16 compression_state;
int32 compressed_hypertable_id;
int16 replication_factor;
} FormData_hypertable;
typedef FormData_hypertable *Form_hypertable;
/* Hypertable primary index attribute numbers */
enum Anum_hypertable_pkey_idx
{
Anum_hypertable_pkey_idx_id = 1,
_Anum_hypertable_pkey_max,
};
#define Natts_hypertable_pkey_idx (_Anum_hypertable_pkey_max - 1)
/* Hypertable name (schema,table) index attribute numbers */
enum Anum_hypertable_name_idx
{
Anum_hypertable_name_idx_table = 1,
Anum_hypertable_name_idx_schema,
_Anum_hypertable_name_max,
};
#define Natts_hypertable_name_idx (_Anum_hypertable_name_max - 1)
enum
{
HYPERTABLE_ID_INDEX = 0,
HYPERTABLE_NAME_INDEX,
_MAX_HYPERTABLE_INDEX,
};
#define HYPERTABLE_DATA_NODE_TABLE_NAME "hypertable_data_node"
enum Anum_hypertable_data_node
{
Anum_hypertable_data_node_hypertable_id = 1,
Anum_hypertable_data_node_node_hypertable_id,
Anum_hypertable_data_node_node_name,
Anum_hypertable_data_node_block_chunks,
_Anum_hypertable_data_node_max,
};
#define Natts_hypertable_data_node (_Anum_hypertable_data_node_max - 1)
typedef struct FormData_hypertable_data_node
{
int32 hypertable_id;
int32 node_hypertable_id;
NameData node_name;
bool block_chunks;
} FormData_hypertable_data_node;
typedef FormData_hypertable_data_node *Form_hypertable_data_node;
enum
{
HYPERTABLE_DATA_NODE_HYPERTABLE_ID_NODE_NAME_IDX,
HYPERTABLE_DATA_NODE_NODE_HYPERTABLE_ID_NODE_NAME_IDX,
_MAX_HYPERTABLE_DATA_NODE_INDEX,
};
enum Anum_hypertable_data_node_hypertable_id_node_name_idx
{
Anum_hypertable_data_node_hypertable_id_node_name_idx_hypertable_id = 1,
Anum_hypertable_data_node_hypertable_id_node_name_idx_node_name,
_Anum_hypertable_data_node_hypertable_id_node_name_idx_max,
};
struct FormData_hypertable_data_node_hypertable_id_node_name_idx
{
int32 hypertable_id;
NameData node_name;
};
enum Anum_hypertable_data_node_node_hypertable_id_node_name_idx
{
Anum_hypertable_data_node_node_hypertable_id_node_name_idx_hypertable_id = 1,
Anum_hypertable_data_node_node_hypertable_id_node_name_idx_node_name,
_Anum_hypertable_data_node_node_hypertable_id_node_name_idx_max,
};
struct FormData_hypertable_data_node_node_hypertable_id_node_name_idx
{
int32 node_hypertable_id;
NameData node_name;
};
/******************************
*
* Dimension table definitions
*
******************************/
#define DIMENSION_TABLE_NAME "dimension"
enum Anum_dimension
{
Anum_dimension_id = 1,
Anum_dimension_hypertable_id,
Anum_dimension_column_name,
Anum_dimension_column_type,
Anum_dimension_aligned,
Anum_dimension_num_slices,
Anum_dimension_partitioning_func_schema,
Anum_dimension_partitioning_func,
Anum_dimension_interval_length,
Anum_dimension_integer_now_func_schema,
Anum_dimension_integer_now_func,
_Anum_dimension_max,
};
#define Natts_dimension (_Anum_dimension_max - 1)
typedef struct FormData_dimension
{
int32 id;
int32 hypertable_id;
NameData column_name;
Oid column_type;
bool aligned;
/* closed (space) columns */
int16 num_slices;
NameData partitioning_func_schema;
NameData partitioning_func;
/* open (time) columns */
int64 interval_length;
NameData integer_now_func_schema;
NameData integer_now_func;
} FormData_dimension;
typedef FormData_dimension *Form_dimension;
enum Anum_dimension_id_idx
{
Anum_dimension_id_idx_id = 1,
_Anum_dimension_id_idx_max,
};
#define Natts_dimension_id_idx (_Anum_dimension_id_idx_max - 1)
enum Anum_dimension_hypertable_id_column_name_idx
{
Anum_dimension_hypertable_id_column_name_idx_hypertable_id = 1,
Anum_dimension_hypertable_id_column_name_idx_column_name,
_Anum_dimension_hypertable_id_idx_max,
};
#define Natts_dimension_hypertable_id_idx (_Anum_dimension_hypertable_id_idx_max - 1)
enum
{
DIMENSION_ID_IDX = 0,
DIMENSION_HYPERTABLE_ID_COLUMN_NAME_IDX,
_MAX_DIMENSION_INDEX,
};
/******************************
*
* Dimension partition table definitions
*
******************************/
#define DIMENSION_PARTITION_TABLE_NAME "dimension_partition"
enum Anum_dimension_partition
{
Anum_dimension_partition_dimension_id = 1,
Anum_dimension_partition_range_start,
Anum_dimension_partition_data_nodes,
_Anum_dimension_partition_max,
};
#define Natts_dimension_partition (_Anum_dimension_partition_max - 1)
typedef struct FormData_dimension_partition
{
int32 dimension_id;
int64 range_start;
/* Variable-length fields start here. The first variable-length field can
* still be accessed directly via the C struct */
ArrayType *data_nodes;
} FormData_dimension_partition;
typedef FormData_dimension_partition *Form_dimension_partition;
enum Anum_dimension_partition_dimension_id_range_start_idx
{
Anum_dimension_partition_dimension_id_range_start_idx_dimension_id = 1,
Anum_dimension_partition_dimension_id_range_start_idx_range_start,
_Anum_dimension_partition_dimension_id_range_start_idx_max,
};
#define Natts_dimension_partition_dimension_id_range_start_idx \
(_Anum_dimension_partition_dimension_id_range_start_idx_max - 1)
enum
{
DIMENSION_PARTITION_DIMENSION_ID_RANGE_START_IDX = 0,
_MAX_DIMENSION_PARTITION_INDEX,
};
/******************************
*
* Dimension slice table definitions
*
******************************/
#define DIMENSION_SLICE_TABLE_NAME "dimension_slice"
enum Anum_dimension_slice
{
Anum_dimension_slice_id = 1,
Anum_dimension_slice_dimension_id,
Anum_dimension_slice_range_start,
Anum_dimension_slice_range_end,
_Anum_dimension_slice_max,
};
#define Natts_dimension_slice (_Anum_dimension_slice_max - 1)
typedef struct FormData_dimension_slice
{
int32 id;
int32 dimension_id;
int64 range_start;
int64 range_end;
} FormData_dimension_slice;
typedef FormData_dimension_slice *Form_dimension_slice;
enum Anum_dimension_slice_id_idx
{
Anum_dimension_slice_id_idx_id = 1,
_Anum_dimension_slice_id_idx_max,
};
#define Natts_dimension_slice_id_idx (_Anum_dimension_slice_id_idx_max - 1)
enum Anum_dimension_slice_dimension_id_range_start_range_end_idx
{
Anum_dimension_slice_dimension_id_range_start_range_end_idx_dimension_id = 1,
Anum_dimension_slice_dimension_id_range_start_range_end_idx_range_start,
Anum_dimension_slice_dimension_id_range_start_range_end_idx_range_end,
_Anum_dimension_slice_dimension_id_range_start_range_end_idx_max,
};
#define Natts_dimension_slice_dimension_id_range_start_range_end_idx \
(_Anum_dimension_slice_dimension_id_range_start_range_end_idx_max - 1)
enum
{
DIMENSION_SLICE_ID_IDX = 0,
DIMENSION_SLICE_DIMENSION_ID_RANGE_START_RANGE_END_IDX,
_MAX_DIMENSION_SLICE_INDEX,
};
/*************************
*
* Chunk table definitions
*
*************************/
#define CHUNK_TABLE_NAME "chunk"
enum Anum_chunk
{
Anum_chunk_id = 1,
Anum_chunk_hypertable_id,
Anum_chunk_schema_name,
Anum_chunk_table_name,
Anum_chunk_compressed_chunk_id,
Anum_chunk_dropped,
Anum_chunk_status,
Anum_chunk_osm_chunk,
_Anum_chunk_max,
};
#define Natts_chunk (_Anum_chunk_max - 1)
typedef struct FormData_chunk
{
int32 id;
int32 hypertable_id;
NameData schema_name;
NameData table_name;
int32 compressed_chunk_id;
bool dropped;
int32 status;
bool osm_chunk;
} FormData_chunk;
typedef FormData_chunk *Form_chunk;
enum
{
CHUNK_ID_INDEX = 0,
CHUNK_HYPERTABLE_ID_INDEX,
CHUNK_SCHEMA_NAME_INDEX,
CHUNK_COMPRESSED_CHUNK_ID_INDEX,
CHUNK_OSM_CHUNK_INDEX,
_MAX_CHUNK_INDEX,
};
enum Anum_chunk_idx
{
Anum_chunk_idx_id = 1,
};
enum Anum_chunk_hypertable_id_idx
{
Anum_chunk_hypertable_id_idx_hypertable_id = 1,
};
enum Anum_chunk_compressed_chunk_id_idx
{
Anum_chunk_compressed_chunk_id_idx_compressed_chunk_id = 1,
};
enum Anum_chunk_schema_name_idx
{
Anum_chunk_schema_name_idx_schema_name = 1,
Anum_chunk_schema_name_idx_table_name,
};
enum Anum_chunk_osm_chunk_idx
{
Anum_chunk_osm_chunk_idx_osm_chunk = 1,
Anum_chunk_osm_chunk_idx_hypertable_id,
};
/************************************
*
* Chunk constraint table definitions
*
************************************/
#define CHUNK_CONSTRAINT_TABLE_NAME "chunk_constraint"
enum Anum_chunk_constraint
{
Anum_chunk_constraint_chunk_id = 1,
Anum_chunk_constraint_dimension_slice_id,
Anum_chunk_constraint_constraint_name,
Anum_chunk_constraint_hypertable_constraint_name,
_Anum_chunk_constraint_max,
};
#define Natts_chunk_constraint (_Anum_chunk_constraint_max - 1)
/* Do Not use GET_STRUCT with FormData_chunk_constraint. It contains NULLS */
typedef struct FormData_chunk_constraint
{
int32 chunk_id;
int32 dimension_slice_id;
NameData constraint_name;
NameData hypertable_constraint_name;
} FormData_chunk_constraint;
typedef FormData_chunk_constraint *Form_chunk_constraint;
enum
{
CHUNK_CONSTRAINT_CHUNK_ID_CONSTRAINT_NAME_IDX = 0,
CHUNK_CONSTRAINT_DIMENSION_SLICE_ID_IDX,
_MAX_CHUNK_CONSTRAINT_INDEX,
};
enum Anum_chunk_constraint_dimension_slice_id_idx
{
Anum_chunk_constraint_dimension_slice_id_idx_dimension_slice_id = 1,
_Anum_chunk_constraint_dimension_slice_id_idx_max,
};
enum Anum_chunk_constraint_chunk_id_constraint_name_idx
{
Anum_chunk_constraint_chunk_id_constraint_name_idx_chunk_id = 1,
Anum_chunk_constraint_chunk_id_constraint_name_idx_constraint_name,
_Anum_chunk_constraint_chunk_id_constraint_name_idx_max,
};
/************************************
*
* Chunk index table definitions
*
************************************/
#define CHUNK_INDEX_TABLE_NAME "chunk_index"
enum Anum_chunk_index
{
Anum_chunk_index_chunk_id = 1,
Anum_chunk_index_index_name,
Anum_chunk_index_hypertable_id,
Anum_chunk_index_hypertable_index_name,
_Anum_chunk_index_max,
};
#define Natts_chunk_index (_Anum_chunk_index_max - 1)
typedef struct FormData_chunk_index
{
int32 chunk_id;
NameData index_name;
int32 hypertable_id;
NameData hypertable_index_name;
} FormData_chunk_index;
typedef FormData_chunk_index *Form_chunk_index;
enum
{
CHUNK_INDEX_CHUNK_ID_INDEX_NAME_IDX = 0,
CHUNK_INDEX_HYPERTABLE_ID_HYPERTABLE_INDEX_NAME_IDX,
_MAX_CHUNK_INDEX_INDEX,
};
enum Anum_chunk_index_chunk_id_index_name_idx
{
Anum_chunk_index_chunk_id_index_name_idx_chunk_id = 1,
Anum_chunk_index_chunk_id_index_name_idx_index_name,
_Anum_chunk_index_chunk_id_index_name_idx_max,
};
enum Anum_chunk_index_hypertable_id_hypertable_index_name_idx
{
Anum_chunk_index_hypertable_id_hypertable_index_name_idx_hypertable_id = 1,
Anum_chunk_index_hypertable_id_hypertable_index_name_idx_hypertable_index_name,
Anum_chunk_index_hypertable_id_hypertable_index_name_idx_max,
};
/************************************
*
* Chunk data node table definitions
*
************************************/
#define CHUNK_DATA_NODE_TABLE_NAME "chunk_data_node"
enum Anum_chunk_data_node
{
Anum_chunk_data_node_chunk_id = 1,
Anum_chunk_data_node_node_chunk_id,
Anum_chunk_data_node_node_name,
_Anum_chunk_data_node_max,
};
#define Natts_chunk_data_node (_Anum_chunk_data_node_max - 1)
typedef struct FormData_chunk_data_node
{
int32 chunk_id;
int32 node_chunk_id;
NameData node_name;
} FormData_chunk_data_node;
typedef FormData_chunk_data_node *Form_chunk_data_node;
enum
{
CHUNK_DATA_NODE_CHUNK_ID_NODE_NAME_IDX,
CHUNK_DATA_NODE_NODE_CHUNK_ID_NODE_NAME_IDX,
CHUNK_DATA_NODE_NODE_NAME_IDX,
_MAX_CHUNK_DATA_NODE_INDEX,
};
enum Anum_chunk_data_node_chunk_id_node_name_idx
{
Anum_chunk_data_node_chunk_id_node_name_idx_chunk_id = 1,
Anum_chunk_data_node_chunk_id_node_name_idx_node_name,
_Anum_chunk_data_node_chunk_id_node_name_idx_max,
};
struct FormData_chunk_data_node_chunk_id_node_name_idx
{
int32 chunk_id;
NameData node_name;
};
enum Anum_chunk_data_node_node_chunk_id_node_name_idx
{
Anum_chunk_data_node_node_chunk_id_node_name_idx_chunk_id = 1,
Anum_chunk_data_node_node_chunk_id_node_name_idx_node_name,
_Anum_chunk_data_node_node_chunk_id_node_name_idx_max,
};
struct FormData_chunk_data_node_node_chunk_id_node_name_idx
{
int32 node_chunk_id;
NameData node_name;
};
enum Anum_chunk_data_node_node_name_idx
{
Anum_chunk_data_node_name_idx_node_name = 1,
_Anum_chunk_data_node_node_name_idx_max,
};
struct FormData_chunk_data_node_node_name_idx
{
NameData node_name;
};
/************************************
*
* Tablespace table definitions
*
************************************/
#define TABLESPACE_TABLE_NAME "tablespace"
enum Anum_tablespace
{
Anum_tablespace_id = 1,
Anum_tablespace_hypertable_id,
Anum_tablespace_tablespace_name,
_Anum_tablespace_max,
};
#define Natts_tablespace (_Anum_tablespace_max - 1)
typedef struct FormData_tablespace
{
int32 id;
int32 hypertable_id;
NameData tablespace_name;
} FormData_tablespace;
typedef FormData_tablespace *Form_tablespace;
enum
{
TABLESPACE_PKEY_IDX = 0,
TABLESPACE_HYPERTABLE_ID_TABLESPACE_NAME_IDX,
_MAX_TABLESPACE_INDEX,
};
enum Anum_tablespace_pkey_idx
{
Anum_tablespace_pkey_idx_tablespace_id = 1,
_Anum_tablespace_pkey_idx_max,
};
typedef struct FormData_tablespace_pkey_idx
{
int32 tablespace_id;
} FormData_tablespace_pkey_idx;
enum Anum_tablespace_hypertable_id_tablespace_name_idx
{
Anum_tablespace_hypertable_id_tablespace_name_idx_hypertable_id = 1,
Anum_tablespace_hypertable_id_tablespace_name_idx_tablespace_name,
_Anum_tablespace_hypertable_id_tablespace_name_idx_max,
};
typedef struct FormData_tablespace_hypertable_id_tablespace_name_idx
{
int32 hypertable_id;
NameData tablespace_name;
} FormData_tablespace_hypertable_id_tablespace_name_idx;
/************************************
*
* bgw_job table definitions
*
************************************/
#define BGW_JOB_TABLE_NAME "bgw_job"
enum Anum_bgw_job
{
Anum_bgw_job_id = 1,
Anum_bgw_job_application_name,
Anum_bgw_job_schedule_interval,
Anum_bgw_job_max_runtime,
Anum_bgw_job_max_retries,
Anum_bgw_job_retry_period,
Anum_bgw_job_proc_schema,
Anum_bgw_job_proc_name,
Anum_bgw_job_owner,
Anum_bgw_job_scheduled,
Anum_bgw_job_fixed_schedule,
Anum_bgw_job_initial_start,
Anum_bgw_job_hypertable_id,
Anum_bgw_job_config,
Anum_bgw_job_check_schema,
Anum_bgw_job_check_name,
Anum_bgw_job_timezone,
_Anum_bgw_job_max,
};
#define Natts_bgw_job (_Anum_bgw_job_max - 1)
/* fixed_schedule needs to come before the varlen fields
for GETSTRUCT to work */
typedef struct FormData_bgw_job
{
int32 id;
NameData application_name;
Interval schedule_interval;
Interval max_runtime;
int32 max_retries;
Interval retry_period;
NameData proc_schema;
NameData proc_name;
NameData owner;
bool scheduled;
bool fixed_schedule;
TimestampTz initial_start;
int32 hypertable_id;
Jsonb *config;
NameData check_schema;
NameData check_name;
text *timezone;
} FormData_bgw_job;
typedef FormData_bgw_job *Form_bgw_job;
enum
{
BGW_JOB_PKEY_IDX = 0,
BGW_JOB_PROC_HYPERTABLE_ID_IDX,
_MAX_BGW_JOB_INDEX,
};
enum Anum_bgw_job_pkey_idx
{
Anum_bgw_job_pkey_idx_id = 1,
_Anum_bgw_job_pkey_idx_max,
};
#define Natts_bjw_job_pkey_idx (_Anum_bgw_job_pkey_idx_max - 1)
enum Anum_bgw_job_proc_hypertable_id_idx
{
Anum_bgw_job_proc_hypertable_id_idx_proc_schema = 1,
Anum_bgw_job_proc_hypertable_id_idx_proc_name,
Anum_bgw_job_proc_hypertable_id_idx_hypertable_id,
_Anum_bgw_job_proc_hypertable_id_idx_max,
};
#define Natts_bgw_job_proc_hypertable_id_idx (_Anum_bgw_job_proc_hypertable_id_idx_max - 1)
/************************************
*
* bgw_job_stat table definitions
*
************************************/
#define BGW_JOB_STAT_TABLE_NAME "bgw_job_stat"
enum Anum_bgw_job_stat
{
Anum_bgw_job_stat_job_id = 1,
Anum_bgw_job_stat_last_start,
Anum_bgw_job_stat_last_finish,
Anum_bgw_job_stat_next_start,
Anum_bgw_job_stat_last_successful_finish,
Anum_bgw_job_stat_last_run_success,
Anum_bgw_job_stat_total_runs,
Anum_bgw_job_stat_total_duration,
Anum_bgw_job_stat_total_success,
Anum_bgw_job_stat_total_failures,
Anum_bgw_job_stat_total_crashes,
Anum_bgw_job_stat_consecutive_failures,
Anum_bgw_job_stat_consecutive_crashes,
Anum_bgw_job_stat_flags,
_Anum_bgw_job_stat_max,
};
#define Natts_bgw_job_stat (_Anum_bgw_job_stat_max - 1)
typedef struct FormData_bgw_job_stat
{
int32 id;
TimestampTz last_start;
TimestampTz last_finish;
TimestampTz next_start;
TimestampTz last_successful_finish;
bool last_run_success;
int64 total_runs;
Interval total_duration;
int64 total_success;
int64 total_failures;
int64 total_crashes;
int32 consecutive_failures;
int32 consecutive_crashes;
int32 flags;
} FormData_bgw_job_stat;
typedef FormData_bgw_job_stat *Form_bgw_job_stat;
enum
{
BGW_JOB_STAT_PKEY_IDX = 0,
_MAX_BGW_JOB_STAT_INDEX,
};
enum Anum_bgw_job_stat_pkey_idx
{
Anum_bgw_job_stat_pkey_idx_job_id = 1,
_Anum_bgw_job_stat_pkey_idx_max,
};
#define Natts_bjw_job_stat_pkey_idx (_Anum_bgw_job_stat_pkey_idx_max - 1)
/******************************
*
* metadata table definitions
*
******************************/
#define METADATA_TABLE_NAME "metadata"
enum Anum_metadata
{
Anum_metadata_key = 1,
Anum_metadata_value,
Anum_metadata_include_in_telemetry,
_Anum_metadata_max,
};
#define Natts_metadata (_Anum_metadata_max - 1)
typedef struct FormData_metadata
{
NameData key;
text *value;
} FormData_metadata;
typedef FormData_metadata *Form_metadata;
/* metadata primary index attribute numbers */
enum Anum_metadata_pkey_idx
{
Anum_metadata_pkey_idx_id = 1,
_Anum_metadata_pkey_max,
};
#define Natts_metadata_pkey_idx (_Anum_metadata_pkey_max - 1)
enum
{
METADATA_PKEY_IDX = 0,
_MAX_METADATA_INDEX,
};
/****** BGW_POLICY_CHUNK_STATS TABLE definitions */
#define BGW_POLICY_CHUNK_STATS_TABLE_NAME "bgw_policy_chunk_stats"
enum Anum_bgw_policy_chunk_stats
{
Anum_bgw_policy_chunk_stats_job_id = 1,
Anum_bgw_policy_chunk_stats_chunk_id,
Anum_bgw_policy_chunk_stats_num_times_job_run,
Anum_bgw_policy_chunk_stats_last_time_job_run,
_Anum_bgw_policy_chunk_stats_max,
};
#define Natts_bgw_policy_chunk_stats (_Anum_bgw_policy_chunk_stats_max - 1)
typedef struct FormData_bgw_policy_chunk_stats
{
int32 job_id;
int32 chunk_id;
int32 num_times_job_run;
TimestampTz last_time_job_run;
} FormData_bgw_policy_chunk_stats;
typedef FormData_bgw_policy_chunk_stats *Form_bgw_job_chunk_stats;
enum
{
BGW_POLICY_CHUNK_STATS_JOB_ID_CHUNK_ID_IDX = 0,
_MAX_BGW_POLICY_CHUNK_STATS_INDEX,
};
enum Anum_bgw_policy_chunk_stats_job_id_chunk_id_idx
{
Anum_bgw_policy_chunk_stats_job_id_chunk_id_idx_job_id = 1,
Anum_bgw_policy_chunk_stats_job_id_chunk_id_idx_chunk_id,
_Anum_bgw_policy_chunk_stats_job_id_chunk_id_idx_max,
};
typedef struct FormData_bgw_policy_chunk_stats_job_id_chunk_id_idx
{
int32 job_id;
int32 chunk_id;
} FormData_bgw_policy_chunk_stats_job_id_chunk_id_idx;
/******************************************
*
* continuous_agg table definitions
*
******************************************/
#define CONTINUOUS_AGG_TABLE_NAME "continuous_agg"
typedef enum Anum_continuous_agg
{
Anum_continuous_agg_mat_hypertable_id = 1,
Anum_continuous_agg_raw_hypertable_id,
Anum_continuous_agg_user_view_schema,
Anum_continuous_agg_user_view_name,
Anum_continuous_agg_partial_view_schema,
Anum_continuous_agg_partial_view_name,
Anum_continuous_agg_bucket_width,
Anum_continuous_agg_direct_view_schema,
Anum_continuous_agg_direct_view_name,
Anum_continuous_agg_materialize_only,
Anum_continuous_agg_finalized,
_Anum_continuous_agg_max,
} Anum_continuous_agg;
#define Natts_continuous_agg (_Anum_continuous_agg_max - 1)
typedef struct FormData_continuous_agg
{
int32 mat_hypertable_id;
int32 raw_hypertable_id;
NameData user_view_schema;
NameData user_view_name;
NameData partial_view_schema;
NameData partial_view_name;
/*
* bucket_width is BUCKET_WIDTH_VARIABLE (see continuous_agg.h) for buckets
* with variable size - monthly buckets, buckets with timezone, etc. For such
* buckets the information about the bucketing function is stored in
* _timescaledb_catalog.continuous_aggs_bucket_function.
*
* When possible, don't access bucket_width directly. Use corresponding
* procedures instead, such as:
* - ts_continuous_agg_bucket_width_variable
* - ts_continuous_agg_bucket_width
*/
int64 bucket_width;
NameData direct_view_schema;
NameData direct_view_name;
bool materialized_only;
bool finalized;
} FormData_continuous_agg;
typedef FormData_continuous_agg *Form_continuous_agg;
enum
{
CONTINUOUS_AGG_PARTIAL_VIEW_SCHEMA_PARTIAL_VIEW_NAME_KEY = 0,
CONTINUOUS_AGG_PKEY,
CONTINUOUS_AGG_USER_VIEW_SCHEMA_USER_VIEW_NAME_KEY,
CONTINUOUS_AGG_RAW_HYPERTABLE_ID_IDX,
_MAX_CONTINUOUS_AGG_INDEX,
};
typedef enum Anum_continuous_agg_partial_view_schema_partial_view_name_key
{
Anum_continuous_agg_partial_view_schema_partial_view_name_key_partial_view_schema = 1,
Anum_continuous_agg_partial_view_schema_partial_view_name_key_partial_view_name,
_Anum_continuous_agg_partial_view_schema_partial_view_name_key_max,
} Anum_continuous_agg_partial_view_schema_partial_view_name_key;
#define Natts_continuous_agg_partial_view_schema_partial_view_name_key \
(_Anum_continuous_agg_partial_view_schema_partial_view_name_key_max - 1)
typedef enum Anum_continuous_agg_pkey
{
Anum_continuous_agg_pkey_mat_hypertable_id = 1,