Re: [GENERAL] Unpredicatable behavior of volatile functions used

2007-01-15 Thread Aleksander Kmetec
Tom Lane wrote: Aleksander Kmetec <[EMAIL PROTECTED]> writes: Some quick testing shows that util.row_number() only gets re-evaluated at every call if the subquery contains an ORDER BY clause. Now we can predict whether we need to compensate for that just by looking at the original query. If y

Re: [GENERAL] Unpredicatable behavior of volatile functions used

2007-01-15 Thread Tom Lane
Aleksander Kmetec <[EMAIL PROTECTED]> writes: > Some quick testing shows that util.row_number() only gets re-evaluated at > every call if the subquery contains an ORDER > BY clause. Now we can predict whether we need to compensate for that just by > looking at the original query. If you're goin

Re: [GENERAL] Unpredicatable behavior of volatile functions used

2007-01-15 Thread Aleksander Kmetec
Tom Lane wrote: This isn't gonna work very well if your query involves sorting, because the SELECT-list is evaluated before the sort step ... regards, tom lane Thanks, this seems to solve my problem. Some quick testing shows that util.row_number() only gets re-evalua

Re: [GENERAL] Unpredicatable behavior of volatile functions used in cursors

2007-01-15 Thread Tom Lane
Aleksander Kmetec <[EMAIL PROTECTED]> writes: > We're using the following technique for counting the number of rows in a > cursor: > DECLARE instance_cur_1 SCROLL CURSOR FOR > SELECT util.row_number(), * > FROM ( > $LONG_RUNNING_QUERY > ) ss > FETCH LAST IN instance_cur_1; > util.row_number

[GENERAL] Unpredicatable behavior of volatile functions used in cursors

2007-01-15 Thread Aleksander Kmetec
Hi, I'm running into some inconsistent behavior when using volatile functions with cursors under PG 8.1. We're using the following technique for counting the number of rows in a cursor: --- DECLARE instance_cur_1 SCROLL CURSOR FOR SELECT util.row_number(), * FROM ( $LONG_RUNNIN