X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3162DD1B4E2 for ; Thu, 18 Sep 2003 06:05:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 94104-07 for ; Thu, 18 Sep 2003 03:04:52 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id B5ED6D1B4EB for ; Thu, 18 Sep 2003 03:04:50 -0300 (ADT) Received: from klaster.net (unknown [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 36A172B3DA; Thu, 18 Sep 2003 08:04:48 +0200 (CEST) Message-ID: <3F694B06.3050802@klaster.net> Date: Thu, 18 Sep 2003 08:04:54 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5a) Gecko/20030718 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Lista dyskusyjna pgsql-sql Subject: Re: cursors in plpgsql References: <3F68C810.6020401@klaster.net> <5920.1063833193@sss.pgh.pa.us> In-Reply-To: <5920.1063833193@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/174 X-Sequence-Number: 15152 > Releases before 7.4 are spotty about supporting backwards scan of > complex queries --- if you have a join or aggregate in the query, > it likely won't work, yielding either strange errors or wrong answers. > > It will work if the top plan node in the query is a SORT, though, so > a possible workaround is to add an explicit ORDER BY to the cursor's > query. (You will need to do some investigation with EXPLAIN to make > sure you are getting a suitable plan for the cursor.) I rewrote my query to have sort in top of plan: Sort (cost=151.24..151.25 rows=1 width=36) Sort Key: czas -> Aggregate (cost=151.22..151.23 rows=1 width=36) -> Group (cost=151.22..151.23 rows=1 width=36) -> Sort (cost=151.22..151.22 rows=1 width=36) I'm not sure if it is what you were talking about, but it didn't help. Anyway the best choice for this function would be a C function, but SPI scares me... And one more question - which syntax is valid? move backward.. or execute ''move backward... > Or try 7.4 beta ... Currently stable branches are better for me... > > regards, tom lane Regards, Tomasz Myrta