Re: [HACKERS] PL/Perl list value return causes segfault

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, PostgreSQL Docs <pgsql-docs(at)postgresql(dot)org>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] PL/Perl list value return causes segfault
Date: 2005-07-30 13:47:58
Message-ID: 42EB850E.9080205@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers pgsql-patches

David Fetter wrote:

>*** 716,724 ****
>
> <listitem>
> <para>
>! In the current implementation, if you are fetching or returning
>! very large data sets, you should be aware that these will all go
>! into memory.
> </para>
> </listitem>
> </itemizedlist>
>--- 766,776 ----
>
> <listitem>
> <para>
>! If you are fetching or returning very large data sets using
>! <literal>spi_exec_query</literal>, you should be aware that
>! these will all go into memory. You can avoid this by using
>! <literal>spi_query</literal>/<literal>spi_fetchrow</literal> as
>! illustrated earlier.
> </para>
> </listitem>
> </itemizedlist>
>
>
>
>

You have rolled 2 problems into one - spi_query+spi_fetchrow does not
address the issue of returning large data sets.

Suggest instead:

<para>

If you are fetching very large data sets using
<literal>spi_exec_query</literal>, you should be aware that
these will all go into memory. You can avoid this by using
<literal>spi_query</literal> and <literal>spi_fetchrow</literal>
as illustrated earlier.
</para>
<para>
A similar problem occurs if a set-returning function passes
a large set of rows back to postgres via
<literal>return</literal>. You can avoid this
problem too by instead using <literal>return_next</literal> for
each row returned, as shown previously.
</para>

cheers

andrew

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David Fetter 2005-07-31 00:34:58 Re: [HACKERS] PL/Perl list value return causes segfault
Previous Message David Fetter 2005-07-30 05:43:54 Re: [HACKERS] PL/Perl list value return causes segfault

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-07-30 14:16:09 Re: [HACKERS] Win32 build broken by recent changes to xlog.c
Previous Message Magnus Hagander 2005-07-30 13:47:33 Win32 build broken by recent changes to xlog.c

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-07-30 14:16:09 Re: [HACKERS] Win32 build broken by recent changes to xlog.c
Previous Message Magnus Hagander 2005-07-30 13:47:33 Win32 build broken by recent changes to xlog.c