mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
To perform cross-type index scans with a timestamp index and a timestamptz comparison value, btree_gin must convert the timestamptz to timestamp to establish the starting point for the indexscan. This is hazardous because timestamp_cmp_timestamptz is actually defined to upconvert the timestamp to timestamptz and then compare timestamptz's. When dealing with ambiguous timestamps near a fall-back DST transition, the value may not round-trip, leading to selecting a scan start point that misses some index entries that should match. To fix that, move the converted value back an hour at a time until it's clearly <= the given comparison value. (We could try to be smarter, but this way seems more certain to work across all possible DST behaviors.) Another hazard is that for timestamptz's that are finite but close to the upper range limit, the conversion may produce timestamp +Infinity, again comparing greater than the given value. It's less clear whether this can lead to missing matching values in practice, but it would at least risk making the aforesaid correction loop very slow. So replace +Infinity by the maximum finite timestamp. The reverse case of timestamptz index and timestamp comparison value is not at risk because upconverting the timestamp stays consistent with what timestamptz_cmp_timestamp will do. Also, while date-vs-timestamptz could theoretically be at risk, the conversion error would have to be a full day which seems not to occur in reality. Author: shihao zhong <zhong950419@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAGRkXqQio=7PWgTfKvjyQY9-7A_0A36E3put1gxJeDypgqFSzw@mail.gmail.com Backpatch-through: 19
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.