mirror of https://github.com/citusdata/citus.git
Merge pull request #535 from citusdata/fix/equality_operator_check
Change equality operator check for operator expressionspull/548/head
commit
3c0673be51
|
@ -3364,8 +3364,7 @@ SupportedLateralQuery(Query *parentQuery, Query *lateralQuery)
|
||||||
{
|
{
|
||||||
OpExpr *operatorExpression = NULL;
|
OpExpr *operatorExpression = NULL;
|
||||||
List *argumentList = NIL;
|
List *argumentList = NIL;
|
||||||
char *operatorName = NULL;
|
bool equalsOperator = false;
|
||||||
int equalsOperator = 0;
|
|
||||||
Expr *leftArgument = NULL;
|
Expr *leftArgument = NULL;
|
||||||
Expr *rightArgument = NULL;
|
Expr *rightArgument = NULL;
|
||||||
Expr *outerQueryExpression = NULL;
|
Expr *outerQueryExpression = NULL;
|
||||||
|
@ -3396,15 +3395,8 @@ SupportedLateralQuery(Query *parentQuery, Query *lateralQuery)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
equalsOperator = OperatorImplementsEquality(operatorExpression->opno);
|
||||||
* We accept all column types that can be joined with an equals sign as
|
if (!equalsOperator)
|
||||||
* valid. These include columns that have cross-type equals operators
|
|
||||||
* (such as int48eq) and columns that can be casted at run-time (such as
|
|
||||||
* from numeric to int4).
|
|
||||||
*/
|
|
||||||
operatorName = get_opname(operatorExpression->opno);
|
|
||||||
equalsOperator = strncmp(operatorName, EQUAL_OPERATOR_STRING, NAMEDATALEN);
|
|
||||||
if (equalsOperator != 0)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -928,15 +928,8 @@ IsJoinClause(Node *clause)
|
||||||
bool equiJoin = false;
|
bool equiJoin = false;
|
||||||
bool joinBetweenDifferentTables = false;
|
bool joinBetweenDifferentTables = false;
|
||||||
|
|
||||||
/*
|
bool equalsOperator = OperatorImplementsEquality(operatorExpression->opno);
|
||||||
* We accept all column types that can be joined with an equals sign as
|
if (equalsOperator)
|
||||||
* valid. These include columns that have cross-type equals operators
|
|
||||||
* (such as int48eq) and columns that can be casted at run-time (such as
|
|
||||||
* from numeric to int4).
|
|
||||||
*/
|
|
||||||
char *operatorName = get_opname(operatorExpression->opno);
|
|
||||||
int equalsOperator = strncmp(operatorName, EQUAL_OPERATOR_STRING, NAMEDATALEN);
|
|
||||||
if (equalsOperator == 0)
|
|
||||||
{
|
{
|
||||||
equiJoin = true;
|
equiJoin = true;
|
||||||
}
|
}
|
||||||
|
@ -1956,3 +1949,29 @@ MultiSubqueryPushdownTable(RangeTblEntry *subqueryRangeTableEntry)
|
||||||
|
|
||||||
return subqueryTableNode;
|
return subqueryTableNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OperatorImplementsEquality returns true if the given opno represents an
|
||||||
|
* equality operator. The function retrieves btree interpretation list for this
|
||||||
|
* opno and check if BTEqualStrategyNumber strategy is present.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
OperatorImplementsEquality(Oid opno)
|
||||||
|
{
|
||||||
|
bool equalityOperator = false;
|
||||||
|
List *btreeIntepretationList = get_op_btree_interpretation(opno);
|
||||||
|
ListCell *btreeInterpretationCell = NULL;
|
||||||
|
foreach(btreeInterpretationCell, btreeIntepretationList)
|
||||||
|
{
|
||||||
|
OpBtreeInterpretation *btreeIntepretation = (OpBtreeInterpretation *)
|
||||||
|
lfirst(btreeInterpretationCell);
|
||||||
|
if (btreeIntepretation->strategy == BTEqualStrategyNumber)
|
||||||
|
{
|
||||||
|
equalityOperator = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return equalityOperator;
|
||||||
|
}
|
||||||
|
|
|
@ -2861,9 +2861,8 @@ HashableClauseMutator(Node *originalNode, Var *partitionColumn)
|
||||||
ScalarArrayOpExpr *arrayOperatorExpression = (ScalarArrayOpExpr *) originalNode;
|
ScalarArrayOpExpr *arrayOperatorExpression = (ScalarArrayOpExpr *) originalNode;
|
||||||
Node *leftOpExpression = linitial(arrayOperatorExpression->args);
|
Node *leftOpExpression = linitial(arrayOperatorExpression->args);
|
||||||
Node *strippedLeftOpExpression = strip_implicit_coercions(leftOpExpression);
|
Node *strippedLeftOpExpression = strip_implicit_coercions(leftOpExpression);
|
||||||
char *operatorName = get_opname(arrayOperatorExpression->opno);
|
bool usingEqualityOperator = OperatorImplementsEquality(
|
||||||
int equalsCompare = strncmp(operatorName, EQUAL_OPERATOR_STRING, NAMEDATALEN);
|
arrayOperatorExpression->opno);
|
||||||
bool usingEqualityOperator = (equalsCompare == 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Citus cannot prune hash-distributed shards with ANY/ALL. We show a NOTICE
|
* Citus cannot prune hash-distributed shards with ANY/ALL. We show a NOTICE
|
||||||
|
|
|
@ -1009,8 +1009,6 @@ ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column)
|
||||||
OpExpr *opExpr = (OpExpr *) node;
|
OpExpr *opExpr = (OpExpr *) node;
|
||||||
bool simpleExpression = SimpleOpExpression((Expr *) opExpr);
|
bool simpleExpression = SimpleOpExpression((Expr *) opExpr);
|
||||||
bool columnInExpr = false;
|
bool columnInExpr = false;
|
||||||
char *operatorName = NULL;
|
|
||||||
int operatorNameComparison = 0;
|
|
||||||
bool usingEqualityOperator = false;
|
bool usingEqualityOperator = false;
|
||||||
|
|
||||||
if (!simpleExpression)
|
if (!simpleExpression)
|
||||||
|
@ -1024,10 +1022,7 @@ ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
operatorName = get_opname(opExpr->opno);
|
usingEqualityOperator = OperatorImplementsEquality(opExpr->opno);
|
||||||
operatorNameComparison = strncmp(operatorName, EQUAL_OPERATOR_STRING,
|
|
||||||
NAMEDATALEN);
|
|
||||||
usingEqualityOperator = (operatorNameComparison == 0);
|
|
||||||
|
|
||||||
return usingEqualityOperator;
|
return usingEqualityOperator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include "nodes/pg_list.h"
|
#include "nodes/pg_list.h"
|
||||||
|
|
||||||
|
|
||||||
/* Defines the operator string used for equi joins */
|
|
||||||
#define EQUAL_OPERATOR_STRING "="
|
|
||||||
#define SUBQUERY_RANGE_TABLE_ID -1
|
#define SUBQUERY_RANGE_TABLE_ID -1
|
||||||
#define SUBQUERY_RELATION_ID 10000
|
#define SUBQUERY_RELATION_ID 10000
|
||||||
#define HEAP_ANALYTICS_SUBQUERY_RELATION_ID 10001
|
#define HEAP_ANALYTICS_SUBQUERY_RELATION_ID 10001
|
||||||
|
@ -201,6 +199,7 @@ extern List * TableEntryList(List *rangeTableList);
|
||||||
extern bool ExtractRangeTableRelationWalker(Node *node, List **rangeTableList);
|
extern bool ExtractRangeTableRelationWalker(Node *node, List **rangeTableList);
|
||||||
extern bool ExtractRangeTableEntryWalker(Node *node, List **rangeTableList);
|
extern bool ExtractRangeTableEntryWalker(Node *node, List **rangeTableList);
|
||||||
extern List * pull_var_clause_default(Node *node);
|
extern List * pull_var_clause_default(Node *node);
|
||||||
|
extern bool OperatorImplementsEquality(Oid opno);
|
||||||
|
|
||||||
|
|
||||||
#endif /* MULTI_LOGICAL_PLANNER_H */
|
#endif /* MULTI_LOGICAL_PLANNER_H */
|
||||||
|
|
Loading…
Reference in New Issue