This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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?)
Assigning to me to make the bug fix.
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. [[