aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/spi.sgml20
1 files changed, 12 insertions, 8 deletions
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
index e39f99fbb32..9e37fc3a14e 100644
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -323,19 +323,23 @@ typedef struct SPITupleTable
/* Public members */
TupleDesc tupdesc; /* tuple descriptor */
HeapTuple *vals; /* array of tuples */
+ uint64 numvals; /* number of valid tuples */
/* Private members, not intended for external callers */
+ uint64 alloced; /* allocated length of vals array */
MemoryContext tuptabcxt; /* memory context of result table */
- uint64 alloced; /* # of alloced vals */
- uint64 free; /* # of free vals */
slist_node next; /* link for internal bookkeeping */
SubTransactionId subid; /* subxact in which tuptable was created */
} SPITupleTable;
</programlisting>
- <structfield>vals</structfield> and <structfield>tupdesc</structfield> can
- be used by SPI callers, the remaining fields are internal.
- <structfield>vals</structfield> is an array of pointers to rows. (The number
- of valid entries is given by <varname>SPI_processed</varname>.)
+ <structfield>tupdesc</structfield>,
+ <structfield>vals</structfield>, and
+ <structfield>numvals</structfield>
+ can be used by SPI callers; the remaining fields are internal.
+ <structfield>vals</structfield> is an array of pointers to rows.
+ The number of rows is given by <structfield>numvals</structfield>
+ (for somewhat historical reasons, this count is also returned
+ in <varname>SPI_processed</varname>).
<structfield>tupdesc</structfield> is a row descriptor which you can pass to
SPI functions dealing with rows.
</para>
@@ -4631,12 +4635,12 @@ execq(PG_FUNCTION_ARGS)
*/
if (ret &gt; 0 &amp;&amp; SPI_tuptable != NULL)
{
- TupleDesc tupdesc = SPI_tuptable-&gt;tupdesc;
SPITupleTable *tuptable = SPI_tuptable;
+ TupleDesc tupdesc = tuptable-&gt;tupdesc;
char buf[8192];
uint64 j;
- for (j = 0; j &lt; proc; j++)
+ for (j = 0; j &lt; tuptable-&gt;numvals; j++)
{
HeapTuple tuple = tuptable-&gt;vals[j];
int i;