mirror of
https://github.com/postgres/postgres.git
synced 2025-08-15 14:02:29 +03:00
Move materialized views' is-populated status into their pg_class entries.
Previously this state was represented by whether the view's disk file had zero or nonzero size, which is problematic for numerous reasons, since it's breaking a fundamental assumption about heap storage. This was done to allow unlogged matviews to revert to unpopulated status after a crash despite our lack of any ability to update catalog entries post-crash. However, this poses enough risk of future problems that it seems better to not support unlogged matviews until we can find another way. Accordingly, revert that choice as well as a number of existing kluges forced by it in favor of creating a pg_class.relispopulated flag column.
This commit is contained in:
@@ -359,10 +359,6 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
|
||||
*/
|
||||
intoRelationDesc = heap_open(intoRelationId, AccessExclusiveLock);
|
||||
|
||||
if (is_matview && !into->skipData)
|
||||
/* Make sure the heap looks good even if no rows are written. */
|
||||
SetMatViewToPopulated(intoRelationDesc);
|
||||
|
||||
/*
|
||||
* Check INSERT permission on the constructed table.
|
||||
*
|
||||
@@ -381,6 +377,13 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
|
||||
|
||||
ExecCheckRTPerms(list_make1(rte), true);
|
||||
|
||||
/*
|
||||
* Tentatively mark the target as populated, if it's a matview and we're
|
||||
* going to fill it; otherwise, no change needed.
|
||||
*/
|
||||
if (is_matview && !into->skipData)
|
||||
SetMatViewPopulatedState(intoRelationDesc, true);
|
||||
|
||||
/*
|
||||
* Fill private fields of myState for use by later routines
|
||||
*/
|
||||
|
Reference in New Issue
Block a user