diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-09-07 22:52:01 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-09-07 22:52:01 +0000 |
commit | 893632be4e17ccd791cfda17d2e99bb2312f6ff8 (patch) | |
tree | eb97eafe66b6413bbf910916f4150d76c05f3c47 /src/include/utils/portal.h | |
parent | b6eab50ce4d49fbbbc7cd9dba32ce86afb3f8c4a (diff) | |
download | postgresql-893632be4e17ccd791cfda17d2e99bb2312f6ff8.tar.gz postgresql-893632be4e17ccd791cfda17d2e99bb2312f6ff8.zip |
Clean up logging for extended-query-protocol operations, as per my recent
proposal. Parameter logging works even for binary-format parameters, and
logging overhead is avoided when disabled.
log_statement = all output for the src/test/examples/testlibpq3.c example
now looks like
LOG: statement: execute <unnamed>: SELECT * FROM test1 WHERE t = $1
DETAIL: parameters: $1 = 'joe''s place'
LOG: statement: execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
DETAIL: parameters: $1 = '2'
and log_min_duration_statement = 0 results in
LOG: duration: 2.431 ms parse <unnamed>: SELECT * FROM test1 WHERE t = $1
LOG: duration: 2.335 ms bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE t = $1
DETAIL: parameters: $1 = 'joe''s place'
LOG: duration: 0.394 ms execute <unnamed>: SELECT * FROM test1 WHERE t = $1
DETAIL: parameters: $1 = 'joe''s place'
LOG: duration: 1.251 ms parse <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
LOG: duration: 0.566 ms bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
DETAIL: parameters: $1 = '2'
LOG: duration: 0.173 ms execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
DETAIL: parameters: $1 = '2'
(This example demonstrates the folly of ignoring parse/bind steps for duration
logging purposes, BTW.)
Along the way, create a less ad-hoc mechanism for determining which commands
are logged by log_statement = mod and log_statement = ddl. The former coding
was actually missing quite a few things that look like ddl to me, and it
did not handle EXECUTE or extended query protocol correctly at all.
This commit does not do anything about the question of whether log_duration
should be removed or made less redundant with log_min_duration_statement.
Diffstat (limited to 'src/include/utils/portal.h')
-rw-r--r-- | src/include/utils/portal.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 4a546bdda96..a377b0ca21a 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -39,7 +39,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.69 2006/09/03 03:19:45 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.70 2006/09/07 22:52:01 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -110,7 +110,7 @@ typedef struct PortalData { /* Bookkeeping data */ const char *name; /* portal's name */ - const char *prepStmtName; /* protocol prepare name */ + const char *prepStmtName; /* source prepared statement (NULL if none) */ MemoryContext heap; /* subsidiary memory for portal */ ResourceOwner resowner; /* resources owned by portal */ void (*cleanup) (Portal portal); /* cleanup hook */ @@ -122,20 +122,20 @@ typedef struct PortalData */ /* The query or queries the portal will execute */ - const char *sourceText; /* text of query, if known, might be NULL */ - const char *bindText; /* text of bind parameters, might be NULL */ + const char *sourceText; /* text of query, if known (may be NULL) */ const char *commandTag; /* command tag for original query */ List *parseTrees; /* parse tree(s) */ List *planTrees; /* plan tree(s) */ - MemoryContext queryContext; /* where the above trees live */ + MemoryContext queryContext; /* where the parse trees live */ /* * Note: queryContext effectively identifies which prepared statement the * portal depends on, if any. The queryContext is *not* owned by the * portal and is not to be deleted by portal destruction. (But for a * cursor it is the same as "heap", and that context is deleted by portal - * destruction.) + * destruction.) The plan trees may be in either queryContext or heap. */ + ParamListInfo portalParams; /* params to pass to query */ /* Features/options */ @@ -216,7 +216,6 @@ extern Portal GetPortalByName(const char *name); extern void PortalDefineQuery(Portal portal, const char *prepStmtName, const char *sourceText, - const char *bindText, const char *commandTag, List *parseTrees, List *planTrees, |