8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
@@ -955,6 +955,7 @@ exec_simple_query(const char *query_string)
955
955
portal -> visible = false;
956
956
957
957
PortalDefineQuery (portal ,
958
+ NULL ,
958
959
query_string ,
959
960
commandTag ,
960
961
querytree_list ,
@@ -1146,7 +1147,7 @@ exec_parse_message(const char *query_string,/* string to execute */
1146
1147
1147
1148
if (log_statement == LOGSTMT_ALL )
1148
1149
ereport (LOG ,
1149
- (errmsg ("statement: <protocol> PREPARE %s AS %s" ,
1150
+ (errmsg ("prepare %s: %s" ,
1150
1151
* stmt_name ?stmt_name :"<unnamed>" ,
1151
1152
query_string )));
1152
1153
@@ -1367,6 +1368,7 @@ exec_bind_message(StringInfo input_message)
1367
1368
PreparedStatement * pstmt ;
1368
1369
Portal portal ;
1369
1370
ParamListInfo params ;
1371
+ StringInfoData str ;
1370
1372
1371
1373
pgstat_report_activity ("<BIND>" );
1372
1374
@@ -1382,6 +1384,9 @@ exec_bind_message(StringInfo input_message)
1382
1384
/* Switch back to message context */
1383
1385
MemoryContextSwitchTo (MessageContext );
1384
1386
1387
+ if (log_statement == LOGSTMT_ALL )
1388
+ initStringInfo (& str );
1389
+
1385
1390
/* Get the fixed part of the message */
1386
1391
portal_name = pq_getmsgstring (input_message );
1387
1392
stmt_name = pq_getmsgstring (input_message );
@@ -1450,13 +1455,6 @@ exec_bind_message(StringInfo input_message)
1450
1455
else
1451
1456
portal = CreatePortal (portal_name , false, false);
1452
1457
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
-
1460
1458
/*
1461
1459
* Fetch parameters, if any, and store in the portal's memory context.
1462
1460
*/
@@ -1519,7 +1517,7 @@ exec_bind_message(StringInfo input_message)
1519
1517
else
1520
1518
pformat = 0 ;/* default = text */
1521
1519
1522
- if (pformat == 0 )
1520
+ if (pformat == 0 )/* text mode */
1523
1521
{
1524
1522
Oid typinput ;
1525
1523
Oid typioparam ;
@@ -1540,11 +1538,16 @@ exec_bind_message(StringInfo input_message)
1540
1538
pstring ,
1541
1539
typioparam ,
1542
1540
-1 );
1541
+
1542
+ if (log_statement == LOGSTMT_ALL )
1543
+ appendStringInfo (& str ,"%s$%d = \"%s\"" ,
1544
+ * str .data ?", " :"" ,paramno + 1 ,pstring );
1545
+
1543
1546
/* Free result of encoding conversion, if any */
1544
1547
if (pstring && pstring != pbuf .data )
1545
1548
pfree (pstring );
1546
1549
}
1547
- else if (pformat == 1 )
1550
+ else if (pformat == 1 )/* binary mode */
1548
1551
{
1549
1552
Oid typreceive ;
1550
1553
Oid typioparam ;
@@ -1595,6 +1598,26 @@ exec_bind_message(StringInfo input_message)
1595
1598
else
1596
1599
params = NULL ;
1597
1600
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
+
1598
1621
/* Get the result format codes */
1599
1622
numRFormats = pq_getmsgint (input_message ,2 );
1600
1623
if (numRFormats > 0 )
@@ -1628,6 +1651,7 @@ exec_bind_message(StringInfo input_message)
1628
1651
* Define portal and start execution.
1629
1652
*/
1630
1653
PortalDefineQuery (portal ,
1654
+ * stmt_name ?pstrdup (stmt_name ) :NULL ,
1631
1655
pstmt -> query_string ,
1632
1656
pstmt -> commandTag ,
1633
1657
pstmt -> query_list ,
@@ -1724,9 +1748,11 @@ exec_execute_message(const char *portal_name, long max_rows)
1724
1748
if (log_statement == LOGSTMT_ALL )
1725
1749
/* We have the portal, so output the source query. */
1726
1750
ereport (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 :"" ,
1730
1756
portal -> sourceText ?portal -> sourceText :"" )));
1731
1757
1732
1758
BeginCommand (portal -> commandTag ,dest );
@@ -1832,10 +1858,12 @@ exec_execute_message(const char *portal_name, long max_rows)
1832
1858
secs ,msecs )));
1833
1859
else
1834
1860
ereport (LOG ,
1835
- (errmsg ("duration: %ld.%03d msstatement: <protocol> %sEXECUTE %s [PREPARE : %s] " ,
1861
+ (errmsg ("duration: %ld.%03d msexecute %s%s%s%s : %s" ,
1836
1862
secs ,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 :"" ,
1839
1867
portal -> sourceText ?portal -> sourceText :"" )));
1840
1868
}
1841
1869
}