Re: creating WITH HOLD cursors using SPI

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Abhijit Menon-Sen <ams(at)oryx(dot)com>
Cc: plperlng-devel(at)pgfoundry(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: creating WITH HOLD cursors using SPI
Date: 2005-06-24 15:59:36
Message-ID: 42BC2DE8.1010405@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Abhijit Menon-Sen wrote:

>Hi.
>
>I've been working on making it possible for PL/Perl users to fetch large
>result sets one row at a time (the current spi_exec_query interface just
>returns a big hash).
>
>The idea is to have spi_query call SPI_prepare/SPI_open_cursor, and have
>an spi_fetchrow that calls SPI_cursor_fetch. It works well enough, but I
>don't know how to reproduce spi_exec_query's error handling (it runs the
>SPI_execute in a subtransaction).
>
>To do something similar, I would have to create a WITH HOLD cursor in my
>spi_query function. But SPI_cursor_open provides no way to do this, and
>it calls PortalStart before I can set CURSOR_OPT_HOLD myself.
>
>Suggestions?
>
>
>
>

Abhijit,

Thinking and reading about this some more, I think we should not try to
mimic the error handling of the existing mechanism. Let's just provide a
separate API using SPI_prepare/SPI_open_cursor/SPI_cursor_fetch, and
leave the current mechanism in place - it's useful enough on small
resultsets.

Does that make sense? If so, can you do that, or give me what you have
and let me bang on it?

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2005-06-24 16:08:34 Re: Server instrumentation patch
Previous Message Tom Lane 2005-06-24 15:53:53 Re: [PATCHES] Function's LEAST, GREATEST and DECODE (Oracle vararg polymorphic functions)