Changeset 199120 in webkit
- Timestamp:
- Apr 6, 2016 3:25:37 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199119 r199120 1 2016-04-06 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: Make sure SQLite backing store records have a INTEGER PRIMARY KEY column. 4 https://bugs.webkit.org/show_bug.cgi?id=156264 5 6 Reviewed by Alex Christensen. 7 8 No new tests (No testable change in behavior yet, current tests pass). 9 10 * Modules/indexeddb/IDBKeyData.cpp: 11 (WebCore::IDBKeyData::encode): Fix the key name for backwards compatibility. 12 (WebCore::IDBKeyData::decode): Ditto. 13 14 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 15 (WebCore::IDBServer::v3RecordsTableSchema): Added v3 Records schema that includes a primary key column. 16 (WebCore::IDBServer::v3RecordsTableSchemaAlternate): 17 (WebCore::IDBServer::createOrMigrateRecordsTableIfNecessary): Upgrade to v3 instead of v2. 18 (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): 19 1 20 2016-04-06 Simon Fraser <simon.fraser@apple.com> 2 21 -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp
r197306 r199120 134 134 return; 135 135 136 encoder.encodeEnum(" m_type", m_type);136 encoder.encodeEnum("type", m_type); 137 137 138 138 switch (m_type) { … … 176 176 || value == KeyType::Min; 177 177 }; 178 if (!decoder.decodeEnum(" m_type", result.m_type, enumFunction))178 if (!decoder.decodeEnum("type", result.m_type, enumFunction)) 179 179 return false; 180 180 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r199078 r199120 110 110 } 111 111 112 static const String v3RecordsTableSchema(const String& tableName) 113 { 114 return makeString("CREATE TABLE ", tableName, " (objectStoreID INTEGER NOT NULL ON CONFLICT FAIL, key TEXT COLLATE IDBKEY NOT NULL ON CONFLICT FAIL, value NOT NULL ON CONFLICT FAIL, recordID INTEGER PRIMARY KEY)"); 115 } 116 117 static const String& v3RecordsTableSchema() 118 { 119 static NeverDestroyed<WTF::String> v3RecordsTableSchemaString(v3RecordsTableSchema("Records")); 120 return v3RecordsTableSchemaString; 121 } 122 123 static const String& v3RecordsTableSchemaAlternate() 124 { 125 static NeverDestroyed<WTF::String> v3RecordsTableSchemaString(v3RecordsTableSchema("\"Records\"")); 126 return v3RecordsTableSchemaString; 127 } 128 112 129 static const String v1IndexRecordsTableSchema(const String& tableName) 113 130 { … … 202 219 // If there is no Records table at all, create it and then bail. 203 220 if (sqliteResult == SQLITE_DONE) { 204 if (!database.executeCommand(v 2RecordsTableSchema())) {221 if (!database.executeCommand(v3RecordsTableSchema())) { 205 222 LOG_ERROR("Could not create Records table in database (%i) - %s", database.lastError(), database.lastErrorMsg()); 206 223 return false; … … 221 238 222 239 // If the schema in the backing store is the current schema, we're done. 223 if (currentSchema == v 2RecordsTableSchema() || currentSchema == v2RecordsTableSchemaAlternate())240 if (currentSchema == v3RecordsTableSchema() || currentSchema == v3RecordsTableSchemaAlternate()) 224 241 return true; 225 242 226 243 // If the record table is not the current schema then it must be one of the previous schemas. 227 244 // If it is not then the database is in an unrecoverable state and this should be considered a fatal error. 228 if (currentSchema != v1RecordsTableSchema() && currentSchema != v1RecordsTableSchemaAlternate()) 245 if (currentSchema != v1RecordsTableSchema() && currentSchema != v1RecordsTableSchemaAlternate() 246 && currentSchema != v2RecordsTableSchema() && currentSchema != v2RecordsTableSchemaAlternate()) 229 247 RELEASE_ASSERT_NOT_REACHED(); 230 248 … … 233 251 234 252 // Create a temporary table with the correct schema and migrate all existing content over. 235 if (!database.executeCommand(v 2RecordsTableSchema("_Temp_Records"))) {253 if (!database.executeCommand(v3RecordsTableSchema("_Temp_Records"))) { 236 254 LOG_ERROR("Could not create temporary records table in database (%i) - %s", database.lastError(), database.lastErrorMsg()); 237 255 return false; 238 256 } 239 257 240 if (!database.executeCommand("INSERT INTO _Temp_Records SELECT *FROM Records")) {258 if (!database.executeCommand("INSERT INTO _Temp_Records (objectStoreID, key, value) SELECT objectStoreID, CAST(key AS TEXT), value FROM Records")) { 241 259 LOG_ERROR("Could not migrate existing Records content (%i) - %s", database.lastError(), database.lastErrorMsg()); 242 260 return false; … … 1307 1325 } 1308 1326 { 1309 SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO Records VALUES (?, CAST(? AS TEXT), ? );"));1327 SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO Records VALUES (?, CAST(? AS TEXT), ?, NULL);")); 1310 1328 if (sql.prepare() != SQLITE_OK 1311 1329 || sql.bindInt64(1, objectStoreInfo.identifier()) != SQLITE_OK
Note: See TracChangeset
for help on using the changeset viewer.