~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/executor/spi_priv.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * spi_priv.h
 
4
 *                              Server Programming Interface private declarations
 
5
 *
 
6
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 * $PostgreSQL$
 
10
 *
 
11
 *-------------------------------------------------------------------------
 
12
 */
 
13
#ifndef SPI_PRIV_H
 
14
#define SPI_PRIV_H
 
15
 
 
16
#include "executor/spi.h"
 
17
 
 
18
 
 
19
#define _SPI_PLAN_MAGIC         569278163
 
20
 
 
21
typedef struct
 
22
{
 
23
        /* current results */
 
24
        uint32          processed;              /* by Executor */
 
25
        Oid                     lastoid;
 
26
        SPITupleTable *tuptable;
 
27
 
 
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;
 
33
 
 
34
/*
 
35
 * SPI plans have two states: saved or unsaved.
 
36
 *
 
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.
 
42
 *
 
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.
 
49
 *
 
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.
 
56
 *
 
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.
 
61
 */
 
62
typedef struct _SPI_plan
 
63
{
 
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;
 
72
 
 
73
#endif   /* SPI_PRIV_H */