[HACKERS] copying a bucket to a BufFile

2005-06-07 Thread mchron
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


[HACKERS] SortMem...

2005-04-12 Thread mchron
Hi
in the function ExecChooseHashTableSize() 
(~/src/backend/executor/nodeHash.c)
are determined the bytes of the hash table. The correspondent code is: 

/*
* Target in-memory hashtablesize in SortMem kilobytes
*/
 hash_table_bytes = SortMem *1024L 

(~/src/include/miscadmin.h)
extern DLLIMPORT int SortMem; 

What SortMem represents? Where is evaluated and what is its value? 

I want to create 2 hash tables. One for the inner and one for the outer rel. 
What should be the hash_table_bytes in that case? 

Thanks in advance!
-martha
---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


[HACKERS] ERROR: unrecognized node type in PostgresMain( )

2005-03-08 Thread mchron
Perhaps you should rebuild the backend with -g (see --enable-debug) so
that gdb can actually be somewhat helpful.  It's usually a good idea to
have --enable-cassert turned on when hacking C code, too. 

When I rebuilded the backend with --enable-debug and --enable-cassert
the database stops and restarts, before it reaches the breakpoint at 
create_plan() in createplan.c. So I can't figure out what is happening. 
(errors came out at function Assert()) 

(My bet is that control got as far as executor startup, which you
already said you hadn't fixed to understand this new node type,
so the error is exactly what I'd expect.) 

As far as I can see, the Executor starts with the invocation of the function
ExecutorStart() which calls CreateExecutorState() and then ExecInitNode()
Is this right? At the ExecInitNode() I checked the messages unrecognized 
node type and I saw that the ERROR happens before this part of code.
Can you please suggest were to look?Any idea? It's looks like that I miss 
something :).
thanks !! 

-martha mc 

---
[EMAIL PROTECTED] writes: 

The problem is that while, Im running the postgres with gdb and I 

set a 

breakpoint at the function
create_plan() of createplan.c, after some step commands,the gdb says 

that it 

cant recongnize
the node 121 in the PostgresMain() function. 

That's not what gdb said at all; all you know is that the error
happened
someplace where you didn't have control.  (My bet is that control got
as
far as executor startup, which you already said you hadn't fixed to
understand this new node type, so the error is exactly what I'd
expect.) 

Perhaps you should rebuild the backend with -g (see --enable-debug) so
that gdb can actually be somewhat helpful.  It's usually a good idea to
have --enable-cassert turned on when hacking C code, too. 

FWIW, I don't personally ever do debugging in a standalone backend,
unless the problem is one that keeps a normal backend from starting.
It's much more pleasant to use a regular psql session to issue SQL
commands, and attach to the connected backend with gdb in another
terminal window. 

  regards, tom lane 


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


[HACKERS] ERROR: unrecognized node type in PostgresMain( )

2005-03-06 Thread mchron
Hi
I'm implementing a new join that needs 2 hash tables, one for each relation. 
I declared a
new type of node, DPHashJoin (with id T_DPHashJoin 121 at nodes.h) , which 
is by now the same as HashJoin
plan node.I created a new plan with two Hash nodes, something that looks 
like a symmetric hash join plan tree,
(I havent create the corresponding plan state tree at the executor yet). 

The problem is that while, Im running the postgres with gdb and I set a 
breakpoint at the function
create_plan() of createplan.c, after some step commands,the gdb says that it 
cant recongnize
the node 121 in the PostgresMain() function. I looked into that function but 
I cant see any
message like this :unrecognized node type:.So I cant see where the proplem 
could be.(I saw as
well that the error didnt come from the execProcnode.c at the executor)

Do anyone has any idea what the problem could be? (That node is recognizable 
at the file I added code
(createplan.c) at the optimizer.) 

Please help. I dont know what to do. I send you the messages of the gdb. 
Please take a look. 

[EMAIL PROTECTED] martha]$ gdb /usr/local/pgsql/bin/postgres
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as i386-redhat-linux-gnu...
(gdb) break create_plan
Breakpoint 1 at 0x811c7f1
(gdb) run -D /usr/local/pgsql/test test
Starting program: /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/test 
test

POSTGRES backend interactive interface
$Revision: 1.375.2.1 $ $Date: 2003/11/24 14:50:02 $
backend select * from work,people where work.peoplesurname=people.surname 

CHEAPEST PATH: #506# #500# #121# #0.30..0.50..# 

Breakpoint 1, 0x0811c7f1 in create_plan ()
(gdb) step
Single stepping until exit from function create_plan,
which has no line number information.
martha: it is T_HashJoin or T_MergeJoin or T_NestLoop. Invoked function 
create_join_plan( ) 

Breakpoint 1, 0x0811c7f1 in create_plan ()
(gdb) step
Single stepping until exit from function create_plan,
which has no line number information.
martha: it is T_SeqScan. Invoked function create_seqscan_plan( )  //this is 
a printf that I added at the source code
0x0811caa7 in create_join_plan ()
(gdb) step
Single stepping until exit from function create_join_plan,
which has no line number information. 

Breakpoint 1, 0x0811c7f1 in create_plan ()
(gdb) step
Single stepping until exit from function create_plan,
which has no line number information.
martha: it is T_SeqScan. Invoked function create_seqscan_plan( )  //this is 
a printf that I added at the source code
0x0811cab6 in create_join_plan ()
(gdb) step
Single stepping until exit from function create_join_plan,
which has no line number information.
0x0811c892 in create_plan ()
(gdb) step
Single stepping until exit from function create_plan,
which has no line number information.
0x081209cb in grouping_planner ()
(gdb) step
Single stepping until exit from function grouping_planner,
which has no line number information.
0x08120253 in subquery_planner ()
(gdb) step
Single stepping until exit from function subquery_planner,
which has no line number information.
0x0811ff7c in planner ()
(gdb) step
Single stepping until exit from function planner,
which has no line number information.
ERROR:  unrecognized node type: 121
0x0814e09c in PostgresMain ()
(gdb) 

Thanks in advance !
-Martha mc
---(end of broadcast)---
TIP 8: explain analyze is your friend