Neil Conway wrote:
> Bruce Momjian wrote:
> > I have applied the following patch to CVS HEAD to mark client-side
> > prepare/bind/execute statements with "[client]" so they can be easily
> > distinguished from SQL commands.
> 
> There is no such thing as a "client-side prepare/bind/execute" 
> statement. The distinction is between SQL-level and protocol-level 
> prepared queries. "[client]" seems wrong; perhaps "[protocol]" could be 
> used instead?

Agreed.  I never liked "client" either.  It got me confused.  I have
changed it to protocol;  patch attached.

> (I'm not thrilled by the idea of prefixing the statement log with 
> "[...]" in any case: it makes it more difficult to determine the actual 
> query string submitted by the user. However I can't see a better 
> alternative...)

Yep.

> > I hesitate to apply this logging change to 8.1.X.
> 
> I don't see any reason to do that -- this is not a bug fix. Furthermore, 
> there are backward-compatibility concerns.

Right.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.473
diff -c -c -r1.473 postgres.c
*** src/backend/tcop/postgres.c 30 Dec 2005 23:49:48 -0000      1.473
--- src/backend/tcop/postgres.c 31 Dec 2005 16:49:09 -0000
***************
*** 589,596 ****
                                entry->query_string)
                        {
                                *prepare_string = 
palloc(strlen(entry->query_string) +
!                                                                         
strlen("  [client PREPARE:  %s]") - 1);
!                               sprintf(*prepare_string, "  [client PREPARE:  
%s]",
                                                entry->query_string);
                        }
                }
--- 589,596 ----
                                entry->query_string)
                        {
                                *prepare_string = 
palloc(strlen(entry->query_string) +
!                                                                         
strlen("  [protocol PREPARE:  %s]") - 1);
!                               sprintf(*prepare_string, "  [protocol PREPARE:  
%s]",
                                                entry->query_string);
                        }
                }
***************
*** 1146,1152 ****
  
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
!                               (errmsg("statement: [client] PREPARE %s AS %s",
                                                (*stmt_name != '\0') ? 
stmt_name : "<unnamed>",
                                                query_string)));
  
--- 1146,1152 ----
  
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
!                               (errmsg("statement: [protocol] PREPARE %s AS 
%s",
                                                (*stmt_name != '\0') ? 
stmt_name : "<unnamed>",
                                                query_string)));
  
***************
*** 1449,1455 ****
        /* We need to output the parameter values someday */
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
!                               (errmsg("statement: [client] <BIND> %s", 
portal_name)));
  
        /*
         * Fetch parameters, if any, and store in the portal's memory context.
--- 1449,1455 ----
        /* We need to output the parameter values someday */
        if (log_statement == LOGSTMT_ALL)
                ereport(LOG,
!                               (errmsg("statement: [protocol] <BIND> %s", 
portal_name)));
  
        /*
         * Fetch parameters, if any, and store in the portal's memory context.
***************
*** 1712,1718 ****
        if (log_statement == LOGSTMT_ALL)
                /* We have the portal, so output the source query. */
                ereport(LOG,
!                               (errmsg("statement: [client] %sEXECUTE %s  
[PREPARE:  %s]",
                                                (execute_is_fetch) ? "FETCH 
from " : "",
                                                (*portal_name != '\0') ? 
portal_name : "<unnamed>",
                                                portal->sourceText ? 
portal->sourceText : "")));
--- 1712,1718 ----
        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 != '\0') ? 
portal_name : "<unnamed>",
                                                portal->sourceText ? 
portal->sourceText : "")));
***************
*** 1821,1827 ****
                        (save_log_min_duration_statement > 0 &&
                         usecs >= save_log_min_duration_statement * 1000))
                        ereport(LOG,
!                                       (errmsg("duration: %ld.%03ld ms  
statement: [client] %sEXECUTE %s  [PREPARE:  %s]",
                                                        (long) ((stop_t.tv_sec 
- start_t.tv_sec) * 1000 +
                                                                  
(stop_t.tv_usec - start_t.tv_usec) / 1000),
                                                        (long) (stop_t.tv_usec 
- start_t.tv_usec) % 1000,
--- 1821,1827 ----
                        (save_log_min_duration_statement > 0 &&
                         usecs >= save_log_min_duration_statement * 1000))
                        ereport(LOG,
!                                       (errmsg("duration: %ld.%03ld ms  
statement: [protocol] %sEXECUTE %s  [PREPARE:  %s]",
                                                        (long) ((stop_t.tv_sec 
- start_t.tv_sec) * 1000 +
                                                                  
(stop_t.tv_usec - start_t.tv_usec) / 1000),
                                                        (long) (stop_t.tv_usec 
- start_t.tv_usec) % 1000,
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to