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-2019, 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
38#include "catalog/genbki.h"
39#include "catalog/pg_init_privs_d.h"
40
41/* ----------------
42 * pg_init_privs definition. cpp turns this into
43 * typedef struct FormData_pg_init_privs
44 * ----------------
45 */
46CATALOG(pg_init_privs,3394,InitPrivsRelationId)
47{
48 Oid objoid; /* OID of object itself */
49 Oid classoid; /* OID of table containing object */
50 int32 objsubid; /* column number, or 0 if not used */
51 char privtype; /* from initdb or extension? */
52
53#ifdef CATALOG_VARLEN /* variable-length fields start here */
54 aclitem initprivs[1] BKI_FORCE_NOT_NULL; /* initial privs on object */
55#endif
56} FormData_pg_init_privs;
57
58/* ----------------
59 * Form_pg_init_privs corresponds to a pointer to a tuple with
60 * the format of pg_init_privs relation.
61 * ----------------
62 */
63typedef FormData_pg_init_privs * Form_pg_init_privs;
64
65/*
66 * It is important to know if the initial privileges are from initdb or from an
67 * extension. This enum is used to provide that differentiation and the two
68 * places which populate this table (initdb and during CREATE EXTENSION, see
69 * recordExtensionInitPriv()) know to use the correct values.
70 */
71
72typedef enum InitPrivsType
73{
74 INITPRIVS_INITDB = 'i',
75 INITPRIVS_EXTENSION = 'e'
76} InitPrivsType;
77
78#endif /* PG_INIT_PRIVS_H */
79