1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00
Tom Lane 16500d2278 Fix contrib/pg_trgm's extraction of trigrams from regular expressions.
The logic for removing excess trigrams from the result was faulty.
It intends to avoid merging the initial and final states of the NFA,
which is necessary, but in testing whether removal of a specific trigram
would cause that, it failed to consider the combined effects of all the
state merges that that trigram's removal would cause.  This could result
in a broken final graph that would never match anything, leading to GIN
or GiST indexscans not finding anything.

To fix, add a "tentParent" field that is used only within this loop,
and set it to show state merges that we are tentatively going to do.
While examining a particular arc, we must chase up through tentParent
links as well as regular parent links (the former can only appear atop
the latter), and we must account for state init/fin flag merges that
haven't actually been done yet.

To simplify the latter, combine the separate init and fin bool fields
into a bitmap flags field.  I also chose to get rid of the "children"
state list, which seems entirely inessential.

Per bug #14563 from Alexey Isayko, which the added test cases are based on.
Back-patch to 9.3 where this code was added.

Report: https://postgr.es/m/20170222111446.1256.67547@wrigleys.postgresql.org
Discussion: https://postgr.es/m/8816.1487787594@sss.pgh.pa.us
2017-02-22 15:04:07 -05:00
..
2016-01-02 13:33:40 -05:00
2016-01-02 14:19:48 -05:00
2016-06-09 18:02:36 -04:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2016-01-02 13:33:40 -05:00
2016-01-02 13:33:40 -05:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2016-01-02 13:33:40 -05:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2017-02-06 11:34:15 +02:00
2017-02-06 12:04:28 +02:00
2017-02-06 11:34:15 +02:00
2016-09-15 12:55:38 +03:00
2017-02-06 11:34:15 +02:00
2016-04-08 21:52:13 +03:00
2017-02-06 11:34:15 +02:00
2016-01-02 13:33:40 -05:00
2016-01-02 13:33:40 -05:00
2016-01-02 13:33:40 -05:00
2017-02-06 11:34:15 +02:00
2016-04-01 16:42:24 +03: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.