mirror of
https://github.com/postgres/postgres.git
synced 2025-05-25 00:04:05 -04: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:
parent
a885ecd6ef
commit
f76730e35a
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.109 2005/01/27 23:23:51 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.110 2005/01/27 23:36:06 neilc Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* See acl.h.
|
* See acl.h.
|
||||||
@ -1208,28 +1208,6 @@ privilege_to_string(AclMode privilege)
|
|||||||
return NULL; /* appease compiler */
|
return NULL; /* appease compiler */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AclId
|
|
||||||
get_grosysid(char *groname)
|
|
||||||
{
|
|
||||||
HeapTuple tuple;
|
|
||||||
AclId id = 0;
|
|
||||||
|
|
||||||
tuple = SearchSysCache(GRONAME,
|
|
||||||
PointerGetDatum(groname),
|
|
||||||
0, 0, 0);
|
|
||||||
if (HeapTupleIsValid(tuple))
|
|
||||||
{
|
|
||||||
id = ((Form_pg_group) GETSTRUCT(tuple))->grosysid;
|
|
||||||
ReleaseSysCache(tuple);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
|
||||||
errmsg("group \"%s\" does not exist", groname)));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert group ID to name, or return NULL if group can't be found
|
* Convert group ID to name, or return NULL if group can't be found
|
||||||
*/
|
*/
|
||||||
|
39
src/backend/utils/cache/lsyscache.c
vendored
39
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* NOTES
|
||||||
* Eventually, the index information should go through here, too.
|
* Eventually, the index information should go through here, too.
|
||||||
@ -25,6 +25,7 @@
|
|||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
|
#include "catalog/pg_group.h"
|
||||||
#include "catalog/pg_statistic.h"
|
#include "catalog/pg_statistic.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "nodes/makefuncs.h"
|
#include "nodes/makefuncs.h"
|
||||||
@ -2032,7 +2033,7 @@ get_namespace_name(Oid nspid)
|
|||||||
AclId
|
AclId
|
||||||
get_usesysid(const char *username)
|
get_usesysid(const char *username)
|
||||||
{
|
{
|
||||||
int32 result;
|
AclId userId;
|
||||||
HeapTuple userTup;
|
HeapTuple userTup;
|
||||||
|
|
||||||
userTup = SearchSysCache(SHADOWNAME,
|
userTup = SearchSysCache(SHADOWNAME,
|
||||||
@ -2043,9 +2044,39 @@ get_usesysid(const char *username)
|
|||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
errmsg("user \"%s\" does not exist", username)));
|
errmsg("user \"%s\" does not exist", username)));
|
||||||
|
|
||||||
result = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
|
userId = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
|
||||||
|
|
||||||
ReleaseSysCache(userTup);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.76 2004/12/31 22:03:45 pgsql Exp $
|
* $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.77 2005/01/27 23:36:14 neilc Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* An ACL array is simply an array of AclItems, representing the union
|
* An ACL array is simply an array of AclItems, representing the union
|
||||||
@ -245,7 +245,6 @@ extern Datum hash_aclitem(PG_FUNCTION_ARGS);
|
|||||||
* prototypes for functions in aclchk.c
|
* prototypes for functions in aclchk.c
|
||||||
*/
|
*/
|
||||||
extern void ExecuteGrantStmt(GrantStmt *stmt);
|
extern void ExecuteGrantStmt(GrantStmt *stmt);
|
||||||
extern AclId get_grosysid(char *groname);
|
|
||||||
extern char *get_groname(AclId grosysid);
|
extern char *get_groname(AclId grosysid);
|
||||||
|
|
||||||
extern AclMode pg_class_aclmask(Oid table_oid, AclId userid,
|
extern AclMode pg_class_aclmask(Oid table_oid, AclId userid,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.93 2004/12/31 22:03:46 pgsql Exp $
|
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.94 2005/01/27 23:36:15 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -115,7 +115,8 @@ extern void free_attstatsslot(Oid atttype,
|
|||||||
Datum *values, int nvalues,
|
Datum *values, int nvalues,
|
||||||
float4 *numbers, int nnumbers);
|
float4 *numbers, int nnumbers);
|
||||||
extern char *get_namespace_name(Oid nspid);
|
extern char *get_namespace_name(Oid nspid);
|
||||||
extern int32 get_usesysid(const char *username);
|
extern AclId get_usesysid(const char *username);
|
||||||
|
extern AclId get_grosysid(char *groname);
|
||||||
|
|
||||||
#define is_array_type(typid) (get_element_type(typid) != InvalidOid)
|
#define is_array_type(typid) (get_element_type(typid) != InvalidOid)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user