mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Rule rewriter was doing the wrong thing with conditional INSTEAD rules
whose conditions might yield NULL. The negated qual to attach to the original query is properly 'x IS NOT TRUE', not 'NOT x'. This fix produces correct behavior, but we may be taking a performance hit because the planner is much stupider about IS NOT TRUE than it is about NOT clauses. Future TODO: teach prepqual, other parts of planner how to cope with BooleanTest clauses more effectively.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.66 2002/09/11 14:48:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.67 2002/10/20 00:58:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -690,34 +690,26 @@ AddHavingQual(Query *parsetree, Node *havingQual)
|
||||
parsetree->hasSubLinks |= checkExprHasSubLink(copy);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
|
||||
/*
|
||||
* Invert the given clause and add it to the WHERE qualifications of the
|
||||
* given querytree. Inversion means "x IS NOT TRUE", not just "NOT x",
|
||||
* else we will do the wrong thing when x evaluates to NULL.
|
||||
*/
|
||||
void
|
||||
AddNotHavingQual(Query *parsetree, Node *havingQual)
|
||||
AddInvertedQual(Query *parsetree, Node *qual)
|
||||
{
|
||||
Node *notqual;
|
||||
|
||||
if (havingQual == NULL)
|
||||
return;
|
||||
|
||||
/* Need not copy input qual, because AddHavingQual will... */
|
||||
notqual = (Node *) make_notclause((Expr *) havingQual);
|
||||
|
||||
AddHavingQual(parsetree, notqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
AddNotQual(Query *parsetree, Node *qual)
|
||||
{
|
||||
Node *notqual;
|
||||
BooleanTest *invqual;
|
||||
|
||||
if (qual == NULL)
|
||||
return;
|
||||
|
||||
/* Need not copy input qual, because AddQual will... */
|
||||
notqual = (Node *) make_notclause((Expr *) qual);
|
||||
invqual = makeNode(BooleanTest);
|
||||
invqual->arg = qual;
|
||||
invqual->booltesttype = IS_NOT_TRUE;
|
||||
|
||||
AddQual(parsetree, notqual);
|
||||
AddQual(parsetree, (Node *) invqual);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user