Re: [HACKERS] Terminating a SETOF function call sequence

2005-02-17 Thread Thomas Hallgren
Tom Lane wrote: Thomas Hallgren <[EMAIL PROTECTED]> writes: My question is, what happens when the evaluator doesn't need more rows? Will it: a) call the function with call_cntr >= max_calls? b) continue calling until the set is exhausted anyway? c) simply stop calling? (c) a) seems unli

Re: [HACKERS] Terminating a SETOF function call sequence

2005-02-17 Thread Tom Lane
Thomas Hallgren <[EMAIL PROTECTED]> writes: > My question is, what happens when the evaluator doesn't need more rows? > Will it: > a) call the function with call_cntr >= max_calls? > b) continue calling until the set is exhausted anyway? > c) simply stop calling? (c) > a) seems unlikely since ma

Re: [HACKERS] Terminating a SETOF function call sequence

2005-02-17 Thread Thomas Hallgren
John, You are supposed to free resources used to produce the rows before srf_return_next(); I can (and must) free up the resources used to produce one single row at that time yes, but I might have resources that is common to all rows. Let's assume that I have a file open for instance. I read one

Re: [HACKERS] Terminating a SETOF function call sequence

2005-02-17 Thread John Hansen
> ... c) would be very bad since it > doesn't give me any chance to release the resources that > where used in order to produce the rows. You are supposed to free resources used to produce the rows before srf_return_next(); The actual rows are pfree()'d by pg. (an dso are any other palloc()'d

[HACKERS] Terminating a SETOF function call sequence

2005-02-17 Thread Thomas Hallgren
Some SQL constructs will be satisfied before all rows of a set has been examined. I'm thinking of for instance: EXISTS(SELECT * FROM y WHERE y.a > 0) If the first row of collection y fulfills the WHERE predicate, there's no reason to continue perusing the rest of the rows. Now, what if 'y' is a