Commit 9f82f9e4 authored by Tom Lane's avatar Tom Lane

Fix some nasty coredump bugs in hashjoin. This code was just

about certain to fail anytime it decided the relation to be hashed was
too big to fit in memory --- the code for 'batching' a series of hashjoins
had multiple errors.  I've fixed the easier problems.  A remaining big
problem is that you can get 'hashtable out of memory' if the code's
guesstimate about how much overflow space it will need turns out wrong.
That will require much more extensive revisions to fix, so I'm committing
these fixes now before I start on that problem.
parent 5d5cf912
This diff is collapsed.
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.17 1999/02/13 23:15:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.18 1999/05/06 00:30:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -650,8 +650,8 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
heapTuple = (HeapTuple) (*position);
heapTuple->t_data = (HeapTupleHeader)
((char *) heapTuple + HEAPTUPLESIZE);
(*position) = (char *) LONGALIGN(*position +
heapTuple->t_len + HEAPTUPLESIZE);
(*position) = (char *) MAXALIGN(*position +
heapTuple->t_len + HEAPTUPLESIZE);
return ExecStoreTuple(heapTuple, tupleSlot, InvalidBuffer, false);
}
......@@ -843,7 +843,7 @@ ExecHashJoinSaveTuple(HeapTuple heapTuple,
}
memmove(position, heapTuple, HEAPTUPLESIZE);
memmove(position + HEAPTUPLESIZE, heapTuple->t_data, heapTuple->t_len);
position = (char *) LONGALIGN(position + heapTuple->t_len + HEAPTUPLESIZE);
position = (char *) MAXALIGN(position + heapTuple->t_len + HEAPTUPLESIZE);
*pageend = position - buffer;
return position;
......
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: hashjoin.h,v 1.8 1999/02/13 23:21:24 momjian Exp $
* $Id: hashjoin.h,v 1.9 1999/05/06 00:30:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -17,18 +17,23 @@
/* -----------------
* have to use relative address as pointers in the hashtable
* because the hashtable may reallocate in difference processes
* because the hashtable may reallocate in different processes
*
* XXX: this relative-address stuff is useless on all supported platforms
* and is a ever-dangerous source of bugs. Really ought to rip it out.
* -----------------
*/
typedef int RelativeAddr;
/* ------------------
* the relative addresses are always relative to the head of the
* hashtable, the following macro converts them to absolute address.
* The relative addresses are always relative to the head of the
* hashtable, the following macros convert them to/from absolute address.
* NULL is represented as -1 (CAUTION: RELADDR() doesn't handle that!).
* CAUTION: ABSADDR evaluates its arg twice!!
* ------------------
*/
#define ABSADDR(X) ((X) < 0 ? NULL: (char*)hashtable + X)
#define RELADDR(X) (RelativeAddr)((char*)(X) - (char*)hashtable)
#define ABSADDR(X) ((X) < 0 ? (char*) NULL : (char*)hashtable + (X))
#define RELADDR(X) ((RelativeAddr)((char*)(X) - (char*)hashtable))
typedef char **charPP;
typedef int *intP;
......@@ -79,6 +84,4 @@ typedef struct HashBucketData
typedef HashBucketData *HashBucket;
#define HASH_PERMISSION 0700
#endif /* HASHJOIN_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment