mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Create a distinction between a populated matview and a scannable one.
The intent was that being populated would, long term, be just one of the conditions which could affect whether a matview was scannable; being populated should be necessary but not always sufficient to scan the relation. Since only CREATE and REFRESH currently determine the scannability, names and comments accidentally conflated these concepts, leading to confusion. Also add missing locking for the SQL function which allows a test for scannability, and fix a modularity violatiion. Per complaints from Tom Lane, although its not clear that these will satisfy his concerns. Hopefully this will at least better frame the discussion.
This commit is contained in:
		@@ -83,7 +83,7 @@ typedef struct RelationData
 | 
			
		||||
	BackendId	rd_backend;		/* owning backend id, if temporary relation */
 | 
			
		||||
	bool		rd_islocaltemp; /* rel is a temp rel of this session */
 | 
			
		||||
	bool		rd_isnailed;	/* rel is nailed in cache */
 | 
			
		||||
	bool		rd_isscannable; /* rel can be scanned */
 | 
			
		||||
	bool		rd_ispopulated;	/* matview has query results */
 | 
			
		||||
	bool		rd_isvalid;		/* relcache entry is valid */
 | 
			
		||||
	char		rd_indexvalid;	/* state of rd_indexlist: 0 = not valid, 1 =
 | 
			
		||||
								 * valid, 2 = temporarily forced */
 | 
			
		||||
@@ -407,6 +407,16 @@ typedef struct StdRdOptions
 | 
			
		||||
	((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP && \
 | 
			
		||||
	 !(relation)->rd_islocaltemp)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * RelationIsScannable
 | 
			
		||||
 * 		Currently can only be false for a materialized view which has not been
 | 
			
		||||
 * 		populated by its query.  This is likely to get more complicated later,
 | 
			
		||||
 * 		so use a macro which looks like a function.
 | 
			
		||||
 */
 | 
			
		||||
#define RelationIsScannable(relation) ((relation)->rd_ispopulated)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* routines in utils/cache/relcache.c */
 | 
			
		||||
extern void RelationIncrementReferenceCount(Relation rel);
 | 
			
		||||
extern void RelationDecrementReferenceCount(Relation rel);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user