postgresql/src/include/parser
Tom Lane ad77039fad Calculate extraUpdatedCols in query rewriter, not parser.
It's unsafe to do this at parse time because addition of generated
columns to a table would not invalidate stored rules containing
UPDATEs on the table ... but there might now be dependent generated
columns that were not there when the rule was made.  This also fixes
an oversight that rewriteTargetView failed to update extraUpdatedCols
when transforming an UPDATE on an updatable view.  (Since the new
calculation is downstream of that, rewriteTargetView doesn't actually
need to do anything; but before, there was a demonstrable bug there.)

In v13 and HEAD, this leads to easily-visible bugs because (since
commit c6679e4fc) we won't recalculate generated columns that aren't
listed in extraUpdatedCols.  In v12 this bitmap is mostly just used
for trigger-firing decisions, so you'd only notice a problem if a
trigger cared whether a generated column had been updated.

I'd complained about this back in May, but then forgot about it
until bug #16671 from Michael Paul Killian revived the issue.

Back-patch to v12 where this field was introduced.  If existing
stored rules contain any extraUpdatedCols values, they'll be
ignored because the rewriter will overwrite them, so the bug will
be fixed even for existing rules.  (But note that if someone were
to update to 13.1 or 12.5, store some rules with UPDATEs on tables
having generated columns, and then downgrade to a prior minor version,
they might observe issues similar to what this patch fixes.  That
seems unlikely enough to not be worth going to a lot of effort to fix.)

Discussion: https://postgr.es/m/10206.1588964727@sss.pgh.pa.us
Discussion: https://postgr.es/m/16671-2fa55851859fb166@postgresql.org
2020-10-28 13:47:02 -04:00
..
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
analyze.h Calculate extraUpdatedCols in query rewriter, not parser. 2020-10-28 13:47:02 -04:00
gramparse.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
kwlist.h Allow most keywords to be used as column labels without requiring AS. 2020-09-18 16:46:36 -04:00
parse_agg.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_clause.h Support FETCH FIRST WITH TIES 2020-04-07 16:22:13 -04:00
parse_coerce.h Add select_common_typmod() 2020-10-27 18:10:42 +01:00
parse_collate.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_cte.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_enr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_expr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_func.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_node.h Go back to returning int from ereport auxiliary functions. 2020-03-25 11:57:36 -04:00
parse_oper.h Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
parse_param.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_relation.h Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
parse_target.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_type.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_utilcmd.h Fix handling of CREATE TABLE LIKE with inheritance. 2020-08-21 15:00:47 -04:00
parser.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parsetree.h Make parser rely more heavily on the ParseNamespaceItem data structure. 2020-01-02 11:29:01 -05:00
scanner.h Go back to returning int from ereport auxiliary functions. 2020-03-25 11:57:36 -04:00
scansup.h Make postgres.bki use the same literal-string syntax as postgresql.conf. 2020-10-04 16:09:55 -04:00