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