mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
has_table_privilege functions from Joe Conway (with some kibitzing from
Tom Lane). For the moment, only the OID/name variants are provided. I didn't force initdb, but the additions to the 'privileges' regress test won't pass until you do one.
This commit is contained in:
38
src/backend/utils/cache/lsyscache.c
vendored
38
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.55 2001/05/09 23:13:35 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.56 2001/06/14 01:09:22 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -18,6 +18,7 @@
|
||||
#include "access/tupmacs.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_shadow.h"
|
||||
#include "catalog/pg_statistic.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "utils/array.h"
|
||||
@ -25,6 +26,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
/* ---------- AMOP CACHES ---------- */
|
||||
|
||||
/*
|
||||
@ -537,7 +539,7 @@ get_relnatts(Oid relid)
|
||||
*
|
||||
* Returns the name of a given relation.
|
||||
*
|
||||
* Note: returns a palloc'd copy of the string, or NULL if no such operator.
|
||||
* Note: returns a palloc'd copy of the string, or NULL if no such relation.
|
||||
*/
|
||||
char *
|
||||
get_rel_name(Oid relid)
|
||||
@ -1039,3 +1041,35 @@ free_attstatsslot(Oid atttype,
|
||||
if (numbers)
|
||||
pfree(numbers);
|
||||
}
|
||||
|
||||
/* ---------- PG_SHADOW CACHE ---------- */
|
||||
|
||||
/*
|
||||
* get_usesysid
|
||||
*
|
||||
* Given a user name, look up the user's sysid.
|
||||
* Raises an error if no such user (rather than returning zero,
|
||||
* which might possibly be a valid usesysid).
|
||||
*
|
||||
* Note: the type of usesysid is currently int4, but may change to Oid
|
||||
* someday. It'd be reasonable to return zero on failure if we were
|
||||
* using Oid ...
|
||||
*/
|
||||
int32
|
||||
get_usesysid(const char *username)
|
||||
{
|
||||
int32 result;
|
||||
HeapTuple userTup;
|
||||
|
||||
userTup = SearchSysCache(SHADOWNAME,
|
||||
PointerGetDatum(username),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(userTup))
|
||||
elog(ERROR, "user \"%s\" does not exist", username);
|
||||
|
||||
result = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
|
||||
|
||||
ReleaseSysCache(userTup);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user