objectaddress.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*-------------------------------------------------------------------------
  2. *
  3. * objectaddress.h
  4. * functions for working with object addresses
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/catalog/objectaddress.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef OBJECTADDRESS_H
  14. #define OBJECTADDRESS_H
  15. #include "access/htup.h"
  16. #include "nodes/parsenodes.h"
  17. #include "storage/lockdefs.h"
  18. #include "utils/relcache.h"
  19. /*
  20. * An ObjectAddress represents a database object of any type.
  21. */
  22. typedef struct ObjectAddress
  23. {
  24. Oid classId; /* Class Id from pg_class */
  25. Oid objectId; /* OID of the object */
  26. int32 objectSubId; /* Subitem within object (eg column), or 0 */
  27. } ObjectAddress;
  28. extern PGDLLIMPORT const ObjectAddress InvalidObjectAddress;
  29. #define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id) \
  30. do { \
  31. (addr).classId = (class_id); \
  32. (addr).objectId = (object_id); \
  33. (addr).objectSubId = (object_sub_id); \
  34. } while (0)
  35. #define ObjectAddressSet(addr, class_id, object_id) \
  36. ObjectAddressSubSet(addr, class_id, object_id, 0)
  37. extern ObjectAddress get_object_address(ObjectType objtype, Node *object,
  38. Relation *relp,
  39. LOCKMODE lockmode, bool missing_ok);
  40. extern ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel,
  41. List *object, Relation *relp,
  42. LOCKMODE lockmode, bool missing_ok);
  43. extern void check_object_ownership(Oid roleid,
  44. ObjectType objtype, ObjectAddress address,
  45. Node *object, Relation relation);
  46. extern Oid get_object_namespace(const ObjectAddress *address);
  47. extern bool is_objectclass_supported(Oid class_id);
  48. extern const char *get_object_class_descr(Oid class_id);
  49. extern Oid get_object_oid_index(Oid class_id);
  50. extern int get_object_catcache_oid(Oid class_id);
  51. extern int get_object_catcache_name(Oid class_id);
  52. extern AttrNumber get_object_attnum_oid(Oid class_id);
  53. extern AttrNumber get_object_attnum_name(Oid class_id);
  54. extern AttrNumber get_object_attnum_namespace(Oid class_id);
  55. extern AttrNumber get_object_attnum_owner(Oid class_id);
  56. extern AttrNumber get_object_attnum_acl(Oid class_id);
  57. extern ObjectType get_object_type(Oid class_id, Oid object_id);
  58. extern bool get_object_namensp_unique(Oid class_id);
  59. extern HeapTuple get_catalog_object_by_oid(Relation catalog,
  60. AttrNumber oidcol, Oid objectId);
  61. extern char *getObjectDescription(const ObjectAddress *object,
  62. bool missing_ok);
  63. extern char *getObjectDescriptionOids(Oid classid, Oid objid);
  64. extern int read_objtype_from_string(const char *objtype);
  65. extern char *getObjectTypeDescription(const ObjectAddress *object,
  66. bool missing_ok);
  67. extern char *getObjectIdentity(const ObjectAddress *address,
  68. bool missing_ok);
  69. extern char *getObjectIdentityParts(const ObjectAddress *address,
  70. List **objname, List **objargs,
  71. bool missing_ok);
  72. extern struct ArrayType *strlist_to_textarray(List *list);
  73. extern ObjectType get_relkind_objtype(char relkind);
  74. #endif /* OBJECTADDRESS_H */