Document that errors are not output by log_statement (was they were in
authorBruce Momjian
Tue, 18 Apr 2006 00:52:23 +0000 (00:52 +0000)
committerBruce Momjian
Tue, 18 Apr 2006 00:52:23 +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 3a827002f74a8e699b47baad4061fd2b6803cc8d..774aed66a82c3e9b5a5e4c3ff790fdfbfcdb2cc2 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
   Server Configuration
@@ -2758,9 +2758,10 @@ SELECT * FROM parent WHERE key = 2400;
        
         
          The EXECUTE statement is not considered a
-         ddl or mod statement.  When it is logged, 
-         only the name of the prepared statement is reported, not the
-         actual prepared statement.
+         ddl or mod statement.  Statements that
+         generate errors are not logged.  Set
+         log_min_error_statement to error to
+         log such statements.      
         
 
         
index df9ef8983a041145560f67c1523dba3e0cf48560..3c24fa532a6bd089e69ce8b1170c7d62b2f9feea 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.483 2006/04/04 19:35:35 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.484 2006/04/18 00:52:23 momjian Exp $
  *
  * NOTES
  *   this is the "main" module of the postgres backend and
@@ -586,19 +586,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("  [protocol PREPARE:  %s]") - 1);
-               sprintf(*prepare_string, "  [protocol PREPARE:  %s]",
+                                     strlen("  [PREPARE:  %s]") - 2 + 1);
+               sprintf(*prepare_string, "  [PREPARE:  %s]",
                        entry->query_string);
            }
        }