pgsql: Improve predtest.c's internal docs,and enhance its functionalit

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve predtest.c's internal docs,and enhance its functionalit
Дата
Msg-id E1euQ27-0005T0-PX@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve predtest.c's internal docs, and enhance its functionality a bit.

Commit b08df9cab left things rather poorly documented as far as the
exact semantics of "clause_is_check" mode went.  Also, that mode did
not really work correctly for predicate_refuted_by; although given the
lack of specification as to what it should do, as well as the lack
of any actual use-case, that's perhaps not surprising.

Rename "clause_is_check" to "weak" proof mode, and provide specifications
for what it should do.  I defined weak refutation as meaning "truth of A
implies non-truth of B", which makes it possible to use the mode in the
part of relation_excluded_by_constraints that checks for mutually
contradictory WHERE clauses.  Fix up several places that did things wrong
for that definition.  (As far as I can see, these errors would only lead
to failure-to-prove, not incorrect claims of proof, making them not
serious bugs even aside from the fact that v10 contains no use of this
mode.  So there seems no need for back-patching.)

In addition, teach predicate_refuted_by_recurse that it can use
predicate_implied_by_recurse after all when processing a strong NOT-clause,
so long as it asks for the correct proof strength.  This is an optimization
that could have been included in commit b08df9cab, but wasn't.

Also, simplify and generalize the logic that checks for whether nullness of
the argument of IS [NOT] NULL would force overall nullness of the predicate
or clause.  (This results in a change in the partition_prune test's output,
as it is now able to prune an all-nulls partition that it did not recognize
before.)

In passing, in PartConstraintImpliedByRelConstraint, remove bogus
conversion of the constraint list to explicit-AND form and then right back
again; that accomplished nothing except forcing a useless extra level of
recursion inside predicate_implied_by.

Discussion: https://postgr.es/m/5983.1520487191@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5748f3a0aa7cf78ac6979010273bd9d50869bb8e

Modified Files
--------------
src/backend/commands/tablecmds.c                   |  20 +-
src/backend/optimizer/util/plancat.c               |   9 +-
src/backend/optimizer/util/predtest.c              | 363 +++++++++++++--------
src/include/optimizer/predtest.h                   |   4 +-
.../test_predtest/expected/test_predtest.out       |  89 ++++-
.../modules/test_predtest/sql/test_predtest.sql    |  34 +-
src/test/regress/expected/partition_prune.out      |   6 +-
src/test/regress/sql/partition_prune.sql           |   2 +-
8 files changed, 364 insertions(+), 163 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix test_predtest's idea of what weak refutation means.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: In psql, restore old behavior of Query_for_list_of_functions.