pgsql: Document nbtree row comparison design. - Mailing list pgsql-committers

From Peter Geoghegan
Subject pgsql: Document nbtree row comparison design.
Date
Msg-id E1vFegc-004jac-0I@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Document nbtree row comparison design.

Add comments explaining when and where it is safe for nbtree to treat
row compare keys as if they were simple scalar inequality keys on the
row's most significant column.  This is particularly important within
_bt_advance_array_keys, which deals with required inequality keys in a
general and uniform way, without any special handling for row compares.

Also spell out the implications of _bt_check_rowcompare's approach of
_conditionally_ evaluating lower-order row compare subkeys, particularly
when one of its lower-order subkeys might see NULL index tuple values
(these may or may not affect whether the qual as a whole is satisfied).
The behavior in this area isn't particularly intuitive, so these issues
seem worth going into.

In passing, add a few more defensive/documenting row comparison related
assertions to _bt_first and _bt_check_rowcompare.

Follow-up to commits bd3f59fd and ec986020.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Victor Yegorov <vyegorov@gmail.com>
Reviewed-By: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAH2-Wznwkak_K7pcAdv9uH8ZfNo8QO7+tHXOaCUddMeTfaCCFw@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6c3b1df878a65bb76e21ed640add30391db8f1d7

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c |  8 +++--
src/backend/access/nbtree/nbtutils.c  | 61 ++++++++++++++++++++++++++++++-----
2 files changed, 58 insertions(+), 11 deletions(-)


pgsql-committers by date:

Previous
From: Peter Geoghegan
Date:
Subject: pgsql: Remove obsolete nbtree equality key comments.
Next
From: Tom Lane
Date:
Subject: pgsql: Change "long" numGroups fields to be Cardinality (i.e., double).