X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 22C6D9FB2B5; Wed, 30 Aug 2006 15:22:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 65167-10; Wed, 30 Aug 2006 18:21:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 593389FA435; Wed, 30 Aug 2006 15:21:46 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id k7UILIT21208; Wed, 30 Aug 2006 14:21:18 -0400 (EDT) From: Bruce Momjian Message-Id: <200608301821.k7UILIT21208@momjian.us> Subject: Re: [HACKERS] [PATCHES] log_statement output for protocol In-Reply-To: <1d4e0c10608300025s2880837bi6fe3e7566b14edde@mail.gmail.com> To: Guillaume Smet Date: Wed, 30 Aug 2006 14:21:18 -0400 (EDT) CC: Tom Lane , Oliver Jowett , Dave Cramer , Csaba Nagy , Postgres JDBC , PostgreSQL-patches X-Mailer: ELM [version 2.4ME+ PL123] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1156962078-4510-0_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200608/179 X-Sequence-Number: 15706 --ELM1156962078-4510-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Guillaume Smet wrote: > On 8/29/06, Bruce Momjian wrote: > > Good point. I thought it was clear enough, but obviously not. I had a > > similar case with bind, and used a comma to separate them: > > > > LOG: statement: prepare sel1, SELECT $1; > > LOG: statement: bind sel1, $1 = 'a''b' > > For this one, I must admit I prefer the colon we used before. > Something like: > LOG: statement: prepare sel1: SELECT $1; > LOG: statement: bind sel1: $1 = 'a''b' > seems better to me as after the colon, we have the details of the > command which is the common sense of a colon. OK, done. > > I am concerned a dash isn't clear enough, and a semicolon is confusing. > > Using a comma the new output is: > > > > LOG: duration: 0.023 ms execute sel1 > > DETAIL: prepare: SELECT $1;, bind: $1 = 'a''b' > > A dash is clearer in this case IMHO. ;, is not very readable. But I > can parse easily both forms so it's not a problem for me if you prefer > a comma. I thought about this, and because we are placing two pieces of information on the same line, it seems "|" is the best choice. > > Is that OK? Patch attached and committed. I also fixed the null bind > > parameter bug. It now displays $1 = NULL (no quotes used). > > Cool. I'll test that. > > > Other suggestions? > > I'll compile this new version and make tests in the next few days to > check everything is consistent and let you know. > > I'm still struggling to find a regexp good enough to parse "statement: > execute y ('a', 4, 'text, with a comma'::text);" :). Oh. You want to pull the parameters out of that. I am thinking you need something that will go over the line character by character with some type of state machine, rather than just regex. > Thanks a lot for your work on this subject. It will help us a lot when > we use the JDBC driver. Patch attached and applied. New output: LOG: statement: begin; LOG: statement: prepare x as select $1::text; LOG: statement: execute x ('a'); DETAIL: prepare: prepare x as select $1::text; LOG: statement: commit; LOG: statement: set log_statement = 'none'; LOG: duration: 0.222 ms statement: set log_min_duration_statement = 0; LOG: duration: 0.061 ms statement: begin; LOG: duration: 0.113 ms statement: prepare y as select $1::text; LOG: duration: 0.213 ms statement: execute y ('a'); DETAIL: prepare: prepare y as select $1::text; LOG: duration: 0.081 ms statement: commit; LOG: statement: prepare sel1: SELECT $1; LOG: statement: bind sel1: $1 = 'a''b' DETAIL: prepare: SELECT $1; LOG: statement: execute sel1 DETAIL: prepare: SELECT $1; | bind: $1 = 'a''b' LOG: duration: 0.445 ms statement: SET log_min_duration_statement = 0; LOG: duration: 0.018 ms execute sel1 DETAIL: prepare: SELECT $1; | bind: $1 = 'a''b' Additional comments? -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + --ELM1156962078-4510-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/bjm/diff" Index: src/backend/tcop/postgres.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/tcop/postgres.c,v retrieving revision 1.502 diff -c -c -r1.502 postgres.c *** src/backend/tcop/postgres.c 29 Aug 2006 20:10:42 -0000 1.502 --- src/backend/tcop/postgres.c 30 Aug 2006 17:59:05 -0000 *************** *** 1146,1152 **** if (log_statement == LOGSTMT_ALL) ereport(LOG, ! (errmsg("statement: prepare %s, %s", *stmt_name ? stmt_name : "", query_string))); --- 1146,1152 ---- if (log_statement == LOGSTMT_ALL) ereport(LOG, ! (errmsg("statement: prepare %s: %s", *stmt_name ? stmt_name : "", query_string))); *************** *** 1621,1627 **** *portal->name ? "/" : "", *portal->name ? portal->name : "", /* print bind parameters if we have them */ ! bind_values_str.len ? ", " : "", bind_values_str.len ? bind_values_str.data : ""), errdetail("prepare: %s", pstmt->query_string))); } --- 1621,1627 ---- *portal->name ? "/" : "", *portal->name ? portal->name : "", /* print bind parameters if we have them */ ! bind_values_str.len ? ": " : "", bind_values_str.len ? bind_values_str.data : ""), errdetail("prepare: %s", pstmt->query_string))); } *************** *** 1788,1794 **** *portal_name ? portal_name : ""), errdetail("prepare: %s%s%s", sourceText, /* optionally print bind parameters */ ! bindText ? ", bind: " : "", bindText ? bindText : ""))); BeginCommand(portal->commandTag, dest); --- 1788,1794 ---- *portal_name ? portal_name : ""), errdetail("prepare: %s%s%s", sourceText, /* optionally print bind parameters */ ! bindText ? " | bind: " : "", bindText ? bindText : ""))); BeginCommand(portal->commandTag, dest); *************** *** 1902,1908 **** *portal_name ? portal_name : ""), errdetail("prepare: %s%s%s", sourceText, /* optionally print bind parameters */ ! bindText ? ", bind: " : "", bindText ? bindText : ""))); } } --- 1902,1908 ---- *portal_name ? portal_name : ""), errdetail("prepare: %s%s%s", sourceText, /* optionally print bind parameters */ ! bindText ? " | bind: " : "", bindText ? bindText : ""))); } } --ELM1156962078-4510-0_--