Re: [HACKERS] tuplestore API problem

2009-04-01 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: I don't think advising or documenting such restriction to the future programmer is a good idea from the point of encapsulation. I've come up with an idea, that the read pointers remember their last slot as you suggest and materialize it when another

Re: [HACKERS] tuplestore API problem

2009-03-30 Thread Hitoshi Harada
2009/3/30 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2009/3/29 Tom Lane t...@sss.pgh.pa.us: ... What might be a bit saner is to remember the slot last passed to tuplestore_gettupleslot for each read pointer.  The implication would be that we'd be assuming only

Re: [HACKERS] tuplestore API problem

2009-03-29 Thread Hitoshi Harada
2009/3/29 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: So I tried pass EState.es_tupleTables to tuplestore_begin_heap() to trace those TupleTableSlots. Note that if you pass NULL the behavior is as before so nothing's broken. Regression passes but I'm not quite

Re: [HACKERS] tuplestore API problem

2009-03-29 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: 2009/3/29 Tom Lane t...@sss.pgh.pa.us: ... What might be a bit saner is to remember the slot last passed to tuplestore_gettupleslot for each read pointer.  The implication would be that we'd be assuming only one slot is used to fetch from any one

Re: [HACKERS] tuplestore API problem

2009-03-28 Thread Hitoshi Harada
2009/3/28 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2009/3/27 Hitoshi Harada umi.tan...@gmail.com: 2009/3/27 Tom Lane t...@sss.pgh.pa.us: A brute-force solution is to change tuplestore_gettupleslot() so that it always copies the tuple, but this would be wasted

Re: [HACKERS] tuplestore API problem

2009-03-28 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: So I tried pass EState.es_tupleTables to tuplestore_begin_heap() to trace those TupleTableSlots. Note that if you pass NULL the behavior is as before so nothing's broken. Regression passes but I'm not quite sure EState.es_tupleTable is only place

Re: [HACKERS] tuplestore API problem

2009-03-27 Thread Hitoshi Harada
2009/3/27 Hitoshi Harada umi.tan...@gmail.com: 2009/3/27 Tom Lane t...@sss.pgh.pa.us: By chance I discovered that this query in the regression tests SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; stops working if work_mem is small enough: it either dumps core or

Re: [HACKERS] tuplestore API problem

2009-03-27 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: 2009/3/27 Hitoshi Harada umi.tan...@gmail.com: 2009/3/27 Tom Lane t...@sss.pgh.pa.us: A brute-force solution is to change tuplestore_gettupleslot() so that it always copies the tuple, but this would be wasted cycles for most uses of tuplestores.  

Re: [HACKERS] tuplestore API problem

2009-03-26 Thread Simon Riggs
On Thu, 2009-03-26 at 12:57 -0400, Tom Lane wrote: If work_mem is small enough, that means the tuplestore is forced into dump-to-disk mode, which means it releases all its in-memory tuples. And guess what: the ScanTupleSlot is pointing at one of those, it doesn't have its own copy of the

Re: [HACKERS] tuplestore API problem

2009-03-26 Thread Tom Lane
Simon Riggs si...@2ndquadrant.com writes: Sounds very similar to the solution that you just removed from the hash join code for performance reasons. Flushing memory when we overflow sounds like an artifact from the time when tuplestore split from tuplesort. Can't we keep the appropriate rows

Re: [HACKERS] tuplestore API problem

2009-03-26 Thread Hitoshi Harada
2009/3/27 Tom Lane t...@sss.pgh.pa.us: By chance I discovered that this query in the regression tests SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2; stops working if work_mem is small enough: it either dumps core or delivers wrong answers depending on platform.