Improve detection of implicitly-temporary views. We've long had a practice of making views temporary by default if they reference any temporary tables. However the implementation was pretty incomplete, in that it only searched for RangeTblEntry references to temp relations. Uses of temporary types, regclass constants, etc were not detected even though the dependency mechanism considers them grounds for dropping the view. Thus a view not believed to be temp could silently go away at session exit anyhow.
To improve matters, replace the ad-hoc isQueryUsingTempRelation() logic with use of the dependency-based infrastructure introduced by commit 572c40ba9. This is complete by definition, and it's less code overall. While we're at it, we can also extend the warning NOTICE (or ERROR in the case of a materialized view) to mention one of the temp objects motivating the classification of the view as temp, as was done for functions in 572c40ba9. Author: Tom Lane <[email protected]> Reviewed-by: Jim Jones <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/698fa924b11a4ff55ac83b340dbae1e6cee00e59 Modified Files -------------- src/backend/catalog/dependency.c | 25 +++++++++++++++ src/backend/commands/view.c | 8 +++-- src/backend/parser/analyze.c | 9 ++++-- src/backend/parser/parse_relation.c | 51 ------------------------------ src/include/catalog/dependency.h | 2 ++ src/include/parser/parse_relation.h | 1 - src/test/regress/expected/create_view.out | 21 ++++++++++-- src/test/regress/expected/groupingsets.out | 1 + src/test/regress/expected/matview.out | 5 +++ src/test/regress/expected/window.out | 1 + src/test/regress/sql/create_view.sql | 4 +-- src/test/regress/sql/matview.sql | 4 +++ 12 files changed, 71 insertions(+), 61 deletions(-)
