Commit 6a1a6dfd authored by hans@chromium.org's avatar hans@chromium.org

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 197a3918
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 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
......
......@@ -45,6 +45,7 @@ Deleted all object stores.
db.createObjectStore('storeName', null)
store.createIndex('indexName', 'x')
store.createIndex('indexName2', 'y', false)
store.createIndex('zIndex', 'z', true)
PASS 'name' in indexObject is true
PASS indexObject.name is "indexName"
PASS 'storeName' in indexObject is true
......@@ -57,7 +58,7 @@ PASS 'openKeyCursor' in indexObject is true
PASS 'openCursor' in indexObject is true
PASS 'getKey' in indexObject is true
PASS 'get' in indexObject is true
store.add({x: 'value', y: 'zzz'}, 'key')
store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'readyState' in result is true
......@@ -74,7 +75,7 @@ PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
event.source.add({x: 'value2', y: 'zzz2'}, 'key2')
event.source.add({x: 'value2', y: 'zzz2', z: 2.71}, 'key2')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'readyState' in result is true
......@@ -127,6 +128,24 @@ PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.result is "key"
indexObject3.get(2.71)
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'readyState' in result is true
An event should fire shortly...
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.result.x is "value2"
indexObject.get('value')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
......
......@@ -49,6 +49,7 @@ function createIndex()
window.store = evalAndLog("db.createObjectStore('storeName', null)");
window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', false)");
window.indexObject3 = evalAndLog("store.createIndex('zIndex', 'z', true)");
addData();
}
......@@ -67,7 +68,7 @@ function addData()
shouldBeTrue("'getKey' in indexObject");
shouldBeTrue("'get' in indexObject");
result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
result = evalAndLog("store.add({x: 'value', y: 'zzz', z: 2.72}, 'key')");
verifyResult(result);
result.onsuccess = addMore;
result.onerror = unexpectedErrorCallback;
......@@ -77,7 +78,7 @@ function addMore()
{
verifySuccessEvent(event);
result = evalAndLog("event.source.add({x: 'value2', y: 'zzz2'}, 'key2')");
result = evalAndLog("event.source.add({x: 'value2', y: 'zzz2', z: 2.71}, 'key2')");
verifyResult(result);
result.onsuccess = getData;
result.onerror = unexpectedErrorCallback;
......@@ -109,6 +110,17 @@ function getObjectData2()
verifySuccessEvent(event);
shouldBeEqualToString("event.result", "key");
result = evalAndLog("indexObject3.get(2.71)");
verifyResult(result);
result.onsuccess = getObjectData3;
result.onerror = unexpectedErrorCallback;
}
function getObjectData3()
{
verifySuccessEvent(event);
shouldBeEqualToString("event.result.x", "value2");
result = evalAndLog("indexObject.get('value')");
verifyResult(result);
result.onsuccess = getDataFail;
......
......@@ -18,8 +18,8 @@ if (window.layoutTestController)
window.testData = [
1,
1,
2,
2,
3.14159,
3.14159,
10,
// FIXME: Dates.
"A big string",
......
......@@ -27,6 +27,11 @@ PASS keyRange.lower is 1
PASS keyRange.upper is 1
PASS keyRange.lowerOpen is false
PASS keyRange.upperOpen is false
webkitIDBKeyRange.only(3.14)
PASS keyRange.lower is 3.14
PASS keyRange.upper is 3.14
PASS keyRange.lowerOpen is false
PASS keyRange.upperOpen is false
webkitIDBKeyRange.only('a')
PASS keyRange.lower is 'a'
PASS keyRange.upper is 'a'
......@@ -47,6 +52,21 @@ PASS keyRange.lower is 12
PASS keyRange.lowerOpen is false
PASS keyRange.upper is null
PASS keyRange.upperOpen is false
webkitIDBKeyRange.lowerBound(10.1,true)
PASS keyRange.lower is 10.1
PASS keyRange.lowerOpen is true
PASS keyRange.upper is null
PASS keyRange.upperOpen is false
webkitIDBKeyRange.lowerBound(11.2,false)
PASS keyRange.lower is 11.2
PASS keyRange.lowerOpen is false
PASS keyRange.upper is null
PASS keyRange.upperOpen is false
webkitIDBKeyRange.lowerBound(12.3,undefined)
PASS keyRange.lower is 12.3
PASS keyRange.lowerOpen is false
PASS keyRange.upper is null
PASS keyRange.upperOpen is false
webkitIDBKeyRange.lowerBound('aa',true)
PASS keyRange.lower is 'aa'
PASS keyRange.lowerOpen is true
......@@ -77,6 +97,21 @@ PASS keyRange.upper is 22
PASS keyRange.upperOpen is false
PASS keyRange.lower is null
PASS keyRange.lowerOpen is false
webkitIDBKeyRange.upperBound(20.2,true)
PASS keyRange.upper is 20.2
PASS keyRange.upperOpen is true
PASS keyRange.lower is null
PASS keyRange.lowerOpen is false
webkitIDBKeyRange.upperBound(21.3,false)
PASS keyRange.upper is 21.3
PASS keyRange.upperOpen is false
PASS keyRange.lower is null
PASS keyRange.lowerOpen is false
webkitIDBKeyRange.upperBound(22.4,undefined)
PASS keyRange.upper is 22.4
PASS keyRange.upperOpen is false
PASS keyRange.lower is null
PASS keyRange.lowerOpen is false
webkitIDBKeyRange.upperBound('ba',true)
PASS keyRange.upper is 'ba'
PASS keyRange.upperOpen is true
......@@ -117,6 +152,31 @@ PASS keyRange.lower is 34
PASS keyRange.upper is 44
PASS keyRange.lowerOpen is true
PASS keyRange.upperOpen is true
webkitIDBKeyRange.bound(30.1,40.2, {lowerOpen: undefined, upperOpen:undefined})
PASS keyRange.lower is 30.1
PASS keyRange.upper is 40.2
PASS keyRange.lowerOpen is false
PASS keyRange.upperOpen is false
webkitIDBKeyRange.bound(31.3,41.4, {lowerOpen: false, upperOpen:false})
PASS keyRange.lower is 31.3
PASS keyRange.upper is 41.4
PASS keyRange.lowerOpen is false
PASS keyRange.upperOpen is false
webkitIDBKeyRange.bound(32.5,42.6, {lowerOpen: false, upperOpen:true})
PASS keyRange.lower is 32.5
PASS keyRange.upper is 42.6
PASS keyRange.lowerOpen is false
PASS keyRange.upperOpen is true
webkitIDBKeyRange.bound(33.7,43.8, {lowerOpen: true, upperOpen:false})
PASS keyRange.lower is 33.7
PASS keyRange.upper is 43.8
PASS keyRange.lowerOpen is true
PASS keyRange.upperOpen is false
webkitIDBKeyRange.bound(34.9,44, {lowerOpen: true, upperOpen:true})
PASS keyRange.lower is 34.9
PASS keyRange.upper is 44
PASS keyRange.lowerOpen is true
PASS keyRange.upperOpen is true
webkitIDBKeyRange.bound('aaa','aba', {lowerOpen: false, upperOpen:false})
PASS keyRange.lower is 'aaa'
PASS keyRange.upper is 'aba'
......
......@@ -84,11 +84,15 @@ function test()
debug("");
checkSingleKeyRange(1);
checkSingleKeyRange(3.14);
checkSingleKeyRange("'a'");
checkLowerBoundKeyRange(10, true);
checkLowerBoundKeyRange(11, false);
checkLowerBoundKeyRange(12);
checkLowerBoundKeyRange(10.1, true);
checkLowerBoundKeyRange(11.2, false);
checkLowerBoundKeyRange(12.3);
checkLowerBoundKeyRange("'aa'", true);
checkLowerBoundKeyRange("'ab'", false);
checkLowerBoundKeyRange("'ac'");
......@@ -96,6 +100,9 @@ function test()
checkUpperBoundKeyRange(20, true);
checkUpperBoundKeyRange(21, false);
checkUpperBoundKeyRange(22);
checkUpperBoundKeyRange(20.2, true);
checkUpperBoundKeyRange(21.3, false);
checkUpperBoundKeyRange(22.4);
checkUpperBoundKeyRange("'ba'", true);
checkUpperBoundKeyRange("'bb'", false);
checkUpperBoundKeyRange("'bc'");
......@@ -106,6 +113,12 @@ function test()
checkBoundKeyRange(33, 43, true, false);
checkBoundKeyRange(34, 44, true, true);
checkBoundKeyRange(30.1, 40.2);
checkBoundKeyRange(31.3, 41.4, false, false);
checkBoundKeyRange(32.5, 42.6, false, true);
checkBoundKeyRange(33.7, 43.8, true, false);
checkBoundKeyRange(34.9, 44.0, true, true);
checkBoundKeyRange("'aaa'", "'aba'", false, false);
checkBoundKeyRange("'aab'", "'abb'");
checkBoundKeyRange("'aac'", "'abc'", false, false);
......
......@@ -16,9 +16,9 @@ if (window.layoutTestController)
// In order of how it should be sorted by IndexedDB.
window.testData = [
1,
2,
2.718281828459,
3,
3.14159265,
10,
// FIXME: Dates.
"A bigger string",
......
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 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
......@@ -827,34 +855,6 @@
* svg/SVGUseElement.cpp:
(WebCore::ShadowTreeUpdateBlocker::while): Ditto.
2010-12-09 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-09 Brady Eidson <beidson@apple.com>
Reviewed by Maciej Stachowiak.
......
......@@ -41,8 +41,8 @@ PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value)
{
if (value->IsNull())
return IDBKey::create();
if (value->IsInt32())
return IDBKey::create(value->Int32Value());
if (value->IsNumber())
return IDBKey::create(value->NumberValue());
if (value->IsString())
return IDBKey::create(v8ValueToWebCoreString(value));
if (value->IsDate())
......
......@@ -45,7 +45,7 @@ v8::Handle<v8::Value> toV8(IDBKey* key)
case IDBKey::NullType:
return v8::Null();
case IDBKey::NumberType:
return v8::Integer::New(key->number());
return v8::Number::New(key->number());
case IDBKey::StringType:
return v8String(key->string());
// FIXME: Implement dates.
......
......@@ -35,6 +35,8 @@
#include "IDBDatabaseException.h"
#include "IDBSQLiteDatabase.h"
#include "IDBTransactionCoordinator.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
#include "SecurityOrigin.h"
#include <wtf/Threading.h>
#include <wtf/UnusedParam.h>
......@@ -93,25 +95,30 @@ static PassRefPtr<IDBSQLiteDatabase> openSQLiteDatabase(SecurityOrigin* security
static bool createTables(SQLiteDatabase& sqliteDatabase)
{
if (sqliteDatabase.tableExists("Databases"))
return true;
static const char* commands[] = {
"CREATE TABLE IF NOT EXISTS Databases (id INTEGER PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, version TEXT NOT NULL)",
"CREATE UNIQUE INDEX IF NOT EXISTS Databases_name ON Databases(name)",
"CREATE TABLE Databases (id INTEGER PRIMARY KEY, name TEXT NOT NULL, description TEXT NOT NULL, version TEXT NOT NULL)",
"CREATE UNIQUE INDEX Databases_name ON Databases(name)",
"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))",
"CREATE UNIQUE INDEX IF NOT EXISTS ObjectStores_composit ON ObjectStores(databaseId, name)",
"CREATE TABLE ObjectStores (id INTEGER PRIMARY KEY, name TEXT NOT NULL, keyPath TEXT, doAutoIncrement INTEGER NOT NULL, databaseId INTEGER NOT NULL REFERENCES Databases(id))",
"CREATE UNIQUE INDEX ObjectStores_composit ON ObjectStores(databaseId, name)",
"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)",
"CREATE UNIQUE INDEX IF NOT EXISTS Indexes_composit ON Indexes(objectStoreId, name)",
"CREATE TABLE Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",
"CREATE UNIQUE INDEX Indexes_composit ON Indexes(objectStoreId, name)",
"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)",
"CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
"CREATE TABLE ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",
"CREATE UNIQUE INDEX ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
"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))",
"CREATE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
"CREATE INDEX IF NOT EXISTS IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
"CREATE INDEX IF NOT EXISTS IndexData_indexId ON IndexData(indexId)"
"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))",
"CREATE INDEX IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
"CREATE INDEX IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
"CREATE INDEX IndexData_indexId ON IndexData(indexId)",
};
SQLiteTransaction transaction(sqliteDatabase, false);
transaction.begin();
for (size_t i = 0; i < arraysize(commands); ++i) {
if (!sqliteDatabase.executeCommand(commands[i])) {
// FIXME: We should try to recover from this situation. Maybe nuke the database and start over?
......@@ -119,6 +126,80 @@ static bool createTables(SQLiteDatabase& sqliteDatabase)
return false;
}
}
transaction.commit();
return true;
}
static bool createMetaDataTable(SQLiteDatabase& sqliteDatabase)
{
static const char* commands[] = {
"CREATE TABLE MetaData (name TEXT PRIMARY KEY, value NONE)",
"INSERT INTO MetaData VALUES ('version', 1)",
};
SQLiteTransaction transaction(sqliteDatabase, false);
transaction.begin();
for (size_t i = 0; i < arraysize(commands); ++i) {
if (!sqliteDatabase.executeCommand(commands[i]))
return false;
}
transaction.commit();
return true;
}
static bool getDatabaseVersion(SQLiteDatabase& sqliteDatabase, int* databaseVersion)
{
SQLiteStatement query(sqliteDatabase, "SELECT value FROM MetaData WHERE name = 'version'");
if (query.prepare() != SQLResultOk || query.step() != SQLResultRow)
return false;
*databaseVersion = query.getColumnInt(0);
return query.finalize() == SQLResultOk;
}
static bool migrateDatabase(SQLiteDatabase& sqliteDatabase)
{
if (!sqliteDatabase.tableExists("MetaData")) {
if (!createMetaDataTable(sqliteDatabase))
return false;
}
int databaseVersion;
if (!getDatabaseVersion(sqliteDatabase, &databaseVersion))
return false;
if (databaseVersion == 1) {
static const char* commands[] = {
"DROP TABLE IF EXISTS ObjectStoreData2",
"CREATE TABLE ObjectStoreData2 (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate REAL, keyNumber REAL, value TEXT NOT NULL)",
"INSERT INTO ObjectStoreData2 SELECT * FROM ObjectStoreData",
"DROP TABLE ObjectStoreData", // This depends on SQLite not enforcing referential consistency.
"ALTER TABLE ObjectStoreData2 RENAME TO ObjectStoreData",
"CREATE UNIQUE INDEX ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
"DROP TABLE IF EXISTS IndexData2", // This depends on SQLite not enforcing referential consistency.
"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))",
"INSERT INTO IndexData2 SELECT * FROM IndexData",
"DROP TABLE IndexData",
"ALTER TABLE IndexData2 RENAME TO IndexData",
"CREATE INDEX IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
"CREATE INDEX IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
"CREATE INDEX IndexData_indexId ON IndexData(indexId)",
"UPDATE MetaData SET value = 2 WHERE name = 'version'",
};
SQLiteTransaction transaction(sqliteDatabase, false);
transaction.begin();
for (size_t i = 0; i < arraysize(commands); ++i) {
if (!sqliteDatabase.executeCommand(commands[i])) {
LOG_ERROR("Failed to run the following command for IndexedDB: %s", commands[i]);
return false;
}
}
transaction.commit();
databaseVersion = 2;
}
return true;
}
......@@ -141,8 +222,9 @@ void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> ca
else {
sqliteDatabase = openSQLiteDatabase(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
if (!sqliteDatabase || !createTables(sqliteDatabase->db())) {
if (!sqliteDatabase || !createTables(sqliteDatabase->db()) || !migrateDatabase(sqliteDatabase->db())) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
m_sqliteDatabaseMap.set(fileIdentifier, 0);
return;
}
m_sqliteDatabaseMap.set(fileIdentifier, sqliteDatabase.get());
......@@ -156,4 +238,3 @@ void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> ca
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
......@@ -38,7 +38,7 @@ IDBKey::IDBKey()
{
}
IDBKey::IDBKey(int32_t number)
IDBKey::IDBKey(double number)
: m_type(NumberType)
, m_number(number)
{
......@@ -65,7 +65,7 @@ PassRefPtr<IDBKey> IDBKey::fromQuery(SQLiteStatement& query, int baseColumn)
}
if (!query.isColumnNull(baseColumn + 2))
return IDBKey::create(query.getColumnInt(baseColumn + 2));
return IDBKey::create(query.getColumnDouble(baseColumn + 2));
return IDBKey::create(); // Null.
}
......@@ -147,7 +147,7 @@ int IDBKey::bind(SQLiteStatement& query, int column) const
query.bindText(column, m_string);
return 1;
case IDBKey::NumberType:
query.bindInt(column, m_number);
query.bindDouble(column, m_number);
return 1;
case IDBKey::NullType:
return 0;
......@@ -168,7 +168,7 @@ void IDBKey::bindWithNulls(SQLiteStatement& query, int baseColumn) const
case IDBKey::NumberType:
query.bindNull(baseColumn + 0);
query.bindNull(baseColumn + 1);
query.bindInt(baseColumn + 2, m_number);
query.bindDouble(baseColumn + 2, m_number);
break;
case IDBKey::NullType:
query.bindNull(baseColumn + 0);
......
......@@ -43,7 +43,7 @@ public:
{
return adoptRef(new IDBKey());
}
static PassRefPtr<IDBKey> create(int32_t number)
static PassRefPtr<IDBKey> create(double number)
{
return adoptRef(new IDBKey(number));
}
......@@ -68,7 +68,7 @@ public:
return m_string;
}
int32_t number() const
double number() const
{
ASSERT(m_type == NumberType);
return m_number;
......@@ -88,12 +88,12 @@ public:
private:
IDBKey();
explicit IDBKey(int32_t);
explicit IDBKey(double);
explicit IDBKey(const String&);
Type m_type;
String m_string;
int32_t m_number;
double m_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):
2010-12-09 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r73616.
......
......@@ -48,7 +48,7 @@ public:
WEBKIT_API static WebIDBKey createFromValueAndKeyPath(const WebSerializedScriptValue&, const WebIDBKeyPath&);
WebIDBKey(const WebString& string) { assign(string); }
WebIDBKey(int32_t number) { assign(number); }
WebIDBKey(double number) { assign(number); }
WebIDBKey(const WebIDBKey& e) { assign(e); }
WebIDBKey& operator=(const WebIDBKey& e)
{
......@@ -59,7 +59,7 @@ public:
WEBKIT_API void assign(const WebIDBKey&);
WEBKIT_API void assignNull();
WEBKIT_API void assign(const WebString&);
WEBKIT_API void assign(int32_t);
WEBKIT_API void assign(double);
WEBKIT_API void assignInvalid();
WEBKIT_API void reset();
......@@ -73,7 +73,7 @@ public:
WEBKIT_API Type type() const;
WEBKIT_API WebString string() const; // Only valid for StringType.
WEBKIT_API int32_t number() const; // Only valid for numberType.
WEBKIT_API double number() const; // Only valid for numberType.
#if WEBKIT_IMPLEMENTATION
WebIDBKey(const WTF::PassRefPtr<WebCore::IDBKey>&);
......
......@@ -77,7 +77,7 @@ void WebIDBKey::assign(const WebString& string)
m_private = IDBKey::create(string);
}
void WebIDBKey::assign(int32_t number)
void WebIDBKey::assign(double number)
{
m_private = IDBKey::create(number);
}
......@@ -104,7 +104,7 @@ WebString WebIDBKey::string() const
return m_private->string();
}
int32_t WebIDBKey::number() const
double WebIDBKey::number() const
{
return m_private->number();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment