Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfec0778

Browse files
committed
Clarify the distinction between public and private SPITupleTable fields.
The fields that we consider public are "tupdesc" and "vals", whichhistorically are in the middle of the struct. Move them to the front(this should be perfectly safe to do in HEAD) and add comments to makeit quite clear which fields are public or not.Also adjust spi.sgml's documentation of the struct to match.That doc had bit-rotted somewhat, as it was missing some fields.(Arguably we should just remove all the private fields from the docs,but for now I refrained.)Daniel Gustafsson, reviewed by Fabien CoelhoDiscussion:https://postgr.es/m/0D19F836-B743-4340-B6A2-F148CA3DD1F0@yesql.se
1 parent860c095 commitfec0778

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

‎doc/src/sgml/spi.sgml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,26 @@ SPI_execute("INSERT INTO foo SELECT * FROM bar RETURNING *", false, 5);
318318
The structure <structname>SPITupleTable</structname> is defined
319319
thus:
320320
<programlisting>
321-
typedef struct
321+
typedef struct SPITupleTable
322322
{
323+
/* Public members */
324+
TupleDesc tupdesc; /* tuple descriptor */
325+
HeapTuple *vals; /* array of tuples */
326+
327+
/* Private members, not intended for external callers */
323328
MemoryContext tuptabcxt; /* memory context of result table */
324-
uint64 alloced; /*number of alloced vals */
325-
uint64 free; /*number of free vals */
326-
TupleDesc tupdesc; /*row descriptor */
327-
HeapTuple *vals; /* rows */
329+
uint64 alloced; /*# of alloced vals */
330+
uint64 free; /*# of free vals */
331+
slist_node next;/*link for internal bookkeeping */
332+
SubTransactionId subid;/* subxact in which tuptable was created */
328333
} SPITupleTable;
329334
</programlisting>
335+
<structfield>vals</structfield> and <structfield>tupdesc</structfield> can
336+
be used by SPI callers, the remaining fields are internal.
330337
<structfield>vals</structfield> is an array of pointers to rows. (The number
331338
of valid entries is given by <varname>SPI_processed</varname>.)
332339
<structfield>tupdesc</structfield> is a row descriptor which you can pass to
333-
SPI functions dealing with rows. <structfield>tuptabcxt</structfield>,
334-
<structfield>alloced</structfield>, and <structfield>free</structfield> are internal
335-
fields not intended for use by SPI callers.
340+
SPI functions dealing with rows.
336341
</para>
337342

338343
<para>

‎src/include/executor/spi.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121

2222
typedefstructSPITupleTable
2323
{
24+
/* Public members */
25+
TupleDesctupdesc;/* tuple descriptor */
26+
HeapTuple*vals;/* array of tuples */
27+
28+
/* Private members, not intended for external callers */
2429
MemoryContexttuptabcxt;/* memory context of result table */
2530
uint64alloced;/* # of alloced vals */
2631
uint64free;/* # of free vals */
27-
TupleDesctupdesc;/* tuple descriptor */
28-
HeapTuple*vals;/* tuples */
2932
slist_nodenext;/* link for internal bookkeeping */
3033
SubTransactionIdsubid;/* subxact in which tuptable was created */
3134
}SPITupleTable;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp