-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.71 2006/07/27 08:30:41 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.72 2006/08/08 01:23:15 momjian Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
<literal>UPDATE</>, <literal>DELETE</>, <literal>TRUNCATE</>,
and <literal>COPY FROM</>. <literal>PREPARE</> and
<literal>EXPLAIN ANALYZE</> statements are also logged if their
- contained command is of an appropriate type.
+ contained command is of an appropriate type. Protocol-level
+ prepare, bind, and execute commands are logged only if
+ <varname>log_statement</> is <literal>all</>. Bind parameter
+ values are also logged if they are supplied in <literal>text</>
+ format.
</para>
<para>
The default is <literal>none</>. Only superusers can change this
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.495 2006/08/06 02:00:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.496 2006/08/08 01:23:15 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
portal->visible = false;
PortalDefineQuery(portal,
+ NULL,
query_string,
commandTag,
querytree_list,
if (log_statement == LOGSTMT_ALL)
ereport(LOG,
- (errmsg("statement: <protocol> PREPARE %s AS %s",
+ (errmsg("prepare %s: %s",
*stmt_name ? stmt_name : "<unnamed>",
query_string)));
PreparedStatement *pstmt;
Portal portal;
ParamListInfo params;
+ StringInfoData str;
pgstat_report_activity("<BIND>");
/* Switch back to message context */
MemoryContextSwitchTo(MessageContext);
+ if (log_statement == LOGSTMT_ALL)
+ initStringInfo(&str);
+
/* Get the fixed part of the message */
portal_name = pq_getmsgstring(input_message);
stmt_name = pq_getmsgstring(input_message);
else
portal = CreatePortal(portal_name, false, false);
- /* We need to output the parameter values someday */
- if (log_statement == LOGSTMT_ALL)
- ereport(LOG,
- (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.
*/
else
pformat = 0; /* default = text */
- if (pformat == 0)
+ if (pformat == 0) /* text mode */
{
Oid typinput;
Oid typioparam;
pstring,
typioparam,
-1);
+
+ if (log_statement == LOGSTMT_ALL)
+ appendStringInfo(&str, "%s$%d = \"%s\"",
+ *str.data ? ", " : "", paramno + 1, pstring);
+
/* Free result of encoding conversion, if any */
if (pstring && pstring != pbuf.data)
pfree(pstring);
}
- else if (pformat == 1)
+ else if (pformat == 1) /* binary mode */
{
Oid typreceive;
Oid typioparam;
else
params = NULL;
+ if (log_statement == LOGSTMT_ALL)
+ {
+ if (*str.data)
+ ereport(LOG,
+ (errmsg("bind %s%s%s: %s",
+ *stmt_name ? stmt_name : "<unnamed>",
+ *portal->name ? "/" : "",
+ *portal->name ? portal->name : "",
+ pstmt->query_string ? pstmt->query_string : ""),
+ errdetail(str.data)));
+ else
+ ereport(LOG,
+ (errmsg("bind %s%s%s: %s",
+ *stmt_name ? stmt_name : "<unnamed>",
+ *portal->name ? "/" : "",
+ *portal->name ? portal->name : "",
+ pstmt->query_string ? pstmt->query_string : "")));
+ pfree(str.data);
+ }
+
/* Get the result format codes */
numRFormats = pq_getmsgint(input_message, 2);
if (numRFormats > 0)
* Define portal and start execution.
*/
PortalDefineQuery(portal,
+ *stmt_name ? pstrdup(stmt_name) : NULL,
pstmt->query_string,
pstmt->commandTag,
pstmt->query_list,
if (log_statement == LOGSTMT_ALL)
/* We have the portal, so output the source query. */
ereport(LOG,
- (errmsg("statement: <protocol> %sEXECUTE %s [PREPARE: %s]",
- execute_is_fetch ? "FETCH from " : "",
- *portal_name ? portal_name : "<unnamed>",
+ (errmsg("execute %s%s%s%s: %s",
+ execute_is_fetch ? "fetch from " : "",
+ portal->prepStmtName ? portal->prepStmtName : "<unnamed>",
+ *portal->name ? "/" : "",
+ *portal->name ? portal->name : "",
portal->sourceText ? portal->sourceText : "")));
BeginCommand(portal->commandTag, dest);
secs, msecs)));
else
ereport(LOG,
- (errmsg("duration: %ld.%03d ms statement: <protocol> %sEXECUTE %s [PREPARE: %s]",
+ (errmsg("duration: %ld.%03d ms execute %s%s%s%s: %s",
secs, msecs,
- execute_is_fetch ? "FETCH from " : "",
- *portal_name ? portal_name : "<unnamed>",
+ execute_is_fetch ? "fetch from " : "",
+ portal->prepStmtName ? portal->prepStmtName : "<unnamed>",
+ *portal->name ? "/" : "",
+ *portal->name ? portal->name : "",
portal->sourceText ? portal->sourceText : "")));
}
}
* 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.63 2006/07/13 18:01:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.64 2006/08/08 01:23:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
/* Bookkeeping data */
const char *name; /* portal's name */
+ const char *prepStmtName; /* protocol prepare name */
MemoryContext heap; /* subsidiary memory for portal */
ResourceOwner resowner; /* resources owned by portal */
void (*cleanup) (Portal portal); /* cleanup hook */
extern void DropDependentPortals(MemoryContext queryContext);
extern Portal GetPortalByName(const char *name);
extern void PortalDefineQuery(Portal portal,
+ const char *prepStmtName,
const char *sourceText,
const char *commandTag,
List *parseTrees,