1 /*-------------------------------------------------------------------------
4 * PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
7 * Copyright (c) 2002-2007, PostgreSQL Global Development Group
9 * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.23 2007/01/05 22:19:53 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include "executor/executor.h"
17 #include "utils/timestamp.h"
20 * The data structure representing a prepared statement
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.
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 */
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);
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,
59 extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
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);
67 #endif /* PREPARE_H */