Document that errors are not output by log_statement (was they were in
authorBruce Momjian <[email protected]>
Tue, 18 Apr 2006 00:52:41 +0000 (00:52 +0000)
committerBruce Momjian <[email protected]>
Tue, 18 Apr 2006 00:52:41 +0000 (00:52 +0000)
8.0), and add as suggestion to use log_min_error_statement for this
purpose.  I also fixed the code so the first EXECUTE has it's prepare,
rather than the last which is what was in the current code.  Also remove
"protocol" prefix for SQL EXECUTE output because it is not accurate.

Backpatch to 8.1.X.

doc/src/sgml/config.sgml
src/backend/tcop/postgres.c

index b617dfa814752b62494ff4da24c4ab75ef03640e..55d8a6975b5b0e6ba87eb458475a8d92cda14ffc 100644 (file)
@@ -2729,9 +2729,10 @@ SELECT * FROM parent WHERE key = 2400;
        <note>
         <para>
          The <command>EXECUTE</command> statement is not considered a
-         <literal>ddl</> or <literal>mod</> statement.  When it is logged, 
-         only the name of the prepared statement is reported, not the
-         actual prepared statement.
+         <literal>ddl</> or <literal>mod</> statement.  Statements that
+         generate errors are not logged.  Set
+         <varname>log_min_error_statement</> to <literal>error</> to
+         log such statements.      
         </para>
 
         <para>
index 33c5b1d81ca74164dbee016143c49695c88aa70e..6248a8651ce2bbb792e0d20ca16059272fa9e021 100644 (file)
@@ -578,19 +578,21 @@ log_after_parse(List *raw_parsetree_list, const char *query_string,
 
                /*
                 * For the first EXECUTE we find, record the client statement used by
-                * the PREPARE.
+                * the PREPARE.  PREPARE doesn't save the parse tree so we have no
+                * way to conditionally output based on the type of query prepared.
                 */
                if (IsA(parsetree, ExecuteStmt))
                {
                        ExecuteStmt *stmt = (ExecuteStmt *) parsetree;
                        PreparedStatement *entry;
 
-                       if ((entry = FetchPreparedStatement(stmt->name, false)) != NULL &&
+                       if (*prepare_string == NULL &&
+                               (entry = FetchPreparedStatement(stmt->name, false)) != NULL &&
                                entry->query_string)
                        {
                                *prepare_string = palloc(strlen(entry->query_string) +
-                                                                         strlen("  [client PREPARE:  %s]") - 1);
-                               sprintf(*prepare_string, "  [client PREPARE:  %s]",
+                                                                         strlen("  [PREPARE:  %s]") - 2 + 1);
+                               sprintf(*prepare_string, "  [PREPARE:  %s]",
                                                entry->query_string);
                        }
                }