]> begriffs open source - ai-pg/blob - full-docs/man3/SPI_connect.3
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man3 / SPI_connect.3
1 '\" t
2 .\"     Title: SPI_connect
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_CONNECT" "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_connect, SPI_connect_ext \- connect a C function to the SPI manager
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 int SPI_connect(void)
36 .fi
37 .sp
38 .nf
39 int SPI_connect_ext(int \fIoptions\fR)
40 .fi
41 .SH "DESCRIPTION"
42 .PP
43 \fBSPI_connect\fR
44 opens a connection from a C function invocation to the SPI manager\&. You must call this function if you want to execute commands through SPI\&. Some utility SPI functions can be called from unconnected C functions\&.
45 .PP
46 \fBSPI_connect_ext\fR
47 does the same but has an argument that allows passing option flags\&. Currently, the following option values are available:
48 .PP
49 SPI_OPT_NONATOMIC
50 .RS 4
51 Sets the SPI connection to be
52 nonatomic, which means that transaction control calls (\fBSPI_commit\fR,
53 \fBSPI_rollback\fR) are allowed\&. Otherwise, calling those functions will result in an immediate error\&.
54 .RE
55 .PP
56 SPI_connect()
57 is equivalent to
58 SPI_connect_ext(0)\&.
59 .SH "RETURN VALUE"
60 .PP
61 SPI_OK_CONNECT
62 .RS 4
63 on success
64 .RE
65 .PP
66 The fact that these functions return
67 int
68 not
69 void
70 is historical\&. All failure cases are reported via
71 \fBereport\fR
72 or
73 \fBelog\fR\&. (In versions before
74 PostgreSQL
75 v10, some but not all failures would be reported with a result value of
76 SPI_ERROR_CONNECT\&.)