[html5] r2607 - [gwr] (2) SQL: Split the transaction() method into two, one for read/write acces [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Dec 29 01:59:47 PST 2008


Author: ianh
Date: 2008-12-29 01:59:45 -0800 (Mon, 29 Dec 2008)
New Revision: 2607

Modified:
   index
   source
Log:
[gwr] (2) SQL: Split the transaction() method into two, one for read/write access and one for shared read access.

Modified: index
===================================================================
--- index	2008-12-29 09:14:32 UTC (rev 2606)
+++ index	2008-12-29 09:59:45 UTC (rev 2607)
@@ -39094,9 +39094,8 @@
   increase the quota every five megabytes.</p>
 
   <pre class=idl>interface <dfn id=database>Database</dfn> {
-  void <a href=#dom-database-transaction title=dom-database-transaction>transaction</a>(in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback);
-  void <a href=#dom-database-transaction title=dom-database-transaction>transaction</a>(in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback, in <a href=#sqltransactionerrorcallback>SQLTransactionErrorCallback</a> errorCallback);
-  void <a href=#dom-database-transaction title=dom-database-transaction>transaction</a>(in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback, in <a href=#sqltransactionerrorcallback>SQLTransactionErrorCallback</a> errorCallback, in <a href=#voidcallback>VoidCallback</a> successCallback);
+  void <a href=#dom-database-transaction title=dom-database-transaction>transaction</a>(in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback, [Optional] in <a href=#sqltransactionerrorcallback>SQLTransactionErrorCallback</a> errorCallback, [Optional] in <a href=#voidcallback>VoidCallback</a> successCallback);
+  void <a href=#dom-database-readtransaction title=dom-database-readTransaction>readTransaction</a>(in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback, [Optional] in <a href=#sqltransactionerrorcallback>SQLTransactionErrorCallback</a> errorCallback, [Optional] in <a href=#voidcallback>VoidCallback</a> successCallback);
 
   readonly attribute DOMString <a href=#dom-database-version title=dom-database-version>version</a>;
   void <a href=#dom-database-changeversion title=dom-database-changeVersion>changeVersion</a>(in DOMString oldVersion, in DOMString newVersion, in <a href=#sqltransactioncallback>SQLTransactionCallback</a> callback, in <a href=#sqltransactionerrorcallback>SQLTransactionErrorCallback</a> errorCallback, in <a href=#voidcallback>VoidCallback</a> successCallback);
@@ -39111,7 +39110,8 @@
 };</pre>
 
   <p>The <dfn id=dom-database-transaction title=dom-database-transaction><code>transaction()</code></dfn>
-  method takes one or two arguments. When called, the method must
+  and <dfn id=dom-database-readtransaction title=dom-database-readTransaction><code>readTransaction()</code></dfn>
+  methods takes one to three arguments. When called, these method must
   immediately return and then asynchronously run the <a href=#transaction-steps>transaction
   steps</a> with the <i>transaction callback</i> being the first
   argument, the <i>error callback</i> being the second argument, if
@@ -39119,6 +39119,10 @@
   and with no <i>preflight operation</i> or <i>postflight
   operation</i>.</p>
 
+  <p>For the <code title=dom-database-transaction><a href=#dom-database-transaction>transaction()</a></code> method, the
+  <i>mode</i> must be read/write. For the <code title=dom-database-readTransaction><a href=#dom-database-readtransaction>readTransaction()</a></code>
+  method, the <i>mode</i> must be read-only.</p>
+
   <p>The version that the database was opened with is the <dfn id=concept-database-expected-version title=concept-database-expected-version>expected version</dfn> of
   this <code><a href=#database>Database</a></code> object. It can be the empty string, in
   which case there is no expected version — any version is
@@ -39143,7 +39147,7 @@
    exactly matches the database's actual version. If it does not, then
    the <i>preflight operation</i> fails.</li>
 
-  </ol><p>...and the <i>postflight operation</i> being the following:</p>
+  </ol><p>...the <i>postflight operation</i> being the following:</p>
 
   <ol><li>Change the database's actual version to the value of the second
    argument to the <code title=dom-database-changeVersion><a href=#dom-database-changeversion>changeVersion()</a></code>
@@ -39153,8 +39157,11 @@
    the value of the second argument to the <code title=dom-database-changeVersion><a href=#dom-database-changeversion>changeVersion()</a></code>
    method.</li>
 
-  </ol><h5 id=executing-sql-statements><span class=secno>5.10.2.3 </span>Executing SQL statements</h5>
+  </ol><p>...and the <i>mode</i> being read/write.</p>
 
+
+  <h5 id=executing-sql-statements><span class=secno>5.10.2.3 </span>Executing SQL statements</h5>
+
   <p>The <code title=dom-database-transaction><a href=#dom-database-transaction>transaction()</a></code>
   and <code title=dom-database-changeVersion><a href=#dom-database-changeversion>changeVersion()</a></code>
   methods invoke callbacks with <code><a href=#sqltransaction>SQLTransaction</a></code>
@@ -39388,14 +39395,20 @@
   be run asynchronously. These steps are invoked with a <i>transaction
   callback</i>, optionally an <i>error callback</i>, optionally a
   <i>success callback</i>, optionally a <i>preflight operation</i>,
-  and optionally a <i>postflight operation</i>.</p>
+  optionally a <i>postflight operation</i>, and with a <i>mode</i>
+  that is either read/write or read-only.</p>
 
   <ol><li><p>Open a new SQL transaction to the database, and create a
    <code><a href=#sqltransaction>SQLTransaction</a></code> object that represents that
-   transaction.</li>
+   transaction. If the <i>mode</i> is read/write, the transaction must
+   have an exclusive write lock over the entire database. If the
+   <i>mode</i> is read-only, the transaction must have a shared read
+   lock over the entire database. The user agent should wait for an
+   appropriate lock to be available..</li>
 
-   <li><p>If an error occurred in the opening of the transaction, jump
-   to the last step.</li>
+   <li><p>If an error occurred in the opening of the transaction
+   (e.g. if the user agent failed to obtain an appropriate lock after
+   an appropriate delay), jump to the last step.</li>
 
    <li><p>If a <i>preflight operation</i> was defined for this
    instance of the transaction steps, run that. If it fails, then jump
@@ -39424,6 +39437,20 @@
     <ol><li><p>If the statement is marked as bogus, jump to the "in case
      of error" steps below.</li>
 
+     <li id=modifications-fail-if-read-only>
+
+      <p>If the <i>mode</i> is read-only but the statement's main verb
+      can modify the database, jump to the "in case of error" steps
+      below.</p>
+
+      <p class=note>Only the statement's main verb (e.g. <code title="">UPDATE</code>, <code title="">SELECT</code>, <code title="">DROP</code>) is considered here. Thus, a statement like
+      "<code title="">UPDATE test SET id=0 WHERE 0=1</code>" would be
+      treated as potentially modifying the database for the purposes
+      of this step, even though it could never in fact have any
+      side-effects.</p>
+
+     </li>
+
      <li><p>Execute the statement in the context of the transaction.
      <a href=#refsSQL>[SQL]</a></p>
 

Modified: source
===================================================================
--- source	2008-12-29 09:14:32 UTC (rev 2606)
+++ source	2008-12-29 09:59:45 UTC (rev 2607)
@@ -44480,9 +44480,8 @@
   increase the quota every five megabytes.</p>
 
   <pre class="idl">interface <dfn>Database</dfn> {
-  void <span title="dom-database-transaction">transaction</span>(in <span>SQLTransactionCallback</span> callback);
-  void <span title="dom-database-transaction">transaction</span>(in <span>SQLTransactionCallback</span> callback, in <span>SQLTransactionErrorCallback</span> errorCallback);
-  void <span title="dom-database-transaction">transaction</span>(in <span>SQLTransactionCallback</span> callback, in <span>SQLTransactionErrorCallback</span> errorCallback, in <span>VoidCallback</span> successCallback);
+  void <span title="dom-database-transaction">transaction</span>(in <span>SQLTransactionCallback</span> callback, [Optional] in <span>SQLTransactionErrorCallback</span> errorCallback, [Optional] in <span>VoidCallback</span> successCallback);
+  void <span title="dom-database-readTransaction">readTransaction</span>(in <span>SQLTransactionCallback</span> callback, [Optional] in <span>SQLTransactionErrorCallback</span> errorCallback, [Optional] in <span>VoidCallback</span> successCallback);
 
   readonly attribute DOMString <span title="dom-database-version">version</span>;
   void <span title="dom-database-changeVersion">changeVersion</span>(in DOMString oldVersion, in DOMString newVersion, in <span>SQLTransactionCallback</span> callback, in <span>SQLTransactionErrorCallback</span> errorCallback, in <span>VoidCallback</span> successCallback);
@@ -44498,7 +44497,9 @@
 
   <p>The <dfn
   title="dom-database-transaction"><code>transaction()</code></dfn>
-  method takes one or two arguments. When called, the method must
+  and <dfn
+  title="dom-database-readTransaction"><code>readTransaction()</code></dfn>
+  methods takes one to three arguments. When called, these method must
   immediately return and then asynchronously run the <span>transaction
   steps</span> with the <i>transaction callback</i> being the first
   argument, the <i>error callback</i> being the second argument, if
@@ -44506,6 +44507,12 @@
   and with no <i>preflight operation</i> or <i>postflight
   operation</i>.</p>
 
+  <p>For the <code
+  title="dom-database-transaction">transaction()</code> method, the
+  <i>mode</i> must be read/write. For the <code
+  title="dom-database-readTransaction">readTransaction()</code>
+  method, the <i>mode</i> must be read-only.</p>
+
   <p>The version that the database was opened with is the <dfn
   title="concept-database-expected-version">expected version</dfn> of
   this <code>Database</code> object. It can be the empty string, in
@@ -44538,7 +44545,7 @@
 
   </ol>
 
-  <p>...and the <i>postflight operation</i> being the following:</p>
+  <p>...the <i>postflight operation</i> being the following:</p>
 
   <ol>
 
@@ -44554,7 +44561,9 @@
 
   </ol>
 
+  <p>...and the <i>mode</i> being read/write.</p>
 
+
   <h5>Executing SQL statements</h5>
 
   <p>The <code title="dom-database-transaction">transaction()</code>
@@ -44829,16 +44838,22 @@
   be run asynchronously. These steps are invoked with a <i>transaction
   callback</i>, optionally an <i>error callback</i>, optionally a
   <i>success callback</i>, optionally a <i>preflight operation</i>,
-  and optionally a <i>postflight operation</i>.</p>
+  optionally a <i>postflight operation</i>, and with a <i>mode</i>
+  that is either read/write or read-only.</p>
 
   <ol>
 
    <li><p>Open a new SQL transaction to the database, and create a
    <code>SQLTransaction</code> object that represents that
-   transaction.</p></li>
+   transaction. If the <i>mode</i> is read/write, the transaction must
+   have an exclusive write lock over the entire database. If the
+   <i>mode</i> is read-only, the transaction must have a shared read
+   lock over the entire database. The user agent should wait for an
+   appropriate lock to be available..</p></li>
 
-   <li><p>If an error occurred in the opening of the transaction, jump
-   to the last step.</p></li>
+   <li><p>If an error occurred in the opening of the transaction
+   (e.g. if the user agent failed to obtain an appropriate lock after
+   an appropriate delay), jump to the last step.</p></li>
 
    <li><p>If a <i>preflight operation</i> was defined for this
    instance of the transaction steps, run that. If it fails, then jump
@@ -44870,6 +44885,22 @@
      <li><p>If the statement is marked as bogus, jump to the "in case
      of error" steps below.</p></li>
 
+     <li id="modifications-fail-if-read-only">
+
+      <p>If the <i>mode</i> is read-only but the statement's main verb
+      can modify the database, jump to the "in case of error" steps
+      below.</p>
+
+      <p class="note">Only the statement's main verb (e.g. <code
+      title="">UPDATE</code>, <code title="">SELECT</code>, <code
+      title="">DROP</code>) is considered here. Thus, a statement like
+      "<code title="">UPDATE test SET id=0 WHERE 0=1</code>" would be
+      treated as potentially modifying the database for the purposes
+      of this step, even though it could never in fact have any
+      side-effects.</p>
+
+     </li>
+
      <li><p>Execute the statement in the context of the transaction.
      <a href="#refsSQL">[SQL]</a></p>
 




More information about the Commit-Watchers mailing list