Improve logging of protocol-level prepared statements.
authorBruce Momjian <bruce@momjian.us>
Fri, 4 Aug 2006 18:53:46 +0000 (18:53 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 4 Aug 2006 18:53:46 +0000 (18:53 +0000)
src/backend/tcop/postgres.c

index 42e42ee3ee680eb54d7aa4af02ce50c2df8b984b..a0df69217fc8c1abeedeb44cf7c2c217725eec29 100644 (file)
@@ -1146,8 +1146,8 @@ exec_parse_message(const char *query_string,      /* string to execute */
 
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
-                               (errmsg("statement: [protocol] PREPARE %s AS %s",
-                                               (*stmt_name != '\0') ? stmt_name : "<unnamed>",
+                               (errmsg("statement: <protocol> PREPARE %s AS %s",
+                                               *stmt_name ? stmt_name : "<unnamed>",
                                                query_string)));
 
        /*
@@ -1452,7 +1452,9 @@ exec_bind_message(StringInfo input_message)
        /* We need to output the parameter values someday */
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
-                               (errmsg("statement: [protocol] <BIND> %s", portal_name)));
+                               (errmsg("statement: <protocol> <BIND> %s  [PREPARE:  %s]",
+                                               *portal_name ? portal_name : "<unnamed>",
+                                               portal->sourceText ? portal->sourceText : "")));
 
        /*
         * Fetch parameters, if any, and store in the portal's memory context.
@@ -1718,9 +1720,9 @@ 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: [protocol] %sEXECUTE %s  [PREPARE:  %s]",
+                               (errmsg("statement: <protocol> %sEXECUTE %s  [PREPARE:  %s]",
                                                execute_is_fetch ? "FETCH from " : "",
-                                               (*portal_name) ? portal_name : "<unnamed>",
+                                               *portal_name ? portal_name : "<unnamed>",
                                                portal->sourceText ? portal->sourceText : "")));
 
        BeginCommand(portal->commandTag, dest);
@@ -1826,11 +1828,11 @@ exec_execute_message(const char *portal_name, long max_rows)
                                                                secs, msecs)));
                        else
                                ereport(LOG,
-                                               (errmsg("duration: %ld.%03d ms  statement: [protocol] %sEXECUTE %s  [PREPARE:  %s]",
+                                               (errmsg("duration: %ld.%03d ms  statement: <protocol> %sEXECUTE %s  [PREPARE:  %s]",
                                                                secs, msecs,
                                                                execute_is_fetch ? "FETCH from " : "",
-                                                               (*portal_name) ? portal_name : "<unnamed>",
-                                                       portal->sourceText ? portal->sourceText : "")));
+                                                               *portal_name ? portal_name : "<unnamed>",
+                                                               portal->sourceText ? portal->sourceText : "")));
                }
        }