Fix some bugs

pull/5740/head
Marco Slot 2022-03-01 19:08:12 +01:00
parent cf2239f9cd
commit 7de878f0ca
1 changed files with 9 additions and 0 deletions

View File

@ -89,6 +89,7 @@ extract_equality_filters_from_query(PG_FUNCTION_ARGS)
char *queryString = text_to_cstring(PG_GETARG_TEXT_P(0)); char *queryString = text_to_cstring(PG_GETARG_TEXT_P(0));
MemoryContext oldContext = CurrentMemoryContext; MemoryContext oldContext = CurrentMemoryContext;
ResourceOwner oldOwner = CurrentResourceOwner;
/* capture filters via hooks */ /* capture filters via hooks */
PlannerRestrictionContext *plannerRestrictionContext = PlannerRestrictionContext *plannerRestrictionContext =
@ -153,6 +154,12 @@ extract_equality_filters_from_query(PG_FUNCTION_ARGS)
Var *leftVar = NULL; Var *leftVar = NULL;
Const *rightConst = NULL; Const *rightConst = NULL;
if (!NodeIsEqualsOpExpr((Node *) clause))
{
/* not an equals expression */
continue;
}
if (!VarConstOpExprClause((OpExpr *) clause, &leftVar, &rightConst) && if (!VarConstOpExprClause((OpExpr *) clause, &leftVar, &rightConst) &&
!VarNullWrapperOpExprClause(clause, wrapperFunctionId, &leftVar)) !VarNullWrapperOpExprClause(clause, wrapperFunctionId, &leftVar))
{ {
@ -273,6 +280,8 @@ extract_equality_filters_from_query(PG_FUNCTION_ARGS)
FlushErrorState(); FlushErrorState();
RollbackAndReleaseCurrentSubTransaction(); RollbackAndReleaseCurrentSubTransaction();
MemoryContextSwitchTo(oldContext);
CurrentResourceOwner = oldOwner;
} }
PG_END_TRY(); PG_END_TRY();