<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>11401</bug_id>
          
          <creation_ts>2010-11-24 21:16:52 +0000</creation_ts>
          <short_desc>[IndexedDB] We should disallow .transaction() from within setVersion transactions</short_desc>
          <delta_ts>2011-06-09 18:16:01 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Indexed Database API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeremy Orlow">jorlow</reporter>
          <assigned_to name="Eliot Graff">eliotgra</assigned_to>
          <cc>eliotgra</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>42758</commentid>
    <comment_count>0</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2010-11-24 21:16:52 +0000</bug_when>
    <thetext>We should disallow .transaction() from within setVersion transactions.  Otherwise things like this can become confusing:

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

or

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

We could specify a bunch of complicated semantics, but it&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46495</commentid>
    <comment_count>1</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2011-03-08 01:27:01 +0000</bug_when>
    <thetext>After talking to Jonas, we&apos;re less sure that disallowing is the right way to go.  If we don&apos;t disallow, it will likely require spec text in a lot of places though.  At the very least, we&apos;ll need text in the steps to delete an object store and to abort a transaction.  And we&apos;ll have to decide how to handle transaction([]).  (i.e. are you locking everything in existence then, or everything in existence when you run?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49395</commentid>
    <comment_count>2</comment_count>
    <who name="Eliot Graff">eliotgra</who>
    <bug_when>2011-06-09 18:08:30 +0000</bug_when>
    <thetext>Assigning to me to make the bug fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49397</commentid>
    <comment_count>3</comment_count>
    <who name="Eliot Graff">eliotgra</who>
    <bug_when>2011-06-09 18:16:01 +0000</bug_when>
    <thetext>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. 
[[</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>