PostgreSQL Source Code  git master
pg_parameter_acl.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_parameter_acl_d.h"
Include dependency graph for pg_parameter_acl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef FormData_pg_parameter_aclForm_pg_parameter_acl
 

Functions

 CATALOG (pg_parameter_acl, 6243, ParameterAclRelationId) BKI_SHARED_RELATION
 
 DECLARE_TOAST_WITH_MACRO (pg_parameter_acl, 6244, 6245, PgParameterAclToastTable, PgParameterAclToastIndex)
 
 DECLARE_UNIQUE_INDEX (pg_parameter_acl_parname_index, 6246, ParameterAclParnameIndexId, pg_parameter_acl, btree(parname text_ops))
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_parameter_acl_oid_index, 6247, ParameterAclOidIndexId, pg_parameter_acl, btree(oid oid_ops))
 
 MAKE_SYSCACHE (PARAMETERACLNAME, pg_parameter_acl_parname_index, 4)
 
 MAKE_SYSCACHE (PARAMETERACLOID, pg_parameter_acl_oid_index, 4)
 
Oid ParameterAclLookup (const char *parameter, bool missing_ok)
 
Oid ParameterAclCreate (const char *parameter)
 

Variables

 FormData_pg_parameter_acl
 

Typedef Documentation

◆ Form_pg_parameter_acl

Function Documentation

◆ CATALOG()

CATALOG ( pg_parameter_acl  ,
6243  ,
ParameterAclRelationId   
)

Definition at line 30 of file pg_parameter_acl.h.

31 {
32  Oid oid; /* oid */
33 
34 #ifdef CATALOG_VARLEN /* variable-length fields start here */
35  /* name of parameter */
36  text parname BKI_FORCE_NOT_NULL;
37 
38  /* access permissions */
39  aclitem paracl[1] BKI_DEFAULT(_null_);
40 #endif
#define BKI_DEFAULT(value)
Definition: genbki.h:35
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:33
FormData_pg_parameter_acl
unsigned int Oid
Definition: postgres_ext.h:31
Definition: c.h:687

References BKI_DEFAULT, and BKI_FORCE_NOT_NULL.

◆ DECLARE_TOAST_WITH_MACRO()

DECLARE_TOAST_WITH_MACRO ( pg_parameter_acl  ,
6244  ,
6245  ,
PgParameterAclToastTable  ,
PgParameterAclToastIndex   
)

◆ DECLARE_UNIQUE_INDEX()

DECLARE_UNIQUE_INDEX ( pg_parameter_acl_parname_index  ,
6246  ,
ParameterAclParnameIndexId  ,
pg_parameter_acl  ,
btree(parname text_ops)   
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_parameter_acl_oid_index  ,
6247  ,
ParameterAclOidIndexId  ,
pg_parameter_acl  ,
btree(oid oid_ops)   
)

◆ MAKE_SYSCACHE() [1/2]

MAKE_SYSCACHE ( PARAMETERACLNAME  ,
pg_parameter_acl_parname_index  ,
 
)

◆ MAKE_SYSCACHE() [2/2]

MAKE_SYSCACHE ( PARAMETERACLOID  ,
pg_parameter_acl_oid_index  ,
 
)

◆ ParameterAclCreate()

Oid ParameterAclCreate ( const char *  parameter)

Definition at line 68 of file pg_parameter_acl.c.

69 {
70  Oid parameterId;
71  char *parname;
72  Relation rel;
73  TupleDesc tupDesc;
74  HeapTuple tuple;
75  Datum values[Natts_pg_parameter_acl] = {0};
76  bool nulls[Natts_pg_parameter_acl] = {0};
77 
78  /*
79  * To prevent cluttering pg_parameter_acl with useless entries, insist
80  * that the name be valid.
81  */
83 
84  /* Convert name to the form it should have in pg_parameter_acl. */
85  parname = convert_GUC_name_for_parameter_acl(parameter);
86 
87  /*
88  * Create and insert a new record containing a null ACL.
89  *
90  * We don't take a strong enough lock to prevent concurrent insertions,
91  * relying instead on the unique index.
92  */
93  rel = table_open(ParameterAclRelationId, RowExclusiveLock);
94  tupDesc = RelationGetDescr(rel);
95  parameterId = GetNewOidWithIndex(rel,
96  ParameterAclOidIndexId,
97  Anum_pg_parameter_acl_oid);
98  values[Anum_pg_parameter_acl_oid - 1] = ObjectIdGetDatum(parameterId);
99  values[Anum_pg_parameter_acl_parname - 1] =
101  nulls[Anum_pg_parameter_acl_paracl - 1] = true;
102  tuple = heap_form_tuple(tupDesc, values, nulls);
103  CatalogTupleInsert(rel, tuple);
104 
105  /* Close pg_parameter_acl, but keep lock till commit. */
106  heap_freetuple(tuple);
107  table_close(rel, NoLock);
108 
109  return parameterId;
110 }
static Datum values[MAXATTR]
Definition: bootstrap.c:152
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:391
void check_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:1412
char * convert_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:1376
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1116
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1434
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:233
#define NoLock
Definition: lockdefs.h:34
#define RowExclusiveLock
Definition: lockdefs.h:38
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:252
#define RelationGetDescr(relation)
Definition: rel.h:531
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40
text * cstring_to_text(const char *s)
Definition: varlena.c:184

References CatalogTupleInsert(), check_GUC_name_for_parameter_acl(), convert_GUC_name_for_parameter_acl(), cstring_to_text(), GetNewOidWithIndex(), heap_form_tuple(), heap_freetuple(), NoLock, ObjectIdGetDatum(), PointerGetDatum(), RelationGetDescr, RowExclusiveLock, table_close(), table_open(), and values.

Referenced by objectNamesToOids().

◆ ParameterAclLookup()

Oid ParameterAclLookup ( const char *  parameter,
bool  missing_ok 
)

Definition at line 35 of file pg_parameter_acl.c.

36 {
37  Oid oid;
38  char *parname;
39 
40  /* Convert name to the form it should have in pg_parameter_acl... */
41  parname = convert_GUC_name_for_parameter_acl(parameter);
42 
43  /* ... and look it up */
44  oid = GetSysCacheOid1(PARAMETERACLNAME, Anum_pg_parameter_acl_oid,
46 
47  if (!OidIsValid(oid) && !missing_ok)
48  ereport(ERROR,
49  (errcode(ERRCODE_UNDEFINED_OBJECT),
50  errmsg("parameter ACL \"%s\" does not exist", parameter)));
51 
52  pfree(parname);
53 
54  return oid;
55 }
#define OidIsValid(objectId)
Definition: c.h:775
int errcode(int sqlerrcode)
Definition: elog.c:857
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
void pfree(void *pointer)
Definition: mcxt.c:1520
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:104

References convert_GUC_name_for_parameter_acl(), cstring_to_text(), ereport, errcode(), errmsg(), ERROR, GetSysCacheOid1, OidIsValid, pfree(), and PointerGetDatum().

Referenced by get_object_address_unqualified(), and objectNamesToOids().

Variable Documentation

◆ FormData_pg_parameter_acl

FormData_pg_parameter_acl

Definition at line 41 of file pg_parameter_acl.h.