mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Replace pg_shadow and pg_group by new role-capable catalogs pg_authid
and pg_auth_members. There are still many loose ends to finish in this patch (no documentation, no regression tests, no pg_dump support for instance). But I'm going to commit it now anyway so that Alvaro can make some progress on shared dependencies. The catalog changes should be pretty much done.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,14 +8,13 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.22 2005/05/11 01:41:41 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.23 2005/06/28 05:09:00 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/xact.h"
|
||||
#include "catalog/pg_shadow.h"
|
||||
#include "fmgr.h"
|
||||
#include "funcapi.h"
|
||||
#include "miscadmin.h"
|
||||
@@ -306,7 +305,7 @@ pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
|
||||
if (!OidIsValid(beentry->userid))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
PG_RETURN_INT32(beentry->userid);
|
||||
PG_RETURN_OID(beentry->userid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.79 2005/05/30 07:20:58 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.80 2005/06/28 05:09:00 tgl Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@@ -3036,7 +3036,7 @@ ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes,
|
||||
{
|
||||
void *qplan;
|
||||
Relation query_rel;
|
||||
AclId save_uid;
|
||||
Oid save_uid;
|
||||
|
||||
/*
|
||||
* The query is always run against the FK table except when this is an
|
||||
@@ -3089,7 +3089,7 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan,
|
||||
Snapshot crosscheck_snapshot;
|
||||
int limit;
|
||||
int spi_result;
|
||||
AclId save_uid;
|
||||
Oid save_uid;
|
||||
Datum vals[RI_MAX_NUMKEYS * 2];
|
||||
char nulls[RI_MAX_NUMKEYS * 2];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* back to source text
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.201 2005/06/26 22:05:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.202 2005/06/28 05:09:01 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -46,13 +46,13 @@
|
||||
#include "catalog/index.h"
|
||||
#include "catalog/indexing.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_authid.h"
|
||||
#include "catalog/pg_cast.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_depend.h"
|
||||
#include "catalog/pg_index.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_shadow.h"
|
||||
#include "catalog/pg_trigger.h"
|
||||
#include "executor/spi.h"
|
||||
#include "funcapi.h"
|
||||
@@ -1194,17 +1194,17 @@ pg_get_expr_worker(text *expr, Oid relid, char *relname, int prettyFlags)
|
||||
|
||||
|
||||
/* ----------
|
||||
* get_userbyid - Get a user name by usesysid and
|
||||
* fallback to 'unknown (UID=n)'
|
||||
* get_userbyid - Get a user name by roleid and
|
||||
* fallback to 'unknown (OID=n)'
|
||||
* ----------
|
||||
*/
|
||||
Datum
|
||||
pg_get_userbyid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int32 uid = PG_GETARG_INT32(0);
|
||||
Oid roleid = PG_GETARG_OID(0);
|
||||
Name result;
|
||||
HeapTuple usertup;
|
||||
Form_pg_shadow user_rec;
|
||||
HeapTuple roletup;
|
||||
Form_pg_authid role_rec;
|
||||
|
||||
/*
|
||||
* Allocate space for the result
|
||||
@@ -1213,19 +1213,19 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
|
||||
memset(NameStr(*result), 0, NAMEDATALEN);
|
||||
|
||||
/*
|
||||
* Get the pg_shadow entry and print the result
|
||||
* Get the pg_authid entry and print the result
|
||||
*/
|
||||
usertup = SearchSysCache(SHADOWSYSID,
|
||||
ObjectIdGetDatum(uid),
|
||||
roletup = SearchSysCache(AUTHOID,
|
||||
ObjectIdGetDatum(roleid),
|
||||
0, 0, 0);
|
||||
if (HeapTupleIsValid(usertup))
|
||||
if (HeapTupleIsValid(roletup))
|
||||
{
|
||||
user_rec = (Form_pg_shadow) GETSTRUCT(usertup);
|
||||
StrNCpy(NameStr(*result), NameStr(user_rec->usename), NAMEDATALEN);
|
||||
ReleaseSysCache(usertup);
|
||||
role_rec = (Form_pg_authid) GETSTRUCT(roletup);
|
||||
StrNCpy(NameStr(*result), NameStr(role_rec->rolname), NAMEDATALEN);
|
||||
ReleaseSysCache(roletup);
|
||||
}
|
||||
else
|
||||
sprintf(NameStr(*result), "unknown (UID=%d)", uid);
|
||||
sprintf(NameStr(*result), "unknown (OID=%u)", roleid);
|
||||
|
||||
PG_RETURN_NAME(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user