1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Server Programming Interface</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Server Programming"
16
HREF="server-programming.html"><LINK
18
TITLE="Environment Variables"
19
HREF="plpython-envar.html"><LINK
21
TITLE="Interface Functions"
22
HREF="spi-interface.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Environment Variables"
57
HREF="plpython-envar.html"
66
TITLE="PL/Python - Python Procedural Language"
89
TITLE="Interface Functions"
90
HREF="spi-interface.html"
105
>Chapter 43. Server Programming Interface</H1
111
>Table of Contents</B
115
HREF="spi-interface.html"
116
>Interface Functions</A
122
HREF="spi-spi-connect.html"
124
> -- connect a procedure to the SPI manager</DT
127
HREF="spi-spi-finish.html"
129
> -- disconnect a procedure from the SPI manager</DT
132
HREF="spi-spi-push.html"
134
> -- push SPI stack to allow recursive SPI usage</DT
137
HREF="spi-spi-pop.html"
139
> -- pop SPI stack to return from recursive SPI usage</DT
142
HREF="spi-spi-execute.html"
144
> -- execute a command</DT
147
HREF="spi-spi-exec.html"
149
> -- execute a read/write command</DT
152
HREF="spi-spi-execute-with-args.html"
153
>SPI_execute_with_args</A
154
> -- execute a command with out-of-line parameters</DT
157
HREF="spi-spi-prepare.html"
159
> -- prepare a plan for a command, without executing it yet</DT
162
HREF="spi-spi-prepare-cursor.html"
163
>SPI_prepare_cursor</A
164
> -- prepare a plan for a command, without executing it yet</DT
167
HREF="spi-spi-prepare-params.html"
168
>SPI_prepare_params</A
169
> -- prepare a plan for a command, without executing it yet</DT
172
HREF="spi-spi-getargcount.html"
174
> -- return the number of arguments needed by a plan
181
HREF="spi-spi-getargtypeid.html"
183
> -- return the data type OID for an argument of
184
a plan prepared by <CODE
190
HREF="spi-spi-is-cursor-plan.html"
191
>SPI_is_cursor_plan</A
192
> -- return <TT
202
>SPI_cursor_open</CODE
206
HREF="spi-spi-execute-plan.html"
208
> -- execute a plan prepared by <CODE
214
HREF="spi-spi-execute-plan-with-paramlist.html"
215
>SPI_execute_plan_with_paramlist</A
216
> -- execute a plan prepared by <CODE
222
HREF="spi-spi-execp.html"
224
> -- execute a plan in read/write mode</DT
227
HREF="spi-spi-cursor-open.html"
229
> -- set up a cursor using a plan created with <CODE
235
HREF="spi-spi-cursor-open-with-args.html"
236
>SPI_cursor_open_with_args</A
237
> -- set up a cursor using a query and parameters</DT
240
HREF="spi-spi-cursor-open-with-paramlist.html"
241
>SPI_cursor_open_with_paramlist</A
242
> -- set up a cursor using parameters</DT
245
HREF="spi-spi-cursor-find.html"
247
> -- find an existing cursor by name</DT
250
HREF="spi-spi-cursor-fetch.html"
252
> -- fetch some rows from a cursor</DT
255
HREF="spi-spi-cursor-move.html"
257
> -- move a cursor</DT
260
HREF="spi-spi-scroll-cursor-fetch.html"
261
>SPI_scroll_cursor_fetch</A
262
> -- fetch some rows from a cursor</DT
265
HREF="spi-spi-scroll-cursor-move.html"
266
>SPI_scroll_cursor_move</A
267
> -- move a cursor</DT
270
HREF="spi-spi-cursor-close.html"
272
> -- close a cursor</DT
275
HREF="spi-spi-saveplan.html"
277
> -- save a plan</DT
282
HREF="spi-interface-support.html"
283
>Interface Support Functions</A
289
HREF="spi-spi-fname.html"
291
> -- determine the column name for the specified column number</DT
294
HREF="spi-spi-fnumber.html"
296
> -- determine the column number for the specified column name</DT
299
HREF="spi-spi-getvalue.html"
301
> -- return the string value of the specified column</DT
304
HREF="spi-spi-getbinval.html"
306
> -- return the binary value of the specified column</DT
309
HREF="spi-spi-gettype.html"
311
> -- return the data type name of the specified column</DT
314
HREF="spi-spi-gettypeid.html"
316
> -- return the data type <ACRONYM
319
> of the specified column</DT
322
HREF="spi-spi-getrelname.html"
324
> -- return the name of the specified relation</DT
327
HREF="spi-spi-getnspname.html"
329
> -- return the namespace of the specified relation</DT
334
HREF="spi-memory.html"
335
>Memory Management</A
341
HREF="spi-spi-palloc.html"
343
> -- allocate memory in the upper executor context</DT
346
HREF="spi-realloc.html"
348
> -- reallocate memory in the upper executor context</DT
351
HREF="spi-spi-pfree.html"
353
> -- free memory in the upper executor context</DT
356
HREF="spi-spi-copytuple.html"
358
> -- make a copy of a row in the upper executor context</DT
361
HREF="spi-spi-returntuple.html"
363
> -- prepare to return a tuple as a Datum</DT
366
HREF="spi-spi-modifytuple.html"
368
> -- create a row by replacing selected fields of a given row</DT
371
HREF="spi-spi-freetuple.html"
373
> -- free a row allocated in the upper executor context</DT
376
HREF="spi-spi-freetupletable.html"
378
> -- free a row set created by <CODE
385
HREF="spi-spi-freeplan.html"
387
> -- free a previously saved plan</DT
392
HREF="spi-visibility.html"
393
>Visibility of Data Changes</A
397
HREF="spi-examples.html"
405
>Server Programming Interface</I
410
>) gives writers of user-defined
414
> functions the ability to run
418
> commands inside their functions.
423
interface functions to simplify access to the parser, planner,
424
and executor. <ACRONYM
437
> The available procedural languages provide various means to
438
execute SQL commands from procedures. Most of these facilities are
439
based on SPI, so this documentation might be of use for users
440
of those languages as well.
445
> To avoid misunderstanding we'll use the term <SPAN
449
when we speak of <ACRONYM
452
> interface functions and
456
> for a user-defined C-function that is
463
> Note that if a command invoked via SPI fails, then control will not be
464
returned to your procedure. Rather, the
465
transaction or subtransaction in which your procedure executes will be
466
rolled back. (This might seem surprising given that the SPI functions mostly
467
have documented error-return conventions. Those conventions only apply
468
for errors detected within the SPI functions themselves, however.)
469
It is possible to recover control after an error by establishing your own
470
subtransaction surrounding SPI calls that might fail. This is not currently
471
documented because the mechanisms required are still in flux.
477
> functions return a nonnegative result on
478
success (either via a returned integer value or in the global
482
>, as described below). On
483
error, a negative result or <TT
489
> Source code files that use SPI must include the header file
501
SUMMARY="Footer navigation table"
512
HREF="plpython-envar.html"
530
HREF="spi-interface.html"
540
>Environment Variables</TD
546
HREF="server-programming.html"
554
>Interface Functions</TD
b'\\ No newline at end of file'