aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/prepare.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-06 21:51:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-06 21:51:42 +0000
commit755d19170095ae6a775046b8bc97cb070bdc7582 (patch)
tree1868e53af5ae170402bec9c8c7d6360a2fb7bc96 /src/backend/commands/prepare.c
parent8f6a6b7e9a48d04bc6912a968326277547dc7927 (diff)
downloadpostgresql-755d19170095ae6a775046b8bc97cb070bdc7582.tar.gz
postgresql-755d19170095ae6a775046b8bc97cb070bdc7582.zip
Add display of eventual result RowDescription (if any) to the output
of Describe on a prepared statement. This was in the original 3.0 protocol proposal, but I took it out for reasons that seemed good at the time. Put it back per yesterday's pghackers discussion.
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r--src/backend/commands/prepare.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index c317494f6fa..6e16853fd78 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -10,7 +10,7 @@
* Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.16 2003/05/06 20:26:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.17 2003/05/06 21:51:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -394,6 +394,34 @@ FetchPreparedStatementParams(const char *stmt_name)
}
/*
+ * Given a prepared statement, determine the result tupledesc it will
+ * produce. Returns NULL if the execution will not return tuples.
+ *
+ * Note: the result is created or copied into current memory context.
+ */
+TupleDesc
+FetchPreparedStatementResultDesc(PreparedStatement *stmt)
+{
+ Query *query;
+
+ switch (ChoosePortalStrategy(stmt->query_list))
+ {
+ case PORTAL_ONE_SELECT:
+ query = (Query *) lfirst(stmt->query_list);
+ return ExecCleanTypeFromTL(query->targetList, false);
+
+ case PORTAL_UTIL_SELECT:
+ query = (Query *) lfirst(stmt->query_list);
+ return UtilityTupleDescriptor(query->utilityStmt);
+
+ case PORTAL_MULTI_QUERY:
+ /* will not return tuples */
+ break;
+ }
+ return NULL;
+}
+
+/*
* Implements the 'DEALLOCATE' utility statement: deletes the
* specified plan from storage.
*/