postgresql/src/backend/commands
Tom Lane 46e3442c9e Fix failures in validateForeignKeyConstraint's slow path.
The foreign-key-checking loop in ATRewriteTables failed to ignore
relations without storage (e.g., partitioned tables), unlike the
initial loop.  This accidentally worked as long as RI_Initial_Check
succeeded, which it does in most practical cases (including all the
ones exercised in the existing regression tests :-().  However, if
that failed, as for instance when there are permissions issues,
then we entered the slow fire-the-trigger-on-each-tuple path.
And that would try to read from the referencing relation, and fail
if it lacks storage.

A second problem, recently introduced in HEAD, was that this loop
had been broken by sloppy refactoring for the tableam API changes.

Repair both issues, and add a regression test case so we have some
coverage on this code path.  Back-patch as needed to v11.

(It looks like this code could do with additional bulletproofing,
but let's get a working test case in place first.)

Hadi Moshayedi, Tom Lane, Andres Freund

Discussion: https://postgr.es/m/CAK=1=WrnNmBbe5D9sm3t0a6dnAq3cdbF1vXY816j1wsMqzC8bw@mail.gmail.com
Discussion: https://postgr.es/m/19030.1554574075@sss.pgh.pa.us
Discussion: https://postgr.es/m/20190325180405.jytoehuzkeozggxx%40alap3.anarazel.de
2019-04-06 15:09:09 -04:00
..
Makefile Move vacuumlazy.c into access/heap. 2019-01-15 12:06:19 -08:00
aggregatecmds.c Implement OR REPLACE option for CREATE AGGREGATE. 2019-03-19 01:16:50 +00:00
alter.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
amcmds.c Harden tableam against nonexistant / wrong kind of AMs. 2019-04-04 17:39:39 -07:00
analyze.c tableam: VACUUM and ANALYZE support. 2019-03-30 19:25:58 -07:00
async.c Move remaining code from tqual.[ch] to heapam.h / heapam_visibility.c. 2019-01-21 17:07:10 -08:00
cluster.c tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. 2019-03-28 20:01:43 -07:00
collationcmds.c Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
comment.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
constraint.c tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
conversioncmds.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
copy.c Remove unused struct member, enforce multi_insert callback presence. 2019-04-04 17:39:39 -07:00
createas.c tableam: Add table_finish_bulk_insert(). 2019-04-01 14:41:42 -07:00
dbcommands.c Refactor the fsync queue for wider use. 2019-04-04 23:38:38 +13:00
define.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
discard.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
dropcmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
event_trigger.c Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
explain.c Add SETTINGS option to EXPLAIN, to print modified settings. 2019-04-04 00:04:31 +02:00
extension.c Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
foreigncmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
functioncmds.c Create the infrastructure for planner support functions. 2019-02-09 18:08:48 -05:00
indexcmds.c Report progress of CREATE INDEX operations 2019-04-02 15:18:08 -03:00
lockcmds.c Adjust gratuitously different error message wording 2019-02-11 14:01:05 +01:00
matview.c tableam: Add table_finish_bulk_insert(). 2019-04-01 14:41:42 -07:00
opclasscmds.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
operatorcmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
policy.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
portalcmds.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
prepare.c Refactor ParamListInfo initialization 2019-03-14 13:30:09 +01:00
proclang.c Remove unnecessary use of PROCEDURAL 2019-02-25 08:38:59 +01:00
publicationcmds.c Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
schemacmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
seclabel.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
sequence.c tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. 2019-03-28 20:01:43 -07:00
statscmds.c Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
subscriptioncmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
tablecmds.c Fix failures in validateForeignKeyConstraint's slow path. 2019-04-06 15:09:09 -04:00
tablespace.c tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
trigger.c Generated columns 2019-03-30 08:15:57 +01:00
tsearchcmds.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
typecmds.c Generated columns 2019-03-30 08:15:57 +01:00
user.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
vacuum.c Allow VACUUM to be run with index cleanup disabled. 2019-04-04 15:04:43 -04:00
variable.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
view.c Fix CREATE VIEW to allow zero-column views. 2019-02-17 12:37:31 -05:00