From 698fa924b11a4ff55ac83b340dbae1e6cee00e59 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 24 Nov 2025 17:00:16 -0500 Subject: 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 Reviewed-by: Jim Jones Discussion: https://postgr.es/m/19cf6ae1-04cd-422c-a760-d7e75fe6cba9@uni-muenster.de --- src/include/parser/parse_relation.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/include/parser/parse_relation.h') diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index d59599cf242..aceb43f995a 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -127,6 +127,5 @@ extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK); extern const NameData *attnumAttName(Relation rd, int attid); extern Oid attnumTypeId(Relation rd, int attid); extern Oid attnumCollationId(Relation rd, int attid); -extern bool isQueryUsingTempRelation(Query *query); #endif /* PARSE_RELATION_H */ -- cgit v1.2.3