PostgreSQL Source Code  git master
prepare.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * prepare.h
4  * PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
5  *
6  *
7  * Copyright (c) 2002-2017, PostgreSQL Global Development Group
8  *
9  * src/include/commands/prepare.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PREPARE_H
14 #define PREPARE_H
15 
16 #include "commands/explain.h"
17 #include "datatype/timestamp.h"
18 #include "utils/plancache.h"
19 
20 /*
21  * The data structure representing a prepared statement. This is now just
22  * a thin veneer over a plancache entry --- the main addition is that of
23  * a name.
24  *
25  * Note: all subsidiary storage lives in the referenced plancache entry.
26  */
27 typedef struct
28 {
29  /* dynahash.c requires key to be first field */
30  char stmt_name[NAMEDATALEN];
31  CachedPlanSource *plansource; /* the actual cached plan */
32  bool from_sql; /* prepared via SQL, not FE/BE protocol? */
33  TimestampTz prepare_time; /* the time when the stmt was prepared */
35 
36 
37 /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
38 extern void PrepareQuery(PrepareStmt *stmt, const char *queryString,
39  int stmt_location, int stmt_len);
40 extern void ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
41  const char *queryString, ParamListInfo params,
42  DestReceiver *dest, char *completionTag);
43 extern void DeallocateQuery(DeallocateStmt *stmt);
44 extern void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into,
45  ExplainState *es, const char *queryString,
46  ParamListInfo params, QueryEnvironment *queryEnv);
47 
48 /* Low-level access to stored prepared statements */
49 extern void StorePreparedStatement(const char *stmt_name,
50  CachedPlanSource *plansource,
51  bool from_sql);
52 extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
53  bool throwError);
54 extern void DropPreparedStatement(const char *stmt_name, bool showError);
57 
58 extern void DropAllPreparedStatements(void);
59 
60 #endif /* PREPARE_H */
PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)
Definition: prepare.c:494
CachedPlanSource * plansource
Definition: prepare.h:31
int64 TimestampTz
Definition: timestamp.h:39
void ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause, const char *queryString, ParamListInfo params, DestReceiver *dest, char *completionTag)
Definition: prepare.c:200
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: prepare.c:631
void DropAllPreparedStatements(void)
Definition: prepare.c:600
#define NAMEDATALEN
TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt)
Definition: prepare.c:526
void DeallocateQuery(DeallocateStmt *stmt)
Definition: prepare.c:565
void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)
Definition: prepare.c:452
List * FetchPreparedStatementTargetList(PreparedStatement *stmt)
Definition: prepare.c:549
void PrepareQuery(PrepareStmt *stmt, const char *queryString, int stmt_location, int stmt_len)
Definition: prepare.c:57
TimestampTz prepare_time
Definition: prepare.h:33
void DropPreparedStatement(const char *stmt_name, bool showError)
Definition: prepare.c:579
Definition: pg_list.h:45