examine this information is to execute queries such as:
<programlisting>
-SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r';
+SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind IN ('r', 'm');
SELECT datname, age(datfrozenxid) FROM pg_database;
</programlisting>
bool toast_delold[MaxHeapAttributeNumber];
/*
- * We should only ever be called for tuples of plain relations ---
- * recursing on a toast rel is bad news.
+ * We should only ever be called for tuples of plain relations or
+ * materialized views --- recursing on a toast rel is bad news.
*/
Assert(rel->rd_rel->relkind == RELKIND_RELATION ||
rel->rd_rel->relkind == RELKIND_MATVIEW);
switch (objtype)
{
case ACL_OBJECT_RELATION:
- /* Process regular tables, views and foreign tables */
objs = getRelationsInNamespace(namespaceId, RELKIND_RELATION);
objects = list_concat(objects, objs);
objs = getRelationsInNamespace(namespaceId, RELKIND_VIEW);
/*
* Decide whether to create an array type over the relation's rowtype. We
* do not create any array types for system catalogs (ie, those made
- * during initdb). We create array types for regular relations, views,
- * composite types and foreign tables ... but not, eg, for toast tables or
- * sequences.
+ * during initdb). We do not create them where the use of a relation as
+ * such is an implementation detail: toast tables, sequences and indexes.
*/
if (IsUnderPostmaster && (relkind == RELKIND_RELATION ||
relkind == RELKIND_VIEW ||
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, composite type, or foreign table",
+ errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
RelationGetRelationName(relation))));
break;
default:
else
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table",
+ errmsg("\"%s\" is not a table or materialized view",
RelationGetRelationName(rel))));
}
/*
* Scan pg_class to build a list of the relations we need to reindex.
*
- * We only consider plain relations here (toast rels will be processed
- * indirectly by reindex_relation).
+ * We only consider plain relations and materialized views here (toast
+ * rels will be processed indirectly by reindex_relation).
*/
relationRelation = heap_open(RelationRelationId, AccessShareLock);
scan = heap_beginscan(relationRelation, SnapshotNow, 0, NULL);
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, composite type, or foreign table",
+ errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
RelationGetRelationName(relation))));
break;
default:
relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, sequence, or foreign table",
+ errmsg("\"%s\" is not a table, view, materialized view, sequence, or foreign table",
rv->relname)));
ReleaseSysCache(tuple);
NULL,
format_type_be(domainOid));
- /* Otherwise we can ignore views, composite types, etc */
+ /*
+ * Otherwise, we can ignore relations except those with both
+ * storage and user-chosen column types.
+ *
+ * XXX If an index-only scan could satisfy "col::some_domain" from
+ * a suitable expression index, this should also check expression
+ * index columns.
+ */
if (rel->rd_rel->relkind != RELKIND_RELATION &&
rel->rd_rel->relkind != RELKIND_MATVIEW)
{
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
/*
- * Only consider heap and TOAST tables (anything else should have
- * InvalidTransactionId in relfrozenxid anyway.)
+ * Only consider relations able to hold unfrozen XIDs (anything else
+ * should have InvalidTransactionId in relfrozenxid anyway.)
*/
if (classForm->relkind != RELKIND_RELATION &&
classForm->relkind != RELKIND_MATVIEW &&
}
/*
- * Check that it's a vacuumable table; we used to do this in
+ * Check that it's a vacuumable relation; we used to do this in
* get_rel_oids() but seems safer to check after we've locked the
* relation.
*/
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, composite type, or foreign table",
+ errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
RelationGetRelationName(relation))));
cancel_parser_errposition_callback(&pcbstate);
/*
* Verify relation is of a type that rules can sensibly be applied to.
+ * Internal callers can target materialized views, but transformRuleStmt()
+ * blocks them for users. Don't mention them in the error message.
*/
if (event_relation->rd_rel->relkind != RELKIND_RELATION &&
event_relation->rd_rel->relkind != RELKIND_MATVIEW &&
for (i = 0; i < numTables; i++)
{
- /* Sequences and views never have parents */
+ /* Some kinds never have parents */
if (tblinfo[i].relkind == RELKIND_SEQUENCE ||
tblinfo[i].relkind == RELKIND_VIEW ||
tblinfo[i].relkind == RELKIND_MATVIEW)
int numParents;
TableInfo **parents;
- /* Sequences and views never have parents */
+ /* Some kinds never have parents */
if (tbinfo->relkind == RELKIND_SEQUENCE ||
tbinfo->relkind == RELKIND_VIEW ||
tbinfo->relkind == RELKIND_MATVIEW)
AccessShareLock, true);
if (pmrel == NULL)
return;
- /* must be table or view, else ignore */
+ /* sanity-check the relation kind */
if (!(pmrel->rd_rel->relkind == RELKIND_RELATION ||
pmrel->rd_rel->relkind == RELKIND_MATVIEW ||
pmrel->rd_rel->relkind == RELKIND_VIEW))
CREATE TABLE ctlt4 (a int, b text);
CREATE SEQUENCE ctlseq1;
CREATE TABLE ctlt10 (LIKE ctlseq1); -- fail
-ERROR: "ctlseq1" is not a table, view, composite type, or foreign table
+ERROR: "ctlseq1" is not a table, view, materialized view, composite type, or foreign table
LINE 1: CREATE TABLE ctlt10 (LIKE ctlseq1);
^
CREATE VIEW ctlv1 AS SELECT * FROM ctlt4;