Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf76730e

Browse files
author
Neil Conway
committed
Small patch to move get_grosysid() from catalog/aclchk.c to
utils/cache/lsyscache.c where it can be used by other things. Alsocleans up both get_usesysid() and get_grosysid() a bit. From StephenFrost.
1 parenta885ecd commitf76730e

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.109 2005/01/27 23:23:51 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.110 2005/01/27 23:36:06 neilc Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -1208,28 +1208,6 @@ privilege_to_string(AclMode privilege)
12081208
returnNULL;/* appease compiler */
12091209
}
12101210

1211-
1212-
AclId
1213-
get_grosysid(char*groname)
1214-
{
1215-
HeapTupletuple;
1216-
AclIdid=0;
1217-
1218-
tuple=SearchSysCache(GRONAME,
1219-
PointerGetDatum(groname),
1220-
0,0,0);
1221-
if (HeapTupleIsValid(tuple))
1222-
{
1223-
id= ((Form_pg_group)GETSTRUCT(tuple))->grosysid;
1224-
ReleaseSysCache(tuple);
1225-
}
1226-
else
1227-
ereport(ERROR,
1228-
(errcode(ERRCODE_UNDEFINED_OBJECT),
1229-
errmsg("group \"%s\" does not exist",groname)));
1230-
returnid;
1231-
}
1232-
12331211
/*
12341212
* Convert group ID to name, or return NULL if group can't be found
12351213
*/

‎src/backend/utils/cache/lsyscache.c

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.119 2004/12/31 22:01:25 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.120 2005/01/27 23:36:12 neilc Exp $
1111
*
1212
* NOTES
1313
* Eventually, the index information should go through here, too.
@@ -25,6 +25,7 @@
2525
#include"catalog/pg_operator.h"
2626
#include"catalog/pg_proc.h"
2727
#include"catalog/pg_shadow.h"
28+
#include"catalog/pg_group.h"
2829
#include"catalog/pg_statistic.h"
2930
#include"catalog/pg_type.h"
3031
#include"nodes/makefuncs.h"
@@ -2032,7 +2033,7 @@ get_namespace_name(Oid nspid)
20322033
AclId
20332034
get_usesysid(constchar*username)
20342035
{
2035-
int32result;
2036+
AclIduserId;
20362037
HeapTupleuserTup;
20372038

20382039
userTup=SearchSysCache(SHADOWNAME,
@@ -2043,9 +2044,39 @@ get_usesysid(const char *username)
20432044
(errcode(ERRCODE_UNDEFINED_OBJECT),
20442045
errmsg("user \"%s\" does not exist",username)));
20452046

2046-
result= ((Form_pg_shadow)GETSTRUCT(userTup))->usesysid;
2047+
userId= ((Form_pg_shadow)GETSTRUCT(userTup))->usesysid;
20472048

20482049
ReleaseSysCache(userTup);
20492050

2050-
returnresult;
2051+
returnuserId;
2052+
}
2053+
2054+
/*
2055+
* get_grosysid
2056+
*
2057+
* Given a group name, look up the group's sysid.
2058+
* Raises an error if no such group (rather than returning zero,
2059+
* which might possibly be a valid grosysid).
2060+
*
2061+
*/
2062+
AclId
2063+
get_grosysid(char*groname)
2064+
{
2065+
AclIdgroupId;
2066+
HeapTuplegroupTup;
2067+
2068+
groupTup=SearchSysCache(GRONAME,
2069+
PointerGetDatum(groname),
2070+
0,0,0);
2071+
if (!HeapTupleIsValid(groupTup))
2072+
ereport(ERROR,
2073+
(errcode(ERRCODE_UNDEFINED_OBJECT),
2074+
errmsg("group \"%s\" does not exist",groname)));
2075+
2076+
groupId= ((Form_pg_group)GETSTRUCT(groupTup))->grosysid;
2077+
2078+
ReleaseSysCache(groupTup);
2079+
2080+
returngroupId;
20512081
}
2082+

‎src/include/utils/acl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.76 2004/12/31 22:03:45 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.77 2005/01/27 23:36:14 neilc Exp $
1111
*
1212
* NOTES
1313
* An ACL array is simply an array of AclItems, representing the union
@@ -245,7 +245,6 @@ extern Datum hash_aclitem(PG_FUNCTION_ARGS);
245245
* prototypes for functions in aclchk.c
246246
*/
247247
externvoidExecuteGrantStmt(GrantStmt*stmt);
248-
externAclIdget_grosysid(char*groname);
249248
externchar*get_groname(AclIdgrosysid);
250249

251250
externAclModepg_class_aclmask(Oidtable_oid,AclIduserid,

‎src/include/utils/lsyscache.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.93 2004/12/31 22:03:46 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.94 2005/01/27 23:36:15 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -115,7 +115,8 @@ extern void free_attstatsslot(Oid atttype,
115115
Datum*values,intnvalues,
116116
float4*numbers,intnnumbers);
117117
externchar*get_namespace_name(Oidnspid);
118-
externint32get_usesysid(constchar*username);
118+
externAclIdget_usesysid(constchar*username);
119+
externAclIdget_grosysid(char*groname);
119120

120121
#defineis_array_type(typid) (get_element_type(typid) != InvalidOid)
121122

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp