X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 073303A3E38 for ; Tue, 23 Nov 2004 14:18:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65561-01 for ; Tue, 23 Nov 2004 14:18:06 +0000 (GMT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by svr1.postgresql.org (Postfix) with ESMTP id B9BCE3A2BC2 for ; Tue, 23 Nov 2004 14:18:08 +0000 (GMT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iANEI9sZ026529 for ; Tue, 23 Nov 2004 09:18:09 -0500 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iANEI8r17504 for ; Tue, 23 Nov 2004 09:18:09 -0500 Received: from 192.168.1.2 (vpn83-131.boston.redhat.com [172.16.83.131]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id iANEI6ht002946 for ; Tue, 23 Nov 2004 09:18:07 -0500 From: Vadim Nasardinov Organization: Red Hat / Westford To: pgsql-jdbc@postgresql.org Subject: better logging on the backend (was: Re: When running with autocommit false only the first BEGIN) Date: Tue, 23 Nov 2004 09:25:30 -0500 User-Agent: KMail/1.5.4 References: <03E7D3E231BB7B4A915A6581D4296CC6C08C46@NSNOVPS00411.nacio.xythos.com> <41A32762.4000403@fastcrypt.com> <41A32A7D.2010102@opencloud.com> In-Reply-To: <41A32A7D.2010102@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411230925.30941@vadim.nasardinov> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/185 X-Sequence-Number: 11607 On Tuesday 23 November 2004 07:18, Oliver Jowett wrote: > Dave Cramer wrote: > > That certainly doesn't seem acceptable. As Barry points out people > > will really be in the dark when their code doesn't work. > > There's nothing much the driver can do about it other than not using > the new features of V3. This needs a server-side fix. Can some kind of statement logging be implemented on the client side? Or do you think there isn't much to be gained by this beyond whatever functionality is already provided by proxying JDBC drivers like P6Spy (http://p6spy.sf.net)? > We could make BEGIN/COMMIT/ROLLBACK more visible at the (small) cost > of an extra Parse on each execution. I'm not sure if you need an extra parse. I'd be happy to have the backend log a (semi-) unique statement ID for each statement it executes. If a statement is reused, its unique ID allows me to find its prior occurrences in the log. It then becomes a matter of having an intelligent log viewer or post-processor, one that shouldn't be too hard to write. Additionally, another thing that could be _really_ useful is the ability to send an arbitrary message to be logged on the backend side along with each statement. For instance, you can log the Java thread name, so you can map statements to threads later on. Another example would be mapping each statement from the back end log to the corresponding Java stack trace on the client side. This could be done by (a) capturing the current stack trace on the client side via org.postgresql.Driver.debug(uniqueID + ": " + p_sql, new Exception()); or some such. (b) sending uniqueID to the backend along with the statement. Thoughts? Vadim ------------------------------------------------------------------------------ P.S. BTW, Driver#log(String,Exception) currently drops the stack trace on the floor. All it does is public static void debug(String msg, Exception ex) { if (logDebug) { DriverManager.println(msg); if (ex != null) { DriverManager.println(ex.toString()); } } } Would it make more sense to do something like this: public static void debug(String msg, Exception ex) { if (logDebug) { DriverManager.println(msg); if (ex != null) { ex.printStackTrace(DriverManager.getLogWriter()); } } }