summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2003-05-05 00:44:56 +0000
committerTom Lane2003-05-05 00:44:56 +0000
commit16503e6fa4a13051debe09698b6db9ce0d509af8 (patch)
treeb8165b6e9481ec187aee0b54f0cb722915d1090a /src/include
parenta59793f82c8bb7d9931dab8675d91e06c1a41f5a (diff)
Extended query protocol: parse, bind, execute, describe FE/BE messages.
Only lightly tested as yet, since libpq doesn't know anything about 'em.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/printtup.h6
-rw-r--r--src/include/commands/portalcmds.h4
-rw-r--r--src/include/commands/prepare.h42
-rw-r--r--src/include/libpq/pqcomm.h4
-rw-r--r--src/include/tcop/dest.h10
-rw-r--r--src/include/tcop/tcopprot.h7
6 files changed, 58 insertions, 15 deletions
diff --git a/src/include/access/printtup.h b/src/include/access/printtup.h
index 728b0c89906..688a75cd2db 100644
--- a/src/include/access/printtup.h
+++ b/src/include/access/printtup.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: printtup.h,v 1.23 2003/01/21 22:06:12 tgl Exp $
+ * $Id: printtup.h,v 1.24 2003/05/05 00:44:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,7 +16,9 @@
#include "tcop/dest.h"
-extern DestReceiver *printtup_create_DR(bool isBinary);
+extern DestReceiver *printtup_create_DR(bool isBinary, bool sendDescrip);
+
+extern void SendRowDescriptionMessage(TupleDesc typeinfo);
extern void debugSetup(DestReceiver *self, int operation,
const char *portalName, TupleDesc typeinfo);
diff --git a/src/include/commands/portalcmds.h b/src/include/commands/portalcmds.h
index efa60869fa6..f89ac36fa57 100644
--- a/src/include/commands/portalcmds.h
+++ b/src/include/commands/portalcmds.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: portalcmds.h,v 1.8 2003/05/02 20:54:35 tgl Exp $
+ * $Id: portalcmds.h,v 1.9 2003/05/05 00:44:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,7 +22,7 @@ extern void PerformCursorOpen(DeclareCursorStmt *stmt, CommandDest dest);
extern void PerformPortalFetch(FetchStmt *stmt, CommandDest dest,
char *completionTag);
-extern void PerformPortalClose(char *name);
+extern void PerformPortalClose(const char *name);
extern void PortalCleanup(Portal portal, bool isError);
diff --git a/src/include/commands/prepare.h b/src/include/commands/prepare.h
index aad64166757..5d24c579a40 100644
--- a/src/include/commands/prepare.h
+++ b/src/include/commands/prepare.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* prepare.h
- * PREPARE, EXECUTE and DEALLOCATE command prototypes
+ * PREPARE, EXECUTE and DEALLOCATE commands, and prepared-stmt storage
*
*
- * Copyright (c) 2002, PostgreSQL Global Development Group
+ * Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
- * $Id: prepare.h,v 1.3 2003/02/02 23:46:38 tgl Exp $
+ * $Id: prepare.h,v 1.4 2003/05/05 00:44:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,10 +18,44 @@
#include "tcop/dest.h"
+/*
+ * 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 */
+ 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 */
+ List *plan_list; /* list of plans */
+ List *argtype_list; /* list of parameter type OIDs */
+ MemoryContext context; /* context containing this query */
+} PreparedStatement;
+
+
+/* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
extern void PrepareQuery(PrepareStmt *stmt);
extern void ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest);
extern void DeallocateQuery(DeallocateStmt *stmt);
-extern List *FetchQueryParams(const char *plan_name);
extern void ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate);
+/* Low-level access to stored prepared statements */
+extern void StorePreparedStatement(const char *stmt_name,
+ const char *query_string,
+ const char *commandTag,
+ List *query_list,
+ List *plan_list,
+ List *argtype_list);
+extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
+ bool throwError);
+extern void DropPreparedStatement(const char *stmt_name, bool showError);
+extern List *FetchPreparedStatementParams(const char *stmt_name);
+
#endif /* PREPARE_H */
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index d5374a68fe6..b6961e824cd 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.81 2003/04/26 20:22:59 tgl Exp $
+ * $Id: pqcomm.h,v 1.82 2003/05/05 00:44:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,7 +106,7 @@ typedef union SockAddr
/* The earliest and latest frontend/backend protocol version supported. */
#define PG_PROTOCOL_EARLIEST PG_PROTOCOL(1,0)
-#define PG_PROTOCOL_LATEST PG_PROTOCOL(3,105) /* XXX temporary value */
+#define PG_PROTOCOL_LATEST PG_PROTOCOL(3,106) /* XXX temporary value */
typedef uint32 ProtocolVersion; /* FE/BE protocol version number */
diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h
index 39063af6e16..5fbe9d33afe 100644
--- a/src/include/tcop/dest.h
+++ b/src/include/tcop/dest.h
@@ -44,7 +44,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dest.h,v 1.34 2003/04/19 00:02:30 tgl Exp $
+ * $Id: dest.h,v 1.35 2003/05/05 00:44:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,10 @@
/* ----------------
* CommandDest is a simplistic means of identifying the desired
* destination. Someday this will probably need to be improved.
+ *
+ * Note: only the values None, Debug, Remote are legal for the global
+ * variable whereToSendOutput. The other values may be selected
+ * as the destination for individual commands.
* ----------------
*/
typedef enum
@@ -71,7 +75,9 @@ typedef enum
RemoteInternal, /* results sent to frontend process in
* internal (binary) form */
SPI, /* results sent to SPI manager */
- Tuplestore /* results sent to Tuplestore */
+ Tuplestore, /* results sent to Tuplestore */
+ RemoteExecute, /* sent to frontend, in Execute command */
+ RemoteExecuteInternal /* same, but binary format */
} CommandDest;
/* ----------------
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index c1fa9c1a6d7..b5e171e1d36 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tcopprot.h,v 1.56 2003/05/02 20:54:36 tgl Exp $
+ * $Id: tcopprot.h,v 1.57 2003/05/05 00:44:56 tgl Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
@@ -35,11 +35,12 @@ extern DLLIMPORT const char *debug_query_string;
#ifndef BOOTSTRAP_INCLUDE
+extern List *pg_parse_and_rewrite(const char *query_string,
+ Oid *paramTypes, int numParams);
extern List *pg_parse_query(const char *query_string);
extern List *pg_analyze_and_rewrite(Node *parsetree,
Oid *paramTypes, int numParams);
-extern List *pg_parse_and_rewrite(const char *query_string,
- Oid *paramTypes, int numParams);
+extern List *pg_rewrite_queries(List *querytree_list);
extern Plan *pg_plan_query(Query *querytree);
extern List *pg_plan_queries(List *querytrees, bool needSnapshot);