postgresql/src/backend/utils
Tom Lane 628cbb50ba Re-implement extraction of fixed prefixes from regular expressions.
To generate btree-indexable conditions from regex WHERE conditions (such as
WHERE indexed_col ~ '^foo'), we need to be able to identify any fixed
prefix that a regex might have; that is, find any string that must be a
prefix of all strings satisfying the regex.  We used to do that with
entirely ad-hoc code that looked at the source text of the regex.  It
didn't know very much about regex syntax, which mostly meant that it would
fail to identify some optimizable cases; but Viktor Rosenfeld reported that
it would produce actively wrong answers for quantified parenthesized
subexpressions, such as '^(foo)?bar'.  Rather than trying to extend the
ad-hoc code to cover this, let's get rid of it altogether in favor of
identifying prefixes by examining the compiled form of a regex.

To do this, I've added a new entry point "pg_regprefix" to the regex library;
hopefully it is defined in a sufficiently general fashion that it can remain
in the library when/if that code gets split out as a standalone project.

Since this bug has been there for a very long time, this fix needs to get
back-patched.  However it depends on some other recent commits (particularly
the addition of wchar-to-database-encoding conversion), so I'll commit this
separately and then go to work on back-porting the necessary fixes.
2012-07-10 14:54:37 -04:00
..
adt Re-implement extraction of fixed prefixes from regular expressions. 2012-07-10 14:54:37 -04:00
cache Fix race condition in enum value comparisons. 2012-07-01 17:12:49 -04:00
error Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
fmgr Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
hash Move CRC tables to libpgport, and provide them in a separate include file. 2012-02-28 19:53:39 -05:00
init Tighten up includes in sinvaladt.h, twophase.h, proc.h 2012-06-25 18:40:40 -04:00
mb Fix failure of new wchar->mb functions to advance from pointer. 2012-07-05 23:47:53 -04:00
misc Assorted message style improvements 2012-07-02 21:12:46 +03:00
mmgr Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
resowner Add a small cache of locks owned by a resource owner in ResourceOwner. 2012-06-21 15:30:26 +03:00
sort Run newly-configured perltidy script on Perl files. 2012-07-04 21:47:49 -04:00
time Assorted message style improvements 2012-07-02 21:12:46 +03:00
.gitignore Avoid maintaining three separate copies of the error codes list. 2011-02-03 22:32:49 -05:00
Gen_dummy_probes.sed Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
Gen_fmgrtab.pl Run updated copyright.pl on HEAD and 9.2 trees, updating the psql 2012-07-06 12:28:18 -04:00
Makefile Make handling of errcodes.h more consistent with other generated headers. 2011-02-04 09:29:10 -05:00
errcodes.txt Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
generate-errcodes.pl Run newly-configured perltidy script on Perl files. 2012-07-04 21:47:49 -04:00
probes.d Make group commit more effective. 2012-01-30 16:53:48 +02:00