From 1d6c72a55b23554cfb946527dc77f9d80044ae2c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 6 May 2013 13:26:51 -0400 Subject: 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. --- src/include/utils/builtins.h | 1 - src/include/utils/rel.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/include/utils') diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index e71876502e1..15b60abfcd9 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -461,7 +461,6 @@ extern Datum pg_table_size(PG_FUNCTION_ARGS); extern Datum pg_indexes_size(PG_FUNCTION_ARGS); extern Datum pg_relation_filenode(PG_FUNCTION_ARGS); extern Datum pg_relation_filepath(PG_FUNCTION_ARGS); -extern Datum pg_relation_is_scannable(PG_FUNCTION_ARGS); /* genfile.c */ extern bytea *read_binary_file(const char *filename, diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 632743af943..4b833c5018c 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -77,7 +77,6 @@ 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_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 */ @@ -408,7 +407,15 @@ typedef struct StdRdOptions * 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) +#define RelationIsScannable(relation) ((relation)->rd_rel->relispopulated) + +/* + * RelationIsPopulated + * Currently, we don't physically distinguish the "populated" and + * "scannable" properties of matviews, but that may change later. + * Hence, use the appropriate one of these macros in code tests. + */ +#define RelationIsPopulated(relation) ((relation)->rd_rel->relispopulated) /* routines in utils/cache/relcache.c */ -- cgit v1.2.3