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 23F2254B62 for ; Thu, 28 Apr 2005 12:22:07 -0300 (ADT) 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 58578-07 for ; Thu, 28 Apr 2005 15:22:04 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 9760C54B61 for ; Thu, 28 Apr 2005 12:22:03 -0300 (ADT) Received: (qmail 23564 invoked by uid 1112); 28 Apr 2005 15:22:01 -0000 Date: Thu, 28 Apr 2005 10:22:01 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Tom Lane Cc: Markus Schaber , "pgsql-jdbc@postgresql.org" Subject: Re: Statement Timeout and Locking In-Reply-To: Message-ID: References: <4270BAE0.1020402@logix-tt.com> <11053.1114697497@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/203 X-Sequence-Number: 12810 On Thu, 28 Apr 2005, Kris Jurka wrote: > On Thu, 28 Apr 2005, Tom Lane wrote: > > Markus Schaber writes: > > > conn.createStatement().execute("SET statement_timeout TO 5000; LOCK TABLE exampletable IN EXCLUSIVE MODE; SET statement_timeout TO DEFAULT;"); > > > > At least in more recent JDBC drivers, I'd expect the above to fail > > entirely because you can only put one SQL command per V3 Parse message. > > Try splitting it into three statements. > > The JDBC driver splits this query itself and issues it in three queries > internally. > This actually is the problem. It works as three separate statements, but fails as one. The server doesn't seem to recognize the SET when other commands come in before Sync. Driver splitting queries: <=BE ReadyForQuery(I) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@1aaa14a, maxRows=0, fetchSize=0, flags=1 FE=> Parse(stmt=S_1,query="BEGIN",oids={}) FE=> Bind(stmt=S_1,portal=null) FE=> Execute(portal=null,limit=0) FE=> Parse(stmt=null,query="SET statement_timeout TO 5000",oids={}) FE=> Bind(stmt=null,portal=null) FE=> Describe(portal=null) FE=> Execute(portal=null,limit=0) FE=> Parse(stmt=null,query=" LOCK TABLE locktest IN EXCLUSIVE MODE",oids={}) FE=> Bind(stmt=null,portal=null) FE=> Describe(portal=null) FE=> Execute(portal=null,limit=0) FE=> Parse(stmt=null,query=" SET statement_timeout TO DEFAULT",oids={}) FE=> Bind(stmt=null,portal=null) FE=> Describe(portal=null) FE=> Execute(portal=null,limit=0) FE=> Sync This hangs while a version split by the caller works: <=BE ReadyForQuery(I) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@7a84e4, maxRows=0, fetchSize=0, flags=1 FE=> Parse(stmt=S_1,query="BEGIN",oids={}) FE=> Bind(stmt=S_1,portal=null) FE=> Execute(portal=null,limit=0) FE=> Parse(stmt=null,query="SET statement_timeout TO 5000",oids={}) FE=> Bind(stmt=null,portal=null) FE=> Describe(portal=null) FE=> Execute(portal=null,limit=0) FE=> Sync <=BE ParseComplete [S_1] <=BE BindComplete [null] <=BE CommandStatus(BEGIN) <=BE ParseComplete [null] <=BE BindComplete [null] <=BE NoData <=BE CommandStatus(SET) <=BE ReadyForQuery(T) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@9ed927, maxRows=0, fetchSize=0, flags=1 FE=> Parse(stmt=null,query="LOCK TABLE locktest IN EXCLUSIVE MODE",oids={}) FE=> Bind(stmt=null,portal=null) FE=> Describe(portal=null) FE=> Execute(portal=null,limit=0) FE=> Sync <=BE ParseComplete [null] <=BE BindComplete [null] <=BE NoData <=BE ErrorMessage(ERROR: canceling query due to user request Kris Jurka