]> begriffs open source - ai-pg/blob - full-docs/man3/SPI_modifytuple.3
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man3 / SPI_modifytuple.3
1 '\" t
2 .\"     Title: SPI_modifytuple
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "SPI_MODIFYTUPLE" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 SPI_modifytuple \- create a row by replacing selected fields of a given row
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 HeapTuple SPI_modifytuple(Relation \fIrel\fR, HeapTuple \fIrow\fR, int \fIncols\fR,
36                           int * \fIcolnum\fR, Datum * \fIvalues\fR, const char * \fInulls\fR)
37 .fi
38 .SH "DESCRIPTION"
39 .PP
40 \fBSPI_modifytuple\fR
41 creates a new row by substituting new values for selected columns, copying the original row\*(Aqs columns at other positions\&. The input row is not modified\&. The new row is returned in the upper executor context\&.
42 .PP
43 This function can only be used while connected to SPI\&. Otherwise, it returns NULL and sets
44 \fISPI_result\fR
45 to
46 SPI_ERROR_UNCONNECTED\&.
47 .SH "ARGUMENTS"
48 .PP
49 Relation \fIrel\fR
50 .RS 4
51 Used only as the source of the row descriptor for the row\&. (Passing a relation rather than a row descriptor is a misfeature\&.)
52 .RE
53 .PP
54 HeapTuple \fIrow\fR
55 .RS 4
56 row to be modified
57 .RE
58 .PP
59 int \fIncols\fR
60 .RS 4
61 number of columns to be changed
62 .RE
63 .PP
64 int * \fIcolnum\fR
65 .RS 4
66 an array of length
67 \fIncols\fR, containing the numbers of the columns that are to be changed (column numbers start at 1)
68 .RE
69 .PP
70 Datum * \fIvalues\fR
71 .RS 4
72 an array of length
73 \fIncols\fR, containing the new values for the specified columns
74 .RE
75 .PP
76 const char * \fInulls\fR
77 .RS 4
78 an array of length
79 \fIncols\fR, describing which new values are null
80 .sp
81 If
82 \fInulls\fR
83 is
84 NULL
85 then
86 \fBSPI_modifytuple\fR
87 assumes that no new values are null\&. Otherwise, each entry of the
88 \fInulls\fR
89 array should be
90 \*(Aq\ \&\*(Aq
91 if the corresponding new value is non\-null, or
92 \*(Aqn\*(Aq
93 if the corresponding new value is null\&. (In the latter case, the actual value in the corresponding
94 \fIvalues\fR
95 entry doesn\*(Aqt matter\&.) Note that
96 \fInulls\fR
97 is not a text string, just an array: it does not need a
98 \*(Aq\e0\*(Aq
99 terminator\&.
100 .RE
101 .SH "RETURN VALUE"
102 .PP
103 new row with modifications, allocated in the upper executor context, or
104 NULL
105 on error (see
106 \fISPI_result\fR
107 for an error indication)
108 .PP
109 On error,
110 \fISPI_result\fR
111 is set as follows:
112 .PP
113 SPI_ERROR_ARGUMENT
114 .RS 4
115 if
116 \fIrel\fR
117 is
118 NULL, or if
119 \fIrow\fR
120 is
121 NULL, or if
122 \fIncols\fR
123 is less than or equal to 0, or if
124 \fIcolnum\fR
125 is
126 NULL, or if
127 \fIvalues\fR
128 is
129 NULL\&.
130 .RE
131 .PP
132 SPI_ERROR_NOATTRIBUTE
133 .RS 4
134 if
135 \fIcolnum\fR
136 contains an invalid column number (less than or equal to 0 or greater than the number of columns in
137 \fIrow\fR)
138 .RE
139 .PP
140 SPI_ERROR_UNCONNECTED
141 .RS 4
142 if SPI is not active
143 .RE