From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Improve predtest.c's ability to reason about operator expression |
Date: | 2014-06-13 04:03:05 |
Message-ID: | E1WvIhl-0004rs-Pf@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2014-06-14 00:07:25 | pgsql: Adjust 9.4 release notes. |
Previous Message | Tom Lane | 2014-06-13 00:15:13 | pgsql: Fix pg_restore's processing of old-style BLOB COMMENTS data. |