mirror of https://github.com/citusdata/citus.git
Move repeated code to a function
parent
a72d959735
commit
b389bebda1
|
@ -106,6 +106,8 @@ static RangeTblEntry * DerivedRangeTableEntry(MultiNode *multiNode, List *column
|
|||
List *tableIdList);
|
||||
static List * DerivedColumnNameList(uint32 columnCount, uint64 generatingJobId);
|
||||
static Query * BuildSubqueryJobQuery(MultiNode *multiNode);
|
||||
static void UpdateAllColumnAttributes(Node *columnContainer, List *rangeTableList,
|
||||
List *dependedJobList);
|
||||
static void UpdateColumnAttributes(Var *column, List *rangeTableList,
|
||||
List *dependedJobList);
|
||||
static Index NewTableId(Index originalTableId, List *rangeTableList);
|
||||
|
@ -579,10 +581,8 @@ BuildJobQuery(MultiNode *multiNode, List *dependedJobList)
|
|||
List *sortClauseList = NIL;
|
||||
List *groupClauseList = NIL;
|
||||
List *selectClauseList = NIL;
|
||||
List *columnList = NIL;
|
||||
Node *limitCount = NULL;
|
||||
Node *limitOffset = NULL;
|
||||
ListCell *columnCell = NULL;
|
||||
FromExpr *joinTree = NULL;
|
||||
Node *joinRoot = NULL;
|
||||
Node *havingQual = NULL;
|
||||
|
@ -650,13 +650,7 @@ BuildJobQuery(MultiNode *multiNode, List *dependedJobList)
|
|||
/* update the column attributes for target entries */
|
||||
if (updateColumnAttributes)
|
||||
{
|
||||
ListCell *columnCell = NULL;
|
||||
List *columnList = pull_var_clause_default((Node *) targetList);
|
||||
foreach(columnCell, columnList)
|
||||
{
|
||||
Var *column = (Var *) lfirst(columnCell);
|
||||
UpdateColumnAttributes(column, rangeTableList, dependedJobList);
|
||||
}
|
||||
UpdateAllColumnAttributes((Node *) targetList, rangeTableList, dependedJobList);
|
||||
}
|
||||
|
||||
/* extract limit count/offset and sort clauses */
|
||||
|
@ -676,28 +670,12 @@ BuildJobQuery(MultiNode *multiNode, List *dependedJobList)
|
|||
/* build the where clause list using select predicates */
|
||||
selectClauseList = QuerySelectClauseList(multiNode);
|
||||
|
||||
/* set correct column attributes for select columns */
|
||||
/* set correct column attributes for select and having clauses */
|
||||
if (updateColumnAttributes)
|
||||
{
|
||||
columnCell = NULL;
|
||||
columnList = pull_var_clause_default((Node *) selectClauseList);
|
||||
foreach(columnCell, columnList)
|
||||
{
|
||||
Var *column = (Var *) lfirst(columnCell);
|
||||
UpdateColumnAttributes(column, rangeTableList, dependedJobList);
|
||||
}
|
||||
}
|
||||
|
||||
/* set correct column attributes for having columns */
|
||||
if (updateColumnAttributes)
|
||||
{
|
||||
columnCell = NULL;
|
||||
columnList = pull_var_clause_default((Node *) havingQual);
|
||||
foreach(columnCell, columnList)
|
||||
{
|
||||
Var *column = (Var *) lfirst(columnCell);
|
||||
UpdateColumnAttributes(column, rangeTableList, dependedJobList);
|
||||
}
|
||||
UpdateAllColumnAttributes((Node *) selectClauseList, rangeTableList,
|
||||
dependedJobList);
|
||||
UpdateAllColumnAttributes(havingQual, rangeTableList, dependedJobList);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1538,6 +1516,25 @@ BuildSubqueryJobQuery(MultiNode *multiNode)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* UpdateAllColumnAttributes extracts column references from provided columnContainer
|
||||
* and calls UpdateColumnAttributes to updates the column's range table reference (varno) and
|
||||
* column attribute number for the range table (varattno).
|
||||
*/
|
||||
static void
|
||||
UpdateAllColumnAttributes(Node *columnContainer, List *rangeTableList,
|
||||
List *dependedJobList)
|
||||
{
|
||||
ListCell *columnCell = NULL;
|
||||
List *columnList = pull_var_clause_default(columnContainer);
|
||||
foreach(columnCell, columnList)
|
||||
{
|
||||
Var *column = (Var *) lfirst(columnCell);
|
||||
UpdateColumnAttributes(column, rangeTableList, dependedJobList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* UpdateColumnAttributes updates the column's range table reference (varno) and
|
||||
* column attribute number for the range table (varattno). The function uses the
|
||||
|
|
Loading…
Reference in New Issue