aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.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/tcop/postgres.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/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index a7dd5cb904a..c9ba35f7bde 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.336 2003/05/06 20:26:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.337 2003/05/06 21:51:41 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -1428,6 +1428,7 @@ static void
exec_describe_statement_message(const char *stmt_name)
{
PreparedStatement *pstmt;
+ TupleDesc tupdesc;
List *l;
StringInfoData buf;
@@ -1445,6 +1446,9 @@ exec_describe_statement_message(const char *stmt_name)
if (whereToSendOutput != Remote)
return; /* can't actually do anything... */
+ /*
+ * First describe the parameters...
+ */
pq_beginmessage(&buf, 't'); /* parameter description message type */
pq_sendint(&buf, length(pstmt->argtype_list), 4);
@@ -1455,6 +1459,24 @@ exec_describe_statement_message(const char *stmt_name)
pq_sendint(&buf, (int) ptype, 4);
}
pq_endmessage(&buf);
+
+ /*
+ * Next send RowDescription or NoData to describe the result...
+ */
+ tupdesc = FetchPreparedStatementResultDesc(pstmt);
+ if (tupdesc)
+ {
+ List *targetlist;
+
+ if (ChoosePortalStrategy(pstmt->query_list) == PORTAL_ONE_SELECT)
+ targetlist = ((Query *) lfirst(pstmt->query_list))->targetList;
+ else
+ targetlist = NIL;
+ SendRowDescriptionMessage(tupdesc, targetlist);
+ }
+ else
+ pq_putemptymessage('n'); /* NoData */
+
}
/*
@@ -2359,7 +2381,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.336 $ $Date: 2003/05/06 20:26:27 $\n");
+ puts("$Revision: 1.337 $ $Date: 2003/05/06 21:51:41 $\n");
}
/*