Changeset 65902 in webkit
- Timestamp:
- Aug 24, 2010 8:44:07 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r65901 r65902 1 2010-08-24 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Steve Block. 4 5 IndexedDB needs to manually delete all objectStore data and indexes 6 https://bugs.webkit.org/show_bug.cgi?id=44522 7 8 * storage/indexeddb/objectstore-removeobjectstore-expected.txt: Added. 9 * storage/indexeddb/objectstore-removeobjectstore.html: Added. 10 * storage/indexeddb/resources/shared.js: 11 (unexpectedSuccessCallback): 12 1 13 2010-08-24 Sam Weinig <sam@webkit.org> 2 14 -
trunk/LayoutTests/storage/indexeddb/resources/shared.js
r65670 r65902 52 52 } 53 53 54 function unexpectedSuccessCallback() 55 { 56 testFailed("Success function called unexpectedly."); 57 debug(""); 58 verifySuccessEvent(event); 59 done(); 60 } 61 54 62 function unexpectedErrorCallback() 55 63 { -
trunk/WebCore/ChangeLog
r65900 r65902 1 2010-08-24 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Steve Block. 4 5 IndexedDB needs to manually delete all objectStore data and indexes 6 https://bugs.webkit.org/show_bug.cgi?id=44522 7 8 Apparently it's only newer versions of SQLite that handle cascade 9 delete. The rest silently fail. So do it manually. 10 11 Test: storage/indexeddb/objectstore-removeobjectstore.html 12 13 * storage/IDBDatabaseBackendImpl.cpp: 14 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 15 (WebCore::doDelete): 16 (WebCore::IDBDatabaseBackendImpl::removeObjectStore): 17 * storage/IDBDatabaseBackendImpl.h: 18 * storage/IDBFactoryBackendImpl.cpp: 19 (WebCore::createTables): 20 * storage/IDBObjectStoreBackendImpl.cpp: 21 (WebCore::IDBObjectStoreBackendImpl::removeIndex): 22 * storage/IDBObjectStoreBackendImpl.h: 23 (WebCore::IDBObjectStoreBackendImpl::create): 24 (WebCore::IDBObjectStoreBackendImpl::id): 25 1 26 2010-08-23 Sam Weinig <sam@webkit.org> 2 27 -
trunk/WebCore/storage/IDBDatabaseBackendImpl.cpp
r65879 r65902 33 33 #include "SQLiteDatabase.h" 34 34 #include "SQLiteStatement.h" 35 #include "SQLiteTransaction.h" 35 36 36 37 #if ENABLE(INDEXED_DATABASE) … … 142 143 int64_t id = sqliteDatabase().lastInsertRowID(); 143 144 144 RefPtr<IDBObjectStoreBackendI nterface> objectStore = IDBObjectStoreBackendImpl::create(this, id, name, keyPath, autoIncrement);145 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, id, name, keyPath, autoIncrement); 145 146 ASSERT(objectStore->name() == name); 146 147 m_objectStores.set(name, objectStore); 147 callbacks->onSuccess(objectStore. release());148 callbacks->onSuccess(objectStore.get()); 148 149 } 149 150 … … 155 156 } 156 157 158 static void doDelete(SQLiteDatabase& db, const char* sql, int64_t id) 159 { 160 SQLiteStatement deleteQuery(db, sql); 161 bool ok = deleteQuery.prepare() == SQLResultOk; 162 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 163 deleteQuery.bindInt64(1, id); 164 ok = deleteQuery.step() == SQLResultDone; 165 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 166 } 167 157 168 void IDBDatabaseBackendImpl::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> callbacks) 158 169 { 159 if (!m_objectStores.contains(name)) { 170 RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(name); 171 if (!objectStore) { 160 172 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "No objectStore with that name exists.")); 161 173 return; 162 174 } 163 175 164 SQLiteStatement deleteQuery(sqliteDatabase(), "DELETE FROM ObjectStores WHERE name = ?"); 165 bool ok = deleteQuery.prepare() == SQLResultOk; 166 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 167 deleteQuery.bindText(1, name); 168 ok = deleteQuery.step() == SQLResultDone; 169 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 176 SQLiteTransaction transaction(sqliteDatabase()); 177 transaction.begin(); 178 doDelete(sqliteDatabase(), "DELETE FROM ObjectStores WHERE id = ?", objectStore->id()); 179 doDelete(sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE objectStoreId = ?", objectStore->id()); 180 doDelete(sqliteDatabase(), "DELETE FROM Indexes WHERE objectStoreId = ?", objectStore->id()); 181 // FIXME: Delete index data as well. 182 transaction.commit(); 170 183 171 184 m_objectStores.remove(name); -
trunk/WebCore/storage/IDBDatabaseBackendImpl.h
r65670 r65902 36 36 namespace WebCore { 37 37 38 class IDBObjectStoreBackendImpl; 38 39 class IDBTransactionCoordinator; 39 40 class SQLiteDatabase; … … 70 71 String m_version; 71 72 72 typedef HashMap<String, RefPtr<IDBObjectStoreBackendI nterface> > ObjectStoreMap;73 typedef HashMap<String, RefPtr<IDBObjectStoreBackendImpl> > ObjectStoreMap; 73 74 ObjectStoreMap m_objectStores; 74 75 -
trunk/WebCore/storage/IDBFactoryBackendImpl.cpp
r65670 r65902 89 89 90 90 "DROP TABLE IF EXISTS Indexes", 91 "CREATE TABLE IF NOT EXISTS Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id) ON DELETE CASCADE, name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",91 "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)", 92 92 "DROP INDEX IF EXISTS Indexes_composit", 93 93 "CREATE UNIQUE INDEX IF NOT EXISTS Indexes_composit ON Indexes(objectStoreId, name)", 94 94 95 95 "DROP TABLE IF EXISTS ObjectStoreData", 96 "CREATE TABLE IF NOT EXISTS ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id) ON DELETE CASCADE, keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",96 "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)", 97 97 "DROP INDEX IF EXISTS ObjectStoreData_composit", 98 98 "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)" -
trunk/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r65893 r65902 260 260 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 261 261 262 // FIXME: Delete index data as well. 263 262 264 m_indexes.remove(name); 263 265 callbacks->onSuccess(); -
trunk/WebCore/storage/IDBObjectStoreBackendImpl.h
r65667 r65902 40 40 class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface { 41 41 public: 42 static PassRefPtr<IDBObjectStoreBackendI nterface> create(IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement)42 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 43 43 { 44 44 return adoptRef(new IDBObjectStoreBackendImpl(database, id, name, keyPath, autoIncrement)); … … 46 46 ~IDBObjectStoreBackendImpl(); 47 47 48 int64_t id() const { return m_id; } 48 49 String name() const { return m_name; } 49 50 String keyPath() const { return m_keyPath; }
Note: See TracChangeset
for help on using the changeset viewer.