diff options
author | Kevin Grittner <kgrittn@postgresql.org> | 2013-04-09 13:02:49 -0500 |
---|---|---|
committer | Kevin Grittner <kgrittn@postgresql.org> | 2013-04-09 13:02:49 -0500 |
commit | 52e6e33ab495cb2b0e694ee480ba7c6394315053 (patch) | |
tree | cf957e2ae91863e97b46f4692f09a339b5cf696f /src/backend/commands/matview.c | |
parent | 0bf42a5f3b62cde41cb366d3442585429c6d9c50 (diff) | |
download | postgresql-52e6e33ab495cb2b0e694ee480ba7c6394315053.tar.gz postgresql-52e6e33ab495cb2b0e694ee480ba7c6394315053.zip |
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.
Diffstat (limited to 'src/backend/commands/matview.c')
-rw-r--r-- | src/backend/commands/matview.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index 1d2b3478289..ac7719e40da 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -52,22 +52,21 @@ static void refresh_matview_datafill(DestReceiver *dest, Query *query, const char *queryString); /* - * SetRelationIsScannable - * Make the relation appear scannable. + * SetMatViewToPopulated + * Indicate that the materialized view has been populated by its query. * - * NOTE: This is only implemented for materialized views. The heap starts out - * in a state that doesn't look scannable, and can only transition from there - * to scannable, unless a new heap is created. + * NOTE: The heap starts out in a state that doesn't look scannable, and can + * only transition from there to scannable at the time a new heap is created. * * NOTE: caller must be holding an appropriate lock on the relation. */ void -SetRelationIsScannable(Relation relation) +SetMatViewToPopulated(Relation relation) { Page page; Assert(relation->rd_rel->relkind == RELKIND_MATVIEW); - Assert(relation->rd_isscannable == false); + Assert(relation->rd_ispopulated == false); page = (Page) palloc(BLCKSZ); PageInit(page, BLCKSZ, 0); @@ -323,7 +322,7 @@ transientrel_startup(DestReceiver *self, int operation, TupleDesc typeinfo) myState->hi_options |= HEAP_INSERT_SKIP_WAL; myState->bistate = GetBulkInsertState(); - SetRelationIsScannable(transientrel); + SetMatViewToPopulated(transientrel); /* Not using WAL requires smgr_targblock be initially invalid */ Assert(RelationGetTargetBlock(transientrel) == InvalidBlockNumber); |