mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
252
src/backend/utils/cache/catcache.c
vendored
252
src/backend/utils/cache/catcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.11 1997/09/07 04:52:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.12 1997/09/08 02:31:09 momjian Exp $
|
||||
*
|
||||
* Notes:
|
||||
* XXX This needs to use exception.h to handle recovery when
|
||||
@ -34,15 +34,15 @@
|
||||
#include "catalog/pg_type.h" /* for OID of int28 type */
|
||||
#include "lib/dllist.h"
|
||||
|
||||
static void CatCacheRemoveCTup(CatCache * cache, Dlelem * e);
|
||||
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
|
||||
static void CatCacheRemoveCTup(CatCache * cache, Dlelem * e);
|
||||
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
|
||||
static Index
|
||||
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
|
||||
Relation relation, HeapTuple tuple);
|
||||
static void
|
||||
CatalogCacheInitializeCache(struct catcache * cache,
|
||||
Relation relation);
|
||||
static long comphash(long l, char *v);
|
||||
static long comphash(long l, char *v);
|
||||
|
||||
/* ----------------
|
||||
* variables, macros and other stuff
|
||||
@ -68,17 +68,17 @@ static long comphash(long l, char *v);
|
||||
#define CACHE6_elog(a,b,c,d,e,f,g)
|
||||
#endif
|
||||
|
||||
CatCache *Caches = NULL;
|
||||
GlobalMemory CacheCxt;
|
||||
CatCache *Caches = NULL;
|
||||
GlobalMemory CacheCxt;
|
||||
|
||||
static int DisableCache;
|
||||
static int DisableCache;
|
||||
|
||||
/* ----------------
|
||||
* EQPROC is used in CatalogCacheInitializeCache
|
||||
* XXX this should be replaced by catalog lookups soon
|
||||
* ----------------
|
||||
*/
|
||||
static long eqproc[] = {
|
||||
static long eqproc[] = {
|
||||
F_BOOLEQ, 0l, F_CHAREQ, F_CHAR16EQ, 0l,
|
||||
F_INT2EQ, F_KEYFIRSTEQ, F_INT4EQ, 0l, F_TEXTEQ,
|
||||
F_OIDEQ, 0l, 0l, 0l, F_OID8EQ
|
||||
@ -120,10 +120,10 @@ static void
|
||||
CatalogCacheInitializeCache(struct catcache * cache,
|
||||
Relation relation)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
short didopen = 0;
|
||||
short i;
|
||||
TupleDesc tupdesc;
|
||||
MemoryContext oldcxt;
|
||||
short didopen = 0;
|
||||
short i;
|
||||
TupleDesc tupdesc;
|
||||
|
||||
CatalogCacheInitializeCache_DEBUG1;
|
||||
|
||||
@ -289,17 +289,17 @@ CatalogCacheSetId(CatCache * cacheInOutP, int id)
|
||||
static long
|
||||
comphash(long l, register char *v)
|
||||
{
|
||||
long i;
|
||||
NameData n;
|
||||
long i;
|
||||
NameData n;
|
||||
|
||||
CACHE3_elog(DEBUG, "comphash (%d,%x)", l, v);
|
||||
|
||||
switch (l)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
return ((long) v);
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
return ((long) v);
|
||||
}
|
||||
|
||||
if (l == NAMEDATALEN)
|
||||
@ -329,10 +329,10 @@ comphash(long l, register char *v)
|
||||
* CatalogCacheComputeHashIndex
|
||||
* --------------------------------
|
||||
*/
|
||||
static Index
|
||||
static Index
|
||||
CatalogCacheComputeHashIndex(struct catcache * cacheInP)
|
||||
{
|
||||
Index hashIndex;
|
||||
Index hashIndex;
|
||||
|
||||
hashIndex = 0x0;
|
||||
CACHE6_elog(DEBUG, "CatalogCacheComputeHashIndex %s %d %d %d %x",
|
||||
@ -344,25 +344,25 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP)
|
||||
|
||||
switch (cacheInP->cc_nkeys)
|
||||
{
|
||||
case 4:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[3],
|
||||
case 4:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[3],
|
||||
(char *) cacheInP->cc_skey[3].sk_argument) << 9;
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[2],
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[2],
|
||||
(char *) cacheInP->cc_skey[2].sk_argument) << 6;
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[1],
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[1],
|
||||
(char *) cacheInP->cc_skey[1].sk_argument) << 3;
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[0],
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
hashIndex ^= comphash(cacheInP->cc_klen[0],
|
||||
(char *) cacheInP->cc_skey[0].sk_argument);
|
||||
break;
|
||||
default:
|
||||
elog(FATAL, "CCComputeHashIndex: %d cc_nkeys", cacheInP->cc_nkeys);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
elog(FATAL, "CCComputeHashIndex: %d cc_nkeys", cacheInP->cc_nkeys);
|
||||
break;
|
||||
}
|
||||
hashIndex %= cacheInP->cc_size;
|
||||
return (hashIndex);
|
||||
@ -372,62 +372,62 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP)
|
||||
* CatalogCacheComputeTupleHashIndex
|
||||
* --------------------------------
|
||||
*/
|
||||
static Index
|
||||
static Index
|
||||
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
|
||||
Relation relation,
|
||||
HeapTuple tuple)
|
||||
{
|
||||
bool isNull = '\0';
|
||||
bool isNull = '\0';
|
||||
|
||||
if (cacheInOutP->relationId == InvalidOid)
|
||||
CatalogCacheInitializeCache(cacheInOutP, relation);
|
||||
switch (cacheInOutP->cc_nkeys)
|
||||
{
|
||||
case 4:
|
||||
cacheInOutP->cc_skey[3].sk_argument =
|
||||
(cacheInOutP->cc_key[3] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[3],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
cacheInOutP->cc_skey[2].sk_argument =
|
||||
(cacheInOutP->cc_key[2] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[2],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
cacheInOutP->cc_skey[1].sk_argument =
|
||||
(cacheInOutP->cc_key[1] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[1],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
cacheInOutP->cc_skey[0].sk_argument =
|
||||
(cacheInOutP->cc_key[0] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[0],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
break;
|
||||
default:
|
||||
elog(FATAL, "CCComputeTupleHashIndex: %d cc_nkeys",
|
||||
cacheInOutP->cc_nkeys
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
cacheInOutP->cc_skey[3].sk_argument =
|
||||
(cacheInOutP->cc_key[3] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[3],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
cacheInOutP->cc_skey[2].sk_argument =
|
||||
(cacheInOutP->cc_key[2] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[2],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
cacheInOutP->cc_skey[1].sk_argument =
|
||||
(cacheInOutP->cc_key[1] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[1],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
cacheInOutP->cc_skey[0].sk_argument =
|
||||
(cacheInOutP->cc_key[0] == ObjectIdAttributeNumber)
|
||||
? (Datum) tuple->t_oid
|
||||
: (Datum) fastgetattr(tuple,
|
||||
cacheInOutP->cc_key[0],
|
||||
RelationGetTupleDescriptor(relation),
|
||||
&isNull);
|
||||
Assert(!isNull);
|
||||
break;
|
||||
default:
|
||||
elog(FATAL, "CCComputeTupleHashIndex: %d cc_nkeys",
|
||||
cacheInOutP->cc_nkeys
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return
|
||||
@ -441,9 +441,9 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
|
||||
static void
|
||||
CatCacheRemoveCTup(CatCache * cache, Dlelem * elt)
|
||||
{
|
||||
CatCTup *ct;
|
||||
CatCTup *other_ct;
|
||||
Dlelem *other_elt;
|
||||
CatCTup *ct;
|
||||
CatCTup *other_ct;
|
||||
Dlelem *other_elt;
|
||||
|
||||
if (elt)
|
||||
ct = (CatCTup *) DLE_VAL(elt);
|
||||
@ -475,10 +475,10 @@ CatalogCacheIdInvalidate(int cacheId, /* XXX */
|
||||
Index hashIndex,
|
||||
ItemPointer pointer)
|
||||
{
|
||||
CatCache *ccp;
|
||||
CatCTup *ct;
|
||||
Dlelem *elt;
|
||||
MemoryContext oldcxt;
|
||||
CatCache *ccp;
|
||||
CatCTup *ct;
|
||||
Dlelem *elt;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@ -558,7 +558,7 @@ CatalogCacheIdInvalidate(int cacheId, /* XXX */
|
||||
void
|
||||
ResetSystemCache()
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
struct catcache *cache;
|
||||
|
||||
/* ----------------
|
||||
@ -593,12 +593,12 @@ ResetSystemCache()
|
||||
*/
|
||||
for (cache = Caches; PointerIsValid(cache); cache = cache->cc_next)
|
||||
{
|
||||
int hash;
|
||||
int hash;
|
||||
|
||||
for (hash = 0; hash < NCCBUCK; hash += 1)
|
||||
{
|
||||
Dlelem *elt,
|
||||
*nextelt;
|
||||
Dlelem *elt,
|
||||
*nextelt;
|
||||
|
||||
for (elt = DLGetHead(cache->cc_cache[hash]); elt; elt = nextelt)
|
||||
{
|
||||
@ -645,7 +645,7 @@ elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \
|
||||
#define InitSysCache_DEBUG1
|
||||
#endif
|
||||
|
||||
CatCache *
|
||||
CatCache *
|
||||
InitSysCache(char *relname,
|
||||
char *iname,
|
||||
int id,
|
||||
@ -653,11 +653,11 @@ InitSysCache(char *relname,
|
||||
int key[],
|
||||
HeapTuple(*iScanfuncP) ())
|
||||
{
|
||||
CatCache *cp;
|
||||
register int i;
|
||||
MemoryContext oldcxt;
|
||||
CatCache *cp;
|
||||
register int i;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
char *indname;
|
||||
char *indname;
|
||||
|
||||
indname = (iname) ? iname : NULL;
|
||||
|
||||
@ -691,7 +691,7 @@ InitSysCache(char *relname,
|
||||
* We could move this to dllist.c, but the way we do this is not
|
||||
* dynamic/portabl, so why allow other routines to use it.
|
||||
*/
|
||||
Dllist *cache_begin = malloc((NCCBUCK + 1) * sizeof(Dllist));
|
||||
Dllist *cache_begin = malloc((NCCBUCK + 1) * sizeof(Dllist));
|
||||
|
||||
for (i = 0; i <= NCCBUCK; ++i)
|
||||
{
|
||||
@ -798,16 +798,16 @@ SearchSysCache(struct catcache * cache,
|
||||
Datum v3,
|
||||
Datum v4)
|
||||
{
|
||||
unsigned hash;
|
||||
CatCTup *ct = NULL;
|
||||
CatCTup *nct;
|
||||
CatCTup *nct2;
|
||||
Dlelem *elt;
|
||||
HeapTuple ntp = 0;
|
||||
Buffer buffer;
|
||||
unsigned hash;
|
||||
CatCTup *ct = NULL;
|
||||
CatCTup *nct;
|
||||
CatCTup *nct2;
|
||||
Dlelem *elt;
|
||||
HeapTuple ntp = 0;
|
||||
Buffer buffer;
|
||||
|
||||
Relation relation;
|
||||
MemoryContext oldcxt;
|
||||
Relation relation;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@ -859,7 +859,7 @@ SearchSysCache(struct catcache * cache,
|
||||
*/
|
||||
if (elt)
|
||||
{
|
||||
Dlelem *old_lru_elt;
|
||||
Dlelem *old_lru_elt;
|
||||
|
||||
old_lru_elt = ((CatCTup *) DLE_VAL(elt))->ct_node;
|
||||
DLRemove(old_lru_elt);
|
||||
@ -932,18 +932,18 @@ SearchSysCache(struct catcache * cache,
|
||||
Assert(cache->cc_iscanfunc);
|
||||
switch (cache->cc_nkeys)
|
||||
{
|
||||
case 4:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2, v3, v4);
|
||||
break;
|
||||
case 3:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2, v3);
|
||||
break;
|
||||
case 2:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2);
|
||||
break;
|
||||
case 1:
|
||||
ntp = cache->cc_iscanfunc(relation, v1);
|
||||
break;
|
||||
case 4:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2, v3, v4);
|
||||
break;
|
||||
case 3:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2, v3);
|
||||
break;
|
||||
case 2:
|
||||
ntp = cache->cc_iscanfunc(relation, v1, v2);
|
||||
break;
|
||||
case 1:
|
||||
ntp = cache->cc_iscanfunc(relation, v1);
|
||||
break;
|
||||
}
|
||||
/* ----------
|
||||
* Back to Cache context. If we got a tuple copy it
|
||||
@ -959,7 +959,7 @@ SearchSysCache(struct catcache * cache,
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapScanDesc sd;
|
||||
HeapScanDesc sd;
|
||||
|
||||
/* ----------
|
||||
* As above do the lookup in the callers memory
|
||||
@ -1004,7 +1004,7 @@ SearchSysCache(struct catcache * cache,
|
||||
* to the heap tuple there and initialize the list pointers.
|
||||
* ----------------
|
||||
*/
|
||||
Dlelem *lru_elt;
|
||||
Dlelem *lru_elt;
|
||||
|
||||
/*
|
||||
* this is a little cumbersome here because we want the Dlelem's
|
||||
@ -1030,7 +1030,7 @@ SearchSysCache(struct catcache * cache,
|
||||
*/
|
||||
if (++cache->cc_ntup > cache->cc_maxtup)
|
||||
{
|
||||
CatCTup *ct;
|
||||
CatCTup *ct;
|
||||
|
||||
elt = DLGetTail(cache->cc_lrulist);
|
||||
ct = (CatCTup *) DLE_VAL(elt);
|
||||
@ -1078,8 +1078,8 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
|
||||
void (*function) (int, Index, ItemPointer))
|
||||
{
|
||||
struct catcache *ccp;
|
||||
MemoryContext oldcxt;
|
||||
Oid relationId;
|
||||
MemoryContext oldcxt;
|
||||
Oid relationId;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
|
42
src/backend/utils/cache/fcache.c
vendored
42
src/backend/utils/cache/fcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.5 1997/09/07 04:52:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.6 1997/09/08 02:31:11 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -35,7 +35,7 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
static Oid GetDynamicFuncArgType(Var * arg, ExprContext * econtext);
|
||||
static Oid GetDynamicFuncArgType(Var * arg, ExprContext * econtext);
|
||||
static FunctionCachePtr
|
||||
init_fcache(Oid foid,
|
||||
bool use_syscache,
|
||||
@ -55,12 +55,12 @@ init_fcache(Oid foid,
|
||||
#define FuncArgTypeIsDynamic(arg) \
|
||||
(IsA(arg,Var) && ((Var*)arg)->varattno == InvalidAttrNumber)
|
||||
|
||||
static Oid
|
||||
static Oid
|
||||
GetDynamicFuncArgType(Var * arg, ExprContext * econtext)
|
||||
{
|
||||
char *relname;
|
||||
int rtid;
|
||||
HeapTuple tup;
|
||||
char *relname;
|
||||
int rtid;
|
||||
HeapTuple tup;
|
||||
|
||||
Assert(IsA(arg, Var));
|
||||
|
||||
@ -77,19 +77,19 @@ GetDynamicFuncArgType(Var * arg, ExprContext * econtext)
|
||||
return tup->t_oid;
|
||||
}
|
||||
|
||||
static FunctionCachePtr
|
||||
static FunctionCachePtr
|
||||
init_fcache(Oid foid,
|
||||
bool use_syscache,
|
||||
List * argList,
|
||||
ExprContext * econtext)
|
||||
{
|
||||
HeapTuple procedureTuple;
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_proc procedureStruct;
|
||||
TypeTupleForm typeStruct;
|
||||
HeapTuple procedureTuple;
|
||||
HeapTuple typeTuple;
|
||||
Form_pg_proc procedureStruct;
|
||||
TypeTupleForm typeStruct;
|
||||
FunctionCachePtr retval;
|
||||
text *tmp;
|
||||
int nargs;
|
||||
text *tmp;
|
||||
int nargs;
|
||||
|
||||
/* ----------------
|
||||
* get the procedure tuple corresponding to the given
|
||||
@ -173,9 +173,9 @@ init_fcache(Oid foid,
|
||||
(retval->oneResult) &&
|
||||
!(retval->typbyval))
|
||||
{
|
||||
Form_pg_class relationStruct;
|
||||
HeapTuple relationTuple;
|
||||
TupleDesc td;
|
||||
Form_pg_class relationStruct;
|
||||
HeapTuple relationTuple;
|
||||
TupleDesc td;
|
||||
TupleTableSlot *slot;
|
||||
|
||||
slot = makeNode(TupleTableSlot);
|
||||
@ -209,14 +209,14 @@ init_fcache(Oid foid,
|
||||
|
||||
if (nargs > 0)
|
||||
{
|
||||
Oid *argTypes;
|
||||
Oid *argTypes;
|
||||
|
||||
retval->nullVect = (bool *) palloc((retval->nargs) * sizeof(bool));
|
||||
|
||||
if (retval->language == SQLlanguageId)
|
||||
{
|
||||
int i;
|
||||
List *oneArg;
|
||||
int i;
|
||||
List *oneArg;
|
||||
|
||||
retval->argOidVect =
|
||||
(Oid *) palloc(retval->nargs * sizeof(Oid));
|
||||
@ -293,8 +293,8 @@ init_fcache(Oid foid,
|
||||
void
|
||||
setFcache(Node * node, Oid foid, List * argList, ExprContext * econtext)
|
||||
{
|
||||
Func *fnode;
|
||||
Oper *onode;
|
||||
Func *fnode;
|
||||
Oper *onode;
|
||||
FunctionCachePtr fcache;
|
||||
|
||||
fcache = init_fcache(foid, true, argList, econtext);
|
||||
|
102
src/backend/utils/cache/inval.c
vendored
102
src/backend/utils/cache/inval.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.5 1997/09/07 04:53:01 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.6 1997/09/08 02:31:12 momjian Exp $
|
||||
*
|
||||
* Note - this code is real crufty...
|
||||
*
|
||||
@ -32,11 +32,11 @@
|
||||
#include "utils/syscache.h" /* XXX to support the hacks below */
|
||||
|
||||
static InvalidationEntry InvalidationEntryAllocate(uint16 size);
|
||||
static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ());
|
||||
static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ());
|
||||
static LocalInvalid
|
||||
LocalInvalidRegister(LocalInvalid invalid,
|
||||
InvalidationEntry entry);
|
||||
static void getmyrelids(void);
|
||||
static void getmyrelids(void);
|
||||
|
||||
|
||||
/* ----------------
|
||||
@ -45,28 +45,28 @@ static void getmyrelids(void);
|
||||
*/
|
||||
typedef struct CatalogInvalidationData
|
||||
{
|
||||
Index cacheId;
|
||||
Index hashIndex;
|
||||
Index cacheId;
|
||||
Index hashIndex;
|
||||
ItemPointerData pointerData;
|
||||
} CatalogInvalidationData;
|
||||
} CatalogInvalidationData;
|
||||
|
||||
typedef struct RelationInvalidationData
|
||||
{
|
||||
Oid relationId;
|
||||
Oid objectId;
|
||||
} RelationInvalidationData;
|
||||
Oid relationId;
|
||||
Oid objectId;
|
||||
} RelationInvalidationData;
|
||||
|
||||
typedef union AnyInvalidation
|
||||
{
|
||||
CatalogInvalidationData catalog;
|
||||
RelationInvalidationData relation;
|
||||
} AnyInvalidation;
|
||||
} AnyInvalidation;
|
||||
|
||||
typedef struct InvalidationMessageData
|
||||
{
|
||||
char kind;
|
||||
char kind;
|
||||
AnyInvalidation any;
|
||||
} InvalidationMessageData;
|
||||
} InvalidationMessageData;
|
||||
|
||||
typedef InvalidationMessageData *InvalidationMessage;
|
||||
|
||||
@ -75,12 +75,12 @@ typedef InvalidationMessageData *InvalidationMessage;
|
||||
* ----------------
|
||||
*/
|
||||
static LocalInvalid Invalid = EmptyLocalInvalid; /* XXX global */
|
||||
static bool RefreshWhenInvalidate = false;
|
||||
static bool RefreshWhenInvalidate = false;
|
||||
|
||||
Oid MyRelationRelationId = InvalidOid;
|
||||
Oid MyAttributeRelationId = InvalidOid;
|
||||
Oid MyAMRelationId = InvalidOid;
|
||||
Oid MyAMOPRelationId = InvalidOid;
|
||||
Oid MyRelationRelationId = InvalidOid;
|
||||
Oid MyAttributeRelationId = InvalidOid;
|
||||
Oid MyAMRelationId = InvalidOid;
|
||||
Oid MyAMOPRelationId = InvalidOid;
|
||||
|
||||
#define ValidateHacks() \
|
||||
if (!OidIsValid(MyRelationRelationId)) getmyrelids()
|
||||
@ -95,7 +95,7 @@ Oid MyAMOPRelationId = InvalidOid;
|
||||
* Allocates an invalidation entry.
|
||||
* --------------------------------
|
||||
*/
|
||||
static InvalidationEntry
|
||||
static InvalidationEntry
|
||||
InvalidationEntryAllocate(uint16 size)
|
||||
{
|
||||
InvalidationEntryData *entryDataP;
|
||||
@ -111,7 +111,7 @@ InvalidationEntryAllocate(uint16 size)
|
||||
* Returns a new local cache invalidation state containing a new entry.
|
||||
* --------------------------------
|
||||
*/
|
||||
static LocalInvalid
|
||||
static LocalInvalid
|
||||
LocalInvalidRegister(LocalInvalid invalid,
|
||||
InvalidationEntry entry)
|
||||
{
|
||||
@ -248,7 +248,7 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
|
||||
static void
|
||||
getmyrelids()
|
||||
{
|
||||
HeapTuple tuple;
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCacheTuple(RELNAME,
|
||||
PointerGetDatum(RelationRelationName),
|
||||
@ -391,26 +391,26 @@ InvalidationMessageRegisterSharedInvalid(InvalidationMessage message)
|
||||
|
||||
switch (message->kind)
|
||||
{
|
||||
case 'c': /* cached system catalog tuple */
|
||||
InvalidationMessageRegisterSharedInvalid_DEBUG1;
|
||||
case 'c': /* cached system catalog tuple */
|
||||
InvalidationMessageRegisterSharedInvalid_DEBUG1;
|
||||
|
||||
RegisterSharedInvalid(message->any.catalog.cacheId,
|
||||
message->any.catalog.hashIndex,
|
||||
&message->any.catalog.pointerData);
|
||||
break;
|
||||
RegisterSharedInvalid(message->any.catalog.cacheId,
|
||||
message->any.catalog.hashIndex,
|
||||
&message->any.catalog.pointerData);
|
||||
break;
|
||||
|
||||
case 'r': /* cached relation descriptor */
|
||||
InvalidationMessageRegisterSharedInvalid_DEBUG2;
|
||||
case 'r': /* cached relation descriptor */
|
||||
InvalidationMessageRegisterSharedInvalid_DEBUG2;
|
||||
|
||||
RegisterSharedInvalid(message->any.relation.relationId,
|
||||
message->any.relation.objectId,
|
||||
(ItemPointer) NULL);
|
||||
break;
|
||||
RegisterSharedInvalid(message->any.relation.relationId,
|
||||
message->any.relation.objectId,
|
||||
(ItemPointer) NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(FATAL,
|
||||
"InvalidationMessageRegisterSharedInvalid: `%c' kind",
|
||||
message->kind);
|
||||
default:
|
||||
elog(FATAL,
|
||||
"InvalidationMessageRegisterSharedInvalid: `%c' kind",
|
||||
message->kind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,23 +441,23 @@ InvalidationMessageCacheInvalidate(InvalidationMessage message)
|
||||
|
||||
switch (message->kind)
|
||||
{
|
||||
case 'c': /* cached system catalog tuple */
|
||||
InvalidationMessageCacheInvalidate_DEBUG1;
|
||||
case 'c': /* cached system catalog tuple */
|
||||
InvalidationMessageCacheInvalidate_DEBUG1;
|
||||
|
||||
CatalogCacheIdInvalidate(message->any.catalog.cacheId,
|
||||
message->any.catalog.hashIndex,
|
||||
&message->any.catalog.pointerData);
|
||||
break;
|
||||
CatalogCacheIdInvalidate(message->any.catalog.cacheId,
|
||||
message->any.catalog.hashIndex,
|
||||
&message->any.catalog.pointerData);
|
||||
break;
|
||||
|
||||
case 'r': /* cached relation descriptor */
|
||||
InvalidationMessageCacheInvalidate_DEBUG2;
|
||||
case 'r': /* cached relation descriptor */
|
||||
InvalidationMessageCacheInvalidate_DEBUG2;
|
||||
|
||||
/* XXX ignore this--is this correct ??? */
|
||||
break;
|
||||
/* XXX ignore this--is this correct ??? */
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(FATAL, "InvalidationMessageCacheInvalidate: `%c' kind",
|
||||
message->kind);
|
||||
default:
|
||||
elog(FATAL, "InvalidationMessageCacheInvalidate: `%c' kind",
|
||||
message->kind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,8 +470,8 @@ RelationInvalidateRelationCache(Relation relation,
|
||||
HeapTuple tuple,
|
||||
void (*function) ())
|
||||
{
|
||||
Oid relationId;
|
||||
Oid objectId = (Oid) 0;
|
||||
Oid relationId;
|
||||
Oid objectId = (Oid) 0;
|
||||
|
||||
/* ----------------
|
||||
* get the relation object id
|
||||
|
16
src/backend/utils/cache/lsyscache.c
vendored
16
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.4 1997/09/07 04:53:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.5 1997/09/08 02:31:14 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -67,11 +67,11 @@ op_class(Oid opno, int32 opclass, Oid amopid)
|
||||
* return the "attname" field from the attribute relation.
|
||||
*
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
get_attname(Oid relid, AttrNumber attnum)
|
||||
{
|
||||
FormData_pg_attribute att_tup;
|
||||
char *retval;
|
||||
char *retval;
|
||||
|
||||
if (SearchSysCacheStruct(ATTNUM,
|
||||
(char *) &att_tup,
|
||||
@ -137,8 +137,8 @@ get_atttype(Oid relid, AttrNumber attnum)
|
||||
bool
|
||||
get_attisset(Oid relid, char *attname)
|
||||
{
|
||||
HeapTuple htup;
|
||||
AttrNumber attno;
|
||||
HeapTuple htup;
|
||||
AttrNumber attno;
|
||||
AttributeTupleForm att_tup;
|
||||
|
||||
attno = get_attnum(relid, attname);
|
||||
@ -192,7 +192,7 @@ get_opcode(Oid opno)
|
||||
*
|
||||
* Note: return the struct so that it gets copied.
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
get_opname(Oid opno)
|
||||
{
|
||||
FormData_pg_operator optup;
|
||||
@ -284,7 +284,7 @@ get_commutator(Oid opno)
|
||||
HeapTuple
|
||||
get_operator_tuple(Oid opno)
|
||||
{
|
||||
HeapTuple optup;
|
||||
HeapTuple optup;
|
||||
|
||||
if ((optup = SearchSysCacheTuple(OPROID,
|
||||
ObjectIdGetDatum(opno),
|
||||
@ -378,7 +378,7 @@ get_relnatts(Oid relid)
|
||||
* Returns the name of a given relation.
|
||||
*
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
get_rel_name(Oid relid)
|
||||
{
|
||||
FormData_pg_class reltup;
|
||||
|
376
src/backend/utils/cache/relcache.c
vendored
376
src/backend/utils/cache/relcache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.21 1997/09/07 04:53:08 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.22 1997/09/08 02:31:16 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -91,8 +91,8 @@ static void
|
||||
RelationFlushRelation(Relation * relationPtr,
|
||||
bool onlyFlushReferenceCountZero);
|
||||
static Relation RelationNameCacheGetRelation(char *relationName);
|
||||
static void init_irels(void);
|
||||
static void write_irels(void);
|
||||
static void init_irels(void);
|
||||
static void write_irels(void);
|
||||
|
||||
/* ----------------
|
||||
* defines
|
||||
@ -105,7 +105,7 @@ static void write_irels(void);
|
||||
* externs
|
||||
* ----------------
|
||||
*/
|
||||
extern bool AMI_OVERRIDE; /* XXX style */
|
||||
extern bool AMI_OVERRIDE; /* XXX style */
|
||||
extern GlobalMemory CacheCxt; /* from utils/cache/catcache.c */
|
||||
|
||||
/* ----------------
|
||||
@ -127,8 +127,8 @@ FormData_pg_attribute Desc_pg_time[Natts_pg_time] = {Schema_pg_time};
|
||||
* thus there are two hash tables for referencing them.
|
||||
* ----------------
|
||||
*/
|
||||
HTAB *RelationNameCache;
|
||||
HTAB *RelationIdCache;
|
||||
HTAB *RelationNameCache;
|
||||
HTAB *RelationIdCache;
|
||||
|
||||
/* ----------------
|
||||
* RelationBuildDescInfo exists so code can be shared
|
||||
@ -137,27 +137,27 @@ HTAB *RelationIdCache;
|
||||
*/
|
||||
typedef struct RelationBuildDescInfo
|
||||
{
|
||||
int infotype; /* lookup by id or by name */
|
||||
int infotype; /* lookup by id or by name */
|
||||
#define INFO_RELID 1
|
||||
#define INFO_RELNAME 2
|
||||
union
|
||||
{
|
||||
Oid info_id;/* relation object id */
|
||||
char *info_name; /* relation name */
|
||||
} i;
|
||||
} RelationBuildDescInfo;
|
||||
Oid info_id; /* relation object id */
|
||||
char *info_name; /* relation name */
|
||||
} i;
|
||||
} RelationBuildDescInfo;
|
||||
|
||||
typedef struct relidcacheent
|
||||
{
|
||||
Oid reloid;
|
||||
Relation reldesc;
|
||||
} RelIdCacheEnt;
|
||||
Oid reloid;
|
||||
Relation reldesc;
|
||||
} RelIdCacheEnt;
|
||||
|
||||
typedef struct relnamecacheent
|
||||
{
|
||||
NameData relname;
|
||||
Relation reldesc;
|
||||
} RelNameCacheEnt;
|
||||
NameData relname;
|
||||
Relation reldesc;
|
||||
} RelNameCacheEnt;
|
||||
|
||||
/* -----------------
|
||||
* macros to manipulate name cache and id cache
|
||||
@ -251,7 +251,7 @@ formrdesc(char *relationName, u_int natts,
|
||||
FormData_pg_attribute att[]);
|
||||
|
||||
#if 0 /* See comments at line 1304 */
|
||||
static void RelationFlushIndexes(Relation * r, Oid accessMethodId);
|
||||
static void RelationFlushIndexes(Relation * r, Oid accessMethodId);
|
||||
|
||||
#endif
|
||||
|
||||
@ -269,19 +269,19 @@ static void
|
||||
build_tupdesc_ind(RelationBuildDescInfo buildinfo,
|
||||
Relation relation, u_int natts);
|
||||
static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo);
|
||||
static void IndexedAccessMethodInitialize(Relation relation);
|
||||
static void AttrDefaultFetch(Relation relation);
|
||||
static void RelCheckFetch(Relation relation);
|
||||
static void IndexedAccessMethodInitialize(Relation relation);
|
||||
static void AttrDefaultFetch(Relation relation);
|
||||
static void RelCheckFetch(Relation relation);
|
||||
|
||||
extern void RelationBuildTriggers(Relation relation);
|
||||
extern void FreeTriggerDesc(Relation relation);
|
||||
extern void RelationBuildTriggers(Relation relation);
|
||||
extern void FreeTriggerDesc(Relation relation);
|
||||
|
||||
/*
|
||||
* newlyCreatedRelns -
|
||||
* relations created during this transaction. We need to keep track of
|
||||
* these.
|
||||
*/
|
||||
static List *newlyCreatedRelns = NULL;
|
||||
static List *newlyCreatedRelns = NULL;
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* RelationIdGetRelation() and RelationNameGetRelation()
|
||||
@ -297,20 +297,20 @@ static List *newlyCreatedRelns = NULL;
|
||||
* the buildinfo passed to it
|
||||
* --------------------------------
|
||||
*/
|
||||
static char *
|
||||
static char *
|
||||
BuildDescInfoError(RelationBuildDescInfo buildinfo)
|
||||
{
|
||||
static char errBuf[64];
|
||||
static char errBuf[64];
|
||||
|
||||
memset(errBuf, 0, (int) sizeof(errBuf));
|
||||
switch (buildinfo.infotype)
|
||||
{
|
||||
case INFO_RELID:
|
||||
sprintf(errBuf, "(relation id %d)", buildinfo.i.info_id);
|
||||
break;
|
||||
case INFO_RELNAME:
|
||||
sprintf(errBuf, "(relation name %s)", buildinfo.i.info_name);
|
||||
break;
|
||||
case INFO_RELID:
|
||||
sprintf(errBuf, "(relation id %d)", buildinfo.i.info_id);
|
||||
break;
|
||||
case INFO_RELNAME:
|
||||
sprintf(errBuf, "(relation name %s)", buildinfo.i.info_name);
|
||||
break;
|
||||
}
|
||||
|
||||
return errBuf;
|
||||
@ -326,7 +326,7 @@ BuildDescInfoError(RelationBuildDescInfo buildinfo)
|
||||
* as specified in buildinfo.
|
||||
* --------------------------------
|
||||
*/
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
ScanPgRelation(RelationBuildDescInfo buildinfo)
|
||||
{
|
||||
|
||||
@ -342,15 +342,15 @@ ScanPgRelation(RelationBuildDescInfo buildinfo)
|
||||
return (scan_pg_rel_ind(buildinfo));
|
||||
}
|
||||
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
{
|
||||
HeapTuple pg_class_tuple;
|
||||
HeapTuple return_tuple;
|
||||
Relation pg_class_desc;
|
||||
HeapScanDesc pg_class_scan;
|
||||
ScanKeyData key;
|
||||
Buffer buf;
|
||||
HeapTuple pg_class_tuple;
|
||||
HeapTuple return_tuple;
|
||||
Relation pg_class_desc;
|
||||
HeapScanDesc pg_class_scan;
|
||||
ScanKeyData key;
|
||||
Buffer buf;
|
||||
|
||||
/* ----------------
|
||||
* form a scan key
|
||||
@ -358,23 +358,23 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
*/
|
||||
switch (buildinfo.infotype)
|
||||
{
|
||||
case INFO_RELID:
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
ObjectIdAttributeNumber,
|
||||
ObjectIdEqualRegProcedure,
|
||||
ObjectIdGetDatum(buildinfo.i.info_id));
|
||||
break;
|
||||
case INFO_RELID:
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
ObjectIdAttributeNumber,
|
||||
ObjectIdEqualRegProcedure,
|
||||
ObjectIdGetDatum(buildinfo.i.info_id));
|
||||
break;
|
||||
|
||||
case INFO_RELNAME:
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_class_relname,
|
||||
Character16EqualRegProcedure,
|
||||
NameGetDatum(buildinfo.i.info_name));
|
||||
break;
|
||||
case INFO_RELNAME:
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_class_relname,
|
||||
Character16EqualRegProcedure,
|
||||
NameGetDatum(buildinfo.i.info_name));
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARN, "ScanPgRelation: bad buildinfo");
|
||||
return NULL;
|
||||
default:
|
||||
elog(WARN, "ScanPgRelation: bad buildinfo");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@ -421,11 +421,11 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
|
||||
return return_tuple;
|
||||
}
|
||||
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
|
||||
{
|
||||
Relation pg_class_desc;
|
||||
HeapTuple return_tuple;
|
||||
Relation pg_class_desc;
|
||||
HeapTuple return_tuple;
|
||||
|
||||
pg_class_desc = heap_openr(RelationRelationName);
|
||||
if (!IsInitProcessingMode())
|
||||
@ -433,23 +433,23 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
|
||||
|
||||
switch (buildinfo.infotype)
|
||||
{
|
||||
case INFO_RELID:
|
||||
return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id);
|
||||
break;
|
||||
case INFO_RELID:
|
||||
return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id);
|
||||
break;
|
||||
|
||||
case INFO_RELNAME:
|
||||
return_tuple = ClassNameIndexScan(pg_class_desc,
|
||||
buildinfo.i.info_name);
|
||||
break;
|
||||
case INFO_RELNAME:
|
||||
return_tuple = ClassNameIndexScan(pg_class_desc,
|
||||
buildinfo.i.info_name);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARN, "ScanPgRelation: bad buildinfo");
|
||||
default:
|
||||
elog(WARN, "ScanPgRelation: bad buildinfo");
|
||||
|
||||
/*
|
||||
* XXX I hope this is right. It seems better than returning an
|
||||
* uninitialized value
|
||||
*/
|
||||
return_tuple = NULL;
|
||||
/*
|
||||
* XXX I hope this is right. It seems better than returning
|
||||
* an uninitialized value
|
||||
*/
|
||||
return_tuple = NULL;
|
||||
}
|
||||
|
||||
/* all done */
|
||||
@ -467,12 +467,12 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
|
||||
* and initialize the rd_rel field.
|
||||
* ----------------
|
||||
*/
|
||||
static Relation
|
||||
static Relation
|
||||
AllocateRelationDesc(u_int natts, Form_pg_class relp)
|
||||
{
|
||||
Relation relation;
|
||||
Size len;
|
||||
Form_pg_class relationTupleForm;
|
||||
Relation relation;
|
||||
Size len;
|
||||
Form_pg_class relationTupleForm;
|
||||
|
||||
/* ----------------
|
||||
* allocate space for the relation tuple form
|
||||
@ -535,12 +535,12 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
|
||||
Relation relation,
|
||||
u_int natts)
|
||||
{
|
||||
HeapTuple pg_attribute_tuple;
|
||||
Relation pg_attribute_desc;
|
||||
HeapScanDesc pg_attribute_scan;
|
||||
HeapTuple pg_attribute_tuple;
|
||||
Relation pg_attribute_desc;
|
||||
HeapScanDesc pg_attribute_scan;
|
||||
AttributeTupleForm attp;
|
||||
ScanKeyData key;
|
||||
int need;
|
||||
ScanKeyData key;
|
||||
int need;
|
||||
|
||||
/* ----------------
|
||||
* form a scan key
|
||||
@ -601,13 +601,13 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
|
||||
Relation relation,
|
||||
u_int natts)
|
||||
{
|
||||
Relation attrel;
|
||||
HeapTuple atttup;
|
||||
Relation attrel;
|
||||
HeapTuple atttup;
|
||||
AttributeTupleForm attp;
|
||||
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
|
||||
AttrDefault *attrdef = NULL;
|
||||
int ndef = 0;
|
||||
int i;
|
||||
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
|
||||
AttrDefault *attrdef = NULL;
|
||||
int ndef = 0;
|
||||
int i;
|
||||
|
||||
constr->has_not_null = false;
|
||||
|
||||
@ -694,15 +694,15 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
|
||||
static void
|
||||
RelationBuildRuleLock(Relation relation)
|
||||
{
|
||||
HeapTuple pg_rewrite_tuple;
|
||||
Relation pg_rewrite_desc;
|
||||
TupleDesc pg_rewrite_tupdesc;
|
||||
HeapScanDesc pg_rewrite_scan;
|
||||
ScanKeyData key;
|
||||
RuleLock *rulelock;
|
||||
int numlocks;
|
||||
RewriteRule **rules;
|
||||
int maxlocks;
|
||||
HeapTuple pg_rewrite_tuple;
|
||||
Relation pg_rewrite_desc;
|
||||
TupleDesc pg_rewrite_tupdesc;
|
||||
HeapScanDesc pg_rewrite_scan;
|
||||
ScanKeyData key;
|
||||
RuleLock *rulelock;
|
||||
int numlocks;
|
||||
RewriteRule **rules;
|
||||
int maxlocks;
|
||||
|
||||
/* ----------------
|
||||
* form an array to hold the rewrite rules (the array is extended if
|
||||
@ -739,10 +739,10 @@ RelationBuildRuleLock(Relation relation)
|
||||
while ((pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0,
|
||||
(Buffer *) NULL)) != NULL)
|
||||
{
|
||||
bool isnull;
|
||||
char *ruleaction = NULL;
|
||||
char *rule_evqual_string;
|
||||
RewriteRule *rule;
|
||||
bool isnull;
|
||||
char *ruleaction = NULL;
|
||||
char *rule_evqual_string;
|
||||
RewriteRule *rule;
|
||||
|
||||
rule = (RewriteRule *) palloc(sizeof(RewriteRule));
|
||||
|
||||
@ -828,19 +828,19 @@ RelationBuildRuleLock(Relation relation)
|
||||
* -cim 2/4/91
|
||||
* --------------------------------
|
||||
*/
|
||||
static Relation
|
||||
static Relation
|
||||
RelationBuildDesc(RelationBuildDescInfo buildinfo)
|
||||
{
|
||||
File fd;
|
||||
Relation relation;
|
||||
u_int natts;
|
||||
Oid relid;
|
||||
Oid relam;
|
||||
Form_pg_class relp;
|
||||
File fd;
|
||||
Relation relation;
|
||||
u_int natts;
|
||||
Oid relid;
|
||||
Oid relam;
|
||||
Form_pg_class relp;
|
||||
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
HeapTuple pg_class_tuple;
|
||||
HeapTuple pg_class_tuple;
|
||||
|
||||
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
|
||||
|
||||
@ -986,13 +986,13 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
|
||||
static void
|
||||
IndexedAccessMethodInitialize(Relation relation)
|
||||
{
|
||||
IndexStrategy strategy;
|
||||
RegProcedure *support;
|
||||
int natts;
|
||||
Size stratSize;
|
||||
Size supportSize;
|
||||
uint16 relamstrategies;
|
||||
uint16 relamsupport;
|
||||
IndexStrategy strategy;
|
||||
RegProcedure *support;
|
||||
int natts;
|
||||
Size stratSize;
|
||||
Size supportSize;
|
||||
uint16 relamstrategies;
|
||||
uint16 relamsupport;
|
||||
|
||||
natts = relation->rd_rel->relnatts;
|
||||
relamstrategies = relation->rd_am->amstrategies;
|
||||
@ -1033,9 +1033,9 @@ formrdesc(char *relationName,
|
||||
u_int natts,
|
||||
FormData_pg_attribute att[])
|
||||
{
|
||||
Relation relation;
|
||||
Size len;
|
||||
int i;
|
||||
Relation relation;
|
||||
Size len;
|
||||
int i;
|
||||
|
||||
/* ----------------
|
||||
* allocate new relation desc
|
||||
@ -1151,7 +1151,7 @@ formrdesc(char *relationName,
|
||||
Relation
|
||||
RelationIdCacheGetRelation(Oid relationId)
|
||||
{
|
||||
Relation rd;
|
||||
Relation rd;
|
||||
|
||||
RelationIdCacheLookup(relationId, rd);
|
||||
|
||||
@ -1175,11 +1175,11 @@ RelationIdCacheGetRelation(Oid relationId)
|
||||
* RelationNameCacheGetRelation
|
||||
* --------------------------------
|
||||
*/
|
||||
static Relation
|
||||
static Relation
|
||||
RelationNameCacheGetRelation(char *relationName)
|
||||
{
|
||||
Relation rd;
|
||||
NameData name;
|
||||
Relation rd;
|
||||
NameData name;
|
||||
|
||||
/*
|
||||
* make sure that the name key used for hash lookup is properly
|
||||
@ -1214,7 +1214,7 @@ RelationNameCacheGetRelation(char *relationName)
|
||||
Relation
|
||||
RelationIdGetRelation(Oid relationId)
|
||||
{
|
||||
Relation rd;
|
||||
Relation rd;
|
||||
RelationBuildDescInfo buildinfo;
|
||||
|
||||
/* ----------------
|
||||
@ -1255,7 +1255,7 @@ RelationIdGetRelation(Oid relationId)
|
||||
Relation
|
||||
RelationNameGetRelation(char *relationName)
|
||||
{
|
||||
Relation rd;
|
||||
Relation rd;
|
||||
RelationBuildDescInfo buildinfo;
|
||||
|
||||
/* ----------------
|
||||
@ -1332,8 +1332,8 @@ static void
|
||||
RelationFlushRelation(Relation * relationPtr,
|
||||
bool onlyFlushReferenceCountZero)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
Relation relation = *relationPtr;
|
||||
MemoryContext oldcxt;
|
||||
Relation relation = *relationPtr;
|
||||
|
||||
if (relation->rd_isnailed)
|
||||
{
|
||||
@ -1356,7 +1356,7 @@ RelationFlushRelation(Relation * relationPtr,
|
||||
#if 0
|
||||
if (relation->rd_rules)
|
||||
{
|
||||
int j;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < relation->rd_rules->numLocks; j++)
|
||||
{
|
||||
@ -1384,22 +1384,22 @@ RelationFlushRelation(Relation * relationPtr,
|
||||
void
|
||||
RelationForgetRelation(Oid rid)
|
||||
{
|
||||
Relation relation;
|
||||
Relation relation;
|
||||
|
||||
RelationIdCacheLookup(rid, relation);
|
||||
Assert(PointerIsValid(relation));
|
||||
|
||||
if (relation->rd_islocal)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
List *curr;
|
||||
List *prev = NIL;
|
||||
MemoryContext oldcxt;
|
||||
List *curr;
|
||||
List *prev = NIL;
|
||||
|
||||
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
|
||||
|
||||
foreach(curr, newlyCreatedRelns)
|
||||
{
|
||||
Relation reln = lfirst(curr);
|
||||
Relation reln = lfirst(curr);
|
||||
|
||||
Assert(reln != NULL && reln->rd_islocal);
|
||||
if (reln->rd_id == rid)
|
||||
@ -1427,7 +1427,7 @@ RelationForgetRelation(Oid rid)
|
||||
void
|
||||
RelationIdInvalidateRelationCacheByRelationId(Oid relationId)
|
||||
{
|
||||
Relation relation;
|
||||
Relation relation;
|
||||
|
||||
RelationIdCacheLookup(relationId, relation);
|
||||
|
||||
@ -1462,7 +1462,7 @@ static void
|
||||
RelationFlushIndexes(Relation * r,
|
||||
Oid accessMethodId)
|
||||
{
|
||||
Relation relation = *r;
|
||||
Relation relation = *r;
|
||||
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
@ -1536,7 +1536,7 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
|
||||
void
|
||||
RelationRegisterRelation(Relation relation)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
|
||||
|
||||
@ -1571,7 +1571,7 @@ RelationRegisterRelation(Relation relation)
|
||||
void
|
||||
RelationPurgeLocalRelation(bool xactCommitted)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
if (newlyCreatedRelns == NULL)
|
||||
return;
|
||||
@ -1580,8 +1580,8 @@ RelationPurgeLocalRelation(bool xactCommitted)
|
||||
|
||||
while (newlyCreatedRelns)
|
||||
{
|
||||
List *l = newlyCreatedRelns;
|
||||
Relation reln = lfirst(l);
|
||||
List *l = newlyCreatedRelns;
|
||||
Relation reln = lfirst(l);
|
||||
|
||||
Assert(reln != NULL && reln->rd_islocal);
|
||||
|
||||
@ -1641,8 +1641,8 @@ RelationPurgeLocalRelation(bool xactCommitted)
|
||||
void
|
||||
RelationInitialize(void)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
HASHCTL ctl;
|
||||
MemoryContext oldcxt;
|
||||
HASHCTL ctl;
|
||||
|
||||
/* ----------------
|
||||
* switch to cache memory context
|
||||
@ -1697,21 +1697,21 @@ RelationInitialize(void)
|
||||
static void
|
||||
AttrDefaultFetch(Relation relation)
|
||||
{
|
||||
AttrDefault *attrdef = relation->rd_att->constr->defval;
|
||||
int ndef = relation->rd_att->constr->num_defval;
|
||||
Relation adrel;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
AttrDefault *attrdef = relation->rd_att->constr->defval;
|
||||
int ndef = relation->rd_att->constr->num_defval;
|
||||
Relation adrel;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
Form_pg_attrdef adform;
|
||||
IndexScanDesc sd;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
struct varlena *val;
|
||||
bool isnull;
|
||||
int found;
|
||||
int i;
|
||||
bool isnull;
|
||||
int found;
|
||||
int i;
|
||||
|
||||
ScanKeyEntryInitialize(&skey,
|
||||
(bits16) 0x0,
|
||||
@ -1787,20 +1787,20 @@ AttrDefaultFetch(Relation relation)
|
||||
static void
|
||||
RelCheckFetch(Relation relation)
|
||||
{
|
||||
ConstrCheck *check = relation->rd_att->constr->check;
|
||||
int ncheck = relation->rd_att->constr->num_check;
|
||||
Relation rcrel;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
ConstrCheck *check = relation->rd_att->constr->check;
|
||||
int ncheck = relation->rd_att->constr->num_check;
|
||||
Relation rcrel;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
Name rcname;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
Name rcname;
|
||||
struct varlena *val;
|
||||
bool isnull;
|
||||
int found;
|
||||
bool isnull;
|
||||
int found;
|
||||
|
||||
ScanKeyEntryInitialize(&skey,
|
||||
(bits16) 0x0,
|
||||
@ -1902,17 +1902,17 @@ RelCheckFetch(Relation relation)
|
||||
static void
|
||||
init_irels(void)
|
||||
{
|
||||
Size len;
|
||||
int nread;
|
||||
File fd;
|
||||
Relation irel[Num_indices_bootstrap];
|
||||
Relation ird;
|
||||
Form_pg_am am;
|
||||
Form_pg_class relform;
|
||||
IndexStrategy strat;
|
||||
RegProcedure *support;
|
||||
int i;
|
||||
int relno;
|
||||
Size len;
|
||||
int nread;
|
||||
File fd;
|
||||
Relation irel[Num_indices_bootstrap];
|
||||
Relation ird;
|
||||
Form_pg_am am;
|
||||
Form_pg_class relform;
|
||||
IndexStrategy strat;
|
||||
RegProcedure *support;
|
||||
int i;
|
||||
int relno;
|
||||
|
||||
if ((fd = FileNameOpenFile(INIT_FILENAME, O_RDONLY, 0600)) < 0)
|
||||
{
|
||||
@ -2057,18 +2057,18 @@ init_irels(void)
|
||||
static void
|
||||
write_irels(void)
|
||||
{
|
||||
int len;
|
||||
int nwritten;
|
||||
File fd;
|
||||
Relation irel[Num_indices_bootstrap];
|
||||
Relation ird;
|
||||
Form_pg_am am;
|
||||
Form_pg_class relform;
|
||||
IndexStrategy strat;
|
||||
RegProcedure *support;
|
||||
ProcessingMode oldmode;
|
||||
int i;
|
||||
int relno;
|
||||
int len;
|
||||
int nwritten;
|
||||
File fd;
|
||||
Relation irel[Num_indices_bootstrap];
|
||||
Relation ird;
|
||||
Form_pg_am am;
|
||||
Form_pg_class relform;
|
||||
IndexStrategy strat;
|
||||
RegProcedure *support;
|
||||
ProcessingMode oldmode;
|
||||
int i;
|
||||
int relno;
|
||||
RelationBuildDescInfo bi;
|
||||
|
||||
fd = FileNameOpenFile(INIT_FILENAME, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
|
76
src/backend/utils/cache/syscache.c
vendored
76
src/backend/utils/cache/syscache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.5 1997/09/07 04:53:10 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.6 1997/09/08 02:31:21 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -52,12 +52,12 @@
|
||||
#include "storage/large_object.h"
|
||||
#include "catalog/pg_listener.h"
|
||||
|
||||
extern bool AMI_OVERRIDE; /* XXX style */
|
||||
extern bool AMI_OVERRIDE; /* XXX style */
|
||||
|
||||
#include "utils/syscache.h"
|
||||
#include "catalog/indexing.h"
|
||||
|
||||
typedef HeapTuple(*ScanFunc) ();
|
||||
typedef HeapTuple(*ScanFunc) ();
|
||||
|
||||
/* ----------------
|
||||
* Warning: cacheinfo[] below is changed, then be sure and
|
||||
@ -321,7 +321,7 @@ static struct cachedesc cacheinfo[] = {
|
||||
|
||||
static struct catcache *SysCache[
|
||||
lengthof(cacheinfo)];
|
||||
static int32 SysCacheSize = lengthof(cacheinfo);
|
||||
static int32 SysCacheSize = lengthof(cacheinfo);
|
||||
|
||||
|
||||
/*
|
||||
@ -344,7 +344,7 @@ zerocaches()
|
||||
void
|
||||
InitCatalogCache()
|
||||
{
|
||||
int cacheId; /* XXX type */
|
||||
int cacheId; /* XXX type */
|
||||
|
||||
if (!AMI_OVERRIDE)
|
||||
{
|
||||
@ -456,7 +456,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */
|
||||
Datum key3,
|
||||
Datum key4)
|
||||
{
|
||||
HeapTuple tp;
|
||||
HeapTuple tp;
|
||||
|
||||
if (!PointerIsValid(returnStruct))
|
||||
{
|
||||
@ -480,7 +480,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */
|
||||
*
|
||||
* [callers all assume this returns a (struct varlena *). -ay 10/94]
|
||||
*/
|
||||
void *
|
||||
void *
|
||||
SearchSysCacheGetAttribute(int cacheId,
|
||||
AttrNumber attributeNumber,
|
||||
Datum key1,
|
||||
@ -488,14 +488,14 @@ SearchSysCacheGetAttribute(int cacheId,
|
||||
Datum key3,
|
||||
Datum key4)
|
||||
{
|
||||
HeapTuple tp;
|
||||
char *cacheName;
|
||||
Relation relation;
|
||||
int32 attributeLength,
|
||||
attributeByValue;
|
||||
bool isNull;
|
||||
char *attributeValue;
|
||||
void *returnValue;
|
||||
HeapTuple tp;
|
||||
char *cacheName;
|
||||
Relation relation;
|
||||
int32 attributeLength,
|
||||
attributeByValue;
|
||||
bool isNull;
|
||||
char *attributeValue;
|
||||
void *returnValue;
|
||||
|
||||
tp = SearchSysCacheTuple(cacheId, key1, key2, key3, key4);
|
||||
cacheName = cacheinfo[cacheId].name;
|
||||
@ -556,8 +556,8 @@ SearchSysCacheGetAttribute(int cacheId,
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
int size = (attributeLength < 0)
|
||||
char *tmp;
|
||||
int size = (attributeLength < 0)
|
||||
? VARSIZE((struct varlena *) attributeValue) /* variable length */
|
||||
: attributeLength; /* fixed length */
|
||||
|
||||
@ -583,16 +583,16 @@ SearchSysCacheGetAttribute(int cacheId,
|
||||
* [identical to get_typdefault, expecting a (struct varlena *) as ret val.
|
||||
* some day, either of the functions should be removed -ay 10/94]
|
||||
*/
|
||||
void *
|
||||
void *
|
||||
TypeDefaultRetrieve(Oid typId)
|
||||
{
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
int32 typByVal,
|
||||
typLen;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
int32 typByVal,
|
||||
typLen;
|
||||
struct varlena *typDefault;
|
||||
int32 dataSize;
|
||||
void *returnValue;
|
||||
int32 dataSize;
|
||||
void *returnValue;
|
||||
|
||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(typId),
|
||||
@ -631,25 +631,25 @@ TypeDefaultRetrieve(Oid typId)
|
||||
|
||||
if (typByVal)
|
||||
{
|
||||
int8 i8;
|
||||
int16 i16;
|
||||
int32 i32;
|
||||
int8 i8;
|
||||
int16 i16;
|
||||
int32 i32;
|
||||
|
||||
if (dataSize == typLen)
|
||||
{
|
||||
switch (typLen)
|
||||
{
|
||||
case sizeof(int8):
|
||||
memmove((char *) &i8, VARDATA(typDefault), sizeof(int8));
|
||||
i32 = i8;
|
||||
break;
|
||||
case sizeof(int16):
|
||||
memmove((char *) &i16, VARDATA(typDefault), sizeof(int16));
|
||||
i32 = i16;
|
||||
break;
|
||||
case sizeof(int32):
|
||||
memmove((char *) &i32, VARDATA(typDefault), sizeof(int32));
|
||||
break;
|
||||
case sizeof(int8):
|
||||
memmove((char *) &i8, VARDATA(typDefault), sizeof(int8));
|
||||
i32 = i8;
|
||||
break;
|
||||
case sizeof(int16):
|
||||
memmove((char *) &i16, VARDATA(typDefault), sizeof(int16));
|
||||
i32 = i16;
|
||||
break;
|
||||
case sizeof(int32):
|
||||
memmove((char *) &i32, VARDATA(typDefault), sizeof(int32));
|
||||
break;
|
||||
}
|
||||
returnValue = (void *) i32;
|
||||
}
|
||||
|
Reference in New Issue
Block a user