postgresql/src/test/modules
Tom Lane 4aea704a5b Fix semantics of regular expression back-references.
POSIX defines the behavior of back-references thus:

    The back-reference expression '\n' shall match the same (possibly
    empty) string of characters as was matched by a subexpression
    enclosed between "\(" and "\)" preceding the '\n'.

As far as I can see, the back-reference is supposed to consider only
the data characters matched by the referenced subexpression.  However,
because our engine copies the NFA constructed from the referenced
subexpression, it effectively enforces any constraints therein, too.
As an example, '(^.)\1' ought to match 'xx', or any other string
starting with two occurrences of the same character; but in our code
it does not, and indeed can't match anything, because the '^' anchor
constraint is included in the backref's copied NFA.  If POSIX intended
that, you'd think they'd mention it.  Perl for one doesn't act that
way, so it's hard to conclude that this isn't a bug.

Fix by modifying the backref's NFA immediately after it's copied from
the reference, replacing all constraint arcs by EMPTY arcs so that the
constraints are treated as automatically satisfied.  This still allows
us to enforce matching rules that depend only on the data characters;
for example, in '(^\d+).*\1' the NFA matching step will still know
that the backref can only match strings of digits.

Perhaps surprisingly, this change does not affect the results of any
of a rather large corpus of real-world regexes.  Nonetheless, I would
not consider back-patching it, since it's a clear compatibility break.

Patch by me, reviewed by Joel Jacobson

Discussion: https://postgr.es/m/661609.1614560029@sss.pgh.pa.us
2021-03-02 11:34:53 -05:00
..
brin Add a couple of missed .gitignore entries. 2020-12-18 16:24:49 -05:00
commit_ts Fix timestamp range handling in regression tests of modules/commit_ts/ 2020-07-13 10:54:26 +09:00
delay_execution Update copyright for 2021 2021-01-02 13:06:25 -05:00
dummy_index_am Pass down "logically unchanged index" hint. 2021-01-13 08:11:00 -08:00
dummy_seclabel Update copyright for 2021 2021-01-02 13:06:25 -05:00
plsample Update copyright for 2021 2021-01-02 13:06:25 -05:00
snapshot_too_old Add a couple of missed .gitignore entries. 2020-12-18 16:24:49 -05:00
ssl_passphrase_callback Introduce --with-ssl={openssl} as a configure option 2021-02-01 19:19:44 +09:00
test_bloomfilter Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_ddl_deparse Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_extensions Fix use-after-free bug with event triggers in an extension script 2020-09-15 21:03:14 -03:00
test_ginpostinglist Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_integerset Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_misc Message fixes and style improvements 2020-09-14 06:42:30 +02:00
test_parser Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_pg_dump Fix pg_dump for GRANT OPTION among initial privileges. 2021-01-16 12:21:35 -08:00
test_predtest Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_rbtree Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_regex Fix semantics of regular expression back-references. 2021-03-02 11:34:53 -05:00
test_rls_hooks Update copyright for 2021 2021-01-02 13:06:25 -05:00
test_shm_mq Update copyright for 2021 2021-01-02 13:06:25 -05:00
unsafe_tests Add primary keys and unique constraints to system catalogs 2021-01-30 19:44:29 +01:00
worker_spi Update copyright for 2021 2021-01-02 13:06:25 -05:00
Makefile Introduce --with-ssl={openssl} as a configure option 2021-02-01 19:19:44 +09:00
README Add an enforcement mechanism for global object names in regression tests. 2019-06-29 11:34:00 -04:00

README

Test extensions and libraries
=============================

src/test/modules contains PostgreSQL extensions that are primarily or entirely
intended for testing PostgreSQL and/or to serve as example code. The extensions
here aren't intended to be installed in a production server and aren't suitable
for "real work".

Furthermore, while you can do "make install" and "make installcheck" in
this directory or its children, it is NOT ADVISABLE to do so with a server
containing valuable data.  Some of these tests may have undesirable
side-effects on roles or other global objects within the tested server.
"make installcheck-world" at the top level does not recurse into this
directory.

Most extensions have their own pg_regress tests or isolationtester specs. Some
are also used by tests elsewhere in the tree.

If you're adding new hooks or other functionality exposed as C-level API this
is where to add the tests for it.