mirror of https://github.com/citusdata/citus.git
Revert ununsed helper functions after refactor
parent
245b9534e2
commit
afd3bd921d
|
|
@ -317,14 +317,20 @@ BuildSelectStatementViaStdPlanner(Query *combineQuery, List *remoteScanTargetLis
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ExtractCitusExtradataContainerRTE is a helper function that stores rangeTblEntry
|
* Finds the rangetable entry in the query that refers to the citus_extradata_container
|
||||||
* to result if it has citus extra data container.
|
* and stores the pointer in result.
|
||||||
*
|
|
||||||
* The function returns true if it finds the RTE, and false otherwise.
|
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ExtractCitusExtradataContainerRTE(RangeTblEntry *rangeTblEntry, RangeTblEntry **result)
|
FindCitusExtradataContainerRTE(Node *node, RangeTblEntry **result)
|
||||||
{
|
{
|
||||||
|
if (node == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsA(node, RangeTblEntry))
|
||||||
|
{
|
||||||
|
RangeTblEntry *rangeTblEntry = castNode(RangeTblEntry, node);
|
||||||
if (rangeTblEntry->rtekind == RTE_FUNCTION &&
|
if (rangeTblEntry->rtekind == RTE_FUNCTION &&
|
||||||
list_length(rangeTblEntry->functions) == 1)
|
list_length(rangeTblEntry->functions) == 1)
|
||||||
{
|
{
|
||||||
|
|
@ -342,27 +348,9 @@ ExtractCitusExtradataContainerRTE(RangeTblEntry *rangeTblEntry, RangeTblEntry **
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* query_tree_walker descends into RTEs */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finds the rangetable entry in the query that refers to the citus_extradata_container
|
|
||||||
* and stores the pointer in result.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
FindCitusExtradataContainerRTE(Node *node, RangeTblEntry **result)
|
|
||||||
{
|
|
||||||
if (node == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsA(node, RangeTblEntry))
|
|
||||||
{
|
|
||||||
RangeTblEntry *rangeTblEntry = castNode(RangeTblEntry, node);
|
|
||||||
return ExtractCitusExtradataContainerRTE(rangeTblEntry, result);
|
|
||||||
}
|
|
||||||
else if (IsA(node, Query))
|
else if (IsA(node, Query))
|
||||||
{
|
{
|
||||||
const int flags = QTW_EXAMINE_RTES_BEFORE;
|
const int flags = QTW_EXAMINE_RTES_BEFORE;
|
||||||
|
|
|
||||||
|
|
@ -282,29 +282,3 @@ ColumnToColumnName(Oid relationId, Node *columnNode)
|
||||||
|
|
||||||
return columnName;
|
return columnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GetAttrNumForMatchingColumn returns the attribute number for the column
|
|
||||||
* in the target relation that matches the given Var. If the column does not
|
|
||||||
* exist or is not comparable, it returns InvalidAttrNumber.
|
|
||||||
*/
|
|
||||||
AttrNumber
|
|
||||||
GetAttrNumForMatchingColumn(RangeTblEntry *rteTarget, Oid relid, Var *var)
|
|
||||||
{
|
|
||||||
char *targetColumnName = get_attname(relid, var->varattno, false);
|
|
||||||
AttrNumber attnum = get_attnum(rteTarget->relid, targetColumnName);
|
|
||||||
if (attnum == InvalidAttrNumber)
|
|
||||||
{
|
|
||||||
ereport(DEBUG5, (errmsg("Column %s does not exist in relation %s",
|
|
||||||
targetColumnName, rteTarget->eref->aliasname)));
|
|
||||||
return InvalidAttrNumber;
|
|
||||||
}
|
|
||||||
if(var->vartype != get_atttype(rteTarget->relid, attnum))
|
|
||||||
{
|
|
||||||
ereport(DEBUG5, (errmsg("Column %s is not comparable for tables with relids %d and %d",
|
|
||||||
targetColumnName, rteTarget->relid, relid)));
|
|
||||||
return InvalidAttrNumber;
|
|
||||||
}
|
|
||||||
return attnum;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,10 @@
|
||||||
#include "catalog/pg_class.h"
|
#include "catalog/pg_class.h"
|
||||||
#include "nodes/nodeFuncs.h"
|
#include "nodes/nodeFuncs.h"
|
||||||
#include "nodes/primnodes.h"
|
#include "nodes/primnodes.h"
|
||||||
#include "parser/parsetree.h"
|
|
||||||
|
|
||||||
#include "distributed/deparse_shard_query.h"
|
|
||||||
#include "distributed/listutils.h"
|
#include "distributed/listutils.h"
|
||||||
#include "distributed/query_utils.h"
|
#include "distributed/query_utils.h"
|
||||||
#include "distributed/relation_restriction_equivalence.h"
|
|
||||||
#include "distributed/version_compat.h"
|
#include "distributed/version_compat.h"
|
||||||
#include "utils/lsyscache.h"
|
|
||||||
|
|
||||||
|
|
||||||
static bool CitusQueryableRangeTableRelation(RangeTblEntry *rangeTableEntry);
|
static bool CitusQueryableRangeTableRelation(RangeTblEntry *rangeTableEntry);
|
||||||
|
|
@ -182,94 +178,3 @@ ExtractRangeTableIndexWalker(Node *node, List **rangeTableIndexList)
|
||||||
|
|
||||||
return walkerResult;
|
return walkerResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ExtractRangeTableIds walks over the given node, and finds all range
|
|
||||||
* table entries.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
ExtractRangeTableIds(Node *node, ExtractRangeTableIdsContext *context)
|
|
||||||
{
|
|
||||||
List **rangeTableList = context->idList;
|
|
||||||
List *rtable = context->rtable;
|
|
||||||
|
|
||||||
if (node == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsA(node, RangeTblRef))
|
|
||||||
{
|
|
||||||
int rangeTableIndex = ((RangeTblRef *) node)->rtindex;
|
|
||||||
|
|
||||||
RangeTblEntry *rte = rt_fetch(rangeTableIndex, rtable);
|
|
||||||
if (rte->rtekind == RTE_SUBQUERY)
|
|
||||||
{
|
|
||||||
Query *subquery = rte->subquery;
|
|
||||||
context->rtable = subquery->rtable;
|
|
||||||
ExtractRangeTableIds((Node *) subquery, context);
|
|
||||||
context->rtable = rtable; /* restore original rtable */
|
|
||||||
}
|
|
||||||
else if (rte->rtekind == RTE_RELATION || rte->rtekind == RTE_FUNCTION)
|
|
||||||
{
|
|
||||||
(*rangeTableList) = lappend(*rangeTableList, rte);
|
|
||||||
ereport(DEBUG4, (errmsg("ExtractRangeTableIds: found range table id %d", rte->relid)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ereport(DEBUG4, (errmsg("Unsupported RTE kind in ExtractRangeTableIds %d", rte->rtekind)));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (IsA(node, Query))
|
|
||||||
{
|
|
||||||
context->rtable = ((Query *) node)->rtable;
|
|
||||||
query_tree_walker((Query *) node, ExtractRangeTableIds, context, 0);
|
|
||||||
context->rtable = rtable; /* restore original rtable */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return expression_tree_walker(node, ExtractRangeTableIds, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* CheckIfAllCitusRTEsAreColocated checks if all distributed tables in the
|
|
||||||
* given node are colocated. If they are, it sets the value of rte to a
|
|
||||||
* representative table.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
CheckIfAllCitusRTEsAreColocated(Node *node, List *rtable, RangeTblEntry **rte, List **citusRelids)
|
|
||||||
{
|
|
||||||
ExtractRangeTableIdsContext context;
|
|
||||||
List *idList = NIL;
|
|
||||||
context.idList = &idList;
|
|
||||||
context.rtable = rtable;
|
|
||||||
ExtractRangeTableIds(node, &context);
|
|
||||||
|
|
||||||
RangeTblEntry *rteTmp;
|
|
||||||
ListCell *lc = NULL;
|
|
||||||
|
|
||||||
foreach(lc, idList)
|
|
||||||
{
|
|
||||||
rteTmp = (RangeTblEntry *) lfirst(lc);
|
|
||||||
if (IsCitusTable(rteTmp->relid))
|
|
||||||
{
|
|
||||||
*citusRelids = lappend_int(*citusRelids, rteTmp->relid);
|
|
||||||
*rte = rteTmp; // set the value of rte, a representative table
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AllDistributedRelationsInListColocated(citusRelids))
|
|
||||||
{
|
|
||||||
ereport(DEBUG5, (errmsg("The distributed tables are not colocated")));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ extern Path * CreateCitusCustomScanPath(PlannerInfo *root, RelOptInfo *relOptInf
|
||||||
CustomScan *remoteScan);
|
CustomScan *remoteScan);
|
||||||
extern PlannedStmt * PlanCombineQuery(struct DistributedPlan *distributedPlan,
|
extern PlannedStmt * PlanCombineQuery(struct DistributedPlan *distributedPlan,
|
||||||
struct CustomScan *dataScan);
|
struct CustomScan *dataScan);
|
||||||
extern bool ExtractCitusExtradataContainerRTE(RangeTblEntry *rangeTblEntry, RangeTblEntry **result);
|
|
||||||
extern bool FindCitusExtradataContainerRTE(Node *node, RangeTblEntry **result);
|
extern bool FindCitusExtradataContainerRTE(Node *node, RangeTblEntry **result);
|
||||||
extern bool ReplaceCitusExtraDataContainer;
|
extern bool ReplaceCitusExtraDataContainer;
|
||||||
extern CustomScan *ReplaceCitusExtraDataContainerWithCustomScan;
|
extern CustomScan *ReplaceCitusExtraDataContainerWithCustomScan;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,5 @@ extern Var * BuildDistributionKeyFromColumnName(Oid relationId,
|
||||||
extern char * ColumnToColumnName(Oid relationId, Node *columnNode);
|
extern char * ColumnToColumnName(Oid relationId, Node *columnNode);
|
||||||
extern Oid ColumnTypeIdForRelationColumnName(Oid relationId, char *columnName);
|
extern Oid ColumnTypeIdForRelationColumnName(Oid relationId, char *columnName);
|
||||||
extern void EnsureValidDistributionColumn(Oid relationId, char *columnName);
|
extern void EnsureValidDistributionColumn(Oid relationId, char *columnName);
|
||||||
extern AttrNumber GetAttrNumForMatchingColumn(RangeTblEntry *rteTarget, Oid relid, Var *var);
|
|
||||||
|
|
||||||
#endif /* DISTRIBUTION_COLUMN_H */
|
#endif /* DISTRIBUTION_COLUMN_H */
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,6 @@ typedef struct ExtractRangeTableWalkerContext
|
||||||
ExtractRangeTableMode walkerMode;
|
ExtractRangeTableMode walkerMode;
|
||||||
} ExtractRangeTableWalkerContext;
|
} ExtractRangeTableWalkerContext;
|
||||||
|
|
||||||
/* Struct to pass rtable list and the result list to walker */
|
|
||||||
typedef struct ExtractRangeTableIdsContext
|
|
||||||
{
|
|
||||||
List **idList;
|
|
||||||
List *rtable;
|
|
||||||
} ExtractRangeTableIdsContext;
|
|
||||||
|
|
||||||
/* Function declarations for query-walker utility functions */
|
/* Function declarations for query-walker utility functions */
|
||||||
extern bool ExtractRangeTableList(Node *node, ExtractRangeTableWalkerContext *context);
|
extern bool ExtractRangeTableList(Node *node, ExtractRangeTableWalkerContext *context);
|
||||||
|
|
||||||
|
|
@ -45,6 +38,5 @@ extern bool ExtractRangeTableRelationWalker(Node *node, List **rangeTableList);
|
||||||
extern bool ExtractRangeTableEntryWalker(Node *node, List **rangeTableList);
|
extern bool ExtractRangeTableEntryWalker(Node *node, List **rangeTableList);
|
||||||
|
|
||||||
extern bool ExtractRangeTableIndexWalker(Node *node, List **rangeTableIndexList);
|
extern bool ExtractRangeTableIndexWalker(Node *node, List **rangeTableIndexList);
|
||||||
extern bool ExtractRangeTableIds(Node *node, ExtractRangeTableIdsContext *context);
|
|
||||||
extern bool CheckIfAllCitusRTEsAreColocated(Node *node, List *rtable, RangeTblEntry **rte, List **citusRelids);
|
|
||||||
#endif /* QUERY_UTILS_H */
|
#endif /* QUERY_UTILS_H */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue