summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPavan Deolasee2014-09-01 13:07:30 +0000
committerPavan Deolasee2014-09-01 13:07:30 +0000
commit8642a0b6269c9d7212a968441266ebc64e90ded8 (patch)
tree1fdea16f55446329c613431af6c4e836a9348afb /src/include
parentfd159b3983473599768ca36ed8e4b8bfa1ed1969 (diff)
The Postgres-XL functionality includes MPP parallelism with
data node to data node communication, more stringent security, and other performance enhancements. Please see release notes. Key contributors are: Andrei Martsinchyk Nikhil Sontakke Mason Sharp
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile3
-rw-r--r--src/include/access/gtm.h13
-rw-r--r--src/include/access/htup.h21
-rw-r--r--src/include/access/transam.h9
-rw-r--r--src/include/access/xact.h7
-rw-r--r--src/include/bootstrap/bootstrap.h3
-rw-r--r--src/include/catalog/catalog.h10
-rw-r--r--src/include/catalog/namespace.h8
-rw-r--r--src/include/catalog/pg_aggregate.h264
-rw-r--r--src/include/catalog/pg_namespace.h10
-rw-r--r--src/include/catalog/pg_proc.h15
-rw-r--r--src/include/catalog/pg_type.h8
-rw-r--r--src/include/commands/sequence.h9
-rw-r--r--src/include/commands/tablecmds.h4
-rw-r--r--src/include/commands/trigger.h5
-rw-r--r--src/include/commands/vacuum.h9
-rw-r--r--src/include/commands/variable.h9
-rw-r--r--src/include/executor/execdesc.h16
-rw-r--r--src/include/executor/executor.h12
-rw-r--r--src/include/executor/producerReceiver.h33
-rw-r--r--src/include/executor/tuptable.h24
-rw-r--r--src/include/gtm/gtm.h9
-rw-r--r--src/include/gtm/gtm_c.h2
-rw-r--r--src/include/gtm/gtm_client.h38
-rw-r--r--src/include/gtm/gtm_msg.h13
-rw-r--r--src/include/gtm/gtm_seq.h38
-rw-r--r--src/include/gtm/gtm_serialize.h6
-rw-r--r--src/include/gtm/gtm_standby.h5
-rw-r--r--src/include/gtm/gtm_txn.h6
-rw-r--r--src/include/gtm/register.h25
-rw-r--r--src/include/libpq/hba.h3
-rw-r--r--src/include/miscadmin.h10
-rw-r--r--src/include/nodes/execnodes.h20
-rw-r--r--src/include/nodes/nodes.h31
-rw-r--r--src/include/nodes/params.h8
-rw-r--r--src/include/nodes/parsenodes.h24
-rw-r--r--src/include/nodes/plannodes.h45
-rw-r--r--src/include/nodes/primnodes.h7
-rw-r--r--src/include/nodes/relation.h87
-rw-r--r--src/include/optimizer/cost.h23
-rw-r--r--src/include/optimizer/pathnode.h17
-rw-r--r--src/include/optimizer/paths.h13
-rw-r--r--src/include/optimizer/planmain.h37
-rw-r--r--src/include/optimizer/planner.h4
-rw-r--r--src/include/parser/analyze.h8
-rw-r--r--src/include/parser/kwlist.h6
-rw-r--r--src/include/parser/parse_agg.h14
-rw-r--r--src/include/parser/parse_utilcmd.h12
-rw-r--r--src/include/pg_config.h.win328
-rw-r--r--src/include/pgstat.h10
-rw-r--r--src/include/pgxc/execRemote.h241
-rw-r--r--src/include/pgxc/locator.h153
-rw-r--r--src/include/pgxc/pause.h38
-rw-r--r--src/include/pgxc/pgxc.h23
-rw-r--r--src/include/pgxc/pgxcnode.h59
-rw-r--r--src/include/pgxc/planner.h236
-rw-r--r--src/include/pgxc/poolmgr.h38
-rw-r--r--src/include/pgxc/postgresql_fdw.h23
-rw-r--r--src/include/pgxc/remotecopy.h11
-rw-r--r--src/include/pgxc/squeue.h60
-rw-r--r--src/include/storage/backendid.h20
-rw-r--r--src/include/storage/lwlock.h8
-rw-r--r--src/include/storage/proc.h11
-rw-r--r--src/include/storage/procarray.h10
-rw-r--r--src/include/storage/procsignal.h5
-rw-r--r--src/include/storage/smgr.h11
-rw-r--r--src/include/tcop/dest.h9
-rw-r--r--src/include/tcop/pquery.h10
-rw-r--r--src/include/tcop/utility.h4
-rw-r--r--src/include/utils/builtins.h19
-rw-r--r--src/include/utils/guc.h9
-rw-r--r--src/include/utils/lsyscache.h19
-rw-r--r--src/include/utils/plancache.h9
-rw-r--r--src/include/utils/portal.h19
-rw-r--r--src/include/utils/rel.h54
-rw-r--r--src/include/utils/tuplesort.h9
-rw-r--r--src/include/utils/tuplestore.h15
77 files changed, 1803 insertions, 341 deletions
diff --git a/src/include/Makefile b/src/include/Makefile
index 5f5e6819d6..74de25eb3e 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -22,8 +22,7 @@ SUBDIRS = access bootstrap catalog commands datatype executor foreign lib libpq
tcop snowball snowball/libstemmer tsearch tsearch/dicts utils \
port port/win32 port/win32_msvc port/win32_msvc/sys \
port/win32/arpa port/win32/netinet port/win32/sys \
- portability \
- gtm
+ portability gtm
# Install all headers
install: all installdirs
diff --git a/src/include/access/gtm.h b/src/include/access/gtm.h
index 5c5692b2c5..5c70872a1b 100644
--- a/src/include/access/gtm.h
+++ b/src/include/access/gtm.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* gtm.h
- *
+ *
* Module interfacing with GTM definitions
*
*
@@ -16,6 +16,9 @@
extern char *GtmHost;
extern int GtmPort;
+#ifdef XCP
+extern bool IsXidFromGTM;
+#endif
extern GlobalTransactionId currentGxid;
extern bool IsGTMConnected(void);
@@ -43,9 +46,15 @@ extern int RegisterGTM(GTM_PGXCNodeType type, GTM_PGXCNodePort port, char *dataf
extern int UnregisterGTM(GTM_PGXCNodeType type);
/* Sequence interface APIs with GTM */
+extern GTM_Sequence GetCurrentValGTM(char *seqname);
+#ifdef XCP
+extern GTM_Sequence GetNextValGTM(char *seqname,
+ GTM_Sequence range, GTM_Sequence *rangemax);
+#else
extern GTM_Sequence GetNextValGTM(char *seqname);
+#endif
extern int SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled);
-extern int CreateSequenceGTM(char *seqname, GTM_Sequence increment,
+extern int CreateSequenceGTM(char *seqname, GTM_Sequence increment,
GTM_Sequence minval, GTM_Sequence maxval, GTM_Sequence startval,
bool cycle);
extern int AlterSequenceGTM(char *seqname, GTM_Sequence increment,
diff --git a/src/include/access/htup.h b/src/include/access/htup.h
index c93a7fb36e..fbb802e4c9 100644
--- a/src/include/access/htup.h
+++ b/src/include/access/htup.h
@@ -4,6 +4,11 @@
* POSTGRES heap tuple definitions.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -534,6 +539,22 @@ typedef HeapTupleData *HeapTuple;
*/
#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
+#ifdef XCP
+/*
+ * Represents a DataRow message received from a remote node.
+ * Contains originating node number and message body in DataRow format without
+ * message code and length. Length and node number are separate fields.
+ * This is a variable length structure.
+ */
+typedef struct RemoteDataRowData
+{
+ Oid msgnode; /* node number of the data row message */
+ int msglen; /* length of the data row message */
+ char msg[0]; /* last data row message */
+} RemoteDataRowData;
+typedef RemoteDataRowData *RemoteDataRow;
+#endif
+
/*
* Accessor macros to be used with HeapTuple pointers.
*/
diff --git a/src/include/access/transam.h b/src/include/access/transam.h
index e9e5edda25..b9d46e3504 100644
--- a/src/include/access/transam.h
+++ b/src/include/access/transam.h
@@ -4,6 +4,11 @@
* postgres transaction access method support code
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -173,6 +178,10 @@ extern TransactionId GetNewTransactionId(bool isSubXact, bool *timestamp_receive
#else
extern TransactionId GetNewTransactionId(bool isSubXact);
#endif /* PGXC */
+#ifdef XCP
+extern bool TransactionIdIsCurrentGlobalTransactionId(TransactionId xid);
+extern TransactionId GetNextTransactionId(void);
+#endif
extern TransactionId ReadNewTransactionId(void);
extern void SetTransactionIdLimit(TransactionId oldest_datfrozenxid,
Oid oldest_datoid);
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index 82999726a0..127a849c10 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -4,6 +4,11 @@
* postgres transaction system definitions
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -228,8 +233,10 @@ extern TransactionId GetTopTransactionIdIfAny(void);
extern TransactionId GetCurrentTransactionId(void);
extern TransactionId GetCurrentTransactionIdIfAny(void);
#ifdef PGXC /* PGXC_COORD */
+#ifndef XCP
extern bool GetCurrentLocalParamStatus(void);
extern void SetCurrentLocalParamStatus(bool status);
+#endif
extern GlobalTransactionId GetAuxilliaryTransactionId(void);
extern GlobalTransactionId GetTopGlobalTransactionId(void);
extern void SetAuxilliaryTransactionId(GlobalTransactionId gxid);
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 47224d3dd2..7f0ed6db2b 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -28,8 +28,7 @@ typedef enum
WalReceiverProcess,
#ifdef PGXC
PoolerProcess,
-#endif
-
+#endif
NUM_AUXPROCTYPES /* Must be last! */
} AuxProcType;
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
index 678a945271..5a1861da6e 100644
--- a/src/include/catalog/catalog.h
+++ b/src/include/catalog/catalog.h
@@ -4,6 +4,11 @@
* prototypes for functions in backend/catalog/catalog.c
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -36,8 +41,13 @@ extern char *relpathbackend(RelFileNode rnode, BackendId backend,
extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
/* First argument is a RelFileNodeBackend */
+#ifdef XCP
+#define relpath(rnode, forknum) \
+ relpathbackend((rnode).node, InvalidBackendId, (forknum))
+#else
#define relpath(rnode, forknum) \
relpathbackend((rnode).node, (rnode).backend, (forknum))
+#endif
/* First argument is a RelFileNode */
#define relpathperm(rnode, forknum) \
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h
index 76215dc8a1..0c2d245e90 100644
--- a/src/include/catalog/namespace.h
+++ b/src/include/catalog/namespace.h
@@ -4,6 +4,11 @@
* prototypes for functions in backend/catalog/namespace.c
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -125,6 +130,9 @@ extern bool isOtherTempNamespace(Oid namespaceId);
extern int GetTempNamespaceBackendId(Oid namespaceId);
extern Oid GetTempToastNamespace(void);
extern void ResetTempTableNamespace(void);
+#ifdef XCP
+extern void ForgetTempTableNamespace(void);
+#endif
extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context);
extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path);
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index ce8fc1b156..7bf70e4ff8 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -5,6 +5,11 @@
* along with the relation's initial contents.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -40,6 +45,9 @@
* aggfinalfn final function (0 if none)
* aggsortop associated sort operator (0 if none)
* aggtranstype type of aggregate's transition (state) data
+#ifdef PGXC
+ * aggcollecttype type of aggregate's collection (state) data
+#endif
* agginitval initial value for transition state (can be NULL)
#ifdef PGXC
* agginitcollect initial value for collection state (can be NULL)
@@ -56,6 +64,7 @@ CATALOG(pg_aggregate,2600) BKI_WITHOUT_OIDS
regproc aggfinalfn;
Oid aggsortop;
Oid aggtranstype;
+ Oid aggcollecttype; /* PGXC */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text agginitval;
@@ -76,15 +85,16 @@ typedef FormData_pg_aggregate *Form_pg_aggregate;
*/
#ifdef PGXC
-#define Natts_pg_aggregate 8
+#define Natts_pg_aggregate 9
#define Anum_pg_aggregate_aggfnoid 1
#define Anum_pg_aggregate_aggtransfn 2
#define Anum_pg_aggregate_aggcollectfn 3
#define Anum_pg_aggregate_aggfinalfn 4
#define Anum_pg_aggregate_aggsortop 5
#define Anum_pg_aggregate_aggtranstype 6
-#define Anum_pg_aggregate_agginitval 7
-#define Anum_pg_aggregate_agginitcollect 8
+#define Anum_pg_aggregate_aggcollecttype 7
+#define Anum_pg_aggregate_agginitval 8
+#define Anum_pg_aggregate_agginitcollect 9
#endif
#ifdef PGXC
//#define Natts_pg_aggregate 6
@@ -104,13 +114,13 @@ typedef FormData_pg_aggregate *Form_pg_aggregate;
/* avg */
#ifdef PGXC
-DATA(insert ( 2100 int8_avg_accum numeric_avg_collect numeric_avg 0 1231 "{0,0}" "{0,0}" ));
-DATA(insert ( 2101 int4_avg_accum int8_avg_collect int8_avg 0 1016 "{0,0}" "{0,0}" ));
-DATA(insert ( 2102 int2_avg_accum int8_avg_collect int8_avg 0 1016 "{0,0}" "{0,0}" ));
-DATA(insert ( 2103 numeric_avg_accum numeric_avg_collect numeric_avg 0 1231 "{0,0}" "{0,0}" ));
-DATA(insert ( 2104 float4_accum float8_collect float8_avg 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2105 float8_accum float8_collect float8_avg 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2106 interval_accum interval_collect interval_avg 0 1187 "{0 second,0 second}" "{0 second,0 second}" ));
+DATA(insert ( 2100 int8_avg_accum numeric_avg_collect numeric_avg 0 1231 1231 "{0,0}" "{0,0}" ));
+DATA(insert ( 2101 int4_avg_accum int8_avg_collect int8_avg 0 1016 1016 "{0,0}" "{0,0}" ));
+DATA(insert ( 2102 int2_avg_accum int8_avg_collect int8_avg 0 1016 1016 "{0,0}" "{0,0}" ));
+DATA(insert ( 2103 numeric_avg_accum numeric_avg_collect numeric_avg 0 1231 1231 "{0,0}" "{0,0}" ));
+DATA(insert ( 2104 float4_accum float8_collect float8_avg 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2105 float8_accum float8_collect float8_avg 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2106 interval_accum interval_collect interval_avg 0 1187 1187 "{0 second,0 second}" "{0 second,0 second}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2100 int8_avg_accum numeric_avg 0 1231 "{0,0}" ));
@@ -124,14 +134,14 @@ DATA(insert ( 2106 interval_accum interval_collect interval_avg 0 1187 "{0 secon
/* sum */
#ifdef PGXC
-DATA(insert ( 2107 int8_sum numeric_add - 0 1700 _null_ "0" ));
-DATA(insert ( 2108 int4_sum int8_sum_to_int8 - 0 20 _null_ _null_ ));
-DATA(insert ( 2109 int2_sum int8_sum_to_int8 - 0 20 _null_ _null_ ));
-DATA(insert ( 2110 float4pl float4pl - 0 700 _null_ "0" ));
-DATA(insert ( 2111 float8pl float8pl - 0 701 _null_ "0" ));
-DATA(insert ( 2112 cash_pl cash_pl - 0 790 _null_ _null_ ));
-DATA(insert ( 2113 interval_pl interval_pl - 0 1186 _null_ _null_ ));
-DATA(insert ( 2114 numeric_add numeric_add - 0 1700 _null_ "0" ));
+DATA(insert ( 2107 int8_sum numeric_add - 0 1700 1700 _null_ _null_ ));
+DATA(insert ( 2108 int4_sum int8_sum_to_int8 - 0 20 20 _null_ _null_ ));
+DATA(insert ( 2109 int2_sum int8_sum_to_int8 - 0 20 20 _null_ _null_ ));
+DATA(insert ( 2110 float4pl float4pl - 0 700 700 _null_ _null_ ));
+DATA(insert ( 2111 float8pl float8pl - 0 701 701 _null_ _null_ ));
+DATA(insert ( 2112 cash_pl cash_pl - 0 790 790 _null_ _null_ ));
+DATA(insert ( 2113 interval_pl interval_pl - 0 1186 1186 _null_ _null_ ));
+DATA(insert ( 2114 numeric_add numeric_add - 0 1700 1700 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2107 int8_sum - 0 1700 _null_ ));
@@ -146,26 +156,26 @@ DATA(insert ( 2114 numeric_add numeric_add - 0 1700 _null_ "0" ));
/* max */
#ifdef PGXC
-DATA(insert ( 2115 int8larger int8larger - 413 20 _null_ _null_ ));
-DATA(insert ( 2116 int4larger int4larger - 521 23 _null_ _null_ ));
-DATA(insert ( 2117 int2larger int2larger - 520 21 _null_ _null_ ));
-DATA(insert ( 2118 oidlarger oidlarger - 610 26 _null_ _null_ ));
-DATA(insert ( 2119 float4larger float4larger - 623 700 _null_ _null_ ));
-DATA(insert ( 2120 float8larger float8larger - 674 701 _null_ _null_ ));
-DATA(insert ( 2121 int4larger int4larger - 563 702 _null_ _null_ ));
-DATA(insert ( 2122 date_larger date_larger - 1097 1082 _null_ _null_ ));
-DATA(insert ( 2123 time_larger time_larger - 1112 1083 _null_ _null_ ));
-DATA(insert ( 2124 timetz_larger timetz_larger - 1554 1266 _null_ _null_ ));
-DATA(insert ( 2125 cashlarger cashlarger - 903 790 _null_ _null_ ));
-DATA(insert ( 2126 timestamp_larger timestamp_larger - 2064 1114 _null_ _null_ ));
-DATA(insert ( 2127 timestamptz_larger timestamptz_larger - 1324 1184 _null_ _null_ ));
-DATA(insert ( 2128 interval_larger interval_larger - 1334 1186 _null_ _null_ ));
-DATA(insert ( 2129 text_larger text_larger - 666 25 _null_ _null_ ));
-DATA(insert ( 2130 numeric_larger numeric_larger - 1756 1700 _null_ _null_ ));
-DATA(insert ( 2050 array_larger array_larger - 1073 2277 _null_ _null_ ));
-DATA(insert ( 2244 bpchar_larger bpchar_larger - 1060 1042 _null_ _null_ ));
-DATA(insert ( 2797 tidlarger tidlarger - 2800 27 _null_ _null_ ));
-DATA(insert ( 3526 enum_larger enum_larger - 3519 3500 _null_ _null_ ));
+DATA(insert ( 2115 int8larger int8larger - 413 20 20 _null_ _null_ ));
+DATA(insert ( 2116 int4larger int4larger - 521 23 23 _null_ _null_ ));
+DATA(insert ( 2117 int2larger int2larger - 520 21 21 _null_ _null_ ));
+DATA(insert ( 2118 oidlarger oidlarger - 610 26 26 _null_ _null_ ));
+DATA(insert ( 2119 float4larger float4larger - 623 700 700 _null_ _null_ ));
+DATA(insert ( 2120 float8larger float8larger - 674 701 701 _null_ _null_ ));
+DATA(insert ( 2121 int4larger int4larger - 563 702 702 _null_ _null_ ));
+DATA(insert ( 2122 date_larger date_larger - 1097 1082 1082 _null_ _null_ ));
+DATA(insert ( 2123 time_larger time_larger - 1112 1083 1083 _null_ _null_ ));
+DATA(insert ( 2124 timetz_larger timetz_larger - 1554 1266 1266 _null_ _null_ ));
+DATA(insert ( 2125 cashlarger cashlarger - 903 790 790 _null_ _null_ ));
+DATA(insert ( 2126 timestamp_larger timestamp_larger - 2064 1114 1114 _null_ _null_ ));
+DATA(insert ( 2127 timestamptz_larger timestamptz_larger - 1324 1184 1184 _null_ _null_ ));
+DATA(insert ( 2128 interval_larger interval_larger - 1334 1186 1186 _null_ _null_ ));
+DATA(insert ( 2129 text_larger text_larger - 666 25 25 _null_ _null_ ));
+DATA(insert ( 2130 numeric_larger numeric_larger - 1756 1700 1700 _null_ _null_ ));
+DATA(insert ( 2050 array_larger array_larger - 1073 2277 2277 _null_ _null_ ));
+DATA(insert ( 2244 bpchar_larger bpchar_larger - 1060 1042 1042 _null_ _null_ ));
+DATA(insert ( 2797 tidlarger tidlarger - 2800 27 27 _null_ _null_ ));
+DATA(insert ( 3526 enum_larger enum_larger - 3519 3500 3500 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2115 int8larger - 413 20 _null_ ));
@@ -192,26 +202,26 @@ DATA(insert ( 3526 enum_larger enum_larger - 3519 3500 _null_ _null_ ));
/* min */
#ifdef PGXC
-DATA(insert ( 2131 int8smaller int8smaller - 412 20 _null_ _null_ ));
-DATA(insert ( 2132 int4smaller int4smaller - 97 23 _null_ _null_ ));
-DATA(insert ( 2133 int2smaller int2smaller - 95 21 _null_ _null_ ));
-DATA(insert ( 2134 oidsmaller oidsmaller - 609 26 _null_ _null_ ));
-DATA(insert ( 2135 float4smaller float4smaller - 622 700 _null_ _null_ ));
-DATA(insert ( 2136 float8smaller float8smaller - 672 701 _null_ _null_ ));
-DATA(insert ( 2137 int4smaller int4smaller - 562 702 _null_ _null_ ));
-DATA(insert ( 2138 date_smaller date_smaller - 1095 1082 _null_ _null_ ));
-DATA(insert ( 2139 time_smaller time_smaller - 1110 1083 _null_ _null_ ));
-DATA(insert ( 2140 timetz_smaller timetz_smaller - 1552 1266 _null_ _null_ ));
-DATA(insert ( 2141 cashsmaller cashsmaller - 902 790 _null_ _null_ ));
-DATA(insert ( 2142 timestamp_smaller timestamp_smaller - 2062 1114 _null_ _null_ ));
-DATA(insert ( 2143 timestamptz_smaller timestamptz_smaller - 1322 1184 _null_ _null_ ));
-DATA(insert ( 2144 interval_smaller interval_smaller - 1332 1186 _null_ _null_ ));
-DATA(insert ( 2145 text_smaller text_smaller - 664 25 _null_ _null_ ));
-DATA(insert ( 2146 numeric_smaller numeric_smaller - 1754 1700 _null_ _null_ ));
-DATA(insert ( 2051 array_smaller array_smaller - 1072 2277 _null_ _null_ ));
-DATA(insert ( 2245 bpchar_smaller bpchar_smaller - 1058 1042 _null_ _null_ ));
-DATA(insert ( 2798 tidsmaller tidsmaller - 2799 27 _null_ _null_ ));
-DATA(insert ( 3527 enum_smaller enum_smaller - 3518 3500 _null_ _null_ ));
+DATA(insert ( 2131 int8smaller int8smaller - 412 20 20 _null_ _null_ ));
+DATA(insert ( 2132 int4smaller int4smaller - 97 23 23 _null_ _null_ ));
+DATA(insert ( 2133 int2smaller int2smaller - 95 21 21 _null_ _null_ ));
+DATA(insert ( 2134 oidsmaller oidsmaller - 609 26 26 _null_ _null_ ));
+DATA(insert ( 2135 float4smaller float4smaller - 622 700 700 _null_ _null_ ));
+DATA(insert ( 2136 float8smaller float8smaller - 672 701 701 _null_ _null_ ));
+DATA(insert ( 2137 int4smaller int4smaller - 562 702 702 _null_ _null_ ));
+DATA(insert ( 2138 date_smaller date_smaller - 1095 1082 1082 _null_ _null_ ));
+DATA(insert ( 2139 time_smaller time_smaller - 1110 1083 1083 _null_ _null_ ));
+DATA(insert ( 2140 timetz_smaller timetz_smaller - 1552 1266 1266 _null_ _null_ ));
+DATA(insert ( 2141 cashsmaller cashsmaller - 902 790 790 _null_ _null_ ));
+DATA(insert ( 2142 timestamp_smaller timestamp_smaller - 2062 1114 1114 _null_ _null_ ));
+DATA(insert ( 2143 timestamptz_smaller timestamptz_smaller - 1322 1184 1184 _null_ _null_ ));
+DATA(insert ( 2144 interval_smaller interval_smaller - 1332 1186 1186 _null_ _null_ ));
+DATA(insert ( 2145 text_smaller text_smaller - 664 25 25 _null_ _null_ ));
+DATA(insert ( 2146 numeric_smaller numeric_smaller - 1754 1700 1700 _null_ _null_ ));
+DATA(insert ( 2051 array_smaller array_smaller - 1072 2277 2277 _null_ _null_ ));
+DATA(insert ( 2245 bpchar_smaller bpchar_smaller - 1058 1042 1042 _null_ _null_ ));
+DATA(insert ( 2798 tidsmaller tidsmaller - 2799 27 27 _null_ _null_ ));
+DATA(insert ( 3527 enum_smaller enum_smaller - 3518 3500 3500 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2131 int8smaller - 412 20 _null_ ));
@@ -239,8 +249,8 @@ DATA(insert ( 3527 enum_smaller enum_smaller - 3518 3500 _null_ _null_ ));
/* count */
/* Final function is data type conversion function numeric_int8 is referenced by OID because of ambiguous definition in pg_proc */
#ifdef PGXC
-DATA(insert ( 2147 int8inc_any int8_sum_to_int8 - 0 20 "0" "0" ));
-DATA(insert ( 2803 int8inc int8_sum_to_int8 - 0 20 "0" "0" ));
+DATA(insert ( 2147 int8inc_any int8_sum_to_int8 - 0 20 20 "0" _null_ ));
+DATA(insert ( 2803 int8inc int8_sum_to_int8 - 0 20 20 "0" _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2147 int8inc_any - 0 20 "0" ));
@@ -249,12 +259,12 @@ DATA(insert ( 2803 int8inc int8_sum_to_int8 - 0 20 "0" "0" ));
/* var_pop */
#ifdef PGXC
-DATA(insert ( 2718 int8_accum numeric_collect numeric_var_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2719 int4_accum numeric_collect numeric_var_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2720 int2_accum numeric_collect numeric_var_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2721 float4_accum float8_collect float8_var_pop 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2722 float8_accum float8_collect float8_var_pop 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2723 numeric_accum numeric_collect numeric_var_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2718 int8_accum numeric_collect numeric_var_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2719 int4_accum numeric_collect numeric_var_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2720 int2_accum numeric_collect numeric_var_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2721 float4_accum float8_collect float8_var_pop 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2722 float8_accum float8_collect float8_var_pop 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2723 numeric_accum numeric_collect numeric_var_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2718 int8_accum numeric_var_pop 0 1231 "{0,0,0}" ));
@@ -267,12 +277,12 @@ DATA(insert ( 2723 numeric_accum numeric_collect numeric_var_pop 0 1231 "{0,0,0
/* var_samp */
#ifdef PGXC
-DATA(insert ( 2641 int8_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2642 int4_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2643 int2_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2644 float4_accum float8_collect float8_var_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2645 float8_accum float8_collect float8_var_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2646 numeric_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2641 int8_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2642 int4_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2643 int2_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2644 float4_accum float8_collect float8_var_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2645 float8_accum float8_collect float8_var_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2646 numeric_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2641 int8_accum numeric_var_samp 0 1231 "{0,0,0}" ));
@@ -285,12 +295,12 @@ DATA(insert ( 2646 numeric_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0
/* variance: historical Postgres syntax for var_samp */
#ifdef PGXC
-DATA(insert ( 2148 int8_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2149 int4_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2150 int2_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2151 float4_accum float8_collect float8_var_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2152 float8_accum float8_collect float8_var_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2153 numeric_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2148 int8_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2149 int4_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2150 int2_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2151 float4_accum float8_collect float8_var_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2152 float8_accum float8_collect float8_var_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2153 numeric_accum numeric_collect numeric_var_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2148 int8_accum numeric_var_samp 0 1231 "{0,0,0}" ));
@@ -303,12 +313,12 @@ DATA(insert ( 2153 numeric_accum numeric_collect numeric_var_samp 0 1231 "{0,0,0
/* stddev_pop */
#ifdef PGXC
-DATA(insert ( 2724 int8_accum numeric_collect numeric_stddev_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2725 int4_accum numeric_collect numeric_stddev_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2726 int2_accum numeric_collect numeric_stddev_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2727 float4_accum float8_collect float8_stddev_pop 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2728 float8_accum float8_collect float8_stddev_pop 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2729 numeric_accum numeric_collect numeric_stddev_pop 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2724 int8_accum numeric_collect numeric_stddev_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2725 int4_accum numeric_collect numeric_stddev_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2726 int2_accum numeric_collect numeric_stddev_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2727 float4_accum float8_collect float8_stddev_pop 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2728 float8_accum float8_collect float8_stddev_pop 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2729 numeric_accum numeric_collect numeric_stddev_pop 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2724 int8_accum numeric_stddev_pop 0 1231 "{0,0,0}" ));
@@ -321,12 +331,12 @@ DATA(insert ( 2729 numeric_accum numeric_collect numeric_stddev_pop 0 1231 "{0,0
/* stddev_samp */
#ifdef PGXC
-DATA(insert ( 2712 int8_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2713 int4_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2714 int2_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2715 float4_accum float8_collect float8_stddev_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2716 float8_accum float8_collect float8_stddev_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2717 numeric_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2712 int8_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2713 int4_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2714 int2_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2715 float4_accum float8_collect float8_stddev_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2716 float8_accum float8_collect float8_stddev_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2717 numeric_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2712 int8_accum numeric_stddev_samp 0 1231 "{0,0,0}" ));
@@ -339,12 +349,12 @@ DATA(insert ( 2717 numeric_accum numeric_collect numeric_stddev_samp 0 1231 "{0,
/* stddev: historical Postgres syntax for stddev_samp */
#ifdef PGXC
-DATA(insert ( 2154 int8_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2155 int4_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2156 int2_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2157 float4_accum float8_collect float8_stddev_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2158 float8_accum float8_collect float8_stddev_samp 0 1022 "{0,0,0}" "{0,0,0}" ));
-DATA(insert ( 2159 numeric_accum numeric_collect numeric_stddev_samp 0 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2154 int8_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2155 int4_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2156 int2_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2157 float4_accum float8_collect float8_stddev_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2158 float8_accum float8_collect float8_stddev_samp 0 1022 1022 "{0,0,0}" "{0,0,0}" ));
+DATA(insert ( 2159 numeric_accum numeric_collect numeric_stddev_samp 0 1231 1231 "{0,0,0}" "{0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2154 int8_accum numeric_stddev_samp 0 1231 "{0,0,0}" ));
@@ -357,18 +367,18 @@ DATA(insert ( 2159 numeric_accum numeric_collect numeric_stddev_samp 0 1231 "{0,
/* SQL2003 binary regression aggregates */
#ifdef PGXC
-DATA(insert ( 2818 int8inc_float8_float8 int8_sum_to_int8 - 0 20 "0" _null_ ));
-DATA(insert ( 2819 float8_regr_accum float8_regr_collect float8_regr_sxx 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2820 float8_regr_accum float8_regr_collect float8_regr_syy 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2821 float8_regr_accum float8_regr_collect float8_regr_sxy 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2822 float8_regr_accum float8_regr_collect float8_regr_avgx 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2823 float8_regr_accum float8_regr_collect float8_regr_avgy 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2824 float8_regr_accum float8_regr_collect float8_regr_r2 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2825 float8_regr_accum float8_regr_collect float8_regr_slope 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2826 float8_regr_accum float8_regr_collect float8_regr_intercept 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2827 float8_regr_accum float8_regr_collect float8_covar_pop 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2828 float8_regr_accum float8_regr_collect float8_covar_samp 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
-DATA(insert ( 2829 float8_regr_accum float8_regr_collect float8_corr 0 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2818 int8inc_float8_float8 int8_sum_to_int8 - 0 20 20 "0" _null_ ));
+DATA(insert ( 2819 float8_regr_accum float8_regr_collect float8_regr_sxx 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2820 float8_regr_accum float8_regr_collect float8_regr_syy 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2821 float8_regr_accum float8_regr_collect float8_regr_sxy 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2822 float8_regr_accum float8_regr_collect float8_regr_avgx 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2823 float8_regr_accum float8_regr_collect float8_regr_avgy 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2824 float8_regr_accum float8_regr_collect float8_regr_r2 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2825 float8_regr_accum float8_regr_collect float8_regr_slope 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2826 float8_regr_accum float8_regr_collect float8_regr_intercept 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2827 float8_regr_accum float8_regr_collect float8_covar_pop 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2828 float8_regr_accum float8_regr_collect float8_covar_samp 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
+DATA(insert ( 2829 float8_regr_accum float8_regr_collect float8_corr 0 1022 1022 "{0,0,0,0,0,0}" "{0,0,0,0,0,0}" ));
#endif
#ifdef PGXC
//DATA(insert ( 2818 int8inc_float8_float8 - 0 20 "0" ));
@@ -387,9 +397,9 @@ DATA(insert ( 2829 float8_regr_accum float8_regr_collect float8_corr 0 1022 "
/* boolean-and and boolean-or */
#ifdef PGXC
-DATA(insert ( 2517 booland_statefunc booland_statefunc - 58 16 _null_ _null_ ));
-DATA(insert ( 2518 boolor_statefunc boolor_statefunc - 59 16 _null_ _null_ ));
-DATA(insert ( 2519 booland_statefunc booland_statefunc - 58 16 _null_ _null_ ));
+DATA(insert ( 2517 booland_statefunc booland_statefunc - 58 16 16 _null_ _null_ ));
+DATA(insert ( 2518 boolor_statefunc boolor_statefunc - 59 16 16 _null_ _null_ ));
+DATA(insert ( 2519 booland_statefunc booland_statefunc - 58 16 16 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2517 booland_statefunc - 58 16 _null_ ));
@@ -399,14 +409,14 @@ DATA(insert ( 2519 booland_statefunc booland_statefunc - 58 16 _null_ _null_ )
/* bitwise integer */
#ifdef PGXC
-DATA(insert ( 2236 int2and int2and - 0 21 _null_ _null_ ));
-DATA(insert ( 2237 int2or int2or - 0 21 _null_ _null_ ));
-DATA(insert ( 2238 int4and int4and - 0 23 _null_ _null_ ));
-DATA(insert ( 2239 int4or int4or - 0 23 _null_ _null_ ));
-DATA(insert ( 2240 int8and int8and - 0 20 _null_ _null_ ));
-DATA(insert ( 2241 int8or int8or - 0 20 _null_ _null_ ));
-DATA(insert ( 2242 bitand bitand - 0 1560 _null_ _null_ ));
-DATA(insert ( 2243 bitor bitor - 0 1560 _null_ _null_ ));
+DATA(insert ( 2236 int2and int2and - 0 21 21 _null_ _null_ ));
+DATA(insert ( 2237 int2or int2or - 0 21 21 _null_ _null_ ));
+DATA(insert ( 2238 int4and int4and - 0 23 23 _null_ _null_ ));
+DATA(insert ( 2239 int4or int4or - 0 23 23 _null_ _null_ ));
+DATA(insert ( 2240 int8and int8and - 0 20 20 _null_ _null_ ));
+DATA(insert ( 2241 int8or int8or - 0 20 20 _null_ _null_ ));
+DATA(insert ( 2242 bitand bitand - 0 1560 1560 _null_ _null_ ));
+DATA(insert ( 2243 bitor bitor - 0 1560 1560 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2236 int2and - 0 21 _null_ ));
@@ -421,7 +431,7 @@ DATA(insert ( 2243 bitor bitor - 0 1560 _null_ _null_ ));
/* xml */
#ifdef PGXC
-DATA(insert ( 2901 xmlconcat2 xmlconcat2 - 0 142 _null_ _null_ ));
+DATA(insert ( 2901 xmlconcat2 - - 0 142 0 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2901 xmlconcat2 - 0 142 _null_ ));
@@ -429,7 +439,7 @@ DATA(insert ( 2901 xmlconcat2 xmlconcat2 - 0 142 _null_ _null_ ));
/* array */
#ifdef PGXC
-DATA(insert ( 2335 array_agg_transfn - array_agg_finalfn 0 2281 _null_ _null_ ));
+DATA(insert ( 2335 array_agg_transfn - array_agg_finalfn 0 2281 0 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 2335 array_agg_transfn array_agg_finalfn 0 2281 _null_ ));
@@ -437,15 +447,18 @@ DATA(insert ( 2335 array_agg_transfn - array_agg_finalfn 0 2281 _null_ _null_ )
/* text */
#ifdef PGXC
-DATA(insert ( 3538 string_agg_transfn - string_agg_finalfn 0 2281 _null_ _null_ ));
+DATA(insert (3538 string_agg_transfn - string_agg_finalfn 0 2281 0 _null_ _null_ ));
+// XXX function string_agg_delim_transfn is not defined?
+//DATA(insert (3538 string_agg_delim_transfn - string_agg_finalfn 0 2281 0 _null_ _null_ ));
#endif
#ifdef PGXC
-//DATA(insert ( 3538 string_agg_transfn string_agg_finalfn 0 2281 _null_ ));
+//DATA(insert (3535 string_agg_transfn string_agg_finalfn 0 2281 _null_ ));
+//DATA(insert (3538 string_agg_delim_transfn string_agg_finalfn 0 2281 _null_ ));
#endif
/* bytea */
#ifdef PGXC
-DATA(insert ( 3545 bytea_string_agg_transfn - bytea_string_agg_finalfn 0 2281 _null_ _null_ ));
+DATA(insert ( 3545 bytea_string_agg_transfn - bytea_string_agg_finalfn 0 2281 0 _null_ _null_ ));
#endif
#ifdef PGXC
//DATA(insert ( 3545 bytea_string_agg_transfn bytea_string_agg_finalfn 0 2281 _null_ ));
@@ -465,6 +478,9 @@ extern void AggregateCreate(const char *aggName,
List *aggfinalfnName,
List *aggsortopName,
Oid aggTransType,
+#ifdef XCP
+ Oid aggCollectType,
+#endif
#ifdef PGXC
const char *agginitval,
const char *agginitcollect);
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index e253921278..2e63e8dd6b 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -5,6 +5,11 @@
* along with the relation's initial contents.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -75,6 +80,11 @@ DESCR("reserved schema for TOAST tables");
DATA(insert OID = 2200 ( "public" PGUID _null_ ));
DESCR("standard public schema");
#define PG_PUBLIC_NAMESPACE 2200
+#ifdef XCP
+DATA(insert OID = 9 ( "storm_catalog" PGUID _null_ ));
+DESCR("StormDB catalog schema");
+#define STORM_CATALOG_NAMESPACE 9
+#endif
/*
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index cda3efa91a..d434303e62 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -4,6 +4,11 @@
* definition of the system "procedure" relation (pg_proc)
* along with the relation's initial contents.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -226,10 +231,6 @@ DATA(insert OID = 1258 ( textcat PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 2
DATA(insert OID = 84 ( boolne PGNSP PGUID 12 1 0 0 0 f f f t t f i 2 0 16 "16 16" _null_ _null_ _null_ _null_ boolne _null_ _null_ _null_ ));
DATA(insert OID = 89 ( version PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 25 "" _null_ _null_ _null_ _null_ pgsql_version _null_ _null_ _null_ ));
DESCR("PostgreSQL version string");
-#ifdef PGXC
-DATA(insert OID = 90 ( pgxc_version PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 25 "" _null_ _null_ _null_ _null_ pgxc_version _null_ _null_ _null_ ));
-DESCR("Postgres-XC version string");
-#endif
/* OIDS 100 - 199 */
@@ -4670,6 +4671,12 @@ DATA(insert OID = 3202 ( pgxc_node_str PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0
DESCR("get the name of the node");
DATA(insert OID = 3203 ( pgxc_is_committed PGNSP PGUID 12 1 1 0 0 f f f f t t s 1 0 16 "28" _null_ _null_ _null_ _null_ pgxc_is_committed _null_ _null_ _null_ ));
DESCR("is given GXID committed or aborted?");
+DATA(insert OID = 3205 ( pgxc_lock_for_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_lock_for_backup _null_ _null_ _null_ ));
+DESCR("lock the cluster for taking backup");
+#ifdef XCP
+DATA(insert OID = 3204 ( stormdb_promote_standby PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 2278 "" _null_ _null_ _null_ _null_ stormdb_promote_standby _null_ _null_ _null_ ));
+DESCR("touch trigger file on a standby machine to end replication");
+#endif
#endif
/*
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 25c664b7c9..f87ec04655 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -5,6 +5,11 @@
* along with the relation's initial contents.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -573,6 +578,9 @@ DATA(insert OID = 2211 ( _regtype PGNSP PGUID -1 f b A f t \054 0 2206 0 arra
/* uuid */
DATA(insert OID = 2950 ( uuid PGNSP PGUID 16 f b U f t \054 0 0 2951 uuid_in uuid_out uuid_recv uuid_send - - - c p f 0 -1 0 0 _null_ _null_ _null_ ));
DESCR("UUID datatype");
+#ifdef XCP
+#define UUIDOID 2950
+#endif
DATA(insert OID = 2951 ( _uuid PGNSP PGUID -1 f b A f t \054 0 2950 0 array_in array_out array_recv array_send - - array_typanalyze i x f 0 -1 0 0 _null_ _null_ _null_ ));
/* text search */
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index 44c1ae0c8b..a917a06a87 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -3,6 +3,11 @@
* sequence.h
* prototypes for sequence.c.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -83,6 +88,10 @@ extern void ResetSequence(Oid seq_relid);
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
extern void seq_desc(StringInfo buf, uint8 xl_info, char *rec);
+#ifdef XCP
+#define DEFAULT_CACHEVAL 1
+extern int SequenceRangeVal;
+#endif
#ifdef PGXC
/*
* List of actions that registered the callback.
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 7d25bf3a31..e262a1d8d3 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -42,11 +42,7 @@ extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
extern void CheckTableNotInUse(Relation rel, const char *stmt);
-#ifdef PGXC
-extern void ExecuteTruncate(TruncateStmt *stmt, const char *sql_statement);
-#else
extern void ExecuteTruncate(TruncateStmt *stmt);
-#endif
extern void SetRelationHasSubclass(Oid relationId, bool relhassubclass);
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index 8e5499e4c5..1f7ba47466 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -210,9 +210,4 @@ extern int RI_FKey_trigger_type(Oid tgfoid);
extern Datum pg_trigger_depth(PG_FUNCTION_ARGS);
-#ifdef PGXC
-/* Postgres-XC related functions for triggers */
-extern bool pgxc_check_triggers_shippability(Oid relid, CmdType commandType);
-#endif
-
#endif /* TRIGGER_H */
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 7a50d2fcb3..7d16edaac5 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -4,6 +4,11 @@
* header file for postgres vacuum cleaner and statistics analyzer
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -161,6 +166,10 @@ extern void vacuum_set_xid_limits(int freeze_min_age, int freeze_table_age,
TransactionId *freezeTableLimit);
extern void vac_update_datfrozenxid(void);
extern void vacuum_delay_point(void);
+#ifdef XCP
+extern void vacuum_rel_coordinator(Relation onerel);
+TargetEntry *make_relation_tle(Oid reloid, const char *relname, const char *column);
+#endif
/* in commands/vacuumlazy.c */
extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h
index ebf7757327..14540a7561 100644
--- a/src/include/commands/variable.h
+++ b/src/include/commands/variable.h
@@ -2,6 +2,11 @@
* variable.h
* Routines for handling specialized SET variables.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -33,6 +38,10 @@ extern bool check_client_encoding(char **newval, void **extra, GucSource source)
extern void assign_client_encoding(const char *newval, void *extra);
extern bool check_session_authorization(char **newval, void **extra, GucSource source);
extern void assign_session_authorization(const char *newval, void *extra);
+#ifdef XCP
+extern bool check_global_session(char **newval, void **extra, GucSource source);
+extern void assign_global_session(const char *newval, void *extra);
+#endif
extern bool check_role(char **newval, void **extra, GucSource source);
extern void assign_role(const char *newval, void *extra);
extern const char *show_role(void);
diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h
index 48d01df1b6..b6c2400ffd 100644
--- a/src/include/executor/execdesc.h
+++ b/src/include/executor/execdesc.h
@@ -5,6 +5,11 @@
* and related modules.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -16,6 +21,9 @@
#define EXECDESC_H
#include "nodes/execnodes.h"
+#ifdef XCP
+#include "pgxc/squeue.h"
+#endif
#include "tcop/dest.h"
@@ -48,6 +56,14 @@ typedef struct QueryDesc
EState *estate; /* executor's query-wide state */
PlanState *planstate; /* tree of per-plan-node state */
+#ifdef XCP
+ SharedQueue squeue; /* the shared memory queue to sent data to other
+ * nodes */
+ int myindex; /* -1 if locally executed subplan is producing
+ * data and distribute via squeue. Otherwise
+ * get local data from squeue */
+#endif
+
/* This is always set NULL by the core system, but plugins can change it */
struct Instrumentation *totaltime; /* total time spent in ExecutorRun */
} QueryDesc;
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 6b9b28fa31..29e8edcc55 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -4,6 +4,11 @@
* support for the POSTGRES executor module
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -61,6 +66,10 @@
#define EXEC_FLAG_SKIP_TRIGGERS 0x0010 /* skip AfterTrigger calls */
#define EXEC_FLAG_WITH_OIDS 0x0020 /* force OIDs in returned tuples */
#define EXEC_FLAG_WITHOUT_OIDS 0x0040 /* force no OIDs in returned tuples */
+#ifdef XCP
+/* distributed executor may never execute the plan on this node */
+#define EXEC_FLAG_SUBPLAN 0x0080
+#endif
/*
@@ -219,6 +228,9 @@ extern void EvalPlanQualEnd(EPQState *epqstate);
* prototypes from functions in execProcnode.c
*/
extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
+#ifdef XCP
+extern void ExecFinishInitProcNode(PlanState *node);
+#endif
extern TupleTableSlot *ExecProcNode(PlanState *node);
extern Node *MultiExecProcNode(PlanState *node);
extern void ExecEndNode(PlanState *node);
diff --git a/src/include/executor/producerReceiver.h b/src/include/executor/producerReceiver.h
new file mode 100644
index 0000000000..1efd957863
--- /dev/null
+++ b/src/include/executor/producerReceiver.h
@@ -0,0 +1,33 @@
+/*-------------------------------------------------------------------------
+ *
+ * producerReceiver.h
+ * prototypes for producerReceiver.c
+ *
+ *
+ * Copyright (c) 2012-2014, TransLattice, Inc.
+ *
+ * src/include/executor/producerReceiver.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef PRODUCER_RECEIVER_H
+#define PRODUCER_RECEIVER_H
+
+#include "tcop/dest.h"
+#include "pgxc/locator.h"
+#include "pgxc/squeue.h"
+
+
+extern DestReceiver *CreateProducerDestReceiver(void);
+
+extern void SetProducerDestReceiverParams(DestReceiver *self,
+ AttrNumber distKey,
+ Locator *locator,
+ SharedQueue squeue);
+extern DestReceiver *SetSelfConsumerDestReceiver(DestReceiver *self,
+ DestReceiver *consumer);
+extern void SetProducerTempMemory(DestReceiver *self, MemoryContext tmpcxt);
+extern bool ProducerReceiverPushBuffers(DestReceiver *self);
+
+#endif /* PRODUCER_RECEIVER_H */
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index 6ea58632fd..693037d1e4 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -4,6 +4,11 @@
* tuple table support stuff
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -118,11 +123,16 @@ typedef struct TupleTableSlot
bool tts_slow; /* saved state for slot_deform_tuple */
HeapTuple tts_tuple; /* physical tuple, or NULL if virtual */
#ifdef PGXC
+#ifdef XCP
+ RemoteDataRow tts_datarow; /* Tuple data in DataRow format */
+ MemoryContext tts_drowcxt; /* Context to store deformed */
+#else
/*
* PGXC extension to support tuples sent from remote Datanode.
*/
char *tts_dataRow; /* Tuple data in DataRow format */
int tts_dataLen; /* Actual length of the data row */
+#endif
bool tts_shouldFreeRow; /* should pfree tts_dataRow? */
struct AttInMetadata *tts_attinmeta; /* store here info to extract values from the DataRow */
#endif
@@ -161,16 +171,30 @@ extern TupleTableSlot *ExecStoreMinimalTuple(MinimalTuple mtup,
TupleTableSlot *slot,
bool shouldFree);
#ifdef PGXC
+#ifdef XCP
+extern TupleTableSlot *ExecStoreDataRowTuple(RemoteDataRow datarow,
+ TupleTableSlot *slot,
+ bool shouldFree);
+#else
extern TupleTableSlot *ExecStoreDataRowTuple(char *msg,
size_t len,
TupleTableSlot *slot,
bool shouldFree);
#endif
+#endif
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
extern TupleTableSlot *ExecStoreVirtualTuple(TupleTableSlot *slot);
extern TupleTableSlot *ExecStoreAllNullTuple(TupleTableSlot *slot);
extern HeapTuple ExecCopySlotTuple(TupleTableSlot *slot);
extern MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot);
+#ifdef PGXC
+#ifdef XCP
+extern RemoteDataRow ExecCopySlotDatarow(TupleTableSlot *slot,
+ MemoryContext tmpcxt);
+#else
+extern int ExecCopySlotDatarow(TupleTableSlot *slot, char **datarow);
+#endif
+#endif
extern HeapTuple ExecFetchSlotTuple(TupleTableSlot *slot);
extern MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot);
extern Datum ExecFetchSlotTupleDatum(TupleTableSlot *slot);
diff --git a/src/include/gtm/gtm.h b/src/include/gtm/gtm.h
index 293d67119b..8affafd358 100644
--- a/src/include/gtm/gtm.h
+++ b/src/include/gtm/gtm.h
@@ -3,6 +3,11 @@
* gtm.h
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -92,6 +97,10 @@ void GTM_DoForAllOtherThreads(void (* process_routine)(GTM_ThreadInfo *));
GTM_ThreadInfo *GTM_ThreadCreate(GTM_ConnectionInfo *conninfo,
void *(* startroutine)(void *));
GTM_ThreadInfo * GTM_GetThreadInfo(GTM_ThreadID thrid);
+#ifdef XCP
+extern void SaveControlInfo(void);
+#define CONTROL_INTERVAL 1000
+#endif
/*
* pthread keys to get thread specific information
diff --git a/src/include/gtm/gtm_c.h b/src/include/gtm/gtm_c.h
index f34f4dbb35..b43f0edaa0 100644
--- a/src/include/gtm/gtm_c.h
+++ b/src/include/gtm/gtm_c.h
@@ -98,7 +98,7 @@ typedef GTM_SequenceKeyData *GTM_SequenceKey;
#define InvalidSequenceValue 0x7fffffffffffffffLL
#define SEQVAL_IS_VALID(v) ((v) != InvalidSequenceValue)
-#define GTM_MAX_GLOBAL_TRANSACTIONS 4096
+#define GTM_MAX_GLOBAL_TRANSACTIONS 16384
typedef enum GTM_IsolationLevel
{
diff --git a/src/include/gtm/gtm_client.h b/src/include/gtm/gtm_client.h
index e50701a7a7..9d7e500480 100644
--- a/src/include/gtm/gtm_client.h
+++ b/src/include/gtm/gtm_client.h
@@ -3,6 +3,11 @@
* gtm_client.h
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -53,12 +58,15 @@ typedef union GTM_ResultData
{
GTM_SequenceKeyData seqkey;
GTM_Sequence seqval;
- } grd_seq; /* SEQUENCE_GET_NEXT */
-
+#ifdef XCP
+ GTM_Sequence rangemax;
+#endif
+ } grd_seq; /* SEQUENCE_GET_CURRENT
+ * SEQUENCE_GET_NEXT */
struct
{
- int seq_count;
- GTM_SeqInfo **seq;
+ int seq_count;
+ GTM_SeqInfo *seq;
} grd_seq_list; /* SEQUENCE_GET_LIST */
struct
@@ -160,7 +168,7 @@ int end_replication_initial_sync(GTM_Conn *);
size_t get_node_list(GTM_Conn *, GTM_PGXCNodeInfo *, size_t);
GlobalTransactionId get_next_gxid(GTM_Conn *);
uint32 get_txn_gxid_list(GTM_Conn *, GTM_Transactions *);
-size_t get_sequence_list(GTM_Conn *, GTM_SeqInfo **, size_t);
+size_t get_sequence_list(GTM_Conn *, GTM_SeqInfo **);
/*
* Transaction Management API
@@ -248,6 +256,10 @@ int node_unregister(GTM_Conn *conn, GTM_PGXCNodeType type, const char *node_name
int bkup_node_unregister(GTM_Conn *conn, GTM_PGXCNodeType type, const char * node_name);
int backend_disconnect(GTM_Conn *conn, bool is_postmaster, GTM_PGXCNodeType type, char *node_name);
char *node_get_local_addr(GTM_Conn *conn, char *buf, size_t buflen, int *rc);
+#ifdef XCP
+int register_session(GTM_Conn *conn, const char *coord_name, int coord_procid,
+ int coord_backendid);
+#endif
/*
* Sequence Management API
@@ -268,10 +280,26 @@ int close_sequence(GTM_Conn *conn, GTM_SequenceKey key);
int bkup_close_sequence(GTM_Conn *conn, GTM_SequenceKey key);
int rename_sequence(GTM_Conn *conn, GTM_SequenceKey key, GTM_SequenceKey newkey);
int bkup_rename_sequence(GTM_Conn *conn, GTM_SequenceKey key, GTM_SequenceKey newkey);
+#ifdef XCP
+int get_current(GTM_Conn *conn, GTM_SequenceKey key,
+ char *coord_name, int coord_procid, GTM_Sequence *result);
+int get_next(GTM_Conn *conn, GTM_SequenceKey key,
+ char *coord_name, int coord_procid,
+ GTM_Sequence range, GTM_Sequence *result, GTM_Sequence *rangemax);
+int bkup_get_next(GTM_Conn *conn, GTM_SequenceKey key,
+ char *coord_name, int coord_procid,
+ GTM_Sequence range, GTM_Sequence *result, GTM_Sequence *rangemax);
+int set_val(GTM_Conn *conn, GTM_SequenceKey key, char *coord_name,
+ int coord_procid, GTM_Sequence nextval, bool iscalled);
+int bkup_set_val(GTM_Conn *conn, GTM_SequenceKey key, char *coord_name,
+ int coord_procid, GTM_Sequence nextval, bool iscalled);
+#else
+GTM_Sequence get_current(GTM_Conn *conn, GTM_SequenceKey key);
GTM_Sequence get_next(GTM_Conn *conn, GTM_SequenceKey key);
GTM_Sequence bkup_get_next(GTM_Conn *conn, GTM_SequenceKey key);
int set_val(GTM_Conn *conn, GTM_SequenceKey key, GTM_Sequence nextval, bool is_called);
int bkup_set_val(GTM_Conn *conn, GTM_SequenceKey key, GTM_Sequence nextval, bool is_called);
+#endif
int reset_sequence(GTM_Conn *conn, GTM_SequenceKey key);
int bkup_reset_sequence(GTM_Conn *conn, GTM_SequenceKey key);
diff --git a/src/include/gtm/gtm_msg.h b/src/include/gtm/gtm_msg.h
index 64f27bfeeb..560c4428f6 100644
--- a/src/include/gtm/gtm_msg.h
+++ b/src/include/gtm/gtm_msg.h
@@ -3,6 +3,11 @@
* gtm_msg.h
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -27,6 +32,9 @@ typedef enum GTM_MessageType
MSG_BKUP_NODE_REGISTER, /* Backup of MSG_NODE_REGISTER */
MSG_NODE_UNREGISTER, /* Unregister a PGXC Node with GTM */
MSG_BKUP_NODE_UNREGISTER, /* Backup of MSG_NODE_UNREGISTER */
+#ifdef XCP
+ MSG_REGISTER_SESSION, /* Register distributed session with GTM */
+#endif
MSG_NODE_LIST, /* Get node list */
MSG_NODE_BEGIN_REPLICATION_INIT,
MSG_NODE_END_REPLICATION_INIT,
@@ -62,6 +70,7 @@ typedef enum GTM_MessageType
MSG_SNAPSHOT_GXID_GET, /* Get GXID and snapshot together */
MSG_SEQUENCE_INIT, /* Initialize a new global sequence */
MSG_BKUP_SEQUENCE_INIT, /* Backup of MSG_SEQUENCE_INIT */
+ MSG_SEQUENCE_GET_CURRENT,/* Get the current value of sequence */
MSG_SEQUENCE_GET_NEXT, /* Get the next sequence value of sequence */
MSG_BKUP_SEQUENCE_GET_NEXT, /* Backup of MSG_SEQUENCE_GET_NEXT */
MSG_SEQUENCE_GET_LAST, /* Get the last sequence value of sequence */
@@ -99,6 +108,9 @@ typedef enum GTM_ResultType
SYNC_STANDBY_RESULT,
NODE_REGISTER_RESULT,
NODE_UNREGISTER_RESULT,
+#ifdef XCP
+ REGISTER_SESSION_RESULT,
+#endif
NODE_LIST_RESULT,
NODE_BEGIN_REPLICATION_INIT_RESULT,
NODE_END_REPLICATION_INIT_RESULT,
@@ -122,6 +134,7 @@ typedef enum GTM_ResultType
SNAPSHOT_GET_MULTI_RESULT,
SNAPSHOT_GXID_GET_RESULT,
SEQUENCE_INIT_RESULT,
+ SEQUENCE_GET_CURRENT_RESULT,
SEQUENCE_GET_NEXT_RESULT,
SEQUENCE_GET_LAST_RESULT,
SEQUENCE_SET_VAL_RESULT,
diff --git a/src/include/gtm/gtm_seq.h b/src/include/gtm/gtm_seq.h
index af92e6d873..c849dbc884 100644
--- a/src/include/gtm/gtm_seq.h
+++ b/src/include/gtm/gtm_seq.h
@@ -3,6 +3,11 @@
* gtm_seq.h
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -20,12 +25,29 @@
/* Global sequence related structures */
+
+#ifdef XCP
+typedef struct GTM_SeqLastVal
+{
+ char gs_coord_name[SP_NODE_NAME];
+ int32 gs_coord_procid;
+ GTM_Sequence gs_last_value;
+} GTM_SeqLastVal;
+#endif
+
+
typedef struct GTM_SeqInfo
{
GTM_SequenceKey gs_key;
GTM_Sequence gs_value;
GTM_Sequence gs_init_value;
+#ifdef XCP
+ int32 gs_max_lastvals;
+ int32 gs_lastval_count;
+ GTM_SeqLastVal *gs_last_values;
+#else
GTM_Sequence gs_last_value;
+#endif
GTM_Sequence gs_increment_by;
GTM_Sequence gs_min_value;
GTM_Sequence gs_max_value;
@@ -70,12 +92,24 @@ int GTM_SeqAlter(GTM_SequenceKey seqkey,
bool is_restart);
int GTM_SeqClose(GTM_SequenceKey seqkey);
int GTM_SeqRename(GTM_SequenceKey seqkey, GTM_SequenceKey newseqkey);
+#ifdef XCP
+int GTM_SeqGetNext(GTM_SequenceKey seqkey, char *coord_name,
+ int coord_procid, GTM_Sequence range,
+ GTM_Sequence *result, GTM_Sequence *rangemax);
+void GTM_SeqGetCurrent(GTM_SequenceKey seqkey, char *coord_name,
+ int coord_procid, GTM_Sequence *result);
+int GTM_SeqSetVal(GTM_SequenceKey seqkey, char *coord_name,
+ int coord_procid, GTM_Sequence nextval, bool iscalled);
+#else
GTM_Sequence GTM_SeqGetNext(GTM_SequenceKey seqkey);
+GTM_Sequence GTM_SeqGetCurrent(GTM_SequenceKey seqkey);
int GTM_SeqSetVal(GTM_SequenceKey seqkey, GTM_Sequence nextval, bool iscalled);
+#endif
int GTM_SeqReset(GTM_SequenceKey seqkey);
void ProcessSequenceInitCommand(Port *myport, StringInfo message, bool is_backup);
+void ProcessSequenceGetCurrentCommand(Port *myport, StringInfo message);
void ProcessSequenceGetNextCommand(Port *myport, StringInfo message, bool is_backup);
void ProcessSequenceSetValCommand(Port *myport, StringInfo message, bool is_backup);
void ProcessSequenceResetCommand(Port *myport, StringInfo message, bool is_backup);
@@ -97,4 +131,8 @@ int GTM_SeqRestore(GTM_SequenceKey seqkey,
bool cycle,
bool called);
+#ifdef XCP
+void GTM_CleanupSeqSession(char *coord_name, int coord_procid);
+#endif
+
#endif
diff --git a/src/include/gtm/gtm_serialize.h b/src/include/gtm/gtm_serialize.h
index 1c31299281..2cabeb1a5e 100644
--- a/src/include/gtm/gtm_serialize.h
+++ b/src/include/gtm/gtm_serialize.h
@@ -36,11 +36,15 @@ size_t gtm_deserialize_transactions(GTM_Transactions *, const char *, size_t);
size_t gtm_get_pgxcnodeinfo_size(GTM_PGXCNodeInfo *);
size_t gtm_serialize_pgxcnodeinfo(GTM_PGXCNodeInfo *, char *, size_t);
+#ifdef XCP
+size_t gtm_deserialize_pgxcnodeinfo(GTM_PGXCNodeInfo *, const char *, size_t, PQExpBuffer *);
+#else
size_t gtm_deserialize_pgxcnodeinfo(GTM_PGXCNodeInfo *, const char *, size_t);
+#endif
size_t gtm_get_sequence_size(GTM_SeqInfo *);
size_t gtm_serialize_sequence(GTM_SeqInfo *, char *, size_t);
-GTM_SeqInfo *gtm_deserialize_sequence(const char *, size_t);
+size_t gtm_deserialize_sequence(GTM_SeqInfo *seq, const char *, size_t);
void dump_transactions_elog(GTM_Transactions *, int);
void dump_transactioninfo_elog(GTM_TransactionInfo *);
diff --git a/src/include/gtm/gtm_standby.h b/src/include/gtm/gtm_standby.h
index 448fc49fbc..e9fa57f6bf 100644
--- a/src/include/gtm/gtm_standby.h
+++ b/src/include/gtm/gtm_standby.h
@@ -51,9 +51,8 @@ void gtm_standby_closeActiveConn(void);
void gtm_standby_finishActiveConn(void);
-/* Functions to process backup */
-void ProcessGTMBeginBackup(Port *myport, StringInfo message);
-void ProcessGTMEndBackup(Port *myport, StringInfo message);
+
+
/*
* Startup mode
diff --git a/src/include/gtm/gtm_txn.h b/src/include/gtm/gtm_txn.h
index 942e46ce0e..57a97eb1c9 100644
--- a/src/include/gtm/gtm_txn.h
+++ b/src/include/gtm/gtm_txn.h
@@ -169,11 +169,7 @@ typedef struct GTM_Transactions
extern GTM_Transactions GTMTransactions;
-/*
- * This macro should be used with READ lock held on gt_TransArrayLock as the
- * number of open transactions might change when counting open transactions
- * if a lock is not hold.
- */
+/* NOTE: This macro should be used with READ lock held on gt_TransArrayLock! */
#define GTM_CountOpenTransactions() (gtm_list_length(GTMTransactions.gt_open_transactions))
/*
diff --git a/src/include/gtm/register.h b/src/include/gtm/register.h
index 4d0e99f068..b9cc089952 100644
--- a/src/include/gtm/register.h
+++ b/src/include/gtm/register.h
@@ -3,6 +3,11 @@
* register.h
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -17,7 +22,6 @@
#include "gtm/libpq-be.h"
#include "gtm/gtm_c.h"
#include "gtm/gtm_lock.h"
-#include "gtm/gtm_list.h"
#include "gtm/stringinfo.h"
/*
@@ -39,6 +43,14 @@ typedef enum GTM_PGXCNodeStatus
NODE_DISCONNECTED
} GTM_PGXCNodeStatus;
+#ifdef XCP
+typedef struct GTM_PGXCSession
+{
+ int gps_coord_proc_id;
+ int gps_coord_backend_id;
+} GTM_PGXCSession;
+#endif
+
typedef struct GTM_PGXCNodeInfo
{
GTM_PGXCNodeType type; /* Type of node */
@@ -48,10 +60,16 @@ typedef struct GTM_PGXCNodeInfo
char *ipaddress; /* IP address of the nodes */
char *datafolder; /* Data folder of the node */
GTM_PGXCNodeStatus status; /* Node status */
+#ifdef XCP
+ int max_sessions;
+ int num_sessions;
+ GTM_PGXCSession *sessions;
+#endif
GTM_RWLock node_lock; /* Lock on this structure */
int socket; /* socket number used for registration */
} GTM_PGXCNodeInfo;
+
/* Maximum number of nodes that can be registered */
#define MAX_NODES 1024
@@ -78,6 +96,11 @@ void Recovery_RestoreRegisterInfo(void);
void Recovery_SaveRegisterInfo(void);
void Recovery_PGXCNodeDisconnect(Port *myport);
void Recovery_SaveRegisterFileName(char *dir);
+#ifdef XCP
+int Recovery_PGXCNodeRegisterCoordProcess(char *coord_node, int coord_procid,
+ int coord_backendid);
+void ProcessPGXCRegisterSession(Port *myport, StringInfo message);
+#endif
void ProcessPGXCNodeRegister(Port *myport, StringInfo message, bool is_backup);
void ProcessPGXCNodeUnregister(Port *myport, StringInfo message, bool is_backup);
diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h
index f3b8be6a0c..12a526e691 100644
--- a/src/include/libpq/hba.h
+++ b/src/include/libpq/hba.h
@@ -93,4 +93,7 @@ extern int check_usermap(const char *usermap_name,
bool case_sensitive);
extern bool pg_isblank(const char c);
+#ifdef XCP
+extern List* get_parsed_hba(void);
+#endif
#endif /* HBA_H */
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 5ff0856765..f54522308c 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -10,6 +10,11 @@
* Over time, this has also become the preferred place for widely known
* resource-limitation stuff, such as work_mem and check_stack_depth().
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -300,6 +305,10 @@ extern void SetUserIdAndContext(Oid userid, bool sec_def_context);
extern void InitializeSessionUserId(const char *rolename);
extern void InitializeSessionUserIdStandalone(void);
extern void SetSessionAuthorization(Oid userid, bool is_superuser);
+#ifdef XCP
+extern void SetGlobalSession(Oid coordid, int coordpid);
+extern char *GetClusterUserName(void);
+#endif
extern Oid GetCurrentRoleId(void);
extern void SetCurrentRoleId(Oid roleid, bool is_superuser);
@@ -345,7 +354,6 @@ typedef enum ProcessingMode
extern ProcessingMode Mode;
-
#define IsBootstrapProcessingMode() ((bool)(Mode == BootstrapProcessing))
#define IsInitProcessingMode() ((bool)(Mode == InitProcessing))
#define IsNormalProcessingMode() ((bool)(Mode == NormalProcessing))
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index ef1aa2743d..93b5380051 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -4,6 +4,11 @@
* definitions for executor state nodes
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -22,6 +27,9 @@
#include "utils/reltrigger.h"
#include "utils/sortsupport.h"
#include "utils/tuplestore.h"
+#ifdef XCP
+#include "pgxc/squeue.h"
+#endif
/* ----------------
@@ -348,9 +356,11 @@ typedef struct EState
ResultRelInfo *es_result_relations; /* array of ResultRelInfos */
int es_num_result_relations; /* length of array */
ResultRelInfo *es_result_relation_info; /* currently active array elt */
-#ifdef PGXC
+#ifdef PGXC
+#ifndef PGXC
struct PlanState *es_result_remoterel; /* currently active remote rel */
-#endif
+#endif
+#endif
/* Stuff used for firing triggers: */
List *es_trig_target_relations; /* trigger-only ResultRelInfos */
@@ -1061,9 +1071,9 @@ typedef struct ModifyTableState
bool canSetTag; /* do we set the command tag/es_processed? */
bool mt_done; /* are we done? */
PlanState **mt_plans; /* subplans (one per target rel) */
-#ifdef PGXC
+#ifdef PGXC
PlanState **mt_remoterels; /* per-target remote query node */
-#endif
+#endif
int mt_nplans; /* number of plans in the array */
int mt_whichplan; /* which one is being executed (0..n-1) */
ResultRelInfo *resultRelInfo; /* per-subplan target relations */
@@ -1694,7 +1704,9 @@ typedef struct AggState
bool table_filled; /* hash table filled yet? */
TupleHashIterator hashiter; /* for iterating through hash table */
#ifdef PGXC
+#ifndef XCP
bool skip_trans; /* skip the transition step for aggregates */
+#endif /* XCP */
#endif /* PGXC */
} AggState;
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 00d03b9602..2c9cf5ee15 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -4,6 +4,11 @@
* Definitions for tagged nodes.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -82,9 +87,15 @@ typedef enum NodeTag
* TAGS FOR PGXC NODES
* (planner.h, locator.h, nodemgr.h, groupmgr.h)
*/
+#ifdef XCP
+ T_Distribution,
+#endif
T_ExecNodes,
T_SimpleSort,
T_RemoteQuery,
+#ifdef XCP
+ T_RemoteSubplan,
+#endif
T_PGXCNodeHandle,
T_AlterNodeStmt,
T_CreateNodeStmt,
@@ -139,6 +150,9 @@ typedef enum NodeTag
T_LimitState,
#ifdef PGXC
T_RemoteQueryState,
+#ifdef XCP
+ T_RemoteSubplanState,
+#endif
#endif
/*
@@ -261,10 +275,9 @@ typedef enum NodeTag
T_PlaceHolderInfo,
T_MinMaxAggInfo,
T_PlannerParamItem,
-#ifdef PGXC
- T_RemoteQueryPath,
-#endif /* PGXC */
-
+#ifdef XCP
+ T_RemoteSubPath,
+#endif
/*
* TAGS FOR MEMORY NODES (memnodes.h)
*/
@@ -347,6 +360,7 @@ typedef enum NodeTag
T_CheckPointStmt,
#ifdef PGXC
T_BarrierStmt,
+ T_PauseClusterStmt,
#endif
T_CreateSchemaStmt,
T_AlterDatabaseStmt,
@@ -382,6 +396,9 @@ typedef enum NodeTag
T_DropUserMappingStmt,
T_ExecDirectStmt,
T_CleanConnStmt,
+#ifdef XCP
+ T_RemoteStmt,
+#endif
T_AlterTableSpaceOptionsStmt,
T_SecLabelStmt,
T_CreateForeignTableStmt,
@@ -518,11 +535,17 @@ extern PGDLLIMPORT Node *newNodeMacroHolder;
/*
* nodes/{outfuncs.c,print.c}
*/
+#ifdef XCP
+extern void set_portable_output(bool value);
+#endif
extern char *nodeToString(const void *obj);
/*
* nodes/{readfuncs.c,read.c}
*/
+#ifdef XCP
+extern void set_portable_input(bool value);
+#endif
extern void *stringToNode(char *str);
/*
diff --git a/src/include/nodes/params.h b/src/include/nodes/params.h
index 3989006078..a7cdd0d888 100644
--- a/src/include/nodes/params.h
+++ b/src/include/nodes/params.h
@@ -4,6 +4,11 @@
* Support for finding the values associated with Param nodes.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -97,6 +102,9 @@ typedef struct ParamExecData
void *execPlan; /* should be "SubPlanState *" */
Datum value;
bool isnull;
+#ifdef XCP
+ Oid ptype;
+#endif
} ParamExecData;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index b7b361bc76..e7a4e826c5 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -10,6 +10,11 @@
* the location.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -156,13 +161,17 @@ typedef struct Query
List *constraintDeps; /* a list of pg_constraint OIDs that the query
* depends on to be semantically valid */
#ifdef PGXC
+#ifndef XCP
/* need this info for PGXC Planner, may be temporary */
char *sql_statement; /* original query */
+ bool qry_finalise_aggs; /* used for queries intended for Datanodes,
+ * should Datanode finalise the aggregates? */
bool is_local; /* enforce query execution on local node
* this is used by EXECUTE DIRECT especially. */
bool is_ins_child_sel_parent;/* true if the query is such an INSERT SELECT that
* inserts into a child by selecting from its parent */
#endif
+#endif
} Query;
@@ -713,8 +722,10 @@ typedef struct RangeTblEntry
*/
#ifdef PGXC
+#ifndef XCP
char *relname;
#endif
+#endif
/*
* Fields valid for a plain relation RTE (else zero):
@@ -1253,7 +1264,7 @@ typedef enum AlterTableType
AT_AddNodeList, /* ADD NODE nodelist */
AT_DeleteNodeList, /* DELETE NODE nodelist */
#endif
- AT_GenericOptions /* OPTIONS (...) */
+ AT_GenericOptions, /* OPTIONS (...) */
} AlterTableType;
typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
@@ -2420,6 +2431,16 @@ typedef struct VacuumStmt
#ifdef PGXC
/*
+ * ---------------------------
+ * Pause Cluster Statement
+ */
+typedef struct PauseClusterStmt
+{
+ NodeTag type;
+ bool pause; /* will be false to unpause */
+} PauseClusterStmt;
+
+/*
* ----------------------
* Barrier Statement
*/
@@ -2448,6 +2469,7 @@ typedef struct AlterNodeStmt
{
NodeTag type;
char *node_name;
+ bool cluster;
List *options;
} AlterNodeStmt;
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index b7aa20b0c9..644dd18a38 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -4,6 +4,11 @@
* definitions for query plan nodes
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -67,6 +72,19 @@ typedef struct PlannedStmt
List *invalItems; /* other dependencies, as PlanInvalItems */
int nParamExec; /* number of PARAM_EXEC Params used */
+#ifdef XCP
+ int nParamRemote; /* number of params sent from the master mode */
+
+ struct RemoteParam *remoteparams;/* parameter descriptors */
+
+ const char *pname; /* the portal name */
+
+ /* Parameters to filter out result rows */
+ char distributionType;
+ AttrNumber distributionKey;
+ List *distributionNodes;
+ List *distributionRestrict;
+#endif
} PlannedStmt;
/* macro for fetching the Plan associated with a SubPlan node */
@@ -175,9 +193,11 @@ typedef struct ModifyTable
List *returningLists; /* per-target-table RETURNING tlists */
List *rowMarks; /* PlanRowMarks (non-locking only) */
int epqParam; /* ID of Param for EvalPlanQual re-eval */
-#ifdef PGXC
+#ifdef PGXC
+#ifndef XCP
List *remote_plans; /* per-target-table remote node */
-#endif
+#endif
+#endif
} ModifyTable;
/* ----------------
@@ -590,12 +610,6 @@ typedef struct Sort
Oid *sortOperators; /* OIDs of operators to sort them by */
Oid *collations; /* OIDs of collations */
bool *nullsFirst; /* NULLS FIRST/LAST directions */
-#ifdef PGXC
- bool srt_start_merge;/* No need to create the sorted runs. The
- * underlying plan provides those runs. Merge
- * them.
- */
-#endif /* PGXC */
} Sort;
/* ---------------
@@ -633,18 +647,33 @@ typedef enum AggStrategy
AGG_HASHED /* grouped agg, use internal hashtable */
} AggStrategy;
+#ifdef XCP
+typedef enum AggDistribution
+{
+ AGG_ONENODE, /* not distributed aggregation */
+ AGG_SLAVE, /* execute only transient function */
+ AGG_MASTER /* execute collection function as transient
+ * and final finction */
+} AggDistribution;
+#endif
+
typedef struct Agg
{
Plan plan;
AggStrategy aggstrategy;
+#ifdef XCP
+ AggDistribution aggdistribution;
+#endif
int numCols; /* number of grouping columns */
AttrNumber *grpColIdx; /* their indexes in the target list */
Oid *grpOperators; /* equality operators to compare with */
long numGroups; /* estimated number of groups in input */
#ifdef PGXC
+#ifndef XCP
bool skip_trans; /* apply collection directly on the data received
* from remote Datanodes
*/
+#endif /* XCP */
#endif /* PGXC */
} Agg;
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 211b2cfc12..3ec44c2b8b 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -7,6 +7,11 @@
* and join trees.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -244,8 +249,10 @@ typedef struct Aggref
Oid aggcollid; /* OID of collation of result */
Oid inputcollid; /* OID of collation that function should use */
#ifdef PGXC
+#ifndef XCP
Oid aggtrantype; /* type Oid of transition results */
bool agghas_collectfn; /* is collection function available */
+#endif /* XCP */
#endif /* PGXC */
List *args; /* arguments and sort expressions */
List *aggorder; /* ORDER BY (list of SortGroupClause) */
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 964b371517..f036ead7dd 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -4,6 +4,11 @@
* Definitions for planner's internal data structures.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -20,6 +25,25 @@
#include "storage/block.h"
+#ifdef XCP
+/*
+ * Distribution
+ *
+ * Distribution is an attribute of distributed plan node. It describes on which
+ * node execution results can be found.
+ */
+typedef struct Distribution
+{
+ NodeTag type;
+
+ char distributionType;
+ Node *distributionExpr;
+ Bitmapset *nodes;
+ Bitmapset *restrictNodes;
+} Distribution;
+#endif
+
+
/*
* Relids
* Set of relation identifiers (indexes into the rangetable).
@@ -229,6 +253,7 @@ typedef struct PlannerInfo
bool hasRecursion; /* true if planning a recursive WITH item */
#ifdef PGXC
+#ifndef XCP
/* This field is used only when RemoteScan nodes are involved */
int rs_alias_index; /* used to build the alias reference */
@@ -242,6 +267,7 @@ typedef struct PlannerInfo
*/
List *xc_rowMarks; /* list of PlanRowMarks of type ROW_MARK_EXCLUSIVE & ROW_MARK_SHARE */
#endif
+#endif
/* These fields are used only when hasRecursion is true: */
int wt_param_id; /* PARAM_EXEC ID for the work table */
@@ -250,9 +276,20 @@ typedef struct PlannerInfo
/* These fields are workspace for createplan.c */
Relids curOuterRels; /* outer rels above current node */
List *curOuterParams; /* not-yet-assigned NestLoopParams */
+#ifdef XCP
+ Bitmapset *curOuterRestrict; /* Datanodes where outer plan is executed */
+#endif
/* optional private data for join_search_hook, e.g., GEQO */
void *join_search_private;
+#ifdef XCP
+ /*
+ * This is NULL for a SELECT query (NULL distribution means "Coordinator"
+ * everywhere in the planner. For INSERT, UPDATE or DELETE it should match
+ * to the target table distribution.
+ */
+ Distribution *distribution; /* Query result distribution */
+#endif
} PlannerInfo;
@@ -710,6 +747,9 @@ typedef struct Path
List *pathkeys; /* sort ordering of path's output */
/* pathkeys is a List of PathKey nodes; see above */
+#ifdef XCP
+ Distribution *distribution;
+#endif
} Path;
/* Macro for extracting a path's parameterization relids; beware double eval */
@@ -947,6 +987,14 @@ typedef struct UniquePath
List *uniq_exprs; /* expressions to be made unique */
} UniquePath;
+#ifdef XCP
+typedef struct RemoteSubPath
+{
+ Path path;
+ Path *subpath;
+} RemoteSubPath;
+#endif
+
/*
* All join-type paths share these fields.
*/
@@ -1028,45 +1076,6 @@ typedef struct HashPath
int num_batches; /* number of batches expected */
} HashPath;
-#ifdef PGXC
-/*
- * A remotequery path represents the queries to be sent to the datanode/s
- *
- * When RemoteQuery plan is created from RemoteQueryPath, we build the query to
- * be executed at the datanode. For building such a query, it's important to get
- * the RHS relation and LHS relation of the JOIN clause. So, instead of storing
- * the outer and inner paths, we find out the RHS and LHS paths and store those
- * here.
- */
-
-typedef struct RemoteQueryPath
-{
- Path path;
- ExecNodes *rqpath_en; /* List of datanodes to execute the query on */
- /*
- * If the path represents a JOIN rel, leftpath and rightpath represent the
- * RemoteQuery paths for left (outer) and right (inner) side of the JOIN
- * resp. jointype and join_restrictlist pertains to such JOINs.
- */
- struct RemoteQueryPath *leftpath;
- struct RemoteQueryPath *rightpath;
- JoinType jointype;
- List *join_restrictlist; /* restrict list corresponding to JOINs,
- * only considered if rest of
- * the JOIN information is
- * available
- */
- bool rqhas_unshippable_qual; /* TRUE if there is at least
- * one qual which can not be
- * shipped to the datanodes
- */
- bool rqhas_temp_rel; /* TRUE if one of the base relations
- * involved in this path is a temporary
- * table.
- */
-} RemoteQueryPath;
-#endif /* PGXC */
-
/*
* Restriction clause info.
*
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index abc9a69afe..2f40438398 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -4,6 +4,11 @@
* prototypes for costsize.c and clausesel.c.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -26,6 +31,10 @@
#define DEFAULT_CPU_TUPLE_COST 0.01
#define DEFAULT_CPU_INDEX_TUPLE_COST 0.005
#define DEFAULT_CPU_OPERATOR_COST 0.0025
+#ifdef XCP
+#define DEFAULT_NETWORK_BYTE_COST 0.001
+#define DEFAULT_REMOTE_QUERY_COST 100.0
+#endif
#define DEFAULT_EFFECTIVE_CACHE_SIZE 16384 /* measured in pages */
@@ -48,6 +57,10 @@ extern PGDLLIMPORT double random_page_cost;
extern PGDLLIMPORT double cpu_tuple_cost;
extern PGDLLIMPORT double cpu_index_tuple_cost;
extern PGDLLIMPORT double cpu_operator_cost;
+#ifdef XCP
+extern PGDLLIMPORT double network_byte_cost;
+extern PGDLLIMPORT double remote_query_cost;
+#endif
extern PGDLLIMPORT int effective_cache_size;
extern Cost disable_cost;
extern bool enable_seqscan;
@@ -62,11 +75,8 @@ extern bool enable_material;
extern bool enable_mergejoin;
extern bool enable_hashjoin;
#ifdef PGXC
-extern bool enable_fast_query_shipping;
extern bool enable_remotejoin;
extern bool enable_remotegroup;
-extern bool enable_remotesort;
-extern bool enable_remotelimit;
#endif
extern int constraint_exclusion;
@@ -92,7 +102,7 @@ extern void cost_functionscan(Path *path, PlannerInfo *root,
extern void cost_valuesscan(Path *path, PlannerInfo *root,
RelOptInfo *baserel);
#ifdef PGXC
-extern void cost_remotequery(RemoteQueryPath *rqpath, PlannerInfo *root, RelOptInfo *rel);
+extern void cost_remotequery(Path *path, PlannerInfo *root, RelOptInfo *baserel);
#endif
extern void cost_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
extern void cost_recursive_union(Plan *runion, Plan *nrterm, Plan *rterm);
@@ -154,6 +164,11 @@ extern void final_cost_hashjoin(PlannerInfo *root, HashPath *path,
extern void cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan);
extern void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root);
extern void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root);
+#ifdef XCP
+extern void cost_remote_subplan(Path *path,
+ Cost input_startup_cost, Cost input_total_cost,
+ double tuples, int width, int replication);
+#endif
extern void compute_semi_anti_join_factors(PlannerInfo *root,
RelOptInfo *outerrel,
RelOptInfo *innerrel,
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index 493256fbe8..2fd43c0cc6 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -4,6 +4,11 @@
* prototypes for pathnode.c, relnode.c.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -67,8 +72,14 @@ extern ResultPath *create_result_path(List *quals);
extern MaterialPath *create_material_path(RelOptInfo *rel, Path *subpath);
extern UniquePath *create_unique_path(PlannerInfo *root, RelOptInfo *rel,
Path *subpath, SpecialJoinInfo *sjinfo);
+#ifdef XCP
+extern Path *create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel,
+ List *pathkeys, Relids required_outer,
+ Distribution *distribution);
+#else
extern Path *create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel,
List *pathkeys, Relids required_outer);
+#endif
extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel);
@@ -78,6 +89,12 @@ extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
List *pathkeys,
Relids required_outer,
List *fdw_private);
+#ifdef PGXC
+#ifndef XCP
+extern Path *create_remotequery_path(PlannerInfo *root, RelOptInfo *rel);
+#endif
+#endif
+
extern Relids calc_nestloop_required_outer(Path *outer_path, Path *inner_path);
extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path);
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index 50af07e0f9..b6fb8ee5ce 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -85,19 +85,6 @@ extern void add_paths_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel,
JoinType jointype, SpecialJoinInfo *sjinfo,
List *restrictlist);
-#ifdef PGXC
-/*
- * rquerypath.c
- * routines to create RemoteQuery paths
- */
-extern bool create_plainrel_rqpath(PlannerInfo *root, RelOptInfo *rel,
- RangeTblEntry *rte);
-extern void create_joinrel_rqpath(PlannerInfo *root, RelOptInfo *joinrel,
- RelOptInfo *outerrel, RelOptInfo *innerrel,
- List *restrictlist, JoinType jointype,
- SpecialJoinInfo *sjinfo);
-#endif /* PGXC */
-
/*
* joinrels.c
* routines to determine which relations to join
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index ecee00e4e4..39a5650eb6 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -4,6 +4,11 @@
* prototypes for various files in optimizer/plan
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -16,6 +21,9 @@
#include "nodes/plannodes.h"
#include "nodes/relation.h"
+#ifdef XCP
+#include "pgxc/planner.h"
+#endif
/* GUC parameters */
#define DEFAULT_CURSOR_TUPLE_FRACTION 0.1
@@ -129,19 +137,22 @@ extern void extract_query_dependencies(Node *query,
List **invalItems);
#ifdef PGXC
-/*
- * prototypes for plan/pgxcplan.c
- */
-extern Plan *create_remotedml_plan(PlannerInfo *root, Plan *topplan,
- CmdType cmdtyp);
+#ifdef XCP
+extern RemoteSubplan *find_push_down_plan(Plan *plan, bool force);
+extern RemoteSubplan *make_remotesubplan(PlannerInfo *root,
+ Plan *lefttree,
+ Distribution *resultDistribution,
+ Distribution *execDistribution,
+ List *pathkeys);
+#else
+extern Var *search_tlist_for_var(Var *var, List *jtlist);
+extern Plan *create_remoteinsert_plan(PlannerInfo *root, Plan *topplan);
+extern Plan *create_remoteupdate_plan(PlannerInfo *root, Plan *topplan);
+extern Plan *create_remotedelete_plan(PlannerInfo *root, Plan *topplan);
extern Plan *create_remotegrouping_plan(PlannerInfo *root, Plan *local_plan);
-extern Plan *create_remotequery_plan(PlannerInfo *root, RemoteQueryPath *best_path);
-extern Plan *create_remotesort_plan(PlannerInfo *root, Plan *local_plan);
-extern Plan *create_remotelimit_plan(PlannerInfo *root, Plan *local_plan);
-extern List *pgxc_order_qual_clauses(PlannerInfo *root, List *clauses);
-extern List *pgxc_build_relation_tlist(RelOptInfo *rel);
-extern void pgxc_copy_path_costsize(Plan *dest, Path *src);
-extern Plan *pgxc_create_gating_plan(PlannerInfo *root, Plan *plan, List *quals);
-#endif
+/* Expose fix_scan_expr to create_remotequery_plan() */
+extern Node *pgxc_fix_scan_expr(PlannerInfo *root, Node *node, int rtoffset);
+#endif /* XCP */
+#endif /* PGXC */
#endif /* PLANMAIN_H */
diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h
index 1f0993b519..79f71cdd36 100644
--- a/src/include/optimizer/planner.h
+++ b/src/include/optimizer/planner.h
@@ -38,6 +38,10 @@ extern Plan *subquery_planner(PlannerGlobal *glob, Query *parse,
extern bool is_dummy_plan(Plan *plan);
extern Expr *expression_planner(Expr *expr);
+#ifdef PGXC
+extern void GetHashExecNodes(RelationLocInfo *rel_loc_info,
+ ExecNodes **exec_nodes, const Expr *expr);
+#endif
extern bool plan_cluster_use_sort(Oid tableOid, Oid indexOid);
diff --git a/src/include/parser/analyze.h b/src/include/parser/analyze.h
index 5fbf520992..dd72351533 100644
--- a/src/include/parser/analyze.h
+++ b/src/include/parser/analyze.h
@@ -4,6 +4,11 @@
* parse analysis for optimizable statements
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -40,4 +45,7 @@ extern void CheckSelectLocking(Query *qry);
extern void applyLockingClause(Query *qry, Index rtindex,
bool forUpdate, bool noWait, bool pushedDown);
+#ifdef XCP
+extern void ParseAnalyze_callback(ParseState *pstate, Query *query);
+#endif
#endif /* ANALYZE_H */
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 33966987e4..977a5ba999 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -292,6 +292,9 @@ PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD)
PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD)
PG_KEYWORD("passing", PASSING, UNRESERVED_KEYWORD)
PG_KEYWORD("password", PASSWORD, UNRESERVED_KEYWORD)
+#ifdef PGXC
+PG_KEYWORD("pause", PAUSE, UNRESERVED_KEYWORD)
+#endif
PG_KEYWORD("placing", PLACING, RESERVED_KEYWORD)
PG_KEYWORD("plans", PLANS, UNRESERVED_KEYWORD)
PG_KEYWORD("position", POSITION, COL_NAME_KEYWORD)
@@ -401,6 +404,9 @@ PG_KEYWORD("unique", UNIQUE, RESERVED_KEYWORD)
PG_KEYWORD("unknown", UNKNOWN, UNRESERVED_KEYWORD)
PG_KEYWORD("unlisten", UNLISTEN, UNRESERVED_KEYWORD)
PG_KEYWORD("unlogged", UNLOGGED, UNRESERVED_KEYWORD)
+#ifdef PGXC
+PG_KEYWORD("unpause", UNPAUSE, UNRESERVED_KEYWORD)
+#endif
PG_KEYWORD("until", UNTIL, UNRESERVED_KEYWORD)
PG_KEYWORD("update", UPDATE, UNRESERVED_KEYWORD)
PG_KEYWORD("user", USER, RESERVED_KEYWORD)
diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h
index b32ee6c272..19fbb01535 100644
--- a/src/include/parser/parse_agg.h
+++ b/src/include/parser/parse_agg.h
@@ -3,6 +3,11 @@
* parse_agg.h
* handle aggregates and window functions in parser
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -27,11 +32,20 @@ extern void parseCheckWindowFuncs(ParseState *pstate, Query *qry);
extern void build_aggregate_fnexprs(Oid *agg_input_types,
int agg_num_inputs,
Oid agg_state_type,
+#ifdef XCP
+ Oid agg_collect_type,
+#endif
Oid agg_result_type,
Oid agg_input_collation,
Oid transfn_oid,
+#ifdef XCP
+ Oid collectfn_oid,
+#endif
Oid finalfn_oid,
Expr **transfnexpr,
+#ifdef XCP
+ Expr **collectfnexpr,
+#endif
Expr **finalfnexpr);
#endif /* PARSE_AGG_H */
diff --git a/src/include/parser/parse_utilcmd.h b/src/include/parser/parse_utilcmd.h
index fdd0db682c..355335ae83 100644
--- a/src/include/parser/parse_utilcmd.h
+++ b/src/include/parser/parse_utilcmd.h
@@ -4,6 +4,11 @@
* parse analysis for utility commands
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -17,8 +22,13 @@
#include "parser/parse_node.h"
-
+#ifdef XCP
+extern bool loose_constraints;
+extern List *transformCreateStmt(CreateStmt *stmt, const char *queryString,
+ bool autodistribute);
+#else
extern List *transformCreateStmt(CreateStmt *stmt, const char *queryString);
+#endif
extern List *transformAlterTableStmt(AlterTableStmt *stmt,
const char *queryString);
extern IndexStmt *transformIndexStmt(IndexStmt *stmt, const char *queryString);
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 5677b6c97f..6a3bdd634d 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -542,13 +542,13 @@
#define MEMSET_LOOP_LIMIT 1024
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "postgres-xc-bugs@lists.sourceforge.net"
+#define PACKAGE_BUGREPORT "postgres-xl-bugs@lists.sourceforge.net"
/* Define to the full name of this package. */
-#define PACKAGE_NAME "Postgres-XC"
+#define PACKAGE_NAME "Postgres-XL"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Postgres-XC 1.1devel"
+#define PACKAGE_STRING "Postgres-XL 9.2.0"
/* Define to the version of this package. */
#define PACKAGE_VERSION "9.2beta2"
@@ -560,7 +560,7 @@
#define PG_VERSION_NUM 90200
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "postgres-xc"
+#define PACKAGE_TARNAME "postgres-xl"
/* Postgres-XC version as a string */
#define PGXC_VERSION "1.1devel"
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index dd978d79c3..fdff029017 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -3,6 +3,11 @@
*
* Definitions for the PostgreSQL statistics collector daemon.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Copyright (c) 2001-2012, PostgreSQL Global Development Group
*
* src/include/pgstat.h
@@ -839,6 +844,11 @@ extern void pgstat_count_heap_insert(Relation rel, int n);
extern void pgstat_count_heap_update(Relation rel, bool hot);
extern void pgstat_count_heap_delete(Relation rel);
extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
+#ifdef XCP
+extern void pgstat_count_remote_insert(Relation rel, int n);
+extern void pgstat_count_remote_update(Relation rel, int n);
+extern void pgstat_count_remote_delete(Relation rel, int n);
+#endif
extern void pgstat_init_function_usage(FunctionCallInfoData *fcinfo,
PgStat_FunctionCallUsage *fcu);
diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h
index 169be003b4..f52bb3181b 100644
--- a/src/include/pgxc/execRemote.h
+++ b/src/include/pgxc/execRemote.h
@@ -5,6 +5,11 @@
* Functions to execute commands on multiple Datanodes
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
*
@@ -18,11 +23,15 @@
#include "locator.h"
#include "nodes/nodes.h"
#include "pgxcnode.h"
+#include "planner.h"
+#ifdef XCP
+#include "squeue.h"
+#include "remotecopy.h"
+#endif
#include "access/tupdesc.h"
#include "executor/tuptable.h"
#include "nodes/execnodes.h"
#include "nodes/pg_list.h"
-#include "optimizer/pgxcplan.h"
#include "tcop/dest.h"
#include "tcop/pquery.h"
#include "utils/snapshot.h"
@@ -38,6 +47,10 @@ extern bool EnforceTwoPhaseCommit;
#define RESPONSE_DATAROW 3
#define RESPONSE_COPY 4
#define RESPONSE_BARRIER_OK 5
+#ifdef XCP
+#define RESPONSE_ERROR 6
+#define RESPONSE_READY 10
+#endif
typedef enum
{
@@ -46,6 +59,10 @@ typedef enum
REQUEST_TYPE_QUERY, /* Row description response */
REQUEST_TYPE_COPY_IN, /* Copy In response */
REQUEST_TYPE_COPY_OUT /* Copy Out response */
+#ifdef XCP
+ ,
+ REQUEST_TYPE_ERROR /* Error, ignore responses */
+#endif
} RequestType;
/*
@@ -66,6 +83,8 @@ typedef struct CombineTag
char data[COMPLETION_TAG_BUFSIZE]; /* execution result combination data */
} CombineTag;
+
+#ifndef XCP
/*
* Represents a DataRow message received from a remote node.
* Contains originating node number and message body in DataRow format without
@@ -78,8 +97,18 @@ typedef struct RemoteDataRowData
int msgnode; /* node number of the data row message */
} RemoteDataRowData;
typedef RemoteDataRowData *RemoteDataRow;
+#endif
+#ifdef XCP
+/*
+ * Common part for all plan state nodes needed to access remote datanodes
+ * ResponseCombiner must be the first field of the plan state node so we can
+ * typecast
+ */
+typedef struct ResponseCombiner
+#else
typedef struct RemoteQueryState
+#endif
{
ScanState ss; /* its first field is NodeTag */
int node_count; /* total count of participating nodes */
@@ -93,54 +122,157 @@ typedef struct RemoteQueryState
int description_count; /* count of received RowDescription messages */
int copy_in_count; /* count of received CopyIn messages */
int copy_out_count; /* count of received CopyOut messages */
+ FILE *copy_file; /* used if copy_dest == COPY_FILE */
+ uint64 processed; /* count of data rows handled */
char errorCode[5]; /* error code to send back to client */
char *errorMessage; /* error message to send back to client */
char *errorDetail; /* error detail to send back to client */
- bool query_Done; /* query has been sent down to Datanodes */
+#ifdef XCP
+ Oid returning_node; /* returning replicated node */
+ RemoteDataRow currentRow; /* next data ro to be wrapped into a tuple */
+#else
RemoteDataRowData currentRow; /* next data ro to be wrapped into a tuple */
+#endif
/* TODO use a tuplestore as a rowbuffer */
List *rowBuffer; /* buffer where rows are stored when connection
* should be cleaned for reuse by other RemoteQuery */
+#ifdef XCP
+ /*
+ * To handle special case - if there is a simple sort and sort connection
+ * is buffered. If EOF is reached on a connection it should be removed from
+ * the array, but we need to know node number of the connection to find
+ * messages in the buffer. So we store nodenum to that array if reach EOF
+ * when buffering
+ */
+ Oid *tapenodes;
+ /*
+ * If some tape (connection) is buffered, contains a reference on the cell
+ * right before first row buffered from this tape, needed to speed up
+ * access to the data
+ */
+ ListCell **tapemarks;
+ bool merge_sort; /* perform mergesort of node tuples */
+ bool extended_query; /* running extended query protocol */
+ bool probing_primary; /* trying replicated on primary node */
+#else
/*
- * To handle special case - if this RemoteQuery is feeding sorted data to
- * Sort plan and if the connection fetching data from the Datanode
+ * To handle special case - if there is a simple sort and sort connection
* is buffered. If EOF is reached on a connection it should be removed from
* the array, but we need to know node number of the connection to find
* messages in the buffer. So we store nodenum to that array if reach EOF
* when buffering
*/
int *tapenodes;
- RemoteCopyType remoteCopyType; /* Type of remote COPY operation */
- FILE *copy_file; /* used if remoteCopyType == REMOTE_COPY_FILE */
- uint64 processed; /* count of data rows when running CopyOut */
+#endif
+ void *tuplesortstate; /* for merge sort */
+ /* COPY support */
+ RemoteCopyType remoteCopyType;
+ Tuplestorestate *tuplestorestate;
/* cursor support */
char *cursor; /* cursor name */
char *update_cursor; /* throw this cursor current tuple can be updated */
int cursor_count; /* total count of participating nodes */
- PGXCNodeHandle **cursor_connections;/* Datanode connections being combined */
+ PGXCNodeHandle **cursor_connections;/* data node connections being combined */
+#ifdef XCP
+} ResponseCombiner;
+
+typedef struct RemoteQueryState
+{
+ ResponseCombiner combiner; /* see ResponseCombiner struct */
+#endif
+ bool query_Done; /* query has been sent down to Datanodes */
+ /*
+ * While we are not supporting grouping use this flag to indicate we need
+ * to initialize collecting of aggregates from the DNs
+ */
+ bool initAggregates;
+ /* Simple DISTINCT support */
+ FmgrInfo *eqfunctions; /* functions to compare tuples */
+ MemoryContext tmp_ctx; /* separate context is needed to compare tuples */
/* Support for parameters */
char *paramval_data; /* parameter data, format is like in BIND */
int paramval_len; /* length of parameter values data */
- Oid *rqs_param_types; /* Types of the remote params */
- int rqs_num_params;
int eflags; /* capability flags to pass to tuplestore */
bool eof_underlying; /* reached end of underlying plan? */
- Tuplestorestate *tuplestorestate;
+#ifndef XCP
CommandId rqs_cmd_id; /* Cmd id to use in some special cases */
- int rqs_tapenum; /* Connection from which to fetch next row,
- * in case of Sorting */
- TupleTableSlot *rqs_tapedata; /* Data received from this connection to be
- * buffered between getlen and readtup calls
- * for sort */
- bool rqs_for_sort; /* The row fetches will be handled by Sort */
- bool non_fqs_dml; /* true if this is a non fast query shipped DML
- * For detailed discussion on why this variable
- * is required see comments in ExecProcNodeDMLInXC */
+#endif
} RemoteQueryState;
+
+#ifdef XCP
+typedef struct RemoteParam
+{
+ ParamKind paramkind; /* kind of parameter */
+ int paramid; /* numeric ID for parameter */
+ Oid paramtype; /* pg_type OID of parameter's datatype */
+} RemoteParam;
+
+
+/*
+ * Execution state of a RemoteSubplan node
+ */
+typedef struct RemoteSubplanState
+{
+ ResponseCombiner combiner; /* see ResponseCombiner struct */
+ char *subplanstr; /* subplan encoded as a string */
+ bool bound; /* subplan is sent down to the nodes */
+ bool local_exec; /* execute subplan on this datanode */
+ Locator *locator; /* determine destination of tuples of
+ * locally executed plan */
+ int *dest_nodes; /* allocate once */
+ List *execNodes; /* where to execute subplan */
+ /* should query be executed on all (true) or any (false) node specified
+ * in the execNodes list */
+ bool execOnAll;
+ int nParamRemote; /* number of params sent from the master node */
+ RemoteParam *remoteparams; /* parameter descriptors */
+} RemoteSubplanState;
+
+
+/*
+ * Data needed to set up a PreparedStatement on the remote node and other data
+ * for the remote executor
+ */
+typedef struct RemoteStmt
+{
+ NodeTag type;
+
+ CmdType commandType; /* select|insert|update|delete */
+
+ bool hasReturning; /* is it insert|update|delete RETURNING? */
+
+ struct Plan *planTree; /* tree of Plan nodes */
+
+ List *rtable; /* list of RangeTblEntry nodes */
+
+ /* rtable indexes of target relations for INSERT/UPDATE/DELETE */
+ List *resultRelations; /* integer list of RT indexes, or NIL */
+
+ List *subplans; /* Plan trees for SubPlan expressions */
+
+ int nParamExec; /* number of PARAM_EXEC Params used */
+
+ int nParamRemote; /* number of params sent from the master node */
+
+ RemoteParam *remoteparams; /* parameter descriptors */
+
+ List *rowMarks;
+
+ char distributionType;
+
+ AttrNumber distributionKey;
+
+ List *distributionNodes;
+
+ List *distributionRestrict;
+} RemoteStmt;
+#endif
+
typedef void (*xact_callback) (bool isCommit, void *args);
+#ifndef XCP
/* Multinode Executor */
extern void PGXCNodeBegin(void);
extern void PGXCNodeSetBeginQuery(char *query_string);
@@ -149,51 +281,104 @@ extern int PGXCNodeRollback(void);
extern bool PGXCNodePrepare(char *gid);
extern bool PGXCNodeRollbackPrepared(char *gid);
extern void PGXCNodeCommitPrepared(char *gid);
+#endif
+
/* Copy command just involves Datanodes */
+#ifdef XCP
+extern void DataNodeCopyBegin(RemoteCopyData *rcstate);
+extern int DataNodeCopyIn(char *data_row, int len, int conn_count,
+ PGXCNodeHandle** copy_connections);
+extern uint64 DataNodeCopyOut(PGXCNodeHandle** copy_connections,
+ int conn_count, FILE* copy_file);
+extern uint64 DataNodeCopyStore(PGXCNodeHandle** copy_connections,
+ int conn_count, Tuplestorestate* store);
+extern void DataNodeCopyFinish(int conn_count, PGXCNodeHandle** connections);
+extern int DataNodeCopyInBinaryForAll(char *msg_buf, int len, int conn_count,
+ PGXCNodeHandle** connections);
+#else
extern PGXCNodeHandle** DataNodeCopyBegin(const char *query, List *nodelist, Snapshot snapshot);
extern int DataNodeCopyIn(char *data_row, int len, ExecNodes *exec_nodes, PGXCNodeHandle** copy_connections);
extern uint64 DataNodeCopyOut(ExecNodes *exec_nodes, PGXCNodeHandle** copy_connections, TupleDesc tupleDesc,
FILE* copy_file, Tuplestorestate *store, RemoteCopyType remoteCopyType);
extern void DataNodeCopyFinish(PGXCNodeHandle** copy_connections, int primary_dn_index, CombineType combine_type);
-extern bool DataNodeCopyEnd(PGXCNodeHandle *handle, bool is_error);
extern int DataNodeCopyInBinaryForAll(char *msg_buf, int len, PGXCNodeHandle** copy_connections);
+#endif
+extern bool DataNodeCopyEnd(PGXCNodeHandle *handle, bool is_error);
+#ifndef XCP
extern int ExecCountSlotsRemoteQuery(RemoteQuery *node);
+#endif
extern RemoteQueryState *ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags);
extern TupleTableSlot* ExecRemoteQuery(RemoteQueryState *step);
extern void ExecEndRemoteQuery(RemoteQueryState *step);
+#ifdef XCP
+extern void RemoteSubplanMakeUnique(Node *plan, int unique);
+extern RemoteSubplanState *ExecInitRemoteSubplan(RemoteSubplan *node, EState *estate, int eflags);
+extern void ExecFinishInitRemoteSubplan(RemoteSubplanState *node);
+extern TupleTableSlot* ExecRemoteSubplan(RemoteSubplanState *node);
+extern void ExecEndRemoteSubplan(RemoteSubplanState *node);
+extern void ExecReScanRemoteSubplan(RemoteSubplanState *node);
+#endif
extern void ExecRemoteUtility(RemoteQuery *node);
-extern int handle_response(PGXCNodeHandle * conn, RemoteQueryState *combiner);
extern bool is_data_node_ready(PGXCNodeHandle * conn);
-extern void HandleCmdComplete(CmdType commandType, CombineTag *combine, const char *msg_body, size_t len);
+
+#ifdef XCP
+extern int handle_response(PGXCNodeHandle *conn, ResponseCombiner *combiner);
+#else
+extern int handle_response(PGXCNodeHandle *conn, RemoteQueryState *combiner);
+#endif
+extern void HandleCmdComplete(CmdType commandType, CombineTag *combine, const char *msg_body,
+ size_t len);
+
+#ifdef XCP
+#define CHECK_OWNERSHIP(conn, node) \
+ do { \
+ if ((conn)->state == DN_CONNECTION_STATE_QUERY && \
+ (conn)->combiner && \
+ (conn)->combiner != (ResponseCombiner *) (node)) \
+ BufferConnection(conn); \
+ (conn)->combiner = (ResponseCombiner *) (node); \
+ } while(0)
+
+extern TupleTableSlot *FetchTuple(ResponseCombiner *combiner);
+extern void InitResponseCombiner(ResponseCombiner *combiner, int node_count,
+ CombineType combine_type);
+extern void CloseCombiner(ResponseCombiner *combiner);
+#else
extern bool FetchTuple(RemoteQueryState *combiner, TupleTableSlot *slot);
+#endif
extern void BufferConnection(PGXCNodeHandle *conn);
extern void ExecRemoteQueryReScan(RemoteQueryState *node, ExprContext *exprCtxt);
-extern void SetDataRowForExtParams(ParamListInfo params, RemoteQueryState *rq_state);
+extern int ParamListToDataRow(ParamListInfo params, char** result);
extern void ExecCloseRemoteStatement(const char *stmt_name, List *nodelist);
-extern void PreCommit_Remote(char *prepareGID, bool preparedLocalNode);
extern char *PrePrepare_Remote(char *prepareGID, bool localNode, bool implicit);
+#ifdef XCP
+extern void PostPrepare_Remote(char *prepareGID, bool implicit);
+extern void PreCommit_Remote(char *prepareGID, char *nodestring, bool preparedLocalNode);
+#else
extern void PostPrepare_Remote(char *prepareGID, char *nodestring, bool implicit);
+extern void PreCommit_Remote(char *prepareGID, bool preparedLocalNode);
+#endif
extern bool PreAbort_Remote(void);
extern void AtEOXact_Remote(void);
extern bool IsTwoPhaseCommitRequired(bool localWrite);
extern bool FinishRemotePreparedTransaction(char *prepareGID, bool commit);
+#ifndef XCP
/* Flags related to temporary objects included in query */
extern void ExecSetTempObjectIncluded(void);
extern bool ExecIsTempObjectIncluded(void);
-extern TupleTableSlot *ExecProcNodeDMLInXC(RemoteQueryState *resultRemoteRel,
- TupleTableSlot *slot);
+extern void ExecRemoteQueryStandard(Relation resultRelationDesc, RemoteQueryState *resultRemoteRel, TupleTableSlot *slot);
extern void pgxc_all_success_nodes(ExecNodes **d_nodes, ExecNodes **c_nodes, char **failednodes_msg);
extern void AtEOXact_DBCleanup(bool isCommit);
extern void set_dbcleanup_callback(xact_callback function, void *paraminfo, int paraminfo_size);
-extern void do_query(RemoteQueryState *node);
#endif
+#endif
diff --git a/src/include/pgxc/locator.h b/src/include/pgxc/locator.h
index 43ee425c25..145028f962 100644
--- a/src/include/pgxc/locator.h
+++ b/src/include/pgxc/locator.h
@@ -13,9 +13,13 @@
#ifndef LOCATOR_H
#define LOCATOR_H
+#ifdef XCP
+#include "fmgr.h"
+#endif
#define LOCATOR_TYPE_REPLICATED 'R'
#define LOCATOR_TYPE_HASH 'H'
#define LOCATOR_TYPE_RANGE 'G'
+#define LOCATOR_TYPE_SINGLE 'S'
#define LOCATOR_TYPE_RROBIN 'N'
#define LOCATOR_TYPE_CUSTOM 'C'
#define LOCATOR_TYPE_MODULO 'M'
@@ -43,6 +47,8 @@
#include "nodes/primnodes.h"
#include "utils/relcache.h"
+typedef int PartAttrNumber;
+
/*
* How relation is accessed in the query
*/
@@ -56,16 +62,14 @@ typedef enum
typedef struct
{
- Oid relid; /* OID of relation */
- char locatorType; /* locator type, see above */
- AttrNumber partAttrNum; /* Distribution column attribute */
- List *nodeList; /* Node indices where data is located */
- ListCell *roundRobinNode; /* Index of the next node to use */
+ Oid relid;
+ char locatorType;
+ PartAttrNumber partAttrNum; /* if partitioned */
+ char *partAttrName; /* if partitioned */
+ List *nodeList; /* Node Indices */
+ ListCell *roundRobinNode; /* index of the next one to use */
} RelationLocInfo;
-#define IsRelationReplicated(rel_loc) IsLocatorReplicated((rel_loc)->locatorType)
-#define IsRelationColumnDistributed(rel_loc) IsLocatorColumnDistributed((rel_loc)->locatorType)
-#define IsRelationDistributedByValue(rel_loc) IsLocatorDistributedByValue((rel_loc)->locatorType)
/*
* Nodes to execute on
* primarynodelist is for replicated table writes, where to execute first.
@@ -75,52 +79,113 @@ typedef struct
typedef struct
{
NodeTag type;
- List *primarynodelist; /* Primary node list indexes */
- List *nodeList; /* Node list indexes */
- char baselocatortype; /* Locator type, see above */
- Expr *en_expr; /* Expression to evaluate at execution time
- * if planner can not determine execution
- * nodes */
- Oid en_relid; /* Relation to determine execution nodes */
- RelationAccessType accesstype; /* Access type to determine execution
- * nodes */
+ List *primarynodelist;
+ List *nodeList;
+ char baselocatortype;
+ Expr *en_expr; /* expression to evaluate at execution time if planner
+ * can not determine execution nodes */
+ Oid en_relid; /* Relation to determine execution nodes */
+ RelationAccessType accesstype; /* Access type to determine execution nodes */
} ExecNodes;
-#define IsExecNodesReplicated(en) IsLocatorReplicated((en)->baselocatortype)
-#define IsExecNodesColumnDistributed(en) IsLocatorColumnDistributed((en)->baselocatortype)
-#define IsExecNodesDistributedByValue(en) IsLocatorDistributedByValue((en)->baselocatortype)
+
+#ifdef XCP
+typedef enum
+{
+ LOCATOR_LIST_NONE, /* locator returns integers in range 0..NodeCount-1,
+ * value of nodeList ignored and can be NULL */
+ LOCATOR_LIST_INT, /* nodeList is an integer array (int *), value from
+ * the array is returned */
+ LOCATOR_LIST_OID, /* node list is an array of Oids (Oid *), value from
+ * the array is returned */
+ LOCATOR_LIST_POINTER, /* node list is an array of pointers (void **),
+ * value from the array is returned */
+ LOCATOR_LIST_LIST, /* node list is a list, item type is determined by
+ * list type (integer, oid or pointer). NodeCount
+ * is ignored */
+} LocatorListType;
+
+typedef Datum (*LocatorHashFunc) (PG_FUNCTION_ARGS);
+
+typedef struct _Locator Locator;
+
+
+/*
+ * Creates a structure holding necessary info to effectively determine nodes
+ * where a tuple should be stored.
+ * Locator does not allocate memory while working, all allocations are made at
+ * the creation time.
+ *
+ * Parameters:
+ *
+ * locatorType - see LOCATOR_TYPE_* constants
+ * accessType - see RelationAccessType enum
+ * dataType - actual data type of values provided to determine nodes
+ * listType - defines how nodeList parameter is interpreted, see
+ * LocatorListType enum for more details
+ * nodeCount - number of nodes to distribute
+ * nodeList - detailed info about relation nodes. Either List or array or NULL
+ * result - returned address of the array where locator will output node
+ * references. Type of array items (int, Oid or pointer (void *))
+ * depends on listType.
+ * primary - set to true if caller ever wants to determine primary node.
+ * Primary node will be returned as the first element of the
+ * result array
+ */
+extern Locator *createLocator(char locatorType, RelationAccessType accessType,
+ Oid dataType, LocatorListType listType, int nodeCount,
+ void *nodeList, void **result, bool primary);
+extern void freeLocator(Locator *locator);
+
+extern int GET_NODES(Locator *self, Datum value, bool isnull, bool *hasprimary);
+extern void *getLocatorResults(Locator *self);
+extern void *getLocatorNodeMap(Locator *self);
+extern int getLocatorNodeCount(Locator *self);
+#endif
/* Extern variables related to locations */
extern Oid primary_data_node;
extern Oid preferred_data_node[MAX_PREFERRED_NODES];
extern int num_preferred_data_nodes;
-/* Function for RelationLocInfo building and management */
-extern void RelationBuildLocator(Relation rel);
-extern RelationLocInfo *GetRelationLocInfo(Oid relid);
-extern RelationLocInfo *CopyRelationLocInfo(RelationLocInfo *srcInfo);
-extern void FreeRelationLocInfo(RelationLocInfo *relationLocInfo);
-extern char *GetRelationDistribColumn(RelationLocInfo *locInfo);
+extern void InitRelationLocInfo(void);
extern char GetLocatorType(Oid relid);
-extern List *GetPreferredReplicationNode(List *relNodes);
-extern bool IsTableDistOnPrimary(RelationLocInfo *locInfo);
-extern bool IsLocatorInfoEqual(RelationLocInfo *locInfo1,
- RelationLocInfo *locInfo2);
-extern int GetRoundRobinNode(Oid relid);
-extern bool IsTypeDistributable(Oid colType);
-extern bool IsDistribColumn(Oid relid, AttrNumber attNum);
-extern ExecNodes *GetRelationNodes(RelationLocInfo *rel_loc_info,
- Datum valueForDistCol,
- bool isValueNull,
- Oid typeOfValueForDistCol,
- RelationAccessType accessType);
-extern ExecNodes *GetRelationNodesByQuals(Oid reloid,
- Index varno,
- Node *quals,
- RelationAccessType relaccess);
-/* Global locator data */
-extern void FreeExecNodes(ExecNodes **exec_nodes);
+extern char ConvertToLocatorType(int disttype);
+
+extern char *GetRelationHashColumn(RelationLocInfo *rel_loc_info);
+extern RelationLocInfo *GetRelationLocInfo(Oid relid);
+extern RelationLocInfo *CopyRelationLocInfo(RelationLocInfo *src_info);
+extern char GetRelationLocType(Oid relid);
+extern bool IsTableDistOnPrimary(RelationLocInfo *rel_loc_info);
+extern bool IsLocatorInfoEqual(RelationLocInfo *rel_loc_info1, RelationLocInfo *rel_loc_info2);
+#ifndef XCP
+extern ExecNodes *GetRelationNodes(RelationLocInfo *rel_loc_info, Datum valueForDistCol,
+ bool isValueNull, Oid typeOfValueForDistCol,
+ RelationAccessType accessType);
+extern ExecNodes *GetRelationNodesByQuals(Oid reloid, Index varno, Node *quals,
+ RelationAccessType relaccess);
+#endif
+extern bool IsHashColumn(RelationLocInfo *rel_loc_info, char *part_col_name);
+extern bool IsHashColumnForRelId(Oid relid, char *part_col_name);
+extern int GetRoundRobinNode(Oid relid);
+
+extern bool IsTypeHashDistributable(Oid col_type);
extern List *GetAllDataNodes(void);
extern List *GetAllCoordNodes(void);
+#ifdef XCP
+extern int GetAnyDataNode(Bitmapset *nodes);
+#else
+extern List *GetPreferredReplicationNode(List *relNodes);
+#endif
+extern void RelationBuildLocator(Relation rel);
+extern void FreeRelationLocInfo(RelationLocInfo *relationLocInfo);
+
+extern bool IsTypeModuloDistributable(Oid col_type);
+extern char *GetRelationModuloColumn(RelationLocInfo *rel_loc_info);
+extern bool IsModuloColumn(RelationLocInfo *rel_loc_info, char *part_col_name);
+extern bool IsModuloColumnForRelId(Oid relid, char *part_col_name);
+extern char *GetRelationDistColumn(RelationLocInfo *rel_loc_info);
+extern bool IsDistColumnForRelId(Oid relid, char *part_col_name);
+extern void FreeExecNodes(ExecNodes **exec_nodes);
#endif /* LOCATOR_H */
diff --git a/src/include/pgxc/pause.h b/src/include/pgxc/pause.h
new file mode 100644
index 0000000000..1ed26ac555
--- /dev/null
+++ b/src/include/pgxc/pause.h
@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ *
+ * pause.h
+ *
+ * Definitions for the Pause/Unpause Cluster handling
+ *
+ * IDENTIFICATION
+ * $$
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef PAUSE_H
+#define PAUSE_H
+
+#include "storage/s_lock.h"
+
+/* Shared memory area for management of cluster pause/unpause */
+typedef struct {
+ int cl_holder_pid; /* pid of the process issuing CLUSTER PAUSE */
+ int cl_process_count; /* Number of processes undergoing txns */
+
+ slock_t cl_mutex; /* locks shared variables mentioned above */
+} ClusterLockInfo;
+
+extern ClusterLockInfo *ClustLinfo;
+
+extern bool cluster_lock_held;
+extern bool cluster_ex_lock_held;
+
+extern void ClusterLockShmemInit(void);
+extern Size ClusterLockShmemSize(void);
+extern void AcquireClusterLock(bool exclusive);
+extern void ReleaseClusterLock(bool exclusive);
+
+extern void RequestClusterPause(bool pause, char *completionTag);
+extern void PGXCCleanClusterLock(int code, Datum arg);
+#endif
diff --git a/src/include/pgxc/pgxc.h b/src/include/pgxc/pgxc.h
index 21cd9c6beb..60c0d138b9 100644
--- a/src/include/pgxc/pgxc.h
+++ b/src/include/pgxc/pgxc.h
@@ -4,6 +4,11 @@
* Postgres-XC flags and connection control information
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2011 PostgreSQL Global Development Group
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
*
@@ -15,9 +20,14 @@
#define PGXC_H
#include "storage/lwlock.h"
+#include "postgres.h"
extern bool isPGXCCoordinator;
extern bool isPGXCDataNode;
+extern bool isRestoreMode;
+#ifdef XCP
+extern char *parentPGXCNode;
+#endif
typedef enum
{
@@ -36,8 +46,14 @@ extern char *PGXCNodeName;
extern int PGXCNodeId;
extern uint32 PGXCNodeIdentifier;
+extern Datum xc_lockForBackupKey1;
+extern Datum xc_lockForBackupKey2;
+
#define IS_PGXC_COORDINATOR isPGXCCoordinator
#define IS_PGXC_DATANODE isPGXCDataNode
+#ifdef XCP
+#define PGXC_PARENT_NODE parentPGXCNode
+#endif
#define REMOTE_CONN_TYPE remoteConnType
#define IsConnFromApp() (remoteConnType == REMOTE_CONN_APP)
@@ -45,4 +61,9 @@ extern uint32 PGXCNodeIdentifier;
#define IsConnFromDatanode() (remoteConnType == REMOTE_CONN_DATANODE)
#define IsConnFromGtm() (remoteConnType == REMOTE_CONN_GTM)
#define IsConnFromGtmProxy() (remoteConnType == REMOTE_CONN_GTM_PROXY)
-#endif /* PGXC_H */
+
+/* key pair to be used as object id while using advisory lock for backup */
+#define XC_LOCK_FOR_BACKUP_KEY_1 0xFFFF
+#define XC_LOCK_FOR_BACKUP_KEY_2 0xFFFF
+
+#endif /* PGXC */
diff --git a/src/include/pgxc/pgxcnode.h b/src/include/pgxc/pgxcnode.h
index 31f973cbca..621e4a9a45 100644
--- a/src/include/pgxc/pgxcnode.h
+++ b/src/include/pgxc/pgxcnode.h
@@ -5,6 +5,11 @@
* Utility functions to communicate to Datanodes and Coordinators
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group ?
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
*
@@ -24,7 +29,6 @@
#define NO_SOCKET -1
-
/* Connection to Datanode maintained by Pool Manager */
typedef struct PGconn NODE_CONNECTION;
typedef struct PGcancel NODE_CANCEL;
@@ -34,6 +38,7 @@ typedef enum
{
DN_CONNECTION_STATE_IDLE, /* idle, ready for query */
DN_CONNECTION_STATE_QUERY, /* query is sent, response expected */
+ DN_CONNECTION_STATE_CLOSE, /* close is sent, confirmation expected */
DN_CONNECTION_STATE_ERROR_FATAL, /* fatal error */
DN_CONNECTION_STATE_COPY_IN,
DN_CONNECTION_STATE_COPY_OUT
@@ -46,6 +51,7 @@ typedef enum
HANDLE_DEFAULT
} PGXCNode_HandleRequested;
+#ifndef XCP
/*
* Enumeration for two purposes
* 1. To indicate to the HandleCommandComplete function whether response checking is required or not
@@ -64,7 +70,7 @@ typedef enum
RESP_ROLLBACK_RECEIVED, /* Response is ROLLBACK */
RESP_ROLLBACK_NOT_RECEIVED /* Response is NOT ROLLBACK */
}RESP_ROLLBACK;
-
+#endif
#define DN_CONNECTION_STATE_ERROR(dnconn) \
((dnconn)->state == DN_CONNECTION_STATE_ERROR_FATAL \
@@ -83,7 +89,12 @@ struct pgxc_node_handle
/* Connection state */
char transaction_status;
DNConnectionState state;
+#ifdef XCP
+ bool read_only;
+ struct ResponseCombiner *combiner;
+#else
struct RemoteQueryState *combiner;
+#endif
#ifdef DN_CONNECTION_DEBUG
bool have_row_desc;
#endif
@@ -98,14 +109,17 @@ struct pgxc_node_handle
size_t inStart;
size_t inEnd;
size_t inCursor;
-
/*
* Have a variable to enable/disable response checking and
* if enable then read the result of response checking
*
* For details see comments of RESP_ROLLBACK
*/
+#ifdef XCP
+ bool ck_resp_rollback;
+#else
RESP_ROLLBACK ck_resp_rollback;
+#endif
};
typedef struct pgxc_node_handle PGXCNodeHandle;
@@ -122,27 +136,46 @@ typedef struct
extern void InitMultinodeExecutor(bool is_force);
/* Open/close connection routines (invoked from Pool Manager) */
+#ifdef XCP
+extern char *PGXCNodeConnStr(char *host, int port, char *dbname, char *user,
+ char *remote_type, char *parent_node);
+#else
extern char *PGXCNodeConnStr(char *host, int port, char *dbname, char *user,
char *pgoptions, char *remote_type);
+#endif
extern NODE_CONNECTION *PGXCNodeConnect(char *connstr);
+#ifndef XCP
extern int PGXCNodeSendSetQuery(NODE_CONNECTION *conn, const char *sql_command);
+#endif
extern void PGXCNodeClose(NODE_CONNECTION * conn);
extern int PGXCNodeConnected(NODE_CONNECTION * conn);
extern int PGXCNodeConnClean(NODE_CONNECTION * conn);
extern void PGXCNodeCleanAndRelease(int code, Datum arg);
+#ifdef XCP
+extern PGXCNodeHandle *get_any_handle(List *datanodelist);
+#endif
/* Look at information cached in node handles */
+#ifdef XCP
+extern int PGXCNodeGetNodeId(Oid nodeoid, char *node_type);
+extern int PGXCNodeGetNodeIdFromName(char *node_name, char *node_type);
+#else
extern int PGXCNodeGetNodeId(Oid nodeoid, char node_type);
-extern Oid PGXCNodeGetNodeOid(int nodeid, char node_type);
extern int PGXCNodeGetNodeIdFromName(char *node_name, char node_type);
+#endif
+extern Oid PGXCNodeGetNodeOid(int nodeid, char node_type);
extern PGXCNodeAllHandles *get_handles(List *datanodelist, List *coordlist, bool is_query_coord_only);
+#ifdef XCP
+extern PGXCNodeAllHandles *get_current_handles(void);
+#endif
extern void pfree_pgxc_all_handles(PGXCNodeAllHandles *handles);
extern void release_handles(void);
+#ifndef XCP
extern void cancel_query(void);
extern void clear_all_data(void);
-
+#endif
extern int get_transaction_nodes(PGXCNodeHandle ** connections,
char client_conn_type,
@@ -171,6 +204,11 @@ extern int pgxc_node_send_query_extended(PGXCNodeHandle *handle, const char *que
int num_params, Oid *param_types,
int paramlen, char *params,
bool send_describe, int fetch_size);
+#ifdef XCP
+extern int pgxc_node_send_plan(PGXCNodeHandle * handle, const char *statement,
+ const char *query, const char *planstr,
+ short num_params, Oid *param_types);
+#endif
extern int pgxc_node_send_gxid(PGXCNodeHandle * handle, GlobalTransactionId gxid);
extern int pgxc_node_send_cmd_id(PGXCNodeHandle *handle, CommandId cid);
extern int pgxc_node_send_snapshot(PGXCNodeHandle * handle, Snapshot snapshot);
@@ -185,8 +223,10 @@ extern int send_some(PGXCNodeHandle * handle, int len);
extern int pgxc_node_flush(PGXCNodeHandle *handle);
extern void pgxc_node_flush_read(PGXCNodeHandle *handle);
+#ifndef XCP
extern int pgxc_all_handles_send_gxid(PGXCNodeAllHandles *pgxc_handles, GlobalTransactionId gxid, bool stop_at_error);
extern int pgxc_all_handles_send_query(PGXCNodeAllHandles *pgxc_handles, const char *buffer, bool stop_at_error);
+#endif
extern char get_message(PGXCNodeHandle *conn, int *len, char **msg);
@@ -194,4 +234,13 @@ extern void add_error_message(PGXCNodeHandle * handle, const char *message);
extern Datum pgxc_execute_on_nodes(int numnodes, Oid *nodelist, char *query);
+#ifdef XCP
+extern void PGXCNodeSetParam(bool local, const char *name, const char *value);
+extern void PGXCNodeResetParams(bool only_local);
+extern char *PGXCNodeGetSessionParamStr(void);
+extern char *PGXCNodeGetTransactionParamStr(void);
+extern void pgxc_node_set_query(PGXCNodeHandle *handle, const char *set_query);
+extern void RequestInvalidateRemoteHandles(void);
+#endif
+
#endif /* PGXCNODE_H */
diff --git a/src/include/pgxc/planner.h b/src/include/pgxc/planner.h
new file mode 100644
index 0000000000..6ee83fb0c0
--- /dev/null
+++ b/src/include/pgxc/planner.h
@@ -0,0 +1,236 @@
+/*-------------------------------------------------------------------------
+ *
+ * planner.h
+ * Externally declared locator functions
+ *
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 2010-2012 Postgres-XC Development Group
+ *
+ * src/include/pgxc/planner.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PGXCPLANNER_H
+#define PGXCPLANNER_H
+
+#include "fmgr.h"
+#include "lib/stringinfo.h"
+#include "nodes/params.h"
+#include "nodes/parsenodes.h"
+#include "nodes/plannodes.h"
+#include "nodes/primnodes.h"
+#include "pgxc/locator.h"
+#include "tcop/dest.h"
+#include "nodes/relation.h"
+
+
+typedef enum
+{
+ COMBINE_TYPE_NONE, /* it is known that no row count, do not parse */
+ COMBINE_TYPE_SUM, /* sum row counts (partitioned, round robin) */
+ COMBINE_TYPE_SAME /* expect all row counts to be the same (replicated write) */
+} CombineType;
+
+/* For sorting within RemoteQuery handling */
+/*
+ * It is pretty much like Sort, but without Plan. We may use Sort later.
+ */
+typedef struct
+{
+ NodeTag type;
+ int numCols; /* number of sort-key columns */
+ AttrNumber *sortColIdx; /* their indexes in the target list */
+ Oid *sortOperators; /* OIDs of operators to sort them by */
+ Oid *sortCollations;
+ bool *nullsFirst; /* NULLS FIRST/LAST directions */
+} SimpleSort;
+
+/*
+ * Determines if query has to be launched
+ * on Coordinators only (SEQUENCE DDL),
+ * on Datanodes (normal Remote Queries),
+ * or on all Postgres-XC nodes (Utilities and DDL).
+ */
+typedef enum
+{
+#ifdef XCP
+ EXEC_ON_CURRENT,
+#endif
+ EXEC_ON_DATANODES,
+ EXEC_ON_COORDS,
+ EXEC_ON_ALL_NODES,
+ EXEC_ON_NONE
+} RemoteQueryExecType;
+
+typedef enum
+{
+ EXEC_DIRECT_NONE,
+ EXEC_DIRECT_LOCAL,
+ EXEC_DIRECT_LOCAL_UTILITY,
+ EXEC_DIRECT_UTILITY,
+ EXEC_DIRECT_SELECT,
+ EXEC_DIRECT_INSERT,
+ EXEC_DIRECT_UPDATE,
+ EXEC_DIRECT_DELETE
+} ExecDirectType;
+
+/*
+ * Contains instructions on processing a step of a query.
+ * In the prototype this will be simple, but it will eventually
+ * evolve into a GridSQL-style QueryStep.
+ */
+typedef struct
+{
+ Scan scan;
+ ExecDirectType exec_direct_type; /* track if remote query is execute direct and what type it is */
+ char *sql_statement;
+ ExecNodes *exec_nodes; /* List of Datanodes where to launch query */
+ CombineType combine_type;
+ SimpleSort *sort;
+ bool read_only; /* do not use 2PC when committing read only steps */
+ bool force_autocommit; /* some commands like VACUUM require autocommit mode */
+ char *statement; /* if specified use it as a PreparedStatement name on Datanodes */
+ char *cursor; /* if specified use it as a Portal name on Datanodes */
+ int remote_num_params; /* number of parameters specified for Prepared remote statement */
+ Oid *remote_param_types; /* parameter types, this pointer is shared
+ * across all the RemoteQuery nodes in the
+ * plan. So, don't change this once set.
+ */
+ RemoteQueryExecType exec_type;
+#ifndef XCP
+ bool is_temp; /* determine if this remote node is based
+ * on a temporary objects (no 2PC) */
+#endif
+ int reduce_level; /* in case of reduced JOIN, it's level */
+ List *base_tlist; /* in case of isReduced, the base tlist */
+ char *outer_alias;
+ char *inner_alias;
+ int outer_reduce_level;
+ int inner_reduce_level;
+ Relids outer_relids;
+ Relids inner_relids;
+ char *inner_statement;
+ char *outer_statement;
+ char *join_condition;
+ bool has_row_marks; /* Did SELECT had FOR UPDATE/SHARE? */
+ bool has_ins_child_sel_parent; /* This node is part of an INSERT SELECT that
+ * inserts into child by selecting from its parent */
+} RemoteQuery;
+
+
+#ifdef XCP
+/*
+ * Going to be a RemoteQuery replacement.
+ * Submit left subplan to the nodes defined by the Distribution and combine
+ * results.
+ */
+typedef struct
+{
+ Scan scan;
+ char distributionType;
+ AttrNumber distributionKey;
+ List *distributionNodes;
+ List *distributionRestrict;
+ List *nodeList;
+ bool execOnAll;
+ SimpleSort *sort;
+ char *cursor;
+ int unique;
+} RemoteSubplan;
+#endif
+
+
+/*
+ * FQS_context
+ * This context structure is used by the Fast Query Shipping walker, to gather
+ * information during analysing query for Fast Query Shipping.
+ */
+typedef struct
+{
+ bool sc_for_expr; /* if false, the we are checking shippability
+ * of the Query, otherwise, we are checking
+ * shippability of a stand-alone expression.
+ */
+ Bitmapset *sc_shippability; /* The conditions for (un)shippability of the
+ * query.
+ */
+ Query *sc_query; /* the query being analysed for FQS */
+ int sc_query_level; /* level of the query */
+ int sc_max_varlevelsup; /* maximum upper level referred to by any
+ * variable reference in the query. If this
+ * value is greater than 0, the query is not
+ * shippable, if shipped alone.
+ */
+ ExecNodes *sc_exec_nodes; /* nodes where the query should be executed */
+ ExecNodes *sc_subquery_en; /* ExecNodes produced by merging the ExecNodes
+ * for individual subqueries. This gets
+ * ultimately merged with sc_exec_nodes.
+ */
+} Shippability_context;
+
+/* enum for reasons as to why a query/expression is not FQSable */
+typedef enum
+{
+ SS_UNSHIPPABLE_EXPR = 0, /* it has unshippable expression */
+ SS_NEED_SINGLENODE, /* Has expressions which can be evaluated when
+ * there is only a single node involved.
+ * Athought aggregates too fit in this class, we
+ * have a separate status to report aggregates,
+ * see below.
+ */
+ SS_NEEDS_COORD, /* the query needs Coordinator */
+ SS_VARLEVEL, /* one of its subqueries has a VAR
+ * referencing an upper level query
+ * relation
+ */
+ SS_NO_NODES, /* no suitable nodes can be found to ship
+ * the query
+ */
+ SS_UNSUPPORTED_EXPR, /* it has expressions currently unsupported
+ * by FQS, but such expressions might be
+ * supported by FQS in future
+ */
+ SS_HAS_AGG_EXPR /* it has aggregate expressions */
+} ShippabilityStat;
+
+#ifndef XCP
+/* global variable corresponding to the GUC with same name */
+extern bool enable_fast_query_shipping;
+/* forbid SQL if unsafe, useful to turn off for development */
+extern bool StrictStatementChecking;
+
+/* forbid SELECT even multi-node ORDER BY */
+extern bool StrictSelectChecking;
+
+extern PlannedStmt *pgxc_planner(Query *query, int cursorOptions,
+ ParamListInfo boundParams);
+extern bool IsHashDistributable(Oid col_type);
+
+extern ExecNodes *IsJoinReducible(RemoteQuery *innernode, RemoteQuery *outernode,
+ Relids in_relids, Relids out_relids,
+ Join *join, JoinPath *join_path, List *rtable);
+
+extern List *AddRemoteQueryNode(List *stmts, const char *queryString,
+ RemoteQueryExecType remoteExecType, bool is_temp);
+extern bool pgxc_query_contains_temp_tables(List *queries);
+extern Expr *pgxc_find_distcol_expr(Index varno, PartAttrNumber partAttrNum,
+extern bool pgxc_query_contains_utility(List *queries);
+#endif
+extern bool pgxc_shippability_walker(Node *node, Shippability_context *sc_context);
+extern bool pgxc_test_shippability_reason(Shippability_context *context,
+ ShippabilityStat reason);
+
+#ifdef XCP
+extern PlannedStmt *pgxc_direct_planner(Query *query, int cursorOptions,
+ ParamListInfo boundParams);
+extern List *AddRemoteQueryNode(List *stmts, const char *queryString,
+ RemoteQueryExecType remoteExecType);
+#endif
+
+#endif /* PGXCPLANNER_H */
diff --git a/src/include/pgxc/poolmgr.h b/src/include/pgxc/poolmgr.h
index 7181968166..1fc04f2007 100644
--- a/src/include/pgxc/poolmgr.h
+++ b/src/include/pgxc/poolmgr.h
@@ -5,6 +5,11 @@
* Definitions for the Datanode connection pool.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
*
@@ -24,6 +29,7 @@
#define MAX_IDLE_TIME 60
+#ifndef XCP
/*
* List of flags related to pooler connection clean up when disconnecting
* a session or relaeasing handles.
@@ -57,11 +63,16 @@ typedef enum
POOL_CMD_LOCAL_SET, /* Local SET flag, current transaction block only */
POOL_CMD_GLOBAL_SET /* Global SET flag */
} PoolCommandType;
+#endif
/* Connection pool entry */
typedef struct
{
+#ifdef XCP
+ time_t released;
+#else
struct timeval released;
+#endif
NODE_CONNECTION *conn;
NODE_CANCEL *xc_cancelConn;
} PGXCNodePoolSlot;
@@ -81,11 +92,16 @@ typedef struct databasepool
{
char *database;
char *user_name;
+#ifndef XCP
char *pgoptions; /* Connection options */
+#endif
HTAB *nodePools; /* Hashtable of PGXCNodePool, one entry for each
* Coordinator or DataNode */
MemoryContext mcxt;
struct databasepool *next; /* Reference to next to organize linked list */
+#ifdef XCP
+ time_t oldest_idle;
+#endif
} DatabasePool;
/*
@@ -107,19 +123,28 @@ typedef struct
Oid *coord_conn_oids; /* one for each Coordinator */
PGXCNodePoolSlot **dn_connections; /* one for each Datanode */
PGXCNodePoolSlot **coord_connections; /* one for each Coordinator */
+#ifndef XCP
char *session_params;
char *local_params;
bool is_temp; /* Temporary objects used for this pool session? */
+#endif
} PoolAgent;
+#ifndef XCP
/* Handle to the pool manager (Session's side) */
typedef struct
{
/* communication channel */
PoolPort port;
} PoolHandle;
+#endif
+#ifdef XCP
+extern int PoolConnKeepAlive;
+extern int PoolMaintenanceTimeout;
+#else
extern int MinPoolSize;
+#endif
extern int MaxPoolSize;
extern int PoolerPort;
@@ -135,6 +160,7 @@ extern int PoolManagerInit(void);
/* Destroy internal structures */
extern int PoolManagerDestroy(void);
+#ifndef XCP
/*
* Get handle to pool manager. This function should be called just before
* forking off new session. It creates PoolHandle, PoolAgent and a pipe between
@@ -150,12 +176,14 @@ extern PoolHandle *GetPoolManagerHandle(void);
* free memory occupied by PoolHandler
*/
extern void PoolManagerCloseHandle(PoolHandle *handle);
+#endif
/*
* Gracefully close connection to the PoolManager
*/
extern void PoolManagerDisconnect(void);
+#ifndef XCP
extern char *session_options(void);
/*
@@ -166,6 +194,7 @@ extern char *session_options(void);
extern void PoolManagerConnect(PoolHandle *handle,
const char *database, const char *user_name,
char *pgoptions);
+#endif
/*
* Reconnect to pool manager
@@ -173,6 +202,8 @@ extern void PoolManagerConnect(PoolHandle *handle,
*/
extern void PoolManagerReconnect(void);
+
+#ifndef XCP
/*
* Save a SET command in Pooler.
* This command is run on existent agent connections
@@ -180,6 +211,7 @@ extern void PoolManagerReconnect(void);
* are requested.
*/
extern int PoolManagerSetCommand(PoolCommandType command_type, const char *set_command);
+#endif
/* Get pooled connections */
extern int *PoolManagerGetConnections(List *datanodelist, List *coordlist);
@@ -197,7 +229,11 @@ extern void PoolManagerReloadConnectionInfo(void);
extern int PoolManagerAbortTransactions(char *dbname, char *username, int **proc_pids);
/* Return connections back to the pool, for both Coordinator and Datanode connections */
+#ifdef XCP
+extern void PoolManagerReleaseConnections(bool destroy);
+#else
extern void PoolManagerReleaseConnections(void);
+#endif
/* Cancel a running query on Datanodes as well as on other Coordinators */
extern void PoolManagerCancelQuery(int dn_count, int* dn_list, int co_count, int* co_list);
@@ -205,10 +241,12 @@ extern void PoolManagerCancelQuery(int dn_count, int* dn_list, int co_count, int
/* Lock/unlock pool manager */
extern void PoolManagerLock(bool is_lock);
+#ifndef XCP
/* Check if pool has a handle */
extern bool IsPoolHandle(void);
/* Send commands to alter the behavior of current transaction */
extern int PoolManagerSendLocalCommand(int dn_count, int* dn_list, int co_count, int* co_list);
+#endif
#endif
diff --git a/src/include/pgxc/postgresql_fdw.h b/src/include/pgxc/postgresql_fdw.h
new file mode 100644
index 0000000000..57ab2b7d1d
--- /dev/null
+++ b/src/include/pgxc/postgresql_fdw.h
@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ *
+ * postgresql_fdw.h
+ *
+ * foreign-data wrapper for PostgreSQL
+ *
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 2010-2012, Postgres-XC Development Group
+ *
+ * src/include/pgxc/postgresql_fdw.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef POSTGRES_FDW_H
+#define POSTGRES_FDW_H
+
+#include "postgres.h"
+#include "pgxc/execRemote.h"
+
+bool is_immutable_func(Oid funcid);
+bool pgxc_is_expr_shippable(Expr *node, bool *has_aggs);
+#endif
diff --git a/src/include/pgxc/remotecopy.h b/src/include/pgxc/remotecopy.h
index 93368c0ada..6adb386306 100644
--- a/src/include/pgxc/remotecopy.h
+++ b/src/include/pgxc/remotecopy.h
@@ -16,6 +16,9 @@
#define REMOTECOPY_H
#include "nodes/parsenodes.h"
+#ifdef XCP
+#include "pgxc/locator.h"
+#endif
/*
* This contains the set of data necessary for remote COPY control.
@@ -32,15 +35,21 @@ typedef struct RemoteCopyData {
* as copy source or destination
*/
StringInfoData query_buf;
-
+#ifdef XCP
+ Locator *locator; /* the locator object */
+ Oid dist_type; /* data type of the distribution column */
+#else
/* Execution nodes for COPY */
ExecNodes *exec_nodes;
+#endif
/* Locator information */
RelationLocInfo *rel_loc; /* the locator key */
+#ifndef XCP
int idx_dist_by_col; /* index of the distributed by column */
PGXCNodeHandle **connections; /* Involved Datanode connections */
+#endif
} RemoteCopyData;
/*
diff --git a/src/include/pgxc/squeue.h b/src/include/pgxc/squeue.h
new file mode 100644
index 0000000000..4cac658fb4
--- /dev/null
+++ b/src/include/pgxc/squeue.h
@@ -0,0 +1,60 @@
+/*-------------------------------------------------------------------------
+ *
+ * barrier.h
+ *
+ * Definitions for the shared queue handling
+ *
+ *
+ * Copyright (c) 2012-2014, TransLattice, Inc.
+ *
+ * IDENTIFICATION
+ * $$
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef SQUEUE_H
+#define SQUEUE_H
+
+#include "postgres.h"
+#include "executor/tuptable.h"
+#include "nodes/pg_list.h"
+#include "utils/tuplestore.h"
+
+extern PGDLLIMPORT int NSQueues;
+extern PGDLLIMPORT int SQueueSize;
+
+/* Fixed size of shared queue, maybe need to be GUC configurable */
+#define SQUEUE_SIZE ((long) SQueueSize * 1024L)
+/* Number of shared queues, maybe need to be GUC configurable */
+#define NUM_SQUEUES ((long) NSQueues)
+
+#define SQUEUE_KEYSIZE (64)
+
+#define SQ_CONS_SELF -1
+#define SQ_CONS_NONE -2
+
+typedef struct SQueueHeader *SharedQueue;
+
+extern Size SharedQueueShmemSize(void);
+extern void SharedQueuesInit(void);
+extern void SharedQueueAcquire(const char *sqname, int ncons);
+extern SharedQueue SharedQueueBind(const char *sqname, List *consNodes,
+ List *distNodes, int *myindex, int *consMap);
+extern void SharedQueueUnBind(SharedQueue squeue);
+extern void SharedQueueRelease(const char *sqname);
+extern void SharedQueuesCleanup(int code, Datum arg);
+
+extern int SharedQueueFinish(SharedQueue squeue, TupleDesc tupDesc,
+ Tuplestorestate **tuplestore);
+
+extern void SharedQueueWrite(SharedQueue squeue, int consumerIdx,
+ TupleTableSlot *slot, Tuplestorestate **tuplestore,
+ MemoryContext tmpcxt);
+extern bool SharedQueueRead(SharedQueue squeue, int consumerIdx,
+ TupleTableSlot *slot, bool canwait);
+extern void SharedQueueReset(SharedQueue squeue, int consumerIdx);
+extern int SharedQueueResetNotConnected(SharedQueue squeue);
+extern bool SharedQueueCanPause(SharedQueue squeue);
+
+#endif
diff --git a/src/include/storage/backendid.h b/src/include/storage/backendid.h
index 8879e2129e..6b951b1566 100644
--- a/src/include/storage/backendid.h
+++ b/src/include/storage/backendid.h
@@ -4,6 +4,11 @@
* POSTGRES backend id communication definitions
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -24,4 +29,19 @@ typedef int BackendId; /* unique currently active backend identifier */
extern PGDLLIMPORT BackendId MyBackendId; /* backend id of this backend */
+#ifdef XCP
+/*
+ * Two next variables make up distributed session id. Actual distributed
+ * session id is a string, which includes coordinator node name, but
+ * it is better to use Oid to store and compare with distributed session ids
+ * of other backends under the same postmaster.
+ */
+extern PGDLLIMPORT Oid MyCoordId;
+
+extern PGDLLIMPORT int MyCoordPid;
+
+/* BackendId of the first backend of the distributed session on the node */
+extern PGDLLIMPORT BackendId MyFirstBackendId;
+#endif
+
#endif /* BACKENDID_H */
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index 7c0fb01cb4..6634554232 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -4,6 +4,11 @@
* Lightweight lock manager
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -75,6 +80,9 @@ typedef enum LWLockId
BarrierLock,
NodeTableLock,
#endif
+#ifdef XCP
+ SQueuesLock,
+#endif
RelationMappingLock,
AsyncCtlLock,
AsyncQueueLock,
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 768e4f89df..8d861a6cfd 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -4,6 +4,11 @@
* per-process shared memory data structures
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -91,6 +96,12 @@ struct PGPROC
BackendId backendId; /* This backend's backend ID (if assigned) */
Oid databaseId; /* OID of database this backend is using */
Oid roleId; /* OID of role using this backend */
+#ifdef XCP
+ Oid coordId; /* Oid of originating coordinator */
+ int coordPid; /* Pid of the originating session */
+ BackendId firstBackendId; /* Backend ID of the first backend of
+ * the distributed session */
+#endif
/*
* While in hot standby mode, shows that a conflict signal has been sent
diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h
index 73b3dabc9b..3bb98b0455 100644
--- a/src/include/storage/procarray.h
+++ b/src/include/storage/procarray.h
@@ -4,6 +4,11 @@
* POSTGRES process array definitions.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -81,5 +86,8 @@ extern bool CountOtherDBBackends(Oid databaseId,
extern void XidCacheRemoveRunningXids(TransactionId xid,
int nxids, const TransactionId *xids,
TransactionId latestXid);
-
+#ifdef XCP
+extern void GetGlobalSessionInfo(int pid, Oid *coordId, int *coordPid);
+extern int GetFirstBackendId(int *numBackends, int *backends);
+#endif /* XCP */
#endif /* PROCARRAY_H */
diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h
index a44659b064..c0127d4f25 100644
--- a/src/include/storage/procsignal.h
+++ b/src/include/storage/procsignal.h
@@ -4,6 +4,11 @@
* Routines for interprocess signalling
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
index f8fc2b2d6e..18c8b98016 100644
--- a/src/include/storage/smgr.h
+++ b/src/include/storage/smgr.h
@@ -4,6 +4,11 @@
* storage manager switch public interface declarations.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -68,8 +73,14 @@ typedef struct SMgrRelationData
typedef SMgrRelationData *SMgrRelation;
+#ifdef XCP
+#define SmgrIsTemp(smgr) \
+ (!OidIsValid(MyCoordId) && \
+ ((smgr)->smgr_rnode.backend != InvalidBackendId))
+#else
#define SmgrIsTemp(smgr) \
((smgr)->smgr_rnode.backend != InvalidBackendId)
+#endif
extern void smgrinit(void);
extern SMgrRelation smgropen(RelFileNode rnode, BackendId backend);
diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h
index 1a8ff4a23b..cdeb8b4810 100644
--- a/src/include/tcop/dest.h
+++ b/src/include/tcop/dest.h
@@ -57,6 +57,11 @@
* calls in portal and cursor manipulations.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -94,6 +99,10 @@ typedef enum
DestIntoRel, /* results sent to relation (SELECT INTO) */
DestCopyOut, /* results sent to COPY TO code */
DestSQLFunction /* results sent to SQL-language func mgr */
+#ifdef XCP
+ ,
+ DestProducer /* results sent to a SharedQueue */
+#endif
} CommandDest;
/* ----------------
diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h
index 22aad2e96c..d91c2a76a0 100644
--- a/src/include/tcop/pquery.h
+++ b/src/include/tcop/pquery.h
@@ -4,6 +4,11 @@
* prototypes for pquery.c.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -42,4 +47,9 @@ extern long PortalRunFetch(Portal portal,
long count,
DestReceiver *dest);
+#ifdef XCP
+extern int AdvanceProducingPortal(Portal portal, bool can_wait);
+extern void cleanupClosedProducers(void);
+#endif
+
#endif /* PQUERY_H */
diff --git a/src/include/tcop/utility.h b/src/include/tcop/utility.h
index 502406ce62..71554f8342 100644
--- a/src/include/tcop/utility.h
+++ b/src/include/tcop/utility.h
@@ -56,4 +56,8 @@ extern bool CommandIsReadOnly(Node *parsetree);
extern void CheckRelationOwnership(RangeVar *rel, bool noCatalogs);
+#ifdef PGXC
+extern bool pgxc_lock_for_utility_stmt(Node *parsetree);
+#endif
+
#endif /* UTILITY_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 571697eb87..87b3a1403a 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -4,6 +4,11 @@
* Declarations for operations on built-in types.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -541,6 +546,7 @@ extern Datum void_recv(PG_FUNCTION_ARGS);
extern Datum void_send(PG_FUNCTION_ARGS);
#ifdef PGXC
extern Datum pgxc_node_str (PG_FUNCTION_ARGS);
+extern Datum pgxc_lock_for_backup (PG_FUNCTION_ARGS);
#endif
extern Datum trigger_in(PG_FUNCTION_ARGS);
extern Datum trigger_out(PG_FUNCTION_ARGS);
@@ -661,9 +667,9 @@ extern Datum pg_get_function_result(PG_FUNCTION_ARGS);
extern char *deparse_expression(Node *expr, List *dpcontext,
bool forceprefix, bool showimplicit);
#ifdef PGXC
-extern void deparse_query(Query *query, StringInfo buf, List *parentnamespace,
- bool finalise_aggs, bool sortgroup_colno);
-extern void deparse_targetlist(Query *query, List *targetList, StringInfo buf);
+extern List *deparse_context_for_remotequery(Alias *aliasname, Oid relid);
+extern void get_query_def_from_valuesList(Query *query, StringInfo buf);
+extern void deparse_query(Query *query, StringInfo buf, List *parentnamespace);
#endif
extern List *deparse_context_for(const char *aliasname, Oid relid);
extern List *deparse_context_for_planstate(Node *planstate, List *ancestors,
@@ -809,8 +815,10 @@ extern Datum text_format_nv(PG_FUNCTION_ARGS);
/* version.c */
extern Datum pgsql_version(PG_FUNCTION_ARGS);
#ifdef PGXC
+#ifndef XCP
extern Datum pgxc_version(PG_FUNCTION_ARGS);
#endif
+#endif
/* xid.c */
extern Datum xidin(PG_FUNCTION_ARGS);
@@ -1182,6 +1190,11 @@ extern Datum pg_cursor(PG_FUNCTION_ARGS);
/* backend/pgxc/pool/poolutils.c */
extern Datum pgxc_pool_check(PG_FUNCTION_ARGS);
extern Datum pgxc_pool_reload(PG_FUNCTION_ARGS);
+
+#ifdef XCP
+/* backend/pgxc/cluster/stormutils.c */
+extern Datum stormdb_promote_standby(PG_FUNCTION_ARGS);
+#endif
#endif
/* backend/access/transam/transam.c */
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 1a28efcc3f..94a8a174ac 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -4,6 +4,11 @@
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Copyright (c) 2000-2012, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
@@ -225,6 +230,10 @@ extern int tcp_keepalives_idle;
extern int tcp_keepalives_interval;
extern int tcp_keepalives_count;
+#ifdef XCP
+extern char *storm_catalog_remap_string;
+#endif
+
/*
* Functions exported by guc.c
*/
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index 7709a3a088..471c2492b9 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -3,6 +3,11 @@
* lsyscache.h
* Convenience routines for common queries in the system catalog cache.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -69,6 +74,11 @@ extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
Oid *typid, int32 *typmod, Oid *collid);
extern char *get_collation_name(Oid colloid);
+#ifdef XCP
+extern Oid get_collation_namespace(Oid colloid);
+extern int32 get_collation_encoding(Oid colloid);
+extern Oid get_collid(const char *collname, int32 collencoding, Oid collnsp);
+#endif
extern char *get_constraint_name(Oid conoid);
extern Oid get_opclass_family(Oid opclass);
extern Oid get_opclass_input_type(Oid opclass);
@@ -166,6 +176,15 @@ extern void free_attstatsslot(Oid atttype,
Datum *values, int nvalues,
float4 *numbers, int nnumbers);
extern char *get_namespace_name(Oid nspid);
+#ifdef XCP
+extern Oid get_namespaceid(const char *nspname);
+extern char *get_typ_name(Oid typid);
+extern Oid get_typ_namespace(Oid typid);
+extern Oid get_typname_typid(const char *typname, Oid typnamespace);
+extern Oid get_funcid(const char *funcname, oidvector *argtypes, Oid funcnsp);
+extern Oid get_opnamespace(Oid opno);
+extern Oid get_operid(const char *oprname, Oid oprleft, Oid oprright, Oid oprnsp);
+#endif
extern Oid get_range_subtype(Oid rangeOid);
#define type_is_array(typid) (get_element_type(typid) != InvalidOid)
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h
index da66ac30b0..efe2a8e3ec 100644
--- a/src/include/utils/plancache.h
+++ b/src/include/utils/plancache.h
@@ -5,6 +5,11 @@
*
* See plancache.c for comments.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -161,5 +166,9 @@ extern CachedPlan *GetCachedPlan(CachedPlanSource *plansource,
ParamListInfo boundParams,
bool useResOwner);
extern void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner);
+#ifdef XCP
+extern void SetRemoteSubplan(CachedPlanSource *plansource,
+ const char *plan_string);
+#endif
#endif /* PLANCACHE_H */
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h
index 4833942654..5c883ace6b 100644
--- a/src/include/utils/portal.h
+++ b/src/include/utils/portal.h
@@ -36,6 +36,11 @@
* to look like NO SCROLL cursors.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -91,6 +96,10 @@ typedef enum PortalStrategy
PORTAL_ONE_MOD_WITH,
PORTAL_UTIL_SELECT,
PORTAL_MULTI_QUERY
+#ifdef XCP
+ ,
+ PORTAL_DISTRIBUTED
+#endif
} PortalStrategy;
/*
@@ -156,6 +165,9 @@ typedef struct PortalData
*/
Tuplestorestate *holdStore; /* store for holdable cursors */
MemoryContext holdContext; /* memory containing holdStore */
+#ifdef XCP
+ MemoryContext tmpContext; /* temporary memory */
+#endif
/*
* atStart, atEnd and portalPos indicate the current cursor position.
@@ -219,5 +231,12 @@ extern void PortalDefineQuery(Portal portal,
extern Node *PortalListGetPrimaryStmt(List *stmts);
extern void PortalCreateHoldStore(Portal portal);
extern void PortalHashTableDeleteAll(void);
+#ifdef XCP
+extern void PortalCreateProducerStore(Portal portal);
+extern List *getProducingPortals(void);
+extern void addProducingPortal(Portal portal);
+extern void removeProducingPortal(Portal portal);
+extern bool portalIsProducing(Portal portal);
+#endif
#endif /* PORTAL_H */
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index ff3eaec84d..3a5b6a6053 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -4,6 +4,11 @@
* POSTGRES relation descriptor (a/k/a relcache entry) definitions.
*
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
@@ -26,6 +31,9 @@
#endif
#include "rewrite/prs2lock.h"
#include "storage/block.h"
+#ifdef XCP
+#include "storage/proc.h"
+#endif
#include "storage/relfilenode.h"
#include "utils/relcache.h"
#include "utils/reltrigger.h"
@@ -366,15 +374,14 @@ typedef struct StdRdOptions
* RelationUsesLocalBuffers
* True if relation's pages are stored in local buffers.
*/
+#ifdef XCP
+#define RelationUsesLocalBuffers(relation) \
+ !OidIsValid(MyCoordId) && \
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+#else
#define RelationUsesLocalBuffers(relation) \
((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
-
-/*
- * RelationUsesTempNamespace
- * True if relation's catalog entries live in a private namespace.
- */
-#define RelationUsesTempNamespace(relation) \
- ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+#endif
#ifdef PGXC
/*
@@ -385,15 +392,40 @@ typedef struct StdRdOptions
#endif
/*
+ * RelationUsesTempNamespace
+ * True if relation's catalog entries live in a private namespace.
+ */
+#define RelationUsesTempNamespace(relation) \
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+
+/*
* RELATION_IS_LOCAL
* If a rel is either temp or newly created in the current transaction,
* it can be assumed to be visible only to the current backend.
*
* Beware of multiple eval of argument
*/
+#ifdef XCP
+#define RELATION_IS_LOCAL(relation) \
+ ((!OidIsValid(MyCoordId) && (relation)->rd_backend == MyBackendId) || \
+ (OidIsValid(MyCoordId) && (relation)->rd_backend == MyFirstBackendId) || \
+ ((relation)->rd_backend == MyBackendId || \
+ (relation)->rd_createSubid != InvalidSubTransactionId))
+#else
#define RELATION_IS_LOCAL(relation) \
((relation)->rd_backend == MyBackendId || \
(relation)->rd_createSubid != InvalidSubTransactionId)
+#endif
+
+#ifdef XCP
+/*
+ * RelationGetLocatorType
+ * Returns the rel's locator type.
+ */
+#define RelationGetLocatorType(relation) \
+ ((relation)->rd_locator_info->locatorType)
+
+#endif
/*
* RELATION_IS_OTHER_TEMP
@@ -401,9 +433,17 @@ typedef struct StdRdOptions
*
* Beware of multiple eval of argument
*/
+#ifdef XCP
+#define RELATION_IS_OTHER_TEMP(relation) \
+ (((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP && \
+ (relation)->rd_backend != MyBackendId) && \
+ ((!OidIsValid(MyCoordId) && (relation)->rd_backend != MyBackendId) || \
+ (OidIsValid(MyCoordId) && (relation)->rd_backend != MyFirstBackendId)))
+#else
#define RELATION_IS_OTHER_TEMP(relation) \
((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP \
&& (relation)->rd_backend != MyBackendId)
+#endif
/* routines in utils/cache/relcache.c */
extern void RelationIncrementReferenceCount(Relation rel);
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index 249c2407e9..6c0d024cd0 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -10,6 +10,11 @@
* amounts are sorted using temporary files and a standard external sort
* algorithm.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -83,7 +88,11 @@ extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
extern Tuplesortstate *tuplesort_begin_merge(TupleDesc tupDesc,
int nkeys, AttrNumber *attNums,
Oid *sortOperators, Oid *sortCollations, bool *nullsFirstFlags,
+#ifdef XCP
+ ResponseCombiner *combiner,
+#else
RemoteQueryState *combiner,
+#endif
int workMem);
#endif
diff --git a/src/include/utils/tuplestore.h b/src/include/utils/tuplestore.h
index fd2ba4c75b..53c56ceea3 100644
--- a/src/include/utils/tuplestore.h
+++ b/src/include/utils/tuplestore.h
@@ -21,6 +21,11 @@
* Also, we have changed the API to return tuples in TupleTableSlots,
* so that there is a check to prevent attempted access to system columns.
*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Portions Copyright (c) 2012-2014, TransLattice, Inc.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
@@ -82,4 +87,14 @@ extern void tuplestore_clear(Tuplestorestate *state);
extern void tuplestore_end(Tuplestorestate *state);
+#ifdef XCP
+extern Tuplestorestate *tuplestore_begin_datarow(bool interXact, int maxKBytes,
+ MemoryContext tmpcxt);
+extern Tuplestorestate *tuplestore_begin_message(bool interXact, int maxKBytes);
+extern void tuplestore_putmessage(Tuplestorestate *state, int len, char* msg);
+extern char *tuplestore_getmessage(Tuplestorestate *state, int *len);
+#endif
+
+extern void tuplestore_collect_stat(Tuplestorestate *state, char *name);
+
#endif /* TUPLESTORE_H */