pgsql: Improve predtest.c's ability to reason about operator expression

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve predtest.c's ability to reason about operator expression
Дата
Msg-id E1WvIhl-0004rs-Pf@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve predtest.c's ability to reason about operator expressions.

We have for a long time been able to prove implications and refutations
between clauses structured like "expr op const" with the same subexpression
and btree-related operators; for example that "x < 4" implies "x <= 5".
The implication machinery is needed to detect usability of partial indexes,
and the refutation machinery is needed to implement constraint exclusion.

This patch extends that machinery to make proofs for operator expressions
involving the same two immutable-but-not-necessarily-just-Const input
expressions, ie does "expr1 op1 expr2" prove or refute "expr1 op2 expr2" or
"expr2 op2 expr1"?  An important example is that we can now prove "x = y"
given "y = x", which formerly the code could not deduce unless x or y was a
constant.  We can make use of the system's knowledge of operator commutator
and negator pairs, and can also make use of btree opclass relationships,
for example "x < y" implies "x <= y" and refutes "x > y" (notice that
neither of these could be proven just from commutator or negator links).

Inspired by a gripe from Brian Dunavant.  This seems more like a new
feature than a bug fix, though, so no back-patch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3f8c23c4d31d4a0e801041733deb2c7cfa577b32

Modified Files
--------------
src/backend/optimizer/util/predtest.c |  517 +++++++++++++++++++++++----------
1 file changed, 358 insertions(+), 159 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix pg_restore's processing of old-style BLOB COMMENTS data.
Следующее
От:
Дата:
Сообщение: ...