mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add a materialized view relations.
A materialized view has a rule just like a view and a heap and other physical properties like a table. The rule is only used to populate the table, references in queries refer to the materialized data. This is a minimal implementation, but should still be useful in many cases. Currently data is only populated "on demand" by the CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW statements. It is expected that future releases will add incremental updates with various timings, and that a more refined concept of defining what is "fresh" data will be developed. At some point it may even be possible to have queries use a materialized in place of references to underlying tables, but that requires the other above-mentioned features to be working first. Much of the documentation work by Robert Haas. Review by Noah Misch, Thom Brown, Robert Haas, Marko Tiikkaja Security review by KaiGai Kohei, with a decision on how best to implement sepgsql still pending.
This commit is contained in:
@@ -1032,6 +1032,7 @@ _copyIntoClause(const IntoClause *from)
|
||||
COPY_SCALAR_FIELD(onCommit);
|
||||
COPY_STRING_FIELD(tableSpaceName);
|
||||
COPY_SCALAR_FIELD(skipData);
|
||||
COPY_SCALAR_FIELD(relkind);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@@ -1970,6 +1971,7 @@ _copyRangeTblEntry(const RangeTblEntry *from)
|
||||
COPY_SCALAR_FIELD(rtekind);
|
||||
COPY_SCALAR_FIELD(relid);
|
||||
COPY_SCALAR_FIELD(relkind);
|
||||
COPY_SCALAR_FIELD(isResultRel);
|
||||
COPY_NODE_FIELD(subquery);
|
||||
COPY_SCALAR_FIELD(security_barrier);
|
||||
COPY_SCALAR_FIELD(jointype);
|
||||
@@ -3228,11 +3230,23 @@ _copyCreateTableAsStmt(const CreateTableAsStmt *from)
|
||||
|
||||
COPY_NODE_FIELD(query);
|
||||
COPY_NODE_FIELD(into);
|
||||
COPY_SCALAR_FIELD(relkind);
|
||||
COPY_SCALAR_FIELD(is_select_into);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RefreshMatViewStmt *
|
||||
_copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
|
||||
{
|
||||
RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
|
||||
|
||||
COPY_SCALAR_FIELD(skipData);
|
||||
COPY_NODE_FIELD(relation);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static CreateSeqStmt *
|
||||
_copyCreateSeqStmt(const CreateSeqStmt *from)
|
||||
{
|
||||
@@ -4303,6 +4317,9 @@ copyObject(const void *from)
|
||||
case T_CreateTableAsStmt:
|
||||
retval = _copyCreateTableAsStmt(from);
|
||||
break;
|
||||
case T_RefreshMatViewStmt:
|
||||
retval = _copyRefreshMatViewStmt(from);
|
||||
break;
|
||||
case T_CreateSeqStmt:
|
||||
retval = _copyCreateSeqStmt(from);
|
||||
break;
|
||||
|
@@ -124,6 +124,7 @@ _equalIntoClause(const IntoClause *a, const IntoClause *b)
|
||||
COMPARE_SCALAR_FIELD(onCommit);
|
||||
COMPARE_STRING_FIELD(tableSpaceName);
|
||||
COMPARE_SCALAR_FIELD(skipData);
|
||||
COMPARE_SCALAR_FIELD(relkind);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1525,11 +1526,21 @@ _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(query);
|
||||
COMPARE_NODE_FIELD(into);
|
||||
COMPARE_SCALAR_FIELD(relkind);
|
||||
COMPARE_SCALAR_FIELD(is_select_into);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalRefreshMatViewStmt(const RefreshMatViewStmt *a, const RefreshMatViewStmt *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(skipData);
|
||||
COMPARE_NODE_FIELD(relation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b)
|
||||
{
|
||||
@@ -2223,6 +2234,7 @@ _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
|
||||
COMPARE_SCALAR_FIELD(rtekind);
|
||||
COMPARE_SCALAR_FIELD(relid);
|
||||
COMPARE_SCALAR_FIELD(relkind);
|
||||
COMPARE_SCALAR_FIELD(isResultRel);
|
||||
COMPARE_NODE_FIELD(subquery);
|
||||
COMPARE_SCALAR_FIELD(security_barrier);
|
||||
COMPARE_SCALAR_FIELD(jointype);
|
||||
@@ -2790,6 +2802,9 @@ equal(const void *a, const void *b)
|
||||
case T_CreateTableAsStmt:
|
||||
retval = _equalCreateTableAsStmt(a, b);
|
||||
break;
|
||||
case T_RefreshMatViewStmt:
|
||||
retval = _equalRefreshMatViewStmt(a, b);
|
||||
break;
|
||||
case T_CreateSeqStmt:
|
||||
retval = _equalCreateSeqStmt(a, b);
|
||||
break;
|
||||
|
@@ -893,6 +893,7 @@ _outIntoClause(StringInfo str, const IntoClause *node)
|
||||
WRITE_ENUM_FIELD(onCommit, OnCommitAction);
|
||||
WRITE_STRING_FIELD(tableSpaceName);
|
||||
WRITE_BOOL_FIELD(skipData);
|
||||
WRITE_CHAR_FIELD(relkind);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2351,6 +2352,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
|
||||
case RTE_RELATION:
|
||||
WRITE_OID_FIELD(relid);
|
||||
WRITE_CHAR_FIELD(relkind);
|
||||
WRITE_BOOL_FIELD(isResultRel);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
WRITE_NODE_FIELD(subquery);
|
||||
|
@@ -395,6 +395,7 @@ _readIntoClause(void)
|
||||
READ_ENUM_FIELD(onCommit, OnCommitAction);
|
||||
READ_STRING_FIELD(tableSpaceName);
|
||||
READ_BOOL_FIELD(skipData);
|
||||
READ_CHAR_FIELD(relkind);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
@@ -1190,6 +1191,7 @@ _readRangeTblEntry(void)
|
||||
case RTE_RELATION:
|
||||
READ_OID_FIELD(relid);
|
||||
READ_CHAR_FIELD(relkind);
|
||||
READ_BOOL_FIELD(isResultRel);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
READ_NODE_FIELD(subquery);
|
||||
|
Reference in New Issue
Block a user