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:671

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 71 of file pg_parameter_acl.c.

72 {
73  Oid parameterId;
74  char *parname;
75  Relation rel;
76  TupleDesc tupDesc;
77  HeapTuple tuple;
78  Datum values[Natts_pg_parameter_acl] = {0};
79  bool nulls[Natts_pg_parameter_acl] = {0};
80 
81  /*
82  * To prevent cluttering pg_parameter_acl with useless entries, insist
83  * that the name be valid.
84  */
85  if (!check_GUC_name_for_parameter_acl(parameter))
86  ereport(ERROR,
87  (errcode(ERRCODE_INVALID_NAME),
88  errmsg("invalid parameter name \"%s\"",
89  parameter)));
90 
91  /* Convert name to the form it should have in pg_parameter_acl. */
92  parname = convert_GUC_name_for_parameter_acl(parameter);
93 
94  /*
95  * Create and insert a new record containing a null ACL.
96  *
97  * We don't take a strong enough lock to prevent concurrent insertions,
98  * relying instead on the unique index.
99  */
100  rel = table_open(ParameterAclRelationId, RowExclusiveLock);
101  tupDesc = RelationGetDescr(rel);
102  parameterId = GetNewOidWithIndex(rel,
103  ParameterAclOidIndexId,
104  Anum_pg_parameter_acl_oid);
105  values[Anum_pg_parameter_acl_oid - 1] = ObjectIdGetDatum(parameterId);
106  values[Anum_pg_parameter_acl_parname - 1] =
108  nulls[Anum_pg_parameter_acl_paracl - 1] = true;
109  tuple = heap_form_tuple(tupDesc, values, nulls);
110  CatalogTupleInsert(rel, tuple);
111 
112  /* Close pg_parameter_acl, but keep lock till commit. */
113  heap_freetuple(tuple);
114  table_close(rel, NoLock);
115 
116  return parameterId;
117 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:393
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
bool check_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:1374
char * convert_GUC_name_for_parameter_acl(const char *name)
Definition: guc.c:1338
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
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:527
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:189

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(), 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 38 of file pg_parameter_acl.c.

39 {
40  Oid oid;
41  char *parname;
42 
43  /* Convert name to the form it should have in pg_parameter_acl... */
44  parname = convert_GUC_name_for_parameter_acl(parameter);
45 
46  /* ... and look it up */
47  oid = GetSysCacheOid1(PARAMETERACLNAME, Anum_pg_parameter_acl_oid,
49 
50  if (!OidIsValid(oid) && !missing_ok)
51  ereport(ERROR,
52  (errcode(ERRCODE_UNDEFINED_OBJECT),
53  errmsg("parameter ACL \"%s\" does not exist", parameter)));
54 
55  pfree(parname);
56 
57  return oid;
58 }
#define OidIsValid(objectId)
Definition: c.h:759
void pfree(void *pointer)
Definition: mcxt.c:1436
@ 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.