Header And Logo

PostgreSQL
| The world's most advanced open source database.

prepare.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * prepare.h
00004  *    PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
00005  *
00006  *
00007  * Copyright (c) 2002-2013, PostgreSQL Global Development Group
00008  *
00009  * src/include/commands/prepare.h
00010  *
00011  *-------------------------------------------------------------------------
00012  */
00013 #ifndef PREPARE_H
00014 #define PREPARE_H
00015 
00016 #include "commands/explain.h"
00017 #include "datatype/timestamp.h"
00018 #include "utils/plancache.h"
00019 
00020 /*
00021  * The data structure representing a prepared statement.  This is now just
00022  * a thin veneer over a plancache entry --- the main addition is that of
00023  * a name.
00024  *
00025  * Note: all subsidiary storage lives in the referenced plancache entry.
00026  */
00027 typedef struct
00028 {
00029     /* dynahash.c requires key to be first field */
00030     char        stmt_name[NAMEDATALEN];
00031     CachedPlanSource *plansource;       /* the actual cached plan */
00032     bool        from_sql;       /* prepared via SQL, not FE/BE protocol? */
00033     TimestampTz prepare_time;   /* the time when the stmt was prepared */
00034 } PreparedStatement;
00035 
00036 
00037 /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
00038 extern void PrepareQuery(PrepareStmt *stmt, const char *queryString);
00039 extern void ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
00040              const char *queryString, ParamListInfo params,
00041              DestReceiver *dest, char *completionTag);
00042 extern void DeallocateQuery(DeallocateStmt *stmt);
00043 extern void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into,
00044                     ExplainState *es,
00045                     const char *queryString, ParamListInfo params);
00046 
00047 /* Low-level access to stored prepared statements */
00048 extern void StorePreparedStatement(const char *stmt_name,
00049                        CachedPlanSource *plansource,
00050                        bool from_sql);
00051 extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
00052                        bool throwError);
00053 extern void DropPreparedStatement(const char *stmt_name, bool showError);
00054 extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
00055 extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
00056 
00057 extern void DropAllPreparedStatements(void);
00058 
00059 #endif   /* PREPARE_H */