mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201304271
|
||||
#define CATALOG_VERSION_NO 201305061
|
||||
|
||||
#endif
|
||||
|
@@ -70,7 +70,6 @@ extern Oid heap_create_with_catalog(const char *relname,
|
||||
bool is_internal);
|
||||
|
||||
extern void heap_create_init_fork(Relation rel);
|
||||
extern bool heap_is_matview_init_state(Relation rel);
|
||||
|
||||
extern void heap_drop_with_catalog(Oid relid);
|
||||
|
||||
|
@@ -66,6 +66,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
|
||||
bool relhasrules; /* has (or has had) any rules */
|
||||
bool relhastriggers; /* has (or has had) any TRIGGERs */
|
||||
bool relhassubclass; /* has (or has had) derived classes */
|
||||
bool relispopulated; /* matview currently holds query results */
|
||||
TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */
|
||||
TransactionId relminmxid; /* all multixacts in this rel are >= this.
|
||||
* this is really a MultiXactId */
|
||||
@@ -93,7 +94,7 @@ typedef FormData_pg_class *Form_pg_class;
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
#define Natts_pg_class 28
|
||||
#define Natts_pg_class 29
|
||||
#define Anum_pg_class_relname 1
|
||||
#define Anum_pg_class_relnamespace 2
|
||||
#define Anum_pg_class_reltype 3
|
||||
@@ -118,10 +119,11 @@ typedef FormData_pg_class *Form_pg_class;
|
||||
#define Anum_pg_class_relhasrules 22
|
||||
#define Anum_pg_class_relhastriggers 23
|
||||
#define Anum_pg_class_relhassubclass 24
|
||||
#define Anum_pg_class_relfrozenxid 25
|
||||
#define Anum_pg_class_relminmxid 26
|
||||
#define Anum_pg_class_relacl 27
|
||||
#define Anum_pg_class_reloptions 28
|
||||
#define Anum_pg_class_relispopulated 25
|
||||
#define Anum_pg_class_relfrozenxid 26
|
||||
#define Anum_pg_class_relminmxid 27
|
||||
#define Anum_pg_class_relacl 28
|
||||
#define Anum_pg_class_reloptions 29
|
||||
|
||||
/* ----------------
|
||||
* initial contents of pg_class
|
||||
@@ -136,13 +138,13 @@ typedef FormData_pg_class *Form_pg_class;
|
||||
* Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId;
|
||||
* similarly, "1" in relminmxid stands for FirstMultiXactId
|
||||
*/
|
||||
DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 0 f f p r 30 0 t f f f f 3 1 _null_ _null_ ));
|
||||
DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 0 f f p r 30 0 t f f f f t 3 1 _null_ _null_ ));
|
||||
DESCR("");
|
||||
DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 0 f f p r 21 0 f f f f f 3 1 _null_ _null_ ));
|
||||
DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 0 f f p r 21 0 f f f f f t 3 1 _null_ _null_ ));
|
||||
DESCR("");
|
||||
DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 0 f f p r 27 0 t f f f f 3 1 _null_ _null_ ));
|
||||
DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 0 f f p r 27 0 t f f f f t 3 1 _null_ _null_ ));
|
||||
DESCR("");
|
||||
DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 0 f f p r 28 0 t f f f f 3 1 _null_ _null_ ));
|
||||
DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 0 f f p r 29 0 t f f f f t 3 1 _null_ _null_ ));
|
||||
DESCR("");
|
||||
|
||||
|
||||
|
@@ -1980,8 +1980,6 @@ DATA(insert OID = 3842 ( pg_view_is_insertable PGNSP PGUID 12 10 0 0 0 f f f f
|
||||
DESCR("is a view insertable-into");
|
||||
DATA(insert OID = 3843 ( pg_view_is_updatable PGNSP PGUID 12 10 0 0 0 f f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_view_is_updatable _null_ _null_ _null_ ));
|
||||
DESCR("is a view updatable");
|
||||
DATA(insert OID = 3846 ( pg_relation_is_scannable PGNSP PGUID 12 10 0 0 0 f f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_relation_is_scannable _null_ _null_ _null_ ));
|
||||
DESCR("is a relation scannable");
|
||||
|
||||
/* Deferrable unique constraint trigger */
|
||||
DATA(insert OID = 1250 ( unique_key_recheck PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 2279 "" _null_ _null_ _null_ _null_ unique_key_recheck _null_ _null_ _null_ ));
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "utils/relcache.h"
|
||||
|
||||
|
||||
extern void SetMatViewToPopulated(Relation relation);
|
||||
extern void SetMatViewPopulatedState(Relation relation, bool newstate);
|
||||
|
||||
extern void ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
|
||||
ParamListInfo params, char *completionTag);
|
||||
|
@@ -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,
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user