mirror of https://github.com/citusdata/citus.git
Enable variable shadowing warnings; fix all
Rather than wait for another place like the previous commit to bite us, I think we should turn on this warning.pull/2669/head
parent
1125fc9da0
commit
71d5d1c865
|
@ -4008,6 +4008,41 @@ if test x"$citusac_cv_prog_cc_cflags__Wmissing_prototypes" = x"yes"; then
|
||||||
CITUS_CFLAGS="$CITUS_CFLAGS -Wmissing-prototypes"
|
CITUS_CFLAGS="$CITUS_CFLAGS -Wmissing-prototypes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshadow" >&5
|
||||||
|
$as_echo_n "checking whether $CC supports -Wshadow... " >&6; }
|
||||||
|
if ${citusac_cv_prog_cc_cflags__Wshadow+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
citusac_save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$citusac_save_CFLAGS -Wshadow"
|
||||||
|
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||||
|
ac_c_werror_flag=yes
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
citusac_cv_prog_cc_cflags__Wshadow=yes
|
||||||
|
else
|
||||||
|
citusac_cv_prog_cc_cflags__Wshadow=no
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||||
|
CFLAGS="$citusac_save_CFLAGS"
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $citusac_cv_prog_cc_cflags__Wshadow" >&5
|
||||||
|
$as_echo "$citusac_cv_prog_cc_cflags__Wshadow" >&6; }
|
||||||
|
if test x"$citusac_cv_prog_cc_cflags__Wshadow" = x"yes"; then
|
||||||
|
CITUS_CFLAGS="$CITUS_CFLAGS -Wshadow"
|
||||||
|
fi
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Werror=vla" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Werror=vla" >&5
|
||||||
$as_echo_n "checking whether $CC supports -Werror=vla... " >&6; }
|
$as_echo_n "checking whether $CC supports -Werror=vla... " >&6; }
|
||||||
if ${citusac_cv_prog_cc_cflags__Werror_vla+:} false; then :
|
if ${citusac_cv_prog_cc_cflags__Werror_vla+:} false; then :
|
||||||
|
|
|
@ -163,6 +163,7 @@ CITUSAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
|
||||||
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
|
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
|
||||||
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-declarations])
|
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-declarations])
|
||||||
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-prototypes])
|
CITUSAC_PROG_CC_CFLAGS_OPT([-Wmissing-prototypes])
|
||||||
|
CITUSAC_PROG_CC_CFLAGS_OPT([-Wshadow])
|
||||||
CITUSAC_PROG_CC_CFLAGS_OPT([-Werror=vla]) # visual studio does not support these
|
CITUSAC_PROG_CC_CFLAGS_OPT([-Werror=vla]) # visual studio does not support these
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -696,7 +696,6 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
/* partitions cannot be distributed if their parent is not distributed */
|
/* partitions cannot be distributed if their parent is not distributed */
|
||||||
if (PartitionTable(relationId) && !IsDistributedTable(parentRelationId))
|
if (PartitionTable(relationId) && !IsDistributedTable(parentRelationId))
|
||||||
{
|
{
|
||||||
char *relationName = get_rel_name(relationId);
|
|
||||||
char *parentRelationName = get_rel_name(parentRelationId);
|
char *parentRelationName = get_rel_name(parentRelationId);
|
||||||
|
|
||||||
ereport(ERROR, (errmsg("cannot distribute relation \"%s\" which is partition of "
|
ereport(ERROR, (errmsg("cannot distribute relation \"%s\" which is partition of "
|
||||||
|
@ -734,8 +733,6 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
/* we don't support distributing tables with multi-level partitioning */
|
/* we don't support distributing tables with multi-level partitioning */
|
||||||
if (PartitionTable(relationId))
|
if (PartitionTable(relationId))
|
||||||
{
|
{
|
||||||
char *relationName = get_rel_name(relationId);
|
|
||||||
Oid parentRelationId = PartitionParentOid(relationId);
|
|
||||||
char *parentRelationName = get_rel_name(parentRelationId);
|
char *parentRelationName = get_rel_name(parentRelationId);
|
||||||
|
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
|
|
@ -667,13 +667,13 @@ FindPlacementListConnection(int flags, List *placementAccessList, const char *us
|
||||||
static ConnectionPlacementHashEntry *
|
static ConnectionPlacementHashEntry *
|
||||||
FindOrCreatePlacementEntry(ShardPlacement *placement)
|
FindOrCreatePlacementEntry(ShardPlacement *placement)
|
||||||
{
|
{
|
||||||
ConnectionPlacementHashKey key;
|
ConnectionPlacementHashKey connKey;
|
||||||
ConnectionPlacementHashEntry *placementEntry = NULL;
|
ConnectionPlacementHashEntry *placementEntry = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
key.placementId = placement->placementId;
|
connKey.placementId = placement->placementId;
|
||||||
|
|
||||||
placementEntry = hash_search(ConnectionPlacementHash, &key, HASH_ENTER, &found);
|
placementEntry = hash_search(ConnectionPlacementHash, &connKey, HASH_ENTER, &found);
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
/* no connection has been chosen for this placement */
|
/* no connection has been chosen for this placement */
|
||||||
|
@ -685,15 +685,15 @@ FindOrCreatePlacementEntry(ShardPlacement *placement)
|
||||||
if (placement->partitionMethod == DISTRIBUTE_BY_HASH ||
|
if (placement->partitionMethod == DISTRIBUTE_BY_HASH ||
|
||||||
placement->partitionMethod == DISTRIBUTE_BY_NONE)
|
placement->partitionMethod == DISTRIBUTE_BY_NONE)
|
||||||
{
|
{
|
||||||
ColocatedPlacementsHashKey key;
|
ColocatedPlacementsHashKey coloKey;
|
||||||
ColocatedPlacementsHashEntry *colocatedEntry = NULL;
|
ColocatedPlacementsHashEntry *colocatedEntry = NULL;
|
||||||
|
|
||||||
key.nodeId = placement->nodeId;
|
coloKey.nodeId = placement->nodeId;
|
||||||
key.colocationGroupId = placement->colocationGroupId;
|
coloKey.colocationGroupId = placement->colocationGroupId;
|
||||||
key.representativeValue = placement->representativeValue;
|
coloKey.representativeValue = placement->representativeValue;
|
||||||
|
|
||||||
/* look for a connection assigned to co-located placements */
|
/* look for a connection assigned to co-located placements */
|
||||||
colocatedEntry = hash_search(ColocatedPlacementsHash, &key, HASH_ENTER,
|
colocatedEntry = hash_search(ColocatedPlacementsHash, &coloKey, HASH_ENTER,
|
||||||
&found);
|
&found);
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
@ -857,10 +857,10 @@ AssociatePlacementWithShard(ConnectionPlacementHashEntry *placementEntry,
|
||||||
*/
|
*/
|
||||||
dlist_foreach(placementIter, &shardEntry->placementConnections)
|
dlist_foreach(placementIter, &shardEntry->placementConnections)
|
||||||
{
|
{
|
||||||
ConnectionPlacementHashEntry *placementEntry =
|
ConnectionPlacementHashEntry *currPlacementEntry =
|
||||||
dlist_container(ConnectionPlacementHashEntry, shardNode, placementIter.cur);
|
dlist_container(ConnectionPlacementHashEntry, shardNode, placementIter.cur);
|
||||||
|
|
||||||
if (placementEntry->key.placementId == placement->placementId)
|
if (currPlacementEntry->key.placementId == placement->placementId)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,8 @@ MultiRealTimeExecute(Job *job)
|
||||||
uint32 completedTaskCount = 0;
|
uint32 completedTaskCount = 0;
|
||||||
|
|
||||||
/* loop around all tasks and manage them */
|
/* loop around all tasks and manage them */
|
||||||
ListCell *taskCell = NULL;
|
taskCell = NULL;
|
||||||
ListCell *taskExecutionCell = NULL;
|
taskExecutionCell = NULL;
|
||||||
|
|
||||||
MultiClientResetWaitInfo(waitInfo);
|
MultiClientResetWaitInfo(waitInfo);
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,6 @@ MultiTaskTrackerExecute(Job *job)
|
||||||
double acceptableHealthyTrackerCount = 0.0;
|
double acceptableHealthyTrackerCount = 0.0;
|
||||||
|
|
||||||
/* first, loop around all tasks and manage them */
|
/* first, loop around all tasks and manage them */
|
||||||
ListCell *taskAndExecutionCell = NULL;
|
|
||||||
foreach(taskAndExecutionCell, taskAndExecutionList)
|
foreach(taskAndExecutionCell, taskAndExecutionList)
|
||||||
{
|
{
|
||||||
Task *task = (Task *) lfirst(taskAndExecutionCell);
|
Task *task = (Task *) lfirst(taskAndExecutionCell);
|
||||||
|
@ -259,7 +258,6 @@ MultiTaskTrackerExecute(Job *job)
|
||||||
if (taskExecutionStatus == EXEC_TASK_TRACKER_FAILED)
|
if (taskExecutionStatus == EXEC_TASK_TRACKER_FAILED)
|
||||||
{
|
{
|
||||||
List *taskList = NIL;
|
List *taskList = NIL;
|
||||||
TaskTracker *transmitTracker = NULL;
|
|
||||||
|
|
||||||
/* mark task tracker as failed, in case it isn't marked already */
|
/* mark task tracker as failed, in case it isn't marked already */
|
||||||
execTaskTracker->trackerFailureCount = MAX_TRACKER_FAILURE_COUNT;
|
execTaskTracker->trackerFailureCount = MAX_TRACKER_FAILURE_COUNT;
|
||||||
|
@ -343,7 +341,6 @@ MultiTaskTrackerExecute(Job *job)
|
||||||
if (transmitExecutionStatus == EXEC_TRANSMIT_TRACKER_FAILED)
|
if (transmitExecutionStatus == EXEC_TRANSMIT_TRACKER_FAILED)
|
||||||
{
|
{
|
||||||
List *taskList = NIL;
|
List *taskList = NIL;
|
||||||
TaskTracker *taskTracker = NULL;
|
|
||||||
|
|
||||||
taskTracker = ResolveTaskTracker(taskTrackerHash,
|
taskTracker = ResolveTaskTracker(taskTrackerHash,
|
||||||
task, taskExecution);
|
task, taskExecution);
|
||||||
|
@ -2358,7 +2355,7 @@ AssignQueuedTasks(TaskTracker *taskTracker)
|
||||||
|
|
||||||
foreach(taskCell, tasksToAssignList)
|
foreach(taskCell, tasksToAssignList)
|
||||||
{
|
{
|
||||||
TrackerTaskState *taskState = (TrackerTaskState *) lfirst(taskCell);
|
taskState = (TrackerTaskState *) lfirst(taskCell);
|
||||||
BatchQueryStatus queryStatus = CLIENT_INVALID_BATCH_QUERY;
|
BatchQueryStatus queryStatus = CLIENT_INVALID_BATCH_QUERY;
|
||||||
|
|
||||||
if (!batchSuccess)
|
if (!batchSuccess)
|
||||||
|
@ -2663,14 +2660,14 @@ JobIdList(Job *job)
|
||||||
uint64 *jobIdPointer = (uint64 *) palloc0(sizeof(uint64));
|
uint64 *jobIdPointer = (uint64 *) palloc0(sizeof(uint64));
|
||||||
List *jobChildrenList = NIL;
|
List *jobChildrenList = NIL;
|
||||||
|
|
||||||
Job *job = (Job *) linitial(jobQueue);
|
Job *currJob = (Job *) linitial(jobQueue);
|
||||||
jobQueue = list_delete_first(jobQueue);
|
jobQueue = list_delete_first(jobQueue);
|
||||||
|
|
||||||
(*jobIdPointer) = job->jobId;
|
(*jobIdPointer) = currJob->jobId;
|
||||||
jobIdList = lappend(jobIdList, jobIdPointer);
|
jobIdList = lappend(jobIdList, jobIdPointer);
|
||||||
|
|
||||||
/* prevent dependedJobList being modified on list_concat() call */
|
/* prevent dependedJobList being modified on list_concat() call */
|
||||||
jobChildrenList = list_copy(job->dependedJobList);
|
jobChildrenList = list_copy(currJob->dependedJobList);
|
||||||
if (jobChildrenList != NIL)
|
if (jobChildrenList != NIL)
|
||||||
{
|
{
|
||||||
jobQueue = list_concat(jobQueue, jobChildrenList);
|
jobQueue = list_concat(jobQueue, jobChildrenList);
|
||||||
|
@ -2907,7 +2904,7 @@ TrackerHashCleanupJob(HTAB *taskTrackerHash, Task *jobCleanupTask)
|
||||||
|
|
||||||
foreach(activeTaskTrackerCell, activeTackTrackerList)
|
foreach(activeTaskTrackerCell, activeTackTrackerList)
|
||||||
{
|
{
|
||||||
TaskTracker *taskTracker = (TaskTracker *) lfirst(activeTaskTrackerCell);
|
taskTracker = (TaskTracker *) lfirst(activeTaskTrackerCell);
|
||||||
int32 connectionId = taskTracker->connectionId;
|
int32 connectionId = taskTracker->connectionId;
|
||||||
const char *nodeName = taskTracker->workerName;
|
const char *nodeName = taskTracker->workerName;
|
||||||
uint32 nodePort = taskTracker->workerPort;
|
uint32 nodePort = taskTracker->workerPort;
|
||||||
|
|
|
@ -471,7 +471,6 @@ master_get_active_worker_nodes(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
MemoryContext oldContext = NULL;
|
MemoryContext oldContext = NULL;
|
||||||
List *workerNodeList = NIL;
|
List *workerNodeList = NIL;
|
||||||
uint32 workerNodeCount = 0;
|
|
||||||
TupleDesc tupleDescriptor = NULL;
|
TupleDesc tupleDescriptor = NULL;
|
||||||
bool hasOid = false;
|
bool hasOid = false;
|
||||||
|
|
||||||
|
|
|
@ -378,8 +378,6 @@ DistributedInsertSelectSupported(Query *queryTree, RangeTblEntry *insertRte,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DeferredErrorMessage *error = NULL;
|
|
||||||
|
|
||||||
/* ensure that INSERT's partition column comes from SELECT's partition column */
|
/* ensure that INSERT's partition column comes from SELECT's partition column */
|
||||||
error = InsertPartitionColumnMatchesSelect(queryTree, insertRte, subqueryRte,
|
error = InsertPartitionColumnMatchesSelect(queryTree, insertRte, subqueryRte,
|
||||||
&selectPartitionColumnTableId);
|
&selectPartitionColumnTableId);
|
||||||
|
|
|
@ -939,9 +939,8 @@ SinglePartitionJoin(JoinOrderNode *currentJoinNode, TableEntry *candidateTable,
|
||||||
/* evaluate re-partitioning the current table only if the rule didn't apply above */
|
/* evaluate re-partitioning the current table only if the rule didn't apply above */
|
||||||
if (nextJoinNode == NULL && candidatePartitionMethod != DISTRIBUTE_BY_NONE)
|
if (nextJoinNode == NULL && candidatePartitionMethod != DISTRIBUTE_BY_NONE)
|
||||||
{
|
{
|
||||||
OpExpr *joinClause = SinglePartitionJoinClause(candidatePartitionColumn,
|
joinClause = SinglePartitionJoinClause(candidatePartitionColumn,
|
||||||
applicableJoinClauses);
|
applicableJoinClauses);
|
||||||
|
|
||||||
if (joinClause != NULL)
|
if (joinClause != NULL)
|
||||||
{
|
{
|
||||||
if (candidatePartitionMethod == DISTRIBUTE_BY_HASH)
|
if (candidatePartitionMethod == DISTRIBUTE_BY_HASH)
|
||||||
|
|
|
@ -4239,23 +4239,23 @@ HasOrderByHllType(List *sortClauseList, List *targetList)
|
||||||
* of distinct clause.
|
* of distinct clause.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
IsGroupBySubsetOfDistinct(List *groupClause, List *distinctClause)
|
IsGroupBySubsetOfDistinct(List *groupClauses, List *distinctClauses)
|
||||||
{
|
{
|
||||||
ListCell *distinctCell = NULL;
|
ListCell *distinctCell = NULL;
|
||||||
ListCell *groupCell = NULL;
|
ListCell *groupCell = NULL;
|
||||||
|
|
||||||
/* There must be a group clause */
|
/* There must be a group clause */
|
||||||
if (list_length(groupClause) == 0)
|
if (list_length(groupClauses) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(groupCell, groupClause)
|
foreach(groupCell, groupClauses)
|
||||||
{
|
{
|
||||||
SortGroupClause *groupClause = (SortGroupClause *) lfirst(groupCell);
|
SortGroupClause *groupClause = (SortGroupClause *) lfirst(groupCell);
|
||||||
bool isFound = false;
|
bool isFound = false;
|
||||||
|
|
||||||
foreach(distinctCell, distinctClause)
|
foreach(distinctCell, distinctClauses)
|
||||||
{
|
{
|
||||||
SortGroupClause *distinctClause = (SortGroupClause *) lfirst(distinctCell);
|
SortGroupClause *distinctClause = (SortGroupClause *) lfirst(distinctCell);
|
||||||
|
|
||||||
|
|
|
@ -814,8 +814,8 @@ BaseRangeTableList(MultiNode *multiNode)
|
||||||
|
|
||||||
while (pendingNodeList != NIL)
|
while (pendingNodeList != NIL)
|
||||||
{
|
{
|
||||||
MultiNode *multiNode = (MultiNode *) linitial(pendingNodeList);
|
MultiNode *currMultiNode = (MultiNode *) linitial(pendingNodeList);
|
||||||
CitusNodeTag nodeType = CitusNodeTag(multiNode);
|
CitusNodeTag nodeType = CitusNodeTag(currMultiNode);
|
||||||
pendingNodeList = list_delete_first(pendingNodeList);
|
pendingNodeList = list_delete_first(pendingNodeList);
|
||||||
|
|
||||||
if (nodeType == T_MultiTable)
|
if (nodeType == T_MultiTable)
|
||||||
|
@ -824,7 +824,7 @@ BaseRangeTableList(MultiNode *multiNode)
|
||||||
* We represent subqueries as MultiTables, and so for base table
|
* We represent subqueries as MultiTables, and so for base table
|
||||||
* entries we skip the subquery ones.
|
* entries we skip the subquery ones.
|
||||||
*/
|
*/
|
||||||
MultiTable *multiTable = (MultiTable *) multiNode;
|
MultiTable *multiTable = (MultiTable *) currMultiNode;
|
||||||
if (multiTable->relationId != SUBQUERY_RELATION_ID &&
|
if (multiTable->relationId != SUBQUERY_RELATION_ID &&
|
||||||
multiTable->relationId != SUBQUERY_PUSHDOWN_RELATION_ID)
|
multiTable->relationId != SUBQUERY_PUSHDOWN_RELATION_ID)
|
||||||
{
|
{
|
||||||
|
@ -843,7 +843,7 @@ BaseRangeTableList(MultiNode *multiNode)
|
||||||
/* do not visit nodes that belong to remote queries */
|
/* do not visit nodes that belong to remote queries */
|
||||||
if (nodeType != T_MultiCollect)
|
if (nodeType != T_MultiCollect)
|
||||||
{
|
{
|
||||||
List *childNodeList = ChildNodeList(multiNode);
|
List *childNodeList = ChildNodeList(currMultiNode);
|
||||||
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -963,21 +963,21 @@ QueryGroupClauseList(MultiNode *multiNode)
|
||||||
|
|
||||||
while (pendingNodeList != NIL)
|
while (pendingNodeList != NIL)
|
||||||
{
|
{
|
||||||
MultiNode *multiNode = (MultiNode *) linitial(pendingNodeList);
|
MultiNode *currMultiNode = (MultiNode *) linitial(pendingNodeList);
|
||||||
CitusNodeTag nodeType = CitusNodeTag(multiNode);
|
CitusNodeTag nodeType = CitusNodeTag(currMultiNode);
|
||||||
pendingNodeList = list_delete_first(pendingNodeList);
|
pendingNodeList = list_delete_first(pendingNodeList);
|
||||||
|
|
||||||
/* extract the group clause list from the extended operator */
|
/* extract the group clause list from the extended operator */
|
||||||
if (nodeType == T_MultiExtendedOp)
|
if (nodeType == T_MultiExtendedOp)
|
||||||
{
|
{
|
||||||
MultiExtendedOp *extendedOpNode = (MultiExtendedOp *) multiNode;
|
MultiExtendedOp *extendedOpNode = (MultiExtendedOp *) currMultiNode;
|
||||||
groupClauseList = extendedOpNode->groupClauseList;
|
groupClauseList = extendedOpNode->groupClauseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add children only if this node isn't a multi collect and multi table */
|
/* add children only if this node isn't a multi collect and multi table */
|
||||||
if (nodeType != T_MultiCollect && nodeType != T_MultiTable)
|
if (nodeType != T_MultiCollect && nodeType != T_MultiTable)
|
||||||
{
|
{
|
||||||
List *childNodeList = ChildNodeList(multiNode);
|
List *childNodeList = ChildNodeList(currMultiNode);
|
||||||
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1000,14 +1000,14 @@ QuerySelectClauseList(MultiNode *multiNode)
|
||||||
|
|
||||||
while (pendingNodeList != NIL)
|
while (pendingNodeList != NIL)
|
||||||
{
|
{
|
||||||
MultiNode *multiNode = (MultiNode *) linitial(pendingNodeList);
|
MultiNode *currMultiNode = (MultiNode *) linitial(pendingNodeList);
|
||||||
CitusNodeTag nodeType = CitusNodeTag(multiNode);
|
CitusNodeTag nodeType = CitusNodeTag(currMultiNode);
|
||||||
pendingNodeList = list_delete_first(pendingNodeList);
|
pendingNodeList = list_delete_first(pendingNodeList);
|
||||||
|
|
||||||
/* extract select clauses from the multi select node */
|
/* extract select clauses from the multi select node */
|
||||||
if (nodeType == T_MultiSelect)
|
if (nodeType == T_MultiSelect)
|
||||||
{
|
{
|
||||||
MultiSelect *selectNode = (MultiSelect *) multiNode;
|
MultiSelect *selectNode = (MultiSelect *) currMultiNode;
|
||||||
List *clauseList = copyObject(selectNode->selectClauseList);
|
List *clauseList = copyObject(selectNode->selectClauseList);
|
||||||
selectClauseList = list_concat(selectClauseList, clauseList);
|
selectClauseList = list_concat(selectClauseList, clauseList);
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1015,7 @@ QuerySelectClauseList(MultiNode *multiNode)
|
||||||
/* add children only if this node isn't a multi collect */
|
/* add children only if this node isn't a multi collect */
|
||||||
if (nodeType != T_MultiCollect)
|
if (nodeType != T_MultiCollect)
|
||||||
{
|
{
|
||||||
List *childNodeList = ChildNodeList(multiNode);
|
List *childNodeList = ChildNodeList(currMultiNode);
|
||||||
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1038,14 +1038,14 @@ QueryJoinClauseList(MultiNode *multiNode)
|
||||||
|
|
||||||
while (pendingNodeList != NIL)
|
while (pendingNodeList != NIL)
|
||||||
{
|
{
|
||||||
MultiNode *multiNode = (MultiNode *) linitial(pendingNodeList);
|
MultiNode *currMultiNode = (MultiNode *) linitial(pendingNodeList);
|
||||||
CitusNodeTag nodeType = CitusNodeTag(multiNode);
|
CitusNodeTag nodeType = CitusNodeTag(currMultiNode);
|
||||||
pendingNodeList = list_delete_first(pendingNodeList);
|
pendingNodeList = list_delete_first(pendingNodeList);
|
||||||
|
|
||||||
/* extract join clauses from the multi join node */
|
/* extract join clauses from the multi join node */
|
||||||
if (nodeType == T_MultiJoin)
|
if (nodeType == T_MultiJoin)
|
||||||
{
|
{
|
||||||
MultiJoin *joinNode = (MultiJoin *) multiNode;
|
MultiJoin *joinNode = (MultiJoin *) currMultiNode;
|
||||||
List *clauseList = copyObject(joinNode->joinClauseList);
|
List *clauseList = copyObject(joinNode->joinClauseList);
|
||||||
joinClauseList = list_concat(joinClauseList, clauseList);
|
joinClauseList = list_concat(joinClauseList, clauseList);
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1053,7 @@ QueryJoinClauseList(MultiNode *multiNode)
|
||||||
/* add this node's children only if the node isn't a multi collect */
|
/* add this node's children only if the node isn't a multi collect */
|
||||||
if (nodeType != T_MultiCollect)
|
if (nodeType != T_MultiCollect)
|
||||||
{
|
{
|
||||||
List *childNodeList = ChildNodeList(multiNode);
|
List *childNodeList = ChildNodeList(currMultiNode);
|
||||||
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
pendingNodeList = list_concat(pendingNodeList, childNodeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1726,8 +1726,8 @@ static List *
|
||||||
ChildNodeList(MultiNode *multiNode)
|
ChildNodeList(MultiNode *multiNode)
|
||||||
{
|
{
|
||||||
List *childNodeList = NIL;
|
List *childNodeList = NIL;
|
||||||
bool unaryNode = UnaryOperator(multiNode);
|
bool isUnaryNode = UnaryOperator(multiNode);
|
||||||
bool binaryNode = BinaryOperator(multiNode);
|
bool isBinaryNode = BinaryOperator(multiNode);
|
||||||
|
|
||||||
/* relation table nodes don't have any children */
|
/* relation table nodes don't have any children */
|
||||||
if (CitusIsA(multiNode, MultiTable))
|
if (CitusIsA(multiNode, MultiTable))
|
||||||
|
@ -1739,12 +1739,12 @@ ChildNodeList(MultiNode *multiNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unaryNode)
|
if (isUnaryNode)
|
||||||
{
|
{
|
||||||
MultiUnaryNode *unaryNode = (MultiUnaryNode *) multiNode;
|
MultiUnaryNode *unaryNode = (MultiUnaryNode *) multiNode;
|
||||||
childNodeList = list_make1(unaryNode->childNode);
|
childNodeList = list_make1(unaryNode->childNode);
|
||||||
}
|
}
|
||||||
else if (binaryNode)
|
else if (isBinaryNode)
|
||||||
{
|
{
|
||||||
MultiBinaryNode *binaryNode = (MultiBinaryNode *) multiNode;
|
MultiBinaryNode *binaryNode = (MultiBinaryNode *) multiNode;
|
||||||
childNodeList = list_make2(binaryNode->leftChildNode,
|
childNodeList = list_make2(binaryNode->leftChildNode,
|
||||||
|
|
|
@ -2416,10 +2416,10 @@ BuildRoutesForInsert(Query *query, DeferredErrorMessage **planningError)
|
||||||
DISTRIBUTE_BY_RANGE)
|
DISTRIBUTE_BY_RANGE)
|
||||||
{
|
{
|
||||||
Datum partitionValue = partitionValueConst->constvalue;
|
Datum partitionValue = partitionValueConst->constvalue;
|
||||||
DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(
|
ShardInterval *shardInterval = NULL;
|
||||||
distributedTableId);
|
|
||||||
ShardInterval *shardInterval = FindShardInterval(partitionValue, cacheEntry);
|
|
||||||
|
|
||||||
|
cacheEntry = DistributedTableCacheEntry(distributedTableId);
|
||||||
|
shardInterval = FindShardInterval(partitionValue, cacheEntry);
|
||||||
if (shardInterval != NULL)
|
if (shardInterval != NULL)
|
||||||
{
|
{
|
||||||
prunedShardList = list_make1(shardInterval);
|
prunedShardList = list_make1(shardInterval);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
|
|
||||||
static bool allowNonIdleRemoteTransactionOnXactHandling = false;
|
static bool allowNonIdleRemoteTransactionOnXactHandling = false;
|
||||||
static MultiConnection *connection = NULL;
|
static MultiConnection *singleConnection = NULL;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,7 +51,7 @@ int IsolationTestSessionRemoteProcessID = -1;
|
||||||
int IsolationTestSessionProcessID = -1;
|
int IsolationTestSessionProcessID = -1;
|
||||||
|
|
||||||
|
|
||||||
static int64 GetRemoteProcessId(MultiConnection *connection);
|
static int64 GetRemoteProcessId(void);
|
||||||
|
|
||||||
/* declarations for dynamic loading */
|
/* declarations for dynamic loading */
|
||||||
PG_FUNCTION_INFO_V1(start_session_level_connection_to_node);
|
PG_FUNCTION_INFO_V1(start_session_level_connection_to_node);
|
||||||
|
@ -88,8 +88,9 @@ start_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
CheckCitusVersion(ERROR);
|
CheckCitusVersion(ERROR);
|
||||||
|
|
||||||
if (connection != NULL && (strcmp(connection->hostname, nodeNameString) != 0 ||
|
if (singleConnection != NULL && (strcmp(singleConnection->hostname,
|
||||||
connection->port != nodePort))
|
nodeNameString) != 0 ||
|
||||||
|
singleConnection->port != nodePort))
|
||||||
{
|
{
|
||||||
elog(ERROR,
|
elog(ERROR,
|
||||||
"can not connect different worker nodes from the same session using start_session_level_connection_to_node");
|
"can not connect different worker nodes from the same session using start_session_level_connection_to_node");
|
||||||
|
@ -99,13 +100,13 @@ start_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
* In order to keep connection open even with an open transaction,
|
* In order to keep connection open even with an open transaction,
|
||||||
* allowSessionLifeSpanWithOpenTransaction is set to true.
|
* allowSessionLifeSpanWithOpenTransaction is set to true.
|
||||||
*/
|
*/
|
||||||
if (connection == NULL)
|
if (singleConnection == NULL)
|
||||||
{
|
{
|
||||||
connection = GetNodeConnection(SESSION_LIFESPAN, nodeNameString, nodePort);
|
singleConnection = GetNodeConnection(SESSION_LIFESPAN, nodeNameString, nodePort);
|
||||||
allowNonIdleRemoteTransactionOnXactHandling = true;
|
allowNonIdleRemoteTransactionOnXactHandling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PQstatus(connection->pgConn) != CONNECTION_OK)
|
if (PQstatus(singleConnection->pgConn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
elog(ERROR, "failed to connect to %s:%d", nodeNameString, (int) nodePort);
|
elog(ERROR, "failed to connect to %s:%d", nodeNameString, (int) nodePort);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,7 @@ run_commands_on_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
PostPortNumber);
|
PostPortNumber);
|
||||||
Oid pgReloadConfOid = InvalidOid;
|
Oid pgReloadConfOid = InvalidOid;
|
||||||
|
|
||||||
if (!connection)
|
if (!singleConnection)
|
||||||
{
|
{
|
||||||
elog(ERROR,
|
elog(ERROR,
|
||||||
"start_session_level_connection_to_node must be called first to open a session level connection");
|
"start_session_level_connection_to_node must be called first to open a session level connection");
|
||||||
|
@ -144,9 +145,9 @@ run_commands_on_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
appendStringInfo(processStringInfo, ALTER_CURRENT_PROCESS_ID, MyProcPid);
|
appendStringInfo(processStringInfo, ALTER_CURRENT_PROCESS_ID, MyProcPid);
|
||||||
appendStringInfo(workerProcessStringInfo, ALTER_CURRENT_WORKER_PROCESS_ID,
|
appendStringInfo(workerProcessStringInfo, ALTER_CURRENT_WORKER_PROCESS_ID,
|
||||||
GetRemoteProcessId(connection));
|
GetRemoteProcessId());
|
||||||
|
|
||||||
ExecuteCriticalRemoteCommand(connection, queryString);
|
ExecuteCriticalRemoteCommand(singleConnection, queryString);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we cannot run `ALTER SYSTEM` command within a transaction, we are
|
* Since we cannot run `ALTER SYSTEM` command within a transaction, we are
|
||||||
|
@ -176,10 +177,10 @@ stop_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
allowNonIdleRemoteTransactionOnXactHandling = false;
|
allowNonIdleRemoteTransactionOnXactHandling = false;
|
||||||
|
|
||||||
if (connection != NULL)
|
if (singleConnection != NULL)
|
||||||
{
|
{
|
||||||
CloseConnection(connection);
|
CloseConnection(singleConnection);
|
||||||
connection = NULL;
|
singleConnection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
|
@ -191,7 +192,7 @@ stop_session_level_connection_to_node(PG_FUNCTION_ARGS)
|
||||||
* by the connection.
|
* by the connection.
|
||||||
*/
|
*/
|
||||||
static int64
|
static int64
|
||||||
GetRemoteProcessId(MultiConnection *connection)
|
GetRemoteProcessId()
|
||||||
{
|
{
|
||||||
StringInfo queryStringInfo = makeStringInfo();
|
StringInfo queryStringInfo = makeStringInfo();
|
||||||
PGresult *result = NULL;
|
PGresult *result = NULL;
|
||||||
|
@ -200,7 +201,7 @@ GetRemoteProcessId(MultiConnection *connection)
|
||||||
|
|
||||||
appendStringInfo(queryStringInfo, GET_PROCESS_ID);
|
appendStringInfo(queryStringInfo, GET_PROCESS_ID);
|
||||||
|
|
||||||
ExecuteOptionalRemoteCommand(connection, queryStringInfo->data, &result);
|
ExecuteOptionalRemoteCommand(singleConnection, queryStringInfo->data, &result);
|
||||||
|
|
||||||
rowCount = PQntuples(result);
|
rowCount = PQntuples(result);
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ GetRemoteProcessId(MultiConnection *connection)
|
||||||
resultValue = ParseIntField(result, 0, 0);
|
resultValue = ParseIntField(result, 0, 0);
|
||||||
|
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
ClearResults(connection, false);
|
ClearResults(singleConnection, false);
|
||||||
|
|
||||||
return resultValue;
|
return resultValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
* ApplyLogRedaction is only supported in Citus Enterprise
|
* ApplyLogRedaction is only supported in Citus Enterprise
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
ApplyLogRedaction(const char *text)
|
ApplyLogRedaction(const char *logText)
|
||||||
{
|
{
|
||||||
return (char *) text;
|
return (char *) logText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -445,8 +445,8 @@ SingleReplicatedTable(Oid relationId)
|
||||||
foreach(shardIntervalCell, shardIntervalList)
|
foreach(shardIntervalCell, shardIntervalList)
|
||||||
{
|
{
|
||||||
uint64 *shardIdPointer = (uint64 *) lfirst(shardIntervalCell);
|
uint64 *shardIdPointer = (uint64 *) lfirst(shardIntervalCell);
|
||||||
uint64 shardId = (*shardIdPointer);
|
shardId = (*shardIdPointer);
|
||||||
List *shardPlacementList = ShardPlacementList(shardId);
|
shardPlacementList = ShardPlacementList(shardId);
|
||||||
|
|
||||||
if (list_length(shardPlacementList) != 1)
|
if (list_length(shardPlacementList) != 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -146,6 +146,6 @@ extern bool IsPartitionColumn(Expr *columnExpression, Query *query);
|
||||||
extern void FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList,
|
extern void FindReferencedTableColumn(Expr *columnExpression, List *parentQueryList,
|
||||||
Query *query, Oid *relationId, Var **column);
|
Query *query, Oid *relationId, Var **column);
|
||||||
|
|
||||||
extern bool IsGroupBySubsetOfDistinct(List *groupClause, List *distinctClause);
|
extern bool IsGroupBySubsetOfDistinct(List *groupClauses, List *distinctClauses);
|
||||||
|
|
||||||
#endif /* MULTI_LOGICAL_OPTIMIZER_H */
|
#endif /* MULTI_LOGICAL_OPTIMIZER_H */
|
||||||
|
|
Loading…
Reference in New Issue