1999-01-27 17:15:22 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
2002-10-15 01:49:20 +02:00
|
|
|
* spi_priv.h
|
1999-01-27 17:15:22 +01:00
|
|
|
* Server Programming Interface private declarations
|
|
|
|
*
|
2007-01-05 23:20:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
2002-10-15 01:49:20 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2007-04-16 19:21:24 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/executor/spi_priv.h,v 1.29 2007/04/16 17:21:23 tgl Exp $
|
1999-01-27 17:15:22 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef SPI_PRIV_H
|
|
|
|
#define SPI_PRIV_H
|
|
|
|
|
1999-07-14 03:20:30 +02:00
|
|
|
#include "executor/spi.h"
|
1999-01-27 17:15:22 +01:00
|
|
|
|
2002-10-15 01:49:20 +02:00
|
|
|
|
2007-03-16 00:12:07 +01:00
|
|
|
#define _SPI_PLAN_MAGIC 569278163
|
|
|
|
|
1999-01-27 17:15:22 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-01 20:43:19 +02:00
|
|
|
/* current results */
|
1999-01-27 17:15:22 +01:00
|
|
|
uint32 processed; /* by Executor */
|
2005-10-01 20:43:19 +02:00
|
|
|
Oid lastoid;
|
1999-01-27 17:15:22 +01:00
|
|
|
SPITupleTable *tuptable;
|
2005-10-01 20:43:19 +02:00
|
|
|
|
2000-06-28 05:33:33 +02:00
|
|
|
MemoryContext procCxt; /* procedure context */
|
|
|
|
MemoryContext execCxt; /* executor context */
|
2007-03-16 00:12:07 +01:00
|
|
|
MemoryContext savedcxt; /* context of SPI_connect's caller */
|
2005-10-15 04:49:52 +02:00
|
|
|
SubTransactionId connectSubid; /* ID of connecting subtransaction */
|
1999-01-27 17:15:22 +01:00
|
|
|
} _SPI_connection;
|
|
|
|
|
2007-03-16 00:12:07 +01:00
|
|
|
/*
|
|
|
|
* SPI plans have two states: saved or unsaved.
|
|
|
|
*
|
|
|
|
* For an unsaved plan, the _SPI_plan struct and all its subsidiary data are in
|
|
|
|
* a dedicated memory context identified by plancxt. An unsaved plan is good
|
|
|
|
* at most for the current transaction, since the locks that protect it from
|
|
|
|
* schema changes will be lost at end of transaction. Hence the plancxt is
|
|
|
|
* always a transient one.
|
|
|
|
*
|
|
|
|
* For a saved plan, the _SPI_plan struct and the argument type array are in
|
|
|
|
* the plancxt (which can be really small). All the other subsidiary state
|
|
|
|
* is in plancache entries identified by plancache_list (note: the list cells
|
|
|
|
* themselves are in plancxt). We rely on plancache.c to keep the cache
|
|
|
|
* entries up-to-date as needed. The plancxt is a child of CacheMemoryContext
|
|
|
|
* since it should persist until explicitly destroyed.
|
|
|
|
*
|
|
|
|
* To avoid redundant coding, the representation of unsaved plans matches
|
|
|
|
* that of saved plans, ie, plancache_list is a list of CachedPlanSource
|
|
|
|
* structs which in turn point to CachedPlan structs. However, in an unsaved
|
|
|
|
* plan all these structs are just created by spi.c and are not known to
|
|
|
|
* plancache.c. We don't try very hard to make all their fields valid,
|
|
|
|
* only the ones spi.c actually uses.
|
|
|
|
*
|
|
|
|
* Note: if the original query string contained only whitespace and comments,
|
|
|
|
* the plancache_list will be NIL and so there is no place to store the
|
|
|
|
* query string. We don't care about that, but we do care about the
|
|
|
|
* argument type array, which is why it's seemingly-redundantly stored.
|
|
|
|
*/
|
|
|
|
typedef struct _SPI_plan
|
1999-01-27 17:15:22 +01:00
|
|
|
{
|
2007-03-16 00:12:07 +01:00
|
|
|
int magic; /* should equal _SPI_PLAN_MAGIC */
|
|
|
|
bool saved; /* saved or unsaved plan? */
|
|
|
|
List *plancache_list; /* one CachedPlanSource per parsetree */
|
|
|
|
MemoryContext plancxt; /* Context containing _SPI_plan and data */
|
2007-04-16 19:21:24 +02:00
|
|
|
int cursor_options; /* Cursor options used for planning */
|
2007-03-16 00:12:07 +01:00
|
|
|
int nargs; /* number of plan arguments */
|
|
|
|
Oid *argtypes; /* Argument types (NULL if nargs is 0) */
|
1999-01-27 17:15:22 +01:00
|
|
|
} _SPI_plan;
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* SPI_PRIV_H */
|