getOpFamilyDescription(&buffer, object->objectId);
break;
+ case OCLASS_AM:
+ {
+ HeapTuple tup;
+
+ tup = SearchSysCache1(AMOID,
+ ObjectIdGetDatum(object->objectId));
+ if (!HeapTupleIsValid(tup))
+ elog(ERROR, "cache lookup failed for access method %u",
+ object->objectId);
+ appendStringInfo(&buffer, _("access method %s"),
+ NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
+ ReleaseSysCache(tup);
+ break;
+ }
+
case OCLASS_AMOP:
{
Relation amopDesc;
break;
}
- case OCLASS_STATISTIC_EXT:
- {
- HeapTuple stxTup;
- Form_pg_statistic_ext stxForm;
-
- stxTup = SearchSysCache1(STATEXTOID,
- ObjectIdGetDatum(object->objectId));
- if (!HeapTupleIsValid(stxTup))
- elog(ERROR, "could not find tuple for statistics object %u",
- object->objectId);
-
- stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
-
- appendStringInfo(&buffer, _("statistics object %s"),
- NameStr(stxForm->stxname));
-
- ReleaseSysCache(stxTup);
- break;
- }
-
- case OCLASS_TRANSFORM:
- {
- HeapTuple trfTup;
- Form_pg_transform trfForm;
-
- trfTup = SearchSysCache1(TRFOID,
- ObjectIdGetDatum(object->objectId));
- if (!HeapTupleIsValid(trfTup))
- elog(ERROR, "could not find tuple for transform %u",
- object->objectId);
-
- trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
-
- appendStringInfo(&buffer, _("transform for %s language %s"),
- format_type_be(trfForm->trftype),
- get_language_name(trfForm->trflang, false));
-
- ReleaseSysCache(trfTup);
- break;
- }
-
case OCLASS_TRIGGER:
{
Relation trigDesc;
break;
}
+ case OCLASS_STATISTIC_EXT:
+ {
+ HeapTuple stxTup;
+ Form_pg_statistic_ext stxForm;
+
+ stxTup = SearchSysCache1(STATEXTOID,
+ ObjectIdGetDatum(object->objectId));
+ if (!HeapTupleIsValid(stxTup))
+ elog(ERROR, "could not find tuple for statistics object %u",
+ object->objectId);
+
+ stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
+
+ appendStringInfo(&buffer, _("statistics object %s"),
+ NameStr(stxForm->stxname));
+
+ ReleaseSysCache(stxTup);
+ break;
+ }
+
case OCLASS_TSPARSER:
{
HeapTuple tup;
break;
}
- case OCLASS_AM:
- {
- HeapTuple tup;
-
- tup = SearchSysCache1(AMOID,
- ObjectIdGetDatum(object->objectId));
- if (!HeapTupleIsValid(tup))
- elog(ERROR, "cache lookup failed for access method %u",
- object->objectId);
- appendStringInfo(&buffer, _("access method %s"),
- NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
- ReleaseSysCache(tup);
- break;
- }
-
case OCLASS_PUBLICATION:
{
appendStringInfo(&buffer, _("publication %s"),
get_subscription_name(object->objectId));
break;
}
+
+ case OCLASS_TRANSFORM:
+ {
+ HeapTuple trfTup;
+ Form_pg_transform trfForm;
+
+ trfTup = SearchSysCache1(TRFOID,
+ ObjectIdGetDatum(object->objectId));
+ if (!HeapTupleIsValid(trfTup))
+ elog(ERROR, "could not find tuple for transform %u",
+ object->objectId);
+
+ trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
+
+ appendStringInfo(&buffer, _("transform for %s language %s"),
+ format_type_be(trfForm->trftype),
+ get_language_name(trfForm->trflang, false));
+
+ ReleaseSysCache(trfTup);
+ break;
+ }
+
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new OCLASS hasn't been handled above.
+ */
}
return buffer.data;
appendStringInfoString(&buffer, "operator family");
break;
+ case OCLASS_AM:
+ appendStringInfoString(&buffer, "access method");
+ break;
+
case OCLASS_AMOP:
appendStringInfoString(&buffer, "operator of access method");
break;
appendStringInfoString(&buffer, "schema");
break;
+ case OCLASS_STATISTIC_EXT:
+ appendStringInfoString(&buffer, "statistics object");
+ break;
+
case OCLASS_TSPARSER:
appendStringInfoString(&buffer, "text search parser");
break;
appendStringInfoString(&buffer, "policy");
break;
- case OCLASS_TRANSFORM:
- appendStringInfoString(&buffer, "transform");
- break;
-
- case OCLASS_AM:
- appendStringInfoString(&buffer, "access method");
- break;
-
case OCLASS_PUBLICATION:
appendStringInfoString(&buffer, "publication");
break;
appendStringInfoString(&buffer, "subscription");
break;
- case OCLASS_STATISTIC_EXT:
- appendStringInfoString(&buffer, "statistics object");
+ case OCLASS_TRANSFORM:
+ appendStringInfoString(&buffer, "transform");
break;
- default:
- appendStringInfo(&buffer, "unrecognized object class %u",
- object->classId);
- break;
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new OCLASS hasn't been handled above.
+ */
}
return buffer.data;
getOpFamilyIdentity(&buffer, object->objectId, objname);
break;
+ case OCLASS_AM:
+ {
+ char *amname;
+
+ amname = get_am_name(object->objectId);
+ if (!amname)
+ elog(ERROR, "cache lookup failed for access method %u",
+ object->objectId);
+ appendStringInfoString(&buffer, quote_identifier(amname));
+ if (objname)
+ *objname = list_make1(amname);
+ }
+ break;
+
case OCLASS_AMOP:
{
Relation amopDesc;
break;
}
- case OCLASS_POLICY:
- {
- Relation polDesc;
- HeapTuple tup;
- Form_pg_policy policy;
-
- polDesc = heap_open(PolicyRelationId, AccessShareLock);
-
- tup = get_catalog_object_by_oid(polDesc, object->objectId);
-
- if (!HeapTupleIsValid(tup))
- elog(ERROR, "could not find tuple for policy %u",
- object->objectId);
-
- policy = (Form_pg_policy) GETSTRUCT(tup);
-
- appendStringInfo(&buffer, "%s on ",
- quote_identifier(NameStr(policy->polname)));
- getRelationIdentity(&buffer, policy->polrelid, objname);
- if (objname)
- *objname = lappend(*objname, pstrdup(NameStr(policy->polname)));
-
- heap_close(polDesc, AccessShareLock);
- break;
- }
-
case OCLASS_SCHEMA:
{
char *nspname;
break;
}
+ case OCLASS_STATISTIC_EXT:
+ {
+ HeapTuple tup;
+ Form_pg_statistic_ext formStatistic;
+ char *schema;
+
+ tup = SearchSysCache1(STATEXTOID,
+ ObjectIdGetDatum(object->objectId));
+ if (!HeapTupleIsValid(tup))
+ elog(ERROR, "cache lookup failed for statistics object %u",
+ object->objectId);
+ formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
+ schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
+ appendStringInfoString(&buffer,
+ quote_qualified_identifier(schema,
+ NameStr(formStatistic->stxname)));
+ if (objname)
+ *objname = list_make2(schema,
+ pstrdup(NameStr(formStatistic->stxname)));
+ ReleaseSysCache(tup);
+ }
+ break;
+
case OCLASS_TSPARSER:
{
HeapTuple tup;
break;
}
- case OCLASS_TRANSFORM:
+ case OCLASS_POLICY:
{
- Relation transformDesc;
+ Relation polDesc;
HeapTuple tup;
- Form_pg_transform transform;
- char *transformLang;
- char *transformType;
+ Form_pg_policy policy;
- transformDesc = heap_open(TransformRelationId, AccessShareLock);
+ polDesc = heap_open(PolicyRelationId, AccessShareLock);
- tup = get_catalog_object_by_oid(transformDesc, object->objectId);
+ tup = get_catalog_object_by_oid(polDesc, object->objectId);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "could not find tuple for transform %u",
+ elog(ERROR, "could not find tuple for policy %u",
object->objectId);
- transform = (Form_pg_transform) GETSTRUCT(tup);
-
- transformType = format_type_be_qualified(transform->trftype);
- transformLang = get_language_name(transform->trflang, false);
+ policy = (Form_pg_policy) GETSTRUCT(tup);
- appendStringInfo(&buffer, "for %s on language %s",
- transformType,
- transformLang);
+ appendStringInfo(&buffer, "%s on ",
+ quote_identifier(NameStr(policy->polname)));
+ getRelationIdentity(&buffer, policy->polrelid, objname);
if (objname)
- {
- *objname = list_make1(transformType);
- *objargs = list_make1(pstrdup(transformLang));
- }
-
- heap_close(transformDesc, AccessShareLock);
- }
- break;
-
- case OCLASS_AM:
- {
- char *amname;
+ *objname = lappend(*objname, pstrdup(NameStr(policy->polname)));
- amname = get_am_name(object->objectId);
- if (!amname)
- elog(ERROR, "cache lookup failed for access method %u",
- object->objectId);
- appendStringInfoString(&buffer, quote_identifier(amname));
- if (objname)
- *objname = list_make1(amname);
+ heap_close(polDesc, AccessShareLock);
+ break;
}
- break;
case OCLASS_PUBLICATION:
{
break;
}
- case OCLASS_STATISTIC_EXT:
+ case OCLASS_TRANSFORM:
{
+ Relation transformDesc;
HeapTuple tup;
- Form_pg_statistic_ext formStatistic;
- char *schema;
+ Form_pg_transform transform;
+ char *transformLang;
+ char *transformType;
+
+ transformDesc = heap_open(TransformRelationId, AccessShareLock);
+
+ tup = get_catalog_object_by_oid(transformDesc, object->objectId);
- tup = SearchSysCache1(STATEXTOID,
- ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tup))
- elog(ERROR, "cache lookup failed for statistics object %u",
+ elog(ERROR, "could not find tuple for transform %u",
object->objectId);
- formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
- schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
- appendStringInfoString(&buffer,
- quote_qualified_identifier(schema,
- NameStr(formStatistic->stxname)));
+
+ transform = (Form_pg_transform) GETSTRUCT(tup);
+
+ transformType = format_type_be_qualified(transform->trftype);
+ transformLang = get_language_name(transform->trflang, false);
+
+ appendStringInfo(&buffer, "for %s on language %s",
+ transformType,
+ transformLang);
if (objname)
- *objname = list_make2(schema,
- pstrdup(NameStr(formStatistic->stxname)));
- ReleaseSysCache(tup);
+ {
+ *objname = list_make1(transformType);
+ *objargs = list_make1(pstrdup(transformLang));
+ }
+
+ heap_close(transformDesc, AccessShareLock);
}
break;
- default:
- appendStringInfo(&buffer, "unrecognized object %u %u %d",
- object->classId,
- object->objectId,
- object->objectSubId);
- break;
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new OCLASS hasn't been handled above.
+ */
}
/*
case OBJECT_USER_MAPPING:
case OBJECT_VIEW:
return true;
+
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new ObjectType hasn't been handled above.
+ */
}
- return true;
+
+ /* Shouldn't get here, but if we do, say "no support" */
+ return false;
}
/*
case OCLASS_OPERATOR:
case OCLASS_OPCLASS:
case OCLASS_OPFAMILY:
+ case OCLASS_AM:
case OCLASS_AMOP:
case OCLASS_AMPROC:
case OCLASS_REWRITE:
case OCLASS_TRIGGER:
case OCLASS_SCHEMA:
- case OCLASS_TRANSFORM:
+ case OCLASS_STATISTIC_EXT:
case OCLASS_TSPARSER:
case OCLASS_TSDICT:
case OCLASS_TSTEMPLATE:
case OCLASS_DEFACL:
case OCLASS_EXTENSION:
case OCLASS_POLICY:
- case OCLASS_AM:
case OCLASS_PUBLICATION:
case OCLASS_PUBLICATION_REL:
case OCLASS_SUBSCRIPTION:
- case OCLASS_STATISTIC_EXT:
+ case OCLASS_TRANSFORM:
return true;
+
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new OCLASS hasn't been handled above.
+ */
}
- return true;
+ /* Shouldn't get here, but if we do, say "no support" */
+ return false;
}
bool
case ACL_OBJECT_NAMESPACE:
case ACL_OBJECT_TYPE:
return true;
- default:
- Assert(false);
- return true;
+
+ /*
+ * There's intentionally no default: case here; we want the
+ * compiler to warn if a new ACL class hasn't been handled above.
+ */
}
+
+ /* Shouldn't get here, but if we do, say "no support" */
+ return false;
}
/*
return "TABLESPACE";
case ACL_OBJECT_TYPE:
return "TYPE";
- default:
- elog(ERROR, "unrecognized type %d", objtype);
- return "???"; /* keep compiler quiet */
}
+
+ elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
+ return "???"; /* keep compiler quiet */
}
/*
* Return the GrantObjectType as a string; as above, but use the spelling
- * in ALTER DEFAULT PRIVILEGES commands instead.
+ * in ALTER DEFAULT PRIVILEGES commands instead. Generally this is just
+ * the plural.
*/
static const char *
stringify_adefprivs_objtype(GrantObjectType objtype)
{
switch (objtype)
{
+ case ACL_OBJECT_COLUMN:
+ return "COLUMNS";
case ACL_OBJECT_RELATION:
return "TABLES";
- break;
- case ACL_OBJECT_FUNCTION:
- return "FUNCTIONS";
- break;
case ACL_OBJECT_SEQUENCE:
return "SEQUENCES";
- break;
+ case ACL_OBJECT_DATABASE:
+ return "DATABASES";
+ case ACL_OBJECT_DOMAIN:
+ return "DOMAINS";
+ case ACL_OBJECT_FDW:
+ return "FOREIGN DATA WRAPPERS";
+ case ACL_OBJECT_FOREIGN_SERVER:
+ return "FOREIGN SERVERS";
+ case ACL_OBJECT_FUNCTION:
+ return "FUNCTIONS";
+ case ACL_OBJECT_LANGUAGE:
+ return "LANGUAGES";
+ case ACL_OBJECT_LARGEOBJECT:
+ return "LARGE OBJECTS";
+ case ACL_OBJECT_NAMESPACE:
+ return "SCHEMAS";
+ case ACL_OBJECT_TABLESPACE:
+ return "TABLESPACES";
case ACL_OBJECT_TYPE:
return "TYPES";
- break;
- default:
- elog(ERROR, "unrecognized type %d", objtype);
- return "???"; /* keep compiler quiet */
}
+
+ elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
+ return "???"; /* keep compiler quiet */
}