From 11b5c554c28b4a45cdc6b7555e90d701c40f3971 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Fri, 2 Sep 2005 21:50:54 +0000
Subject: [PATCH] Add log display label for unnamed server-side portals.

---
 src/backend/tcop/postgres.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index aa0da207a3a..f7d21c23621 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.457 2005/08/11 21:11:45 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.458 2005/09/02 21:50:54 momjian Exp $
  *
  * NOTES
  *	  this is the "main" module of the postgres backend and
@@ -1164,7 +1164,9 @@ exec_parse_message(const char *query_string,	/* string to execute */
 
 	if (log_statement == LOGSTMT_ALL)
 		ereport(LOG,
-				(errmsg("statement: PREPARE %s AS %s", stmt_name, query_string)));
+				(errmsg("statement: PREPARE %s AS %s",
+						(*stmt_name != '\0') ? stmt_name : "<unnamed>",
+						query_string)));
 
 	/*
 	 * Start up a transaction command so we can run parse analysis etc.
@@ -1732,7 +1734,8 @@ exec_execute_message(const char *portal_name, long max_rows)
 	if (log_statement == LOGSTMT_ALL)
 		/* We have the portal, so output the source query. */
 		ereport(LOG,
-				(errmsg("statement: EXECUTE %s  [PREPARE:  %s]", portal_name,
+				(errmsg("statement: EXECUTE %s  [PREPARE:  %s]",
+						(*portal_name != '\0') ? portal_name : "<unnamed>",
 						portal->sourceText ? portal->sourceText : "")));
 
 	BeginCommand(portal->commandTag, dest);
@@ -1867,7 +1870,7 @@ exec_execute_message(const char *portal_name, long max_rows)
 						(long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
 							  (stop_t.tv_usec - start_t.tv_usec) / 1000),
 						(long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
-							portal_name,
+							(*portal_name != '\0') ? portal_name : "<unnamed>",
 							portal->sourceText ? portal->sourceText : "")));
 	}
 
-- 
GitLab