1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Small patch to move get_grosysid() from catalog/aclchk.c to

utils/cache/lsyscache.c where it can be used by other things.  Also
cleans up both get_usesysid() and get_grosysid() a bit. From Stephen
Frost.
This commit is contained in:
Neil Conway
2005-01-27 23:36:15 +00:00
parent a885ecd6ef
commit f76730e35a
4 changed files with 40 additions and 31 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.119 2004/12/31 22:01:25 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.120 2005/01/27 23:36:12 neilc Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@ -25,6 +25,7 @@
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_shadow.h"
#include "catalog/pg_group.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
@ -2032,7 +2033,7 @@ get_namespace_name(Oid nspid)
AclId
get_usesysid(const char *username)
{
int32 result;
AclId userId;
HeapTuple userTup;
userTup = SearchSysCache(SHADOWNAME,
@ -2043,9 +2044,39 @@ get_usesysid(const char *username)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("user \"%s\" does not exist", username)));
result = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
userId = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
ReleaseSysCache(userTup);
return result;
return userId;
}
/*
* get_grosysid
*
* Given a group name, look up the group's sysid.
* Raises an error if no such group (rather than returning zero,
* which might possibly be a valid grosysid).
*
*/
AclId
get_grosysid(char *groname)
{
AclId groupId;
HeapTuple groupTup;
groupTup = SearchSysCache(GRONAME,
PointerGetDatum(groname),
0, 0, 0);
if (!HeapTupleIsValid(groupTup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("group \"%s\" does not exist", groname)));
groupId = ((Form_pg_group) GETSTRUCT(groupTup))->grosysid;
ReleaseSysCache(groupTup);
return groupId;
}