PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, PostgreSQL Global Development Group
8 *
9 * src/include/commands/prepare.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PREPARE_H
14#define PREPARE_H
15
17#include "datatype/timestamp.h"
18#include "tcop/dest.h"
19#include "utils/plancache.h"
20
21/*
22 * The data structure representing a prepared statement. This is now just
23 * a thin veneer over a plancache entry --- the main addition is that of
24 * a name.
25 *
26 * Note: all subsidiary storage lives in the referenced plancache entry.
27 */
28typedef struct
29{
30 /* dynahash.c requires key to be first field */
31 char stmt_name[NAMEDATALEN];
32 CachedPlanSource *plansource; /* the actual cached plan */
33 bool from_sql; /* prepared via SQL, not FE/BE protocol? */
34 TimestampTz prepare_time; /* the time when the stmt was prepared */
36
37
38/* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
39extern void PrepareQuery(ParseState *pstate, PrepareStmt *stmt,
40 int stmt_location, int stmt_len);
41extern void ExecuteQuery(ParseState *pstate,
42 ExecuteStmt *stmt, IntoClause *intoClause,
43 ParamListInfo params,
46extern void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into,
47 ExplainState *es, ParseState *pstate,
48 ParamListInfo params);
49
50/* Low-level access to stored prepared statements */
51extern void StorePreparedStatement(const char *stmt_name,
52 CachedPlanSource *plansource,
53 bool from_sql);
54extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
55 bool throwError);
56extern void DropPreparedStatement(const char *stmt_name, bool showError);
59
60extern void DropAllPreparedStatements(void);
61
62#endif /* PREPARE_H */
int64 TimestampTz
Definition: timestamp.h:39
#define stmt
Definition: indent_codes.h:59
#define NAMEDATALEN
void DropPreparedStatement(const char *stmt_name, bool showError)
Definition: prepare.c:520
void PrepareQuery(ParseState *pstate, PrepareStmt *stmt, int stmt_location, int stmt_len)
Definition: prepare.c:59
TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt)
Definition: prepare.c:467
PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)
Definition: prepare.c:435
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, ParseState *pstate, ParamListInfo params)
Definition: prepare.c:572
void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)
Definition: prepare.c:393
void ExecuteQuery(ParseState *pstate, ExecuteStmt *stmt, IntoClause *intoClause, ParamListInfo params, DestReceiver *dest, QueryCompletion *qc)
Definition: prepare.c:150
void DropAllPreparedStatements(void)
Definition: prepare.c:541
List * FetchPreparedStatementTargetList(PreparedStatement *stmt)
Definition: prepare.c:490
void DeallocateQuery(DeallocateStmt *stmt)
Definition: prepare.c:506
Definition: pg_list.h:54
TimestampTz prepare_time
Definition: prepare.h:34
CachedPlanSource * plansource
Definition: prepare.h:32