mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Doc: clarify behavior of row-limit arguments in the PLs' SPI wrappers.
plperl, plpython, and pltcl all provide query-execution functions that are thin wrappers around SPI_execute() or its variants. The SPI functions document their row-count limit arguments clearly, as "maximum number of rows to return, or 0 for no limit". However the PLs' documentation failed to explain this special behavior of zero, so that a reader might well assume it means "fetch zero rows". Improve that. Daniel Gustafsson and Tom Lane, per report from Kieran McCusker Discussion: https://postgr.es/m/CAGgUQ6H6qYScctOhktQ9HLFDDoafBKHyUgJbZ6q_dOApnzNTXg@mail.gmail.com
This commit is contained in:
@@ -789,7 +789,7 @@ $$ LANGUAGE plpython3u;
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>plpy.<function>execute</function>(<replaceable>query</replaceable> [, <replaceable>max-rows</replaceable>])</literal></term>
|
||||
<term><literal>plpy.<function>execute</function>(<replaceable>query</replaceable> [, <replaceable>limit</replaceable>])</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Calling <function>plpy.execute</function> with a query string and an
|
||||
@@ -797,6 +797,15 @@ $$ LANGUAGE plpython3u;
|
||||
be returned in a result object.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If <replaceable>limit</replaceable> is specified and is greater than
|
||||
zero, then <function>plpy.execute</function> retrieves at
|
||||
most <replaceable>limit</replaceable> rows, much as if the query
|
||||
included a <literal>LIMIT</literal>
|
||||
clause. Omitting <replaceable>limit</replaceable> or specifying it as
|
||||
zero results in no row limit.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The result object emulates a list or dictionary object. The result
|
||||
object can be accessed by row number and column name. For example:
|
||||
@@ -887,7 +896,7 @@ foo = rv[i]["my_column"]
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>plpy.<function>prepare</function>(<replaceable>query</replaceable> [, <replaceable>argtypes</replaceable>])</literal></term>
|
||||
<term><literal>plpy.<function>execute</function>(<replaceable>plan</replaceable> [, <replaceable>arguments</replaceable> [, <replaceable>max-rows</replaceable>]])</literal></term>
|
||||
<term><literal>plpy.<function>execute</function>(<replaceable>plan</replaceable> [, <replaceable>arguments</replaceable> [, <replaceable>limit</replaceable>]])</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<indexterm><primary>preparing a query</primary><secondary>in PL/Python</secondary></indexterm>
|
||||
|
Reference in New Issue
Block a user