6 messages in com.googlegroups.google-gearsRe: [google-gears] Closing ResultSets...
FromSent OnAttachments
mich...@google.com16 Jul 2007 16:51 
Scott Hess16 Jul 2007 17:15 
Scott Hess16 Jul 2007 17:42 
mich...@google.com16 Jul 2007 19:39 
Aaron Boodman16 Jul 2007 20:17 
mich...@google.com18 Jul 2007 07:53 
Subject:Re: [google-gears] Closing ResultSets When Not Selecting
From:Scott Hess (sh.@google.com)
Date:07/16/2007 05:42:58 PM
List:com.googlegroups.google-gears

Aaron mentions that I'm subtley wrong.

If the statement succeeds but generates a result set which has no columns, then the close() is called in execute(). You can close() it again, but don't need to. So you should be able to safely drop ResultSets from statements which only do data manipulation language type statements. [I think this means anything but SELECT or PRAGMA (which Gears disables) or EXPLAIN.]

Sorry for the misleading post.

-scott

On 7/16/07, mich@google.com <mich@gmail.com> wrote:

Is there any need to close a resultset you're not selecting any rows? It seems silly to have to assign the result of a database query to a variable for the sole purpose of closing the resultset, but the docs do not draw a distinction between resultsets from select operations and update/delete operations.

We've been thinking of this, witness: http://code.google.com/p/google-gears/wiki/DatabaseHelpers

From the Gears level, there's really no way to know whether something is going to return results or not - it's all SQL! An idiom which should be safe to use for now would be something like:

db.execute("INSERT INTO t VALUES (?)", [x]).close();

This should be safe, if execute() completes, the ResultSet is closed. If execute() has an error, it will throw an exception and a ResultSet should never be generated.