postgresql/contrib
Tom Lane 0663382c9b Fix btree_gist's NotEqual strategy on internal index pages.
gbt_var_consistent() handled the <> (BtreeGistNotEqual) strategy without
distinguishing leaf from internal pages, unlike every other strategy.
In particular, it tried to apply the datatype-specific f_eq method,
which is completely wrong since internal keys might not have the same
representation as leaf keys.  This led to OOB reads and potentially
crashes, and most likely to wrong query results as well.

On leaf pages we can apply the inverse of what the Equal strategy does.
On internal pages, use a correct implementation of what the previous
code intended: we can descend if the query value equals both bounds,
*so long as the bounds aren't truncated*.  With truncated bounds we
don't quite know the range of what's below, so we must always descend.

Adjust the code in gbt_num_consistent() to look similar, too.  This
fixes a performance buglet in that there's no need to do two comparisons
on a leaf entry, but the main point is just to keep code consistency.

Reported-by: 王跃林 <violin0613@tju.edu.cn>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/AH*AvQCYKhQGVvPWi1GiU4oY.8.1781609375063.Hmail.3020001251@tju.edu.cn
Backpatch-through: 14
2026-07-03 13:50:14 -04:00
..
adminpack Use "data directory" not "current directory" in error messages. 2023-03-16 12:04:08 -04:00
amcheck amcheck: Use correct varlena size accessor in bt_normalize_tuple() 2026-06-14 04:07:42 +03:00
auth_delay Fix copy-pasto in contrib/auth_delay/meson.build variable name. 2023-04-02 09:31:10 -07:00
auto_explain Allow resetting unknown custom GUCs with reserved prefixes. 2025-08-01 16:52:11 -05:00
basebackup_to_shell Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
basic_archive basic_archive: Allow archive directory to be missing at startup. 2026-03-02 13:12:25 -06:00
bloom Count contrib/bloom index scans in pgstat view. 2024-11-12 20:57:41 -05:00
bool_plperl Update copyright for 2023 2023-01-02 15:00:37 -05:00
btree_gin btree_gin: Fix calculation of leftmost interval value. 2023-10-29 11:14:36 +00:00
btree_gist Fix btree_gist's NotEqual strategy on internal index pages. 2026-07-03 13:50:14 -04:00
citext Skip citext_utf8 test on Windows. 2024-08-02 10:03:45 +12:00
cube Rework pg_input_error_message(), now renamed pg_input_error_info() 2023-02-28 08:04:13 +09:00
dblink Avoid resource leaks when a dblink connection fails. 2025-05-29 10:39:55 -04:00
dict_int Update copyright for 2023 2023-01-02 15:00:37 -05:00
dict_xsyn Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:29:15 +13:00
earthdistance contrib/earthdistance: Use SQL-standard function bodies. 2024-12-14 16:07:18 -05:00
file_fdw Fix bogus ctid requirement for dummy-root partitioned targets 2026-01-23 10:23:18 +09:00
fuzzystrmatch Ensure Soundex difference() function handles empty input sanely. 2023-05-16 10:53:42 -04:00
hstore hstore: Fix NULL pointer dereference with receive function 2026-02-17 08:41:34 +09:00
hstore_plperl hstore_plperl: Add CHECK_FOR_INTERRUPTS() in reference-unwinding loop. 2026-06-18 12:22:55 -04:00
hstore_plpython plpython: Fix NULL pointer dereferences for broken sequence and mapping objects 2026-06-29 11:41:50 +09:00
intagg Update copyright for 2023 2023-01-02 15:00:37 -05:00
intarray Fix missed ReleaseVariableStats() in intarray's _int_matchsel(). 2026-05-25 18:15:49 -04:00
isn Rework pg_input_error_message(), now renamed pg_input_error_info() 2023-02-28 08:04:13 +09:00
jsonb_plperl jsonb_plperl, jsonb_plpython: Fix unguarded recursion and loops. 2026-06-17 11:04:41 -04:00
jsonb_plpython plpython: Fix NULL pointer dereferences for broken sequence and mapping objects 2026-06-29 11:41:50 +09:00
lo Repair incorrect handling of AfterTriggerSharedData.ats_modifiedcols. 2025-01-22 11:58:20 -05:00
ltree Fix int32 overflow in ltree_compare() 2026-06-16 09:31:17 +03:00
ltree_plpython Update copyright for 2023 2023-01-02 15:00:37 -05:00
oid2name Mark options as deprecated in usage output 2023-03-02 14:36:37 +01:00
old_snapshot Update copyright for 2023 2023-01-02 15:00:37 -05:00
pageinspect Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:29:15 +13:00
passwordcheck Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_buffercache Add CHECK_FOR_INTERRUPTS in contrib/pg_buffercache functions. 2025-08-19 12:11:34 -07:00
pg_freespacemap Prevent assertion failure in contrib/pg_freespacemap. 2025-03-27 13:20:23 -04:00
pg_prewarm Allow role created by new test to log in on Windows. 2025-10-18 18:36:21 -04:00
pg_stat_statements Avoid memory leak on error while parsing pg_stat_statements dump file 2026-03-27 12:21:48 +02:00
pg_surgery pg_surgery: Fix off-by-one bug with heap offset 2026-06-06 08:16:43 +09:00
pg_trgm Code coverage for most pg_mblen* calls. 2026-02-09 12:29:41 +13:00
pg_visibility Restore smgrtruncate() prototype in back-branches. 2025-01-08 10:46:45 +13:00
pg_walinspect Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
pgcrypto pgcrypto: Tweak error message for incorrect session key length 2026-02-16 12:18:31 +09:00
pgrowlocks Adjust the order of the prechecks in pgrowlocks() 2023-10-31 16:42:35 +13:00
pgstattuple pgstattuple: Improve reports generated for indexes (hash, gist, btree) 2025-10-02 11:09:13 +09:00
postgres_fdw postgres_fdw: Fix handling of abort-cleanup-failed connections. 2026-05-05 18:55:04 +09:00
seg seg: Fix seg_out() to preserve the upper boundary's certainty indicator 2026-06-11 12:34:37 +03:00
sepgsql meson: Fix sepgsql installation 2025-01-24 10:55:24 +01:00
spi refint: Remove plan cache. 2026-06-05 12:08:05 -05:00
sslinfo Fix compilation with OpenSSL 4 2026-06-12 13:57:22 +02:00
start-scripts Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
tablefunc Update copyright for 2023 2023-01-02 15:00:37 -05:00
tcn Update copyright for 2023 2023-01-02 15:00:37 -05:00
test_decoding Fix re-distributing previously distributed invalidation messages during logical decoding. 2025-06-16 17:35:55 -07:00
tsm_system_rows Update copyright for 2023 2023-01-02 15:00:37 -05:00
tsm_system_time Update copyright for 2023 2023-01-02 15:00:37 -05:00
unaccent Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:29:15 +13:00
uuid-ossp New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
vacuumlo Update copyright for 2023 2023-01-02 15:00:37 -05:00
xml2 xml2: Fix crash with namespace nodes in xpath_nodeset() 2026-06-11 14:29:26 +09:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00
Makefile Revert "Rename contrib module basic_archive to basic_wal_module" 2023-01-26 09:13:39 +09:00
meson.build Revert "Rename contrib module basic_archive to basic_wal_module" 2023-01-26 09:13:39 +09:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.