postgresql/src/test
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
..
authentication Update copyright for 2021 2021-01-02 13:06:25 -05:00
examples Avoid redundantly prefixing PQerrorMessage for a connection failure. 2021-01-22 16:52:31 -05:00
isolation Fix permission checks on constraint violation errors on partitions. 2021-02-08 11:01:51 +02:00
kerberos Don't clobber the calling user's credentials cache in Kerberos test. 2021-01-25 14:53:13 -05:00
ldap Update copyright for 2021 2021-01-02 13:06:25 -05:00
locale Clean up after tests in src/test/locale/. 2020-11-28 16:08:36 -05:00
mb Fix MB regression tests for WAL-logging of hash indexes. 2017-03-15 07:25:36 -04:00
modules Fix semantics of regular expression back-references. 2021-03-02 11:34:53 -05:00
perl Update copyright for 2021 2021-01-02 13:06:25 -05:00
recovery Fix recovery test hang in 021_row_visibility.pl on windows. 2021-03-01 11:25:24 -08:00
regress Improve reporting for syntax errors in multi-line JSON data. 2021-03-01 16:44:17 -05:00
ssl Allow specifying CRL directory 2021-02-18 07:59:10 +01:00
subscription Remove the unnecessary PrepareWrite in pgoutput. 2021-02-16 07:26:50 +05:30
Makefile Introduce --with-ssl={openssl} as a configure option 2021-02-01 19:19:44 +09:00
README Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00

README

PostgreSQL tests
================

This directory contains a variety of test infrastructure as well as some of the
tests in PostgreSQL. Not all tests are here -- in particular, there are more in
individual contrib/ modules and in src/bin.

Not all these tests get run by "make check". Check src/test/Makefile to see
which tests get run automatically.

authentication/
  Tests for authentication (but see also below)

examples/
  Demonstration programs for libpq that double as regression tests via
  "make check"

isolation/
  Tests for concurrent behavior at the SQL level

kerberos/
  Tests for Kerberos/GSSAPI authentication and encryption

ldap/
  Tests for LDAP-based authentication

locale/
  Sanity checks for locale data, encodings, etc

mb/
  Tests for multibyte encoding (UTF-8) support

modules/
  Extensions used only or mainly for test purposes, generally not suitable
  for installing in production databases

perl/
  Infrastructure for Perl-based TAP tests

recovery/
  Test suite for recovery and replication

regress/
  PostgreSQL's main regression test suite, pg_regress

ssl/
  Tests to exercise and verify SSL certificate handling

subscription/
  Tests for logical replication