HTML5 Database / transaction ordering

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 UTC