From: Bruce Momjian Date: Tue, 18 Apr 2006 00:52:41 +0000 (+0000) Subject: Document that errors are not output by log_statement (was they were in X-Git-Tag: REL8_1_4~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65f1a7a8dcd67735c8e1efadd4b4d30a745dc39c;p=postgresql Document that errors are not output by log_statement (was they were in 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. --- diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 37dbaddf7c..7e40c6922d 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1,5 +1,5 @@ Server Configuration @@ -2729,9 +2729,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. diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index b790d04483..329ba44524 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.468.2.3 2005/12/14 17:06:37 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.468.2.4 2006/04/18 00:52:41 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -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); } }