W3C home > Mailing lists > Public > public-html-comments@w3.org > October 2008

HTML5 Database / transaction ordering

From: Victor Suba <vosuba@gmail.com>
Date: Fri, 3 Oct 2008 22:33:38 -0700
Message-ID: <7dc299cb0810032233g30e44b18s88e1944f7934adef@mail.gmail.com>
To: public-html-comments@w3.org
As I understand, client database transactions are to be queued and executed
sequentially in the order that they are called.

This is a useful fact for ordering transaction code without endless chaining
of callbacks, for instance in the following example the steps will execute
in order 1,2,3,4:

db.transaction(
 function(tx)
 {
  // step 1
  tx.executeSql('...',[],
   function(tx)
   {
    // step 2
   });
 });

db.transaction(
 function(tx)
 {
  // step 3
  tx.executeSql('...',[],
   function(tx)
   {
    // step 4
   });
 });

However, in the following case of nested transactions the execution is
perhaps not ideal, running steps in the order 1,2,5,6,3,4:

db.transaction(
 function(tx)
 {
  // step 1
  tx.executeSql('...',[],
   function(tx)
   {
    // step 2
   });

  db.transaction(
  function(tx)
  {
   // step 3
   tx.executeSql('...',[],
    function(tx)
    {
     // step 4
    });
  });
 });

db.transaction(
 function(tx)
 {
  // step 5
  tx.executeSql('...',[],
   function(tx)
   {
    // step 6
   });
 });

For consideration, how about if transactions that are issued from inside
other transactions could be queued immediately after, to reliably achieve
order 1,2,3,4,5,6?

Thanks,
Victor
Received on Monday, 6 October 2008 01:21:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 1 June 2011 00:13:59 GMT