PostgreSQL Source Code
git master
Loading...
Searching...
No Matches
pg_parameter_acl.c
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* pg_parameter_acl.c
4
* routines to support manipulation of the pg_parameter_acl relation
5
*
6
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
8
*
9
*
10
* IDENTIFICATION
11
* src/backend/catalog/pg_parameter_acl.c
12
*
13
*-------------------------------------------------------------------------
14
*/
15
#include "
postgres.h
"
16
17
#include "
access/htup_details.h
"
18
#include "
access/table.h
"
19
#include "
catalog/catalog.h
"
20
#include "
catalog/indexing.h
"
21
#include "
catalog/pg_parameter_acl.h
"
22
#include "
utils/builtins.h
"
23
#include "
utils/guc.h
"
24
#include "
utils/rel.h
"
25
#include "
utils/syscache.h
"
26
27
28
/*
29
* ParameterAclLookup - Given a configuration parameter name,
30
* look up the associated configuration parameter ACL's OID.
31
*
32
* If missing_ok is false, throw an error if ACL entry not found. If
33
* true, just return InvalidOid.
34
*/
35
Oid
36
ParameterAclLookup
(
const
char
*
parameter
,
bool
missing_ok)
37
{
38
Oid
oid;
39
char
*
parname
;
40
41
/* Convert name to the form it should have in pg_parameter_acl... */
42
parname
=
convert_GUC_name_for_parameter_acl
(
parameter
);
43
44
/* ... and look it up */
45
oid =
GetSysCacheOid1
(
PARAMETERACLNAME
,
Anum_pg_parameter_acl_oid
,
46
PointerGetDatum
(
cstring_to_text
(
parname
)));
47
48
if
(!
OidIsValid
(oid) && !missing_ok)
49
ereport
(
ERROR
,
50
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
51
errmsg
(
"parameter ACL \"%s\" does not exist"
,
parameter
)));
52
53
pfree
(
parname
);
54
55
return
oid;
56
}
57
58
/*
59
* ParameterAclCreate
60
*
61
* Add a new tuple to pg_parameter_acl.
62
*
63
* parameter: the parameter name to create an entry for.
64
* Caller should have verified that there's no such entry already.
65
*
66
* Returns the new entry's OID.
67
*/
68
Oid
69
ParameterAclCreate
(
const
char
*
parameter
)
70
{
71
Oid
parameterId
;
72
char
*
parname
;
73
Relation
rel;
74
TupleDesc
tupDesc;
75
HeapTuple
tuple;
76
Datum
values
[
Natts_pg_parameter_acl
] = {0};
77
bool
nulls[
Natts_pg_parameter_acl
] = {0};
78
79
/*
80
* To prevent cluttering pg_parameter_acl with useless entries, insist
81
* that the name be valid.
82
*/
83
check_GUC_name_for_parameter_acl
(
parameter
);
84
85
/* Convert name to the form it should have in pg_parameter_acl. */
86
parname
=
convert_GUC_name_for_parameter_acl
(
parameter
);
87
88
/*
89
* Create and insert a new record containing a null ACL.
90
*
91
* We don't take a strong enough lock to prevent concurrent insertions,
92
* relying instead on the unique index.
93
*/
94
rel =
table_open
(
ParameterAclRelationId
,
RowExclusiveLock
);
95
tupDesc =
RelationGetDescr
(rel);
96
parameterId
=
GetNewOidWithIndex
(rel,
97
ParameterAclOidIndexId
,
98
Anum_pg_parameter_acl_oid
);
99
values
[
Anum_pg_parameter_acl_oid
- 1] =
ObjectIdGetDatum
(
parameterId
);
100
values
[
Anum_pg_parameter_acl_parname
- 1] =
101
PointerGetDatum
(
cstring_to_text
(
parname
));
102
nulls[
Anum_pg_parameter_acl_paracl
- 1] =
true
;
103
tuple =
heap_form_tuple
(tupDesc,
values
, nulls);
104
CatalogTupleInsert
(rel, tuple);
105
106
/* Close pg_parameter_acl, but keep lock till commit. */
107
heap_freetuple
(tuple);
108
table_close
(rel,
NoLock
);
109
110
return
parameterId
;
111
}
values
static Datum values[MAXATTR]
Definition
bootstrap.c:155
builtins.h
OidIsValid
#define OidIsValid(objectId)
Definition
c.h:788
GetNewOidWithIndex
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition
catalog.c:448
catalog.h
errcode
int errcode(int sqlerrcode)
Definition
elog.c:863
errmsg
int errmsg(const char *fmt,...)
Definition
elog.c:1080
ERROR
#define ERROR
Definition
elog.h:39
ereport
#define ereport(elevel,...)
Definition
elog.h:150
check_GUC_name_for_parameter_acl
void check_GUC_name_for_parameter_acl(const char *name)
Definition
guc.c:1287
convert_GUC_name_for_parameter_acl
char * convert_GUC_name_for_parameter_acl(const char *name)
Definition
guc.c:1251
guc.h
heap_form_tuple
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition
heaptuple.c:1117
heap_freetuple
void heap_freetuple(HeapTuple htup)
Definition
heaptuple.c:1435
htup_details.h
CatalogTupleInsert
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition
indexing.c:233
indexing.h
NoLock
#define NoLock
Definition
lockdefs.h:34
RowExclusiveLock
#define RowExclusiveLock
Definition
lockdefs.h:38
pfree
void pfree(void *pointer)
Definition
mcxt.c:1616
ParameterAclLookup
Oid ParameterAclLookup(const char *parameter, bool missing_ok)
Definition
pg_parameter_acl.c:36
ParameterAclCreate
Oid ParameterAclCreate(const char *parameter)
Definition
pg_parameter_acl.c:69
pg_parameter_acl.h
postgres.h
PointerGetDatum
static Datum PointerGetDatum(const void *X)
Definition
postgres.h:352
ObjectIdGetDatum
static Datum ObjectIdGetDatum(Oid X)
Definition
postgres.h:262
Datum
uint64_t Datum
Definition
postgres.h:70
Oid
unsigned int Oid
Definition
postgres_ext.h:32
fb
static int fb(int x)
Definition
preproc-init.c:92
rel.h
RelationGetDescr
#define RelationGetDescr(relation)
Definition
rel.h:540
HeapTupleData
Definition
htup.h:63
RelationData
Definition
rel.h:56
TupleDescData
Definition
tupdesc.h:136
syscache.h
GetSysCacheOid1
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition
syscache.h:109
table_close
void table_close(Relation relation, LOCKMODE lockmode)
Definition
table.c:126
table_open
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition
table.c:40
table.h
cstring_to_text
text * cstring_to_text(const char *s)
Definition
varlena.c:181
src
backend
catalog
pg_parameter_acl.c
Generated on Tue Jan 27 2026 06:13:11 for PostgreSQL Source Code by
1.9.8