mirror of https://github.com/citusdata/citus.git
Now compiles for 11 & 12, but 12 crashes on missing symbol we're supposed to get from ruleutils
parent
86b30ee094
commit
44fa6cc2db
|
@ -28,4 +28,5 @@ configure -whitespace
|
|||
src/backend/distributed/utils/citus_outfuncs.c -citus-style
|
||||
src/backend/distributed/utils/ruleutils_10.c -citus-style
|
||||
src/backend/distributed/utils/ruleutils_11.c -citus-style
|
||||
src/backend/distributed/utils/ruleutils_12.c -citus-style
|
||||
src/include/distributed/citus_nodes.h -citus-style
|
||||
|
|
|
@ -2531,7 +2531,7 @@ if test -z "$version_num"; then
|
|||
as_fn_error $? "Could not detect PostgreSQL version from pg_config." "$LINENO" 5
|
||||
fi
|
||||
|
||||
if test "$version_num" != '10' -a "$version_num" != '11'; then
|
||||
if test "$version_num" != '10' -a "$version_num" != '11' -a "$version_num" != '12'; then
|
||||
as_fn_error $? "Citus is not compatible with the detected PostgreSQL version ${version_num}." "$LINENO" 5
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5
|
||||
|
|
|
@ -74,7 +74,7 @@ if test -z "$version_num"; then
|
|||
AC_MSG_ERROR([Could not detect PostgreSQL version from pg_config.])
|
||||
fi
|
||||
|
||||
if test "$version_num" != '10' -a "$version_num" != '11'; then
|
||||
if test "$version_num" != '10' -a "$version_num" != '11' -a "$version_num" != '12'; then
|
||||
AC_MSG_ERROR([Citus is not compatible with the detected PostgreSQL version ${version_num}.])
|
||||
else
|
||||
AC_MSG_NOTICE([building against PostgreSQL $version_num])
|
||||
|
|
|
@ -645,6 +645,8 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
|||
relationDesc = RelationGetDescr(relation);
|
||||
relationName = RelationGetRelationName(relation);
|
||||
|
||||
#if PG_VERSION_NUM < 120000
|
||||
|
||||
/* verify target relation does not use WITH (OIDS) PostgreSQL feature */
|
||||
if (relationDesc->tdhasoid)
|
||||
{
|
||||
|
@ -653,6 +655,7 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
|||
errdetail("Distributed relations must not specify the WITH "
|
||||
"(OIDS) option in their definitions.")));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* verify target relation does not use identity columns */
|
||||
if (RelationUsesIdentityColumns(relationDesc))
|
||||
|
@ -1196,7 +1199,11 @@ CopyLocalDataIntoShards(Oid distributedRelationId)
|
|||
bool stopOnFailure = true;
|
||||
|
||||
EState *estate = NULL;
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
TableScanDesc scan = NULL;
|
||||
#else
|
||||
HeapScanDesc scan = NULL;
|
||||
#endif
|
||||
HeapTuple tuple = NULL;
|
||||
ExprContext *econtext = NULL;
|
||||
MemoryContext oldContext = NULL;
|
||||
|
@ -1230,7 +1237,7 @@ CopyLocalDataIntoShards(Oid distributedRelationId)
|
|||
|
||||
/* get the table columns */
|
||||
tupleDescriptor = RelationGetDescr(distributedRelation);
|
||||
slot = MakeSingleTupleTableSlot(tupleDescriptor);
|
||||
slot = MakeSingleTupleTableSlotCompat(tupleDescriptor);
|
||||
columnNameList = TupleDescColumnNameList(tupleDescriptor);
|
||||
|
||||
/* determine the partition column in the tuple descriptor */
|
||||
|
@ -1256,7 +1263,11 @@ CopyLocalDataIntoShards(Oid distributedRelationId)
|
|||
copyDest->rStartup(copyDest, 0, tupleDescriptor);
|
||||
|
||||
/* begin reading from local table */
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
scan = table_beginscan(distributedRelation, GetActiveSnapshot(), 0, NULL);
|
||||
#else
|
||||
scan = heap_beginscan(distributedRelation, GetActiveSnapshot(), 0, NULL);
|
||||
#endif
|
||||
|
||||
oldContext = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
|
||||
|
||||
|
@ -1293,7 +1304,11 @@ CopyLocalDataIntoShards(Oid distributedRelationId)
|
|||
MemoryContextSwitchTo(oldContext);
|
||||
|
||||
/* finish reading from the local table */
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
table_endscan(scan);
|
||||
#else
|
||||
heap_endscan(scan);
|
||||
#endif
|
||||
|
||||
/* finish writing into the shards */
|
||||
copyDest->rShutdown(copyDest);
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "access/htup_details.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#if (PG_VERSION_NUM >= 120000)
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#if (PG_VERSION_NUM < 110000)
|
||||
#include "catalog/pg_constraint_fn.h"
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#if PG_VERSION_NUM > 12000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/htup_details.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/catalog.h"
|
||||
|
|
|
@ -463,7 +463,7 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag)
|
|||
columnNulls = palloc0(columnCount * sizeof(bool));
|
||||
|
||||
/* set up a virtual tuple table slot */
|
||||
tupleTableSlot = MakeSingleTupleTableSlot(tupleDescriptor);
|
||||
tupleTableSlot = MakeSingleTupleTableSlotCompat(tupleDescriptor);
|
||||
tupleTableSlot->tts_nvalid = columnCount;
|
||||
tupleTableSlot->tts_values = columnValues;
|
||||
tupleTableSlot->tts_isnull = columnNulls;
|
||||
|
@ -561,8 +561,8 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag)
|
|||
oldContext = MemoryContextSwitchTo(executorTupleContext);
|
||||
|
||||
/* parse a row from the input */
|
||||
nextRowFound = NextCopyFrom(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls, NULL);
|
||||
nextRowFound = NextCopyFromCompat(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls);
|
||||
|
||||
if (!nextRowFound)
|
||||
{
|
||||
|
@ -681,8 +681,8 @@ CopyToNewShards(CopyStmt *copyStatement, char *completionTag, Oid relationId)
|
|||
oldContext = MemoryContextSwitchTo(executorTupleContext);
|
||||
|
||||
/* parse a row from the input */
|
||||
nextRowFound = NextCopyFrom(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls, NULL);
|
||||
nextRowFound = NextCopyFromCompat(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls);
|
||||
|
||||
if (!nextRowFound)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/htup_details.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/index.h"
|
||||
|
|
|
@ -46,6 +46,7 @@ RedirectCopyDataToRegularFile(const char *filename)
|
|||
File fileDesc = -1;
|
||||
const int fileFlags = (O_APPEND | O_CREAT | O_RDWR | O_TRUNC | PG_BINARY);
|
||||
const int fileMode = (S_IRUSR | S_IWUSR);
|
||||
off_t offset = 0;
|
||||
|
||||
fileDesc = FileOpenForTransmit(filename, fileFlags, fileMode);
|
||||
|
||||
|
@ -57,14 +58,16 @@ RedirectCopyDataToRegularFile(const char *filename)
|
|||
/* if received data has contents, append to regular file */
|
||||
if (copyData->len > 0)
|
||||
{
|
||||
int appended = FileWrite(fileDesc, copyData->data, copyData->len,
|
||||
PG_WAIT_IO);
|
||||
int appended = FileWriteCompat(fileDesc, copyData->data, copyData->len,
|
||||
offset, PG_WAIT_IO);
|
||||
|
||||
if (appended != copyData->len)
|
||||
{
|
||||
ereport(ERROR, (errcode_for_file_access(),
|
||||
errmsg("could not append to received file: %m")));
|
||||
}
|
||||
|
||||
offset += appended;
|
||||
}
|
||||
|
||||
resetStringInfo(copyData);
|
||||
|
@ -90,6 +93,7 @@ SendRegularFile(const char *filename)
|
|||
const uint32 fileBufferSize = 32768; /* 32 KB */
|
||||
const int fileFlags = (O_RDONLY | PG_BINARY);
|
||||
const int fileMode = 0;
|
||||
off_t offset = 0;
|
||||
|
||||
/* we currently do not check if the caller has permissions for this file */
|
||||
fileDesc = FileOpenForTransmit(filename, fileFlags, fileMode);
|
||||
|
@ -103,7 +107,8 @@ SendRegularFile(const char *filename)
|
|||
|
||||
SendCopyOutStart();
|
||||
|
||||
readBytes = FileRead(fileDesc, fileBuffer->data, fileBufferSize, PG_WAIT_IO);
|
||||
readBytes = FileReadCompat(fileDesc, fileBuffer->data, fileBufferSize, offset,
|
||||
PG_WAIT_IO);
|
||||
while (readBytes > 0)
|
||||
{
|
||||
fileBuffer->len = readBytes;
|
||||
|
@ -111,8 +116,9 @@ SendRegularFile(const char *filename)
|
|||
SendCopyData(fileBuffer);
|
||||
|
||||
resetStringInfo(fileBuffer);
|
||||
readBytes = FileRead(fileDesc, fileBuffer->data, fileBufferSize,
|
||||
PG_WAIT_IO);
|
||||
readBytes = FileReadCompat(fileDesc, fileBuffer->data, fileBufferSize,
|
||||
offset, PG_WAIT_IO);
|
||||
offset += readBytes;
|
||||
}
|
||||
|
||||
SendCopyDone();
|
||||
|
|
|
@ -22,9 +22,162 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|
||||
#include "commands/vacuum.h"
|
||||
#include "commands/defrem.h"
|
||||
|
||||
/*
|
||||
* This is mostly ExecVacuum from Postgres's commands/vacuum.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* A wrapper function of defGetBoolean().
|
||||
*
|
||||
* This function returns VACOPT_TERNARY_ENABLED and VACOPT_TERNARY_DISABLED
|
||||
* instead of true and false.
|
||||
*/
|
||||
static VacOptTernaryValue
|
||||
get_vacopt_ternary_value(DefElem *def)
|
||||
{
|
||||
return defGetBoolean(def) ? VACOPT_TERNARY_ENABLED : VACOPT_TERNARY_DISABLED;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
VacuumStmt_options(VacuumStmt *vacstmt)
|
||||
{
|
||||
VacuumParams params;
|
||||
bool verbose = false;
|
||||
bool skip_locked = false;
|
||||
bool analyze = false;
|
||||
bool freeze = false;
|
||||
bool full = false;
|
||||
bool disable_page_skipping = false;
|
||||
ListCell *lc;
|
||||
|
||||
/* Set default value */
|
||||
params.index_cleanup = VACOPT_TERNARY_DEFAULT;
|
||||
params.truncate = VACOPT_TERNARY_DEFAULT;
|
||||
|
||||
/* Parse options list */
|
||||
foreach(lc, vacstmt->options)
|
||||
{
|
||||
DefElem *opt = (DefElem *) lfirst(lc);
|
||||
|
||||
/* Parse common options for VACUUM and ANALYZE */
|
||||
if (strcmp(opt->defname, "verbose") == 0)
|
||||
{
|
||||
verbose = defGetBoolean(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "skip_locked") == 0)
|
||||
{
|
||||
skip_locked = defGetBoolean(opt);
|
||||
}
|
||||
|
||||
/* Parse options available on VACUUM */
|
||||
else if (strcmp(opt->defname, "analyze") == 0)
|
||||
{
|
||||
analyze = defGetBoolean(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "freeze") == 0)
|
||||
{
|
||||
freeze = defGetBoolean(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "full") == 0)
|
||||
{
|
||||
full = defGetBoolean(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "disable_page_skipping") == 0)
|
||||
{
|
||||
disable_page_skipping = defGetBoolean(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "index_cleanup") == 0)
|
||||
{
|
||||
params.index_cleanup = get_vacopt_ternary_value(opt);
|
||||
}
|
||||
else if (strcmp(opt->defname, "truncate") == 0)
|
||||
{
|
||||
params.truncate = get_vacopt_ternary_value(opt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set vacuum options */
|
||||
params.options =
|
||||
(vacstmt->is_vacuumcmd ? VACOPT_VACUUM : VACOPT_ANALYZE) |
|
||||
(verbose ? VACOPT_VERBOSE : 0) |
|
||||
(skip_locked ? VACOPT_SKIP_LOCKED : 0) |
|
||||
(analyze ? VACOPT_ANALYZE : 0) |
|
||||
(freeze ? VACOPT_FREEZE : 0) |
|
||||
(full ? VACOPT_FULL : 0) |
|
||||
(disable_page_skipping ? VACOPT_DISABLE_PAGE_SKIPPING : 0);
|
||||
|
||||
/* sanity checks on options */
|
||||
Assert(params.options & (VACOPT_VACUUM | VACOPT_ANALYZE));
|
||||
Assert((params.options & VACOPT_VACUUM) ||
|
||||
!(params.options & (VACOPT_FULL | VACOPT_FREEZE)));
|
||||
Assert(!(params.options & VACOPT_SKIPTOAST));
|
||||
|
||||
/*
|
||||
* Make sure VACOPT_ANALYZE is specified if any column lists are present.
|
||||
*/
|
||||
if (!(params.options & VACOPT_ANALYZE))
|
||||
{
|
||||
foreach(lc, vacstmt->rels)
|
||||
{
|
||||
VacuumRelation *vrel = lfirst_node(VacuumRelation, lc);
|
||||
|
||||
if (vrel->va_cols != NIL)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg(
|
||||
"ANALYZE option must be specified when a column list is provided")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* All freeze ages are zero if the FREEZE option is given; otherwise pass
|
||||
* them as -1 which means to use the default values.
|
||||
*/
|
||||
if (params.options & VACOPT_FREEZE)
|
||||
{
|
||||
params.freeze_min_age = 0;
|
||||
params.freeze_table_age = 0;
|
||||
params.multixact_freeze_min_age = 0;
|
||||
params.multixact_freeze_table_age = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.freeze_min_age = -1;
|
||||
params.freeze_table_age = -1;
|
||||
params.multixact_freeze_min_age = -1;
|
||||
params.multixact_freeze_table_age = -1;
|
||||
}
|
||||
|
||||
/* user-invoked vacuum is never "for wraparound" */
|
||||
params.is_wraparound = false;
|
||||
|
||||
/* user-invoked vacuum never uses this parameter */
|
||||
params.log_min_duration = -1;
|
||||
|
||||
return params.options;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
static int
|
||||
VacuumStmt_options(VacuumStmt *vacuumStmt)
|
||||
{
|
||||
return vacuumStmt->options;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* Local functions forward declarations for processing distributed table commands */
|
||||
static bool IsDistributedVacuumStmt(VacuumStmt *vacuumStmt, List *vacuumRelationIdList);
|
||||
static bool IsDistributedVacuumStmt(int vacuumOptions, List *vacuumRelationIdList);
|
||||
static List * VacuumTaskList(Oid relationId, int vacuumOptions, List *vacuumColumnList);
|
||||
static StringInfo DeparseVacuumStmtPrefix(int vacuumFlags);
|
||||
static char * DeparseVacuumColumnNames(List *columnNameList);
|
||||
|
@ -49,7 +202,8 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
ListCell *vacuumRelationCell = NULL;
|
||||
List *relationIdList = NIL;
|
||||
ListCell *relationIdCell = NULL;
|
||||
LOCKMODE lockMode = (vacuumStmt->options & VACOPT_FULL) ? AccessExclusiveLock :
|
||||
int vacuumOptions = VacuumStmt_options(vacuumStmt);
|
||||
LOCKMODE lockMode = (vacuumOptions & VACOPT_FULL) ? AccessExclusiveLock :
|
||||
ShareUpdateExclusiveLock;
|
||||
int executedVacuumCount = 0;
|
||||
|
||||
|
@ -60,7 +214,7 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
relationIdList = lappend_oid(relationIdList, relationId);
|
||||
}
|
||||
|
||||
distributedVacuumStmt = IsDistributedVacuumStmt(vacuumStmt, relationIdList);
|
||||
distributedVacuumStmt = IsDistributedVacuumStmt(vacuumOptions, relationIdList);
|
||||
if (!distributedVacuumStmt)
|
||||
{
|
||||
return;
|
||||
|
@ -82,7 +236,7 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
* commands can run inside a transaction block. Notice that we do this
|
||||
* once even if there are multiple distributed tables to be vacuumed.
|
||||
*/
|
||||
if (executedVacuumCount == 0 && (vacuumStmt->options & VACOPT_VACUUM) != 0)
|
||||
if (executedVacuumCount == 0 && (vacuumOptions & VACOPT_VACUUM) != 0)
|
||||
{
|
||||
/* save old commit protocol to restore at xact end */
|
||||
Assert(SavedMultiShardCommitProtocol == COMMIT_PROTOCOL_BARE);
|
||||
|
@ -91,7 +245,7 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
}
|
||||
|
||||
vacuumColumnList = VacuumColumnList(vacuumStmt, relationIndex);
|
||||
taskList = VacuumTaskList(relationId, vacuumStmt->options, vacuumColumnList);
|
||||
taskList = VacuumTaskList(relationId, vacuumOptions, vacuumColumnList);
|
||||
|
||||
/* use adaptive executor when enabled */
|
||||
ExecuteUtilityTaskListWithoutResults(taskList, targetPoolSize, false);
|
||||
|
@ -111,9 +265,9 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
* false otherwise.
|
||||
*/
|
||||
static bool
|
||||
IsDistributedVacuumStmt(VacuumStmt *vacuumStmt, List *vacuumRelationIdList)
|
||||
IsDistributedVacuumStmt(int vacuumOptions, List *vacuumRelationIdList)
|
||||
{
|
||||
const char *stmtName = (vacuumStmt->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE";
|
||||
const char *stmtName = (vacuumOptions & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE";
|
||||
bool distributeStmt = false;
|
||||
ListCell *relationIdCell = NULL;
|
||||
int distributedRelationCount = 0;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "distributed/remote_commands.h"
|
||||
#include "distributed/transmit.h"
|
||||
#include "distributed/transaction_identifier.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
|
@ -413,7 +414,8 @@ RemoteFileDestReceiverReceive(TupleTableSlot *slot, DestReceiver *dest)
|
|||
static void
|
||||
WriteToLocalFile(StringInfo copyData, File fileDesc)
|
||||
{
|
||||
int bytesWritten = FileWrite(fileDesc, copyData->data, copyData->len, PG_WAIT_IO);
|
||||
int bytesWritten = FileWriteCompat(fileDesc, copyData->data, copyData->len, 0,
|
||||
PG_WAIT_IO);
|
||||
if (bytesWritten < 0)
|
||||
{
|
||||
ereport(ERROR, (errcode_for_file_access(),
|
||||
|
|
|
@ -138,7 +138,9 @@ CitusExecutorRun(QueryDesc *queryDesc,
|
|||
EState *estate = queryDesc->estate;
|
||||
|
||||
estate->es_processed = 0;
|
||||
#if PG_VERSION_NUM < 120000
|
||||
estate->es_lastoid = InvalidOid;
|
||||
#endif
|
||||
|
||||
/* start and shutdown tuple receiver to simulate empty result */
|
||||
dest->rStartup(queryDesc->dest, CMD_SELECT, queryDesc->tupDesc);
|
||||
|
@ -351,8 +353,8 @@ ReadFileIntoTupleStore(char *fileName, char *copyFormat, TupleDesc tupleDescript
|
|||
ResetPerTupleExprContext(executorState);
|
||||
oldContext = MemoryContextSwitchTo(executorTupleContext);
|
||||
|
||||
nextRowFound = NextCopyFrom(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls, NULL);
|
||||
nextRowFound = NextCopyFromCompat(copyState, executorExpressionContext,
|
||||
columnValues, columnNulls);
|
||||
if (!nextRowFound)
|
||||
{
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
|
|
|
@ -704,7 +704,7 @@ SortTupleStore(CitusScanState *scanState)
|
|||
/* iterate over all the sorted tuples, add them to original tuplestore */
|
||||
while (true)
|
||||
{
|
||||
TupleTableSlot *newSlot = MakeSingleTupleTableSlot(tupleDescriptor);
|
||||
TupleTableSlot *newSlot = MakeSingleTupleTableSlotCompat(tupleDescriptor);
|
||||
bool found = tuplesort_gettupleslot(tuplesortstate, true, false, newSlot, NULL);
|
||||
|
||||
if (!found)
|
||||
|
|
|
@ -42,13 +42,16 @@
|
|||
#include "distributed/worker_protocol.h"
|
||||
#include "distributed/worker_transaction.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#endif
|
||||
#include "nodes/nodes.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/predtest.h"
|
||||
#include "compat/optimizer/predtest.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "storage/lock.h"
|
||||
#include "storage/lmgr.h"
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "libpq-fe.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/htup_details.h"
|
||||
#include "access/sysattr.h"
|
||||
#include "access/xact.h"
|
||||
|
@ -53,7 +56,6 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/* Local functions forward declarations */
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
#include "distributed/worker_protocol.h"
|
||||
#include "distributed/worker_transaction.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/predtest.h"
|
||||
#include "compat/optimizer/predtest.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "utils/builtins.h"
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "utils/palloc.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/ruleutils.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/varlena.h"
|
||||
|
||||
|
||||
|
@ -472,7 +471,6 @@ master_get_active_worker_nodes(PG_FUNCTION_ARGS)
|
|||
MemoryContext oldContext = NULL;
|
||||
List *workerNodeList = NIL;
|
||||
TupleDesc tupleDescriptor = NULL;
|
||||
bool hasOid = false;
|
||||
|
||||
/* create a function context for cross-call persistence */
|
||||
functionContext = SRF_FIRSTCALL_INIT();
|
||||
|
@ -490,7 +488,11 @@ master_get_active_worker_nodes(PG_FUNCTION_ARGS)
|
|||
* This tuple descriptor must match the output parameters declared for
|
||||
* the function in pg_proc.
|
||||
*/
|
||||
tupleDescriptor = CreateTemplateTupleDesc(WORKER_NODE_FIELDS, hasOid);
|
||||
#if PG_VERSION_NUM < 120000
|
||||
tupleDescriptor = CreateTemplateTupleDesc(WORKER_NODE_FIELDS, false);
|
||||
#else
|
||||
tupleDescriptor = CreateTemplateTupleDesc(WORKER_NODE_FIELDS);
|
||||
#endif
|
||||
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 1, "node_name",
|
||||
TEXTOID, -1, 0);
|
||||
TupleDescInitEntry(tupleDescriptor, (AttrNumber) 2, "node_port",
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/* Local functions forward declarations */
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
static char * LocalGroupIdUpdateCommand(int32 groupId);
|
||||
|
|
|
@ -35,7 +35,11 @@
|
|||
#include "nodes/nodeFuncs.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "parser/parse_type.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/cost.h"
|
||||
#endif
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/planner.h"
|
||||
#include "utils/builtins.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "distributed/metadata_cache.h"
|
||||
#include "distributed/multi_logical_optimizer.h"
|
||||
#include "distributed/pg_dist_partition.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/pg_list.h"
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "distributed/query_pushdown_planning.h"
|
||||
#include "distributed/recursive_planning.h"
|
||||
#include "distributed/resource_lock.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
|
@ -33,7 +34,7 @@
|
|||
#include "optimizer/planner.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "parser/parse_coerce.h"
|
||||
#include "parser/parse_relation.h"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "distributed/pg_dist_partition.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/datum.h"
|
||||
|
|
|
@ -35,12 +35,13 @@
|
|||
#include "distributed/multi_physical_planner.h"
|
||||
#include "distributed/pg_dist_partition.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/print.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parse_agg.h"
|
||||
#include "parser/parse_coerce.h"
|
||||
#include "parser/parse_oper.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/* Config variable managed via guc.c */
|
||||
|
@ -2962,7 +2962,11 @@ AggregateFunctionOid(const char *functionName, Oid inputType)
|
|||
/* check if input type and found value type match */
|
||||
if (procForm->proargtypes.values[0] == inputType)
|
||||
{
|
||||
#if PG_VERSION_NUM < 120000
|
||||
functionOid = HeapTupleGetOid(heapTuple);
|
||||
#else
|
||||
functionOid = procForm->oid;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2992,7 +2996,8 @@ TypeOid(Oid schemaId, const char *typeName)
|
|||
{
|
||||
Oid typeOid;
|
||||
|
||||
typeOid = GetSysCacheOid2(TYPENAMENSP, PointerGetDatum(typeName),
|
||||
typeOid = GetSysCacheOid2Compat(TYPENAMENSP, Anum_pg_type_oid, PointerGetDatum(
|
||||
typeName),
|
||||
ObjectIdGetDatum(schemaId));
|
||||
|
||||
return typeOid;
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
#include "distributed/version_compat.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/prep.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "utils/datum.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "distributed/multi_physical_planner.h"
|
||||
#include "distributed/distributed_planner.h"
|
||||
#include "distributed/multi_server_executor.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
|
@ -29,7 +30,7 @@
|
|||
#include "optimizer/cost.h"
|
||||
#include "optimizer/planmain.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/memutils.h"
|
||||
|
@ -356,9 +357,11 @@ BuildAggregatePlan(Query *masterQuery, Plan *subPlan)
|
|||
}
|
||||
|
||||
/* finally create the plan */
|
||||
aggregatePlan = make_agg(aggregateTargetList, (List *) havingQual, aggregateStrategy,
|
||||
/* TODO no nulls */
|
||||
aggregatePlan = make_aggCompat(aggregateTargetList, (List *) havingQual,
|
||||
aggregateStrategy,
|
||||
AGGSPLIT_SIMPLE, groupColumnCount, groupColumnIdArray,
|
||||
groupColumnOpArray, NIL, NIL,
|
||||
groupColumnOpArray, NULL, NIL, NIL,
|
||||
rowEstimate, subPlan);
|
||||
|
||||
/* just for reproducible costs between different PostgreSQL versions */
|
||||
|
@ -529,10 +532,12 @@ BuildDistinctPlan(Query *masterQuery, Plan *subPlan)
|
|||
Oid *distinctColumnOpArray = extract_grouping_ops(distinctClauseList);
|
||||
uint32 distinctClauseCount = list_length(distinctClauseList);
|
||||
|
||||
distinctPlan = (Plan *) make_agg(targetList, NIL, AGG_HASHED,
|
||||
/* TODO no nulls */
|
||||
distinctPlan = (Plan *) make_aggCompat(targetList, NIL, AGG_HASHED,
|
||||
AGGSPLIT_SIMPLE, distinctClauseCount,
|
||||
distinctColumnIdArray,
|
||||
distinctColumnOpArray, NIL, NIL,
|
||||
distinctColumnOpArray,
|
||||
NULL, NIL, NIL,
|
||||
rowEstimate, subPlan);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -54,9 +54,9 @@
|
|||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/predtest.h"
|
||||
#include "compat/optimizer/predtest.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parse_relation.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "utils/builtins.h"
|
||||
|
|
|
@ -57,9 +57,9 @@
|
|||
#include "optimizer/joininfo.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/paths.h"
|
||||
#include "optimizer/predtest.h"
|
||||
#include "compat/optimizer/predtest.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "parser/parse_oper.h"
|
||||
#include "storage/lock.h"
|
||||
|
|
|
@ -31,10 +31,14 @@
|
|||
#include "distributed/pg_dist_partition.h"
|
||||
#include "distributed/query_pushdown_planning.h"
|
||||
#include "distributed/relation_restriction_equivalence.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "nodes/makefuncs.h"
|
||||
#endif
|
||||
#include "nodes/pg_list.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "compat/optimizer/var.h"
|
||||
#include "parser/parsetree.h"
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
#include "nodes/nodes.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "distributed/multi_physical_planner.h"
|
||||
#include "distributed/shardinterval_utils.h"
|
||||
#include "distributed/pg_dist_partition.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
|
@ -138,6 +139,17 @@ typedef struct PendingPruningInstance
|
|||
Node *continueAt;
|
||||
} PendingPruningInstance;
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
typedef union \
|
||||
{ \
|
||||
FunctionCallInfoBaseData fcinfo; \
|
||||
/* ensure enough space for nargs args is available */ \
|
||||
char fcinfo_data[SizeForFunctionCallInfo(2)]; \
|
||||
} FunctionCall2InfoData;
|
||||
#else
|
||||
typedef FunctionCallInfoData FunctionCall2InfoData;
|
||||
typedef FunctionCallInfoData *FunctionCallInfo;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Data necessary to perform a single PruneShards().
|
||||
|
@ -161,11 +173,11 @@ typedef struct ClauseWalkerContext
|
|||
|
||||
/*
|
||||
* Information about function calls we need to perform. Re-using the same
|
||||
* FunctionCallInfoData, instead of using FunctionCall2Coll, is often
|
||||
* FunctionCall2InfoData, instead of using FunctionCall2Coll, is often
|
||||
* cheaper.
|
||||
*/
|
||||
FunctionCallInfoData compareValueFunctionCall;
|
||||
FunctionCallInfoData compareIntervalFunctionCall;
|
||||
FunctionCall2InfoData compareValueFunctionCall;
|
||||
FunctionCall2InfoData compareIntervalFunctionCall;
|
||||
} ClauseWalkerContext;
|
||||
|
||||
static void PrunableExpressions(Node *originalNode, ClauseWalkerContext *context);
|
||||
|
@ -184,9 +196,9 @@ static void AddNewConjuction(ClauseWalkerContext *context, OpExpr *op);
|
|||
static PruningInstance * CopyPartialPruningInstance(PruningInstance *sourceInstance);
|
||||
static List * ShardArrayToList(ShardInterval **shardArray, int length);
|
||||
static List * DeepCopyShardIntervalList(List *originalShardIntervalList);
|
||||
static int PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a,
|
||||
static int PerformValueCompare(FunctionCallInfo compareFunctionCall, Datum a,
|
||||
Datum b);
|
||||
static int PerformCompare(FunctionCallInfoData *compareFunctionCall);
|
||||
static int PerformCompare(FunctionCallInfo compareFunctionCall);
|
||||
|
||||
static List * PruneOne(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *context,
|
||||
PruningInstance *prune);
|
||||
|
@ -201,11 +213,11 @@ static bool ExhaustivePruneOne(ShardInterval *curInterval,
|
|||
PruningInstance *prune);
|
||||
static int UpperShardBoundary(Datum partitionColumnValue,
|
||||
ShardInterval **shardIntervalCache,
|
||||
int shardCount, FunctionCallInfoData *compareFunction,
|
||||
int shardCount, FunctionCallInfo compareFunction,
|
||||
bool includeMin);
|
||||
static int LowerShardBoundary(Datum partitionColumnValue,
|
||||
ShardInterval **shardIntervalCache,
|
||||
int shardCount, FunctionCallInfoData *compareFunction,
|
||||
int shardCount, FunctionCallInfo compareFunction,
|
||||
bool includeMax);
|
||||
|
||||
|
||||
|
@ -261,7 +273,8 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList,
|
|||
if (cacheEntry->shardIntervalCompareFunction)
|
||||
{
|
||||
/* initiate function call info once (allows comparators to cache metadata) */
|
||||
InitFunctionCallInfoData(context.compareIntervalFunctionCall,
|
||||
InitFunctionCallInfoDataCompat(*(FunctionCallInfo) &
|
||||
context.compareIntervalFunctionCall,
|
||||
cacheEntry->shardIntervalCompareFunction,
|
||||
2, DEFAULT_COLLATION_OID, NULL, NULL);
|
||||
}
|
||||
|
@ -274,7 +287,8 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList,
|
|||
if (cacheEntry->shardColumnCompareFunction)
|
||||
{
|
||||
/* initiate function call info once (allows comparators to cache metadata) */
|
||||
InitFunctionCallInfoData(context.compareValueFunctionCall,
|
||||
InitFunctionCallInfoDataCompat(*(FunctionCallInfo) &
|
||||
context.compareValueFunctionCall,
|
||||
cacheEntry->shardColumnCompareFunction,
|
||||
2, DEFAULT_COLLATION_OID, NULL, NULL);
|
||||
}
|
||||
|
@ -753,7 +767,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
|
|||
case BTLessStrategyNumber:
|
||||
{
|
||||
if (!prune->lessConsts ||
|
||||
PerformValueCompare(&context->compareValueFunctionCall,
|
||||
PerformValueCompare((FunctionCallInfo) &
|
||||
context->compareValueFunctionCall,
|
||||
constantClause->constvalue,
|
||||
prune->lessConsts->constvalue) < 0)
|
||||
{
|
||||
|
@ -766,7 +781,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
|
|||
case BTLessEqualStrategyNumber:
|
||||
{
|
||||
if (!prune->lessEqualConsts ||
|
||||
PerformValueCompare(&context->compareValueFunctionCall,
|
||||
PerformValueCompare((FunctionCallInfo) &
|
||||
context->compareValueFunctionCall,
|
||||
constantClause->constvalue,
|
||||
prune->lessEqualConsts->constvalue) < 0)
|
||||
{
|
||||
|
@ -782,7 +798,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
|
|||
{
|
||||
prune->equalConsts = constantClause;
|
||||
}
|
||||
else if (PerformValueCompare(&context->compareValueFunctionCall,
|
||||
else if (PerformValueCompare((FunctionCallInfo) &
|
||||
context->compareValueFunctionCall,
|
||||
constantClause->constvalue,
|
||||
prune->equalConsts->constvalue) != 0)
|
||||
{
|
||||
|
@ -796,7 +813,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
|
|||
case BTGreaterEqualStrategyNumber:
|
||||
{
|
||||
if (!prune->greaterEqualConsts ||
|
||||
PerformValueCompare(&context->compareValueFunctionCall,
|
||||
PerformValueCompare((FunctionCallInfo) &
|
||||
context->compareValueFunctionCall,
|
||||
constantClause->constvalue,
|
||||
prune->greaterEqualConsts->constvalue) > 0
|
||||
)
|
||||
|
@ -810,7 +828,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
|
|||
case BTGreaterStrategyNumber:
|
||||
{
|
||||
if (!prune->greaterConsts ||
|
||||
PerformValueCompare(&context->compareValueFunctionCall,
|
||||
PerformValueCompare((FunctionCallInfo) &
|
||||
context->compareValueFunctionCall,
|
||||
constantClause->constvalue,
|
||||
prune->greaterConsts->constvalue) > 0)
|
||||
{
|
||||
|
@ -1133,7 +1152,7 @@ PruneOne(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *context,
|
|||
* unexpected NULL returns.
|
||||
*/
|
||||
static int
|
||||
PerformCompare(FunctionCallInfoData *compareFunctionCall)
|
||||
PerformCompare(FunctionCallInfo compareFunctionCall)
|
||||
{
|
||||
Datum result = FunctionCallInvoke(compareFunctionCall);
|
||||
|
||||
|
@ -1151,12 +1170,10 @@ PerformCompare(FunctionCallInfoData *compareFunctionCall)
|
|||
* NULL returns.
|
||||
*/
|
||||
static int
|
||||
PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a, Datum b)
|
||||
PerformValueCompare(FunctionCallInfo compareFunctionCall, Datum a, Datum b)
|
||||
{
|
||||
compareFunctionCall->arg[0] = a;
|
||||
compareFunctionCall->argnull[0] = false;
|
||||
compareFunctionCall->arg[1] = b;
|
||||
compareFunctionCall->argnull[1] = false;
|
||||
fcSetArg(compareFunctionCall, 0, a);
|
||||
fcSetArg(compareFunctionCall, 1, b);
|
||||
|
||||
return PerformCompare(compareFunctionCall);
|
||||
}
|
||||
|
@ -1168,7 +1185,7 @@ PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a, Datum b)
|
|||
*/
|
||||
static int
|
||||
LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCache,
|
||||
int shardCount, FunctionCallInfoData *compareFunction, bool includeMax)
|
||||
int shardCount, FunctionCallInfo compareFunction, bool includeMax)
|
||||
{
|
||||
int lowerBoundIndex = 0;
|
||||
int upperBoundIndex = shardCount;
|
||||
|
@ -1176,8 +1193,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
Assert(shardCount != 0);
|
||||
|
||||
/* setup partitionColumnValue argument once */
|
||||
compareFunction->arg[0] = partitionColumnValue;
|
||||
compareFunction->argnull[0] = false;
|
||||
fcSetArg(compareFunction, 0, partitionColumnValue);
|
||||
|
||||
while (lowerBoundIndex < upperBoundIndex)
|
||||
{
|
||||
|
@ -1186,8 +1202,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
int minValueComparison = 0;
|
||||
|
||||
/* setup minValue as argument */
|
||||
compareFunction->arg[1] = shardIntervalCache[middleIndex]->minValue;
|
||||
compareFunction->argnull[1] = false;
|
||||
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->minValue);
|
||||
|
||||
/* execute cmp(partitionValue, lowerBound) */
|
||||
minValueComparison = PerformCompare(compareFunction);
|
||||
|
@ -1201,8 +1216,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
}
|
||||
|
||||
/* setup maxValue as argument */
|
||||
compareFunction->arg[1] = shardIntervalCache[middleIndex]->maxValue;
|
||||
compareFunction->argnull[1] = false;
|
||||
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->maxValue);
|
||||
|
||||
/* execute cmp(partitionValue, upperBound) */
|
||||
maxValueComparison = PerformCompare(compareFunction);
|
||||
|
@ -1249,7 +1263,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
*/
|
||||
static int
|
||||
UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCache,
|
||||
int shardCount, FunctionCallInfoData *compareFunction, bool includeMin)
|
||||
int shardCount, FunctionCallInfo compareFunction, bool includeMin)
|
||||
{
|
||||
int lowerBoundIndex = 0;
|
||||
int upperBoundIndex = shardCount;
|
||||
|
@ -1257,8 +1271,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
Assert(shardCount != 0);
|
||||
|
||||
/* setup partitionColumnValue argument once */
|
||||
compareFunction->arg[0] = partitionColumnValue;
|
||||
compareFunction->argnull[0] = false;
|
||||
fcSetArg(compareFunction, 0, partitionColumnValue);
|
||||
|
||||
while (lowerBoundIndex < upperBoundIndex)
|
||||
{
|
||||
|
@ -1267,8 +1280,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
int minValueComparison = 0;
|
||||
|
||||
/* setup minValue as argument */
|
||||
compareFunction->arg[1] = shardIntervalCache[middleIndex]->minValue;
|
||||
compareFunction->argnull[1] = false;
|
||||
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->minValue);
|
||||
|
||||
/* execute cmp(partitionValue, lowerBound) */
|
||||
minValueComparison = PerformCompare(compareFunction);
|
||||
|
@ -1283,8 +1295,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
|
|||
}
|
||||
|
||||
/* setup maxValue as argument */
|
||||
compareFunction->arg[1] = shardIntervalCache[middleIndex]->maxValue;
|
||||
compareFunction->argnull[1] = false;
|
||||
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->maxValue);
|
||||
|
||||
/* execute cmp(partitionValue, upperBound) */
|
||||
maxValueComparison = PerformCompare(compareFunction);
|
||||
|
@ -1345,7 +1356,8 @@ PruneWithBoundaries(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *contex
|
|||
int lowerBoundIdx = -1;
|
||||
int upperBoundIdx = -1;
|
||||
int curIdx = 0;
|
||||
FunctionCallInfo compareFunctionCall = &context->compareIntervalFunctionCall;
|
||||
FunctionCallInfo compareFunctionCall = (FunctionCallInfo) &
|
||||
context->compareIntervalFunctionCall;
|
||||
|
||||
if (prune->greaterEqualConsts)
|
||||
{
|
||||
|
@ -1476,7 +1488,8 @@ ExhaustivePruneOne(ShardInterval *curInterval,
|
|||
ClauseWalkerContext *context,
|
||||
PruningInstance *prune)
|
||||
{
|
||||
FunctionCallInfo compareFunctionCall = &context->compareIntervalFunctionCall;
|
||||
FunctionCallInfo compareFunctionCall = (FunctionCallInfo) &
|
||||
context->compareIntervalFunctionCall;
|
||||
Datum compareWith = 0;
|
||||
|
||||
/* NULL boundaries can't be compared to */
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "distributed/function_utils.h"
|
||||
#include "distributed/multi_progress.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "storage/dsm.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
|
@ -155,7 +156,7 @@ ProgressMonitorList(uint64 commandTypeMagicNumber, List **attachedDSMSegments)
|
|||
getProgressInfoFunctionOid,
|
||||
commandTypeDatum);
|
||||
|
||||
tupleTableSlot = MakeSingleTupleTableSlot(progressResultSet->setDesc);
|
||||
tupleTableSlot = MakeSingleTupleTableSlotCompat(progressResultSet->setDesc);
|
||||
|
||||
/* iterate over tuples in tuple store, and send them to destination */
|
||||
for (;;)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "postgres.h"
|
||||
#include "c.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -755,8 +756,10 @@ AppendShardIdToName(char **name, uint64 shardId)
|
|||
neededBytes = snprintf((*name), NAMEDATALEN, "%s", extendedName);
|
||||
if (neededBytes < 0)
|
||||
{
|
||||
char *strerrno = strerror(errno);
|
||||
|
||||
ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory: %s", strerror(errno))));
|
||||
errmsg("out of memory: %s", strerrno)));
|
||||
}
|
||||
else if (neededBytes >= NAMEDATALEN)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "nodes/nodes.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/planmain.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/heapam.h"
|
||||
#include "access/htup_details.h"
|
||||
#include "access/relscan.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "distributed/master_metadata_utility.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
#include "utils/datum.h"
|
||||
|
||||
|
||||
|
|
|
@ -45,9 +45,15 @@ CitusSetTag(Node *node, int tag)
|
|||
nodeTypeName *local_node = (nodeTypeName *) CitusSetTag((Node *) node, T_##nodeTypeName)
|
||||
|
||||
/* And a few guys need only the pg_strtok support fields */
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#define READ_TEMP_LOCALS() \
|
||||
const char *token; \
|
||||
int length
|
||||
#else
|
||||
#define READ_TEMP_LOCALS() \
|
||||
char *token; \
|
||||
int length
|
||||
#endif
|
||||
|
||||
/* ... but most need both */
|
||||
#define READ_LOCALS(nodeTypeName) \
|
||||
|
|
|
@ -128,7 +128,11 @@ get_extension_schema(Oid ext_oid)
|
|||
rel = heap_open(ExtensionRelationId, AccessShareLock);
|
||||
|
||||
ScanKeyInit(&entry[0],
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
Anum_pg_extension_oid,
|
||||
#else
|
||||
ObjectIdAttributeNumber,
|
||||
#endif
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(ext_oid));
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/htup_details.h"
|
||||
#include "access/stratnum.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
|
||||
#include "catalog/namespace.h"
|
||||
#include "distributed/function_utils.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "executor/executor.h"
|
||||
#include "utils/builtins.h"
|
||||
#if (PG_VERSION_NUM >= 100000)
|
||||
#include "utils/regproc.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FunctionOid searches for a function that has the given name and the given
|
||||
|
@ -83,7 +82,7 @@ FunctionOidExtended(const char *schemaName, const char *functionName, int argume
|
|||
ReturnSetInfo *
|
||||
FunctionCallGetTupleStore1(PGFunction function, Oid functionId, Datum argument)
|
||||
{
|
||||
FunctionCallInfoData fcinfo;
|
||||
LOCAL_FCINFO(fcinfo, 1);
|
||||
FmgrInfo flinfo;
|
||||
ReturnSetInfo *rsinfo = makeNode(ReturnSetInfo);
|
||||
EState *estate = CreateExecutorState();
|
||||
|
@ -91,12 +90,11 @@ FunctionCallGetTupleStore1(PGFunction function, Oid functionId, Datum argument)
|
|||
rsinfo->allowedModes = SFRM_Materialize;
|
||||
|
||||
fmgr_info(functionId, &flinfo);
|
||||
InitFunctionCallInfoData(fcinfo, &flinfo, 1, InvalidOid, NULL, (Node *) rsinfo);
|
||||
InitFunctionCallInfoData(*fcinfo, &flinfo, 1, InvalidOid, NULL, (Node *) rsinfo);
|
||||
|
||||
fcinfo.arg[0] = argument;
|
||||
fcinfo.argnull[0] = false;
|
||||
fcSetArg(fcinfo, 0, argument);
|
||||
|
||||
(*function)(&fcinfo);
|
||||
(*function)(fcinfo);
|
||||
|
||||
return rsinfo;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "access/sysattr.h"
|
||||
#include "catalog/indexing.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_enum.h"
|
||||
#include "catalog/pg_extension.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_type.h"
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include "distributed/pg_dist_placement.h"
|
||||
#include "distributed/shared_library_init.h"
|
||||
#include "distributed/shardinterval_utils.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_manager.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "executor/executor.h"
|
||||
|
@ -1616,9 +1618,8 @@ AvailableExtensionVersion(void)
|
|||
{
|
||||
ReturnSetInfo *extensionsResultSet = NULL;
|
||||
TupleTableSlot *tupleTableSlot = NULL;
|
||||
FunctionCallInfoData *fcinfo = NULL;
|
||||
FmgrInfo *flinfo = NULL;
|
||||
int argumentCount = 0;
|
||||
LOCAL_FCINFO(fcinfo, 0);
|
||||
FmgrInfo flinfo;
|
||||
EState *estate = NULL;
|
||||
|
||||
bool hasTuple = false;
|
||||
|
@ -1633,17 +1634,14 @@ AvailableExtensionVersion(void)
|
|||
extensionsResultSet->econtext = GetPerTupleExprContext(estate);
|
||||
extensionsResultSet->allowedModes = SFRM_Materialize;
|
||||
|
||||
fcinfo = palloc0(sizeof(FunctionCallInfoData));
|
||||
flinfo = palloc0(sizeof(FmgrInfo));
|
||||
|
||||
fmgr_info(F_PG_AVAILABLE_EXTENSIONS, flinfo);
|
||||
InitFunctionCallInfoData(*fcinfo, flinfo, argumentCount, InvalidOid, NULL,
|
||||
fmgr_info(F_PG_AVAILABLE_EXTENSIONS, &flinfo);
|
||||
InitFunctionCallInfoData(*fcinfo, &flinfo, 0, InvalidOid, NULL,
|
||||
(Node *) extensionsResultSet);
|
||||
|
||||
/* pg_available_extensions returns result set containing all available extensions */
|
||||
(*pg_available_extensions)(fcinfo);
|
||||
|
||||
tupleTableSlot = MakeSingleTupleTableSlot(extensionsResultSet->setDesc);
|
||||
tupleTableSlot = MakeSingleTupleTableSlotCompat(extensionsResultSet->setDesc);
|
||||
hasTuple = tuplestore_gettupleslot(extensionsResultSet->setResult, goForward, doCopy,
|
||||
tupleTableSlot);
|
||||
while (hasTuple)
|
||||
|
@ -1984,7 +1982,8 @@ CitusCopyFormatTypeId(void)
|
|||
if (MetadataCache.copyFormatTypeId == InvalidOid)
|
||||
{
|
||||
char *typeName = "citus_copy_format";
|
||||
MetadataCache.copyFormatTypeId = GetSysCacheOid2(TYPENAMENSP,
|
||||
MetadataCache.copyFormatTypeId = GetSysCacheOid2Compat(TYPENAMENSP,
|
||||
Anum_pg_enum_oid,
|
||||
PointerGetDatum(typeName),
|
||||
PG_CATALOG_NAMESPACE);
|
||||
}
|
||||
|
@ -2248,7 +2247,11 @@ LookupNodeRoleTypeOid()
|
|||
return InvalidOid;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
nodeRoleTypId = ((Form_pg_type) GETSTRUCT(tup))->oid;
|
||||
#else
|
||||
nodeRoleTypId = HeapTupleGetOid(tup);
|
||||
#endif
|
||||
ReleaseSysCache(tup);
|
||||
|
||||
return nodeRoleTypId;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#include "distributed/shardinterval_utils.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "partitioning/partdesc.h"
|
||||
#endif
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#if (PG_VERSION_NUM >= 110000)
|
||||
#if (PG_VERSION_NUM >= 110000) && (PG_VERSION_NUM < 120000)
|
||||
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
@ -7909,4 +7909,4 @@ get_range_partbound_string(List *bound_datums)
|
|||
return buf->data;
|
||||
}
|
||||
|
||||
#endif /* (PG_VERSION_NUM >= 110000) */
|
||||
#endif /* (PG_VERSION_NUM >= 110000) && (PG_VERSION_NUM < 120000) */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,6 @@
|
|||
#include "citus_version.h"
|
||||
#include "fmgr.h"
|
||||
#include "utils/uuid.h"
|
||||
#include "utils/backend_random.h"
|
||||
|
||||
bool EnableStatisticsCollection = true; /* send basic usage statistics to Citus */
|
||||
|
||||
|
@ -600,11 +599,11 @@ citus_server_id(PG_FUNCTION_ARGS)
|
|||
uint8 *buf = (uint8 *) palloc(UUID_LEN);
|
||||
|
||||
/*
|
||||
* If pg_backend_random() fails, fall-back to using random(). In previous
|
||||
* versions of postgres we don't have pg_backend_random(), so use it by
|
||||
* If pg_strong_random() fails, fall-back to using random(). In previous
|
||||
* versions of postgres we don't have pg_strong_random(), so use it by
|
||||
* default in that case.
|
||||
*/
|
||||
if (!pg_backend_random((char *) buf, UUID_LEN))
|
||||
if (!pg_strong_random((char *) buf, UUID_LEN))
|
||||
{
|
||||
int bufIdx = 0;
|
||||
for (bufIdx = 0; bufIdx < UUID_LEN; bufIdx++)
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#include "funcapi.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/genam.h"
|
||||
#endif
|
||||
#include "access/htup_details.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/dependency.h"
|
||||
|
@ -35,7 +38,6 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/snapmgr.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/* Local functions forward declarations */
|
||||
|
@ -362,7 +364,8 @@ RemoveJobSchema(StringInfo schemaName)
|
|||
Datum schemaNameDatum = CStringGetDatum(schemaName->data);
|
||||
Oid schemaId = InvalidOid;
|
||||
|
||||
schemaId = GetSysCacheOid(NAMESPACENAME, schemaNameDatum, 0, 0, 0);
|
||||
schemaId = GetSysCacheOid1Compat(NAMESPACENAME, Anum_pg_namespace_oid,
|
||||
schemaNameDatum);
|
||||
if (OidIsValid(schemaId))
|
||||
{
|
||||
ObjectAddress schemaObject = { 0, 0, 0 };
|
||||
|
|
|
@ -65,8 +65,8 @@ static uint32 FileBufferSize(int partitionBufferSizeInKB, uint32 fileCount);
|
|||
static FileOutputStream * OpenPartitionFiles(StringInfo directoryName, uint32 fileCount);
|
||||
static void ClosePartitionFiles(FileOutputStream *partitionFileArray, uint32 fileCount);
|
||||
static void RenameDirectory(StringInfo oldDirectoryName, StringInfo newDirectoryName);
|
||||
static void FileOutputStreamWrite(FileOutputStream file, StringInfo dataToWrite);
|
||||
static void FileOutputStreamFlush(FileOutputStream file);
|
||||
static void FileOutputStreamWrite(FileOutputStream *file, StringInfo dataToWrite);
|
||||
static void FileOutputStreamFlush(FileOutputStream *file);
|
||||
static void FilterAndPartitionTable(const char *filterQuery,
|
||||
const char *columnName, Oid columnType,
|
||||
uint32 (*PartitionIdFunction)(Datum, const void *),
|
||||
|
@ -500,13 +500,13 @@ ClosePartitionFiles(FileOutputStream *partitionFileArray, uint32 fileCount)
|
|||
uint32 fileIndex = 0;
|
||||
for (fileIndex = 0; fileIndex < fileCount; fileIndex++)
|
||||
{
|
||||
FileOutputStream partitionFile = partitionFileArray[fileIndex];
|
||||
FileOutputStream *partitionFile = &partitionFileArray[fileIndex];
|
||||
|
||||
FileOutputStreamFlush(partitionFile);
|
||||
|
||||
FileClose(partitionFile.fileDescriptor);
|
||||
FreeStringInfo(partitionFile.fileBuffer);
|
||||
FreeStringInfo(partitionFile.filePath);
|
||||
FileClose(partitionFile->fileDescriptor);
|
||||
FreeStringInfo(partitionFile->fileBuffer);
|
||||
FreeStringInfo(partitionFile->filePath);
|
||||
}
|
||||
|
||||
pfree(partitionFileArray);
|
||||
|
@ -829,9 +829,9 @@ RenameDirectory(StringInfo oldDirectoryName, StringInfo newDirectoryName)
|
|||
* if so, the function flushes the buffer to the underlying file.
|
||||
*/
|
||||
static void
|
||||
FileOutputStreamWrite(FileOutputStream file, StringInfo dataToWrite)
|
||||
FileOutputStreamWrite(FileOutputStream *file, StringInfo dataToWrite)
|
||||
{
|
||||
StringInfo fileBuffer = file.fileBuffer;
|
||||
StringInfo fileBuffer = file->fileBuffer;
|
||||
uint32 newBufferSize = fileBuffer->len + dataToWrite->len;
|
||||
|
||||
appendBinaryStringInfo(fileBuffer, dataToWrite->data, dataToWrite->len);
|
||||
|
@ -847,20 +847,23 @@ FileOutputStreamWrite(FileOutputStream file, StringInfo dataToWrite)
|
|||
|
||||
/* Flushes data buffered in the file stream object to the underlying file. */
|
||||
static void
|
||||
FileOutputStreamFlush(FileOutputStream file)
|
||||
FileOutputStreamFlush(FileOutputStream *file)
|
||||
{
|
||||
StringInfo fileBuffer = file.fileBuffer;
|
||||
StringInfo fileBuffer = file->fileBuffer;
|
||||
int written = 0;
|
||||
|
||||
errno = 0;
|
||||
written = FileWrite(file.fileDescriptor, fileBuffer->data, fileBuffer->len,
|
||||
written = FileWriteCompat(file->fileDescriptor, fileBuffer->data, fileBuffer->len,
|
||||
file->offset,
|
||||
PG_WAIT_IO);
|
||||
if (written != fileBuffer->len)
|
||||
{
|
||||
ereport(ERROR, (errcode_for_file_access(),
|
||||
errmsg("could not write %d bytes to partition file \"%s\"",
|
||||
fileBuffer->len, file.filePath->data)));
|
||||
fileBuffer->len, file->filePath->data)));
|
||||
}
|
||||
|
||||
file->offset += written;
|
||||
}
|
||||
|
||||
|
||||
|
@ -946,7 +949,7 @@ FilterAndPartitionTable(const char *filterQuery,
|
|||
{
|
||||
HeapTuple row = SPI_tuptable->vals[rowIndex];
|
||||
TupleDesc rowDescriptor = SPI_tuptable->tupdesc;
|
||||
FileOutputStream partitionFile = { 0, 0, 0 };
|
||||
FileOutputStream *partitionFile = NULL;
|
||||
StringInfo rowText = NULL;
|
||||
Datum partitionKey = 0;
|
||||
bool partitionKeyNull = false;
|
||||
|
@ -978,7 +981,7 @@ FilterAndPartitionTable(const char *filterQuery,
|
|||
|
||||
rowText = rowOutputState->fe_msgbuf;
|
||||
|
||||
partitionFile = partitionFileArray[partitionId];
|
||||
partitionFile = &partitionFileArray[partitionId];
|
||||
FileOutputStreamWrite(partitionFile, rowText);
|
||||
|
||||
resetStringInfo(rowText);
|
||||
|
@ -1136,7 +1139,7 @@ OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount)
|
|||
AppendCopyBinaryHeaders(headerOutputState);
|
||||
|
||||
partitionFile = partitionFileArray[fileIndex];
|
||||
FileOutputStreamWrite(partitionFile, headerOutputState->fe_msgbuf);
|
||||
FileOutputStreamWrite(&partitionFile, headerOutputState->fe_msgbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1165,7 @@ OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount)
|
|||
AppendCopyBinaryFooters(footerOutputState);
|
||||
|
||||
partitionFile = partitionFileArray[fileIndex];
|
||||
FileOutputStreamWrite(partitionFile, footerOutputState->fe_msgbuf);
|
||||
FileOutputStreamWrite(&partitionFile, footerOutputState->fe_msgbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "distributed/commands/multi_copy.h"
|
||||
#include "distributed/multi_executor.h"
|
||||
#include "distributed/transmit.h"
|
||||
#include "distributed/version_compat.h"
|
||||
#include "distributed/worker_protocol.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/memutils.h"
|
||||
|
@ -251,7 +252,8 @@ TaskFileDestReceiverReceive(TupleTableSlot *slot, DestReceiver *dest)
|
|||
static void
|
||||
WriteToLocalFile(StringInfo copyData, File fileDesc)
|
||||
{
|
||||
int bytesWritten = FileWrite(fileDesc, copyData->data, copyData->len, PG_WAIT_IO);
|
||||
int bytesWritten = FileWriteCompat(fileDesc, copyData->data, copyData->len, 0,
|
||||
PG_WAIT_IO);
|
||||
if (bytesWritten < 0)
|
||||
{
|
||||
ereport(ERROR, (errcode_for_file_access(),
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#if PG_VERSION_NUM >= 120000
|
||||
#include "nodes/pathnodes.h"
|
||||
#else
|
||||
#include "nodes/relation.h"
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
#if PG_VERSION_NUM >= 120000
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/predtest.h"
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
#if PG_VERSION_NUM >= 120000
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/var.h"
|
||||
#endif
|
|
@ -11,7 +11,7 @@
|
|||
#define DISTRIBUTED_PLANNER_H
|
||||
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
|
||||
#include "distributed/citus_nodes.h"
|
||||
#include "distributed/errormessage.h"
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "utils/hsearch.h"
|
||||
|
||||
#if PG_VERSION_NUM < 120000
|
||||
|
||||
/*
|
||||
* Combine two hash values, resulting in another hash value, with decent bit
|
||||
* mixing.
|
||||
|
@ -25,6 +27,9 @@ hash_combine(uint32 a, uint32 b)
|
|||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
extern void hash_delete_all(HTAB *htab);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "distributed/relation_restriction_equivalence.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "compat/nodes/relation.h"
|
||||
|
||||
|
||||
extern List * GenerateSubplansForSubqueriesAndCTEs(uint64 planId, Query *originalQuery,
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#include "catalog/namespace.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
|
||||
#if (PG_VERSION_NUM >= 120000)
|
||||
#include "optimizer/optimizer.h"
|
||||
#endif
|
||||
|
||||
#if (PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 110000)
|
||||
|
||||
#include "access/hash.h"
|
||||
|
@ -240,5 +244,67 @@ RangeVarGetRelidInternal(const RangeVar *relation, LOCKMODE lockmode, uint32 fla
|
|||
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|
||||
#define NextCopyLastParam
|
||||
#define MakeSingleTupleTableSlotCompat(tupleDesc) \
|
||||
MakeSingleTupleTableSlot(tupleDesc, &TTSOpsHeapTuple)
|
||||
#define AllocSetContextCreateExtended AllocSetContextCreateInternal
|
||||
#define ExecStoreTuple(tuple, slot, buffer, shouldFree) \
|
||||
ExecStoreHeapTuple(tuple, slot, shouldFree)
|
||||
#define NextCopyFromCompat NextCopyFrom
|
||||
#define QTW_EXAMINE_RTES QTW_EXAMINE_RTES_BEFORE
|
||||
#define ArrayRef SubscriptingRef
|
||||
#define T_ArrayRef T_SubscriptingRef
|
||||
#define or_clause is_orclause
|
||||
#define GetSysCacheOid1Compat GetSysCacheOid1
|
||||
#define GetSysCacheOid2Compat GetSysCacheOid2
|
||||
#define GetSysCacheOid3Compat GetSysCacheOid3
|
||||
#define GetSysCacheOid4Compat GetSysCacheOid4
|
||||
#define make_aggCompat make_agg
|
||||
#define FileReadCompat FileRead
|
||||
#define FileWriteCompat FileWrite
|
||||
|
||||
#define fcSetArg(fc, n, argval) \
|
||||
((fc)->args[n].isnull = false, (fc)->args[n].value = (argval))
|
||||
#define fcSetArgNull(fc, n) \
|
||||
((fc)->args[n].isnull = true, (fc)->args[n].value = (Datum) 0)
|
||||
#define InitFunctionCallInfoDataCompat InitFunctionCallInfoData
|
||||
|
||||
#else /* pre PG12 */
|
||||
#define MakeSingleTupleTableSlotCompat MakeSingleTupleTableSlot
|
||||
#define NextCopyFromCompat(cstate, econtext, values, nulls) \
|
||||
NextCopyFrom(cstate, econtext, values, nulls, NULL)
|
||||
#define GetSysCacheOid1Compat(cacheId, oidcol, key1) \
|
||||
GetSysCacheOid1(cacheId, key1)
|
||||
#define GetSysCacheOid2Compat(cacheId, oidcol, key1, key2) \
|
||||
GetSysCacheOid2(cacheId, key1, key2)
|
||||
#define GetSysCacheOid3Compat(cacheId, oidcol, key1, key2, key3) \
|
||||
GetSysCacheOid3(cacheId, key1, key2, key3)
|
||||
#define GetSysCacheOid4Compat(cacheId, oidcol, key1, key2, key3, key4) \
|
||||
GetSysCacheOid4(cacheId, key1, key2, key3, key4)
|
||||
#define LOCAL_FCINFO(name, nargs) \
|
||||
FunctionCallInfoData name ## data; \
|
||||
FunctionCallInfoData *name = &name ## data
|
||||
#define make_aggCompat(tlist, qual, aggstrategy, aggsplit, numGroupCols, grpColIdx, \
|
||||
grpOperators, grpCollations, groupingSets, chain, dNumGrous, \
|
||||
lefttree) \
|
||||
make_agg(tlist, qual, aggstrategy, aggsplit, numGroupCols, grpColIdx, grpOperators, \
|
||||
groupingSets, chain, dNumGrous, lefttree)
|
||||
|
||||
|
||||
#define fcSetArg(fc, n, value) \
|
||||
(((fc)->argnull[n] = false), ((fc)->arg[n] = (value)))
|
||||
#define fcSetArgNull(fc, n) \
|
||||
(((fc)->argnull[n] = true), ((fc)->arg[n] = (Datum) 0))
|
||||
#define InitFunctionCallInfoDataCompat(fc, fn, nargs, collation, ctx, result) \
|
||||
InitFunctionCallInfoData(fc, fn, nargs, collation, ctx, result)
|
||||
|
||||
#define FileReadCompat(file, buffer, amount, offset, wait_event_info) \
|
||||
FileRead(file, buffer, amount, wait_event_info)
|
||||
#define FileWriteCompat(file, buffer, amount, offset, wait_event_info) \
|
||||
FileWrite(file, buffer, amount, wait_event_info)
|
||||
|
||||
#endif /* PG12 */
|
||||
|
||||
#endif /* VERSION_COMPAT_H */
|
||||
|
|
|
@ -92,6 +92,7 @@ typedef struct HashPartitionContext
|
|||
typedef struct FileOutputStream
|
||||
{
|
||||
File fileDescriptor;
|
||||
off_t offset;
|
||||
StringInfo fileBuffer;
|
||||
StringInfo filePath;
|
||||
} FileOutputStream;
|
||||
|
|
Loading…
Reference in New Issue