hi, I'm trying to copy the contents of a bucket of a hash table to a BufFile. There is a memory context for each bucket. That is, there is an array (#nbuckets) memory contexts.
thus the tree of mem cxts are
    ...
  hashCxt
    |
  batchCxt
 |          |
 |          |
BucketCxt... BucketCxt ... (#nbuckets) The server terminated abnormally here "->>> (1)" at the code below and I can't understand why! Please if anyone has any idea what's wrong, i'd appreciate any suggetion. Thanks is advance!! --martha

void ExecScanDPHashBucketCopyToFile(HashJoinTable hashTable,int noOfbucket)
{
HashJoinTuple hashTuple;
TupleTableSlot *slot;

// create temp files only if they already don't  exist.
if(hashTable->outerBucketFile[noOfbucket] == NULL)
hashTable->BucketFile[noOfbucket] = BufFileCreateTemp(false);


hashTuple = hashTable->buckets[noOfbucket]; // first tuple in bucket
        while(hashTuple != NULL)
        {
                HeapTuple heapTuple = &hashTuple->htup;
                
             ExecHashJoinSaveTuple(heapTuple,
HashTable->BucketFile[noOfbucket]);
                ->>> (1)
              // print the tuple we copy
              slot = ExecStoreTuple(heapTuple,slot,InvalidBuffer,false);
              if(!TupIsNull(slot))
               print_slot(slot);
                
                hashTuple = hashTuple->next;
        }
      // the bucket has copied. Rewind file to read it later.
      if(BufFileSeek(hashtable->BucketFile[noOfbucket], 0, 0L, SEK_SET))     
          ereport(ERROR,(errcode_for_file_access(),
errmsq("could not rewind hash join emp file:%m"))); if(hashTable->bucketCxt[noOfbucket] != NULL) //if there is a context allocated for this bucket.
        MemoryContextReset(*(hashTable->bucketCxt[noOfbucket]));
        hashTable->flushedBucket[noOfbucket] = true; // consider it flushed 
anyway   
}


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to