]> granicus.if.org Git - postgresql/blob - src/include/commands/prepare.h
Update CVS HEAD for 2007 copyright. Back branches are typically not
[postgresql] / src / include / commands / prepare.h
1 /*-------------------------------------------------------------------------
2  *
3  * prepare.h
4  *        PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
5  *
6  *
7  * Copyright (c) 2002-2007, PostgreSQL Global Development Group
8  *
9  * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.23 2007/01/05 22:19:53 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PREPARE_H
14 #define PREPARE_H
15
16 #include "executor/executor.h"
17 #include "utils/timestamp.h"
18
19 /*
20  * The data structure representing a prepared statement
21  *
22  * Note: all subsidiary storage lives in the context denoted by the context
23  * field.  However, the string referenced by commandTag is not subsidiary
24  * storage; it is assumed to be a compile-time-constant string.  As with
25  * portals, commandTag shall be NULL if and only if the original query string
26  * (before rewriting) was an empty string.
27  */
28 typedef struct
29 {
30         /* dynahash.c requires key to be first field */
31         char            stmt_name[NAMEDATALEN];
32         char       *query_string;       /* text of query, or NULL */
33         const char *commandTag;         /* command tag (a constant!), or NULL */
34         List       *query_list;         /* list of queries, rewritten */
35         List       *plan_list;          /* list of plans */
36         List       *argtype_list;       /* list of parameter type OIDs */
37         TimestampTz prepare_time;       /* the time when the stmt was prepared */
38         bool            from_sql;               /* stmt prepared via SQL, not FE/BE protocol? */
39         MemoryContext context;          /* context containing this query */
40 } PreparedStatement;
41
42
43 /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
44 extern void PrepareQuery(PrepareStmt *stmt);
45 extern void ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
46                          DestReceiver *dest, char *completionTag);
47 extern void DeallocateQuery(DeallocateStmt *stmt);
48 extern void ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
49                                         TupOutputState *tstate);
50
51 /* Low-level access to stored prepared statements */
52 extern void StorePreparedStatement(const char *stmt_name,
53                                            const char *query_string,
54                                            const char *commandTag,
55                                            List *query_list,
56                                            List *plan_list,
57                                            List *argtype_list,
58                                            bool from_sql);
59 extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
60                                            bool throwError);
61 extern void DropPreparedStatement(const char *stmt_name, bool showError);
62 extern List *FetchPreparedStatementParams(const char *stmt_name);
63 extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
64 extern bool PreparedStatementReturnsTuples(PreparedStatement *stmt);
65 extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
66
67 #endif   /* PREPARE_H */