mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +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:
@ -260,6 +260,7 @@ DefineQueryRewrite(char *rulename,
|
||||
* Verify relation is of a type that rules can sensibly be applied to.
|
||||
*/
|
||||
if (event_relation->rd_rel->relkind != RELKIND_RELATION &&
|
||||
event_relation->rd_rel->relkind != RELKIND_MATVIEW &&
|
||||
event_relation->rd_rel->relkind != RELKIND_VIEW)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
@ -356,7 +357,8 @@ DefineQueryRewrite(char *rulename,
|
||||
*/
|
||||
checkRuleResultList(query->targetList,
|
||||
RelationGetDescr(event_relation),
|
||||
true);
|
||||
event_relation->rd_rel->relkind !=
|
||||
RELKIND_MATVIEW);
|
||||
|
||||
/*
|
||||
* ... there must not be another ON SELECT rule already ...
|
||||
@ -414,7 +416,8 @@ DefineQueryRewrite(char *rulename,
|
||||
* business of converting relations to views is just a kluge to allow
|
||||
* dump/reload of views that participate in circular dependencies.)
|
||||
*/
|
||||
if (event_relation->rd_rel->relkind != RELKIND_VIEW)
|
||||
if (event_relation->rd_rel->relkind != RELKIND_VIEW &&
|
||||
event_relation->rd_rel->relkind != RELKIND_MATVIEW)
|
||||
{
|
||||
HeapScanDesc scanDesc;
|
||||
|
||||
|
Reference in New Issue
Block a user