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, on pg_parameter_acl using btree(parname text_ops))
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_parameter_acl_oid_index, 6247, ParameterAclOidIndexId, on pg_parameter_acl using btree(oid oid_ops))
 
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:622

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  ,
on pg_parameter_acl using   btreeparname text_ops 
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_parameter_acl_oid_index  ,
6247  ,
ParameterAclOidIndexId  ,
on pg_parameter_acl using   btreeoid oid_ops 
)

◆ ParameterAclCreate()

Oid ParameterAclCreate ( const char *  parameter)

Definition at line 70 of file pg_parameter_acl.c.

71 {
72  Oid parameterId;
73  char *parname;
74  Relation rel;
75  TupleDesc tupDesc;
76  HeapTuple tuple;
77  Datum values[Natts_pg_parameter_acl];
78  bool nulls[Natts_pg_parameter_acl];
79 
80  /*
81  * To prevent cluttering pg_parameter_acl with useless entries, insist
82  * that the name be valid.
83  */
84  if (!check_GUC_name_for_parameter_acl(parameter))
85  ereport(ERROR,
86  (errcode(ERRCODE_INVALID_NAME),
87  errmsg("invalid parameter name \"%s\"",
88  parameter)));
89 
90  /* Convert name to the form it should have in pg_parameter_acl. */
91  parname = convert_GUC_name_for_parameter_acl(parameter);
92 
93  /*
94  * Create and insert a new record containing a null ACL.
95  *
96  * We don't take a strong enough lock to prevent concurrent insertions,
97  * relying instead on the unique index.
98  */
99  rel = table_open(ParameterAclRelationId, RowExclusiveLock);
100  tupDesc = RelationGetDescr(rel);
101  MemSet(values, 0, sizeof(values));
102  MemSet(nulls, false, sizeof(nulls));
103  parameterId = GetNewOidWithIndex(rel,
104  ParameterAclOidIndexId,
105  Anum_pg_parameter_acl_oid);
106  values[Anum_pg_parameter_acl_oid - 1] = ObjectIdGetDatum(parameterId);
107  values[Anum_pg_parameter_acl_parname - 1] =
109  nulls[Anum_pg_parameter_acl_paracl - 1] = true;
110  tuple = heap_form_tuple(tupDesc, values, nulls);
111  CatalogTupleInsert(rel, tuple);
112 
113  /* Close pg_parameter_acl, but keep lock till commit. */
114  heap_freetuple(tuple);
115  table_close(rel, NoLock);
116 
117  return parameterId;
118 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define MemSet(start, val, len)
Definition: c.h:1008
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:391
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ERROR
Definition: elog.h:33
#define ereport(elevel,...)
Definition: elog.h:143
bool check_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:5817
char * convert_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:5781
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:221
#define NoLock
Definition: lockdefs.h:34
#define RowExclusiveLock
Definition: lockdefs.h:38
uintptr_t Datum
Definition: postgres.h:411
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define PointerGetDatum(X)
Definition: postgres.h:600
#define RelationGetDescr(relation)
Definition: rel.h:514
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
text * cstring_to_text(const char *s)
Definition: varlena.c:188

References CatalogTupleInsert(), check_GUC_name_for_parameter_acl(), convert_GUC_name_for_parameter_acl(), cstring_to_text(), ereport, errcode(), errmsg(), ERROR, GetNewOidWithIndex(), heap_form_tuple(), heap_freetuple(), MemSet, 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 37 of file pg_parameter_acl.c.

38 {
39  Oid oid;
40  char *parname;
41 
42  /* Convert name to the form it should have in pg_parameter_acl... */
43  parname = convert_GUC_name_for_parameter_acl(parameter);
44 
45  /* ... and look it up */
46  oid = GetSysCacheOid1(PARAMETERACLNAME, Anum_pg_parameter_acl_oid,
48 
49  if (!OidIsValid(oid) && !missing_ok)
50  ereport(ERROR,
51  (errcode(ERRCODE_UNDEFINED_OBJECT),
52  errmsg("parameter ACL \"%s\" does not exist", parameter)));
53 
54  pfree(parname);
55 
56  return oid;
57 }
#define OidIsValid(objectId)
Definition: c.h:710
void pfree(void *pointer)
Definition: mcxt.c:1175
@ PARAMETERACLNAME
Definition: syscache.h:75
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:197

References convert_GUC_name_for_parameter_acl(), cstring_to_text(), ereport, errcode(), errmsg(), ERROR, GetSysCacheOid1, OidIsValid, PARAMETERACLNAME, 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.