PostgreSQL Source Code  git master
objectaddress.h File Reference
#include "access/htup.h"
#include "nodes/parsenodes.h"
#include "storage/lockdefs.h"
#include "utils/relcache.h"
Include dependency graph for objectaddress.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ObjectAddress
 

Macros

#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
 
#define ObjectAddressSet(addr, class_id, object_id)   ObjectAddressSubSet(addr, class_id, object_id, 0)
 

Typedefs

typedef struct ObjectAddress ObjectAddress
 

Functions

ObjectAddress get_object_address (ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
 
ObjectAddress get_object_address_rv (ObjectType objtype, RangeVar *rel, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
 
void check_object_ownership (Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
 
Oid get_object_namespace (const ObjectAddress *address)
 
bool is_objectclass_supported (Oid class_id)
 
Oid get_object_oid_index (Oid class_id)
 
int get_object_catcache_oid (Oid class_id)
 
int get_object_catcache_name (Oid class_id)
 
AttrNumber get_object_attnum_oid (Oid class_id)
 
AttrNumber get_object_attnum_name (Oid class_id)
 
AttrNumber get_object_attnum_namespace (Oid class_id)
 
AttrNumber get_object_attnum_owner (Oid class_id)
 
AttrNumber get_object_attnum_acl (Oid class_id)
 
ObjectType get_object_type (Oid class_id, Oid object_id)
 
bool get_object_namensp_unique (Oid class_id)
 
HeapTuple get_catalog_object_by_oid (Relation catalog, AttrNumber oidcol, Oid objectId)
 
char * getObjectDescription (const ObjectAddress *object)
 
char * getObjectDescriptionOids (Oid classid, Oid objid)
 
int read_objtype_from_string (const char *objtype)
 
char * getObjectTypeDescription (const ObjectAddress *object)
 
char * getObjectIdentity (const ObjectAddress *address)
 
char * getObjectIdentityParts (const ObjectAddress *address, List **objname, List **objargs)
 
struct ArrayTypestrlist_to_textarray (List *list)
 
ObjectType get_relkind_objtype (char relkind)
 

Variables

const ObjectAddress InvalidObjectAddress
 

Macro Definition Documentation

◆ ObjectAddressSet

#define ObjectAddressSet (   addr,
  class_id,
  object_id 
)    ObjectAddressSubSet(addr, class_id, object_id, 0)

Definition at line 40 of file objectaddress.h.

Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), AlterCollation(), AlterDatabaseOwner(), AlterDomainAddConstraint(), AlterDomainDefault(), AlterDomainDropConstraint(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEnum(), AlterEventTriggerOwner(), AlterExtensionNamespace(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner(), AlterForeignServer(), AlterForeignServerOwner(), AlterFunction(), AlterPublicationOptions(), AlterPublicationOwner(), AlterSchemaOwner(), AlterSequence(), AlterStatistics(), AlterSubscription(), AlterSubscriptionOwner(), AlterTableNamespace(), AlterTSConfiguration(), AlterTSDictionary(), AlterType(), AlterTypeNamespace(), AlterTypeOwner(), AlterUserMapping(), ATAddCheckConstraint(), ATExecAddInherit(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecAttachPartitionIdx(), ATExecClusterOn(), ATExecDetachPartition(), ATExecDropInherit(), ATExecValidateConstraint(), ATPostAlterTypeCleanup(), CloneFkReferencing(), ConstraintSetParentConstraint(), CreatePublication(), CreateSchemaCommand(), CreateStatistics(), CreateSubscription(), CreateTrigger(), DefineCollation(), DefineIndex(), DefineQueryRewrite(), DefineRelation(), DefineTSConfiguration(), DefineVirtualRelation(), domainAddConstraint(), DropSubscription(), EventTriggerCollectAlterOpFam(), EventTriggerCollectAlterTSConfig(), EventTriggerCollectCreateOpClass(), ExecAlterExtensionStmt(), ExecAlterObjectSchemaStmt(), ExecRefreshMatView(), get_object_address_defacl(), get_object_address_opf_member(), get_object_address_publication_rel(), get_object_address_usermapping(), index_constraint_create(), IndexSetParentIndex(), pg_event_trigger_ddl_commands(), publication_add_relation(), PublicationDropTables(), rename_constraint_internal(), rename_policy(), RenameDatabase(), RenameRelation(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig(), RenameType(), tryAttachPartitionForeignKey(), TypeCreate(), and TypeShellMake().

◆ ObjectAddressSubSet

#define ObjectAddressSubSet (   addr,
  class_id,
  object_id,
  object_sub_id 
)

Typedef Documentation

◆ ObjectAddress

typedef struct ObjectAddress ObjectAddress

Function Documentation

◆ check_object_ownership()

void check_object_ownership ( Oid  roleid,
ObjectType  objtype,
ObjectAddress  address,
Node object,
Relation  relation 
)

Definition at line 2271 of file objectaddress.c.

References aclcheck_error(), aclcheck_error_type(), ACLCHECK_NOT_OWNER, castNode, CONSTROID, elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, has_createrole_privilege(), HeapTupleIsValid, linitial_node, lo_compat_privileges, lsecond_node, NameListToString(), OBJECT_ACCESS_METHOD, OBJECT_AGGREGATE, OBJECT_ATTRIBUTE, OBJECT_CAST, OBJECT_COLLATION, OBJECT_COLUMN, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_DOMCONSTRAINT, OBJECT_EVENT_TRIGGER, OBJECT_EXTENSION, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FOREIGN_TABLE, OBJECT_FUNCTION, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_MATVIEW, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_POLICY, OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_ROLE, OBJECT_ROUTINE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_STATISTIC_EXT, OBJECT_SUBSCRIPTION, OBJECT_TABCONSTRAINT, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TRANSFORM, OBJECT_TRIGGER, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TSPARSER, OBJECT_TSTEMPLATE, OBJECT_TYPE, OBJECT_VIEW, ObjectAddress::objectId, ObjectIdGetDatum, pg_class_ownercheck(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_database_ownercheck(), pg_event_trigger_ownercheck(), pg_extension_ownercheck(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_ownercheck(), pg_language_ownercheck(), pg_largeobject_ownercheck(), pg_namespace_ownercheck(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_ownercheck(), pg_publication_ownercheck(), pg_statistics_object_ownercheck(), pg_subscription_ownercheck(), pg_tablespace_ownercheck(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_ownercheck(), RelationGetRelationName, RelationGetRelid, ReleaseSysCache(), SearchSysCache1(), strVal, superuser_arg(), and typenameTypeId().

Referenced by CommentObject(), ExecAlterExtensionContentsStmt(), ExecAlterObjectDependsStmt(), ExecSecLabelStmt(), and RemoveObjects().

2273 {
2274  switch (objtype)
2275  {
2276  case OBJECT_INDEX:
2277  case OBJECT_SEQUENCE:
2278  case OBJECT_TABLE:
2279  case OBJECT_VIEW:
2280  case OBJECT_MATVIEW:
2281  case OBJECT_FOREIGN_TABLE:
2282  case OBJECT_COLUMN:
2283  case OBJECT_RULE:
2284  case OBJECT_TRIGGER:
2285  case OBJECT_POLICY:
2286  case OBJECT_TABCONSTRAINT:
2287  if (!pg_class_ownercheck(RelationGetRelid(relation), roleid))
2289  RelationGetRelationName(relation));
2290  break;
2291  case OBJECT_DATABASE:
2292  if (!pg_database_ownercheck(address.objectId, roleid))
2294  strVal((Value *) object));
2295  break;
2296  case OBJECT_TYPE:
2297  case OBJECT_DOMAIN:
2298  case OBJECT_ATTRIBUTE:
2299  if (!pg_type_ownercheck(address.objectId, roleid))
2301  break;
2302  case OBJECT_DOMCONSTRAINT:
2303  {
2304  HeapTuple tuple;
2305  Oid contypid;
2306 
2307  tuple = SearchSysCache1(CONSTROID,
2308  ObjectIdGetDatum(address.objectId));
2309  if (!HeapTupleIsValid(tuple))
2310  elog(ERROR, "constraint with OID %u does not exist",
2311  address.objectId);
2312 
2313  contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid;
2314 
2315  ReleaseSysCache(tuple);
2316 
2317  /*
2318  * Fallback to type ownership check in this case as this is
2319  * what domain constraints rely on.
2320  */
2321  if (!pg_type_ownercheck(contypid, roleid))
2323  }
2324  break;
2325  case OBJECT_AGGREGATE:
2326  case OBJECT_FUNCTION:
2327  case OBJECT_PROCEDURE:
2328  case OBJECT_ROUTINE:
2329  if (!pg_proc_ownercheck(address.objectId, roleid))
2331  NameListToString((castNode(ObjectWithArgs, object))->objname));
2332  break;
2333  case OBJECT_OPERATOR:
2334  if (!pg_oper_ownercheck(address.objectId, roleid))
2336  NameListToString((castNode(ObjectWithArgs, object))->objname));
2337  break;
2338  case OBJECT_SCHEMA:
2339  if (!pg_namespace_ownercheck(address.objectId, roleid))
2341  strVal((Value *) object));
2342  break;
2343  case OBJECT_COLLATION:
2344  if (!pg_collation_ownercheck(address.objectId, roleid))
2346  NameListToString(castNode(List, object)));
2347  break;
2348  case OBJECT_CONVERSION:
2349  if (!pg_conversion_ownercheck(address.objectId, roleid))
2351  NameListToString(castNode(List, object)));
2352  break;
2353  case OBJECT_EXTENSION:
2354  if (!pg_extension_ownercheck(address.objectId, roleid))
2356  strVal((Value *) object));
2357  break;
2358  case OBJECT_FDW:
2359  if (!pg_foreign_data_wrapper_ownercheck(address.objectId, roleid))
2361  strVal((Value *) object));
2362  break;
2363  case OBJECT_FOREIGN_SERVER:
2364  if (!pg_foreign_server_ownercheck(address.objectId, roleid))
2366  strVal((Value *) object));
2367  break;
2368  case OBJECT_EVENT_TRIGGER:
2369  if (!pg_event_trigger_ownercheck(address.objectId, roleid))
2371  strVal((Value *) object));
2372  break;
2373  case OBJECT_LANGUAGE:
2374  if (!pg_language_ownercheck(address.objectId, roleid))
2376  strVal((Value *) object));
2377  break;
2378  case OBJECT_OPCLASS:
2379  if (!pg_opclass_ownercheck(address.objectId, roleid))
2381  NameListToString(castNode(List, object)));
2382  break;
2383  case OBJECT_OPFAMILY:
2384  if (!pg_opfamily_ownercheck(address.objectId, roleid))
2386  NameListToString(castNode(List, object)));
2387  break;
2388  case OBJECT_LARGEOBJECT:
2389  if (!lo_compat_privileges &&
2390  !pg_largeobject_ownercheck(address.objectId, roleid))
2391  ereport(ERROR,
2392  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2393  errmsg("must be owner of large object %u",
2394  address.objectId)));
2395  break;
2396  case OBJECT_CAST:
2397  {
2398  /* We can only check permissions on the source/target types */
2399  TypeName *sourcetype = linitial_node(TypeName, castNode(List, object));
2400  TypeName *targettype = lsecond_node(TypeName, castNode(List, object));
2401  Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
2402  Oid targettypeid = typenameTypeId(NULL, targettype);
2403 
2404  if (!pg_type_ownercheck(sourcetypeid, roleid)
2405  && !pg_type_ownercheck(targettypeid, roleid))
2406  ereport(ERROR,
2407  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2408  errmsg("must be owner of type %s or type %s",
2409  format_type_be(sourcetypeid),
2410  format_type_be(targettypeid))));
2411  }
2412  break;
2413  case OBJECT_PUBLICATION:
2414  if (!pg_publication_ownercheck(address.objectId, roleid))
2416  strVal((Value *) object));
2417  break;
2418  case OBJECT_SUBSCRIPTION:
2419  if (!pg_subscription_ownercheck(address.objectId, roleid))
2421  strVal((Value *) object));
2422  break;
2423  case OBJECT_TRANSFORM:
2424  {
2425  TypeName *typename = linitial_node(TypeName, castNode(List, object));
2426  Oid typeid = typenameTypeId(NULL, typename);
2427 
2428  if (!pg_type_ownercheck(typeid, roleid))
2430  }
2431  break;
2432  case OBJECT_TABLESPACE:
2433  if (!pg_tablespace_ownercheck(address.objectId, roleid))
2435  strVal((Value *) object));
2436  break;
2437  case OBJECT_TSDICTIONARY:
2438  if (!pg_ts_dict_ownercheck(address.objectId, roleid))
2440  NameListToString(castNode(List, object)));
2441  break;
2443  if (!pg_ts_config_ownercheck(address.objectId, roleid))
2445  NameListToString(castNode(List, object)));
2446  break;
2447  case OBJECT_ROLE:
2448 
2449  /*
2450  * We treat roles as being "owned" by those with CREATEROLE priv,
2451  * except that superusers are only owned by superusers.
2452  */
2453  if (superuser_arg(address.objectId))
2454  {
2455  if (!superuser_arg(roleid))
2456  ereport(ERROR,
2457  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2458  errmsg("must be superuser")));
2459  }
2460  else
2461  {
2462  if (!has_createrole_privilege(roleid))
2463  ereport(ERROR,
2464  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2465  errmsg("must have CREATEROLE privilege")));
2466  }
2467  break;
2468  case OBJECT_TSPARSER:
2469  case OBJECT_TSTEMPLATE:
2470  case OBJECT_ACCESS_METHOD:
2471  /* We treat these object types as being owned by superusers */
2472  if (!superuser_arg(roleid))
2473  ereport(ERROR,
2474  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2475  errmsg("must be superuser")));
2476  break;
2477  case OBJECT_STATISTIC_EXT:
2478  if (!pg_statistics_object_ownercheck(address.objectId, roleid))
2480  break;
2481  default:
2482  elog(ERROR, "unrecognized object type: %d",
2483  (int) objtype);
2484  }
2485 }
bool has_createrole_privilege(Oid roleid)
Definition: aclchk.c:5378
bool pg_collation_ownercheck(Oid coll_oid, Oid roleid)
Definition: aclchk.c:5197
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
bool lo_compat_privileges
Definition: inv_api.c:58
bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
Definition: aclchk.c:4886
bool pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
Definition: aclchk.c:5036
bool pg_language_ownercheck(Oid lan_oid, Oid roleid)
Definition: aclchk.c:4857
#define castNode(_type_, nodeptr)
Definition: nodes.h:595
bool pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
Definition: aclchk.c:5063
bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid)
Definition: aclchk.c:5117
bool pg_publication_ownercheck(Oid pub_oid, Oid roleid)
Definition: aclchk.c:5291
#define strVal(v)
Definition: value.h:54
bool pg_oper_ownercheck(Oid oper_oid, Oid roleid)
Definition: aclchk.c:4805
int errcode(int sqlerrcode)
Definition: elog.c:610
char * format_type_be(Oid type_oid)
Definition: format_type.c:327
bool pg_namespace_ownercheck(Oid nsp_oid, Oid roleid)
Definition: aclchk.c:4929
unsigned int Oid
Definition: postgres_ext.h:31
bool pg_type_ownercheck(Oid type_oid, Oid roleid)
Definition: aclchk.c:4779
#define linitial_node(type, l)
Definition: pg_list.h:198
void aclcheck_error_type(AclResult aclerr, Oid typeOid)
Definition: aclchk.c:3665
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3352
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
bool pg_event_trigger_ownercheck(Oid et_oid, Oid roleid)
Definition: aclchk.c:5144
bool pg_extension_ownercheck(Oid ext_oid, Oid roleid)
Definition: aclchk.c:5249
#define RelationGetRelationName(relation)
Definition: rel.h:470
bool pg_tablespace_ownercheck(Oid spc_oid, Oid roleid)
Definition: aclchk.c:4955
bool pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
Definition: aclchk.c:5009
bool pg_database_ownercheck(Oid db_oid, Oid roleid)
Definition: aclchk.c:5171
bool superuser_arg(Oid roleid)
Definition: superuser.c:56
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
char * NameListToString(List *names)
Definition: namespace.c:3102
#define lsecond_node(type, l)
Definition: pg_list.h:203
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
bool pg_opclass_ownercheck(Oid opc_oid, Oid roleid)
Definition: aclchk.c:4982
bool pg_conversion_ownercheck(Oid conv_oid, Oid roleid)
Definition: aclchk.c:5223
#define ereport(elevel,...)
Definition: elog.h:144
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Definition: value.h:42
bool pg_class_ownercheck(Oid class_oid, Oid roleid)
Definition: aclchk.c:4753
bool pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid)
Definition: aclchk.c:5090
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
Definition: pg_list.h:50
#define RelationGetRelid(relation)
Definition: rel.h:436
bool pg_proc_ownercheck(Oid proc_oid, Oid roleid)
Definition: aclchk.c:4831
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
Definition: parse_type.c:291
bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
Definition: aclchk.c:5317
bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid)
Definition: aclchk.c:5343

◆ get_catalog_object_by_oid()

HeapTuple get_catalog_object_by_oid ( Relation  catalog,
AttrNumber  oidcol,
Oid  objectId 
)

Definition at line 2706 of file objectaddress.c.

References Assert, BTEqualStrategyNumber, get_object_catcache_oid(), get_object_oid_index(), heap_copytuple(), HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, RelationGetRelid, ScanKeyInit(), SearchSysCacheCopy1, systable_beginscan(), systable_endscan(), and systable_getnext().

Referenced by AlterObjectOwner_internal(), EventTriggerSQLDropAddObject(), getConstraintTypeDescription(), getObjectIdentityParts(), pg_event_trigger_ddl_commands(), and pg_identify_object().

2707 {
2708  HeapTuple tuple;
2709  Oid classId = RelationGetRelid(catalog);
2710  int oidCacheId = get_object_catcache_oid(classId);
2711 
2712  if (oidCacheId > 0)
2713  {
2714  tuple = SearchSysCacheCopy1(oidCacheId, ObjectIdGetDatum(objectId));
2715  if (!HeapTupleIsValid(tuple)) /* should not happen */
2716  return NULL;
2717  }
2718  else
2719  {
2720  Oid oidIndexId = get_object_oid_index(classId);
2721  SysScanDesc scan;
2722  ScanKeyData skey;
2723 
2724  Assert(OidIsValid(oidIndexId));
2725 
2726  ScanKeyInit(&skey,
2727  oidcol,
2728  BTEqualStrategyNumber, F_OIDEQ,
2729  ObjectIdGetDatum(objectId));
2730 
2731  scan = systable_beginscan(catalog, oidIndexId, true,
2732  NULL, 1, &skey);
2733  tuple = systable_getnext(scan);
2734  if (!HeapTupleIsValid(tuple))
2735  {
2736  systable_endscan(scan);
2737  return NULL;
2738  }
2739  tuple = heap_copytuple(tuple);
2740 
2741  systable_endscan(scan);
2742  }
2743 
2744  return tuple;
2745 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:529
Oid get_object_oid_index(Oid class_id)
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:644
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:356
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:448
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
int get_object_catcache_oid(Oid class_id)
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:738
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:174
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define RelationGetRelid(relation)
Definition: rel.h:436
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_object_address()

ObjectAddress get_object_address ( ObjectType  objtype,
Node object,
Relation relp,
LOCKMODE  lockmode,
bool  missing_ok 
)

Definition at line 834 of file objectaddress.c.

References Assert, castNode, ObjectAddress::classId, elog, ereport, errcode(), errmsg(), ERROR, get_cast_oid(), get_collation_oid(), get_conversion_oid(), get_domain_constraint_oid(), get_language_oid(), get_object_address_attrdef(), get_object_address_attribute(), get_object_address_defacl(), get_object_address_opcf(), get_object_address_opf_member(), get_object_address_publication_rel(), get_object_address_relobject(), get_object_address_type(), get_object_address_unqualified(), get_object_address_usermapping(), get_relation_by_qualified_name(), get_statistics_object_oid(), get_transform_oid(), get_ts_config_oid(), get_ts_dict_oid(), get_ts_parser_oid(), get_ts_template_oid(), InvalidOid, IsSharedRelation(), LargeObjectExists(), linitial_node, LockDatabaseObject(), LockSharedObject(), LookupFuncWithArgs(), LookupOperWithArgs(), LookupTypeNameOid(), lsecond, lsecond_node, NoLock, OBJECT_ACCESS_METHOD, OBJECT_AGGREGATE, OBJECT_AMOP, OBJECT_AMPROC, OBJECT_CAST, OBJECT_COLLATION, OBJECT_COLUMN, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DEFACL, OBJECT_DEFAULT, OBJECT_DOMAIN, OBJECT_DOMCONSTRAINT, OBJECT_EVENT_TRIGGER, OBJECT_EXTENSION, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FOREIGN_TABLE, OBJECT_FUNCTION, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_MATVIEW, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_POLICY, OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_PUBLICATION_REL, OBJECT_ROLE, OBJECT_ROUTINE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_STATISTIC_EXT, OBJECT_SUBSCRIPTION, OBJECT_TABCONSTRAINT, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TRANSFORM, OBJECT_TRIGGER, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TSPARSER, OBJECT_TSTEMPLATE, OBJECT_TYPE, OBJECT_USER_MAPPING, OBJECT_VIEW, ObjectAddress::objectId, ObjectAddress::objectSubId, OidIsValid, oidparse(), SharedInvalidMessageCounter, strVal, UnlockDatabaseObject(), and UnlockSharedObject().

Referenced by CommentObject(), ExecAlterExtensionContentsStmt(), ExecAlterObjectDependsStmt(), ExecAlterObjectSchemaStmt(), ExecAlterOwnerStmt(), ExecRenameStmt(), ExecSecLabelStmt(), get_object_address_rv(), pg_get_object_address(), and RemoveObjects().

836 {
837  ObjectAddress address;
838  ObjectAddress old_address = {InvalidOid, InvalidOid, 0};
839  Relation relation = NULL;
840  uint64 inval_count;
841 
842  /* Some kind of lock must be taken. */
843  Assert(lockmode != NoLock);
844 
845  for (;;)
846  {
847  /*
848  * Remember this value, so that, after looking up the object name and
849  * locking it, we can check whether any invalidation messages have
850  * been processed that might require a do-over.
851  */
852  inval_count = SharedInvalidMessageCounter;
853 
854  /* Look up object address. */
855  switch (objtype)
856  {
857  case OBJECT_INDEX:
858  case OBJECT_SEQUENCE:
859  case OBJECT_TABLE:
860  case OBJECT_VIEW:
861  case OBJECT_MATVIEW:
863  address =
864  get_relation_by_qualified_name(objtype, castNode(List, object),
865  &relation, lockmode,
866  missing_ok);
867  break;
868  case OBJECT_COLUMN:
869  address =
870  get_object_address_attribute(objtype, castNode(List, object),
871  &relation, lockmode,
872  missing_ok);
873  break;
874  case OBJECT_DEFAULT:
875  address =
876  get_object_address_attrdef(objtype, castNode(List, object),
877  &relation, lockmode,
878  missing_ok);
879  break;
880  case OBJECT_RULE:
881  case OBJECT_TRIGGER:
883  case OBJECT_POLICY:
884  address = get_object_address_relobject(objtype, castNode(List, object),
885  &relation, missing_ok);
886  break;
888  {
889  List *objlist;
890  ObjectAddress domaddr;
891  char *constrname;
892 
893  objlist = castNode(List, object);
895  linitial_node(TypeName, objlist),
896  missing_ok);
897  constrname = strVal(lsecond(objlist));
898 
899  address.classId = ConstraintRelationId;
900  address.objectId = get_domain_constraint_oid(domaddr.objectId,
901  constrname, missing_ok);
902  address.objectSubId = 0;
903 
904  }
905  break;
906  case OBJECT_DATABASE:
907  case OBJECT_EXTENSION:
908  case OBJECT_TABLESPACE:
909  case OBJECT_ROLE:
910  case OBJECT_SCHEMA:
911  case OBJECT_LANGUAGE:
912  case OBJECT_FDW:
916  case OBJECT_PUBLICATION:
917  case OBJECT_SUBSCRIPTION:
918  address = get_object_address_unqualified(objtype,
919  (Value *) object, missing_ok);
920  break;
921  case OBJECT_TYPE:
922  case OBJECT_DOMAIN:
923  address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok);
924  break;
925  case OBJECT_AGGREGATE:
926  case OBJECT_FUNCTION:
927  case OBJECT_PROCEDURE:
928  case OBJECT_ROUTINE:
929  address.classId = ProcedureRelationId;
930  address.objectId = LookupFuncWithArgs(objtype, castNode(ObjectWithArgs, object), missing_ok);
931  address.objectSubId = 0;
932  break;
933  case OBJECT_OPERATOR:
934  address.classId = OperatorRelationId;
935  address.objectId = LookupOperWithArgs(castNode(ObjectWithArgs, object), missing_ok);
936  address.objectSubId = 0;
937  break;
938  case OBJECT_COLLATION:
939  address.classId = CollationRelationId;
940  address.objectId = get_collation_oid(castNode(List, object), missing_ok);
941  address.objectSubId = 0;
942  break;
943  case OBJECT_CONVERSION:
944  address.classId = ConversionRelationId;
945  address.objectId = get_conversion_oid(castNode(List, object), missing_ok);
946  address.objectSubId = 0;
947  break;
948  case OBJECT_OPCLASS:
949  case OBJECT_OPFAMILY:
950  address = get_object_address_opcf(objtype, castNode(List, object), missing_ok);
951  break;
952  case OBJECT_AMOP:
953  case OBJECT_AMPROC:
954  address = get_object_address_opf_member(objtype, castNode(List, object), missing_ok);
955  break;
956  case OBJECT_LARGEOBJECT:
957  address.classId = LargeObjectRelationId;
958  address.objectId = oidparse(object);
959  address.objectSubId = 0;
960  if (!LargeObjectExists(address.objectId))
961  {
962  if (!missing_ok)
963  ereport(ERROR,
964  (errcode(ERRCODE_UNDEFINED_OBJECT),
965  errmsg("large object %u does not exist",
966  address.objectId)));
967  }
968  break;
969  case OBJECT_CAST:
970  {
971  TypeName *sourcetype = linitial_node(TypeName, castNode(List, object));
972  TypeName *targettype = lsecond_node(TypeName, castNode(List, object));
973  Oid sourcetypeid;
974  Oid targettypeid;
975 
976  sourcetypeid = LookupTypeNameOid(NULL, sourcetype, missing_ok);
977  targettypeid = LookupTypeNameOid(NULL, targettype, missing_ok);
978  address.classId = CastRelationId;
979  address.objectId =
980  get_cast_oid(sourcetypeid, targettypeid, missing_ok);
981  address.objectSubId = 0;
982  }
983  break;
984  case OBJECT_TRANSFORM:
985  {
986  TypeName *typename = linitial_node(TypeName, castNode(List, object));
987  char *langname = strVal(lsecond(castNode(List, object)));
988  Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
989  Oid lang_id = get_language_oid(langname, missing_ok);
990 
991  address.classId = TransformRelationId;
992  address.objectId =
993  get_transform_oid(type_id, lang_id, missing_ok);
994  address.objectSubId = 0;
995  }
996  break;
997  case OBJECT_TSPARSER:
998  address.classId = TSParserRelationId;
999  address.objectId = get_ts_parser_oid(castNode(List, object), missing_ok);
1000  address.objectSubId = 0;
1001  break;
1002  case OBJECT_TSDICTIONARY:
1003  address.classId = TSDictionaryRelationId;
1004  address.objectId = get_ts_dict_oid(castNode(List, object), missing_ok);
1005  address.objectSubId = 0;
1006  break;
1007  case OBJECT_TSTEMPLATE:
1008  address.classId = TSTemplateRelationId;
1009  address.objectId = get_ts_template_oid(castNode(List, object), missing_ok);
1010  address.objectSubId = 0;
1011  break;
1013  address.classId = TSConfigRelationId;
1014  address.objectId = get_ts_config_oid(castNode(List, object), missing_ok);
1015  address.objectSubId = 0;
1016  break;
1017  case OBJECT_USER_MAPPING:
1018  address = get_object_address_usermapping(castNode(List, object),
1019  missing_ok);
1020  break;
1023  &relation,
1024  missing_ok);
1025  break;
1026  case OBJECT_DEFACL:
1027  address = get_object_address_defacl(castNode(List, object),
1028  missing_ok);
1029  break;
1030  case OBJECT_STATISTIC_EXT:
1031  address.classId = StatisticExtRelationId;
1032  address.objectId = get_statistics_object_oid(castNode(List, object),
1033  missing_ok);
1034  address.objectSubId = 0;
1035  break;
1036  default:
1037  elog(ERROR, "unrecognized objtype: %d", (int) objtype);
1038  /* placate compiler, in case it thinks elog might return */
1039  address.classId = InvalidOid;
1040  address.objectId = InvalidOid;
1041  address.objectSubId = 0;
1042  }
1043 
1044  /*
1045  * If we could not find the supplied object, return without locking.
1046  */
1047  if (!OidIsValid(address.objectId))
1048  {
1049  Assert(missing_ok);
1050  return address;
1051  }
1052 
1053  /*
1054  * If we're retrying, see if we got the same answer as last time. If
1055  * so, we're done; if not, we locked the wrong thing, so give up our
1056  * lock.
1057  */
1058  if (OidIsValid(old_address.classId))
1059  {
1060  if (old_address.classId == address.classId
1061  && old_address.objectId == address.objectId
1062  && old_address.objectSubId == address.objectSubId)
1063  break;
1064  if (old_address.classId != RelationRelationId)
1065  {
1066  if (IsSharedRelation(old_address.classId))
1067  UnlockSharedObject(old_address.classId,
1068  old_address.objectId,
1069  0, lockmode);
1070  else
1071  UnlockDatabaseObject(old_address.classId,
1072  old_address.objectId,
1073  0, lockmode);
1074  }
1075  }
1076 
1077  /*
1078  * If we're dealing with a relation or attribute, then the relation is
1079  * already locked. Otherwise, we lock it now.
1080  */
1081  if (address.classId != RelationRelationId)
1082  {
1083  if (IsSharedRelation(address.classId))
1084  LockSharedObject(address.classId, address.objectId, 0,
1085  lockmode);
1086  else
1087  LockDatabaseObject(address.classId, address.objectId, 0,
1088  lockmode);
1089  }
1090 
1091  /*
1092  * At this point, we've resolved the name to an OID and locked the
1093  * corresponding database object. However, it's possible that by the
1094  * time we acquire the lock on the object, concurrent DDL has modified
1095  * the database in such a way that the name we originally looked up no
1096  * longer resolves to that OID.
1097  *
1098  * We can be certain that this isn't an issue if (a) no shared
1099  * invalidation messages have been processed or (b) we've locked a
1100  * relation somewhere along the line. All the relation name lookups
1101  * in this module ultimately use RangeVarGetRelid() to acquire a
1102  * relation lock, and that function protects against the same kinds of
1103  * races we're worried about here. Even when operating on a
1104  * constraint, rule, or trigger, we still acquire AccessShareLock on
1105  * the relation, which is enough to freeze out any concurrent DDL.
1106  *
1107  * In all other cases, however, it's possible that the name we looked
1108  * up no longer refers to the object we locked, so we retry the lookup
1109  * and see whether we get the same answer.
1110  */
1111  if (inval_count == SharedInvalidMessageCounter || relation != NULL)
1112  break;
1113  old_address = address;
1114  }
1115 
1116  /* Return the object address and the relation. */
1117  *relp = relation;
1118  return address;
1119 }
Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError)
Definition: parse_oper.c:140
static ObjectAddress get_object_address_usermapping(List *object, bool missing_ok)
static ObjectAddress get_object_address_publication_rel(List *object, Relation *relp, bool missing_ok)
Oid oidparse(Node *node)
Definition: oid.c:314
static ObjectAddress get_object_address_attribute(ObjectType objtype, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
#define castNode(_type_, nodeptr)
Definition: nodes.h:595
Oid get_language_oid(const char *langname, bool missing_ok)
Definition: proclang.c:250
#define strVal(v)
Definition: value.h:54
int errcode(int sqlerrcode)
Definition: elog.c:610
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2679
unsigned int Oid
Definition: postgres_ext.h:31
#define linitial_node(type, l)
Definition: pg_list.h:198
static ObjectAddress get_object_address_unqualified(ObjectType objtype, Value *strval, bool missing_ok)
#define OidIsValid(objectId)
Definition: c.h:644
#define lsecond(l)
Definition: pg_list.h:200
static ObjectAddress get_relation_by_qualified_name(ObjectType objtype, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
static ObjectAddress get_object_address_attrdef(ObjectType objtype, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2426
Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok)
#define ERROR
Definition: elog.h:43
void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:1023
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2178
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2553
#define NoLock
Definition: lockdefs.h:34
static ObjectAddress get_object_address_relobject(ObjectType objtype, List *object, Relation *relp, bool missing_ok)
void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:961
static ObjectAddress get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
static ObjectAddress get_object_address_opcf(ObjectType objtype, List *object, bool missing_ok)
static ObjectAddress get_object_address_defacl(List *object, bool missing_ok)
void UnlockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:982
#define lsecond_node(type, l)
Definition: pg_list.h:203
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:238
void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:1002
uint64 SharedInvalidMessageCounter
Definition: sinval.c:26
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2300
#define Assert(condition)
Definition: c.h:738
Definition: value.h:42
static ObjectAddress get_object_address_opf_member(ObjectType objtype, List *object, bool missing_ok)
Oid get_conversion_oid(List *name, bool missing_ok)
Definition: namespace.c:3655
bool LargeObjectExists(Oid loid)
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
Definition: parse_func.c:2163
Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
Definition: lsyscache.c:956
Oid get_collation_oid(List *name, bool missing_ok)
Definition: namespace.c:3601
Definition: pg_list.h:50
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
Definition: parse_type.c:232

◆ get_object_address_rv()

ObjectAddress get_object_address_rv ( ObjectType  objtype,
RangeVar rel,
List object,
Relation relp,
LOCKMODE  lockmode,
bool  missing_ok 
)

Definition at line 1129 of file objectaddress.c.

References RangeVar::catalogname, get_object_address(), lcons(), makeString(), RangeVar::relname, and RangeVar::schemaname.

Referenced by ExecAlterObjectDependsStmt().

1132 {
1133  if (rel)
1134  {
1135  object = lcons(makeString(rel->relname), object);
1136  if (rel->schemaname)
1137  object = lcons(makeString(rel->schemaname), object);
1138  if (rel->catalogname)
1139  object = lcons(makeString(rel->catalogname), object);
1140  }
1141 
1142  return get_object_address(objtype, (Node *) object,
1143  relp, lockmode, missing_ok);
1144 }
Value * makeString(char *str)
Definition: value.c:53
Definition: nodes.h:526
char * schemaname
Definition: primnodes.h:67
char * relname
Definition: primnodes.h:68
List * lcons(void *datum, List *list)
Definition: list.c:454
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
char * catalogname
Definition: primnodes.h:66

◆ get_object_attnum_acl()

AttrNumber get_object_attnum_acl ( Oid  class_id)

Definition at line 2609 of file objectaddress.c.

References ObjectPropertyType::attnum_acl, and get_object_property_data().

Referenced by AlterObjectOwner_internal().

2610 {
2611  const ObjectPropertyType *prop = get_object_property_data(class_id);
2612 
2613  return prop->attnum_acl;
2614 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)
AttrNumber attnum_acl

◆ get_object_attnum_name()

AttrNumber get_object_attnum_name ( Oid  class_id)

Definition at line 2585 of file objectaddress.c.

References ObjectPropertyType::attnum_name, and get_object_property_data().

Referenced by AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), EventTriggerSQLDropAddObject(), and pg_identify_object().

2586 {
2587  const ObjectPropertyType *prop = get_object_property_data(class_id);
2588 
2589  return prop->attnum_name;
2590 }
AttrNumber attnum_name
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_attnum_namespace()

AttrNumber get_object_attnum_namespace ( Oid  class_id)

Definition at line 2593 of file objectaddress.c.

References ObjectPropertyType::attnum_namespace, and get_object_property_data().

Referenced by AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), EventTriggerSQLDropAddObject(), pg_event_trigger_ddl_commands(), and pg_identify_object().

2594 {
2595  const ObjectPropertyType *prop = get_object_property_data(class_id);
2596 
2597  return prop->attnum_namespace;
2598 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)
AttrNumber attnum_namespace

◆ get_object_attnum_oid()

AttrNumber get_object_attnum_oid ( Oid  class_id)

Definition at line 2577 of file objectaddress.c.

References ObjectPropertyType::attnum_oid, and get_object_property_data().

Referenced by AlterObjectOwner_internal(), EventTriggerSQLDropAddObject(), pg_event_trigger_ddl_commands(), and pg_identify_object().

2578 {
2579  const ObjectPropertyType *prop = get_object_property_data(class_id);
2580 
2581  return prop->attnum_oid;
2582 }
AttrNumber attnum_oid
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_attnum_owner()

AttrNumber get_object_attnum_owner ( Oid  class_id)

Definition at line 2601 of file objectaddress.c.

References ObjectPropertyType::attnum_owner, and get_object_property_data().

Referenced by AlterObjectNamespace_internal(), AlterObjectOwner_internal(), and AlterObjectRename_internal().

2602 {
2603  const ObjectPropertyType *prop = get_object_property_data(class_id);
2604 
2605  return prop->attnum_owner;
2606 }
AttrNumber attnum_owner
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_catcache_name()

int get_object_catcache_name ( Oid  class_id)

Definition at line 2569 of file objectaddress.c.

References get_object_property_data(), and ObjectPropertyType::name_catcache_id.

Referenced by AlterObjectNamespace_internal(), and AlterObjectRename_internal().

2570 {
2571  const ObjectPropertyType *prop = get_object_property_data(class_id);
2572 
2573  return prop->name_catcache_id;
2574 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_catcache_oid()

int get_object_catcache_oid ( Oid  class_id)

Definition at line 2561 of file objectaddress.c.

References get_object_property_data(), and ObjectPropertyType::oid_catcache_id.

Referenced by AlterObjectNamespace_internal(), AlterObjectRename_internal(), and get_catalog_object_by_oid().

2562 {
2563  const ObjectPropertyType *prop = get_object_property_data(class_id);
2564 
2565  return prop->oid_catcache_id;
2566 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_namensp_unique()

bool get_object_namensp_unique ( Oid  class_id)

Definition at line 2642 of file objectaddress.c.

References get_object_property_data(), and ObjectPropertyType::is_nsp_name_unique.

Referenced by EventTriggerSQLDropAddObject(), and pg_identify_object().

2643 {
2644  const ObjectPropertyType *prop = get_object_property_data(class_id);
2645 
2646  return prop->is_nsp_name_unique;
2647 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_namespace()

Oid get_object_namespace ( const ObjectAddress address)

Definition at line 2494 of file objectaddress.c.

References Assert, ObjectPropertyType::attnum_namespace, ObjectAddress::classId, DatumGetObjectId, elog, ERROR, get_object_property_data(), HeapTupleIsValid, InvalidAttrNumber, InvalidOid, ObjectAddress::objectId, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and SysCacheGetAttr().

Referenced by RemoveObjects().

2495 {
2496  int cache;
2497  HeapTuple tuple;
2498  bool isnull;
2499  Oid oid;
2500  const ObjectPropertyType *property;
2501 
2502  /* If not owned by a namespace, just return InvalidOid. */
2503  property = get_object_property_data(address->classId);
2504  if (property->attnum_namespace == InvalidAttrNumber)
2505  return InvalidOid;
2506 
2507  /* Currently, we can only handle object types with system caches. */
2508  cache = property->oid_catcache_id;
2509  Assert(cache != -1);
2510 
2511  /* Fetch tuple from syscache and extract namespace attribute. */
2512  tuple = SearchSysCache1(cache, ObjectIdGetDatum(address->objectId));
2513  if (!HeapTupleIsValid(tuple))
2514  elog(ERROR, "cache lookup failed for cache %d oid %u",
2515  cache, address->objectId);
2516  oid = DatumGetObjectId(SysCacheGetAttr(cache,
2517  tuple,
2518  property->attnum_namespace,
2519  &isnull));
2520  Assert(!isnull);
2521  ReleaseSysCache(tuple);
2522 
2523  return oid;
2524 }
#define DatumGetObjectId(X)
Definition: postgres.h:500
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
static const ObjectPropertyType * get_object_property_data(Oid class_id)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:738
AttrNumber attnum_namespace
#define InvalidAttrNumber
Definition: attnum.h:23
#define elog(elevel,...)
Definition: elog.h:214

◆ get_object_oid_index()

Oid get_object_oid_index ( Oid  class_id)

Definition at line 2553 of file objectaddress.c.

References get_object_property_data(), and ObjectPropertyType::oid_index_oid.

Referenced by get_catalog_object_by_oid().

2554 {
2555  const ObjectPropertyType *prop = get_object_property_data(class_id);
2556 
2557  return prop->oid_index_oid;
2558 }
static const ObjectPropertyType * get_object_property_data(Oid class_id)

◆ get_object_type()

ObjectType get_object_type ( Oid  class_id,
Oid  object_id 
)

Definition at line 2624 of file objectaddress.c.

References get_object_property_data(), get_rel_relkind(), get_relkind_objtype(), OBJECT_TABLE, and ObjectPropertyType::objtype.

Referenced by AlterObjectNamespace_internal(), AlterObjectOwner_internal(), and AlterObjectRename_internal().

2625 {
2626  const ObjectPropertyType *prop = get_object_property_data(class_id);
2627 
2628  if (prop->objtype == OBJECT_TABLE)
2629  {
2630  /*
2631  * If the property data says it's a table, dig a little deeper to get
2632  * the real relation kind, so that callers can produce more precise
2633  * error messages.
2634  */
2635  return get_relkind_objtype(get_rel_relkind(object_id));
2636  }
2637  else
2638  return prop->objtype;
2639 }
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1866
static const ObjectPropertyType * get_object_property_data(Oid class_id)
ObjectType get_relkind_objtype(char relkind)

◆ get_relkind_objtype()

ObjectType get_relkind_objtype ( char  relkind)

Definition at line 5355 of file objectaddress.c.

References OBJECT_FOREIGN_TABLE, OBJECT_INDEX, OBJECT_MATVIEW, OBJECT_SEQUENCE, OBJECT_TABLE, and OBJECT_VIEW.

Referenced by AlterTableMoveAll(), ATExecChangeOwner(), ATSimplePermissions(), checkFkeyPermissions(), CreateStatistics(), CreateTrigger(), currtid_byrelname(), currtid_byreloid(), DefineQueryRewrite(), EnableDisableRule(), ExecCheckRTPerms(), get_object_type(), get_rel_from_relname(), LockViewRecurse_walker(), MergeAttributes(), pg_prewarm(), pgrowlocks(), PublicationAddTables(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), renameatt_check(), transformTableLikeClause(), and truncate_check_perms().

5356 {
5357  switch (relkind)
5358  {
5359  case RELKIND_RELATION:
5360  case RELKIND_PARTITIONED_TABLE:
5361  return OBJECT_TABLE;
5362  case RELKIND_INDEX:
5363  case RELKIND_PARTITIONED_INDEX:
5364  return OBJECT_INDEX;
5365  case RELKIND_SEQUENCE:
5366  return OBJECT_SEQUENCE;
5367  case RELKIND_VIEW:
5368  return OBJECT_VIEW;
5369  case RELKIND_MATVIEW:
5370  return OBJECT_MATVIEW;
5371  case RELKIND_FOREIGN_TABLE:
5372  return OBJECT_FOREIGN_TABLE;
5373  case RELKIND_TOASTVALUE:
5374  return OBJECT_TABLE;
5375  default:
5376  /* Per above, don't raise an error */
5377  return OBJECT_TABLE;
5378  }
5379 }

◆ getObjectDescription()

char* getObjectDescription ( const ObjectAddress object)

Definition at line 2753 of file objectaddress.c.

References _, AccessMethodOperatorOidIndexId, AccessMethodProcedureOidIndexId, AccessShareLock, AMOID, appendStringInfo(), Assert, AttrDefaultOidIndexId, BTEqualStrategyNumber, CastOidIndexId, CLAOID, ObjectAddress::classId, CollationIsVisible(), COLLOID, CONSTROID, ConversionIsVisible(), CONVOID, StringInfoData::data, datname, DefaultAclOidIndexId, elog, ERROR, EVENTTRIGGEROID, ForeignDataWrapper::fdwname, format_operator(), format_procedure(), format_type_be(), get_attname(), get_database_name(), get_extension_name(), get_language_name(), get_namespace_name(), get_publication_name(), get_subscription_name(), get_tablespace_name(), GetForeignDataWrapper(), GetForeignServer(), getObjectClass(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GETSTRUCT, GetUserNameFromId(), HeapTupleIsValid, initStringInfo(), NameStr, ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OCLASS_AM, OCLASS_AMOP, OCLASS_AMPROC, OCLASS_CAST, OCLASS_CLASS, OCLASS_COLLATION, OCLASS_CONSTRAINT, OCLASS_CONVERSION, OCLASS_DATABASE, OCLASS_DEFACL, OCLASS_DEFAULT, OCLASS_EVENT_TRIGGER, OCLASS_EXTENSION, OCLASS_FDW, OCLASS_FOREIGN_SERVER, OCLASS_LANGUAGE, OCLASS_LARGEOBJECT, OCLASS_OPCLASS, OCLASS_OPERATOR, OCLASS_OPFAMILY, OCLASS_POLICY, OCLASS_PROC, OCLASS_PUBLICATION, OCLASS_PUBLICATION_REL, OCLASS_REWRITE, OCLASS_ROLE, OCLASS_SCHEMA, OCLASS_STATISTIC_EXT, OCLASS_SUBSCRIPTION, OCLASS_TBLSPACE, OCLASS_TRANSFORM, OCLASS_TRIGGER, OCLASS_TSCONFIG, OCLASS_TSDICT, OCLASS_TSPARSER, OCLASS_TSTEMPLATE, OCLASS_TYPE, OCLASS_USER_MAPPING, OidIsValid, OpclassIsVisible(), pfree(), PolicyOidIndexId, PUBLICATIONREL, quote_qualified_identifier(), ReleaseSysCache(), RewriteOidIndexId, ScanKeyInit(), SearchSysCache1(), ForeignServer::servername, STATEXTOID, StatisticsObjIsVisible(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), TRFOID, TriggerOidIndexId, TSConfigIsVisible(), TSCONFIGOID, TSDictionaryIsVisible(), TSDICTOID, TSParserIsVisible(), TSPARSEROID, TSTemplateIsVisible(), TSTEMPLATEOID, and USERMAPPINGOID.

Referenced by AlterExtensionNamespace(), ATExecAlterColumnType(), changeDependenciesOn(), check_relation_privileges(), checkSharedDependencies(), ExecAlterExtensionContentsStmt(), findDependentObjects(), get_object_address_opf_member(), getObjectDescription(), getObjectDescriptionOids(), pg_describe_object(), recordDependencyOnCurrentExtension(), reportDependentObjects(), sepgsql_fmgr_hook(), shdepDropOwned(), shdepReassignOwned(), and storeObjectDescription().

2754 {
2755  StringInfoData buffer;
2756 
2757  initStringInfo(&buffer);
2758 
2759  switch (getObjectClass(object))
2760  {
2761  case OCLASS_CLASS:
2762  if (object->objectSubId == 0)
2763  getRelationDescription(&buffer, object->objectId);
2764  else
2765  {
2766  /* column, not whole relation */
2767  StringInfoData rel;
2768 
2769  initStringInfo(&rel);
2770  getRelationDescription(&rel, object->objectId);
2771  /* translator: second %s is, e.g., "table %s" */
2772  appendStringInfo(&buffer, _("column %s of %s"),
2773  get_attname(object->objectId,
2774  object->objectSubId,
2775  false),
2776  rel.data);
2777  pfree(rel.data);
2778  }
2779  break;
2780 
2781  case OCLASS_PROC:
2782  appendStringInfo(&buffer, _("function %s"),
2783  format_procedure(object->objectId));
2784  break;
2785 
2786  case OCLASS_TYPE:
2787  appendStringInfo(&buffer, _("type %s"),
2788  format_type_be(object->objectId));
2789  break;
2790 
2791  case OCLASS_CAST:
2792  {
2793  Relation castDesc;
2794  ScanKeyData skey[1];
2795  SysScanDesc rcscan;
2796  HeapTuple tup;
2797  Form_pg_cast castForm;
2798 
2799  castDesc = table_open(CastRelationId, AccessShareLock);
2800 
2801  ScanKeyInit(&skey[0],
2802  Anum_pg_cast_oid,
2803  BTEqualStrategyNumber, F_OIDEQ,
2804  ObjectIdGetDatum(object->objectId));
2805 
2806  rcscan = systable_beginscan(castDesc, CastOidIndexId, true,
2807  NULL, 1, skey);
2808 
2809  tup = systable_getnext(rcscan);
2810 
2811  if (!HeapTupleIsValid(tup))
2812  elog(ERROR, "could not find tuple for cast %u",
2813  object->objectId);
2814 
2815  castForm = (Form_pg_cast) GETSTRUCT(tup);
2816 
2817  appendStringInfo(&buffer, _("cast from %s to %s"),
2818  format_type_be(castForm->castsource),
2819  format_type_be(castForm->casttarget));
2820 
2821  systable_endscan(rcscan);
2822  table_close(castDesc, AccessShareLock);
2823  break;
2824  }
2825 
2826  case OCLASS_COLLATION:
2827  {
2828  HeapTuple collTup;
2829  Form_pg_collation coll;
2830  char *nspname;
2831 
2832  collTup = SearchSysCache1(COLLOID,
2833  ObjectIdGetDatum(object->objectId));
2834  if (!HeapTupleIsValid(collTup))
2835  elog(ERROR, "cache lookup failed for collation %u",
2836  object->objectId);
2837  coll = (Form_pg_collation) GETSTRUCT(collTup);
2838 
2839  /* Qualify the name if not visible in search path */
2840  if (CollationIsVisible(object->objectId))
2841  nspname = NULL;
2842  else
2843  nspname = get_namespace_name(coll->collnamespace);
2844 
2845  appendStringInfo(&buffer, _("collation %s"),
2847  NameStr(coll->collname)));
2848  ReleaseSysCache(collTup);
2849  break;
2850  }
2851 
2852  case OCLASS_CONSTRAINT:
2853  {
2854  HeapTuple conTup;
2855  Form_pg_constraint con;
2856 
2857  conTup = SearchSysCache1(CONSTROID,
2858  ObjectIdGetDatum(object->objectId));
2859  if (!HeapTupleIsValid(conTup))
2860  elog(ERROR, "cache lookup failed for constraint %u",
2861  object->objectId);
2862  con = (Form_pg_constraint) GETSTRUCT(conTup);
2863 
2864  if (OidIsValid(con->conrelid))
2865  {
2866  StringInfoData rel;
2867 
2868  initStringInfo(&rel);
2869  getRelationDescription(&rel, con->conrelid);
2870  /* translator: second %s is, e.g., "table %s" */
2871  appendStringInfo(&buffer, _("constraint %s on %s"),
2872  NameStr(con->conname), rel.data);
2873  pfree(rel.data);
2874  }
2875  else
2876  {
2877  appendStringInfo(&buffer, _("constraint %s"),
2878  NameStr(con->conname));
2879  }
2880 
2881  ReleaseSysCache(conTup);
2882  break;
2883  }
2884 
2885  case OCLASS_CONVERSION:
2886  {
2887  HeapTuple conTup;
2888  Form_pg_conversion conv;
2889  char *nspname;
2890 
2891  conTup = SearchSysCache1(CONVOID,
2892  ObjectIdGetDatum(object->objectId));
2893  if (!HeapTupleIsValid(conTup))
2894  elog(ERROR, "cache lookup failed for conversion %u",
2895  object->objectId);
2896  conv = (Form_pg_conversion) GETSTRUCT(conTup);
2897 
2898  /* Qualify the name if not visible in search path */
2899  if (ConversionIsVisible(object->objectId))
2900  nspname = NULL;
2901  else
2902  nspname = get_namespace_name(conv->connamespace);
2903 
2904  appendStringInfo(&buffer, _("conversion %s"),
2906  NameStr(conv->conname)));
2907  ReleaseSysCache(conTup);
2908  break;
2909  }
2910 
2911  case OCLASS_DEFAULT:
2912  {
2913  Relation attrdefDesc;
2914  ScanKeyData skey[1];
2915  SysScanDesc adscan;
2916  HeapTuple tup;
2917  Form_pg_attrdef attrdef;
2918  ObjectAddress colobject;
2919 
2920  attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
2921 
2922  ScanKeyInit(&skey[0],
2923  Anum_pg_attrdef_oid,
2924  BTEqualStrategyNumber, F_OIDEQ,
2925  ObjectIdGetDatum(object->objectId));
2926 
2927  adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId,
2928  true, NULL, 1, skey);
2929 
2930  tup = systable_getnext(adscan);
2931 
2932  if (!HeapTupleIsValid(tup))
2933  elog(ERROR, "could not find tuple for attrdef %u",
2934  object->objectId);
2935 
2936  attrdef = (Form_pg_attrdef) GETSTRUCT(tup);
2937 
2938  colobject.classId = RelationRelationId;
2939  colobject.objectId = attrdef->adrelid;
2940  colobject.objectSubId = attrdef->adnum;
2941 
2942  /* translator: %s is typically "column %s of table %s" */
2943  appendStringInfo(&buffer, _("default value for %s"),
2944  getObjectDescription(&colobject));
2945 
2946  systable_endscan(adscan);
2947  table_close(attrdefDesc, AccessShareLock);
2948  break;
2949  }
2950 
2951  case OCLASS_LANGUAGE:
2952  appendStringInfo(&buffer, _("language %s"),
2953  get_language_name(object->objectId, false));
2954  break;
2955 
2956  case OCLASS_LARGEOBJECT:
2957  appendStringInfo(&buffer, _("large object %u"),
2958  object->objectId);
2959  break;
2960 
2961  case OCLASS_OPERATOR:
2962  appendStringInfo(&buffer, _("operator %s"),
2963  format_operator(object->objectId));
2964  break;
2965 
2966  case OCLASS_OPCLASS:
2967  {
2968  HeapTuple opcTup;
2969  Form_pg_opclass opcForm;
2970  HeapTuple amTup;
2971  Form_pg_am amForm;
2972  char *nspname;
2973 
2974  opcTup = SearchSysCache1(CLAOID,
2975  ObjectIdGetDatum(object->objectId));
2976  if (!HeapTupleIsValid(opcTup))
2977  elog(ERROR, "cache lookup failed for opclass %u",
2978  object->objectId);
2979  opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
2980 
2981  amTup = SearchSysCache1(AMOID,
2982  ObjectIdGetDatum(opcForm->opcmethod));
2983  if (!HeapTupleIsValid(amTup))
2984  elog(ERROR, "cache lookup failed for access method %u",
2985  opcForm->opcmethod);
2986  amForm = (Form_pg_am) GETSTRUCT(amTup);
2987 
2988  /* Qualify the name if not visible in search path */
2989  if (OpclassIsVisible(object->objectId))
2990  nspname = NULL;
2991  else
2992  nspname = get_namespace_name(opcForm->opcnamespace);
2993 
2994  appendStringInfo(&buffer, _("operator class %s for access method %s"),
2996  NameStr(opcForm->opcname)),
2997  NameStr(amForm->amname));
2998 
2999  ReleaseSysCache(amTup);
3000  ReleaseSysCache(opcTup);
3001  break;
3002  }
3003 
3004  case OCLASS_OPFAMILY:
3005  getOpFamilyDescription(&buffer, object->objectId);
3006  break;
3007 
3008  case OCLASS_AM:
3009  {
3010  HeapTuple tup;
3011 
3012  tup = SearchSysCache1(AMOID,
3013  ObjectIdGetDatum(object->objectId));
3014  if (!HeapTupleIsValid(tup))
3015  elog(ERROR, "cache lookup failed for access method %u",
3016  object->objectId);
3017  appendStringInfo(&buffer, _("access method %s"),
3018  NameStr(((Form_pg_am) GETSTRUCT(tup))->amname));
3019  ReleaseSysCache(tup);
3020  break;
3021  }
3022 
3023  case OCLASS_AMOP:
3024  {
3025  Relation amopDesc;
3026  HeapTuple tup;
3027  ScanKeyData skey[1];
3028  SysScanDesc amscan;
3029  Form_pg_amop amopForm;
3030  StringInfoData opfam;
3031 
3032  amopDesc = table_open(AccessMethodOperatorRelationId,
3033  AccessShareLock);
3034 
3035  ScanKeyInit(&skey[0],
3036  Anum_pg_amop_oid,
3037  BTEqualStrategyNumber, F_OIDEQ,
3038  ObjectIdGetDatum(object->objectId));
3039 
3040  amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true,
3041  NULL, 1, skey);
3042 
3043  tup = systable_getnext(amscan);
3044 
3045  if (!HeapTupleIsValid(tup))
3046  elog(ERROR, "could not find tuple for amop entry %u",
3047  object->objectId);
3048 
3049  amopForm = (Form_pg_amop) GETSTRUCT(tup);
3050 
3051  initStringInfo(&opfam);
3052  getOpFamilyDescription(&opfam, amopForm->amopfamily);
3053 
3054  /*------
3055  translator: %d is the operator strategy (a number), the
3056  first two %s's are data type names, the third %s is the
3057  description of the operator family, and the last %s is the
3058  textual form of the operator with arguments. */
3059  appendStringInfo(&buffer, _("operator %d (%s, %s) of %s: %s"),
3060  amopForm->amopstrategy,
3061  format_type_be(amopForm->amoplefttype),
3062  format_type_be(amopForm->amoprighttype),
3063  opfam.data,
3064  format_operator(amopForm->amopopr));
3065 
3066  pfree(opfam.data);
3067 
3068  systable_endscan(amscan);
3069  table_close(amopDesc, AccessShareLock);
3070  break;
3071  }
3072 
3073  case OCLASS_AMPROC:
3074  {
3075  Relation amprocDesc;
3076  ScanKeyData skey[1];
3077  SysScanDesc amscan;
3078  HeapTuple tup;
3079  Form_pg_amproc amprocForm;
3080  StringInfoData opfam;
3081 
3082  amprocDesc = table_open(AccessMethodProcedureRelationId,
3083  AccessShareLock);
3084 
3085  ScanKeyInit(&skey[0],
3086  Anum_pg_amproc_oid,
3087  BTEqualStrategyNumber, F_OIDEQ,
3088  ObjectIdGetDatum(object->objectId));
3089 
3090  amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true,
3091  NULL, 1, skey);
3092 
3093  tup = systable_getnext(amscan);
3094 
3095  if (!HeapTupleIsValid(tup))
3096  elog(ERROR, "could not find tuple for amproc entry %u",
3097  object->objectId);
3098 
3099  amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
3100 
3101  initStringInfo(&opfam);
3102  getOpFamilyDescription(&opfam, amprocForm->amprocfamily);
3103 
3104  /*------
3105  translator: %d is the function number, the first two %s's
3106  are data type names, the third %s is the description of the
3107  operator family, and the last %s is the textual form of the
3108  function with arguments. */
3109  appendStringInfo(&buffer, _("function %d (%s, %s) of %s: %s"),
3110  amprocForm->amprocnum,
3111  format_type_be(amprocForm->amproclefttype),
3112  format_type_be(amprocForm->amprocrighttype),
3113  opfam.data,
3114  format_procedure(amprocForm->amproc));
3115 
3116  pfree(opfam.data);
3117 
3118  systable_endscan(amscan);
3119  table_close(amprocDesc, AccessShareLock);
3120  break;
3121  }
3122 
3123  case OCLASS_REWRITE:
3124  {
3125  Relation ruleDesc;
3126  ScanKeyData skey[1];
3127  SysScanDesc rcscan;
3128  HeapTuple tup;
3130  StringInfoData rel;
3131 
3132  ruleDesc = table_open(RewriteRelationId, AccessShareLock);
3133 
3134  ScanKeyInit(&skey[0],
3135  Anum_pg_rewrite_oid,
3136  BTEqualStrategyNumber, F_OIDEQ,
3137  ObjectIdGetDatum(object->objectId));
3138 
3139  rcscan = systable_beginscan(ruleDesc, RewriteOidIndexId, true,
3140  NULL, 1, skey);
3141 
3142  tup = systable_getnext(rcscan);
3143 
3144  if (!HeapTupleIsValid(tup))
3145  elog(ERROR, "could not find tuple for rule %u",
3146  object->objectId);
3147  rule = (Form_pg_rewrite) GETSTRUCT(tup);
3148 
3149  initStringInfo(&rel);
3150  getRelationDescription(&rel, rule->ev_class);
3151 
3152  /* translator: second %s is, e.g., "table %s" */
3153  appendStringInfo(&buffer, _("rule %s on %s"),
3154  NameStr(rule->rulename), rel.data);
3155  pfree(rel.data);
3156  systable_endscan(rcscan);
3157  table_close(ruleDesc, AccessShareLock);
3158  break;
3159  }
3160 
3161  case OCLASS_TRIGGER:
3162  {
3163  Relation trigDesc;
3164  ScanKeyData skey[1];
3165  SysScanDesc tgscan;
3166  HeapTuple tup;
3167  Form_pg_trigger trig;
3168  StringInfoData rel;
3169 
3170  trigDesc = table_open(TriggerRelationId, AccessShareLock);
3171 
3172  ScanKeyInit(&skey[0],
3173  Anum_pg_trigger_oid,
3174  BTEqualStrategyNumber, F_OIDEQ,
3175  ObjectIdGetDatum(object->objectId));
3176 
3177  tgscan = systable_beginscan(trigDesc, TriggerOidIndexId, true,
3178  NULL, 1, skey);
3179 
3180  tup = systable_getnext(tgscan);
3181 
3182  if (!HeapTupleIsValid(tup))
3183  elog(ERROR, "could not find tuple for trigger %u",
3184  object->objectId);
3185  trig = (Form_pg_trigger) GETSTRUCT(tup);
3186 
3187  initStringInfo(&rel);
3188  getRelationDescription(&rel, trig->tgrelid);
3189 
3190  /* translator: second %s is, e.g., "table %s" */
3191  appendStringInfo(&buffer, _("trigger %s on %s"),
3192  NameStr(trig->tgname), rel.data);
3193  pfree(rel.data);
3194  systable_endscan(tgscan);
3195  table_close(trigDesc, AccessShareLock);
3196  break;
3197  }
3198 
3199  case OCLASS_SCHEMA:
3200  {
3201  char *nspname;
3202 
3203  nspname = get_namespace_name(object->objectId);
3204  if (!nspname)
3205  elog(ERROR, "cache lookup failed for namespace %u",
3206  object->objectId);
3207  appendStringInfo(&buffer, _("schema %s"), nspname);
3208  break;
3209  }
3210 
3211  case OCLASS_STATISTIC_EXT:
3212  {
3213  HeapTuple stxTup;
3214  Form_pg_statistic_ext stxForm;
3215  char *nspname;
3216 
3217  stxTup = SearchSysCache1(STATEXTOID,
3218  ObjectIdGetDatum(object->objectId));
3219  if (!HeapTupleIsValid(stxTup))
3220  elog(ERROR, "could not find tuple for statistics object %u",
3221  object->objectId);
3222  stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup);
3223 
3224  /* Qualify the name if not visible in search path */
3225  if (StatisticsObjIsVisible(object->objectId))
3226  nspname = NULL;
3227  else
3228  nspname = get_namespace_name(stxForm->stxnamespace);
3229 
3230  appendStringInfo(&buffer, _("statistics object %s"),
3232  NameStr(stxForm->stxname)));
3233 
3234  ReleaseSysCache(stxTup);
3235  break;
3236  }
3237 
3238  case OCLASS_TSPARSER:
3239  {
3240  HeapTuple tup;
3241  Form_pg_ts_parser prsForm;
3242  char *nspname;
3243 
3245  ObjectIdGetDatum(object->objectId));
3246  if (!HeapTupleIsValid(tup))
3247  elog(ERROR, "cache lookup failed for text search parser %u",
3248  object->objectId);
3249  prsForm = (Form_pg_ts_parser) GETSTRUCT(tup);
3250 
3251  /* Qualify the name if not visible in search path */
3252  if (TSParserIsVisible(object->objectId))
3253  nspname = NULL;
3254  else
3255  nspname = get_namespace_name(prsForm->prsnamespace);
3256 
3257  appendStringInfo(&buffer, _("text search parser %s"),
3259  NameStr(prsForm->prsname)));
3260  ReleaseSysCache(tup);
3261  break;
3262  }
3263 
3264  case OCLASS_TSDICT:
3265  {
3266  HeapTuple tup;
3267  Form_pg_ts_dict dictForm;
3268  char *nspname;
3269 
3270  tup = SearchSysCache1(TSDICTOID,
3271  ObjectIdGetDatum(object->objectId));
3272  if (!HeapTupleIsValid(tup))
3273  elog(ERROR, "cache lookup failed for text search dictionary %u",
3274  object->objectId);
3275  dictForm = (Form_pg_ts_dict) GETSTRUCT(tup);
3276 
3277  /* Qualify the name if not visible in search path */
3278  if (TSDictionaryIsVisible(object->objectId))
3279  nspname = NULL;
3280  else
3281  nspname = get_namespace_name(dictForm->dictnamespace);
3282 
3283  appendStringInfo(&buffer, _("text search dictionary %s"),
3285  NameStr(dictForm->dictname)));
3286  ReleaseSysCache(tup);
3287  break;
3288  }
3289 
3290  case OCLASS_TSTEMPLATE:
3291  {
3292  HeapTuple tup;
3293  Form_pg_ts_template tmplForm;
3294  char *nspname;
3295 
3297  ObjectIdGetDatum(object->objectId));
3298  if (!HeapTupleIsValid(tup))
3299  elog(ERROR, "cache lookup failed for text search template %u",
3300  object->objectId);
3301  tmplForm = (Form_pg_ts_template) GETSTRUCT(tup);
3302 
3303  /* Qualify the name if not visible in search path */
3304  if (TSTemplateIsVisible(object->objectId))
3305  nspname = NULL;
3306  else
3307  nspname = get_namespace_name(tmplForm->tmplnamespace);
3308 
3309  appendStringInfo(&buffer, _("text search template %s"),
3311  NameStr(tmplForm->tmplname)));
3312  ReleaseSysCache(tup);
3313  break;
3314  }
3315 
3316  case OCLASS_TSCONFIG:
3317  {
3318  HeapTuple tup;
3319  Form_pg_ts_config cfgForm;
3320  char *nspname;
3321 
3323  ObjectIdGetDatum(object->objectId));
3324  if (!HeapTupleIsValid(tup))
3325  elog(ERROR, "cache lookup failed for text search configuration %u",
3326  object->objectId);
3327  cfgForm = (Form_pg_ts_config) GETSTRUCT(tup);
3328 
3329  /* Qualify the name if not visible in search path */
3330  if (TSConfigIsVisible(object->objectId))
3331  nspname = NULL;
3332  else
3333  nspname = get_namespace_name(cfgForm->cfgnamespace);
3334 
3335  appendStringInfo(&buffer, _("text search configuration %s"),
3337  NameStr(cfgForm->cfgname)));
3338  ReleaseSysCache(tup);
3339  break;
3340  }
3341 
3342  case OCLASS_ROLE:
3343  {
3344  appendStringInfo(&buffer, _("role %s"),
3345  GetUserNameFromId(object->objectId, false));
3346  break;
3347  }
3348 
3349  case OCLASS_DATABASE:
3350  {
3351  char *datname;
3352 
3353  datname = get_database_name(object->objectId);
3354  if (!datname)
3355  elog(ERROR, "cache lookup failed for database %u",
3356  object->objectId);
3357  appendStringInfo(&buffer, _("database %s"), datname);
3358  break;
3359  }
3360 
3361  case OCLASS_TBLSPACE:
3362  {
3363  char *tblspace;
3364 
3365  tblspace = get_tablespace_name(object->objectId);
3366  if (!tblspace)
3367  elog(ERROR, "cache lookup failed for tablespace %u",
3368  object->objectId);
3369  appendStringInfo(&buffer, _("tablespace %s"), tblspace);
3370  break;
3371  }
3372 
3373  case OCLASS_FDW:
3374  {
3375  ForeignDataWrapper *fdw;
3376 
3377  fdw = GetForeignDataWrapper(object->objectId);
3378  appendStringInfo(&buffer, _("foreign-data wrapper %s"), fdw->fdwname);
3379  break;
3380  }
3381 
3382  case OCLASS_FOREIGN_SERVER:
3383  {
3384  ForeignServer *srv;
3385 
3386  srv = GetForeignServer(object->objectId);
3387  appendStringInfo(&buffer, _("server %s"), srv->servername);
3388  break;
3389  }
3390 
3391  case OCLASS_USER_MAPPING:
3392  {
3393  HeapTuple tup;
3394  Oid useid;
3395  char *usename;
3396  Form_pg_user_mapping umform;
3397  ForeignServer *srv;
3398 
3400  ObjectIdGetDatum(object->objectId));
3401  if (!HeapTupleIsValid(tup))
3402  elog(ERROR, "cache lookup failed for user mapping %u",
3403  object->objectId);
3404  umform = (Form_pg_user_mapping) GETSTRUCT(tup);
3405  useid = umform->umuser;
3406  srv = GetForeignServer(umform->umserver);
3407 
3408  ReleaseSysCache(tup);
3409 
3410  if (OidIsValid(useid))
3411  usename = GetUserNameFromId(useid, false);
3412  else
3413  usename = "public";
3414 
3415  appendStringInfo(&buffer, _("user mapping for %s on server %s"), usename,
3416  srv->servername);
3417  break;
3418  }
3419 
3420  case OCLASS_DEFACL:
3421  {
3422  Relation defaclrel;
3423  ScanKeyData skey[1];
3424  SysScanDesc rcscan;
3425  HeapTuple tup;
3426  Form_pg_default_acl defacl;
3427  char *rolename;
3428  char *nspname;
3429 
3430  defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
3431 
3432  ScanKeyInit(&skey[0],
3433  Anum_pg_default_acl_oid,
3434  BTEqualStrategyNumber, F_OIDEQ,
3435  ObjectIdGetDatum(object->objectId));
3436 
3437  rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId,
3438  true, NULL, 1, skey);
3439 
3440  tup = systable_getnext(rcscan);
3441 
3442  if (!HeapTupleIsValid(tup))
3443  elog(ERROR, "could not find tuple for default ACL %u",
3444  object->objectId);
3445 
3446  defacl = (Form_pg_default_acl) GETSTRUCT(tup);
3447 
3448  rolename = GetUserNameFromId(defacl->defaclrole, false);
3449 
3450  if (OidIsValid(defacl->defaclnamespace))
3451  nspname = get_namespace_name(defacl->defaclnamespace);
3452  else
3453  nspname = NULL;
3454 
3455  switch (defacl->defaclobjtype)
3456  {
3457  case DEFACLOBJ_RELATION:
3458  if (nspname)
3459  appendStringInfo(&buffer,
3460  _("default privileges on new relations belonging to role %s in schema %s"),
3461  rolename, nspname);
3462  else
3463  appendStringInfo(&buffer,
3464  _("default privileges on new relations belonging to role %s"),
3465  rolename);
3466  break;
3467  case DEFACLOBJ_SEQUENCE:
3468  if (nspname)
3469  appendStringInfo(&buffer,
3470  _("default privileges on new sequences belonging to role %s in schema %s"),
3471  rolename, nspname);
3472  else
3473  appendStringInfo(&buffer,
3474  _("default privileges on new sequences belonging to role %s"),
3475  rolename);
3476  break;
3477  case DEFACLOBJ_FUNCTION:
3478  if (nspname)
3479  appendStringInfo(&buffer,
3480  _("default privileges on new functions belonging to role %s in schema %s"),
3481  rolename, nspname);
3482  else
3483  appendStringInfo(&buffer,
3484  _("default privileges on new functions belonging to role %s"),
3485  rolename);
3486  break;
3487  case DEFACLOBJ_TYPE:
3488  if (nspname)
3489  appendStringInfo(&buffer,
3490  _("default privileges on new types belonging to role %s in schema %s"),
3491  rolename, nspname);
3492  else
3493  appendStringInfo(&buffer,
3494  _("default privileges on new types belonging to role %s"),
3495  rolename);
3496  break;
3497  case DEFACLOBJ_NAMESPACE:
3498  Assert(!nspname);
3499  appendStringInfo(&buffer,
3500  _("default privileges on new schemas belonging to role %s"),
3501  rolename);
3502  break;
3503  default:
3504  /* shouldn't get here */
3505  if (nspname)
3506  appendStringInfo(&buffer,
3507  _("default privileges belonging to role %s in schema %s"),
3508  rolename, nspname);
3509  else
3510  appendStringInfo(&buffer,
3511  _("default privileges belonging to role %s"),
3512  rolename);
3513  break;
3514  }
3515 
3516  systable_endscan(rcscan);
3517  table_close(defaclrel, AccessShareLock);
3518  break;
3519  }
3520 
3521  case OCLASS_EXTENSION:
3522  {
3523  char *extname;
3524 
3525  extname = get_extension_name(object->objectId);
3526  if (!extname)
3527  elog(ERROR, "cache lookup failed for extension %u",
3528  object->objectId);
3529  appendStringInfo(&buffer, _("extension %s"), extname);
3530  break;
3531  }
3532 
3533  case OCLASS_EVENT_TRIGGER:
3534  {
3535  HeapTuple tup;
3536 
3538  ObjectIdGetDatum(object->objectId));
3539  if (!HeapTupleIsValid(tup))
3540  elog(ERROR, "cache lookup failed for event trigger %u",
3541  object->objectId);
3542  appendStringInfo(&buffer, _("event trigger %s"),
3543  NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname));
3544  ReleaseSysCache(tup);
3545  break;
3546  }
3547 
3548  case OCLASS_POLICY:
3549  {
3550  Relation policy_rel;
3551  ScanKeyData skey[1];
3552  SysScanDesc sscan;
3553  HeapTuple tuple;
3554  Form_pg_policy form_policy;
3555  StringInfoData rel;
3556 
3557  policy_rel = table_open(PolicyRelationId, AccessShareLock);
3558 
3559  ScanKeyInit(&skey[0],
3560  Anum_pg_policy_oid,
3561  BTEqualStrategyNumber, F_OIDEQ,
3562  ObjectIdGetDatum(object->objectId));
3563 
3564  sscan = systable_beginscan(policy_rel, PolicyOidIndexId,
3565  true, NULL, 1, skey);
3566 
3567  tuple = systable_getnext(sscan);
3568 
3569  if (!HeapTupleIsValid(tuple))
3570  elog(ERROR, "could not find tuple for policy %u",
3571  object->objectId);
3572  form_policy = (Form_pg_policy) GETSTRUCT(tuple);
3573 
3574  initStringInfo(&rel);
3575  getRelationDescription(&rel, form_policy->polrelid);
3576 
3577  /* translator: second %s is, e.g., "table %s" */
3578  appendStringInfo(&buffer, _("policy %s on %s"),
3579  NameStr(form_policy->polname), rel.data);
3580  pfree(rel.data);
3581  systable_endscan(sscan);
3582  table_close(policy_rel, AccessShareLock);
3583  break;
3584  }
3585 
3586  case OCLASS_PUBLICATION:
3587  {
3588  appendStringInfo(&buffer, _("publication %s"),
3590  false));
3591  break;
3592  }
3593 
3595  {
3596  HeapTuple tup;
3597  char *pubname;
3598  Form_pg_publication_rel prform;
3599  StringInfoData rel;
3600 
3602  ObjectIdGetDatum(object->objectId));
3603  if (!HeapTupleIsValid(tup))
3604  elog(ERROR, "cache lookup failed for publication table %u",
3605  object->objectId);
3606 
3607  prform = (Form_pg_publication_rel) GETSTRUCT(tup);
3608  pubname = get_publication_name(prform->prpubid, false);
3609 
3610  initStringInfo(&rel);
3611  getRelationDescription(&rel, prform->prrelid);
3612 
3613  /* translator: first %s is, e.g., "table %s" */
3614  appendStringInfo(&buffer, _("publication of %s in publication %s"),
3615  rel.data, pubname);
3616  pfree(rel.data);
3617  ReleaseSysCache(tup);
3618  break;
3619  }
3620 
3621  case OCLASS_SUBSCRIPTION:
3622  {
3623  appendStringInfo(&buffer, _("subscription %s"),
3625  false));
3626  break;
3627  }
3628 
3629  case OCLASS_TRANSFORM:
3630  {
3631  HeapTuple trfTup;
3632  Form_pg_transform trfForm;
3633 
3634  trfTup = SearchSysCache1(TRFOID,
3635  ObjectIdGetDatum(object->objectId));
3636  if (!HeapTupleIsValid(trfTup))
3637  elog(ERROR, "could not find tuple for transform %u",
3638  object->objectId);
3639 
3640  trfForm = (Form_pg_transform) GETSTRUCT(trfTup);
3641 
3642  appendStringInfo(&buffer, _("transform for %s language %s"),
3643  format_type_be(trfForm->trftype),
3644  get_language_name(trfForm->trflang, false));
3645 
3646  ReleaseSysCache(trfTup);
3647  break;
3648  }
3649 
3650  /*
3651  * There's intentionally no default: case here; we want the
3652  * compiler to warn if a new OCLASS hasn't been handled above.
3653  */
3654  }
3655 
3656  return buffer.data;
3657 }
#define RewriteOidIndexId
Definition: indexing.h:215
#define TriggerOidIndexId
Definition: indexing.h:255
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:529
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: syscache.h:36
char * get_language_name(Oid langoid, bool missing_ok)
Definition: lsyscache.c:1051
FormData_pg_ts_config * Form_pg_ts_config
Definition: pg_ts_config.h:48
char * fdwname
Definition: foreign.h:28
#define PolicyOidIndexId
Definition: indexing.h:331
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
char * get_extension_name(Oid ext_oid)
Definition: extension.c:185
#define DefaultAclOidIndexId
Definition: indexing.h:311
#define AccessShareLock
Definition: lockdefs.h:36
bool StatisticsObjIsVisible(Oid relid)
Definition: namespace.c:2235
static void getOpFamilyDescription(StringInfo buffer, Oid opfid)
#define AttrDefaultOidIndexId
Definition: indexing.h:91
#define AccessMethodOperatorOidIndexId
Definition: indexing.h:81
char * format_type_be(Oid type_oid)
Definition: format_type.c:327
NameData datname
Definition: pg_database.h:35
char * format_operator(Oid operator_oid)
Definition: regproc.c:821
unsigned int Oid
Definition: postgres_ext.h:31
ObjectClass getObjectClass(const ObjectAddress *object)
Definition: dependency.c:2725
#define OidIsValid(objectId)
Definition: c.h:644
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:356
char * get_publication_name(Oid pubid, bool missing_ok)
char * getObjectDescription(const ObjectAddress *object)
Definition: localtime.c:79
char * get_subscription_name(Oid subid, bool missing_ok)
#define AccessMethodProcedureOidIndexId
Definition: indexing.h:86
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:448
ForeignDataWrapper * GetForeignDataWrapper(Oid fdwid)
Definition: foreign.c:35
void pfree(void *pointer)
Definition: mcxt.c:1056
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2737
char * get_database_name(Oid dbid)
Definition: dbcommands.c:2155
FormData_pg_user_mapping * Form_pg_user_mapping
FormData_pg_ts_dict * Form_pg_ts_dict
Definition: pg_ts_dict.h:52
FormData_pg_default_acl * Form_pg_default_acl
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3155
#define CastOidIndexId
Definition: indexing.h:109
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2048
FormData_pg_cast * Form_pg_cast
Definition: pg_cast.h:57
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
FormData_pg_attrdef * Form_pg_attrdef
Definition: pg_attrdef.h:47
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2484
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:10808
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
ForeignServer * GetForeignServer(Oid serverid)
Definition: foreign.c:109
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_ts_parser * Form_pg_ts_parser
Definition: pg_ts_parser.h:55
FormData_pg_conversion * Form_pg_conversion
Definition: pg_conversion.h:61
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1833
FormData_pg_policy * Form_pg_policy
Definition: pg_policy.h:50
char * format_procedure(Oid procedure_oid)
Definition: regproc.c:324
static void getRelationDescription(StringInfo buffer, Oid relid)
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2131
FormData_pg_constraint * Form_pg_constraint
FormData_pg_event_trigger * Form_pg_event_trigger
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
char * GetUserNameFromId(Oid roleid, bool noerr)
Definition: miscinit.c:854
#define Assert(condition)
Definition: c.h:738
FormData_pg_trigger * Form_pg_trigger
Definition: pg_trigger.h:72
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
FormData_pg_rewrite * Form_pg_rewrite
Definition: pg_rewrite.h:52
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2611
FormData_pg_am * Form_pg_am
Definition: pg_am.h:48
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2358
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
char * get_tablespace_name(Oid spc_oid)
Definition: tablespace.c:1462
char * servername
Definition: foreign.h:39
FormData_pg_ts_template * Form_pg_ts_template
#define elog(elevel,...)
Definition: elog.h:214
FormData_pg_publication_rel * Form_pg_publication_rel
#define NameStr(name)
Definition: c.h:615
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Definition: lsyscache.c:776
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83
#define _(x)
Definition: elog.c:88
#define BTEqualStrategyNumber
Definition: stratnum.h:31
FormData_pg_statistic_ext * Form_pg_statistic_ext

◆ getObjectDescriptionOids()

char* getObjectDescriptionOids ( Oid  classid,
Oid  objid 
)

Definition at line 3663 of file objectaddress.c.

References ObjectAddress::classId, getObjectDescription(), ObjectAddress::objectId, and ObjectAddress::objectSubId.

Referenced by AlterObjectNamespace_internal(), and AlterObjectRename_internal().

3664 {
3665  ObjectAddress address;
3666 
3667  address.classId = classid;
3668  address.objectId = objid;
3669  address.objectSubId = 0;
3670 
3671  return getObjectDescription(&address);
3672 }
char * getObjectDescription(const ObjectAddress *object)

◆ getObjectIdentity()

◆ getObjectIdentityParts()

char* getObjectIdentityParts ( const ObjectAddress address,
List **  objname,
List **  objargs 
)

Definition at line 4296 of file objectaddress.c.

References AccessMethodOperatorOidIndexId, AccessMethodProcedureOidIndexId, AccessShareLock, AMOID, appendStringInfo(), appendStringInfoString(), Assert, AttrDefaultOidIndexId, BTEqualStrategyNumber, CLAOID, ObjectAddress::classId, COLLOID, CONSTROID, CONVOID, StringInfoData::data, datname, DefaultAclOidIndexId, elog, ERROR, EVENTTRIGGEROID, ForeignDataWrapper::fdwname, format_operator_parts(), format_operator_qualified(), format_procedure_parts(), format_procedure_qualified(), format_type_be_qualified(), get_am_name(), get_attname(), get_catalog_object_by_oid(), get_database_name(), get_extension_name(), get_language_name(), get_namespace_name_or_temp(), get_publication_name(), get_subscription_name(), get_tablespace_name(), GetForeignDataWrapper(), GetForeignServer(), getObjectClass(), getObjectIdentityParts(), getOpFamilyIdentity(), getRelationIdentity(), GETSTRUCT, GetUserNameFromId(), HeapTupleIsValid, initStringInfo(), LANGOID, lappend(), list_make1, list_make2, list_make3, NameStr, NIL, ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OCLASS_AM, OCLASS_AMOP, OCLASS_AMPROC, OCLASS_CAST, OCLASS_CLASS, OCLASS_COLLATION, OCLASS_CONSTRAINT, OCLASS_CONVERSION, OCLASS_DATABASE, OCLASS_DEFACL, OCLASS_DEFAULT, OCLASS_EVENT_TRIGGER, OCLASS_EXTENSION, OCLASS_FDW, OCLASS_FOREIGN_SERVER, OCLASS_LANGUAGE, OCLASS_LARGEOBJECT, OCLASS_OPCLASS, OCLASS_OPERATOR, OCLASS_OPFAMILY, OCLASS_POLICY, OCLASS_PROC, OCLASS_PUBLICATION, OCLASS_PUBLICATION_REL, OCLASS_REWRITE, OCLASS_ROLE, OCLASS_SCHEMA, OCLASS_STATISTIC_EXT, OCLASS_SUBSCRIPTION, OCLASS_TBLSPACE, OCLASS_TRANSFORM, OCLASS_TRIGGER, OCLASS_TSCONFIG, OCLASS_TSDICT, OCLASS_TSPARSER, OCLASS_TSTEMPLATE, OCLASS_TYPE, OCLASS_USER_MAPPING, OidIsValid, pfree(), PointerIsValid, psprintf(), pstrdup(), PUBLICATIONREL, quote_identifier(), quote_qualified_identifier(), ReleaseSysCache(), ScanKeyInit(), SearchSysCache1(), ForeignServer::servername, STATEXTOID, subname, systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), TSCONFIGOID, TSDICTOID, TSPARSEROID, TSTEMPLATEOID, USERMAPPINGOID, and username.

Referenced by EventTriggerSQLDropAddObject(), getObjectIdentity(), getObjectIdentityParts(), and pg_identify_object_as_address().

4298 {
4299  StringInfoData buffer;
4300 
4301  initStringInfo(&buffer);
4302 
4303  /*
4304  * Make sure that both objname and objargs were passed, or none was; and
4305  * initialize them to empty lists. For objname this is useless because it
4306  * will be initialized in all cases inside the switch; but we do it anyway
4307  * so that we can test below that no branch leaves it unset.
4308  */
4309  Assert(PointerIsValid(objname) == PointerIsValid(objargs));
4310  if (objname)
4311  {
4312  *objname = NIL;
4313  *objargs = NIL;
4314  }
4315 
4316  switch (getObjectClass(object))
4317  {
4318  case OCLASS_CLASS:
4319  getRelationIdentity(&buffer, object->objectId, objname);
4320  if (object->objectSubId != 0)
4321  {
4322  char *attr;
4323 
4324  attr = get_attname(object->objectId, object->objectSubId,
4325  false);
4326  appendStringInfo(&buffer, ".%s", quote_identifier(attr));
4327  if (objname)
4328  *objname = lappend(*objname, attr);
4329  }
4330  break;
4331 
4332  case OCLASS_PROC:
4333  appendStringInfoString(&buffer,
4334  format_procedure_qualified(object->objectId));
4335  if (objname)
4336  format_procedure_parts(object->objectId, objname, objargs);
4337  break;
4338 
4339  case OCLASS_TYPE:
4340  {
4341  char *typeout;
4342 
4343  typeout = format_type_be_qualified(object->objectId);
4344  appendStringInfoString(&buffer, typeout);
4345  if (objname)
4346  *objname = list_make1(typeout);
4347  }
4348  break;
4349 
4350  case OCLASS_CAST:
4351  {
4352  Relation castRel;
4353  HeapTuple tup;
4354  Form_pg_cast castForm;
4355 
4356  castRel = table_open(CastRelationId, AccessShareLock);
4357 
4358  tup = get_catalog_object_by_oid(castRel, Anum_pg_cast_oid,
4359  object->objectId);
4360 
4361  if (!HeapTupleIsValid(tup))
4362  elog(ERROR, "could not find tuple for cast %u",
4363  object->objectId);
4364 
4365  castForm = (Form_pg_cast) GETSTRUCT(tup);
4366 
4367  appendStringInfo(&buffer, "(%s AS %s)",
4368  format_type_be_qualified(castForm->castsource),
4369  format_type_be_qualified(castForm->casttarget));
4370 
4371  if (objname)
4372  {
4373  *objname = list_make1(format_type_be_qualified(castForm->castsource));
4374  *objargs = list_make1(format_type_be_qualified(castForm->casttarget));
4375  }
4376 
4377  table_close(castRel, AccessShareLock);
4378  break;
4379  }
4380 
4381  case OCLASS_COLLATION:
4382  {
4383  HeapTuple collTup;
4384  Form_pg_collation coll;
4385  char *schema;
4386 
4387  collTup = SearchSysCache1(COLLOID,
4388  ObjectIdGetDatum(object->objectId));
4389  if (!HeapTupleIsValid(collTup))
4390  elog(ERROR, "cache lookup failed for collation %u",
4391  object->objectId);
4392  coll = (Form_pg_collation) GETSTRUCT(collTup);
4393  schema = get_namespace_name_or_temp(coll->collnamespace);
4394  appendStringInfoString(&buffer,
4396  NameStr(coll->collname)));
4397  if (objname)
4398  *objname = list_make2(schema,
4399  pstrdup(NameStr(coll->collname)));
4400  ReleaseSysCache(collTup);
4401  break;
4402  }
4403 
4404  case OCLASS_CONSTRAINT:
4405  {
4406  HeapTuple conTup;
4407  Form_pg_constraint con;
4408 
4409  conTup = SearchSysCache1(CONSTROID,
4410  ObjectIdGetDatum(object->objectId));
4411  if (!HeapTupleIsValid(conTup))
4412  elog(ERROR, "cache lookup failed for constraint %u",
4413  object->objectId);
4414  con = (Form_pg_constraint) GETSTRUCT(conTup);
4415 
4416  if (OidIsValid(con->conrelid))
4417  {
4418  appendStringInfo(&buffer, "%s on ",
4419  quote_identifier(NameStr(con->conname)));
4420  getRelationIdentity(&buffer, con->conrelid, objname);
4421  if (objname)
4422  *objname = lappend(*objname, pstrdup(NameStr(con->conname)));
4423  }
4424  else
4425  {
4426  ObjectAddress domain;
4427 
4428  Assert(OidIsValid(con->contypid));
4429  domain.classId = TypeRelationId;
4430  domain.objectId = con->contypid;
4431  domain.objectSubId = 0;
4432 
4433  appendStringInfo(&buffer, "%s on %s",
4434  quote_identifier(NameStr(con->conname)),
4435  getObjectIdentityParts(&domain, objname, objargs));
4436 
4437  if (objname)
4438  *objargs = lappend(*objargs, pstrdup(NameStr(con->conname)));
4439  }
4440 
4441  ReleaseSysCache(conTup);
4442  break;
4443  }
4444 
4445  case OCLASS_CONVERSION:
4446  {
4447  HeapTuple conTup;
4448  Form_pg_conversion conForm;
4449  char *schema;
4450 
4451  conTup = SearchSysCache1(CONVOID,
4452  ObjectIdGetDatum(object->objectId));
4453  if (!HeapTupleIsValid(conTup))
4454  elog(ERROR, "cache lookup failed for conversion %u",
4455  object->objectId);
4456  conForm = (Form_pg_conversion) GETSTRUCT(conTup);
4457  schema = get_namespace_name_or_temp(conForm->connamespace);
4458  appendStringInfoString(&buffer,
4460  NameStr(conForm->conname)));
4461  if (objname)
4462  *objname = list_make2(schema,
4463  pstrdup(NameStr(conForm->conname)));
4464  ReleaseSysCache(conTup);
4465  break;
4466  }
4467 
4468  case OCLASS_DEFAULT:
4469  {
4470  Relation attrdefDesc;
4471  ScanKeyData skey[1];
4472  SysScanDesc adscan;
4473 
4474  HeapTuple tup;
4475  Form_pg_attrdef attrdef;
4476  ObjectAddress colobject;
4477 
4478  attrdefDesc = table_open(AttrDefaultRelationId, AccessShareLock);
4479 
4480  ScanKeyInit(&skey[0],
4481  Anum_pg_attrdef_oid,
4482  BTEqualStrategyNumber, F_OIDEQ,
4483  ObjectIdGetDatum(object->objectId));
4484 
4485  adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId,
4486  true, NULL, 1, skey);
4487 
4488  tup = systable_getnext(adscan);
4489 
4490  if (!HeapTupleIsValid(tup))
4491  elog(ERROR, "could not find tuple for attrdef %u",
4492  object->objectId);
4493 
4494  attrdef = (Form_pg_attrdef) GETSTRUCT(tup);
4495 
4496  colobject.classId = RelationRelationId;
4497  colobject.objectId = attrdef->adrelid;
4498  colobject.objectSubId = attrdef->adnum;
4499 
4500  appendStringInfo(&buffer, "for %s",
4501  getObjectIdentityParts(&colobject,
4502  objname, objargs));
4503 
4504  systable_endscan(adscan);
4505  table_close(attrdefDesc, AccessShareLock);
4506  break;
4507  }
4508 
4509  case OCLASS_LANGUAGE:
4510  {
4511  HeapTuple langTup;
4512  Form_pg_language langForm;
4513 
4514  langTup = SearchSysCache1(LANGOID,
4515  ObjectIdGetDatum(object->objectId));
4516  if (!HeapTupleIsValid(langTup))
4517  elog(ERROR, "cache lookup failed for language %u",
4518  object->objectId);
4519  langForm = (Form_pg_language) GETSTRUCT(langTup);
4520  appendStringInfoString(&buffer,
4521  quote_identifier(NameStr(langForm->lanname)));
4522  if (objname)
4523  *objname = list_make1(pstrdup(NameStr(langForm->lanname)));
4524  ReleaseSysCache(langTup);
4525  break;
4526  }
4527  case OCLASS_LARGEOBJECT:
4528  appendStringInfo(&buffer, "%u",
4529  object->objectId);
4530  if (objname)
4531  *objname = list_make1(psprintf("%u", object->objectId));
4532  break;
4533 
4534  case OCLASS_OPERATOR:
4535  appendStringInfoString(&buffer,
4536  format_operator_qualified(object->objectId));
4537  if (objname)
4538  format_operator_parts(object->objectId, objname, objargs);
4539  break;
4540 
4541  case OCLASS_OPCLASS:
4542  {
4543  HeapTuple opcTup;
4544  Form_pg_opclass opcForm;
4545  HeapTuple amTup;
4546  Form_pg_am amForm;
4547  char *schema;
4548 
4549  opcTup = SearchSysCache1(CLAOID,
4550  ObjectIdGetDatum(object->objectId));
4551  if (!HeapTupleIsValid(opcTup))
4552  elog(ERROR, "cache lookup failed for opclass %u",
4553  object->objectId);
4554  opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
4555  schema = get_namespace_name_or_temp(opcForm->opcnamespace);
4556 
4557  amTup = SearchSysCache1(AMOID,
4558  ObjectIdGetDatum(opcForm->opcmethod));
4559  if (!HeapTupleIsValid(amTup))
4560  elog(ERROR, "cache lookup failed for access method %u",
4561  opcForm->opcmethod);
4562  amForm = (Form_pg_am) GETSTRUCT(amTup);
4563 
4564  appendStringInfo(&buffer, "%s USING %s",
4566  NameStr(opcForm->opcname)),
4567  quote_identifier(NameStr(amForm->amname)));
4568  if (objname)
4569  *objname = list_make3(pstrdup(NameStr(amForm->amname)),
4570  schema,
4571  pstrdup(NameStr(opcForm->opcname)));
4572 
4573  ReleaseSysCache(amTup);
4574  ReleaseSysCache(opcTup);
4575  break;
4576  }
4577 
4578  case OCLASS_OPFAMILY:
4579  getOpFamilyIdentity(&buffer, object->objectId, objname);
4580  break;
4581 
4582  case OCLASS_AM:
4583  {
4584  char *amname;
4585 
4586  amname = get_am_name(object->objectId);
4587  if (!amname)
4588  elog(ERROR, "cache lookup failed for access method %u",
4589  object->objectId);
4590  appendStringInfoString(&buffer, quote_identifier(amname));
4591  if (objname)
4592  *objname = list_make1(amname);
4593  }
4594  break;
4595 
4596  case OCLASS_AMOP:
4597  {
4598  Relation amopDesc;
4599  HeapTuple tup;
4600  ScanKeyData skey[1];
4601  SysScanDesc amscan;
4602  Form_pg_amop amopForm;
4603  StringInfoData opfam;
4604  char *ltype;
4605  char *rtype;
4606 
4607  amopDesc = table_open(AccessMethodOperatorRelationId,
4608  AccessShareLock);
4609 
4610  ScanKeyInit(&skey[0],
4611  Anum_pg_amop_oid,
4612  BTEqualStrategyNumber, F_OIDEQ,
4613  ObjectIdGetDatum(object->objectId));
4614 
4615  amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true,
4616  NULL, 1, skey);
4617 
4618  tup = systable_getnext(amscan);
4619 
4620  if (!HeapTupleIsValid(tup))
4621  elog(ERROR, "could not find tuple for amop entry %u",
4622  object->objectId);
4623 
4624  amopForm = (Form_pg_amop) GETSTRUCT(tup);
4625 
4626  initStringInfo(&opfam);
4627  getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname);
4628 
4629  ltype = format_type_be_qualified(amopForm->amoplefttype);
4630  rtype = format_type_be_qualified(amopForm->amoprighttype);
4631 
4632  if (objname)
4633  {
4634  *objname = lappend(*objname,
4635  psprintf("%d", amopForm->amopstrategy));
4636  *objargs = list_make2(ltype, rtype);
4637  }
4638 
4639  appendStringInfo(&buffer, "operator %d (%s, %s) of %s",
4640  amopForm->amopstrategy,
4641  ltype, rtype, opfam.data);
4642 
4643  pfree(opfam.data);
4644 
4645  systable_endscan(amscan);
4646  table_close(amopDesc, AccessShareLock);
4647  break;
4648  }
4649 
4650  case OCLASS_AMPROC:
4651  {
4652  Relation amprocDesc;
4653  ScanKeyData skey[1];
4654  SysScanDesc amscan;
4655  HeapTuple tup;
4656  Form_pg_amproc amprocForm;
4657  StringInfoData opfam;
4658  char *ltype;
4659  char *rtype;
4660 
4661  amprocDesc = table_open(AccessMethodProcedureRelationId,
4662  AccessShareLock);
4663 
4664  ScanKeyInit(&skey[0],
4665  Anum_pg_amproc_oid,
4666  BTEqualStrategyNumber, F_OIDEQ,
4667  ObjectIdGetDatum(object->objectId));
4668 
4669  amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true,
4670  NULL, 1, skey);
4671 
4672  tup = systable_getnext(amscan);
4673 
4674  if (!HeapTupleIsValid(tup))
4675  elog(ERROR, "could not find tuple for amproc entry %u",
4676  object->objectId);
4677 
4678  amprocForm = (Form_pg_amproc) GETSTRUCT(tup);
4679 
4680  initStringInfo(&opfam);
4681  getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname);
4682 
4683  ltype = format_type_be_qualified(amprocForm->amproclefttype);
4684  rtype = format_type_be_qualified(amprocForm->amprocrighttype);
4685 
4686  if (objname)
4687  {
4688  *objname = lappend(*objname,
4689  psprintf("%d", amprocForm->amprocnum));
4690  *objargs = list_make2(ltype, rtype);
4691  }
4692 
4693  appendStringInfo(&buffer, "function %d (%s, %s) of %s",
4694  amprocForm->amprocnum,
4695  ltype, rtype, opfam.data);
4696 
4697  pfree(opfam.data);
4698 
4699  systable_endscan(amscan);
4700  table_close(amprocDesc, AccessShareLock);
4701  break;
4702  }
4703 
4704  case OCLASS_REWRITE:
4705  {
4706  Relation ruleDesc;
4707  HeapTuple tup;
4709 
4710  ruleDesc = table_open(RewriteRelationId, AccessShareLock);
4711 
4712  tup = get_catalog_object_by_oid(ruleDesc, Anum_pg_rewrite_oid,
4713  object->objectId);
4714 
4715  if (!HeapTupleIsValid(tup))
4716  elog(ERROR, "could not find tuple for rule %u",
4717  object->objectId);
4718 
4719  rule = (Form_pg_rewrite) GETSTRUCT(tup);
4720 
4721  appendStringInfo(&buffer, "%s on ",
4722  quote_identifier(NameStr(rule->rulename)));
4723  getRelationIdentity(&buffer, rule->ev_class, objname);
4724  if (objname)
4725  *objname = lappend(*objname, pstrdup(NameStr(rule->rulename)));
4726 
4727  table_close(ruleDesc, AccessShareLock);
4728  break;
4729  }
4730 
4731  case OCLASS_TRIGGER:
4732  {
4733  Relation trigDesc;
4734  HeapTuple tup;
4735  Form_pg_trigger trig;
4736 
4737  trigDesc = table_open(TriggerRelationId, AccessShareLock);
4738 
4739  tup = get_catalog_object_by_oid(trigDesc, Anum_pg_trigger_oid,
4740  object->objectId);
4741 
4742  if (!HeapTupleIsValid(tup))
4743  elog(ERROR, "could not find tuple for trigger %u",
4744  object->objectId);
4745 
4746  trig = (Form_pg_trigger) GETSTRUCT(tup);
4747 
4748  appendStringInfo(&buffer, "%s on ",
4749  quote_identifier(NameStr(trig->tgname)));
4750  getRelationIdentity(&buffer, trig->tgrelid, objname);
4751  if (objname)
4752  *objname = lappend(*objname, pstrdup(NameStr(trig->tgname)));
4753 
4754  table_close(trigDesc, AccessShareLock);
4755  break;
4756  }
4757 
4758  case OCLASS_SCHEMA:
4759  {
4760  char *nspname;
4761 
4762  nspname = get_namespace_name_or_temp(object->objectId);
4763  if (!nspname)
4764  elog(ERROR, "cache lookup failed for namespace %u",
4765  object->objectId);
4766  appendStringInfoString(&buffer,
4767  quote_identifier(nspname));
4768  if (objname)
4769  *objname = list_make1(nspname);
4770  break;
4771  }
4772 
4773  case OCLASS_STATISTIC_EXT:
4774  {
4775  HeapTuple tup;
4776  Form_pg_statistic_ext formStatistic;
4777  char *schema;
4778 
4780  ObjectIdGetDatum(object->objectId));
4781  if (!HeapTupleIsValid(tup))
4782  elog(ERROR, "cache lookup failed for statistics object %u",
4783  object->objectId);
4784  formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
4785  schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
4786  appendStringInfoString(&buffer,
4788  NameStr(formStatistic->stxname)));
4789  if (objname)
4790  *objname = list_make2(schema,
4791  pstrdup(NameStr(formStatistic->stxname)));
4792  ReleaseSysCache(tup);
4793  }
4794  break;
4795 
4796  case OCLASS_TSPARSER:
4797  {
4798  HeapTuple tup;
4799  Form_pg_ts_parser formParser;
4800  char *schema;
4801 
4803  ObjectIdGetDatum(object->objectId));
4804  if (!HeapTupleIsValid(tup))
4805  elog(ERROR, "cache lookup failed for text search parser %u",
4806  object->objectId);
4807  formParser = (Form_pg_ts_parser) GETSTRUCT(tup);
4808  schema = get_namespace_name_or_temp(formParser->prsnamespace);
4809  appendStringInfoString(&buffer,
4811  NameStr(formParser->prsname)));
4812  if (objname)
4813  *objname = list_make2(schema,
4814  pstrdup(NameStr(formParser->prsname)));
4815  ReleaseSysCache(tup);
4816  break;
4817  }
4818 
4819  case OCLASS_TSDICT:
4820  {
4821  HeapTuple tup;
4822  Form_pg_ts_dict formDict;
4823  char *schema;
4824 
4825  tup = SearchSysCache1(TSDICTOID,
4826  ObjectIdGetDatum(object->objectId));
4827  if (!HeapTupleIsValid(tup))
4828  elog(ERROR, "cache lookup failed for text search dictionary %u",
4829  object->objectId);
4830  formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
4831  schema = get_namespace_name_or_temp(formDict->dictnamespace);
4832  appendStringInfoString(&buffer,
4834  NameStr(formDict->dictname)));
4835  if (objname)
4836  *objname = list_make2(schema,
4837  pstrdup(NameStr(formDict->dictname)));
4838  ReleaseSysCache(tup);
4839  break;
4840  }
4841 
4842  case OCLASS_TSTEMPLATE:
4843  {
4844  HeapTuple tup;
4845  Form_pg_ts_template formTmpl;
4846  char *schema;
4847 
4849  ObjectIdGetDatum(object->objectId));
4850  if (!HeapTupleIsValid(tup))
4851  elog(ERROR, "cache lookup failed for text search template %u",
4852  object->objectId);
4853  formTmpl = (Form_pg_ts_template) GETSTRUCT(tup);
4854  schema = get_namespace_name_or_temp(formTmpl->tmplnamespace);
4855  appendStringInfoString(&buffer,
4857  NameStr(formTmpl->tmplname)));
4858  if (objname)
4859  *objname = list_make2(schema,
4860  pstrdup(NameStr(formTmpl->tmplname)));
4861  ReleaseSysCache(tup);
4862  break;
4863  }
4864 
4865  case OCLASS_TSCONFIG:
4866  {
4867  HeapTuple tup;
4868  Form_pg_ts_config formCfg;
4869  char *schema;
4870 
4872  ObjectIdGetDatum(object->objectId));
4873  if (!HeapTupleIsValid(tup))
4874  elog(ERROR, "cache lookup failed for text search configuration %u",
4875  object->objectId);
4876  formCfg = (Form_pg_ts_config) GETSTRUCT(tup);
4877  schema = get_namespace_name_or_temp(formCfg->cfgnamespace);
4878  appendStringInfoString(&buffer,
4880  NameStr(formCfg->cfgname)));
4881  if (objname)
4882  *objname = list_make2(schema,
4883  pstrdup(NameStr(formCfg->cfgname)));
4884  ReleaseSysCache(tup);
4885  break;
4886  }
4887 
4888  case OCLASS_ROLE:
4889  {
4890  char *username;
4891 
4892  username = GetUserNameFromId(object->objectId, false);
4893  if (objname)
4894  *objname = list_make1(username);
4895  appendStringInfoString(&buffer,
4896  quote_identifier(username));
4897  break;
4898  }
4899 
4900  case OCLASS_DATABASE:
4901  {
4902  char *datname;
4903 
4904  datname = get_database_name(object->objectId);
4905  if (!datname)
4906  elog(ERROR, "cache lookup failed for database %u",
4907  object->objectId);
4908  if (objname)
4909  *objname = list_make1(datname);
4910  appendStringInfoString(&buffer,
4911  quote_identifier(datname));
4912  break;
4913  }
4914 
4915  case OCLASS_TBLSPACE:
4916  {
4917  char *tblspace;
4918 
4919  tblspace = get_tablespace_name(object->objectId);
4920  if (!tblspace)
4921  elog(ERROR, "cache lookup failed for tablespace %u",
4922  object->objectId);
4923  if (objname)
4924  *objname = list_make1(tblspace);
4925  appendStringInfoString(&buffer,
4926  quote_identifier(tblspace));
4927  break;
4928  }
4929 
4930  case OCLASS_FDW:
4931  {
4932  ForeignDataWrapper *fdw;
4933 
4934  fdw = GetForeignDataWrapper(object->objectId);
4936  if (objname)
4937  *objname = list_make1(pstrdup(fdw->fdwname));
4938  break;
4939  }
4940 
4941  case OCLASS_FOREIGN_SERVER:
4942  {
4943  ForeignServer *srv;
4944 
4945  srv = GetForeignServer(object->objectId);
4946  appendStringInfoString(&buffer,
4948  if (objname)
4949  *objname = list_make1(pstrdup(srv->servername));
4950  break;
4951  }
4952 
4953  case OCLASS_USER_MAPPING:
4954  {
4955  HeapTuple tup;
4956  Oid useid;
4957  Form_pg_user_mapping umform;
4958  ForeignServer *srv;
4959  const char *usename;
4960 
4962  ObjectIdGetDatum(object->objectId));
4963  if (!HeapTupleIsValid(tup))
4964  elog(ERROR, "cache lookup failed for user mapping %u",
4965  object->objectId);
4966  umform = (Form_pg_user_mapping) GETSTRUCT(tup);
4967  useid = umform->umuser;
4968  srv = GetForeignServer(umform->umserver);
4969 
4970  ReleaseSysCache(tup);
4971 
4972  if (OidIsValid(useid))
4973  usename = GetUserNameFromId(useid, false);
4974  else
4975  usename = "public";
4976 
4977  if (objname)
4978  {
4979  *objname = list_make1(pstrdup(usename));
4980  *objargs = list_make1(pstrdup(srv->servername));
4981  }
4982 
4983  appendStringInfo(&buffer, "%s on server %s",
4984  quote_identifier(usename),
4985  srv->servername);
4986  break;
4987  }
4988 
4989  case OCLASS_DEFACL:
4990  {
4991  Relation defaclrel;
4992  ScanKeyData skey[1];
4993  SysScanDesc rcscan;
4994  HeapTuple tup;
4995  Form_pg_default_acl defacl;
4996  char *schema;
4997  char *username;
4998 
4999  defaclrel = table_open(DefaultAclRelationId, AccessShareLock);
5000 
5001  ScanKeyInit(&skey[0],
5002  Anum_pg_default_acl_oid,
5003  BTEqualStrategyNumber, F_OIDEQ,
5004  ObjectIdGetDatum(object->objectId));
5005 
5006  rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId,
5007  true, NULL, 1, skey);
5008 
5009  tup = systable_getnext(rcscan);
5010 
5011  if (!HeapTupleIsValid(tup))
5012  elog(ERROR, "could not find tuple for default ACL %u",
5013  object->objectId);
5014 
5015  defacl = (Form_pg_default_acl) GETSTRUCT(tup);
5016 
5017  username = GetUserNameFromId(defacl->defaclrole, false);
5018  appendStringInfo(&buffer,
5019  "for role %s",
5020  quote_identifier(username));
5021 
5022  if (OidIsValid(defacl->defaclnamespace))
5023  {
5024  schema = get_namespace_name_or_temp(defacl->defaclnamespace);
5025  appendStringInfo(&buffer,
5026  " in schema %s",
5027  quote_identifier(schema));
5028  }
5029  else
5030  schema = NULL;
5031 
5032  switch (defacl->defaclobjtype)
5033  {
5034  case DEFACLOBJ_RELATION:
5035  appendStringInfoString(&buffer,
5036  " on tables");
5037  break;
5038  case DEFACLOBJ_SEQUENCE:
5039  appendStringInfoString(&buffer,
5040  " on sequences");
5041  break;
5042  case DEFACLOBJ_FUNCTION:
5043  appendStringInfoString(&buffer,
5044  " on functions");
5045  break;
5046  case DEFACLOBJ_TYPE:
5047  appendStringInfoString(&buffer,
5048  " on types");
5049  break;
5050  case DEFACLOBJ_NAMESPACE:
5051  appendStringInfoString(&buffer,
5052  " on schemas");
5053  break;
5054  }
5055 
5056  if (objname)
5057  {
5058  *objname = list_make1(username);
5059  if (schema)
5060  *objname = lappend(*objname, schema);
5061  *objargs = list_make1(psprintf("%c", defacl->defaclobjtype));
5062  }
5063 
5064  systable_endscan(rcscan);
5065  table_close(defaclrel, AccessShareLock);
5066  break;
5067  }
5068 
5069  case OCLASS_EXTENSION:
5070  {
5071  char *extname;
5072 
5073  extname = get_extension_name(object->objectId);
5074  if (!extname)
5075  elog(ERROR, "cache lookup failed for extension %u",
5076  object->objectId);
5077  appendStringInfoString(&buffer, quote_identifier(extname));
5078  if (objname)
5079  *objname = list_make1(extname);
5080  break;
5081  }
5082 
5083  case OCLASS_EVENT_TRIGGER:
5084  {
5085  HeapTuple tup;
5086  Form_pg_event_trigger trigForm;
5087 
5088  /* no objname support here */
5089  if (objname)
5090  *objname = NIL;
5091 
5093  ObjectIdGetDatum(object->objectId));
5094  if (!HeapTupleIsValid(tup))
5095  elog(ERROR, "cache lookup failed for event trigger %u",
5096  object->objectId);
5097  trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
5098  appendStringInfoString(&buffer,
5099  quote_identifier(NameStr(trigForm->evtname)));
5100  ReleaseSysCache(tup);
5101  break;
5102  }
5103 
5104  case OCLASS_POLICY:
5105  {
5106  Relation polDesc;
5107  HeapTuple tup;
5108  Form_pg_policy policy;
5109 
5110  polDesc = table_open(PolicyRelationId, AccessShareLock);
5111 
5112  tup = get_catalog_object_by_oid(polDesc, Anum_pg_policy_oid,
5113  object->objectId);
5114 
5115  if (!HeapTupleIsValid(tup))
5116  elog(ERROR, "could not find tuple for policy %u",
5117  object->objectId);
5118 
5119  policy = (Form_pg_policy) GETSTRUCT(tup);
5120 
5121  appendStringInfo(&buffer, "%s on ",
5122  quote_identifier(NameStr(policy->polname)));
5123  getRelationIdentity(&buffer, policy->polrelid, objname);
5124  if (objname)
5125  *objname = lappend(*objname, pstrdup(NameStr(policy->polname)));
5126 
5127  table_close(polDesc, AccessShareLock);
5128  break;
5129  }
5130 
5131  case OCLASS_PUBLICATION:
5132  {
5133  char *pubname;
5134 
5135  pubname = get_publication_name(object->objectId, false);
5136  appendStringInfoString(&buffer,
5137  quote_identifier(pubname));
5138  if (objname)
5139  *objname = list_make1(pubname);
5140  break;
5141  }
5142 
5144  {
5145  HeapTuple tup;
5146  char *pubname;
5147  Form_pg_publication_rel prform;
5148 
5150  ObjectIdGetDatum(object->objectId));
5151  if (!HeapTupleIsValid(tup))
5152  elog(ERROR, "cache lookup failed for publication table %u",
5153  object->objectId);
5154 
5155  prform = (Form_pg_publication_rel) GETSTRUCT(tup);
5156  pubname = get_publication_name(prform->prpubid, false);
5157 
5158  getRelationIdentity(&buffer, prform->prrelid, objname);
5159  appendStringInfo(&buffer, " in publication %s", pubname);
5160 
5161  if (objargs)
5162  *objargs = list_make1(pubname);
5163 
5164  ReleaseSysCache(tup);
5165  break;
5166  }
5167 
5168  case OCLASS_SUBSCRIPTION:
5169  {
5170  char *subname;
5171 
5172  subname = get_subscription_name(object->objectId, false);
5173  appendStringInfoString(&buffer,
5174  quote_identifier(subname));
5175  if (objname)
5176  *objname = list_make1(subname);
5177  break;
5178  }
5179 
5180  case OCLASS_TRANSFORM:
5181  {
5182  Relation transformDesc;
5183  HeapTuple tup;
5184  Form_pg_transform transform;
5185  char *transformLang;
5186  char *transformType;
5187 
5188  transformDesc = table_open(TransformRelationId, AccessShareLock);
5189 
5190  tup = get_catalog_object_by_oid(transformDesc,
5191  Anum_pg_transform_oid,
5192  object->objectId);
5193 
5194  if (!HeapTupleIsValid(tup))
5195  elog(ERROR, "could not find tuple for transform %u",
5196  object->objectId);
5197 
5198  transform = (Form_pg_transform) GETSTRUCT(tup);
5199 
5200  transformType = format_type_be_qualified(transform->trftype);
5201  transformLang = get_language_name(transform->trflang, false);
5202 
5203  appendStringInfo(&buffer, "for %s on language %s",
5204  transformType,
5205  transformLang);
5206  if (objname)
5207  {
5208  *objname = list_make1(transformType);
5209  *objargs = list_make1(pstrdup(transformLang));
5210  }
5211 
5212  table_close(transformDesc, AccessShareLock);
5213  }
5214  break;
5215 
5216  /*
5217  * There's intentionally no default: case here; we want the
5218  * compiler to warn if a new OCLASS hasn't been handled above.
5219  */
5220  }
5221 
5222  /*
5223  * If a get_object_address representation was requested, make sure we are
5224  * providing one. We don't check objargs, because many of the cases above
5225  * leave it as NIL.
5226  */
5227  if (objname && *objname == NIL)
5228  elog(ERROR, "requested object address for unsupported object class %d: text result \"%s\"",
5229  (int) getObjectClass(object), buffer.data);
5230 
5231  return buffer.data;
5232 }
#define list_make2(x1, x2)
Definition: pg_list.h:229
#define list_make3(x1, x2, x3)
Definition: pg_list.h:231
#define NIL
Definition: pg_list.h:65
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:529
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: syscache.h:36
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:10724
char * get_language_name(Oid langoid, bool missing_ok)
Definition: lsyscache.c:1051
FormData_pg_ts_config * Form_pg_ts_config
Definition: pg_ts_config.h:48
char * fdwname
Definition: foreign.h:28
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
char * pstrdup(const char *in)
Definition: mcxt.c:1186
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
char * get_extension_name(Oid ext_oid)
Definition: extension.c:185
static void getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object)
char * getObjectIdentityParts(const ObjectAddress *object, List **objname, List **objargs)
#define DefaultAclOidIndexId
Definition: indexing.h:311
#define AccessShareLock
Definition: lockdefs.h:36
#define AttrDefaultOidIndexId
Definition: indexing.h:91
#define AccessMethodOperatorOidIndexId
Definition: indexing.h:81
NameData datname
Definition: pg_database.h:35
unsigned int Oid
Definition: postgres_ext.h:31
NameData subname
ObjectClass getObjectClass(const ObjectAddress *object)
Definition: dependency.c:2725
#define OidIsValid(objectId)
Definition: c.h:644
static void getRelationIdentity(StringInfo buffer, Oid relid, List **object)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:356
char * get_publication_name(Oid pubid, bool missing_ok)
Definition: localtime.c:79
char * get_subscription_name(Oid subid, bool missing_ok)
#define AccessMethodProcedureOidIndexId
Definition: indexing.h:86
#define list_make1(x1)
Definition: pg_list.h:227
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:448
ForeignDataWrapper * GetForeignDataWrapper(Oid fdwid)
Definition: foreign.c:35
void pfree(void *pointer)
Definition: mcxt.c:1056
void format_operator_parts(Oid operator_oid, List **objnames, List **objargs)
Definition: regproc.c:833
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
char * format_operator_qualified(Oid operator_oid)
Definition: regproc.c:827
char * get_database_name(Oid dbid)
Definition: dbcommands.c:2155
FormData_pg_user_mapping * Form_pg_user_mapping
FormData_pg_ts_dict * Form_pg_ts_dict
Definition: pg_ts_dict.h:52
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
FormData_pg_default_acl * Form_pg_default_acl
char * get_am_name(Oid amOid)
Definition: amcmds.c:216
void format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs)
Definition: regproc.c:409
FormData_pg_cast * Form_pg_cast
Definition: pg_cast.h:57
char * format_procedure_qualified(Oid procedure_oid)
Definition: regproc.c:330
List * lappend(List *list, void *datum)
Definition: list.c:322
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
FormData_pg_attrdef * Form_pg_attrdef
Definition: pg_attrdef.h:47
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:10808
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
ForeignServer * GetForeignServer(Oid serverid)
Definition: foreign.c:109
HeapTuple get_catalog_object_by_oid(Relation catalog, AttrNumber oidcol, Oid objectId)
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_ts_parser * Form_pg_ts_parser
Definition: pg_ts_parser.h:55
FormData_pg_conversion * Form_pg_conversion
Definition: pg_conversion.h:61
static char * username
Definition: initdb.c:133
FormData_pg_policy * Form_pg_policy
Definition: pg_policy.h:50
FormData_pg_constraint * Form_pg_constraint
FormData_pg_event_trigger * Form_pg_event_trigger
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
char * GetUserNameFromId(Oid roleid, bool noerr)
Definition: miscinit.c:854
#define Assert(condition)
Definition: c.h:738
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:337
FormData_pg_trigger * Form_pg_trigger
Definition: pg_trigger.h:72
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
FormData_pg_rewrite * Form_pg_rewrite
Definition: pg_rewrite.h:52
FormData_pg_am * Form_pg_am
Definition: pg_am.h:48
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3179
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
char * get_tablespace_name(Oid spc_oid)
Definition: tablespace.c:1462
char * servername
Definition: foreign.h:39
FormData_pg_ts_template * Form_pg_ts_template
#define elog(elevel,...)
Definition: elog.h:214
FormData_pg_publication_rel * Form_pg_publication_rel
#define NameStr(name)
Definition: c.h:615
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Definition: lsyscache.c:776
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83
#define PointerIsValid(pointer)
Definition: c.h:632
#define BTEqualStrategyNumber
Definition: stratnum.h:31
FormData_pg_statistic_ext * Form_pg_statistic_ext

◆ getObjectTypeDescription()

char* getObjectTypeDescription ( const ObjectAddress object)

Definition at line 3997 of file objectaddress.c.

References appendStringInfoString(), StringInfoData::data, getConstraintTypeDescription(), getObjectClass(), getProcedureTypeDescription(), getRelationTypeDescription(), initStringInfo(), ObjectAddress::objectId, ObjectAddress::objectSubId, OCLASS_AM, OCLASS_AMOP, OCLASS_AMPROC, OCLASS_CAST, OCLASS_CLASS, OCLASS_COLLATION, OCLASS_CONSTRAINT, OCLASS_CONVERSION, OCLASS_DATABASE, OCLASS_DEFACL, OCLASS_DEFAULT, OCLASS_EVENT_TRIGGER, OCLASS_EXTENSION, OCLASS_FDW, OCLASS_FOREIGN_SERVER, OCLASS_LANGUAGE, OCLASS_LARGEOBJECT, OCLASS_OPCLASS, OCLASS_OPERATOR, OCLASS_OPFAMILY, OCLASS_POLICY, OCLASS_PROC, OCLASS_PUBLICATION, OCLASS_PUBLICATION_REL, OCLASS_REWRITE, OCLASS_ROLE, OCLASS_SCHEMA, OCLASS_STATISTIC_EXT, OCLASS_SUBSCRIPTION, OCLASS_TBLSPACE, OCLASS_TRANSFORM, OCLASS_TRIGGER, OCLASS_TSCONFIG, OCLASS_TSDICT, OCLASS_TSPARSER, OCLASS_TSTEMPLATE, OCLASS_TYPE, and OCLASS_USER_MAPPING.

Referenced by EventTriggerSQLDropAddObject(), pg_event_trigger_ddl_commands(), pg_identify_object(), pg_identify_object_as_address(), and sepgsql_object_relabel().

3998 {
3999  StringInfoData buffer;
4000 
4001  initStringInfo(&buffer);
4002 
4003  switch (getObjectClass(object))
4004  {
4005  case OCLASS_CLASS:
4006  getRelationTypeDescription(&buffer, object->objectId,
4007  object->objectSubId);
4008  break;
4009 
4010  case OCLASS_PROC:
4011  getProcedureTypeDescription(&buffer, object->objectId);
4012  break;
4013 
4014  case OCLASS_TYPE:
4015  appendStringInfoString(&buffer, "type");
4016  break;
4017 
4018  case OCLASS_CAST:
4019  appendStringInfoString(&buffer, "cast");
4020  break;
4021 
4022  case OCLASS_COLLATION:
4023  appendStringInfoString(&buffer, "collation");
4024  break;
4025 
4026  case OCLASS_CONSTRAINT:
4027  getConstraintTypeDescription(&buffer, object->objectId);
4028  break;
4029 
4030  case OCLASS_CONVERSION:
4031  appendStringInfoString(&buffer, "conversion");
4032  break;
4033 
4034  case OCLASS_DEFAULT:
4035  appendStringInfoString(&buffer, "default value");
4036  break;
4037 
4038  case OCLASS_LANGUAGE:
4039  appendStringInfoString(&buffer, "language");
4040  break;
4041 
4042  case OCLASS_LARGEOBJECT:
4043  appendStringInfoString(&buffer, "large object");
4044  break;
4045 
4046  case OCLASS_OPERATOR:
4047  appendStringInfoString(&buffer, "operator");
4048  break;
4049 
4050  case OCLASS_OPCLASS:
4051  appendStringInfoString(&buffer, "operator class");
4052  break;
4053 
4054  case OCLASS_OPFAMILY:
4055  appendStringInfoString(&buffer, "operator family");
4056  break;
4057 
4058  case OCLASS_AM:
4059  appendStringInfoString(&buffer, "access method");
4060  break;
4061 
4062  case OCLASS_AMOP:
4063  appendStringInfoString(&buffer, "operator of access method");
4064  break;
4065 
4066  case OCLASS_AMPROC:
4067  appendStringInfoString(&buffer, "function of access method");
4068  break;
4069 
4070  case OCLASS_REWRITE:
4071  appendStringInfoString(&buffer, "rule");
4072  break;
4073 
4074  case OCLASS_TRIGGER:
4075  appendStringInfoString(&buffer, "trigger");
4076  break;
4077 
4078  case OCLASS_SCHEMA:
4079  appendStringInfoString(&buffer, "schema");
4080  break;
4081 
4082  case OCLASS_STATISTIC_EXT:
4083  appendStringInfoString(&buffer, "statistics object");
4084  break;
4085 
4086  case OCLASS_TSPARSER:
4087  appendStringInfoString(&buffer, "text search parser");
4088  break;
4089 
4090  case OCLASS_TSDICT:
4091  appendStringInfoString(&buffer, "text search dictionary");
4092  break;
4093 
4094  case OCLASS_TSTEMPLATE:
4095  appendStringInfoString(&buffer, "text search template");
4096  break;
4097 
4098  case OCLASS_TSCONFIG:
4099  appendStringInfoString(&buffer, "text search configuration");
4100  break;
4101 
4102  case OCLASS_ROLE:
4103  appendStringInfoString(&buffer, "role");
4104  break;
4105 
4106  case OCLASS_DATABASE:
4107  appendStringInfoString(&buffer, "database");
4108  break;
4109 
4110  case OCLASS_TBLSPACE:
4111  appendStringInfoString(&buffer, "tablespace");
4112  break;
4113 
4114  case OCLASS_FDW:
4115  appendStringInfoString(&buffer, "foreign-data wrapper");
4116  break;
4117 
4118  case OCLASS_FOREIGN_SERVER:
4119  appendStringInfoString(&buffer, "server");
4120  break;
4121 
4122  case OCLASS_USER_MAPPING:
4123  appendStringInfoString(&buffer, "user mapping");
4124  break;
4125 
4126  case OCLASS_DEFACL:
4127  appendStringInfoString(&buffer, "default acl");
4128  break;
4129 
4130  case OCLASS_EXTENSION:
4131  appendStringInfoString(&buffer, "extension");
4132  break;
4133 
4134  case OCLASS_EVENT_TRIGGER:
4135  appendStringInfoString(&buffer, "event trigger");
4136  break;
4137 
4138  case OCLASS_POLICY:
4139  appendStringInfoString(&buffer, "policy");
4140  break;
4141 
4142  case OCLASS_PUBLICATION:
4143  appendStringInfoString(&buffer, "publication");
4144  break;
4145 
4147  appendStringInfoString(&buffer, "publication relation");
4148  break;
4149 
4150  case OCLASS_SUBSCRIPTION:
4151  appendStringInfoString(&buffer, "subscription");
4152  break;
4153 
4154  case OCLASS_TRANSFORM:
4155  appendStringInfoString(&buffer, "transform");
4156  break;
4157 
4158  /*
4159  * There's intentionally no default: case here; we want the
4160  * compiler to warn if a new OCLASS hasn't been handled above.
4161  */
4162  }
4163 
4164  return buffer.data;
4165 }
static void getConstraintTypeDescription(StringInfo buffer, Oid constroid)
static void getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId)
ObjectClass getObjectClass(const ObjectAddress *object)
Definition: dependency.c:2725
static void getProcedureTypeDescription(StringInfo buffer, Oid procid)
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59

◆ is_objectclass_supported()

bool is_objectclass_supported ( Oid  class_id)

Definition at line 2654 of file objectaddress.c.

References lengthof.

Referenced by EventTriggerSQLDropAddObject(), pg_event_trigger_ddl_commands(), and pg_identify_object().

2655 {
2656  int index;
2657 
2658  for (index = 0; index < lengthof(ObjectProperty); index++)
2659  {
2660  if (ObjectProperty[index].class_oid == class_id)
2661  return true;
2662  }
2663 
2664  return false;
2665 }
#define lengthof(array)
Definition: c.h:668
Definition: type.h:89
static const ObjectPropertyType ObjectProperty[]

◆ read_objtype_from_string()

int read_objtype_from_string ( const char *  objtype)

Definition at line 2533 of file objectaddress.c.

References ereport, errcode(), errmsg(), ERROR, i, lengthof, ObjectTypeMap, object_type_map::tm_name, and object_type_map::tm_type.

Referenced by pg_get_object_address().

2534 {
2535  int i;
2536 
2537  for (i = 0; i < lengthof(ObjectTypeMap); i++)
2538  {
2539  if (strcmp(ObjectTypeMap[i].tm_name, objtype) == 0)
2540  return ObjectTypeMap[i].tm_type;
2541  }
2542  ereport(ERROR,
2543  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2544  errmsg("unrecognized object type \"%s\"", objtype)));
2545 
2546  return -1; /* keep compiler quiet */
2547 }
int errcode(int sqlerrcode)
Definition: elog.c:610
#define lengthof(array)
Definition: c.h:668
#define ERROR
Definition: elog.h:43
static const struct object_type_map ObjectTypeMap[]
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg(const char *fmt,...)
Definition: elog.c:824
int i

◆ strlist_to_textarray()

struct ArrayType* strlist_to_textarray ( List list)

Definition at line 5300 of file objectaddress.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, construct_md_array(), CStringGetTextDatum, CurrentMemoryContext, lfirst, list_length(), MemoryContextDelete(), MemoryContextSwitchTo(), name, and palloc().

Referenced by fill_hba_line(), pg_event_trigger_dropped_objects(), and pg_identify_object_as_address().

5301 {
5302  ArrayType *arr;
5303  Datum *datums;
5304  bool *nulls;
5305  int j = 0;
5306  ListCell *cell;
5307  MemoryContext memcxt;
5308  MemoryContext oldcxt;
5309  int lb[1];
5310 
5311  /* Work in a temp context; easier than individually pfree'ing the Datums */
5313  "strlist to array",
5315  oldcxt = MemoryContextSwitchTo(memcxt);
5316 
5317  datums = (Datum *) palloc(sizeof(Datum) * list_length(list));
5318  nulls = palloc(sizeof(bool) * list_length(list));
5319 
5320  foreach(cell, list)
5321  {
5322  char *name = lfirst(cell);
5323 
5324  if (name)
5325  {
5326  nulls[j] = false;
5327  datums[j++] = CStringGetTextDatum(name);
5328  }
5329  else
5330  nulls[j] = true;
5331  }
5332 
5333  MemoryContextSwitchTo(oldcxt);
5334 
5335  lb[0] = 1;
5336  arr = construct_md_array(datums, nulls, 1, &j,
5337  lb, TEXTOID, -1, false, TYPALIGN_INT);
5338 
5339  MemoryContextDelete(memcxt);
5340 
5341  return arr;
5342 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
#define AllocSetContextCreate
Definition: memutils.h:170
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
uintptr_t Datum
Definition: postgres.h:367
#define lfirst(lc)
Definition: pg_list.h:190
static int list_length(const List *l)
Definition: pg_list.h:169
const char * name
Definition: encode.c:521
void * palloc(Size size)
Definition: mcxt.c:949
#define CStringGetTextDatum(s)
Definition: builtins.h:87
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3326

Variable Documentation

◆ InvalidObjectAddress