forked from citusdata/pg_shard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg_shard.h
90 lines (71 loc) · 2.64 KB
/
pg_shard.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
/*-------------------------------------------------------------------------
*
* pg_shard.h
*
* Declarations for public functions and types needed by the pg_shard extension.
*
* Copyright (c) 2014, Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_SHARD_H
#define PG_SHARD_H
#include "c.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
#include "nodes/plannodes.h"
#include "lib/stringinfo.h"
/* prefix used for temporary tables created on the master node */
#define TEMPORARY_TABLE_PREFIX "pg_shard_temp_table"
/* extension name used to determine if extension has been created */
#define PG_SHARD_EXTENSION_NAME "pg_shard"
/*
* DistributedNodeTag identifies nodes used in the planning and execution of
* queries interacting with distributed tables.
*/
typedef enum DistributedNodeTag
{
/* Tags for distributed planning begin a safe distance after all other tags. */
T_DistributedPlan = 2100, /* plan to be built and passed to executor */
} DistributedNodeTag;
/*
* PlannerType identifies the type of planner which should be used for a given
* query.
*/
typedef enum PlannerType
{
PLANNER_INVALID_FIRST = 0,
PLANNER_TYPE_CITUSDB = 1,
PLANNER_TYPE_PG_SHARD = 2,
PLANNER_TYPE_POSTGRES = 3
} PlannerType;
/*
* DistributedPlan contains a set of tasks to be executed remotely as part of a
* distributed query.
*/
typedef struct DistributedPlan
{
Plan plan; /* this is a "subclass" of Plan */
Plan *originalPlan; /* we save a copy of standard_planner's output */
List *taskList; /* list of tasks to run as part of this plan */
List *targetList; /* copy of the target list for remote SELECT queries only */
bool selectFromMultipleShards; /* does the select run across multiple shards? */
CreateStmt *createTemporaryTableStmt; /* valid for multiple shard selects */
} DistributedPlan;
/*
* Tasks just bundle a query string (already ready for execution) with a list of
* placements on which that string could be executed. The semantics of a task
* will vary based on the type of statement being executed: an INSERT must be
* executed on all placements, but a SELECT might view subsequent placements as
* fallbacks to be used only if the first placement fails to respond.
*/
typedef struct Task
{
StringInfo queryString; /* SQL string suitable for immediate remote execution */
List *taskPlacementList; /* ShardPlacements on which the task can be executed */
int64 shardId; /* Denormalized shardId of tasks for convenience */
} Task;
/* function declarations for extension loading and unloading */
extern void _PG_init(void);
extern void _PG_fini(void);
#endif /* PG_SHARD_H */