mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Now that we are allowing index opclasses to contain operators that are
only stable and not immutable, pred_test_simple_clause has to guard against making invalid deductions. Add a test for immutability of the selected test_op.
This commit is contained in:
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.157 2004/03/07 05:43:53 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.158 2004/03/27 00:24:28 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "executor/executor.h"
|
#include "executor/executor.h"
|
||||||
#include "nodes/makefuncs.h"
|
#include "nodes/makefuncs.h"
|
||||||
@ -990,9 +991,10 @@ static const StrategyNumber
|
|||||||
* and constants can be different but the operators must be in the same btree
|
* and constants can be different but the operators must be in the same btree
|
||||||
* operator class. We use the above operator implication table to be able to
|
* operator class. We use the above operator implication table to be able to
|
||||||
* derive implications between nonidentical clauses. (Note: "foo" is known
|
* derive implications between nonidentical clauses. (Note: "foo" is known
|
||||||
* immutable, and constants are surely immutable, and we assume that operators
|
* immutable, and constants are surely immutable, but we have to check that
|
||||||
* that are in btree opclasses are immutable, so there's no need to do extra
|
* the operators are too. As of 7.5 it's possible for opclasses to contain
|
||||||
* mutability checks in this case either.)
|
* operators that are merely stable, and we dare not make deductions with
|
||||||
|
* these.)
|
||||||
*
|
*
|
||||||
* Eventually, rtree operators could also be handled by defining an
|
* Eventually, rtree operators could also be handled by defining an
|
||||||
* appropriate "RT_implic_table" array.
|
* appropriate "RT_implic_table" array.
|
||||||
@ -1278,11 +1280,23 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
|||||||
test_strategy);
|
test_strategy);
|
||||||
}
|
}
|
||||||
if (OidIsValid(test_op))
|
if (OidIsValid(test_op))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Last check: test_op must be immutable.
|
||||||
|
*
|
||||||
|
* Note that we require only the test_op to be immutable, not
|
||||||
|
* the original clause_op. (pred_op must be immutable, else it
|
||||||
|
* would not be allowed in an index predicate.) Essentially
|
||||||
|
* we are assuming that the opclass is consistent even if it
|
||||||
|
* contains operators that are merely stable.
|
||||||
|
*/
|
||||||
|
if (op_volatile(test_op) == PROVOLATILE_IMMUTABLE)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReleaseSysCacheList(catlist);
|
ReleaseSysCacheList(catlist);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user