postgresql/src/include/executor/spi.h

116 lines
3.6 KiB
C
Raw Normal View History

1997-08-29 11:05:57 +02:00
/*-------------------------------------------------------------------------
*
* spi.h
*
* $Id: spi.h,v 1.29 2001/10/25 05:49:59 momjian Exp $
1997-08-29 11:05:57 +02:00
*
*-------------------------------------------------------------------------
*/
#ifndef SPI_H
1997-08-29 11:05:57 +02:00
#define SPI_H
/*
* This file may be used by client modules that haven't already
* included postgres.h
*/
1997-08-29 11:05:57 +02:00
#include "postgres.h"
/*
* These are not needed by this file, but used by other programs
* using SPI
*/
1997-08-29 11:05:57 +02:00
#include "nodes/primnodes.h"
#include "nodes/relation.h"
#include "nodes/execnodes.h"
#include "nodes/plannodes.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
1997-08-29 11:05:57 +02:00
#include "tcop/pquery.h"
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
#include "tcop/dest.h"
#include "nodes/params.h"
#include "utils/fcache.h"
#include "utils/datum.h"
#include "utils/syscache.h"
1997-09-11 09:24:37 +02:00
#include "utils/builtins.h"
1997-08-29 11:05:57 +02:00
#include "catalog/pg_language.h"
#include "access/heapam.h"
#include "access/xact.h"
#include "executor/executor.h"
#include "executor/execdefs.h"
typedef struct
{
MemoryContext tuptabcxt; /* memory context of result table */
uint32 alloced; /* # of alloced vals */
uint32 free; /* # of free vals */
TupleDesc tupdesc; /* tuple descriptor */
HeapTuple *vals; /* tuples */
} SPITupleTable;
1997-08-29 11:05:57 +02:00
#define SPI_ERROR_CONNECT (-1)
#define SPI_ERROR_COPY (-2)
#define SPI_ERROR_OPUNKNOWN (-3)
#define SPI_ERROR_UNCONNECTED (-4)
#define SPI_ERROR_CURSOR (-5)
#define SPI_ERROR_ARGUMENT (-6)
#define SPI_ERROR_PARAM (-7)
#define SPI_ERROR_TRANSACTION (-8)
#define SPI_ERROR_NOATTRIBUTE (-9)
#define SPI_ERROR_NOOUTFUNC (-10)
#define SPI_ERROR_TYPUNKNOWN (-11)
1997-08-29 11:05:57 +02:00
#define SPI_OK_CONNECT 1
#define SPI_OK_FINISH 2
#define SPI_OK_FETCH 3
#define SPI_OK_UTILITY 4
#define SPI_OK_SELECT 5
#define SPI_OK_SELINTO 6
#define SPI_OK_INSERT 7
#define SPI_OK_DELETE 8
#define SPI_OK_UPDATE 9
#define SPI_OK_CURSOR 10
1997-09-04 15:26:19 +02:00
extern DLLIMPORT uint32 SPI_processed;
extern DLLIMPORT Oid SPI_lastoid;
extern DLLIMPORT SPITupleTable *SPI_tuptable;
1999-05-25 18:15:34 +02:00
extern DLLIMPORT int SPI_result;
1997-08-29 11:05:57 +02:00
extern int SPI_connect(void);
extern int SPI_finish(void);
1999-05-25 18:15:34 +02:00
extern void SPI_push(void);
extern void SPI_pop(void);
extern int SPI_exec(char *src, int tcount);
extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount);
extern void *SPI_prepare(char *src, int nargs, Oid *argtypes);
extern void *SPI_saveplan(void *plan);
extern int SPI_freeplan(void *plan);
1997-09-04 15:26:19 +02:00
extern HeapTuple SPI_copytuple(HeapTuple tuple);
extern TupleDesc SPI_copytupledesc(TupleDesc tupdesc);
extern HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts,
int *attnum, Datum *Values, char *Nulls);
extern int SPI_fnumber(TupleDesc tupdesc, char *fname);
1997-09-11 09:24:37 +02:00
extern char *SPI_fname(TupleDesc tupdesc, int fnumber);
extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber);
extern Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull);
extern char *SPI_gettype(TupleDesc tupdesc, int fnumber);
extern Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber);
extern char *SPI_getrelname(Relation rel);
extern void *SPI_palloc(Size size);
extern void *SPI_repalloc(void *pointer, Size size);
extern void SPI_pfree(void *pointer);
extern void SPI_freetuple(HeapTuple pointer);
extern void SPI_freetuptable(SPITupleTable *tuptable);
extern Portal SPI_cursor_open(char *name, void *plan,
Datum *Values, char *Nulls);
extern Portal SPI_cursor_find(char *name);
extern void SPI_cursor_fetch(Portal portal, bool forward, int count);
extern void SPI_cursor_move(Portal portal, bool forward, int count);
extern void SPI_cursor_close(Portal portal);
1997-08-29 11:05:57 +02:00
extern void AtEOXact_SPI(void);
#endif /* SPI_H */