Skip to content

Commit

Permalink
[gwr] (2) SQL: Split the transaction() method into two, one for read/…
Browse files Browse the repository at this point in the history
…write access and one for shared read access.

git-svn-id: http://svn.whatwg.org/webapps@2607 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Dec 29, 2008
1 parent 2a21f1f commit 222c943
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 19 deletions.
47 changes: 37 additions & 10 deletions index
Expand Up @@ -39094,9 +39094,8 @@ have a variable and unknowable number of literals coming:
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);
Expand All @@ -39111,14 +39110,19 @@ interface <dfn id=sqltransactionerrorcallback>SQLTransactionErrorCallback</dfn>
};</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
any, the <i>success callback</i> being the third argument, if any,
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 &mdash; any version is
Expand All @@ -39143,7 +39147,7 @@ interface <dfn id=sqltransactionerrorcallback>SQLTransactionErrorCallback</dfn>
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>
Expand All @@ -39153,7 +39157,10 @@ interface <dfn id=sqltransactionerrorcallback>SQLTransactionErrorCallback</dfn>
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>
Expand Down Expand Up @@ -39388,14 +39395,20 @@ interface <dfn id=sqlstatementerrorcallback>SQLStatementErrorCallback</dfn> {
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
Expand Down Expand Up @@ -39424,6 +39437,20 @@ interface <dfn id=sqlstatementerrorcallback>SQLStatementErrorCallback</dfn> {
<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>

Expand Down
49 changes: 40 additions & 9 deletions source
Expand Up @@ -44480,9 +44480,8 @@ have a variable and unknowable number of literals coming:
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);
Expand All @@ -44498,14 +44497,22 @@ interface <dfn>SQLTransactionErrorCallback</dfn> {

<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
any, the <i>success callback</i> being the third argument, if any,
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
Expand Down Expand Up @@ -44538,7 +44545,7 @@ interface <dfn>SQLTransactionErrorCallback</dfn> {

</ol>

<p>...and the <i>postflight operation</i> being the following:</p>
<p>...the <i>postflight operation</i> being the following:</p>

<ol>

Expand All @@ -44554,6 +44561,8 @@ interface <dfn>SQLTransactionErrorCallback</dfn> {

</ol>

<p>...and the <i>mode</i> being read/write.</p>


<h5>Executing SQL statements</h5>

Expand Down Expand Up @@ -44829,16 +44838,22 @@ interface <dfn>SQLStatementErrorCallback</dfn> {
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
Expand Down Expand Up @@ -44870,6 +44885,22 @@ interface <dfn>SQLStatementErrorCallback</dfn> {
<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>

Expand Down

0 comments on commit 222c943

Please sign in to comment.