Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / include / executor / spi_priv.h
blob04f3614cb751983039c5a7ed4a69b4178ba40ff4
1 /*-------------------------------------------------------------------------
3 * spi_priv.h
4 * Server Programming Interface private declarations
6 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * $PostgreSQL$
11 *-------------------------------------------------------------------------
13 #ifndef SPI_PRIV_H
14 #define SPI_PRIV_H
16 #include "executor/spi.h"
19 #define _SPI_PLAN_MAGIC 569278163
21 typedef struct
23 /* current results */
24 uint32 processed; /* by Executor */
25 Oid lastoid;
26 SPITupleTable *tuptable;
28 MemoryContext procCxt; /* procedure context */
29 MemoryContext execCxt; /* executor context */
30 MemoryContext savedcxt; /* context of SPI_connect's caller */
31 SubTransactionId connectSubid; /* ID of connecting subtransaction */
32 } _SPI_connection;
35 * SPI plans have two states: saved or unsaved.
37 * For an unsaved plan, the _SPI_plan struct and all its subsidiary data are in
38 * a dedicated memory context identified by plancxt. An unsaved plan is good
39 * at most for the current transaction, since the locks that protect it from
40 * schema changes will be lost at end of transaction. Hence the plancxt is
41 * always a transient one.
43 * For a saved plan, the _SPI_plan struct and the argument type array are in
44 * the plancxt (which can be really small). All the other subsidiary state
45 * is in plancache entries identified by plancache_list (note: the list cells
46 * themselves are in plancxt). We rely on plancache.c to keep the cache
47 * entries up-to-date as needed. The plancxt is a child of CacheMemoryContext
48 * since it should persist until explicitly destroyed.
50 * To avoid redundant coding, the representation of unsaved plans matches
51 * that of saved plans, ie, plancache_list is a list of CachedPlanSource
52 * structs which in turn point to CachedPlan structs. However, in an unsaved
53 * plan all these structs are just created by spi.c and are not known to
54 * plancache.c. We don't try very hard to make all their fields valid,
55 * only the ones spi.c actually uses.
57 * Note: if the original query string contained only whitespace and comments,
58 * the plancache_list will be NIL and so there is no place to store the
59 * query string. We don't care about that, but we do care about the
60 * argument type array, which is why it's seemingly-redundantly stored.
62 typedef struct _SPI_plan
64 int magic; /* should equal _SPI_PLAN_MAGIC */
65 bool saved; /* saved or unsaved plan? */
66 List *plancache_list; /* one CachedPlanSource per parsetree */
67 MemoryContext plancxt; /* Context containing _SPI_plan and data */
68 int cursor_options; /* Cursor options used for planning */
69 int nargs; /* number of plan arguments */
70 Oid *argtypes; /* Argument types (NULL if nargs is 0) */
71 } _SPI_plan;
73 #endif /* SPI_PRIV_H */