diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/common/scankey.c | 8 | ||||
-rw-r--r-- | src/backend/access/index/indexam.c | 40 | ||||
-rw-r--r-- | src/backend/executor/nodeMergejoin.c | 12 | ||||
-rw-r--r-- | src/backend/optimizer/path/xfunc.c | 11 | ||||
-rw-r--r-- | src/backend/storage/buffer/freelist.c | 18 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 9 | ||||
-rw-r--r-- | src/backend/tioga/Arr_TgRecipe.h | 18 | ||||
-rw-r--r-- | src/backend/tioga/Varray.h | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/date.c | 9 | ||||
-rw-r--r-- | src/backend/utils/adt/dt.c | 10 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 36 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 150 | ||||
-rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 76 | ||||
-rw-r--r-- | src/backend/utils/sort/psort.c | 28 |
14 files changed, 243 insertions, 188 deletions
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c index 130a80ae6d3..680d8aeec52 100644 --- a/src/backend/access/common/scankey.c +++ b/src/backend/access/common/scankey.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.11 1998/01/15 19:41:46 pgsql Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.12 1998/06/15 18:39:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,10 @@ * True iff the scan key entry is legal. */ #define ScanKeyEntryIsLegal(entry) \ - ((bool) (AssertMacro(PointerIsValid(entry)) && \ - AttributeNumberIsValid(entry->sk_attno))) +( \ + AssertMacro(PointerIsValid(entry)), \ + AttributeNumberIsValid((entry)->sk_attno) \ +) /* * ScanKeyEntrySetIllegal -- diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 17fb43b4362..e6af2ff9e6a 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.21 1998/02/26 12:07:10 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.22 1998/06/15 18:39:23 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relationId @@ -92,25 +92,35 @@ * ---------------------------------------------------------------- */ #define RELATION_CHECKS \ -Assert(RelationIsValid(relation)); \ - Assert(PointerIsValid(relation->rd_am)) +( \ + AssertMacro(RelationIsValid(relation)), \ + AssertMacro(PointerIsValid(relation->rd_am)) \ +) #define SCAN_CHECKS \ - Assert(IndexScanIsValid(scan)); \ - Assert(RelationIsValid(scan->relation)); \ - Assert(PointerIsValid(scan->relation->rd_am)) +( \ + AssertMacro(IndexScanIsValid(scan)), \ + AssertMacro(RelationIsValid(scan->relation)), \ + AssertMacro(PointerIsValid(scan->relation->rd_am)) \ +) #define GET_REL_PROCEDURE(x,y) \ - procedure = relation->rd_am->y; \ - if (! RegProcedureIsValid(procedure)) \ - elog(ERROR, "index_%s: invalid %s regproc", \ - CppAsString(x), CppAsString(y)) - +( \ + procedure = relation->rd_am->y, \ + (!RegProcedureIsValid(procedure)) ? \ + elog(ERROR, "index_%s: invalid %s regproc", \ + CppAsString(x), CppAsString(y)) \ + : (void)NULL \ +) + #define GET_SCAN_PROCEDURE(x,y) \ - procedure = scan->relation->rd_am->y; \ - if (! RegProcedureIsValid(procedure)) \ - elog(ERROR, "index_%s: invalid %s regproc", \ - CppAsString(x), CppAsString(y)) +( \ + procedure = scan->relation->rd_am->y, \ + (!RegProcedureIsValid(procedure)) ? \ + elog(ERROR, "index_%s: invalid %s regproc", \ + CppAsString(x), CppAsString(y)) \ + : (void)NULL \ +) /* ---------------------------------------------------------------- diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 211160b9e4a..0525f93296d 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.14 1998/02/27 16:11:28 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.15 1998/06/15 18:39:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,12 +88,12 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext); #define MarkInnerTuple(innerTupleSlot, mergestate) \ -{ \ - ExecStoreTuple(heap_copytuple(innerTupleSlot->val), \ - mergestate->mj_MarkedTupleSlot, \ +( \ + ExecStoreTuple(heap_copytuple((innerTupleSlot)->val), \ + (mergestate)->mj_MarkedTupleSlot, \ InvalidBuffer, \ - true); \ -} + true) \ +) /* ---------------------------------------------------------------- * MJFormOSortopI diff --git a/src/backend/optimizer/path/xfunc.c b/src/backend/optimizer/path/xfunc.c index 3b77217481a..935a2422f52 100644 --- a/src/backend/optimizer/path/xfunc.c +++ b/src/backend/optimizer/path/xfunc.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.13 1998/02/26 04:32:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.14 1998/06/15 18:39:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1424,9 +1424,12 @@ xfunc_LispRemove(LispValue foo, List bar) } #define Node_Copy(a, b, c, d) \ - if (NodeCopy((Node)((a)->d), (Node*)&((b)->d), c) != true) { \ - return false; \ - } +do { \ + if (NodeCopy((Node)((a)->d), (Node*)&((b)->d), c) != true) \ + { \ + return false; \ + } \ +} while(0) /* ** xfunc_copyrel -- diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index dcfebe60142..e24d36cb8d4 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.9 1998/01/07 21:04:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.10 1998/06/15 18:39:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,14 +40,18 @@ static BufferDesc *SharedFreeList; extern SPINLOCK BufMgrLock; #define IsInQueue(bf) \ - Assert((bf->freeNext != INVALID_DESCRIPTOR));\ - Assert((bf->freePrev != INVALID_DESCRIPTOR));\ - Assert((bf->flags & BM_FREE)) +( \ + AssertMacro((bf->freeNext != INVALID_DESCRIPTOR)), \ + AssertMacro((bf->freePrev != INVALID_DESCRIPTOR)), \ + AssertMacro((bf->flags & BM_FREE)) \ +) #define NotInQueue(bf) \ - Assert((bf->freeNext == INVALID_DESCRIPTOR));\ - Assert((bf->freePrev == INVALID_DESCRIPTOR));\ - Assert(! (bf->flags & BM_FREE)) +( \ + AssertMacro((bf->freeNext == INVALID_DESCRIPTOR)), \ + AssertMacro((bf->freePrev == INVALID_DESCRIPTOR)), \ + AssertMacro(! (bf->flags & BM_FREE)) \ +) /* diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 20eb12d7f51..83ec8c9fd1f 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.39 1998/06/04 17:26:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.40 1998/06/15 18:39:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,13 +67,18 @@ extern const char **ps_status; /* from postgres.c */ * processing within an aborted transaction block. * ---------------- */ + /* we have to use IF because of the 'break' */ #define CHECK_IF_ABORTED() \ - if (IsAbortedTransactionBlockState()) { \ +if (1) \ +{ \ + if (IsAbortedTransactionBlockState()) \ + { \ elog(NOTICE, "(transaction aborted): %s", \ "queries ignored until END"); \ commandTag = "*ABORT STATE*"; \ break; \ } \ +} else /* ---------------- * general utility function invoker diff --git a/src/backend/tioga/Arr_TgRecipe.h b/src/backend/tioga/Arr_TgRecipe.h index 9cfec9585e9..ddfcf8ce382 100644 --- a/src/backend/tioga/Arr_TgRecipe.h +++ b/src/backend/tioga/Arr_TgRecipe.h @@ -43,8 +43,10 @@ typedef struct Arr_TgString (Arr_TgString *) NewVarray(ARR_TgString_INITIAL_SIZE, sizeof(TgString)) #define enlargeArr_TgString(A, I) \ - (A)->size += (I); \ - (A)->val = (TgString *) realloc((A)->val, (A)->valSize * (A)->size) +( \ + (A)->size += (I), \ + (A)->val = (TgString *) realloc((A)->val, (A)->valSize * (A)->size) \ +) #define addArr_TgString(A, V) \ AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgString) @@ -79,8 +81,10 @@ typedef struct Arr_TgElementPtr (Arr_TgElementPtr *) NewVarray(ARR_TgElementPtr_INITIAL_SIZE, sizeof(TgElementPtr)) #define enlargeArr_TgElementPtr(A, I) \ - (A)->size += (I); \ - (A)->val = (TgElementPtr *) realloc((A)->val, (A)->valSize * (A)->size) +( \ + (A)->size += (I), \ + (A)->val = (TgElementPtr *) realloc((A)->val, (A)->valSize * (A)->size) \ +) #define addArr_TgElementPtr(A, V) \ AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgElementPtr) @@ -115,8 +119,10 @@ typedef struct Arr_TgNodePtr (Arr_TgNodePtr *) NewVarray(ARR_TgNodePtr_INITIAL_SIZE, sizeof(TgNodePtr)) #define enlargeArr_TgNodePtr(A, I) \ - (A)->size += (I); \ - (A)->val = (TgNodePtr *) realloc((A)->val, (A)->valSize * (A)->size) +( \ + (A)->size += (I), \ + (A)->val = (TgNodePtr *) realloc((A)->val, (A)->valSize * (A)->size) \ +) #define addArr_TgNodePtr(A, V) \ AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgNodePtr) diff --git a/src/backend/tioga/Varray.h b/src/backend/tioga/Varray.h index 496b04520ab..3b229ce462b 100644 --- a/src/backend/tioga/Varray.h +++ b/src/backend/tioga/Varray.h @@ -23,9 +23,11 @@ typedef void (*CopyingFunct) (void *from, void *to); #define VARRAY_INITIAL_SIZE 32 #define ENLARGE_VARRAY(ARRAY, INC) \ - (ARRAY)->maxObj += (INC); \ +( \ + (ARRAY)->maxObj += (INC), \ (ARRAY)->val = (void *) realloc((ARRAY)->val, \ - (ARRAY)->size * (ARRAY)->maxObj) + (ARRAY)->size * (ARRAY)->maxObj) \ +) #define VARRAY_NTH(VAL, SIZE, N) (((char *) (VAL)) + (SIZE) * (N)) diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 6b7c24c5488..0edd618656b 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.24 1998/02/26 04:36:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.25 1998/06/15 18:39:34 momjian Exp $ * * NOTES * This code is actually (almost) unused. @@ -187,8 +187,11 @@ reltimeout(int32 time) } /* reltimeout() */ -#define TMODULO(t,q,u) {q = (t / u); \ - if (q != 0) t -= (q * u);} +#define TMODULO(t,q,u) \ +do { \ + q = (t / u); \ + if (q != 0) t -= (q * u); \ +} while(0) static void reltime2tm(int32 time, struct tm * tm) diff --git a/src/backend/utils/adt/dt.c b/src/backend/utils/adt/dt.c index ffbb71167de..f7f18b559d2 100644 --- a/src/backend/utils/adt/dt.c +++ b/src/backend/utils/adt/dt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.53 1998/05/09 22:38:18 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.54 1998/06/15 18:39:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,8 +66,12 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", /* TMODULO() * Macro to replace modf(), which is broken on some platforms. */ -#define TMODULO(t,q,u) {q = ((t < 0)? ceil(t / u): floor(t / u)); \ - if (q != 0) t -= rint(q * u);} +#define TMODULO(t,q,u) \ +do { \ + q = ((t < 0)? ceil(t / u): floor(t / u)); \ + if (q != 0) \ + t -= rint(q * u); \ +} while(0) static void GetEpochTime(struct tm * tm); diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index bb0adff8678..47ce6a8b6ea 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.27 1998/04/26 04:08:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.28 1998/06/15 18:39:40 momjian Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -96,13 +96,17 @@ static long eqproc[] = { */ #ifdef CACHEDEBUG #define CatalogCacheInitializeCache_DEBUG1 \ +do { \ elog(DEBUG, "CatalogCacheInitializeCache: cache @%08lx", cache); \ if (relation) \ elog(DEBUG, "CatalogCacheInitializeCache: called w/relation(inval)"); \ else \ elog(DEBUG, "CatalogCacheInitializeCache: called w/relname %s", \ - cache->cc_relname) + cache->cc_relname) \ +} while(0) + #define CatalogCacheInitializeCache_DEBUG2 \ +do { \ if (cache->cc_key[i] > 0) { \ elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d, %d", \ i+1, cache->cc_nkeys, cache->cc_key[i], \ @@ -110,7 +114,9 @@ static long eqproc[] = { } else { \ elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d", \ i+1, cache->cc_nkeys, cache->cc_key[i]); \ - } + } \ +} while(0) + #else #define CatalogCacheInitializeCache_DEBUG1 #define CatalogCacheInitializeCache_DEBUG2 @@ -654,16 +660,20 @@ SystemCacheRelationFlushed(Oid relId) */ #ifdef CACHEDEBUG #define InitSysCache_DEBUG1 \ -elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \ - cp->relationId, cp->id, cp->cc_nkeys, cp->cc_size); \ - for (i = 0; i < nkeys; i += 1) { \ - elog(DEBUG, "InitSysCache: key=%d len=%d skey=[%d %d %d %d]\n", \ - cp->cc_key[i], cp->cc_klen[i], \ - cp->cc_skey[i].sk_flags, \ - cp->cc_skey[i].sk_attno, \ - cp->cc_skey[i].sk_procedure, \ - cp->cc_skey[i].sk_argument); \ - } +do { \ + elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \ + cp->relationId, cp->id, cp->cc_nkeys, cp->cc_size); \ + for (i = 0; i < nkeys; i += 1) \ + { \ + elog(DEBUG, "InitSysCache: key=%d len=%d skey=[%d %d %d %d]\n", \ + cp->cc_key[i], cp->cc_klen[i], \ + cp->cc_skey[i].sk_flags, \ + cp->cc_skey[i].sk_attno, \ + cp->cc_skey[i].sk_procedure, \ + cp->cc_skey[i].sk_argument); \ + } \ +} while(0) + #else #define InitSysCache_DEBUG1 #endif diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 9776bcd9bff..3fe7de4c321 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.38 1998/04/27 04:07:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.39 1998/06/15 18:39:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -157,86 +157,80 @@ typedef struct relnamecacheent * ----------------- */ #define RelationCacheInsert(RELATION) \ - { RelIdCacheEnt *idhentry; RelNameCacheEnt *namehentry; \ - char *relname; Oid reloid; bool found; \ - relname = (RELATION->rd_rel->relname).data; \ - namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ - relname, \ - HASH_ENTER, \ - &found); \ - if (namehentry == NULL) { \ - elog(FATAL, "can't insert into relation descriptor cache"); \ - } \ - if (found && !IsBootstrapProcessingMode()) { \ - /* used to give notice -- now just keep quiet */ ; \ - } \ - namehentry->reldesc = RELATION; \ - reloid = RELATION->rd_id; \ - idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ - (char *)&reloid, \ +do { \ + RelIdCacheEnt *idhentry; RelNameCacheEnt *namehentry; \ + char *relname; Oid reloid; bool found; \ + relname = (RELATION->rd_rel->relname).data; \ + namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ + relname, \ HASH_ENTER, \ &found); \ - if (idhentry == NULL) { \ - elog(FATAL, "can't insert into relation descriptor cache"); \ - } \ - if (found && !IsBootstrapProcessingMode()) { \ - /* used to give notice -- now just keep quiet */ ; \ - } \ - idhentry->reldesc = RELATION; \ - } + if (namehentry == NULL) \ + elog(FATAL, "can't insert into relation descriptor cache"); \ + if (found && !IsBootstrapProcessingMode()) \ + /* used to give notice -- now just keep quiet */ ; \ + namehentry->reldesc = RELATION; \ + reloid = RELATION->rd_id; \ + idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ + (char *)&reloid, \ + HASH_ENTER, \ + &found); \ + if (idhentry == NULL) \ + elog(FATAL, "can't insert into relation descriptor cache"); \ + if (found && !IsBootstrapProcessingMode()) \ + /* used to give notice -- now just keep quiet */ ; \ + idhentry->reldesc = RELATION; \ +} while(0) + #define RelationNameCacheLookup(NAME, RELATION) \ - { RelNameCacheEnt *hentry; bool found; \ - hentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ - (char *)NAME,HASH_FIND,&found); \ - if (hentry == NULL) { \ - elog(FATAL, "error in CACHE"); \ - } \ - if (found) { \ - RELATION = hentry->reldesc; \ - } \ - else { \ - RELATION = NULL; \ - } \ - } -#define RelationIdCacheLookup(ID, RELATION) \ - { RelIdCacheEnt *hentry; bool found; \ - hentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ - (char *)&(ID),HASH_FIND, &found); \ - if (hentry == NULL) { \ - elog(FATAL, "error in CACHE"); \ - } \ - if (found) { \ - RELATION = hentry->reldesc; \ - } \ - else { \ - RELATION = NULL; \ - } \ - } -#define RelationCacheDelete(RELATION) \ - { RelNameCacheEnt *namehentry; RelIdCacheEnt *idhentry; \ - char *relname; Oid reloid; bool found; \ - relname = (RELATION->rd_rel->relname).data; \ - namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ - relname, \ - HASH_REMOVE, \ - &found); \ - if (namehentry == NULL) { \ - elog(FATAL, "can't delete from relation descriptor cache"); \ - } \ - if (!found) { \ - elog(NOTICE, "trying to delete a reldesc that does not exist."); \ - } \ - reloid = RELATION->rd_id; \ - idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ - (char *)&reloid, \ - HASH_REMOVE, &found); \ - if (idhentry == NULL) { \ - elog(FATAL, "can't delete from relation descriptor cache"); \ - } \ - if (!found) { \ - elog(NOTICE, "trying to delete a reldesc that does not exist."); \ - } \ - } +do { \ + RelNameCacheEnt *hentry; bool found; \ + hentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ + (char *)NAME,HASH_FIND,&found); \ + if (hentry == NULL) \ + elog(FATAL, "error in CACHE"); \ + if (found) \ + RELATION = hentry->reldesc; \ + else \ + RELATION = NULL; \ +} while(0) + +#define RelationIdCacheLookup(ID, RELATION) \ +do { \ + RelIdCacheEnt *hentry; \ + bool found; \ + hentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ + (char *)&(ID),HASH_FIND, &found); \ + if (hentry == NULL) \ + elog(FATAL, "error in CACHE"); \ + if (found) \ + RELATION = hentry->reldesc; \ + else \ + RELATION = NULL; \ +} while(0) + +#define RelationCacheDelete(RELATION) \ +do { \ + RelNameCacheEnt *namehentry; RelIdCacheEnt *idhentry; \ + char *relname; Oid reloid; bool found; \ + relname = (RELATION->rd_rel->relname).data; \ + namehentry = (RelNameCacheEnt*)hash_search(RelationNameCache, \ + relname, \ + HASH_REMOVE, \ + &found); \ + if (namehentry == NULL) \ + elog(FATAL, "can't delete from relation descriptor cache"); \ + if (!found) \ + elog(NOTICE, "trying to delete a reldesc that does not exist."); \ + reloid = RELATION->rd_id; \ + idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \ + (char *)&reloid, \ + HASH_REMOVE, &found); \ + if (idhentry == NULL) \ + elog(FATAL, "can't delete from relation descriptor cache"); \ + if (!found) \ + elog(NOTICE, "trying to delete a reldesc that does not exist."); \ +} while(0) /* non-export function prototypes */ static void diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index f56bc4cf0ae..e12b6f44ac9 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.10 1998/02/26 04:38:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.11 1998/06/15 18:39:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,41 +125,49 @@ typedef struct portalhashent static HTAB *PortalHashTable = NULL; #define PortalHashTableLookup(NAME, PORTAL) \ - { PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ - MemSet(key, 0, MAX_PORTALNAME_LEN); \ - sprintf(key, "%s", NAME); \ - hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ - key, HASH_FIND, &found); \ - if (hentry == NULL) \ - elog(FATAL, "error in PortalHashTable"); \ - if (found) \ - PORTAL = hentry->portal; \ - else \ - PORTAL = NULL; \ - } +do { \ + PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ + \ + MemSet(key, 0, MAX_PORTALNAME_LEN); \ + sprintf(key, "%s", NAME); \ + hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ + key, HASH_FIND, &found); \ + if (hentry == NULL) \ + elog(FATAL, "error in PortalHashTable"); \ + if (found) \ + PORTAL = hentry->portal; \ + else \ + PORTAL = NULL; \ +} while(0) + #define PortalHashTableInsert(PORTAL) \ - { PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ - MemSet(key, 0, MAX_PORTALNAME_LEN); \ - sprintf(key, "%s", PORTAL->name); \ - hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ - key, HASH_ENTER, &found); \ - if (hentry == NULL) \ - elog(FATAL, "error in PortalHashTable"); \ - if (found) \ - elog(NOTICE, "trying to insert a portal name that exists."); \ - hentry->portal = PORTAL; \ - } +do { \ + PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ + \ + MemSet(key, 0, MAX_PORTALNAME_LEN); \ + sprintf(key, "%s", PORTAL->name); \ + hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ + key, HASH_ENTER, &found); \ + if (hentry == NULL) \ + elog(FATAL, "error in PortalHashTable"); \ + if (found) \ + elog(NOTICE, "trying to insert a portal name that exists."); \ + hentry->portal = PORTAL; \ +} while(0) + #define PortalHashTableDelete(PORTAL) \ - { PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ - MemSet(key, 0, MAX_PORTALNAME_LEN); \ - sprintf(key, "%s", PORTAL->name); \ - hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ - key, HASH_REMOVE, &found); \ - if (hentry == NULL) \ - elog(FATAL, "error in PortalHashTable"); \ - if (!found) \ - elog(NOTICE, "trying to delete portal name that does not exist."); \ - } +{ \ + PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ + \ + MemSet(key, 0, MAX_PORTALNAME_LEN); \ + sprintf(key, "%s", PORTAL->name); \ + hentry = (PortalHashEnt*)hash_search(PortalHashTable, \ + key, HASH_REMOVE, &found); \ + if (hentry == NULL) \ + elog(FATAL, "error in PortalHashTable"); \ + if (!found) \ + elog(NOTICE, "trying to delete portal name that does not exist."); \ +} while(0) static GlobalMemory PortalMemory = NULL; static char PortalMemoryName[] = "Portal"; diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index fa439f520ed..926c464fd26 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.39 1998/02/26 04:38:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.40 1998/06/15 18:39:45 momjian Exp $ * * NOTES * Sorts the first relation into the second relation. @@ -222,20 +222,24 @@ inittapes(Sort *node) */ -#define PUTTUP(NODE, TUP, FP) do {\ - ((Psortstate *)NODE->psortstate)->BytesWritten += (TUP)->t_len; \ - fwrite((char *)TUP, (TUP)->t_len, 1, FP); \ - fwrite((char *)&((TUP)->t_len), sizeof (tlendummy), 1, FP); \ - } while (0) +#define PUTTUP(NODE, TUP, FP) \ +( \ + ((Psortstate *)NODE->psortstate)->BytesWritten += (TUP)->t_len, \ + fwrite((char *)TUP, (TUP)->t_len, 1, FP), \ + fwrite((char *)&((TUP)->t_len), sizeof (tlendummy), 1, FP) \ +) + #define ENDRUN(FP) fwrite((char *)&tlenzero, sizeof (tlenzero), 1, FP) #define GETLEN(LEN, FP) fread((char *)&(LEN), sizeof (tlenzero), 1, FP) #define ALLOCTUP(LEN) ((HeapTuple)palloc((unsigned)LEN)) -#define GETTUP(NODE, TUP, LEN, FP) do {\ - IncrProcessed(); \ - ((Psortstate *)NODE->psortstate)->BytesRead += (LEN) - sizeof (tlenzero); \ - fread((char *)(TUP) + sizeof (tlenzero), (LEN) - sizeof (tlenzero), 1, FP); \ - fread((char *)&tlendummy, sizeof (tlendummy), 1, FP); \ - } while (0) +#define GETTUP(NODE, TUP, LEN, FP) \ +( \ + IncrProcessed(), \ + ((Psortstate *)NODE->psortstate)->BytesRead += (LEN) - sizeof (tlenzero), \ + fread((char *)(TUP) + sizeof (tlenzero), (LEN) - sizeof (tlenzero), 1, FP), \ + fread((char *)&tlendummy, sizeof (tlendummy), 1, FP) \ +) + #define SETTUPLEN(TUP, LEN) (TUP)->t_len = LEN /* |