mirror of https://github.com/citusdata/citus.git
Remove ONLY clause from worker queries
Fixes #475 With this change we prevent addition of ONLY clause to queries prepared for worker nodes. When we add ONLY clause we may miss the inherited tables in worker nodes created by users manually.pull/1938/head
parent
491ba8e4b0
commit
15f55cb675
|
@ -71,6 +71,7 @@ static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn);
|
|||
static Task * RouterSelectTask(Query *query);
|
||||
static Job * RouterQueryJob(Query *query, Task *task);
|
||||
static bool ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column);
|
||||
static void SetRangeTablesInherited(Query *query);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -424,6 +425,12 @@ RouterModifyTask(Query *query)
|
|||
upsertQuery = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We set inh flag of all range tables entries to true so that deparser will not
|
||||
* add ONLY keyword to resulting query string.
|
||||
*/
|
||||
SetRangeTablesInherited(query);
|
||||
|
||||
deparse_shard_query(query, shardInterval->relationId, shardId, queryString);
|
||||
ereport(DEBUG4, (errmsg("distributed statement: %s", queryString->data)));
|
||||
|
||||
|
@ -778,6 +785,12 @@ RouterSelectTask(Query *query)
|
|||
joinTree->quals = whereClause;
|
||||
}
|
||||
|
||||
/*
|
||||
* We set inh flag of all range tables entries to true so that deparser will not
|
||||
* add ONLY keyword to resulting query string.
|
||||
*/
|
||||
SetRangeTablesInherited(query);
|
||||
|
||||
deparse_shard_query(query, shardInterval->relationId, shardId, queryString);
|
||||
ereport(DEBUG4, (errmsg("distributed statement: %s", queryString->data)));
|
||||
|
||||
|
@ -1043,3 +1056,24 @@ ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* RouterSetRangeTablesInherited sets inh flag of all range table entries to true.
|
||||
* We basically iterate over all range table entries and set their inh flag.
|
||||
*/
|
||||
static void
|
||||
SetRangeTablesInherited(Query *query)
|
||||
{
|
||||
List *rangeTableList = query->rtable;
|
||||
ListCell *rangeTableCell = NULL;
|
||||
|
||||
foreach(rangeTableCell, rangeTableList)
|
||||
{
|
||||
RangeTblEntry *rangeTableEntry = (RangeTblEntry *) lfirst(rangeTableCell);
|
||||
if (rangeTableEntry->rtekind == RTE_RELATION)
|
||||
{
|
||||
rangeTableEntry->inh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue