X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C29719FA8EF for ; Wed, 21 Jun 2006 13:00:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 11963-04 for ; Wed, 21 Jun 2006 13:00:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by postgresql.org (Postfix) with SMTP id CF54C9F9F2D for ; Wed, 21 Jun 2006 13:00:08 -0300 (ADT) Received: (qmail 30480 invoked by uid 1112); 21 Jun 2006 16:00:06 -0000 Date: Wed, 21 Jun 2006 11:00:06 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary2.csoft.net To: Sebastiaan van Erk cc: pgsql-jdbc@postgresql.org Subject: Re: Limit vs setMaxRows issue In-Reply-To: <44990D57.9070506@sebster.com> Message-ID: References: <44990D57.9070506@sebster.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/72 X-Sequence-Number: 15352 On Wed, 21 Jun 2006, Sebastiaan van Erk wrote: > I'm not 100% sure of what JDBC says about setMaxRows (it's kind of ambiguous > in the java doc, as usual), but as far as I can tell, if you call setMaxRows > on the prepared statement there is no way in to ever retrieve more than that > number of rows. If this is indeed the case, it seems to me that currently > there is a mismatch between the JDBC api and the postgresql api, and JDBC > should somehow tell postgres that this is a hard limit and it should not plan > for a second batch. > > Therefore, my question is: is this a bug? It is not feasable for me to add > LIMIT clauses to all the SQL queries in my code, so if this IS a bug, I hope > it can be fixed. If it is NOT a bug, is there an alternative workaround that > does not involve changing all of my sql statements? > I'm not sure how you would like the driver to tell the server that it doesn't want more than setMaxRows rows. The defined API for this is using LIMIT in your sql query. The driver cannot do this for you (at least without parsing your query) because the query may already have a LIMIT or it may be something like an INSERT into a VIEW that has a DO INSTEAD SELECT rule on it. If you're suggesting that we extended the frontend/backend protocol to include this extra information than that's definitely a feature request, not a bug report. Kris Jurka