pg_init_privs.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_init_privs.h
  4. * definition of the "initial privileges" system catalog (pg_init_privs)
  5. *
  6. * NOTE: an object is identified by the OID of the row that primarily
  7. * defines the object, plus the OID of the table that that row appears in.
  8. * For example, a function is identified by the OID of its pg_proc row
  9. * plus the pg_class OID of table pg_proc. This allows unique identification
  10. * of objects without assuming that OIDs are unique across tables.
  11. *
  12. * Since attributes don't have OIDs of their own, we identify an attribute
  13. * privilege by the objoid+classoid of its parent table, plus an "objsubid"
  14. * giving the attribute column number. "objsubid" must be zero in a privilege
  15. * for a table itself, so that it is distinct from any column privilege.
  16. * Currently, objsubid is unused and zero for all other kinds of objects.
  17. *
  18. * Because the contents of this table depend on what is done with the other
  19. * objects in the system (and, in particular, may change due to changes in
  20. * system_views.sql), there is no pg_init_privs.dat file. The initial contents
  21. * are loaded near the end of initdb.
  22. *
  23. *
  24. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  25. * Portions Copyright (c) 1994, Regents of the University of California
  26. *
  27. * src/include/catalog/pg_init_privs.h
  28. *
  29. * NOTES
  30. * The Catalog.pm module reads this file and derives schema
  31. * information.
  32. *
  33. *-------------------------------------------------------------------------
  34. */
  35. #ifndef PG_INIT_PRIVS_H
  36. #define PG_INIT_PRIVS_H
  37. #include "catalog/genbki.h"
  38. #include "catalog/pg_init_privs_d.h"
  39. /* ----------------
  40. * pg_init_privs definition. cpp turns this into
  41. * typedef struct FormData_pg_init_privs
  42. * ----------------
  43. */
  44. CATALOG(pg_init_privs,3394,InitPrivsRelationId)
  45. {
  46. Oid objoid; /* OID of object itself */
  47. Oid classoid BKI_LOOKUP(pg_class); /* OID of table containing
  48. * object */
  49. int32 objsubid; /* column number, or 0 if not used */
  50. char privtype; /* from initdb or extension? */
  51. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  52. aclitem initprivs[1] BKI_FORCE_NOT_NULL; /* initial privs on object */
  53. #endif
  54. } FormData_pg_init_privs;
  55. /* ----------------
  56. * Form_pg_init_privs corresponds to a pointer to a tuple with
  57. * the format of pg_init_privs relation.
  58. * ----------------
  59. */
  60. typedef FormData_pg_init_privs * Form_pg_init_privs;
  61. DECLARE_TOAST(pg_init_privs, 4155, 4156);
  62. DECLARE_UNIQUE_INDEX_PKEY(pg_init_privs_o_c_o_index, 3395, InitPrivsObjIndexId, on pg_init_privs using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
  63. /*
  64. * It is important to know if the initial privileges are from initdb or from an
  65. * extension. This enum is used to provide that differentiation and the two
  66. * places which populate this table (initdb and during CREATE EXTENSION, see
  67. * recordExtensionInitPriv()) know to use the correct values.
  68. */
  69. typedef enum InitPrivsType
  70. {
  71. INITPRIVS_INITDB = 'i',
  72. INITPRIVS_EXTENSION = 'e'
  73. } InitPrivsType;
  74. #endif /* PG_INIT_PRIVS_H */