Skip to content

Commit 74f418e

Browse files
committed
Add pg_statistic index, add missing Hiroshi file.
1 parent 61a93ed commit 74f418e

File tree

15 files changed

+156
-74
lines changed

15 files changed

+156
-74
lines changed

src/backend/catalog/aclchk.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.31 1999/11/24 00:44:28 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.32 1999/11/24 16:52:31 momjian Exp $
1111
*
1212
* NOTES
1313
* See acl.h.
@@ -350,7 +350,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
350350
int32 result;
351351
Relation relation;
352352

353-
tuple = SearchSysCacheTuple(USERNAME,
353+
tuple = SearchSysCacheTuple(SHADOWNAME,
354354
PointerGetDatum(usename),
355355
0, 0, 0);
356356
if (!HeapTupleIsValid(tuple))
@@ -469,7 +469,7 @@ pg_ownercheck(char *usename,
469469
AclId user_id,
470470
owner_id = 0;
471471

472-
tuple = SearchSysCacheTuple(USERNAME,
472+
tuple = SearchSysCacheTuple(SHADOWNAME,
473473
PointerGetDatum(usename),
474474
0, 0, 0);
475475
if (!HeapTupleIsValid(tuple))
@@ -535,7 +535,7 @@ pg_func_ownercheck(char *usename,
535535
AclId user_id,
536536
owner_id;
537537

538-
tuple = SearchSysCacheTuple(USERNAME,
538+
tuple = SearchSysCacheTuple(SHADOWNAME,
539539
PointerGetDatum(usename),
540540
0, 0, 0);
541541
if (!HeapTupleIsValid(tuple))
@@ -577,7 +577,7 @@ pg_aggr_ownercheck(char *usename,
577577
AclId user_id,
578578
owner_id;
579579

580-
tuple = SearchSysCacheTuple(USERNAME,
580+
tuple = SearchSysCacheTuple(SHADOWNAME,
581581
PointerGetDatum(usename),
582582
0, 0, 0);
583583
if (!HeapTupleIsValid(tuple))

src/backend/catalog/indexing.c

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.51 1999/11/22 17:55:57 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.52 1999/11/24 16:52:31 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -881,42 +881,77 @@ RewriteOidIndexScan(Relation heapRelation, Oid rewriteId)
881881

882882

883883
HeapTuple
884-
TypeNameIndexScan(Relation heapRelation, char *typeName)
884+
ShadowNameIndexScan(Relation heapRelation, char *useName)
885885
{
886886
Relation idesc;
887887
ScanKeyData skey[1];
888888
HeapTuple tuple;
889-
889+
890890
ScanKeyEntryInitialize(&skey[0],
891891
(bits16) 0x0,
892892
(AttrNumber) 1,
893893
(RegProcedure) F_NAMEEQ,
894-
PointerGetDatum(typeName));
894+
PointerGetDatum(useName));
895895

896-
idesc = index_openr(TypeNameIndex);
896+
idesc = index_openr(ShadowNameIndex);
897897
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
898898

899899
index_close(idesc);
900-
901900
return tuple;
902901
}
903902

904903

905904
HeapTuple
906-
TypeOidIndexScan(Relation heapRelation, Oid typeId)
905+
ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
907906
{
908907
Relation idesc;
909908
ScanKeyData skey[1];
910909
HeapTuple tuple;
910+
911+
ScanKeyEntryInitialize(&skey[0],
912+
(bits16) 0x0,
913+
(AttrNumber) 1,
914+
(RegProcedure) F_INT4EQ,
915+
Int32GetDatum(sysId));
916+
917+
idesc = index_openr(ShadowSysidIndex);
918+
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
919+
920+
index_close(idesc);
921+
return tuple;
922+
}
923+
924+
925+
HeapTuple
926+
StatisticRelidAttnumOpIndexScan(Relation heapRelation,
927+
Oid relId,
928+
AttrNumber attNum,
929+
Oid op)
930+
{
931+
Relation idesc;
932+
ScanKeyData skey[3];
933+
HeapTuple tuple;
911934

912935
ScanKeyEntryInitialize(&skey[0],
913936
(bits16) 0x0,
914937
(AttrNumber) 1,
915938
(RegProcedure) F_OIDEQ,
916-
ObjectIdGetDatum(typeId));
939+
ObjectIdGetDatum(relId));
917940

918-
idesc = index_openr(TypeOidIndex);
919-
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
941+
ScanKeyEntryInitialize(&skey[1],
942+
(bits16) 0x0,
943+
(AttrNumber) 2,
944+
(RegProcedure) F_INT2EQ,
945+
Int16GetDatum(attNum));
946+
947+
ScanKeyEntryInitialize(&skey[2],
948+
(bits16) 0x0,
949+
(AttrNumber) 3,
950+
(RegProcedure) F_OIDEQ,
951+
ObjectIdGetDatum(op));
952+
953+
idesc = index_openr(StatisticRelidAttnumOpIndex);
954+
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
920955

921956
index_close(idesc);
922957

@@ -925,44 +960,45 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
925960

926961

927962
HeapTuple
928-
ShadowNameIndexScan(Relation heapRelation, char *useName)
963+
TypeNameIndexScan(Relation heapRelation, char *typeName)
929964
{
930965
Relation idesc;
931966
ScanKeyData skey[1];
932967
HeapTuple tuple;
933-
968+
934969
ScanKeyEntryInitialize(&skey[0],
935970
(bits16) 0x0,
936971
(AttrNumber) 1,
937972
(RegProcedure) F_NAMEEQ,
938-
PointerGetDatum(useName));
973+
PointerGetDatum(typeName));
939974

940-
idesc = index_openr(ShadowNameIndex);
975+
idesc = index_openr(TypeNameIndex);
941976
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
942977

943978
index_close(idesc);
979+
944980
return tuple;
945981
}
946982

947983

948984
HeapTuple
949-
ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
985+
TypeOidIndexScan(Relation heapRelation, Oid typeId)
950986
{
951987
Relation idesc;
952988
ScanKeyData skey[1];
953989
HeapTuple tuple;
954-
990+
955991
ScanKeyEntryInitialize(&skey[0],
956992
(bits16) 0x0,
957993
(AttrNumber) 1,
958-
(RegProcedure) F_INT4EQ,
959-
Int32GetDatum(sysId));
994+
(RegProcedure) F_OIDEQ,
995+
ObjectIdGetDatum(typeId));
960996

961-
idesc = index_openr(ShadowSysidIndex);
997+
idesc = index_openr(TypeOidIndex);
962998
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
963999

9641000
index_close(idesc);
1001+
9651002
return tuple;
9661003
}
9671004

968-

src/backend/commands/comment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void CommentDatabase(char *database, char *comment) {
395395
/*** Now, fetch user information ***/
396396

397397
username = GetPgUserName();
398-
usertuple = SearchSysCacheTuple(USERNAME, PointerGetDatum(username),
398+
usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
399399
0, 0, 0);
400400
if (!HeapTupleIsValid(usertuple)) {
401401
elog(ERROR, "current user '%s' does not exist", username);

src/backend/commands/dbcommands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.44 1999/11/22 17:56:01 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.45 1999/11/24 16:52:32 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -241,7 +241,7 @@ check_permissions(char *command,
241241
char path[MAXPGPATH];
242242

243243
userName = GetPgUserName();
244-
utup = SearchSysCacheTuple(USERNAME,
244+
utup = SearchSysCacheTuple(SHADOWNAME,
245245
PointerGetDatum(userName),
246246
0, 0, 0);
247247
Assert(utup);

src/backend/commands/user.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: user.c,v 1.37 1999/11/22 17:56:02 momjian Exp $
8+
* $Id: user.c,v 1.38 1999/11/24 16:52:32 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -261,7 +261,7 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
261261
pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
262262
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
263263

264-
tuple = SearchSysCacheTuple(USERNAME,
264+
tuple = SearchSysCacheTuple(SHADOWNAME,
265265
PointerGetDatum(stmt->user),
266266
0, 0, 0);
267267
if (!HeapTupleIsValid(tuple))
@@ -374,7 +374,7 @@ RemoveUser(char *user, CommandDest dest)
374374
pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
375375
pg_dsc = RelationGetDescr(pg_shadow_rel);
376376

377-
tuple = SearchSysCacheTuple(USERNAME,
377+
tuple = SearchSysCacheTuple(SHADOWNAME,
378378
PointerGetDatum(user),
379379
0, 0, 0);
380380
if (!HeapTupleIsValid(tuple))

src/backend/rewrite/locks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.25 1999/11/22 17:56:23 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.26 1999/11/24 16:52:33 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -170,7 +170,7 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index)
170170
*/
171171
rte = (RangeTblEntry *) nth(rt_index - 1, parsetree->rtable);
172172
ev_rel = heap_openr(rte->relname, AccessShareLock);
173-
usertup = SearchSysCacheTuple(USERSYSID,
173+
usertup = SearchSysCacheTuple(SHADOWSYSID,
174174
ObjectIdGetDatum(ev_rel->rd_rel->relowner),
175175
0, 0, 0);
176176
if (!HeapTupleIsValid(usertup))

src/backend/utils/adt/acl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.42 1999/11/22 17:56:28 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.43 1999/11/24 16:52:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -170,7 +170,7 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
170170
switch (aip->ai_idtype)
171171
{
172172
case ACL_IDTYPE_UID:
173-
htup = SearchSysCacheTuple(USERNAME,
173+
htup = SearchSysCacheTuple(SHADOWNAME,
174174
PointerGetDatum(name),
175175
0, 0, 0);
176176
if (!HeapTupleIsValid(htup))
@@ -281,7 +281,7 @@ aclitemout(AclItem *aip)
281281
switch (aip->ai_idtype)
282282
{
283283
case ACL_IDTYPE_UID:
284-
htup = SearchSysCacheTuple(USERSYSID,
284+
htup = SearchSysCacheTuple(SHADOWSYSID,
285285
ObjectIdGetDatum(aip->ai_id),
286286
0, 0, 0);
287287
if (!HeapTupleIsValid(htup))

src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* out of it's tuple
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.32 1999/11/22 17:56:30 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.33 1999/11/24 16:52:37 momjian Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -567,7 +567,7 @@ pg_get_userbyid(int32 uid)
567567
* Get the pg_shadow entry and print the result
568568
* ----------
569569
*/
570-
usertup = SearchSysCacheTuple(USERSYSID,
570+
usertup = SearchSysCacheTuple(SHADOWSYSID,
571571
ObjectIdGetDatum(uid), 0, 0, 0);
572572
if (HeapTupleIsValid(usertup))
573573
{

0 commit comments

Comments
 (0)