1 /*-------------------------------------------------------------------------
2  *
3  * pg_dist_partition.h
4  *	  definition of the system "remote partition" relation (pg_dist_partition).
5  *
6  * This table keeps metadata on logical tables that the user requested remote
7  * partitioning for (smaller physical tables that we partition data to are
8  * handled in another system catalog).
9  *
10  * Copyright (c) Citus Data, Inc.
11  *
12  *-------------------------------------------------------------------------
13  */
14 
15 #ifndef PG_DIST_PARTITION_H
16 #define PG_DIST_PARTITION_H
17 
18 /* ----------------
19  *		pg_dist_partition definition.
20  * ----------------
21  */
22 typedef struct FormData_pg_dist_partition
23 {
24 	Oid logicalrelid;    /* logical relation id; references pg_class oid */
25 	char partmethod;     /* partition method; see codes below */
26 #ifdef CATALOG_VARLEN    /* variable-length fields start here */
27 	text partkey;        /* partition key expression */
28 	uint32 colocationid; /* id of the co-location group of particular table belongs to */
29 	char repmodel;       /* replication model; see codes below */
30 #endif
31 } FormData_pg_dist_partition;
32 
33 /* ----------------
34  *      Form_pg_dist_partitions corresponds to a pointer to a tuple with
35  *      the format of pg_dist_partitions relation.
36  * ----------------
37  */
38 typedef FormData_pg_dist_partition *Form_pg_dist_partition;
39 
40 /* ----------------
41  *      compiler constants for pg_dist_partitions
42  * ----------------
43  */
44 #define Natts_pg_dist_partition 5
45 #define Anum_pg_dist_partition_logicalrelid 1
46 #define Anum_pg_dist_partition_partmethod 2
47 #define Anum_pg_dist_partition_partkey 3
48 #define Anum_pg_dist_partition_colocationid 4
49 #define Anum_pg_dist_partition_repmodel 5
50 
51 /* valid values for partmethod include append, hash, and range */
52 #define DISTRIBUTE_BY_APPEND 'a'
53 #define DISTRIBUTE_BY_HASH 'h'
54 #define DISTRIBUTE_BY_RANGE 'r'
55 #define DISTRIBUTE_BY_NONE 'n'
56 #define REDISTRIBUTE_BY_HASH 'x'
57 #define DISTRIBUTE_BY_INVALID '\0'
58 
59 /*
60  * Valid values for repmodel are 'c' for coordinator, 's' for streaming
61  * and 't' for two-phase-commit. We also use an invalid replication model
62  * ('i') for distinguishing uninitialized variables where necessary.
63  */
64 #define REPLICATION_MODEL_COORDINATOR 'c'
65 #define REPLICATION_MODEL_STREAMING 's'
66 #define REPLICATION_MODEL_2PC 't'
67 #define REPLICATION_MODEL_INVALID 'i'
68 
69 
70 #endif   /* PG_DIST_PARTITION_H */
71