1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-13 16:22:44 +03:00

Add pg_statistic index, add missing Hiroshi file.

This commit is contained in:
Bruce Momjian
1999-11-24 16:52:50 +00:00
parent 61a93ed2da
commit 74f418eb9a
15 changed files with 183 additions and 101 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.31 1999/11/24 00:44:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.32 1999/11/24 16:52:31 momjian Exp $
*
* NOTES
* See acl.h.
@@ -350,7 +350,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
int32 result;
Relation relation;
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -469,7 +469,7 @@ pg_ownercheck(char *usename,
AclId user_id,
owner_id = 0;
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -535,7 +535,7 @@ pg_func_ownercheck(char *usename,
AclId user_id,
owner_id;
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -577,7 +577,7 @@ pg_aggr_ownercheck(char *usename,
AclId user_id,
owner_id;
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.51 1999/11/22 17:55:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.52 1999/11/24 16:52:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -880,6 +880,85 @@ RewriteOidIndexScan(Relation heapRelation, Oid rewriteId)
}
HeapTuple
ShadowNameIndexScan(Relation heapRelation, char *useName)
{
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(useName));
idesc = index_openr(ShadowNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
{
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_INT4EQ,
Int32GetDatum(sysId));
idesc = index_openr(ShadowSysidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
StatisticRelidAttnumOpIndexScan(Relation heapRelation,
Oid relId,
AttrNumber attNum,
Oid op)
{
Relation idesc;
ScanKeyData skey[3];
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relId));
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
(AttrNumber) 2,
(RegProcedure) F_INT2EQ,
Int16GetDatum(attNum));
ScanKeyEntryInitialize(&skey[2],
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(op));
idesc = index_openr(StatisticRelidAttnumOpIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
index_close(idesc);
return tuple;
}
HeapTuple
TypeNameIndexScan(Relation heapRelation, char *typeName)
{
@@ -923,46 +1002,3 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
return tuple;
}
HeapTuple
ShadowNameIndexScan(Relation heapRelation, char *useName)
{
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
PointerGetDatum(useName));
idesc = index_openr(ShadowNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}
HeapTuple
ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
{
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_INT4EQ,
Int32GetDatum(sysId));
idesc = index_openr(ShadowSysidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
return tuple;
}

View File

@@ -395,7 +395,7 @@ void CommentDatabase(char *database, char *comment) {
/*** Now, fetch user information ***/
username = GetPgUserName();
usertuple = SearchSysCacheTuple(USERNAME, PointerGetDatum(username),
usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
0, 0, 0);
if (!HeapTupleIsValid(usertuple)) {
elog(ERROR, "current user '%s' does not exist", username);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.44 1999/11/22 17:56:01 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.45 1999/11/24 16:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -241,7 +241,7 @@ check_permissions(char *command,
char path[MAXPGPATH];
userName = GetPgUserName();
utup = SearchSysCacheTuple(USERNAME,
utup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(userName),
0, 0, 0);
Assert(utup);

View File

@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: user.c,v 1.37 1999/11/22 17:56:02 momjian Exp $
* $Id: user.c,v 1.38 1999/11/24 16:52:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -261,7 +261,7 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(stmt->user),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -374,7 +374,7 @@ RemoveUser(char *user, CommandDest dest)
pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
pg_dsc = RelationGetDescr(pg_shadow_rel);
tuple = SearchSysCacheTuple(USERNAME,
tuple = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(user),
0, 0, 0);
if (!HeapTupleIsValid(tuple))

View File

@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.25 1999/11/22 17:56:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.26 1999/11/24 16:52:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -170,7 +170,7 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
*/
rte = (RangeTblEntry *) nth(rt_index - 1, parsetree->rtable);
ev_rel = heap_openr(rte->relname, AccessShareLock);
usertup = SearchSysCacheTuple(USERSYSID,
usertup = SearchSysCacheTuple(SHADOWSYSID,
ObjectIdGetDatum(ev_rel->rd_rel->relowner),
0, 0, 0);
if (!HeapTupleIsValid(usertup))

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.42 1999/11/22 17:56:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.43 1999/11/24 16:52:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -170,7 +170,7 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
switch (aip->ai_idtype)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(USERNAME,
htup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(name),
0, 0, 0);
if (!HeapTupleIsValid(htup))
@@ -281,7 +281,7 @@ aclitemout(AclItem *aip)
switch (aip->ai_idtype)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(USERSYSID,
htup = SearchSysCacheTuple(SHADOWSYSID,
ObjectIdGetDatum(aip->ai_id),
0, 0, 0);
if (!HeapTupleIsValid(htup))

View File

@@ -3,7 +3,7 @@
* out of it's tuple
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.32 1999/11/22 17:56:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.33 1999/11/24 16:52:37 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -567,7 +567,7 @@ pg_get_userbyid(int32 uid)
* Get the pg_shadow entry and print the result
* ----------
*/
usertup = SearchSysCacheTuple(USERSYSID,
usertup = SearchSysCacheTuple(SHADOWSYSID,
ObjectIdGetDatum(uid), 0, 0, 0);
if (HeapTupleIsValid(usertup))
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.42 1999/11/24 00:58:48 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.43 1999/11/24 16:52:38 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@@ -66,7 +66,8 @@ typedef HeapTuple (*ScanFunc) ();
lookups return only one row, so the index should be unique.
In backend/catalog/indexing.c, initialize the relation array with
the index names for the relation, and create the index lookup function.
the index names for the relation, fixed size of relation (or marking
first non-fixed length field), and create the index lookup function.
Pick one that takes similar arguments and use that one, but keep the
function names in the same order as the cache list for clarity.
@@ -333,6 +334,41 @@ static struct cachedesc cacheinfo[] = {
offsetof(FormData_pg_rewrite, ev_qual),
RewriteOidIndex,
RewriteOidIndexScan},
{ShadowRelationName, /* SHADOWNAME */
1,
{
Anum_pg_shadow_usename,
0,
0,
0
},
sizeof(FormData_pg_shadow),
NULL,NULL
/* ShadowNameIndex,
ShadowNameIndexScan*/},
{ShadowRelationName, /* SHADOWSYSID */
1,
{
Anum_pg_shadow_usesysid,
0,
0,
0
},
sizeof(FormData_pg_shadow),
NULL,NULL
/* ShadowSysidIndex,
ShadowSysidIndexScan*/},
{StatisticRelationName, /* STATRELID */
3,
{
Anum_pg_statistic_starelid,
Anum_pg_statistic_staattnum,
Anum_pg_statistic_staop,
0
},
offsetof(FormData_pg_statistic, stacommonval),
StatisticRelidAttnumOpIndex,
StatisticRelidAttnumOpIndexScan},
{TypeRelationName, /* TYPENAME */
1,
{
@@ -354,31 +390,7 @@ static struct cachedesc cacheinfo[] = {
},
offsetof(FormData_pg_type, typalign) +sizeof(char),
TypeOidIndex,
TypeOidIndexScan},
{ShadowRelationName, /* USERNAME */
1,
{
Anum_pg_shadow_usename,
0,
0,
0
},
sizeof(FormData_pg_shadow),
NULL,NULL
/* ShadowNameIndex,
ShadowNameIndexScan*/},
{ShadowRelationName, /* USERSYSID */
1,
{
Anum_pg_shadow_usesysid,
0,
0,
0
},
sizeof(FormData_pg_shadow),
NULL,NULL
/* ShadowSysidIndex,
ShadowSysidIndexScan*/}
TypeOidIndexScan}
};
static struct catcache *SysCache[lengthof(cacheinfo)];

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.36 1999/11/22 17:56:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.37 1999/11/24 16:52:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -453,7 +453,7 @@ SetUserId()
}
userName = GetPgUserName();
userTup = SearchSysCacheTuple(USERNAME,
userTup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(userName),
0, 0, 0);
if (!HeapTupleIsValid(userTup))

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.11 1999/11/22 17:56:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.12 1999/11/24 16:52:45 momjian Exp $
*
* DESCRIPTION
* See superuser().
@@ -30,7 +30,7 @@ superuser(void)
HeapTuple utup;
utup = SearchSysCacheTuple(USERNAME,
utup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(UserName),
0, 0, 0);
Assert(utup != NULL);