Skip to content

Commit 02d2b69

Browse files
committed
Update messages, comments and documentation for materialized views.
All instances of the verbiage lagging the code. Back-patch to 9.3, where materialized views were introduced.
1 parent 269e780 commit 02d2b69

File tree

15 files changed

+29
-22
lines changed

15 files changed

+29
-22
lines changed

doc/src/sgml/maintenance.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@
534534
examine this information is to execute queries such as:
535535

536536
<programlisting>
537-
SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r';
537+
SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind IN ('r', 'm');
538538
SELECT datname, age(datfrozenxid) FROM pg_database;
539539
</programlisting>
540540

src/backend/access/heap/tuptoaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
512512
bool toast_delold[MaxHeapAttributeNumber];
513513

514514
/*
515-
* We should only ever be called for tuples of plain relations ---
516-
* recursing on a toast rel is bad news.
515+
* We should only ever be called for tuples of plain relations or
516+
* materialized views --- recursing on a toast rel is bad news.
517517
*/
518518
Assert(rel->rd_rel->relkind == RELKIND_RELATION ||
519519
rel->rd_rel->relkind == RELKIND_MATVIEW);

src/backend/catalog/aclchk.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ objectsInSchemaToOids(GrantObjectType objtype, List *nspnames)
761761
switch (objtype)
762762
{
763763
case ACL_OBJECT_RELATION:
764-
/* Process regular tables, views and foreign tables */
765764
objs = getRelationsInNamespace(namespaceId, RELKIND_RELATION);
766765
objects = list_concat(objects, objs);
767766
objs = getRelationsInNamespace(namespaceId, RELKIND_VIEW);

src/backend/catalog/heap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,8 @@ heap_create_with_catalog(const char *relname,
11521152
/*
11531153
* Decide whether to create an array type over the relation's rowtype. We
11541154
* do not create any array types for system catalogs (ie, those made
1155-
* during initdb). We create array types for regular relations, views,
1156-
* composite types and foreign tables ... but not, eg, for toast tables or
1157-
* sequences.
1155+
* during initdb). We do not create them where the use of a relation as
1156+
* such is an implementation detail: toast tables, sequences and indexes.
11581157
*/
11591158
if (IsUnderPostmaster && (relkind == RELKIND_RELATION ||
11601159
relkind == RELKIND_VIEW ||

src/backend/commands/comment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CommentObject(CommentStmt *stmt)
9898
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
9999
ereport(ERROR,
100100
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
101-
errmsg("\"%s\" is not a table, view, composite type, or foreign table",
101+
errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
102102
RelationGetRelationName(relation))));
103103
break;
104104
default:

src/backend/commands/indexcmds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ DefineIndex(IndexStmt *stmt,
372372
else
373373
ereport(ERROR,
374374
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
375-
errmsg("\"%s\" is not a table",
375+
errmsg("\"%s\" is not a table or materialized view",
376376
RelationGetRelationName(rel))));
377377
}
378378

@@ -1834,8 +1834,8 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
18341834
/*
18351835
* Scan pg_class to build a list of the relations we need to reindex.
18361836
*
1837-
* We only consider plain relations here (toast rels will be processed
1838-
* indirectly by reindex_relation).
1837+
* We only consider plain relations and materialized views here (toast
1838+
* rels will be processed indirectly by reindex_relation).
18391839
*/
18401840
relationRelation = heap_open(RelationRelationId, AccessShareLock);
18411841
scan = heap_beginscan_catalog(relationRelation, 0, NULL);

src/backend/commands/seclabel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
111111
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
112112
ereport(ERROR,
113113
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
114-
errmsg("\"%s\" is not a table, view, composite type, or foreign table",
114+
errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
115115
RelationGetRelationName(relation))));
116116
break;
117117
default:

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10696,7 +10696,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
1069610696
relkind != RELKIND_FOREIGN_TABLE)
1069710697
ereport(ERROR,
1069810698
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
10699-
errmsg("\"%s\" is not a table, view, sequence, or foreign table",
10699+
errmsg("\"%s\" is not a table, view, materialized view, sequence, or foreign table",
1070010700
rv->relname)));
1070110701

1070210702
ReleaseSysCache(tuple);

src/backend/commands/typecmds.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,14 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
28202820
NULL,
28212821
format_type_be(domainOid));
28222822

2823-
/* Otherwise we can ignore views, composite types, etc */
2823+
/*
2824+
* Otherwise, we can ignore relations except those with both
2825+
* storage and user-chosen column types.
2826+
*
2827+
* XXX If an index-only scan could satisfy "col::some_domain" from
2828+
* a suitable expression index, this should also check expression
2829+
* index columns.
2830+
*/
28242831
if (rel->rd_rel->relkind != RELKIND_RELATION &&
28252832
rel->rd_rel->relkind != RELKIND_MATVIEW)
28262833
{

src/backend/commands/vacuum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ vac_update_datfrozenxid(void)
742742
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
743743

744744
/*
745-
* Only consider heap and TOAST tables (anything else should have
746-
* InvalidTransactionId in relfrozenxid anyway.)
745+
* Only consider relations able to hold unfrozen XIDs (anything else
746+
* should have InvalidTransactionId in relfrozenxid anyway.)
747747
*/
748748
if (classForm->relkind != RELKIND_RELATION &&
749749
classForm->relkind != RELKIND_MATVIEW &&
@@ -1044,7 +1044,7 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, bool do_toast, bool for_wraparound)
10441044
}
10451045

10461046
/*
1047-
* Check that it's a vacuumable table; we used to do this in
1047+
* Check that it's a vacuumable relation; we used to do this in
10481048
* get_rel_oids() but seems safer to check after we've locked the
10491049
* relation.
10501050
*/

src/backend/parser/parse_utilcmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
683683
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
684684
ereport(ERROR,
685685
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
686-
errmsg("\"%s\" is not a table, view, composite type, or foreign table",
686+
errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
687687
RelationGetRelationName(relation))));
688688

689689
cancel_parser_errposition_callback(&pcbstate);

src/backend/rewrite/rewriteDefine.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ DefineQueryRewrite(char *rulename,
258258

259259
/*
260260
* Verify relation is of a type that rules can sensibly be applied to.
261+
* Internal callers can target materialized views, but transformRuleStmt()
262+
* blocks them for users. Don't mention them in the error message.
261263
*/
262264
if (event_relation->rd_rel->relkind != RELKIND_RELATION &&
263265
event_relation->rd_rel->relkind != RELKIND_MATVIEW &&

src/bin/pg_dump/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ flagInhTables(TableInfo *tblinfo, int numTables,
269269

270270
for (i = 0; i < numTables; i++)
271271
{
272-
/* Sequences and views never have parents */
272+
/* Some kinds never have parents */
273273
if (tblinfo[i].relkind == RELKIND_SEQUENCE ||
274274
tblinfo[i].relkind == RELKIND_VIEW ||
275275
tblinfo[i].relkind == RELKIND_MATVIEW)
@@ -315,7 +315,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables)
315315
int numParents;
316316
TableInfo **parents;
317317

318-
/* Sequences and views never have parents */
318+
/* Some kinds never have parents */
319319
if (tbinfo->relkind == RELKIND_SEQUENCE ||
320320
tbinfo->relkind == RELKIND_VIEW ||
321321
tbinfo->relkind == RELKIND_MATVIEW)

src/pl/tcl/pltcl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ pltcl_init_load_unknown(Tcl_Interp *interp)
504504
AccessShareLock, true);
505505
if (pmrel == NULL)
506506
return;
507-
/* must be table or view, else ignore */
507+
/* sanity-check the relation kind */
508508
if (!(pmrel->rd_rel->relkind == RELKIND_RELATION ||
509509
pmrel->rd_rel->relkind == RELKIND_MATVIEW ||
510510
pmrel->rd_rel->relkind == RELKIND_VIEW))

src/test/regress/expected/create_table_like.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ NOTICE: drop cascades to table inhe
221221
CREATE TABLE ctlt4 (a int, b text);
222222
CREATE SEQUENCE ctlseq1;
223223
CREATE TABLE ctlt10 (LIKE ctlseq1); -- fail
224-
ERROR: "ctlseq1" is not a table, view, composite type, or foreign table
224+
ERROR: "ctlseq1" is not a table, view, materialized view, composite type, or foreign table
225225
LINE 1: CREATE TABLE ctlt10 (LIKE ctlseq1);
226226
^
227227
CREATE VIEW ctlv1 AS SELECT * FROM ctlt4;

0 commit comments

Comments
 (0)