mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Teach predtest.c about CHECK clauses to fix partitioning bugs.
In a CHECK clause, a null result means true, whereas in a WHERE clause it means false. predtest.c provided different functions depending on which set of semantics applied to the predicate being proved, but had no option to control what a null meant in the clauses provided as axioms. Add one. Use that in the partitioning code when figuring out whether the validation scan on a new partition can be skipped. Rip out the old logic that attempted (not very successfully) to compensate for the absence of the necessary support in predtest.c. Ashutosh Bapat and Robert Haas, reviewed by Amit Langote and incorporating feedback from Tom Lane. Discussion: http://postgr.es/m/CAFjFpReT_kq_uwU_B8aWDxR7jNGE=P0iELycdq5oupi=xSQTOw@mail.gmail.com
This commit is contained in:
@ -1210,10 +1210,10 @@ build_paths_for_OR(PlannerInfo *root, RelOptInfo *rel,
|
||||
all_clauses = list_concat(list_copy(clauses),
|
||||
other_clauses);
|
||||
|
||||
if (!predicate_implied_by(index->indpred, all_clauses))
|
||||
if (!predicate_implied_by(index->indpred, all_clauses, false))
|
||||
continue; /* can't use it at all */
|
||||
|
||||
if (!predicate_implied_by(index->indpred, other_clauses))
|
||||
if (!predicate_implied_by(index->indpred, other_clauses, false))
|
||||
useful_predicate = true;
|
||||
}
|
||||
}
|
||||
@ -1519,7 +1519,7 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths)
|
||||
{
|
||||
Node *np = (Node *) lfirst(l);
|
||||
|
||||
if (predicate_implied_by(list_make1(np), qualsofar))
|
||||
if (predicate_implied_by(list_make1(np), qualsofar, false))
|
||||
{
|
||||
redundant = true;
|
||||
break; /* out of inner foreach loop */
|
||||
@ -2871,7 +2871,8 @@ check_index_predicates(PlannerInfo *root, RelOptInfo *rel)
|
||||
continue; /* ignore non-partial indexes here */
|
||||
|
||||
if (!index->predOK) /* don't repeat work if already proven OK */
|
||||
index->predOK = predicate_implied_by(index->indpred, clauselist);
|
||||
index->predOK = predicate_implied_by(index->indpred, clauselist,
|
||||
false);
|
||||
|
||||
/* If rel is an update target, leave indrestrictinfo as set above */
|
||||
if (is_target_rel)
|
||||
@ -2886,7 +2887,7 @@ check_index_predicates(PlannerInfo *root, RelOptInfo *rel)
|
||||
/* predicate_implied_by() assumes first arg is immutable */
|
||||
if (contain_mutable_functions((Node *) rinfo->clause) ||
|
||||
!predicate_implied_by(list_make1(rinfo->clause),
|
||||
index->indpred))
|
||||
index->indpred, false))
|
||||
index->indrestrictinfo = lappend(index->indrestrictinfo, rinfo);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user