*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.98 2002/12/04 05:18:33 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.99 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void swap_relfilenodes(Oid r1, Oid r2);
static void cluster_rel(relToCluster *rv);
static bool check_cluster_ownership(Oid relOid);
-static List *get_tables_to_cluster(Oid owner);
+static List *get_tables_to_cluster(AclId owner);
static MemoryContext cluster_context = NULL;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.108 2002/12/02 05:20:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.109 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char src_loc[MAXPGPATH];
char buf[2 * MAXPGPATH + 100];
Oid src_dboid;
- int4 src_owner;
+ AclId src_owner;
int src_encoding;
bool src_istemplate;
Oid src_lastsysoid;
Datum new_record[Natts_pg_database];
char new_record_nulls[Natts_pg_database];
Oid dboid;
- int32 datdba;
+ AclId datdba;
List *option;
DefElem *downer = NULL;
DefElem *dpath = NULL;
else
datdba = GetUserId();
- if (datdba == (int32) GetUserId())
+ if (datdba == GetUserId())
{
/* creating database for self: can be superuser or createdb */
if (!superuser() && !have_createdb_privilege())
bool retval;
utup = SearchSysCache(SHADOWSYSID,
- ObjectIdGetDatum(GetUserId()),
+ Int32GetDatum(GetUserId()),
0, 0, 0);
if (!HeapTupleIsValid(utup))
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.6 2002/09/04 20:31:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.7 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *parsetree_list;
List *parsetree_item;
const char *owner_name;
- Oid owner_userid;
- Oid saved_userid;
+ AclId owner_userid;
+ AclId saved_userid;
AclResult aclresult;
saved_userid = GetUserId();
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.114 2002/12/02 05:20:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.115 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
TupleDesc pg_dsc;
ScanKeyData scankey;
HeapScanDesc scan;
- int32 usesysid;
+ AclId usesysid;
tuple = SearchSysCache(SHADOWNAME,
PointerGetDatum(user),
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.71 2002/09/04 20:31:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.72 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
const char *
assign_session_authorization(const char *value, bool doit, bool interactive)
{
- Oid usesysid;
+ AclId usesysid;
char *endptr;
char *result;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.188 2002/11/29 19:03:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.189 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation)
{
Oid relOid;
- Oid userid;
+ AclId userid;
AclResult aclcheck_result;
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.80 2002/09/11 14:48:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.81 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/syscache.h"
-static void setRuleCheckAsUser(Query *qry, Oid userid);
+static void setRuleCheckAsUser(Query *qry, AclId userid);
static bool setRuleCheckAsUser_walker(Node *node, Oid *context);
* them always.
*/
static void
-setRuleCheckAsUser(Query *qry, Oid userid)
+setRuleCheckAsUser(Query *qry, AclId userid)
{
List *l;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.83 2002/11/13 00:39:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.84 2002/12/05 04:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
text *tablename = PG_GETARG_TEXT_P(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
Oid tableoid;
AclMode mode;
AclResult aclresult;
{
Oid tableoid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
AclMode mode;
AclResult aclresult;
{
text *databasename = PG_GETARG_TEXT_P(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
Oid databaseoid;
AclMode mode;
AclResult aclresult;
{
Oid databaseoid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
AclMode mode;
AclResult aclresult;
{
text *functionname = PG_GETARG_TEXT_P(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
Oid functionoid;
AclMode mode;
AclResult aclresult;
{
Oid functionoid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
AclMode mode;
AclResult aclresult;
{
text *languagename = PG_GETARG_TEXT_P(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
Oid languageoid;
AclMode mode;
AclResult aclresult;
{
Oid languageoid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
AclMode mode;
AclResult aclresult;
{
text *schemaname = PG_GETARG_TEXT_P(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
Oid schemaoid;
AclMode mode;
AclResult aclresult;
{
Oid schemaoid = PG_GETARG_OID(0);
text *priv_type_text = PG_GETARG_TEXT_P(1);
- int32 usesysid;
+ AclId usesysid;
AclMode mode;
AclResult aclresult;
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.44 2002/11/29 21:39:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.45 2002/12/05 04:04:43 momjian Exp $
*
* ----------
*/
bool isnull;
int i;
int match_type;
- Oid save_uid;
+ AclId save_uid;
save_uid = GetUserId();
Datum check_values[RI_MAX_NUMKEYS];
char check_nulls[RI_MAX_NUMKEYS + 1];
int i;
- Oid save_uid;
+ AclId save_uid;
bool result;
save_uid = GetUserId();
bool isnull;
int i;
int match_type;
- Oid save_uid;
+ AclId save_uid;
save_uid = GetUserId();
bool isnull;
int i;
int match_type;
- Oid save_uid;
+ AclId save_uid;
save_uid = GetUserId();
char del_nulls[RI_MAX_NUMKEYS + 1];
bool isnull;
int i;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
bool isnull;
int i;
int j;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
char del_nulls[RI_MAX_NUMKEYS + 1];
bool isnull;
int i;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
char upd_nulls[RI_MAX_NUMKEYS + 1];
bool isnull;
int i;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
char upd_nulls[RI_MAX_NUMKEYS + 1];
bool isnull;
int i;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
int i;
int match_type;
bool use_cached_query;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
char upd_nulls[RI_MAX_NUMKEYS + 1];
bool isnull;
int i;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
bool isnull;
int i;
int match_type;
- Oid save_uid;
- Oid fk_owner;
+ AclId save_uid;
+ AclId fk_owner;
ReferentialIntegritySnapshotOverride = true;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.87 2002/12/01 21:05:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.88 2002/12/05 04:04:44 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
*-------------------------------------------------------------------------
*/
#include "postgres.h"
+#include "miscadmin.h"
#include "access/tupmacs.h"
#include "catalog/pg_amop.h"
* someday. It'd be reasonable to return zero on failure if we were
* using Oid ...
*/
-int32
+AclId
get_usesysid(const char *username)
{
int32 result;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.66 2002/11/13 00:39:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.67 2002/12/05 04:04:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
struct fmgr_security_definer_cache
{
FmgrInfo flinfo;
- Oid userid;
+ AclId userid;
};
/*
Datum result;
FmgrInfo *save_flinfo;
struct fmgr_security_definer_cache *fcache;
- Oid save_userid;
+ AclId save_userid;
HeapTuple tuple;
if (!fcinfo->flinfo->fn_extra)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.97 2002/11/08 20:23:57 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.98 2002/12/05 04:04:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* restore the current user id if you need to change it.
* ----------------------------------------------------------------
*/
-static Oid AuthenticatedUserId = InvalidOid;
-static Oid SessionUserId = InvalidOid;
-static Oid CurrentUserId = InvalidOid;
+static AclId AuthenticatedUserId = 0;
+static AclId SessionUserId = 0;
+static AclId CurrentUserId = 0;
static bool AuthenticatedUserIsSuperuser = false;
/*
* This function is relevant for all privilege checks.
*/
-Oid
+AclId
GetUserId(void)
{
- AssertState(OidIsValid(CurrentUserId));
+ AssertState(AclIdIsValid(CurrentUserId));
return CurrentUserId;
}
void
-SetUserId(Oid newid)
+SetUserId(AclId newid)
{
- AssertArg(OidIsValid(newid));
+ AssertArg(AclIdIsValid(newid));
CurrentUserId = newid;
}
/*
* This value is only relevant for informational purposes.
*/
-Oid
+AclId
GetSessionUserId(void)
{
- AssertState(OidIsValid(SessionUserId));
+ AssertState(AclIdIsValid(SessionUserId));
return SessionUserId;
}
void
-SetSessionUserId(Oid newid)
+SetSessionUserId(AclId newid)
{
- AssertArg(OidIsValid(newid));
+ AssertArg(AclIdIsValid(newid));
SessionUserId = newid;
/* Current user defaults to session user. */
- if (!OidIsValid(CurrentUserId))
+ if (!AclIdIsValid(CurrentUserId))
CurrentUserId = newid;
}
HeapTuple userTup;
Datum datum;
bool isnull;
- Oid usesysid;
+ AclId usesysid;
/*
* Don't do scans if we're bootstrapping, none of the system catalogs
* Only a superuser may set auth ID to something other than himself.
*/
void
-SetSessionAuthorization(Oid userid)
+SetSessionAuthorization(AclId userid)
{
/* Must have authenticated already, else can't make permission check */
- AssertState(OidIsValid(AuthenticatedUserId));
+ AssertState(AclIdIsValid(AuthenticatedUserId));
if (userid != AuthenticatedUserId &&
!AuthenticatedUserIsSuperuser)
* Get user name from user id
*/
char *
-GetUserNameFromId(Oid userid)
+GetUserNameFromId(AclId userid)
{
HeapTuple tuple;
char *result;
ObjectIdGetDatum(userid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "invalid user id %u", (unsigned) userid);
+ elog(ERROR, "invalid user id %d", userid);
result = pstrdup(NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.24 2002/08/09 16:45:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.25 2002/12/05 04:04:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool
-superuser_arg(Oid userid)
+superuser_arg(AclId userid)
{
bool result = false;
HeapTuple utup;
return true;
utup = SearchSysCache(SHADOWSYSID,
- ObjectIdGetDatum(userid),
+ Int32GetDatum(userid),
0, 0, 0);
if (HeapTupleIsValid(utup))
{
bool
is_dbadmin(Oid dbid)
{
- Oid dba;
+ AclId dba;
dba = get_database_owner(dbid);
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.132 2002/11/13 00:37:06 momjian Exp $
+ * $Id: c.h,v 1.133 2002/12/05 04:04:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
+#define AclIdIsValid(aclId) ((bool) ((aclId) != 0))
+
#define RegProcedureIsValid(p) OidIsValid(p)
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.112 2002/12/04 05:18:34 momjian Exp $
+ * $Id: miscadmin.h,v 1.113 2002/12/05 04:04:50 momjian Exp $
*
* NOTES
* some of the information in this file should be moved to
extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path);
-extern char *GetUserNameFromId(Oid userid);
-
/*
* AclId system identifier for the user, group, etc.
- * XXX Perhaps replace this type by OID?
*/
-typedef uint32 AclId;
+typedef int32 AclId;
+
+extern char *GetUserNameFromId(AclId userid);
extern AclId GetUserId(void);
-extern void SetUserId(Oid userid);
-extern Oid GetSessionUserId(void);
-extern void SetSessionUserId(Oid userid);
+extern void SetUserId(AclId userid);
+extern AclId GetSessionUserId(void);
+extern void SetSessionUserId(AclId userid);
extern void InitializeSessionUserId(const char *username);
extern void InitializeSessionUserIdStandalone(void);
-extern void SetSessionAuthorization(Oid userid);
+extern void SetSessionAuthorization(AclId userid);
extern void SetDataDir(const char *dir);
/* in utils/misc/superuser.c */
extern bool superuser(void); /* current user is superuser */
-extern bool superuser_arg(Oid userid); /* given user is superuser */
+extern bool superuser_arg(AclId userid); /* given user is superuser */
extern bool is_dbadmin(Oid dbid); /* current user is owner of
* database */
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
- * $Id: pgstat.h,v 1.10 2001/11/05 17:46:31 momjian Exp $
+ * $Id: pgstat.h,v 1.11 2002/12/05 04:04:51 momjian Exp $
* ----------
*/
#ifndef PGSTAT_H
#define PGSTAT_H
+#include "miscadmin.h"
+
/* ----------
* Paths for the statistics files. The %s is replaced with the
* installations $PGDATA.
int m_backendid;
int m_procpid;
Oid m_databaseid;
- Oid m_userid;
+ AclId m_userid;
} PgStat_MsgHdr;
/* ----------
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: acl.h,v 1.48 2002/12/04 05:18:38 momjian Exp $
+ * $Id: acl.h,v 1.49 2002/12/05 04:04:51 momjian Exp $
*
* NOTES
* For backward-compatibility purposes we have to allow there
extern AclId get_grosysid(char *groname);
extern char *get_groname(AclId grosysid);
-extern AclResult pg_class_aclcheck(Oid table_oid, Oid userid, AclMode mode);
-extern AclResult pg_database_aclcheck(Oid db_oid, Oid userid, AclMode mode);
-extern AclResult pg_proc_aclcheck(Oid proc_oid, Oid userid, AclMode mode);
-extern AclResult pg_language_aclcheck(Oid lang_oid, Oid userid, AclMode mode);
-extern AclResult pg_namespace_aclcheck(Oid nsp_oid, Oid userid, AclMode mode);
+extern AclResult pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode);
+extern AclResult pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode);
+extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode);
+extern AclResult pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode);
+extern AclResult pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode);
extern void aclcheck_error(AclResult errcode, const char *objectname);