88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.495 2006/08/06 02:00:52 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.496 2006/08/08 01:23:15 momjian Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -955,6 +955,7 @@ exec_simple_query(const char *query_string)
955955portal -> visible = false;
956956
957957PortalDefineQuery (portal ,
958+ NULL ,
958959query_string ,
959960commandTag ,
960961querytree_list ,
@@ -1146,7 +1147,7 @@ exec_parse_message(const char *query_string,/* string to execute */
11461147
11471148if (log_statement == LOGSTMT_ALL )
11481149ereport (LOG ,
1149- (errmsg ("statement: <protocol> PREPARE %s AS %s" ,
1150+ (errmsg ("prepare %s: %s" ,
11501151* stmt_name ?stmt_name :"<unnamed>" ,
11511152query_string )));
11521153
@@ -1367,6 +1368,7 @@ exec_bind_message(StringInfo input_message)
13671368PreparedStatement * pstmt ;
13681369Portal portal ;
13691370ParamListInfo params ;
1371+ StringInfoData str ;
13701372
13711373pgstat_report_activity ("<BIND>" );
13721374
@@ -1382,6 +1384,9 @@ exec_bind_message(StringInfo input_message)
13821384/* Switch back to message context */
13831385MemoryContextSwitchTo (MessageContext );
13841386
1387+ if (log_statement == LOGSTMT_ALL )
1388+ initStringInfo (& str );
1389+
13851390/* Get the fixed part of the message */
13861391portal_name = pq_getmsgstring (input_message );
13871392stmt_name = pq_getmsgstring (input_message );
@@ -1450,13 +1455,6 @@ exec_bind_message(StringInfo input_message)
14501455else
14511456portal = CreatePortal (portal_name , false, false);
14521457
1453- /* We need to output the parameter values someday */
1454- if (log_statement == LOGSTMT_ALL )
1455- ereport (LOG ,
1456- (errmsg ("statement: <protocol> <BIND> %s [PREPARE: %s]" ,
1457- * portal_name ?portal_name :"<unnamed>" ,
1458- portal -> sourceText ?portal -> sourceText :"" )));
1459-
14601458/*
14611459 * Fetch parameters, if any, and store in the portal's memory context.
14621460 */
@@ -1519,7 +1517,7 @@ exec_bind_message(StringInfo input_message)
15191517else
15201518pformat = 0 ;/* default = text */
15211519
1522- if (pformat == 0 )
1520+ if (pformat == 0 )/* text mode */
15231521{
15241522Oid typinput ;
15251523Oid typioparam ;
@@ -1540,11 +1538,16 @@ exec_bind_message(StringInfo input_message)
15401538pstring ,
15411539typioparam ,
15421540-1 );
1541+
1542+ if (log_statement == LOGSTMT_ALL )
1543+ appendStringInfo (& str ,"%s$%d = \"%s\"" ,
1544+ * str .data ?", " :"" ,paramno + 1 ,pstring );
1545+
15431546/* Free result of encoding conversion, if any */
15441547if (pstring && pstring != pbuf .data )
15451548pfree (pstring );
15461549}
1547- else if (pformat == 1 )
1550+ else if (pformat == 1 )/* binary mode */
15481551{
15491552Oid typreceive ;
15501553Oid typioparam ;
@@ -1595,6 +1598,26 @@ exec_bind_message(StringInfo input_message)
15951598else
15961599params = NULL ;
15971600
1601+ if (log_statement == LOGSTMT_ALL )
1602+ {
1603+ if (* str .data )
1604+ ereport (LOG ,
1605+ (errmsg ("bind %s%s%s: %s" ,
1606+ * stmt_name ?stmt_name :"<unnamed>" ,
1607+ * portal -> name ?"/" :"" ,
1608+ * portal -> name ?portal -> name :"" ,
1609+ pstmt -> query_string ?pstmt -> query_string :"" ),
1610+ errdetail (str .data )));
1611+ else
1612+ ereport (LOG ,
1613+ (errmsg ("bind %s%s%s: %s" ,
1614+ * stmt_name ?stmt_name :"<unnamed>" ,
1615+ * portal -> name ?"/" :"" ,
1616+ * portal -> name ?portal -> name :"" ,
1617+ pstmt -> query_string ?pstmt -> query_string :"" )));
1618+ pfree (str .data );
1619+ }
1620+
15981621/* Get the result format codes */
15991622numRFormats = pq_getmsgint (input_message ,2 );
16001623if (numRFormats > 0 )
@@ -1628,6 +1651,7 @@ exec_bind_message(StringInfo input_message)
16281651 * Define portal and start execution.
16291652 */
16301653PortalDefineQuery (portal ,
1654+ * stmt_name ?pstrdup (stmt_name ) :NULL ,
16311655pstmt -> query_string ,
16321656pstmt -> commandTag ,
16331657pstmt -> query_list ,
@@ -1724,9 +1748,11 @@ exec_execute_message(const char *portal_name, long max_rows)
17241748if (log_statement == LOGSTMT_ALL )
17251749/* We have the portal, so output the source query. */
17261750ereport (LOG ,
1727- (errmsg ("statement: <protocol> %sEXECUTE %s [PREPARE: %s]" ,
1728- execute_is_fetch ?"FETCH from " :"" ,
1729- * portal_name ?portal_name :"<unnamed>" ,
1751+ (errmsg ("execute %s%s%s%s: %s" ,
1752+ execute_is_fetch ?"fetch from " :"" ,
1753+ portal -> prepStmtName ?portal -> prepStmtName :"<unnamed>" ,
1754+ * portal -> name ?"/" :"" ,
1755+ * portal -> name ?portal -> name :"" ,
17301756portal -> sourceText ?portal -> sourceText :"" )));
17311757
17321758BeginCommand (portal -> commandTag ,dest );
@@ -1832,10 +1858,12 @@ exec_execute_message(const char *portal_name, long max_rows)
18321858secs ,msecs )));
18331859else
18341860ereport (LOG ,
1835- (errmsg ("duration: %ld.%03d msstatement: <protocol> %sEXECUTE %s [PREPARE : %s] " ,
1861+ (errmsg ("duration: %ld.%03d msexecute %s%s%s%s : %s" ,
18361862secs ,msecs ,
1837- execute_is_fetch ?"FETCH from " :"" ,
1838- * portal_name ?portal_name :"<unnamed>" ,
1863+ execute_is_fetch ?"fetch from " :"" ,
1864+ portal -> prepStmtName ?portal -> prepStmtName :"<unnamed>" ,
1865+ * portal -> name ?"/" :"" ,
1866+ * portal -> name ?portal -> name :"" ,
18391867portal -> sourceText ?portal -> sourceText :"" )));
18401868}
18411869}