]> granicus.if.org Git - postgresql/blob - src/include/executor/spi.h
Another pgindent run. Fixes enum indenting, and improves #endif
[postgresql] / src / include / executor / spi.h
1 /*-------------------------------------------------------------------------
2  *
3  * spi.h
4  *
5  * $Id: spi.h,v 1.30 2001/10/28 06:26:06 momjian Exp $
6  *
7  *-------------------------------------------------------------------------
8  */
9 #ifndef SPI_H
10 #define SPI_H
11
12 /*
13  * This file may be used by client modules that haven't already
14  * included postgres.h
15  */
16 #include "postgres.h"
17
18 /*
19  *      These are not needed by this file, but used by other programs
20  *      using SPI
21  */
22 #include "nodes/primnodes.h"
23 #include "nodes/relation.h"
24 #include "nodes/execnodes.h"
25 #include "nodes/plannodes.h"
26 #include "catalog/pg_proc.h"
27 #include "catalog/pg_type.h"
28 #include "tcop/pquery.h"
29 #include "tcop/tcopprot.h"
30 #include "tcop/utility.h"
31 #include "tcop/dest.h"
32 #include "nodes/params.h"
33 #include "utils/fcache.h"
34 #include "utils/datum.h"
35 #include "utils/syscache.h"
36 #include "utils/builtins.h"
37 #include "catalog/pg_language.h"
38 #include "access/heapam.h"
39 #include "access/xact.h"
40 #include "executor/executor.h"
41 #include "executor/execdefs.h"
42
43 typedef struct
44 {
45         MemoryContext tuptabcxt;        /* memory context of result table */
46         uint32          alloced;                /* # of alloced vals */
47         uint32          free;                   /* # of free vals */
48         TupleDesc       tupdesc;                /* tuple descriptor */
49         HeapTuple  *vals;                       /* tuples */
50 } SPITupleTable;
51
52 #define SPI_ERROR_CONNECT               (-1)
53 #define SPI_ERROR_COPY                  (-2)
54 #define SPI_ERROR_OPUNKNOWN             (-3)
55 #define SPI_ERROR_UNCONNECTED   (-4)
56 #define SPI_ERROR_CURSOR                (-5)
57 #define SPI_ERROR_ARGUMENT              (-6)
58 #define SPI_ERROR_PARAM                 (-7)
59 #define SPI_ERROR_TRANSACTION   (-8)
60 #define SPI_ERROR_NOATTRIBUTE   (-9)
61 #define SPI_ERROR_NOOUTFUNC             (-10)
62 #define SPI_ERROR_TYPUNKNOWN    (-11)
63
64 #define SPI_OK_CONNECT                  1
65 #define SPI_OK_FINISH                   2
66 #define SPI_OK_FETCH                    3
67 #define SPI_OK_UTILITY                  4
68 #define SPI_OK_SELECT                   5
69 #define SPI_OK_SELINTO                  6
70 #define SPI_OK_INSERT                   7
71 #define SPI_OK_DELETE                   8
72 #define SPI_OK_UPDATE                   9
73 #define SPI_OK_CURSOR                   10
74
75 extern DLLIMPORT uint32 SPI_processed;
76 extern DLLIMPORT Oid SPI_lastoid;
77 extern DLLIMPORT SPITupleTable *SPI_tuptable;
78 extern DLLIMPORT int SPI_result;
79
80 extern int      SPI_connect(void);
81 extern int      SPI_finish(void);
82 extern void SPI_push(void);
83 extern void SPI_pop(void);
84 extern int      SPI_exec(char *src, int tcount);
85 extern int      SPI_execp(void *plan, Datum *values, char *Nulls, int tcount);
86 extern void *SPI_prepare(char *src, int nargs, Oid *argtypes);
87 extern void *SPI_saveplan(void *plan);
88 extern int      SPI_freeplan(void *plan);
89
90 extern HeapTuple SPI_copytuple(HeapTuple tuple);
91 extern TupleDesc SPI_copytupledesc(TupleDesc tupdesc);
92 extern HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts,
93                                 int *attnum, Datum *Values, char *Nulls);
94 extern int      SPI_fnumber(TupleDesc tupdesc, char *fname);
95 extern char *SPI_fname(TupleDesc tupdesc, int fnumber);
96 extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber);
97 extern Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull);
98 extern char *SPI_gettype(TupleDesc tupdesc, int fnumber);
99 extern Oid      SPI_gettypeid(TupleDesc tupdesc, int fnumber);
100 extern char *SPI_getrelname(Relation rel);
101 extern void *SPI_palloc(Size size);
102 extern void *SPI_repalloc(void *pointer, Size size);
103 extern void SPI_pfree(void *pointer);
104 extern void SPI_freetuple(HeapTuple pointer);
105 extern void SPI_freetuptable(SPITupleTable *tuptable);
106
107 extern Portal SPI_cursor_open(char *name, void *plan,
108                                 Datum *Values, char *Nulls);
109 extern Portal SPI_cursor_find(char *name);
110 extern void SPI_cursor_fetch(Portal portal, bool forward, int count);
111 extern void SPI_cursor_move(Portal portal, bool forward, int count);
112 extern void SPI_cursor_close(Portal portal);
113
114 extern void AtEOXact_SPI(void);
115
116 #endif   /* SPI_H */