Changeset 73697 in webkit


Ignore:
Timestamp:
Dec 10, 2010 2:12:55 AM (13 years ago)
Author:
hans@chromium.org
Message:

2010-12-10 Hans Wennborg <hans@chromium.org>

Reviewed by Jeremy Orlow.

IndexedDB: Numeric keys are floats.
https://bugs.webkit.org/show_bug.cgi?id=50674

Update layout tests to use floating-point values for keys.

  • storage/indexeddb/keyrange-expected.txt:
  • storage/indexeddb/keyrange.html: Make sure creating the keys works.
  • storage/indexeddb/objectstore-cursor-expected.txt:
  • storage/indexeddb/objectstore-cursor.html: Make sure retrieving the keys from the DB objectstore works.

2010-12-10 Hans Wennborg <hans@chromium.org>

Reviewed by Jeremy Orlow.

IndexedDB: Numeric keys are floats.
https://bugs.webkit.org/show_bug.cgi?id=50674

Use floating point to represent numeric keys,
add version meta data to the SQLite db,
and migrate object stores that use integers.

  • bindings/v8/IDBBindingUtilities.cpp: (WebCore::createIDBKeyFromValue):
  • bindings/v8/custom/V8IDBKeyCustom.cpp: (WebCore::toV8):
  • storage/IDBFactoryBackendImpl.cpp: (WebCore::createTables): (WebCore::migrateDatabase): (WebCore::IDBFactoryBackendImpl::open):
  • storage/IDBKey.cpp: (WebCore::IDBKey::IDBKey): (WebCore::IDBKey::fromQuery): (WebCore::IDBKey::bind): (WebCore::IDBKey::bindWithNulls):
  • storage/IDBKey.h: (WebCore::IDBKey::create): (WebCore::IDBKey::number):

2010-12-10 Hans Wennborg <hans@chromium.org>

Reviewed by Jeremy Orlow.

IndexedDB: Numeric keys are floats.
https://bugs.webkit.org/show_bug.cgi?id=50674

Represent numeric keys as floating point values.

  • public/WebIDBKey.h: (WebKit::WebIDBKey::WebIDBKey):
  • src/WebIDBKey.cpp: (WebKit::WebIDBKey::assign): (WebKit::WebIDBKey::number):
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73695 r73697  
     12010-12-10  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        IndexedDB: Numeric keys are floats.
     6        https://bugs.webkit.org/show_bug.cgi?id=50674
     7
     8        Update layout tests to use floating-point values for keys.
     9
     10        * storage/indexeddb/keyrange-expected.txt:
     11        * storage/indexeddb/keyrange.html:
     12        Make sure creating the keys works.
     13        * storage/indexeddb/objectstore-cursor-expected.txt:
     14        * storage/indexeddb/objectstore-cursor.html:
     15        Make sure retrieving the keys from the DB objectstore works.
     16
    1172010-12-10  Martin Robinson  <mrobinson@igalia.com>
    218
  • trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt

    r73633 r73697  
    4646store.createIndex('indexName', 'x')
    4747store.createIndex('indexName2', 'y', false)
     48store.createIndex('zIndex', 'z', true)
    4849PASS 'name' in indexObject is true
    4950PASS indexObject.name is "indexName"
     
    5859PASS 'getKey' in indexObject is true
    5960PASS 'get' in indexObject is true
    60 store.add({x: 'value', y: 'zzz'}, 'key')
    61 PASS 'onsuccess' in result is true
    62 PASS 'onerror' in result is true
    63 PASS 'readyState' in result is true
    64 An event should fire shortly...
    65 
    66 Success event fired:
    67 PASS 'result' in event is true
    68 PASS 'code' in event is false
    69 PASS 'message' in event is false
    70 PASS 'source' in event is true
    71 PASS event.source != null is true
    72 PASS 'onsuccess' in event.target is true
    73 PASS 'onerror' in event.target is true
    74 PASS 'readyState' in event.target is true
    75 PASS event.target.readyState is event.target.DONE
    76 
    77 event.source.add({x: 'value2', y: 'zzz2'}, 'key2')
     61store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')
     62PASS 'onsuccess' in result is true
     63PASS 'onerror' in result is true
     64PASS 'readyState' in result is true
     65An event should fire shortly...
     66
     67Success event fired:
     68PASS 'result' in event is true
     69PASS 'code' in event is false
     70PASS 'message' in event is false
     71PASS 'source' in event is true
     72PASS event.source != null is true
     73PASS 'onsuccess' in event.target is true
     74PASS 'onerror' in event.target is true
     75PASS 'readyState' in event.target is true
     76PASS event.target.readyState is event.target.DONE
     77
     78event.source.add({x: 'value2', y: 'zzz2', z: 2.71}, 'key2')
    7879PASS 'onsuccess' in result is true
    7980PASS 'onerror' in result is true
     
    128129
    129130PASS event.result is "key"
     131indexObject3.get(2.71)
     132PASS 'onsuccess' in result is true
     133PASS 'onerror' in result is true
     134PASS 'readyState' in result is true
     135An event should fire shortly...
     136
     137Success event fired:
     138PASS 'result' in event is true
     139PASS 'code' in event is false
     140PASS 'message' in event is false
     141PASS 'source' in event is true
     142PASS event.source != null is true
     143PASS 'onsuccess' in event.target is true
     144PASS 'onerror' in event.target is true
     145PASS 'readyState' in event.target is true
     146PASS event.target.readyState is event.target.DONE
     147
     148PASS event.result.x is "value2"
    130149indexObject.get('value')
    131150PASS 'onsuccess' in result is true
  • trunk/LayoutTests/storage/indexeddb/index-basics.html

    r73633 r73697  
    5050    window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
    5151    window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', false)");
     52    window.indexObject3 = evalAndLog("store.createIndex('zIndex', 'z', true)");
    5253    addData();
    5354}
     
    6869    shouldBeTrue("'get' in indexObject");
    6970
    70     result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
     71    result = evalAndLog("store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')");
    7172    verifyResult(result);
    7273    result.onsuccess = addMore;
     
    7879    verifySuccessEvent(event);
    7980
    80     result = evalAndLog("event.source.add({x: 'value2', y: 'zzz2'}, 'key2')");
     81    result = evalAndLog("event.source.add({x: 'value2', y: 'zzz2', z: 2.71}, 'key2')");
    8182    verifyResult(result);
    8283    result.onsuccess = getData;
     
    109110    verifySuccessEvent(event);
    110111    shouldBeEqualToString("event.result", "key");
     112
     113    result = evalAndLog("indexObject3.get(2.71)");
     114    verifyResult(result);
     115    result.onsuccess = getObjectData3;
     116    result.onerror = unexpectedErrorCallback;
     117}
     118
     119function getObjectData3()
     120{
     121    verifySuccessEvent(event);
     122    shouldBeEqualToString("event.result.x", "value2");
    111123
    112124    result = evalAndLog("indexObject.get('value')");
  • trunk/LayoutTests/storage/indexeddb/index-cursor.html

    r73633 r73697  
    1919    1,
    2020    1,
    21     2,
    22     2,
     21    3.14159,
     22    3.14159,
    2323    10,
    2424    // FIXME: Dates.
  • trunk/LayoutTests/storage/indexeddb/keyrange-expected.txt

    r73633 r73697  
    2828PASS keyRange.lowerOpen is false
    2929PASS keyRange.upperOpen is false
     30webkitIDBKeyRange.only(3.14)
     31PASS keyRange.lower is 3.14
     32PASS keyRange.upper is 3.14
     33PASS keyRange.lowerOpen is false
     34PASS keyRange.upperOpen is false
    3035webkitIDBKeyRange.only('a')
    3136PASS keyRange.lower is 'a'
     
    4853PASS keyRange.upper is null
    4954PASS keyRange.upperOpen is false
     55webkitIDBKeyRange.lowerBound(10.1,true)
     56PASS keyRange.lower is 10.1
     57PASS keyRange.lowerOpen is true
     58PASS keyRange.upper is null
     59PASS keyRange.upperOpen is false
     60webkitIDBKeyRange.lowerBound(11.2,false)
     61PASS keyRange.lower is 11.2
     62PASS keyRange.lowerOpen is false
     63PASS keyRange.upper is null
     64PASS keyRange.upperOpen is false
     65webkitIDBKeyRange.lowerBound(12.3,undefined)
     66PASS keyRange.lower is 12.3
     67PASS keyRange.lowerOpen is false
     68PASS keyRange.upper is null
     69PASS keyRange.upperOpen is false
    5070webkitIDBKeyRange.lowerBound('aa',true)
    5171PASS keyRange.lower is 'aa'
     
    7595webkitIDBKeyRange.upperBound(22,undefined)
    7696PASS keyRange.upper is 22
     97PASS keyRange.upperOpen is false
     98PASS keyRange.lower is null
     99PASS keyRange.lowerOpen is false
     100webkitIDBKeyRange.upperBound(20.2,true)
     101PASS keyRange.upper is 20.2
     102PASS keyRange.upperOpen is true
     103PASS keyRange.lower is null
     104PASS keyRange.lowerOpen is false
     105webkitIDBKeyRange.upperBound(21.3,false)
     106PASS keyRange.upper is 21.3
     107PASS keyRange.upperOpen is false
     108PASS keyRange.lower is null
     109PASS keyRange.lowerOpen is false
     110webkitIDBKeyRange.upperBound(22.4,undefined)
     111PASS keyRange.upper is 22.4
    77112PASS keyRange.upperOpen is false
    78113PASS keyRange.lower is null
     
    118153PASS keyRange.lowerOpen is true
    119154PASS keyRange.upperOpen is true
     155webkitIDBKeyRange.bound(30.1,40.2, {lowerOpen: undefined, upperOpen:undefined})
     156PASS keyRange.lower is 30.1
     157PASS keyRange.upper is 40.2
     158PASS keyRange.lowerOpen is false
     159PASS keyRange.upperOpen is false
     160webkitIDBKeyRange.bound(31.3,41.4, {lowerOpen: false, upperOpen:false})
     161PASS keyRange.lower is 31.3
     162PASS keyRange.upper is 41.4
     163PASS keyRange.lowerOpen is false
     164PASS keyRange.upperOpen is false
     165webkitIDBKeyRange.bound(32.5,42.6, {lowerOpen: false, upperOpen:true})
     166PASS keyRange.lower is 32.5
     167PASS keyRange.upper is 42.6
     168PASS keyRange.lowerOpen is false
     169PASS keyRange.upperOpen is true
     170webkitIDBKeyRange.bound(33.7,43.8, {lowerOpen: true, upperOpen:false})
     171PASS keyRange.lower is 33.7
     172PASS keyRange.upper is 43.8
     173PASS keyRange.lowerOpen is true
     174PASS keyRange.upperOpen is false
     175webkitIDBKeyRange.bound(34.9,44, {lowerOpen: true, upperOpen:true})
     176PASS keyRange.lower is 34.9
     177PASS keyRange.upper is 44
     178PASS keyRange.lowerOpen is true
     179PASS keyRange.upperOpen is true
    120180webkitIDBKeyRange.bound('aaa','aba', {lowerOpen: false, upperOpen:false})
    121181PASS keyRange.lower is 'aaa'
  • trunk/LayoutTests/storage/indexeddb/keyrange.html

    r73633 r73697  
    8585
    8686    checkSingleKeyRange(1);
     87    checkSingleKeyRange(3.14);
    8788    checkSingleKeyRange("'a'");
    8889
     
    9091    checkLowerBoundKeyRange(11, false);
    9192    checkLowerBoundKeyRange(12);
     93    checkLowerBoundKeyRange(10.1, true);
     94    checkLowerBoundKeyRange(11.2, false);
     95    checkLowerBoundKeyRange(12.3);
    9296    checkLowerBoundKeyRange("'aa'", true);
    9397    checkLowerBoundKeyRange("'ab'", false);
     
    97101    checkUpperBoundKeyRange(21, false);
    98102    checkUpperBoundKeyRange(22);
     103    checkUpperBoundKeyRange(20.2, true);
     104    checkUpperBoundKeyRange(21.3, false);
     105    checkUpperBoundKeyRange(22.4);
    99106    checkUpperBoundKeyRange("'ba'", true);
    100107    checkUpperBoundKeyRange("'bb'", false);
     
    106113    checkBoundKeyRange(33, 43, true, false);
    107114    checkBoundKeyRange(34, 44, true, true);
     115
     116    checkBoundKeyRange(30.1, 40.2);
     117    checkBoundKeyRange(31.3, 41.4, false, false);
     118    checkBoundKeyRange(32.5, 42.6, false, true);
     119    checkBoundKeyRange(33.7, 43.8, true, false);
     120    checkBoundKeyRange(34.9, 44.0, true, true);
    108121
    109122    checkBoundKeyRange("'aaa'", "'aba'", false, false);
  • trunk/LayoutTests/storage/indexeddb/objectstore-cursor.html

    r73633 r73697  
    1717// In order of how it should be sorted by IndexedDB.
    1818window.testData = [
    19     1,
    20     2,
     19    2.718281828459,
    2120    3,
     21    3.14159265,
    2222    10,
    2323    // FIXME: Dates.
  • trunk/WebCore/ChangeLog

    r73695 r73697  
     12010-12-10  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        IndexedDB: Numeric keys are floats.
     6        https://bugs.webkit.org/show_bug.cgi?id=50674
     7
     8        Use floating point to represent numeric keys,
     9        add version meta data to the SQLite db,
     10        and migrate object stores that use integers.
     11
     12        * bindings/v8/IDBBindingUtilities.cpp:
     13        (WebCore::createIDBKeyFromValue):
     14        * bindings/v8/custom/V8IDBKeyCustom.cpp:
     15        (WebCore::toV8):
     16        * storage/IDBFactoryBackendImpl.cpp:
     17        (WebCore::createTables):
     18        (WebCore::migrateDatabase):
     19        (WebCore::IDBFactoryBackendImpl::open):
     20        * storage/IDBKey.cpp:
     21        (WebCore::IDBKey::IDBKey):
     22        (WebCore::IDBKey::fromQuery):
     23        (WebCore::IDBKey::bind):
     24        (WebCore::IDBKey::bindWithNulls):
     25        * storage/IDBKey.h:
     26        (WebCore::IDBKey::create):
     27        (WebCore::IDBKey::number):
     28
    1292010-12-10  Martin Robinson  <mrobinson@igalia.com>
    230
     
    827855        * svg/SVGUseElement.cpp:
    828856        (WebCore::ShadowTreeUpdateBlocker::while): Ditto.
    829 
    830 2010-12-09  Hans Wennborg  <hans@chromium.org>
    831 
    832         Reviewed by Jeremy Orlow.
    833 
    834         IndexedDB: Numeric keys are floats.
    835         https://bugs.webkit.org/show_bug.cgi?id=50674
    836 
    837         Use floating point to represent numeric keys,
    838         add version meta data to the SQLite db,
    839         and migrate object stores that use integers.
    840 
    841         * bindings/v8/IDBBindingUtilities.cpp:
    842         (WebCore::createIDBKeyFromValue):
    843         * bindings/v8/custom/V8IDBKeyCustom.cpp:
    844         (WebCore::toV8):
    845         * storage/IDBFactoryBackendImpl.cpp:
    846         (WebCore::createTables):
    847         (WebCore::migrateDatabase):
    848         (WebCore::IDBFactoryBackendImpl::open):
    849         * storage/IDBKey.cpp:
    850         (WebCore::IDBKey::IDBKey):
    851         (WebCore::IDBKey::fromQuery):
    852         (WebCore::IDBKey::bind):
    853         (WebCore::IDBKey::bindWithNulls):
    854         * storage/IDBKey.h:
    855         (WebCore::IDBKey::create):
    856         (WebCore::IDBKey::number):
    857857
    8588582010-12-09  Brady Eidson  <beidson@apple.com>
  • trunk/WebCore/bindings/v8/IDBBindingUtilities.cpp

    r73633 r73697  
    4242    if (value->IsNull())
    4343        return IDBKey::create();
    44     if (value->IsInt32())
    45         return IDBKey::create(value->Int32Value());
     44    if (value->IsNumber())
     45        return IDBKey::create(value->NumberValue());
    4646    if (value->IsString())
    4747        return IDBKey::create(v8ValueToWebCoreString(value));
  • trunk/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp

    r73633 r73697  
    4646        return v8::Null();
    4747    case IDBKey::NumberType:
    48         return v8::Integer::New(key->number());
     48        return v8::Number::New(key->number());
    4949    case IDBKey::StringType:
    5050        return v8String(key->string());
  • trunk/WebCore/storage/IDBFactoryBackendImpl.cpp

    r73633 r73697  
    3636#include "IDBSQLiteDatabase.h"
    3737#include "IDBTransactionCoordinator.h"
     38#include "SQLiteStatement.h"
     39#include "SQLiteTransaction.h"
    3840#include "SecurityOrigin.h"
    3941#include <wtf/Threading.h>
     
    9496static bool createTables(SQLiteDatabase& sqliteDatabase)
    9597{
     98    if (sqliteDatabase.tableExists("Databases"))
     99        return true;
     100
    96101    static const char* commands[] = {
    97         "CREATE TABLE IF NOT EXISTS Databases (id INTEGER PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, version TEXT NOT NULL)",
    98         "CREATE UNIQUE INDEX IF NOT EXISTS Databases_name ON Databases(name)",
    99 
    100         "CREATE TABLE IF NOT EXISTS ObjectStores (id INTEGER PRIMARY KEY, name TEXT NOT NULL, keyPath TEXT, doAutoIncrement INTEGER NOT NULL, databaseId INTEGER NOT NULL REFERENCES Databases(id))",
    101         "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStores_composit ON ObjectStores(databaseId, name)",
    102 
    103         "CREATE TABLE IF NOT EXISTS Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",
    104         "CREATE UNIQUE INDEX IF NOT EXISTS Indexes_composit ON Indexes(objectStoreId, name)",
    105 
    106         "CREATE TABLE IF NOT EXISTS ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",
    107         "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
    108 
    109         "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL REFERENCES ObjectStoreData(id))",
    110         "CREATE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
    111         "CREATE INDEX IF NOT EXISTS IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
    112         "CREATE INDEX IF NOT EXISTS IndexData_indexId ON IndexData(indexId)"
     102        "CREATE TABLE Databases (id INTEGER PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, version TEXT NOT NULL)",
     103        "CREATE UNIQUE INDEX Databases_name ON Databases(name)",
     104
     105        "CREATE TABLE ObjectStores (id INTEGER PRIMARY KEY, name TEXT NOT NULL, keyPath TEXT, doAutoIncrement INTEGER NOT NULL, databaseId INTEGER NOT NULL REFERENCES Databases(id))",
     106        "CREATE UNIQUE INDEX ObjectStores_composit ON ObjectStores(databaseId, name)",
     107
     108        "CREATE TABLE Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",
     109        "CREATE UNIQUE INDEX Indexes_composit ON Indexes(objectStoreId, name)",
     110
     111        "CREATE TABLE ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",
     112        "CREATE UNIQUE INDEX ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
     113
     114        "CREATE TABLE IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL REFERENCES ObjectStoreData(id))",
     115        "CREATE INDEX IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
     116        "CREATE INDEX IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
     117        "CREATE INDEX IndexData_indexId ON IndexData(indexId)",
    113118        };
    114119
     120    SQLiteTransaction transaction(sqliteDatabase, false);
     121    transaction.begin();
    115122    for (size_t i = 0; i < arraysize(commands); ++i) {
    116123        if (!sqliteDatabase.executeCommand(commands[i])) {
     
    120127        }
    121128    }
     129    transaction.commit();
     130    return true;
     131}
     132
     133static bool createMetaDataTable(SQLiteDatabase& sqliteDatabase)
     134{
     135    static const char* commands[] = {
     136        "CREATE TABLE MetaData (name TEXT PRIMARY KEY, value NONE)",
     137        "INSERT INTO MetaData VALUES ('version', 1)",
     138    };
     139
     140    SQLiteTransaction transaction(sqliteDatabase, false);
     141    transaction.begin();
     142    for (size_t i = 0; i < arraysize(commands); ++i) {
     143        if (!sqliteDatabase.executeCommand(commands[i]))
     144            return false;
     145    }
     146    transaction.commit();
     147    return true;
     148}
     149
     150static bool getDatabaseVersion(SQLiteDatabase& sqliteDatabase, int* databaseVersion)
     151{
     152    SQLiteStatement query(sqliteDatabase, "SELECT value FROM MetaData WHERE name = 'version'");
     153    if (query.prepare() != SQLResultOk || query.step() != SQLResultRow)
     154        return false;
     155
     156    *databaseVersion = query.getColumnInt(0);
     157    return query.finalize() == SQLResultOk;
     158}
     159
     160static bool migrateDatabase(SQLiteDatabase& sqliteDatabase)
     161{
     162    if (!sqliteDatabase.tableExists("MetaData")) {
     163        if (!createMetaDataTable(sqliteDatabase))
     164            return false;
     165    }
     166
     167    int databaseVersion;
     168    if (!getDatabaseVersion(sqliteDatabase, &databaseVersion))
     169        return false;
     170
     171    if (databaseVersion == 1) {
     172        static const char* commands[] = {
     173            "DROP TABLE IF EXISTS ObjectStoreData2",
     174            "CREATE TABLE ObjectStoreData2 (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate REAL, keyNumber REAL, value TEXT NOT NULL)",
     175            "INSERT INTO ObjectStoreData2 SELECT * FROM ObjectStoreData",
     176            "DROP TABLE ObjectStoreData", // This depends on SQLite not enforcing referential consistency.
     177            "ALTER TABLE ObjectStoreData2 RENAME TO ObjectStoreData",
     178            "CREATE UNIQUE INDEX ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
     179            "DROP TABLE IF EXISTS IndexData2", // This depends on SQLite not enforcing referential consistency.
     180            "CREATE TABLE IndexData2 (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate REAL, keyNumber REAL, objectStoreDataId INTEGER NOT NULL REFERENCES ObjectStoreData(id))",
     181            "INSERT INTO IndexData2 SELECT * FROM IndexData",
     182            "DROP TABLE IndexData",
     183            "ALTER TABLE IndexData2 RENAME TO IndexData",
     184            "CREATE INDEX IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
     185            "CREATE INDEX IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
     186            "CREATE INDEX IndexData_indexId ON IndexData(indexId)",
     187            "UPDATE MetaData SET value = 2 WHERE name = 'version'",
     188        };
     189
     190        SQLiteTransaction transaction(sqliteDatabase, false);
     191        transaction.begin();
     192        for (size_t i = 0; i < arraysize(commands); ++i) {
     193            if (!sqliteDatabase.executeCommand(commands[i])) {
     194                LOG_ERROR("Failed to run the following command for IndexedDB: %s", commands[i]);
     195                return false;
     196            }
     197        }
     198        transaction.commit();
     199
     200        databaseVersion = 2;
     201    }
     202
    122203    return true;
    123204}
     
    142223        sqliteDatabase = openSQLiteDatabase(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
    143224
    144         if (!sqliteDatabase || !createTables(sqliteDatabase->db())) {
     225        if (!sqliteDatabase || !createTables(sqliteDatabase->db()) || !migrateDatabase(sqliteDatabase->db())) {
    145226            callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
     227            m_sqliteDatabaseMap.set(fileIdentifier, 0);
    146228            return;
    147229        }
     
    157239
    158240#endif // ENABLE(INDEXED_DATABASE)
    159 
  • trunk/WebCore/storage/IDBKey.cpp

    r73633 r73697  
    3939}
    4040
    41 IDBKey::IDBKey(int32_t number)
     41IDBKey::IDBKey(double number)
    4242    : m_type(NumberType)
    4343    , m_number(number)
     
    6666
    6767    if (!query.isColumnNull(baseColumn + 2))
    68         return IDBKey::create(query.getColumnInt(baseColumn + 2));
     68        return IDBKey::create(query.getColumnDouble(baseColumn + 2));
    6969
    7070    return IDBKey::create(); // Null.
     
    148148        return 1;
    149149    case IDBKey::NumberType:
    150         query.bindInt(column, m_number);
     150        query.bindDouble(column, m_number);
    151151        return 1;
    152152    case IDBKey::NullType:
     
    169169        query.bindNull(baseColumn + 0);
    170170        query.bindNull(baseColumn + 1);
    171         query.bindInt(baseColumn + 2, m_number);
     171        query.bindDouble(baseColumn + 2, m_number);
    172172        break;
    173173    case IDBKey::NullType:
  • trunk/WebCore/storage/IDBKey.h

    r73633 r73697  
    4444        return adoptRef(new IDBKey());
    4545    }
    46     static PassRefPtr<IDBKey> create(int32_t number)
     46    static PassRefPtr<IDBKey> create(double number)
    4747    {
    4848        return adoptRef(new IDBKey(number));
     
    6969    }
    7070
    71     int32_t number() const
     71    double number() const
    7272    {
    7373        ASSERT(m_type == NumberType);
     
    8989private:
    9090    IDBKey();
    91     explicit IDBKey(int32_t);
     91    explicit IDBKey(double);
    9292    explicit IDBKey(const String&);
    9393
    9494    Type m_type;
    9595    String m_string;
    96     int32_t m_number;
     96    double m_number;
    9797};
    9898
  • trunk/WebKit/chromium/ChangeLog

    r73633 r73697  
     12010-12-10  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        IndexedDB: Numeric keys are floats.
     6        https://bugs.webkit.org/show_bug.cgi?id=50674
     7
     8        Represent numeric keys as floating point values.
     9
     10        * public/WebIDBKey.h:
     11        (WebKit::WebIDBKey::WebIDBKey):
     12        * src/WebIDBKey.cpp:
     13        (WebKit::WebIDBKey::assign):
     14        (WebKit::WebIDBKey::number):
     15
    1162010-12-09  Sheriff Bot  <webkit.review.bot@gmail.com>
    217
  • trunk/WebKit/chromium/public/WebIDBKey.h

    r73633 r73697  
    4949
    5050    WebIDBKey(const WebString& string) { assign(string); }
    51     WebIDBKey(int32_t number) { assign(number); }
     51    WebIDBKey(double number) { assign(number); }
    5252    WebIDBKey(const WebIDBKey& e) { assign(e); }
    5353    WebIDBKey& operator=(const WebIDBKey& e)
     
    6060    WEBKIT_API void assignNull();
    6161    WEBKIT_API void assign(const WebString&);
    62     WEBKIT_API void assign(int32_t);
     62    WEBKIT_API void assign(double);
    6363    WEBKIT_API void assignInvalid();
    6464    WEBKIT_API void reset();
     
    7474    WEBKIT_API Type type() const;
    7575    WEBKIT_API WebString string() const; // Only valid for StringType.
    76     WEBKIT_API int32_t number() const; // Only valid for numberType.
     76    WEBKIT_API double number() const; // Only valid for numberType.
    7777
    7878#if WEBKIT_IMPLEMENTATION
  • trunk/WebKit/chromium/src/WebIDBKey.cpp

    r73633 r73697  
    7878}
    7979
    80 void WebIDBKey::assign(int32_t number)
     80void WebIDBKey::assign(double number)
    8181{
    8282    m_private = IDBKey::create(number);
     
    105105}
    106106
    107 int32_t WebIDBKey::number() const
     107double WebIDBKey::number() const
    108108{
    109109    return m_private->number();
Note: See TracChangeset for help on using the changeset viewer.