This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11401 - [IndexedDB] We should disallow .transaction() from within setVersion transactions
Summary: [IndexedDB] We should disallow .transaction() from within setVersion transact...
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Eliot Graff
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-24 21:16 UTC by Jeremy Orlow
Modified: 2011-06-09 18:16 UTC (History)
3 users (show)

See Also:


Attachments

Description Jeremy Orlow 2010-11-24 21:16:52 UTC
We should disallow .transaction() from within setVersion transactions.  Otherwise things like this can become confusing:

db.setVersion('1').onsuccess(function () {
  db.createObjectStore('a');
  trans = db.transaction('a');
  db.removeObjectStore('a');
  db.createObjectStore('a');
  trans.objectStore('a').put('foo', 'bar');
});

or

db.setVersion('1').onsuccess(function () {
  thisTrans = event.result;
  db.createObjectStore('a');
  trans = db.transaction('a');
  thisTrans.abort();
  trans.objectStore('a').put('foo', 'bar');
});

We could specify a bunch of complicated semantics, but it's much easier to just say that .transaction() throws if called within a setVersion transaction.  Any use case that needs to create a transaction within should be satisfied by doing the work in an oncomplete handler for the setVersion transaction.
Comment 1 Jeremy Orlow 2011-03-08 01:27:01 UTC
After talking to Jonas, we're less sure that disallowing is the right way to go.  If we don't disallow, it will likely require spec text in a lot of places though.  At the very least, we'll need text in the steps to delete an object store and to abort a transaction.  And we'll have to decide how to handle transaction([]).  (i.e. are you locking everything in existence then, or everything in existence when you run?)
Comment 2 Eliot Graff 2011-06-09 18:08:30 UTC
Assigning to me to make the bug fix.
Comment 3 Eliot Graff 2011-06-09 18:16:01 UTC
Added these sentences to the description of IDBDatabase.transaction():

]]
This method must throw an IDBDatabaseException of type NOT_ALLOWED_ERR if the transaction method is called within the onsuccess handler of a setVersion request. This method also must throw an IDBDatabaseException of type NOT_ALLOWED_ERR if the transaction method is called when there is a pending setVersion call. In short, the transaction method throws NOT_ALLOWED_ERR from the time that setVersion is called to the point when the complete event is fired on the resulting transaction. 
[[

I did not add anything to IDBDatabaseSync.transaction(), which already has this in the description:

]]
This method must throw an IDBDatabaseException with a NOT_ALLOWED_ERR description when it is called within the IDBTransactionCallback of a setVersion method. 
[[