Add a materialized view relations.

Kevin Grittner <kgrittn@postgresql.org>

Commit: 3bf3ab8c563699138be02f9dc305b7b77a724307
Author: Kevin Grittner <kgrittn@postgresql.org>
Date: 2013-03-04T00:23:31Z
Releases: 9.3.0
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.

Files

PathChange+/−
contrib/oid2name/oid2name.c modified +2 −2
contrib/pgstattuple/pgstattuple.c modified +1 −0
contrib/pg_upgrade/info.c modified +1 −1
contrib/pg_upgrade/pg_upgrade.c modified +2 −2
contrib/pg_upgrade/version_old_8_3.c modified +3 −0
contrib/vacuumlo/vacuumlo.c modified +1 −1
doc/src/sgml/catalogs.sgml modified +5 −4
doc/src/sgml/func.sgml modified +16 −7
doc/src/sgml/ref/allfiles.sgml modified +4 −0
doc/src/sgml/ref/alter_extension.sgml modified +1 −0
doc/src/sgml/ref/alter_materialized_view.sgml added +167 −0
doc/src/sgml/ref/comment.sgml modified +2 −0
doc/src/sgml/ref/create_index.sgml modified +2 −2
doc/src/sgml/ref/create_materialized_view.sgml added +154 −0
doc/src/sgml/ref/create_table_as.sgml modified +1 −0
doc/src/sgml/ref/create_view.sgml modified +1 −0
doc/src/sgml/ref/drop_materialized_view.sgml added +114 −0
doc/src/sgml/reference.sgml modified +4 −0
doc/src/sgml/ref/refresh_materialized_view.sgml added +113 −0
doc/src/sgml/ref/security_label.sgml modified +1 −0
doc/src/sgml/rules.sgml modified +200 −0
src/backend/access/common/reloptions.c modified +2 −0
src/backend/access/heap/heapam.c modified +6 −3
src/backend/access/heap/tuptoaster.c modified +6 −4
src/backend/catalog/aclchk.c modified +2 −0
src/backend/catalog/dependency.c modified +4 −0
src/backend/catalog/heap.c modified +28 −3
src/backend/catalog/objectaddress.c modified +9 −0
src/backend/catalog/system_views.sql modified +20 −6
src/backend/catalog/toasting.c modified +3 −2
src/backend/commands/alter.c modified +2 −0
src/backend/commands/analyze.c modified +5 −4
src/backend/commands/cluster.c modified +18 −0
src/backend/commands/comment.c modified +8 −6
src/backend/commands/copy.c modified +11 −0
src/backend/commands/createas.c modified +112 −25
src/backend/commands/event_trigger.c modified +2 −0
src/backend/commands/explain.c modified +15 −20
src/backend/commands/indexcmds.c modified +4 −2
src/backend/commands/Makefile modified +1 −1
src/backend/commands/matview.c added +374 −0
src/backend/commands/prepare.c modified +1 −1
src/backend/commands/seclabel.c modified +3 −2
src/backend/commands/tablecmds.c modified +124 −34
src/backend/commands/typecmds.c modified +2 −1
src/backend/commands/vacuum.c modified +13 −8
src/backend/commands/view.c modified +13 −55
src/backend/executor/execMain.c modified +80 −0
src/backend/executor/spi.c modified +7 −0
src/backend/nodes/copyfuncs.c modified +17 −0
src/backend/nodes/equalfuncs.c modified +15 −0
src/backend/nodes/outfuncs.c modified +2 −0
src/backend/nodes/readfuncs.c modified +2 −0
src/backend/optimizer/plan/planner.c modified +1 −1
src/backend/optimizer/util/plancat.c modified +1 −0
src/backend/parser/analyze.c modified +26 −1
src/backend/parser/gram.y modified +175 −6
src/backend/parser/parse_utilcmd.c modified +6 −0
src/backend/postmaster/autovacuum.c modified +11 −11
src/backend/postmaster/pgstat.c modified +1 −0
src/backend/rewrite/rewriteDefine.c modified +5 −2
src/backend/rewrite/rewriteDefine.c.orig added +945 −0
src/backend/rewrite/rewriteHandler.c modified +19 −1
src/backend/storage/lmgr/predicate.c modified +3 −2
src/backend/tcop/dest.c modified +7 −0
src/backend/tcop/utility.c modified +43 −7
src/backend/utils/adt/dbsize.c modified +24 −0
src/backend/utils/adt/xml.c modified +2 −2
src/backend/utils/cache/relcache.c modified +26 −0
src/bin/initdb/initdb.c modified +1 −1
src/bin/pg_dump/common.c modified +4 −2
src/bin/pg_dump/pg_backup_archiver.c modified +3 −1
src/bin/pg_dump/pg_dump.c modified +318 −101
src/bin/pg_dump/pg_dump.h modified +3 −1
src/bin/pg_dump/pg_dump_sort.c modified +12 −5
src/bin/psql/command.c modified +2 −1
src/bin/psql/describe.c modified +93 −54
src/bin/psql/help.c modified +1 −0
src/bin/psql/tab-complete.c modified +149 −27
src/include/catalog/heap.h modified +1 −0
src/include/catalog/pg_class.h modified +1 −0
src/include/catalog/pg_proc.h modified +2 −0
src/include/commands/createas.h modified +4 −0
src/include/commands/explain.h modified +2 −2
src/include/commands/matview.h added +28 −0
src/include/commands/tablecmds.h modified +2 −0
src/include/commands/view.h modified +2 −0
src/include/executor/executor.h modified +1 −0
src/include/nodes/nodes.h modified +1 −0
src/include/nodes/parsenodes.h modified +17 −1
src/include/nodes/primnodes.h modified +3 −1
src/include/parser/kwlist.h modified +2 −0
src/include/tcop/dest.h modified +2 −1
src/include/utils/builtins.h modified +1 −0
src/include/utils/rel.h modified +1 −0
src/pl/plpgsql/src/pl_comp.c modified +8 −2
src/pl/tcl/pltcl.c modified +1 −0
src/test/regress/expected/matview.out added +406 −0
src/test/regress/expected/rules.out modified +27 −7
src/test/regress/output/misc.source modified +11 −1
src/test/regress/parallel_schedule modified +1 −1
src/test/regress/serial_schedule modified +1 −0
src/test/regress/sql/matview.sql added +128 −0