Truncating an internal node's upper bound can cause it to compare less than some values that in fact are included in the represented leaf page. So we need a hack to make sure it looks large enough to include all values that could be on the page. But there's no equivalent issue for the lower bound. The fact that the code did fuzzy comparisons for the lower bound too seems to be the result of fuzzy thinking. Or maybe there was a desire to not assume too much about what the datatype's comparison rule is; but we've already fully bought into the premise that internal keys compare like bytea. Hence, remove the useless check against the key's lower bound in gbt_var_node_pf_match. The comparable check in gbt_var_penalty may also be useless, but I'm not quite sure. In any case that seems negligible from a performance standpoint, so I left it alone. Also, in the strategy cases in gbt_var_consistent that only require comparisons to the lower bound, there's no need to call gbt_var_node_pf_match at all. Refactor that logic by inventing macros lower_is_below_query and upper_is_above_query to directly express what we need to test. I also took this opportunity to flip all the tests around to be "indexkey OP query" rather than mostly being the reverse: IMO this makes the code less confusing since the tests now match the names of the strategies. Also, in the name of consistency, make gbt_num_consistent look like that too. There's no functional change there, but this should be more readable going forward. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com> Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn |
||
|---|---|---|
| .github | ||
| config | ||
| contrib | ||
| doc | ||
| src | ||
| .dir-locals.el | ||
| .editorconfig | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| aclocal.m4 | ||
| configure | ||
| configure.ac | ||
| COPYRIGHT | ||
| GNUmakefile.in | ||
| HISTORY | ||
| Makefile | ||
| meson.build | ||
| meson_options.txt | ||
| README.md | ||
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.