W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

Re: [web databases] changeVersion error reporting

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 1 Dec 2009 02:04:09 +0000 (UTC)
To: João Eiras <joaoe@opera.com>, Michael Nordman <michaeln@google.com>
Cc: "public-webapps@w3.org" <public-webapps@w3.org>
Message-ID: <Pine.LNX.4.62.0912010202550.4718@hixie.dreamhostps.com>
On Fri, 4 Sep 2009, João Eiras wrote:
> 
> Database.changeVersion expects oldVersion and newVersion arguments. The
> Database also specifies a version attribute.
> The transaction steps tell to fail the transaction due to the failed preflight
> condition if oldVersion does not match the current database version.
> Meanwhile, the callbacks have been made optional, and rightly so.
> 
> So:
>  - if the author does not use the callbacks, there no error reporting that the
> preflight condition failed
>  - the version check can be done synchronously when changeVersion is called
> because the Database object has immediate access to that value, and it's much
> more convenient for the author to just get an exception (like
> INVALID_STATE_ERR) than to have to go through the entire callback process just
> to realize later that the transaction failed due to the mismatched version. It
> also spares the user agent from creating and executing a transaction that WILL
> fail.
> 
> To solve these issues, I would suggest doing immediate synchronous validation
> of the version when changeVersion is called, throwing an exception on error,
> and drop that step from the preflight operations.

On Thu, 3 Sep 2009, Michael Nordman wrote:
>
> If the version is stored in the database file itself, as is with webkit's
> impl for example, the database object does not have immediate access to that
> value.

On Fri, 4 Sep 2009, João Eiras wrote:
> 
> So that was one of the motives to add the creation callback on 
> openDatabase I presume.
> 
> In either case, before the script gets a Database object, a version 
> check needs to be made during openDatabase, so the value can be cached 
> inside the Database object, to be used for changeVersion, the version 
> property and subsequent transactions.

The version might change in the background, so the value can't be cached.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 1 December 2009 02:04:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:35 GMT