postgresql/src/test/regress
Tom Lane 7421f4b89a Fix incorrect handling of CTEs and ENRs as DML target relations.
setTargetTable threw an error if the proposed target RangeVar's relname
matched any visible CTE or ENR.  This breaks backwards compatibility in
the CTE case, since pre-v10 we never looked for a CTE here at all, so that
CTE names did not mask regular tables.  It does seem like a good idea to
throw an error for the ENR case, though, thus causing ENRs to mask tables
for this purpose; ENRs are new in v10 so we're not breaking existing code,
and we may someday want to allow them to be the targets of DML.

To fix that, replace use of getRTEForSpecialRelationTypes, which was
overkill anyway, with use of scanNameSpaceForENR.

A second problem was that the check neglected to verify null schemaname,
so that a CTE or ENR could incorrectly be thought to match a qualified
RangeVar.  That happened because getRTEForSpecialRelationTypes relied
on its caller to have checked for null schemaname.  Even though the one
remaining caller got it right, this is obviously bug-prone, so move
the check inside getRTEForSpecialRelationTypes.

Also, revert commit 18ce3a4ab's extremely poorly thought out decision to
add a NULL return case to parserOpenTable --- without either documenting
that or adjusting any of the callers to check for it.  The current bug
seems to have arisen in part due to working around that bad idea.

In passing, remove the one-line shim functions transformCTEReference and
transformENRReference --- they don't seem to be adding any clarity or
functionality.

Per report from Hugo Mercier (via Julien Rouhaud).  Back-patch to v10
where the bug was introduced.

Thomas Munro, with minor editing by me

Discussion: https://postgr.es/m/CAOBaU_YdPVH+PTtiKSSLOiiW3mVDYsnNUekK+XPbHXiP=wrFLA@mail.gmail.com
2017-10-16 17:56:54 -04:00
..
data Improve key representation for GIN jsonb_ops, and fix existence-search bug. 2014-05-09 08:41:26 -04:00
expected Fix incorrect handling of CTEs and ENRs as DML target relations. 2017-10-16 17:56:54 -04:00
input Test coverage for CREATE/ALTER FOREIGN DATA WRAPPER .. HANDLER. 2017-09-15 08:07:22 -04:00
output Test coverage for CREATE/ALTER FOREIGN DATA WRAPPER .. HANDLER. 2017-09-15 08:07:22 -04:00
sql Fix incorrect handling of CTEs and ENRs as DML target relations. 2017-10-16 17:56:54 -04:00
.gitignore Update .gitignore for config.cache. 2014-12-18 19:56:42 +09:00
GNUmakefile Enforce our convention about max number of parallel regression tests. 2017-10-07 17:20:09 -04:00
Makefile Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
parallel_schedule Clean up sloppy maintenance of regression test schedule files. 2017-10-07 13:19:13 -04:00
pg_regress_main.c Fix inclusions of postgres_fe.h from .h files. 2017-03-08 20:41:06 -05:00
pg_regress.c Add missing options to pg_regress help() output 2017-10-13 16:06:41 -07:00
pg_regress.h Initial pgindent run with pg_bsd_indent version 2.0. 2017-06-21 14:39:04 -04:00
README Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:04 -05:00
regress.c Document and use SPI_result_code_string() 2017-10-04 22:14:21 -04:00
regressplans.sh Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00
resultmap Enable compiling with the mingw-w64 32 bit compiler. 2011-12-10 15:35:41 -05:00
serial_schedule Clean up sloppy maintenance of regression test schedule files. 2017-10-07 13:19:13 -04:00
standby_schedule Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00

Documentation concerning how to run these regression tests and interpret
the results can be found in the PostgreSQL manual, in the chapter
"Regression Tests".