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
|
/*-------------------------------------------------------------------------
*
* redistrib.h
* Routines related to online data redistribution
*
* Copyright (c) 2010-2012 Postgres-XC Development Group
*
*
* IDENTIFICATION
* src/include/pgxc/redistrib.h
*
*-------------------------------------------------------------------------
*/
#ifndef REDISTRIB_H
#define REDISTRIB_H
#include "nodes/parsenodes.h"
#include "utils/tuplestore.h"
/*
* Type of data redistribution operations.
* Online data redistribution is made of one or more of those operations.
*/
typedef enum RedistribOperation {
DISTRIB_NONE, /* Default operation */
DISTRIB_DELETE_HASH, /* Perform a DELETE with hash value check */
DISTRIB_DELETE_MODULO, /* Perform a DELETE with modulo value check */
DISTRIB_COPY_TO, /* Perform a COPY TO */
DISTRIB_COPY_FROM, /* Perform a COPY FROM */
DISTRIB_TRUNCATE, /* Truncate relation */
DISTRIB_REINDEX /* Reindex relation */
} RedistribOperation;
/*
* Determine if operation can be done before or after
* catalog update on local node.
*/
typedef enum RedistribCatalog {
CATALOG_UPDATE_NONE, /* Default state */
CATALOG_UPDATE_AFTER, /* After catalog update */
CATALOG_UPDATE_BEFORE, /* Before catalog update */
CATALOG_UPDATE_BOTH /* Before and after catalog update */
} RedistribCatalog;
/*
* Redistribution command
* This contains the tools necessary to perform a redistribution operation.
*/
typedef struct RedistribCommand {
RedistribOperation type; /* Operation type */
ExecNodes *execNodes; /* List of nodes where to perform operation */
RedistribCatalog updateState; /* Flag to determine if operation can be done
* before or after catalog update */
} RedistribCommand;
/*
* Redistribution operation state
* Maintainer of redistribution state having the list of commands
* to be performed during redistribution.
* For the list of commands, we use an array and not a simple list as operations
* might need to be done in a certain order.
*/
typedef struct RedistribState {
Oid relid; /* Oid of relation redistributed */
List *commands; /* List of commands */
Tuplestorestate *store; /* Tuple store used for temporary data storage */
} RedistribState;
extern void PGXCRedistribTable(RedistribState *distribState, RedistribCatalog type);
extern void PGXCRedistribCreateCommandList(RedistribState *distribState,
RelationLocInfo *newLocInfo);
extern RedistribCommand *makeRedistribCommand(RedistribOperation type,
RedistribCatalog updateState,
ExecNodes *nodes);
extern RedistribState *makeRedistribState(Oid relOid);
extern void FreeRedistribState(RedistribState *state);
extern void FreeRedistribCommand(RedistribCommand *command);
#endif /* REDISTRIB_H */
|