diff options
author | Bruce Momjian | 1999-11-24 16:52:50 +0000 |
---|---|---|
committer | Bruce Momjian | 1999-11-24 16:52:50 +0000 |
commit | 4d7c743ec4d70328e70eb8e6df699e3a79722667 (patch) | |
tree | e972089b39e101e6c04348b855c0fb23c8702da2 | |
parent | b9d70891438e6ffaeaadee86ba1bfc8ef4623fbc (diff) |
Add pg_statistic index, add missing Hiroshi file.
-rw-r--r-- | src/backend/catalog/aclchk.c | 8 | ||||
-rw-r--r-- | src/backend/catalog/indexing.c | 74 | ||||
-rw-r--r-- | src/backend/commands/comment.c | 2 | ||||
-rw-r--r-- | src/backend/commands/dbcommands.c | 2 | ||||
-rw-r--r-- | src/backend/commands/user.c | 4 | ||||
-rw-r--r-- | src/backend/rewrite/locks.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/acl.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 2 | ||||
-rw-r--r-- | src/backend/utils/cache/syscache.c | 58 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 2 | ||||
-rw-r--r-- | src/backend/utils/misc/superuser.c | 2 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/indexing.h | 6 | ||||
-rw-r--r-- | src/include/executor/nodeTidscan.h | 27 | ||||
-rw-r--r-- | src/include/utils/syscache.h | 9 |
15 files changed, 143 insertions, 61 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 326d88ba4c..47e1c25293 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -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)) diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 7453e5a2b6..5a6089340f 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -881,42 +881,77 @@ RewriteOidIndexScan(Relation heapRelation, Oid rewriteId) HeapTuple -TypeNameIndexScan(Relation heapRelation, char *typeName) +ShadowNameIndexScan(Relation heapRelation, char *useName) { Relation idesc; ScanKeyData skey[1]; HeapTuple tuple; - + ScanKeyEntryInitialize(&skey[0], (bits16) 0x0, (AttrNumber) 1, (RegProcedure) F_NAMEEQ, - PointerGetDatum(typeName)); + PointerGetDatum(useName)); - idesc = index_openr(TypeNameIndex); + idesc = index_openr(ShadowNameIndex); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); index_close(idesc); - return tuple; } HeapTuple -TypeOidIndexScan(Relation heapRelation, Oid typeId) +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(typeId)); + ObjectIdGetDatum(relId)); - idesc = index_openr(TypeOidIndex); - tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); + 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); @@ -925,44 +960,45 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId) HeapTuple -ShadowNameIndexScan(Relation heapRelation, char *useName) +TypeNameIndexScan(Relation heapRelation, char *typeName) { Relation idesc; ScanKeyData skey[1]; HeapTuple tuple; - + ScanKeyEntryInitialize(&skey[0], (bits16) 0x0, (AttrNumber) 1, (RegProcedure) F_NAMEEQ, - PointerGetDatum(useName)); + PointerGetDatum(typeName)); - idesc = index_openr(ShadowNameIndex); + idesc = index_openr(TypeNameIndex); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); index_close(idesc); + return tuple; } HeapTuple -ShadowSysidIndexScan(Relation heapRelation, int4 sysId) +TypeOidIndexScan(Relation heapRelation, Oid typeId) { Relation idesc; ScanKeyData skey[1]; HeapTuple tuple; - + ScanKeyEntryInitialize(&skey[0], (bits16) 0x0, (AttrNumber) 1, - (RegProcedure) F_INT4EQ, - Int32GetDatum(sysId)); + (RegProcedure) F_OIDEQ, + ObjectIdGetDatum(typeId)); - idesc = index_openr(ShadowSysidIndex); + idesc = index_openr(TypeOidIndex); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); index_close(idesc); + return tuple; } - diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 4d58eb3ccc..1b046a5f57 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -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); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 40b29a0fc2..185c8d7716 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -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); diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 31248cc8a1..41a0ee9779 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -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)) diff --git a/src/backend/rewrite/locks.c b/src/backend/rewrite/locks.c index 0fc7320def..b2a9b8d2c6 100644 --- a/src/backend/rewrite/locks.c +++ b/src/backend/rewrite/locks.c @@ -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)) diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index efea6d1540..c8d02a594d 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -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)) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 6e64dc0ad2..d9fe720abe 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -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)) { diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index acc095fa69..bec8b97cf2 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -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,52 +334,63 @@ static struct cachedesc cacheinfo[] = { offsetof(FormData_pg_rewrite, ev_qual), RewriteOidIndex, RewriteOidIndexScan}, - {TypeRelationName, /* TYPENAME */ + {ShadowRelationName, /* SHADOWNAME */ 1, { - Anum_pg_type_typname, + Anum_pg_shadow_usename, 0, 0, 0 }, - offsetof(FormData_pg_type, typalign) +sizeof(char), - TypeNameIndex, - TypeNameIndexScan}, - {TypeRelationName, /* TYPEOID */ + sizeof(FormData_pg_shadow), +NULL,NULL +/* ShadowNameIndex, + ShadowNameIndexScan*/}, + {ShadowRelationName, /* SHADOWSYSID */ 1, { - ObjectIdAttributeNumber, + Anum_pg_shadow_usesysid, 0, 0, 0 }, - offsetof(FormData_pg_type, typalign) +sizeof(char), - TypeOidIndex, - TypeOidIndexScan}, - {ShadowRelationName, /* USERNAME */ + 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, { - Anum_pg_shadow_usename, + Anum_pg_type_typname, 0, 0, 0 }, - sizeof(FormData_pg_shadow), -NULL,NULL -/* ShadowNameIndex, - ShadowNameIndexScan*/}, - {ShadowRelationName, /* USERSYSID */ + offsetof(FormData_pg_type, typalign) +sizeof(char), + TypeNameIndex, + TypeNameIndexScan}, + {TypeRelationName, /* TYPEOID */ 1, { - Anum_pg_shadow_usesysid, + ObjectIdAttributeNumber, 0, 0, 0 }, - sizeof(FormData_pg_shadow), -NULL,NULL -/* ShadowSysidIndex, - ShadowSysidIndexScan*/} + offsetof(FormData_pg_type, typalign) +sizeof(char), + TypeOidIndex, + TypeOidIndexScan} }; static struct catcache *SysCache[lengthof(cacheinfo)]; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 10c225cf7d..01fcd32f60 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -453,7 +453,7 @@ SetUserId() } userName = GetPgUserName(); - userTup = SearchSysCacheTuple(USERNAME, + userTup = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(userName), 0, 0, 0); if (!HeapTupleIsValid(userTup)) diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index 85d6461634..6efc8a357c 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -30,7 +30,7 @@ superuser(void) HeapTuple utup; - utup = SearchSysCacheTuple(USERNAME, + utup = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(UserName), 0, 0, 0); Assert(utup != NULL); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 7afb2c046d..1cd2325a22 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -51,6 +51,6 @@ * catalog changes on the same day...) */ -#define CATALOG_VERSION_NO 199911221 +#define CATALOG_VERSION_NO 199911241 #endif diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 4a6eda23ea..c7cafe3569 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -37,6 +37,7 @@ #define Num_pg_relcheck_indices 1 #define Num_pg_rewrite_indices 2 #define Num_pg_shadow_indices 2 +#define Num_pg_statistic_indices 1 #define Num_pg_trigger_indices 3 #define Num_pg_type_indices 2 @@ -72,6 +73,7 @@ #define RewriteRulenameIndex "pg_rewrite_rulename_index" #define ShadowNameIndex "pg_shadow_name_index" #define ShadowSysidIndex "pg_shadow_sysid_index" +#define StatisticRelidAttnumOpIndex "pg_statistic_relid_att_op_index" #define TriggerConstrNameIndex "pg_trigger_tgconstrname_index" #define TriggerConstrRelidIndex "pg_trigger_tgconstrrelid_index" #define TriggerRelidIndex "pg_trigger_tgrelid_index" @@ -96,6 +98,7 @@ extern char *Name_pg_proc_indices[]; extern char *Name_pg_relcheck_indices[]; extern char *Name_pg_rewrite_indices[]; extern char *Name_pg_shadow_indices[]; +extern char *Name_pg_statistic_indices[]; extern char *Name_pg_trigger_indices[]; extern char *Name_pg_type_indices[]; @@ -150,6 +153,8 @@ extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation, char *ruleName); extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName); extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId); +extern HeapTuple StatisticRelidAttnumOpIndexScan(Relation heapRelation, + Oid relId, AttrNumber attNum, Oid op); extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName); extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId); @@ -197,6 +202,7 @@ DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulenam xDECLARE_UNIQUE_INDEX(pg_shadow_name_index on pg_shadow using btree(usename name_ops)); xDECLARE_UNIQUE_INDEX(pg_shadow_sysid_index on pg_shadow using btree(usesysid int4_ops)); */ +DECLARE_INDEX(pg_statistic_relid_att_op_index on pg_shadow using btree(starelid oid_ops, staattnum int2_ops, staop oid_ops)); DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops)); DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops)); DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops)); diff --git a/src/include/executor/nodeTidscan.h b/src/include/executor/nodeTidscan.h new file mode 100644 index 0000000000..885c5dafb6 --- /dev/null +++ b/src/include/executor/nodeTidscan.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * nodeTidscan.h + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id$ + * + *------------------------------------------------------------------------- + */ +#ifndef NODETIDSCAN_H +#define NODETIDSCAN_H + +#include "nodes/plannodes.h" + +extern TupleTableSlot *ExecTidScan(TidScan *node); +extern void ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent); +extern void ExecEndTidScan(TidScan *node); +extern void ExecTidMarkPos(TidScan *node); +extern void ExecTidRestrPos(TidScan *node); +extern bool ExecInitTidScan(TidScan *node, EState *estate, Plan *parent); +extern int ExecCountSlotsTidScan(TidScan *node); +extern void ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent); + +#endif /* NODETIDSCAN_H */ diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index fb373ed415..383cbb990c 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -53,10 +53,11 @@ #define RELOID 20 #define RULENAME 21 #define RULEOID 22 -#define TYPENAME 23 -#define TYPEOID 24 -#define USERNAME 25 -#define USERSYSID 26 +#define SHADOWNAME 23 +#define SHADOWSYSID 24 +#define STATRELID 25 +#define TYPENAME 26 +#define TYPEOID 27 /* ---------------- * struct cachedesc: information needed for a call to InitSysCache() |