2002-08-27 06:55:12 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* prepare.h
|
2003-05-05 02:44:56 +02:00
|
|
|
* PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
|
2002-08-27 06:55:12 +02:00
|
|
|
*
|
|
|
|
*
|
2006-03-05 16:59:11 +01:00
|
|
|
* Copyright (c) 2002-2006, PostgreSQL Global Development Group
|
2002-08-27 06:55:12 +02:00
|
|
|
*
|
2006-04-25 16:11:59 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.20 2006/04/25 14:11:59 momjian Exp $
|
2002-08-27 06:55:12 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef PREPARE_H
|
|
|
|
#define PREPARE_H
|
|
|
|
|
2003-02-03 00:46:38 +01:00
|
|
|
#include "executor/executor.h"
|
2002-08-27 06:55:12 +02:00
|
|
|
#include "nodes/parsenodes.h"
|
|
|
|
#include "tcop/dest.h"
|
|
|
|
|
|
|
|
|
2003-05-05 02:44:56 +02:00
|
|
|
/*
|
|
|
|
* The data structure representing a prepared statement
|
|
|
|
*
|
|
|
|
* Note: all subsidiary storage lives in the context denoted by the context
|
|
|
|
* field. However, the string referenced by commandTag is not subsidiary
|
|
|
|
* storage; it is assumed to be a compile-time-constant string. As with
|
|
|
|
* portals, commandTag shall be NULL if and only if the original query string
|
|
|
|
* (before rewriting) was an empty string.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* dynahash.c requires key to be first field */
|
2006-01-08 08:00:27 +01:00
|
|
|
char stmt_name[NAMEDATALEN];
|
|
|
|
char *query_string; /* text of query, or NULL */
|
|
|
|
const char *commandTag; /* command tag (a constant!), or NULL */
|
|
|
|
List *query_list; /* list of queries, rewritten */
|
|
|
|
List *plan_list; /* list of plans */
|
|
|
|
List *argtype_list; /* list of parameter type OIDs */
|
|
|
|
TimestampTz prepare_time; /* the time when the stmt was prepared */
|
|
|
|
bool from_sql; /* stmt prepared via SQL, not
|
|
|
|
* FE/BE protocol? */
|
|
|
|
MemoryContext context; /* context containing this query */
|
2003-08-08 23:42:59 +02:00
|
|
|
} PreparedStatement;
|
2003-05-05 02:44:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
|
2002-08-27 06:55:12 +02:00
|
|
|
extern void PrepareQuery(PrepareStmt *stmt);
|
2005-11-29 02:25:50 +01:00
|
|
|
extern void ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
|
|
|
|
DestReceiver *dest, char *completionTag);
|
2002-08-27 06:55:12 +02:00
|
|
|
extern void DeallocateQuery(DeallocateStmt *stmt);
|
2005-11-29 02:25:50 +01:00
|
|
|
extern void ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
|
|
|
|
TupOutputState *tstate);
|
2002-08-27 06:55:12 +02:00
|
|
|
|
2003-05-05 02:44:56 +02:00
|
|
|
/* Low-level access to stored prepared statements */
|
|
|
|
extern void StorePreparedStatement(const char *stmt_name,
|
2003-08-04 02:43:34 +02:00
|
|
|
const char *query_string,
|
|
|
|
const char *commandTag,
|
|
|
|
List *query_list,
|
|
|
|
List *plan_list,
|
2006-01-08 08:00:27 +01:00
|
|
|
List *argtype_list,
|
|
|
|
bool from_sql);
|
2003-05-05 02:44:56 +02:00
|
|
|
extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
|
2003-08-04 02:43:34 +02:00
|
|
|
bool throwError);
|
2003-05-05 02:44:56 +02:00
|
|
|
extern void DropPreparedStatement(const char *stmt_name, bool showError);
|
|
|
|
extern List *FetchPreparedStatementParams(const char *stmt_name);
|
2003-08-08 23:42:59 +02:00
|
|
|
extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
|
2005-12-14 18:06:28 +01:00
|
|
|
extern bool PreparedStatementReturnsTuples(PreparedStatement *stmt);
|
2005-06-22 19:45:46 +02:00
|
|
|
extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
|
2003-05-05 02:44:56 +02:00
|
|
|
|
2002-09-04 22:31:48 +02:00
|
|
|
#endif /* PREPARE_H */
|