From b03663e52bc49751b8a48e4c6bfceddf9c0cd45d Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 27 May 2015 09:49:17 -0700 Subject: [PATCH] Connection version/upgrade abort cleanup. Resolves #20 --- index.html | 75 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index ddcce17..7cc1cce 100644 --- a/index.html +++ b/index.html @@ -462,6 +462,15 @@
Database Connection
The act of opening a database creates a connection. There MAY be multiple connections to a given database at any given time.

+

+ A connection has a version, which is + set when the connection is created. It remains constant + for the lifetime of the connection unless an + upgrade is aborted, in + which case it is set to the previous version of the database. Once + the connection is closed the version + does not change. +

Each connection has a close pending flag which is initially unset. @@ -484,13 +493,14 @@

Database Connection

- A connection has an object store set, which is set to the + A connection has an object store set, which is initialized to the set of object stores in the associated database when the connection is created. The contents of the set will remain constant except when an upgrade transaction is running.

+ @@ -555,7 +565,7 @@
Object Store Handle
but there MUST be only one object store handle associated with a particular object store within a transaction.

- An object store handle has an index set, which is set to the + An object store handle has an index set, which is initialized to the set of indexes that reference the associated object store when the object store handle is created. @@ -2046,16 +2056,13 @@

The IDBDatabase interface

readonly attribute unsigned long long version
- The version attribute's getter must return the version of the - database when the connection was created. - When an IDBDatabase instance is created, - this is always the number given as the version - argument given to the open - call used to create the IDBDatabase instance. This value remains constant for the lifetime of the IDBDatabase object. - If the connection is closed, this attribute represents a - snapshot of the version that the database had when the connection - was closed. Even if another connection is later used to modify the - version, that attribute on closed instances are not changed. + The version attribute's getter must return this + connection's version. +
readonly attribute DOMStringList objectStoreNames
@@ -3963,6 +3970,9 @@

Opening a database

  • Let connection be a new connection to db.
  • +
  • + Set connection's version to version. +
  • If db's version is less than version:
      @@ -3974,7 +3984,6 @@

      Opening a database

      If connection was closed, create and return a new AbortError exception and abort these steps. -
    1. If the upgrade transaction was aborted, run the steps for closing a database connection with connection, @@ -4119,7 +4128,7 @@

      Steps for aborting a transaction

      All the changes made to the database by the transaction are reverted. For upgrade transactions this includes changes to the set of object stores and indexes, as well as the change to the version. Also run the steps for aborting an upgrade transaction - which reverts changes to all IDBDatabase and IDBObjectStore instances. + which reverts changes to all connection and object store handle instances.
    2. If error is not null, set transaction's error property @@ -4308,6 +4317,11 @@

      Steps for aborting an upgrade transaction

      The steps for aborting an upgrade transaction transaction are as follows.

      +
      1. Let connection be transaction's connection. @@ -4316,31 +4330,42 @@

        Steps for aborting an upgrade transaction

        Let database be connection's database.
      2. - Revert database's version to the value it had before the transaction was started - if the database previously existed, or 0 (zero) if the database was newly created. + Set connection's version to database's version + if database previously existed, + or 0 (zero) if database was newly created +
      3. - Revert connection's object store set to the value it had before the transaction was started - if the database previously existed, or an empty set if the database was newly created. + Set connection's object store set to the + set of object stores in database + if database previously existed, + or the empty set if database was newly created. +
      4. - For each object store handle store associated with transaction - revert store's index set to the value it had before the transaction was started - if the object store previously existed, or an empty set if the object store was newly created. - + For each object store handle store associated with transaction, + including handles for stores + that were deleted during transaction, + set store's index set to the + set of indexes that reference the associated object store. + This reverts the value of indexNames returned by related IDBObjectStore objects. -
      +