1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Make new GENERATED-expressions code more bulletproof.

In commit 8bf6ec3ba I assumed that no code path could reach
ExecGetExtraUpdatedCols without having gone through
ExecInitStoredGenerated.  That turns out not to be the case in
logical replication: if there's an ON UPDATE trigger on the target
table, trigger.c will call this code before anybody has set up its
generated columns.  Having seen that, I don't have a lot of faith in
there not being other such paths.  ExecGetExtraUpdatedCols can call
ExecInitStoredGenerated for itself, as long as we are willing to
assume that it is only called in CMD_UPDATE operations, which on
the whole seems like a safer leap of faith.

Per report from Vitaly Davydov.

Discussion: https://postgr.es/m/d259d69652b8c2ff50e14cda3c236c7f@postgrespro.ru
This commit is contained in:
Tom Lane
2023-01-15 13:14:52 -05:00
parent 1334b79a35
commit 3f244d020f
4 changed files with 50 additions and 17 deletions

View File

@ -360,7 +360,7 @@ ExecCheckTIDVisible(EState *estate,
* fields. (Currently, ri_extraUpdatedCols is consulted only in UPDATE,
* but we might as well fill it for INSERT too.)
*/
static void
void
ExecInitStoredGenerated(ResultRelInfo *resultRelInfo,
EState *estate,
CmdType cmdtype)