| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/file_path.h" | |
| 10 #include "base/file_util.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/scoped_temp_dir.h" | |
| 13 #include "base/stl_util.h" | |
| 14 #include "base/string_number_conversions.h" | |
| 15 #include "chrome/browser/sync/syncable/directory_backing_store.h" | |
| 16 #include "chrome/browser/sync/syncable/on_disk_directory_backing_store.h" | |
| 17 #include "chrome/browser/sync/syncable/syncable-inl.h" | |
| 18 #include "chrome/browser/sync/syncable/syncable.h" | |
| 19 #include "chrome/browser/sync/test/test_directory_backing_store.h" | |
| 20 #include "chrome/browser/sync/util/time.h" | |
| 21 #include "sql/connection.h" | |
| 22 #include "sql/statement.h" | |
| 23 #include "sync/protocol/bookmark_specifics.pb.h" | |
| 24 #include "sync/protocol/sync.pb.h" | |
| 25 #include "testing/gtest/include/gtest/gtest-param-test.h" | |
| 26 | |
| 27 namespace syncable { | |
| 28 | |
| 29 extern const int32 kCurrentDBVersion; | |
| 30 | |
| 31 class MigrationTest : public testing::TestWithParam<int> { | |
| 32 public: | |
| 33 virtual void SetUp() { | |
| 34 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 35 } | |
| 36 | |
| 37 protected: | |
| 38 std::string GetUsername() { | |
| 39 return "nick@chromium.org"; | |
| 40 } | |
| 41 | |
| 42 FilePath GetDatabasePath() { | |
| 43 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); | |
| 44 } | |
| 45 | |
| 46 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { | |
| 47 MetahandlesIndex metas; | |
| 48 STLElementDeleter<MetahandlesIndex> index_deleter(&metas); | |
| 49 Directory::KernelLoadInfo kernel_load_info; | |
| 50 return dbs->Load(&metas, &kernel_load_info) == OPENED; | |
| 51 } | |
| 52 | |
| 53 void SetUpVersion67Database(sql::Connection* connection); | |
| 54 void SetUpVersion68Database(sql::Connection* connection); | |
| 55 void SetUpVersion69Database(sql::Connection* connection); | |
| 56 void SetUpVersion70Database(sql::Connection* connection); | |
| 57 void SetUpVersion71Database(sql::Connection* connection); | |
| 58 void SetUpVersion72Database(sql::Connection* connection); | |
| 59 void SetUpVersion73Database(sql::Connection* connection); | |
| 60 void SetUpVersion74Database(sql::Connection* connection); | |
| 61 void SetUpVersion75Database(sql::Connection* connection); | |
| 62 void SetUpVersion76Database(sql::Connection* connection); | |
| 63 void SetUpVersion77Database(sql::Connection* connection); | |
| 64 | |
| 65 void SetUpCurrentDatabaseAndCheckVersion(sql::Connection* connection) { | |
| 66 SetUpVersion77Database(connection); // Prepopulates data. | |
| 67 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 68 new TestDirectoryBackingStore(GetUsername(), connection)); | |
| 69 | |
| 70 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get())); | |
| 71 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 72 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); | |
| 73 } | |
| 74 | |
| 75 private: | |
| 76 ScopedTempDir temp_dir_; | |
| 77 }; | |
| 78 | |
| 79 class DirectoryBackingStoreTest : public MigrationTest {}; | |
| 80 | |
| 81 #if defined(OS_WIN) | |
| 82 | |
| 83 // On Windows, we used to store timestamps in FILETIME format. | |
| 84 #define LEGACY_META_PROTO_TIMES_1 129079956640320000LL | |
| 85 #define LEGACY_META_PROTO_TIMES_2 128976886618480000LL | |
| 86 #define LEGACY_META_PROTO_TIMES_4 129002163642690000LL | |
| 87 #define LEGACY_META_PROTO_TIMES_5 129001555500000000LL | |
| 88 #define LEGACY_META_PROTO_TIMES_6 129053976170000000LL | |
| 89 #define LEGACY_META_PROTO_TIMES_7 128976864758480000LL | |
| 90 #define LEGACY_META_PROTO_TIMES_8 128976864758480000LL | |
| 91 #define LEGACY_META_PROTO_TIMES_9 128976864758480000LL | |
| 92 #define LEGACY_META_PROTO_TIMES_10 128976864758480000LL | |
| 93 #define LEGACY_META_PROTO_TIMES_11 129079956948440000LL | |
| 94 #define LEGACY_META_PROTO_TIMES_12 129079957513650000LL | |
| 95 #define LEGACY_META_PROTO_TIMES_13 129079957985300000LL | |
| 96 #define LEGACY_META_PROTO_TIMES_14 129079958383000000LL | |
| 97 | |
| 98 #define LEGACY_META_PROTO_TIMES_STR_1 "129079956640320000" | |
| 99 #define LEGACY_META_PROTO_TIMES_STR_2 "128976886618480000" | |
| 100 #define LEGACY_META_PROTO_TIMES_STR_4 "129002163642690000" | |
| 101 #define LEGACY_META_PROTO_TIMES_STR_5 "129001555500000000" | |
| 102 #define LEGACY_META_PROTO_TIMES_STR_6 "129053976170000000" | |
| 103 #define LEGACY_META_PROTO_TIMES_STR_7 "128976864758480000" | |
| 104 #define LEGACY_META_PROTO_TIMES_STR_8 "128976864758480000" | |
| 105 #define LEGACY_META_PROTO_TIMES_STR_9 "128976864758480000" | |
| 106 #define LEGACY_META_PROTO_TIMES_STR_10 "128976864758480000" | |
| 107 #define LEGACY_META_PROTO_TIMES_STR_11 "129079956948440000" | |
| 108 #define LEGACY_META_PROTO_TIMES_STR_12 "129079957513650000" | |
| 109 #define LEGACY_META_PROTO_TIMES_STR_13 "129079957985300000" | |
| 110 #define LEGACY_META_PROTO_TIMES_STR_14 "129079958383000000" | |
| 111 | |
| 112 // Generated via: | |
| 113 // | |
| 114 // ruby -ane '$F[1].sub!("LEGACY_", ""); $F[2] = Integer($F[2].sub!("LL", "")) /
10000 - 11644473600000; print "#{$F[0]} #{$F[1]} #{$F[2]}LL\n"' | |
| 115 // | |
| 116 // Magic numbers taken from | |
| 117 // http://stackoverflow.com/questions/5398557/java-library-for-dealing-with-win3
2-filetime . | |
| 118 | |
| 119 // Now we store them in Java format (ms since the Unix epoch). | |
| 120 #define META_PROTO_TIMES_1 1263522064032LL | |
| 121 #define META_PROTO_TIMES_2 1253215061848LL | |
| 122 #define META_PROTO_TIMES_4 1255742764269LL | |
| 123 #define META_PROTO_TIMES_5 1255681950000LL | |
| 124 #define META_PROTO_TIMES_6 1260924017000LL | |
| 125 #define META_PROTO_TIMES_7 1253212875848LL | |
| 126 #define META_PROTO_TIMES_8 1253212875848LL | |
| 127 #define META_PROTO_TIMES_9 1253212875848LL | |
| 128 #define META_PROTO_TIMES_10 1253212875848LL | |
| 129 #define META_PROTO_TIMES_11 1263522094844LL | |
| 130 #define META_PROTO_TIMES_12 1263522151365LL | |
| 131 #define META_PROTO_TIMES_13 1263522198530LL | |
| 132 #define META_PROTO_TIMES_14 1263522238300LL | |
| 133 | |
| 134 #define META_PROTO_TIMES_STR_1 "1263522064032" | |
| 135 #define META_PROTO_TIMES_STR_2 "1253215061848" | |
| 136 #define META_PROTO_TIMES_STR_4 "1255742764269" | |
| 137 #define META_PROTO_TIMES_STR_5 "1255681950000" | |
| 138 #define META_PROTO_TIMES_STR_6 "1260924017000" | |
| 139 #define META_PROTO_TIMES_STR_7 "1253212875848" | |
| 140 #define META_PROTO_TIMES_STR_8 "1253212875848" | |
| 141 #define META_PROTO_TIMES_STR_9 "1253212875848" | |
| 142 #define META_PROTO_TIMES_STR_10 "1253212875848" | |
| 143 #define META_PROTO_TIMES_STR_11 "1263522094844" | |
| 144 #define META_PROTO_TIMES_STR_12 "1263522151365" | |
| 145 #define META_PROTO_TIMES_STR_13 "1263522198530" | |
| 146 #define META_PROTO_TIMES_STR_14 "1263522238300" | |
| 147 | |
| 148 #else | |
| 149 | |
| 150 // On other platforms, we used to store timestamps in time_t format (s | |
| 151 // since the Unix epoch). | |
| 152 #define LEGACY_META_PROTO_TIMES_1 1263522064LL | |
| 153 #define LEGACY_META_PROTO_TIMES_2 1253215061LL | |
| 154 #define LEGACY_META_PROTO_TIMES_4 1255742764LL | |
| 155 #define LEGACY_META_PROTO_TIMES_5 1255681950LL | |
| 156 #define LEGACY_META_PROTO_TIMES_6 1260924017LL | |
| 157 #define LEGACY_META_PROTO_TIMES_7 1253212875LL | |
| 158 #define LEGACY_META_PROTO_TIMES_8 1253212875LL | |
| 159 #define LEGACY_META_PROTO_TIMES_9 1253212875LL | |
| 160 #define LEGACY_META_PROTO_TIMES_10 1253212875LL | |
| 161 #define LEGACY_META_PROTO_TIMES_11 1263522094LL | |
| 162 #define LEGACY_META_PROTO_TIMES_12 1263522151LL | |
| 163 #define LEGACY_META_PROTO_TIMES_13 1263522198LL | |
| 164 #define LEGACY_META_PROTO_TIMES_14 1263522238LL | |
| 165 | |
| 166 #define LEGACY_META_PROTO_TIMES_STR_1 "1263522064" | |
| 167 #define LEGACY_META_PROTO_TIMES_STR_2 "1253215061" | |
| 168 #define LEGACY_META_PROTO_TIMES_STR_4 "1255742764" | |
| 169 #define LEGACY_META_PROTO_TIMES_STR_5 "1255681950" | |
| 170 #define LEGACY_META_PROTO_TIMES_STR_6 "1260924017" | |
| 171 #define LEGACY_META_PROTO_TIMES_STR_7 "1253212875" | |
| 172 #define LEGACY_META_PROTO_TIMES_STR_8 "1253212875" | |
| 173 #define LEGACY_META_PROTO_TIMES_STR_9 "1253212875" | |
| 174 #define LEGACY_META_PROTO_TIMES_STR_10 "1253212875" | |
| 175 #define LEGACY_META_PROTO_TIMES_STR_11 "1263522094" | |
| 176 #define LEGACY_META_PROTO_TIMES_STR_12 "1263522151" | |
| 177 #define LEGACY_META_PROTO_TIMES_STR_13 "1263522198" | |
| 178 #define LEGACY_META_PROTO_TIMES_STR_14 "1263522238" | |
| 179 | |
| 180 // Now we store them in Java format (ms since the Unix epoch). | |
| 181 #define META_PROTO_TIMES_1 1263522064000LL | |
| 182 #define META_PROTO_TIMES_2 1253215061000LL | |
| 183 #define META_PROTO_TIMES_4 1255742764000LL | |
| 184 #define META_PROTO_TIMES_5 1255681950000LL | |
| 185 #define META_PROTO_TIMES_6 1260924017000LL | |
| 186 #define META_PROTO_TIMES_7 1253212875000LL | |
| 187 #define META_PROTO_TIMES_8 1253212875000LL | |
| 188 #define META_PROTO_TIMES_9 1253212875000LL | |
| 189 #define META_PROTO_TIMES_10 1253212875000LL | |
| 190 #define META_PROTO_TIMES_11 1263522094000LL | |
| 191 #define META_PROTO_TIMES_12 1263522151000LL | |
| 192 #define META_PROTO_TIMES_13 1263522198000LL | |
| 193 #define META_PROTO_TIMES_14 1263522238000LL | |
| 194 | |
| 195 #define META_PROTO_TIMES_STR_1 "1263522064000" | |
| 196 #define META_PROTO_TIMES_STR_2 "1253215061000" | |
| 197 #define META_PROTO_TIMES_STR_4 "1255742764000" | |
| 198 #define META_PROTO_TIMES_STR_5 "1255681950000" | |
| 199 #define META_PROTO_TIMES_STR_6 "1260924017000" | |
| 200 #define META_PROTO_TIMES_STR_7 "1253212875000" | |
| 201 #define META_PROTO_TIMES_STR_8 "1253212875000" | |
| 202 #define META_PROTO_TIMES_STR_9 "1253212875000" | |
| 203 #define META_PROTO_TIMES_STR_10 "1253212875000" | |
| 204 #define META_PROTO_TIMES_STR_11 "1263522094000" | |
| 205 #define META_PROTO_TIMES_STR_12 "1263522151000" | |
| 206 #define META_PROTO_TIMES_STR_13 "1263522198000" | |
| 207 #define META_PROTO_TIMES_STR_14 "1263522238000" | |
| 208 | |
| 209 #endif | |
| 210 | |
| 211 // Helper macros for the database dumps in the SetUpVersion*Database | |
| 212 // functions. | |
| 213 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x | |
| 214 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x | |
| 215 #define LEGACY_PROTO_TIME_VALS(x) \ | |
| 216 LEGACY_META_PROTO_TIMES_STR(x) "," \ | |
| 217 LEGACY_META_PROTO_TIMES_STR(x) "," \ | |
| 218 LEGACY_META_PROTO_TIMES_STR(x) "," \ | |
| 219 LEGACY_META_PROTO_TIMES_STR(x) | |
| 220 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x | |
| 221 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x | |
| 222 #define META_PROTO_TIMES_VALS(x) \ | |
| 223 META_PROTO_TIMES_STR(x) "," \ | |
| 224 META_PROTO_TIMES_STR(x) "," \ | |
| 225 META_PROTO_TIMES_STR(x) "," \ | |
| 226 META_PROTO_TIMES_STR(x) | |
| 227 | |
| 228 namespace { | |
| 229 | |
| 230 // Helper functions for testing. | |
| 231 | |
| 232 enum ShouldIncludeDeletedItems { | |
| 233 INCLUDE_DELETED_ITEMS, | |
| 234 DONT_INCLUDE_DELETED_ITEMS | |
| 235 }; | |
| 236 | |
| 237 // Returns a map from metahandle -> expected legacy time (in proto | |
| 238 // format). | |
| 239 std::map<int64, int64> GetExpectedLegacyMetaProtoTimes( | |
| 240 enum ShouldIncludeDeletedItems include_deleted) { | |
| 241 std::map<int64, int64> expected_legacy_meta_proto_times; | |
| 242 expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1); | |
| 243 if (include_deleted == INCLUDE_DELETED_ITEMS) { | |
| 244 expected_legacy_meta_proto_times[2] = LEGACY_META_PROTO_TIMES(2); | |
| 245 expected_legacy_meta_proto_times[4] = LEGACY_META_PROTO_TIMES(4); | |
| 246 expected_legacy_meta_proto_times[5] = LEGACY_META_PROTO_TIMES(5); | |
| 247 } | |
| 248 expected_legacy_meta_proto_times[6] = LEGACY_META_PROTO_TIMES(6); | |
| 249 expected_legacy_meta_proto_times[7] = LEGACY_META_PROTO_TIMES(7); | |
| 250 expected_legacy_meta_proto_times[8] = LEGACY_META_PROTO_TIMES(8); | |
| 251 expected_legacy_meta_proto_times[9] = LEGACY_META_PROTO_TIMES(9); | |
| 252 expected_legacy_meta_proto_times[10] = LEGACY_META_PROTO_TIMES(10); | |
| 253 expected_legacy_meta_proto_times[11] = LEGACY_META_PROTO_TIMES(11); | |
| 254 expected_legacy_meta_proto_times[12] = LEGACY_META_PROTO_TIMES(12); | |
| 255 expected_legacy_meta_proto_times[13] = LEGACY_META_PROTO_TIMES(13); | |
| 256 expected_legacy_meta_proto_times[14] = LEGACY_META_PROTO_TIMES(14); | |
| 257 return expected_legacy_meta_proto_times; | |
| 258 } | |
| 259 | |
| 260 // Returns a map from metahandle -> expected time (in proto format). | |
| 261 std::map<int64, int64> GetExpectedMetaProtoTimes( | |
| 262 enum ShouldIncludeDeletedItems include_deleted) { | |
| 263 std::map<int64, int64> expected_meta_proto_times; | |
| 264 expected_meta_proto_times[1] = META_PROTO_TIMES(1); | |
| 265 if (include_deleted == INCLUDE_DELETED_ITEMS) { | |
| 266 expected_meta_proto_times[2] = META_PROTO_TIMES(2); | |
| 267 expected_meta_proto_times[4] = META_PROTO_TIMES(4); | |
| 268 expected_meta_proto_times[5] = META_PROTO_TIMES(5); | |
| 269 } | |
| 270 expected_meta_proto_times[6] = META_PROTO_TIMES(6); | |
| 271 expected_meta_proto_times[7] = META_PROTO_TIMES(7); | |
| 272 expected_meta_proto_times[8] = META_PROTO_TIMES(8); | |
| 273 expected_meta_proto_times[9] = META_PROTO_TIMES(9); | |
| 274 expected_meta_proto_times[10] = META_PROTO_TIMES(10); | |
| 275 expected_meta_proto_times[11] = META_PROTO_TIMES(11); | |
| 276 expected_meta_proto_times[12] = META_PROTO_TIMES(12); | |
| 277 expected_meta_proto_times[13] = META_PROTO_TIMES(13); | |
| 278 expected_meta_proto_times[14] = META_PROTO_TIMES(14); | |
| 279 return expected_meta_proto_times; | |
| 280 } | |
| 281 | |
| 282 // Returns a map from metahandle -> expected time (as a Time object). | |
| 283 std::map<int64, base::Time> GetExpectedMetaTimes() { | |
| 284 std::map<int64, base::Time> expected_meta_times; | |
| 285 const std::map<int64, int64>& expected_meta_proto_times = | |
| 286 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS); | |
| 287 for (std::map<int64, int64>::const_iterator it = | |
| 288 expected_meta_proto_times.begin(); | |
| 289 it != expected_meta_proto_times.end(); ++it) { | |
| 290 expected_meta_times[it->first] = | |
| 291 browser_sync::ProtoTimeToTime(it->second); | |
| 292 } | |
| 293 return expected_meta_times; | |
| 294 } | |
| 295 | |
| 296 // Extracts a map from metahandle -> time (in proto format) from the | |
| 297 // given database. | |
| 298 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) { | |
| 299 sql::Statement s(db->GetCachedStatement( | |
| 300 SQL_FROM_HERE, | |
| 301 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime " | |
| 302 "FROM metas")); | |
| 303 EXPECT_EQ(5, s.ColumnCount()); | |
| 304 std::map<int64, int64> meta_times; | |
| 305 while (s.Step()) { | |
| 306 int64 metahandle = s.ColumnInt64(0); | |
| 307 int64 mtime = s.ColumnInt64(1); | |
| 308 int64 server_mtime = s.ColumnInt64(2); | |
| 309 int64 ctime = s.ColumnInt64(3); | |
| 310 int64 server_ctime = s.ColumnInt64(4); | |
| 311 EXPECT_EQ(mtime, server_mtime); | |
| 312 EXPECT_EQ(mtime, ctime); | |
| 313 EXPECT_EQ(mtime, server_ctime); | |
| 314 meta_times[metahandle] = mtime; | |
| 315 } | |
| 316 EXPECT_TRUE(s.Succeeded()); | |
| 317 return meta_times; | |
| 318 } | |
| 319 | |
| 320 ::testing::AssertionResult AssertTimesMatch(const char* t1_expr, | |
| 321 const char* t2_expr, | |
| 322 const base::Time& t1, | |
| 323 const base::Time& t2) { | |
| 324 if (t1 == t2) | |
| 325 return ::testing::AssertionSuccess(); | |
| 326 | |
| 327 return ::testing::AssertionFailure() | |
| 328 << t1_expr << " and " << t2_expr | |
| 329 << " (internal values: " << t1.ToInternalValue() | |
| 330 << " and " << t2.ToInternalValue() | |
| 331 << ") (proto time: " << browser_sync::TimeToProtoTime(t1) | |
| 332 << " and " << browser_sync::TimeToProtoTime(t2) | |
| 333 << ") do not match"; | |
| 334 } | |
| 335 | |
| 336 // Expect that all time fields of the given entry kernel will be the | |
| 337 // given time. | |
| 338 void ExpectTime(const EntryKernel& entry_kernel, | |
| 339 const base::Time& expected_time) { | |
| 340 EXPECT_PRED_FORMAT2(AssertTimesMatch, | |
| 341 expected_time, entry_kernel.ref(CTIME)); | |
| 342 EXPECT_PRED_FORMAT2(AssertTimesMatch, | |
| 343 expected_time, entry_kernel.ref(SERVER_CTIME)); | |
| 344 EXPECT_PRED_FORMAT2(AssertTimesMatch, | |
| 345 expected_time, entry_kernel.ref(MTIME)); | |
| 346 EXPECT_PRED_FORMAT2(AssertTimesMatch, | |
| 347 expected_time, entry_kernel.ref(SERVER_MTIME)); | |
| 348 } | |
| 349 | |
| 350 // Expect that all the entries in |index| have times matching those in | |
| 351 // the given map (from metahandle to expect time). | |
| 352 void ExpectTimes(const MetahandlesIndex& index, | |
| 353 const std::map<int64, base::Time>& expected_times) { | |
| 354 for (MetahandlesIndex::const_iterator it = index.begin(); | |
| 355 it != index.end(); ++it) { | |
| 356 int64 meta_handle = (*it)->ref(META_HANDLE); | |
| 357 SCOPED_TRACE(meta_handle); | |
| 358 std::map<int64, base::Time>::const_iterator it2 = | |
| 359 expected_times.find(meta_handle); | |
| 360 if (it2 == expected_times.end()) { | |
| 361 ADD_FAILURE() << "Could not find expected time for " << meta_handle; | |
| 362 continue; | |
| 363 } | |
| 364 ExpectTime(**it, it2->second); | |
| 365 } | |
| 366 } | |
| 367 | |
| 368 } // namespace | |
| 369 | |
| 370 void MigrationTest::SetUpVersion67Database(sql::Connection* connection) { | |
| 371 // This is a version 67 database dump whose contents were backformed from | |
| 372 // the contents of the version 68 database dump (the v68 migration was | |
| 373 // actually written first). | |
| 374 ASSERT_TRUE(connection->is_open()); | |
| 375 ASSERT_TRUE(connection->BeginTransaction()); | |
| 376 ASSERT_TRUE(connection->Execute( | |
| 377 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), " | |
| 378 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);" | |
| 379 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL," | |
| 380 "base_version bigint default -1,server_version bigint default 0," | |
| 381 "mtime bigint default 0,server_mtime bigint default 0," | |
| 382 "ctime bigint default 0,server_ctime bigint default 0," | |
| 383 "server_position_in_parent bigint default 0," | |
| 384 "local_external_id bigint default 0,id varchar(255) default 'r'," | |
| 385 "parent_id varchar(255) default 'r'," | |
| 386 "server_parent_id varchar(255) default 'r'," | |
| 387 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r'," | |
| 388 "is_unsynced bit default 0,is_unapplied_update bit default 0," | |
| 389 "is_del bit default 0,is_dir bit default 0," | |
| 390 "is_bookmark_object bit default 0,server_is_dir bit default 0," | |
| 391 "server_is_del bit default 0,server_is_bookmark_object bit default 0," | |
| 392 "name varchar(255), " /* COLLATE PATHNAME, */ | |
| 393 "unsanitized_name varchar(255)," /* COLLATE PATHNAME, */ | |
| 394 "non_unique_name varchar," | |
| 395 "server_name varchar(255)," /* COLLATE PATHNAME */ | |
| 396 "server_non_unique_name varchar," | |
| 397 "bookmark_url varchar,server_bookmark_url varchar," | |
| 398 "singleton_tag varchar,bookmark_favicon blob," | |
| 399 "server_bookmark_favicon blob);" | |
| 400 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 401 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL," | |
| 402 "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);" | |
| 403 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 404 ",-2097152," | |
| 405 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1," | |
| 406 "'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item'," | |
| 407 "'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA'," | |
| 408 "'ASADGADGADG');" | |
| 409 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 410 ",-3145728," | |
| 411 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1," | |
| 412 "'Welcome to Chromium',NULL,'Welcome to Chromium'," | |
| 413 "'Welcome to Chromium','Welcome to Chromium'," | |
| 414 "'http://www.google.com/chrome/intl/en/welcome.html'," | |
| 415 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL," | |
| 416 "NULL);" | |
| 417 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 418 ",1048576," | |
| 419 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1," | |
| 420 "'Google',NULL,'Google','Google','Google','http://www.google.com/'," | |
| 421 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');" | |
| 422 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 423 ",-4194304," | |
| 424 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1," | |
| 425 "'The Internet',NULL,'The Internet','The Internet'," | |
| 426 "'The Internet',NULL,NULL,NULL,NULL,NULL);" | |
| 427 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 428 "," | |
| 429 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1," | |
| 430 "'Google Chrome',NULL,'Google Chrome','Google Chrome'," | |
| 431 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);" | |
| 432 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 433 ",1048576," | |
| 434 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks'," | |
| 435 "NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL," | |
| 436 "'google_chrome_bookmarks',NULL,NULL);" | |
| 437 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 438 "," | |
| 439 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0," | |
| 440 "1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar'," | |
| 441 "NULL,NULL,'bookmark_bar',NULL,NULL);" | |
| 442 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 443 ",2097152," | |
| 444 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1," | |
| 445 "'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks'," | |
| 446 "'Other Bookmarks',NULL,NULL,'other_bookmarks'," | |
| 447 "NULL,NULL);" | |
| 448 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 449 ",-1048576," | |
| 450 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1," | |
| 451 "'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)'," | |
| 452 "'Home (The Chromium Projects)','Home (The Chromium Projects)'," | |
| 453 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL," | |
| 454 "'AGATWA','AFAGVASF');" | |
| 455 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 456 ",0,9," | |
| 457 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1," | |
| 458 "'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks'," | |
| 459 "'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);" | |
| 460 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 461 ",-917504," | |
| 462 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0," | |
| 463 "1,'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 464 "'ICANN Internet Corporation for Assigned Names and Numbers'," | |
| 465 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 466 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 467 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 468 "'http://www.icann.com/','http://www.icann.com/',NULL," | |
| 469 "'PNGAXF0AAFF','DAAFASF');" | |
| 470 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 471 ",1048576," | |
| 472 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1," | |
| 473 "'The WebKit Open Source Project',NULL," | |
| 474 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 475 "'The WebKit Open Source Project','http://webkit.org/'," | |
| 476 "'http://webkit.org/x',NULL,'PNGX','PNG2Y');" | |
| 477 "CREATE TABLE share_info (id VARCHAR(128) primary key, " | |
| 478 "last_sync_timestamp INT, name VARCHAR(128), " | |
| 479 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), " | |
| 480 "db_create_version VARCHAR(128), db_create_time int, " | |
| 481 "next_id bigint default -2, cache_guid VARCHAR(32));" | |
| 482 "INSERT INTO share_info VALUES('nick@chromium.org',694," | |
| 483 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb'," | |
| 484 "'Unknown',1263522064,-65542," | |
| 485 "'9010788312004066376x-6609234393368420856x');" | |
| 486 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 487 "INSERT INTO share_version VALUES('nick@chromium.org',68);")); | |
| 488 ASSERT_TRUE(connection->CommitTransaction()); | |
| 489 } | |
| 490 | |
| 491 void MigrationTest::SetUpVersion68Database(sql::Connection* connection) { | |
| 492 // This sets up an actual version 68 database dump. The IDs were | |
| 493 // canonicalized to be less huge, and the favicons were overwritten | |
| 494 // with random junk so that they didn't contain any unprintable | |
| 495 // characters. A few server URLs were tweaked so that they'd be | |
| 496 // different from the local URLs. Lastly, the custom collation on | |
| 497 // the server_non_unique_name column was removed. | |
| 498 ASSERT_TRUE(connection->is_open()); | |
| 499 ASSERT_TRUE(connection->BeginTransaction()); | |
| 500 ASSERT_TRUE(connection->Execute( | |
| 501 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), " | |
| 502 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);" | |
| 503 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL," | |
| 504 "base_version bigint default -1,server_version bigint default 0," | |
| 505 "mtime bigint default 0,server_mtime bigint default 0," | |
| 506 "ctime bigint default 0,server_ctime bigint default 0," | |
| 507 "server_position_in_parent bigint default 0," | |
| 508 "local_external_id bigint default 0,id varchar(255) default 'r'," | |
| 509 "parent_id varchar(255) default 'r'," | |
| 510 "server_parent_id varchar(255) default 'r'," | |
| 511 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r'," | |
| 512 "is_unsynced bit default 0,is_unapplied_update bit default 0," | |
| 513 "is_del bit default 0,is_dir bit default 0," | |
| 514 "is_bookmark_object bit default 0,server_is_dir bit default 0," | |
| 515 "server_is_del bit default 0," | |
| 516 "server_is_bookmark_object bit default 0," | |
| 517 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 518 "bookmark_url varchar,server_bookmark_url varchar," | |
| 519 "singleton_tag varchar,bookmark_favicon blob," | |
| 520 "server_bookmark_favicon blob);" | |
| 521 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 522 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL," | |
| 523 "NULL,NULL,NULL,NULL,NULL,NULL);" | |
| 524 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 525 ",-2097152," | |
| 526 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1," | |
| 527 "'Deleted Item','Deleted Item','http://www.google.com/'," | |
| 528 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');" | |
| 529 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 530 ",-3145728," | |
| 531 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1," | |
| 532 "'Welcome to Chromium','Welcome to Chromium'," | |
| 533 "'http://www.google.com/chrome/intl/en/welcome.html'," | |
| 534 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL," | |
| 535 "NULL);" | |
| 536 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 537 ",1048576," | |
| 538 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1," | |
| 539 "'Google','Google','http://www.google.com/'," | |
| 540 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');" | |
| 541 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 542 ",-4194304," | |
| 543 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1," | |
| 544 "'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);" | |
| 545 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 546 "," | |
| 547 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1," | |
| 548 "'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL," | |
| 549 "NULL);" | |
| 550 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 551 ",1048576," | |
| 552 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks'," | |
| 553 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);" | |
| 554 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 555 "," | |
| 556 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0," | |
| 557 "1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL," | |
| 558 "NULL);" | |
| 559 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 560 ",2097152," | |
| 561 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1," | |
| 562 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks'," | |
| 563 "NULL,NULL);" | |
| 564 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 565 ",-1048576," | |
| 566 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1," | |
| 567 "'Home (The Chromium Projects)','Home (The Chromium Projects)'," | |
| 568 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL," | |
| 569 "'AGATWA','AFAGVASF');" | |
| 570 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 571 ",0,9," | |
| 572 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1," | |
| 573 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);" | |
| 574 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 575 ",-917504," | |
| 576 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0," | |
| 577 "1,'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 578 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 579 "'http://www.icann.com/','http://www.icann.com/',NULL," | |
| 580 "'PNGAXF0AAFF','DAAFASF');" | |
| 581 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 582 ",1048576," | |
| 583 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1," | |
| 584 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 585 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');" | |
| 586 "CREATE TABLE share_info (id VARCHAR(128) primary key, " | |
| 587 "last_sync_timestamp INT, name VARCHAR(128), " | |
| 588 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), " | |
| 589 "db_create_version VARCHAR(128), db_create_time int, " | |
| 590 "next_id bigint default -2, cache_guid VARCHAR(32));" | |
| 591 "INSERT INTO share_info VALUES('nick@chromium.org',694," | |
| 592 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb'," | |
| 593 "'Unknown',1263522064,-65542," | |
| 594 "'9010788312004066376x-6609234393368420856x');" | |
| 595 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 596 "INSERT INTO share_version VALUES('nick@chromium.org',68);")); | |
| 597 ASSERT_TRUE(connection->CommitTransaction()); | |
| 598 } | |
| 599 | |
| 600 void MigrationTest::SetUpVersion69Database(sql::Connection* connection) { | |
| 601 ASSERT_TRUE(connection->is_open()); | |
| 602 ASSERT_TRUE(connection->BeginTransaction()); | |
| 603 ASSERT_TRUE(connection->Execute( | |
| 604 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), " | |
| 605 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);" | |
| 606 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL," | |
| 607 "base_version bigint default -1,server_version bigint default 0," | |
| 608 "mtime bigint default 0,server_mtime bigint default 0," | |
| 609 "ctime bigint default 0,server_ctime bigint default 0," | |
| 610 "server_position_in_parent bigint default 0," | |
| 611 "local_external_id bigint default 0,id varchar(255) default 'r'," | |
| 612 "parent_id varchar(255) default 'r'," | |
| 613 "server_parent_id varchar(255) default 'r'," | |
| 614 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r'," | |
| 615 "is_unsynced bit default 0,is_unapplied_update bit default 0," | |
| 616 "is_del bit default 0,is_dir bit default 0," | |
| 617 "is_bookmark_object bit default 0,server_is_dir bit default 0," | |
| 618 "server_is_del bit default 0," | |
| 619 "server_is_bookmark_object bit default 0," | |
| 620 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 621 "bookmark_url varchar,server_bookmark_url varchar," | |
| 622 "singleton_tag varchar,bookmark_favicon blob," | |
| 623 "server_bookmark_favicon blob, specifics blob, " | |
| 624 "server_specifics blob);" | |
| 625 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 626 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL," | |
| 627 "NULL,NULL,X'',X'');" | |
| 628 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 629 ",-2097152," | |
| 630 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1," | |
| 631 "'Deleted Item','Deleted Item','http://www.google.com/'," | |
| 632 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG'," | |
| 633 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415" | |
| 634 "34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F" | |
| 635 "6D2F32120B4153414447414447414447');" | |
| 636 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 637 ",-3145728," | |
| 638 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1," | |
| 639 "'Welcome to Chromium','Welcome to Chromium'," | |
| 640 "'http://www.google.com/chrome/intl/en/welcome.html'," | |
| 641 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,NULL," | |
| 642 "X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6" | |
| 643 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168" | |
| 644 "7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6" | |
| 645 "56E2F77656C636F6D652E68746D6C1200');" | |
| 646 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 647 ",1048576,7," | |
| 648 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1," | |
| 649 "'Google','Google','http://www.google.com/'," | |
| 650 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166" | |
| 651 "87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'" | |
| 652 "C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464" | |
| 653 "447415347');" | |
| 654 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 655 ",-4194304,6" | |
| 656 ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet'," | |
| 657 "'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');" | |
| 658 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 659 ",1048576,0," | |
| 660 "'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome'," | |
| 661 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);" | |
| 662 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 663 ",1048576,0," | |
| 664 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks'," | |
| 665 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL," | |
| 666 "X'C2881000',X'C2881000');" | |
| 667 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 668 ",1048576,1," | |
| 669 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1," | |
| 670 "'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL," | |
| 671 "X'C2881000',X'C2881000');" | |
| 672 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 673 ",2097152,2," | |
| 674 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1," | |
| 675 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks'," | |
| 676 "NULL,NULL,X'C2881000',X'C2881000');" | |
| 677 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 678 ",-1048576," | |
| 679 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1," | |
| 680 "'Home (The Chromium Projects)','Home (The Chromium Projects)'," | |
| 681 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL," | |
| 682 "'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6" | |
| 683 "9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576" | |
| 684 "2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');" | |
| 685 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 686 ",0,9," | |
| 687 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1," | |
| 688 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL," | |
| 689 "X'C2881000',X'C2881000');" | |
| 690 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 691 ",-917504," | |
| 692 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0," | |
| 693 "1,'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 694 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 695 "'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF'," | |
| 696 "'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1" | |
| 697 "20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963" | |
| 698 "616E6E2E636F6D2F120744414146415346');" | |
| 699 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 700 ",1048576,11," | |
| 701 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1," | |
| 702 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 703 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y'," | |
| 704 "X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C2" | |
| 705 "88101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259');" | |
| 706 "CREATE TABLE share_info (id VARCHAR(128) primary key, " | |
| 707 "last_sync_timestamp INT, name VARCHAR(128), " | |
| 708 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), " | |
| 709 "db_create_version VARCHAR(128), db_create_time int, " | |
| 710 "next_id bigint default -2, cache_guid VARCHAR(32));" | |
| 711 "INSERT INTO share_info VALUES('nick@chromium.org',694," | |
| 712 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb'," | |
| 713 "'Unknown',1263522064,-65542," | |
| 714 "'9010788312004066376x-6609234393368420856x');" | |
| 715 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 716 "INSERT INTO share_version VALUES('nick@chromium.org',69);" | |
| 717 )); | |
| 718 ASSERT_TRUE(connection->CommitTransaction()); | |
| 719 } | |
| 720 | |
| 721 void MigrationTest::SetUpVersion70Database(sql::Connection* connection) { | |
| 722 ASSERT_TRUE(connection->is_open()); | |
| 723 ASSERT_TRUE(connection->BeginTransaction()); | |
| 724 ASSERT_TRUE(connection->Execute( | |
| 725 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), " | |
| 726 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);" | |
| 727 "CREATE TABLE share_info (id VARCHAR(128) primary key, " | |
| 728 "last_sync_timestamp INT, name VARCHAR(128), " | |
| 729 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), " | |
| 730 "db_create_version VARCHAR(128), db_create_time int, " | |
| 731 "next_id bigint default -2, cache_guid VARCHAR(32));" | |
| 732 "INSERT INTO share_info VALUES('nick@chromium.org',694," | |
| 733 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb'," | |
| 734 "'Unknown',1263522064,-65542," | |
| 735 "'9010788312004066376x-6609234393368420856x');" | |
| 736 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 737 "INSERT INTO share_version VALUES('nick@chromium.org',70);" | |
| 738 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL," | |
| 739 "base_version bigint default -1,server_version bigint default 0," | |
| 740 "mtime bigint default 0,server_mtime bigint default 0," | |
| 741 "ctime bigint default 0,server_ctime bigint default 0," | |
| 742 "server_position_in_parent bigint default 0," | |
| 743 "local_external_id bigint default 0,id varchar(255) default 'r'," | |
| 744 "parent_id varchar(255) default 'r'," | |
| 745 "server_parent_id varchar(255) default 'r'," | |
| 746 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r'," | |
| 747 "is_unsynced bit default 0,is_unapplied_update bit default 0," | |
| 748 "is_del bit default 0,is_dir bit default 0," | |
| 749 "server_is_dir bit default 0,server_is_del bit default 0," | |
| 750 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 751 "unique_server_tag varchar,unique_client_tag varchar," | |
| 752 "specifics blob,server_specifics blob);" | |
| 753 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 754 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');" | |
| 755 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) "," | |
| 756 "-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0," | |
| 757 "1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A" | |
| 758 "2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026" | |
| 759 "0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741" | |
| 760 "4447414447');" | |
| 761 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 762 ",-3145728," | |
| 763 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1," | |
| 764 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A" | |
| 765 "31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74" | |
| 766 "6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F" | |
| 767 "2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765" | |
| 768 "6C636F6D652E68746D6C1200');" | |
| 769 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 770 ",1048576,7," | |
| 771 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google'," | |
| 772 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6" | |
| 773 "52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777" | |
| 774 "72E676F6F676C652E636F6D2F12084147464447415347');" | |
| 775 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 776 ",-4194304," | |
| 777 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet'," | |
| 778 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');" | |
| 779 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 780 ",1048576,0," | |
| 781 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome'," | |
| 782 "'Google Chrome','google_chrome',NULL,NULL,NULL);" | |
| 783 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 784 ",1048576,0," | |
| 785 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks'," | |
| 786 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000'," | |
| 787 "X'C2881000');" | |
| 788 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 789 ",1048576," | |
| 790 "1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0," | |
| 791 "'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000'," | |
| 792 "X'C2881000');" | |
| 793 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 794 "," | |
| 795 "2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0," | |
| 796 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL," | |
| 797 "X'C2881000',X'C2881000');" | |
| 798 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 799 ",-1048576," | |
| 800 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0," | |
| 801 "'Home (The Chromium Projects)','Home (The Chromium Projects)'," | |
| 802 "NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F" | |
| 803 "72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872" | |
| 804 "6F6D69756D2E6F72672F6F7468657212084146414756415346');" | |
| 805 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 806 ",0,9," | |
| 807 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0," | |
| 808 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000'," | |
| 809 "X'C2881000');" | |
| 810 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 811 ",-917504," | |
| 812 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0," | |
| 813 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 814 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 815 "NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F" | |
| 816 "120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69" | |
| 817 "63616E6E2E636F6D2F120744414146415346');" | |
| 818 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 819 ",1048576," | |
| 820 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0," | |
| 821 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 822 "NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450" | |
| 823 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F78120550" | |
| 824 "4E473259');" | |
| 825 )); | |
| 826 ASSERT_TRUE(connection->CommitTransaction()); | |
| 827 } | |
| 828 | |
| 829 void MigrationTest::SetUpVersion71Database(sql::Connection* connection) { | |
| 830 ASSERT_TRUE(connection->is_open()); | |
| 831 ASSERT_TRUE(connection->BeginTransaction()); | |
| 832 ASSERT_TRUE(connection->Execute( | |
| 833 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), " | |
| 834 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);" | |
| 835 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 836 "INSERT INTO 'share_version' VALUES('nick@chromium.org',71);" | |
| 837 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL," | |
| 838 "base_version bigint default -1,server_version bigint default 0," | |
| 839 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint " | |
| 840 "default 0,server_ctime bigint default 0,server_position_in_parent " | |
| 841 "bigint default 0,local_external_id bigint default 0,id varchar(255) " | |
| 842 "default 'r',parent_id varchar(255) default 'r',server_parent_id " | |
| 843 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id " | |
| 844 "varchar(255) default 'r',is_unsynced bit default 0," | |
| 845 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit " | |
| 846 "default 0,server_is_dir bit default 0,server_is_del bit default 0," | |
| 847 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 848 "unique_server_tag varchar,unique_client_tag varchar,specifics blob," | |
| 849 "server_specifics blob);" | |
| 850 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 851 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL," | |
| 852 "NULL,NULL,X'',X'');" | |
| 853 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 854 ",-2097152,4," | |
| 855 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1," | |
| 856 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F" | |
| 857 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768" | |
| 858 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144" | |
| 859 "47');" | |
| 860 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 861 ",-3145728,3," | |
| 862 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1," | |
| 863 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31" | |
| 864 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F" | |
| 865 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777" | |
| 866 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D" | |
| 867 "652E68746D6C1200');" | |
| 868 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 869 ",1048576,7," | |
| 870 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google'," | |
| 871 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652" | |
| 872 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6" | |
| 873 "76F6F676C652E636F6D2F12084147464447415347');" | |
| 874 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 875 ",-4194304,6," | |
| 876 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet'," | |
| 877 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');" | |
| 878 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 879 ",1048576,0," | |
| 880 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'" | |
| 881 ",'google_chrome',NULL,NULL,NULL);" | |
| 882 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 883 ",1048576,0," | |
| 884 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks'," | |
| 885 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 886 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 887 ",1048576,1," | |
| 888 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'," | |
| 889 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 890 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 891 ",2097152,2," | |
| 892 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0," | |
| 893 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL," | |
| 894 "X'C2881000',X'C2881000');" | |
| 895 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 896 ",-1048576,8," | |
| 897 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0," | |
| 898 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL," | |
| 899 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1" | |
| 900 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756" | |
| 901 "D2E6F72672F6F7468657212084146414756415346');" | |
| 902 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 903 ",0,9," | |
| 904 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0," | |
| 905 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000'," | |
| 906 "X'C2881000');" | |
| 907 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 908 ",-917504,10," | |
| 909 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0," | |
| 910 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 911 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL," | |
| 912 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504" | |
| 913 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2" | |
| 914 "E636F6D2F120744414146415346');" | |
| 915 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 916 ",1048576,11," | |
| 917 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0," | |
| 918 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 919 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450" | |
| 920 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E" | |
| 921 "473259');" | |
| 922 "CREATE TABLE models (model_id BLOB primary key, " | |
| 923 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);" | |
| 924 "INSERT INTO 'models' VALUES(X'C2881000',694,1);" | |
| 925 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, " | |
| 926 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, " | |
| 927 "next_id INT default -2, cache_guid TEXT);" | |
| 928 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | |
| 929 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542," | |
| 930 "'9010788312004066376x-6609234393368420856x');")); | |
| 931 ASSERT_TRUE(connection->CommitTransaction()); | |
| 932 } | |
| 933 | |
| 934 void MigrationTest::SetUpVersion72Database(sql::Connection* connection) { | |
| 935 ASSERT_TRUE(connection->is_open()); | |
| 936 ASSERT_TRUE(connection->BeginTransaction()); | |
| 937 ASSERT_TRUE(connection->Execute( | |
| 938 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 939 "INSERT INTO 'share_version' VALUES('nick@chromium.org',72);" | |
| 940 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL," | |
| 941 "base_version bigint default -1,server_version bigint default 0," | |
| 942 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint " | |
| 943 "default 0,server_ctime bigint default 0,server_position_in_parent " | |
| 944 "bigint default 0,local_external_id bigint default 0,id varchar(255) " | |
| 945 "default 'r',parent_id varchar(255) default 'r',server_parent_id " | |
| 946 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id " | |
| 947 "varchar(255) default 'r',is_unsynced bit default 0," | |
| 948 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit " | |
| 949 "default 0,server_is_dir bit default 0,server_is_del bit default 0," | |
| 950 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 951 "unique_server_tag varchar,unique_client_tag varchar,specifics blob," | |
| 952 "server_specifics blob);" | |
| 953 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 954 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL," | |
| 955 "NULL,NULL,X'',X'');" | |
| 956 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 957 ",-2097152,4," | |
| 958 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1," | |
| 959 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F" | |
| 960 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768" | |
| 961 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144" | |
| 962 "47');" | |
| 963 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 964 ",-3145728,3," | |
| 965 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1," | |
| 966 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31" | |
| 967 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F" | |
| 968 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777" | |
| 969 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D" | |
| 970 "652E68746D6C1200');" | |
| 971 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 972 ",1048576,7," | |
| 973 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google'," | |
| 974 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652" | |
| 975 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6" | |
| 976 "76F6F676C652E636F6D2F12084147464447415347');" | |
| 977 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 978 ",-4194304,6," | |
| 979 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet'," | |
| 980 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');" | |
| 981 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 982 ",1048576,0," | |
| 983 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'" | |
| 984 ",'google_chrome',NULL,NULL,NULL);" | |
| 985 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 986 ",1048576,0," | |
| 987 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks'," | |
| 988 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 989 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 990 ",1048576,1," | |
| 991 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'," | |
| 992 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 993 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 994 ",2097152,2," | |
| 995 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0," | |
| 996 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL," | |
| 997 "X'C2881000',X'C2881000');" | |
| 998 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 999 ",-1048576,8," | |
| 1000 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0," | |
| 1001 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL," | |
| 1002 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1" | |
| 1003 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756" | |
| 1004 "D2E6F72672F6F7468657212084146414756415346');" | |
| 1005 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 1006 ",0,9," | |
| 1007 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0," | |
| 1008 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000'," | |
| 1009 "X'C2881000');" | |
| 1010 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 1011 ",-917504,10," | |
| 1012 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0," | |
| 1013 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 1014 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL," | |
| 1015 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504" | |
| 1016 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2" | |
| 1017 "E636F6D2F120744414146415346');" | |
| 1018 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 1019 ",1048576,11," | |
| 1020 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0," | |
| 1021 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 1022 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450" | |
| 1023 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E" | |
| 1024 "473259');" | |
| 1025 "CREATE TABLE models (model_id BLOB primary key, " | |
| 1026 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);" | |
| 1027 "INSERT INTO 'models' VALUES(X'C2881000',694,1);" | |
| 1028 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, " | |
| 1029 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, " | |
| 1030 "next_id INT default -2, cache_guid TEXT);" | |
| 1031 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | |
| 1032 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542," | |
| 1033 "'9010788312004066376x-6609234393368420856x');")); | |
| 1034 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1035 } | |
| 1036 | |
| 1037 void MigrationTest::SetUpVersion73Database(sql::Connection* connection) { | |
| 1038 ASSERT_TRUE(connection->is_open()); | |
| 1039 ASSERT_TRUE(connection->BeginTransaction()); | |
| 1040 ASSERT_TRUE(connection->Execute( | |
| 1041 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 1042 "INSERT INTO 'share_version' VALUES('nick@chromium.org',73);" | |
| 1043 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL," | |
| 1044 "base_version bigint default -1,server_version bigint default 0," | |
| 1045 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint " | |
| 1046 "default 0,server_ctime bigint default 0,server_position_in_parent " | |
| 1047 "bigint default 0,local_external_id bigint default 0,id varchar(255) " | |
| 1048 "default 'r',parent_id varchar(255) default 'r',server_parent_id " | |
| 1049 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id " | |
| 1050 "varchar(255) default 'r',is_unsynced bit default 0," | |
| 1051 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit " | |
| 1052 "default 0,server_is_dir bit default 0,server_is_del bit default 0," | |
| 1053 "non_unique_name varchar,server_non_unique_name varchar(255)," | |
| 1054 "unique_server_tag varchar,unique_client_tag varchar,specifics blob," | |
| 1055 "server_specifics blob);" | |
| 1056 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 1057 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL," | |
| 1058 "NULL,NULL,X'',X'');" | |
| 1059 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 1060 ",-2097152,4," | |
| 1061 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1," | |
| 1062 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F" | |
| 1063 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768" | |
| 1064 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144" | |
| 1065 "47');" | |
| 1066 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 1067 ",-3145728,3," | |
| 1068 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1," | |
| 1069 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31" | |
| 1070 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F" | |
| 1071 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777" | |
| 1072 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D" | |
| 1073 "652E68746D6C1200');" | |
| 1074 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 1075 ",1048576,7," | |
| 1076 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google'," | |
| 1077 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652" | |
| 1078 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6" | |
| 1079 "76F6F676C652E636F6D2F12084147464447415347');" | |
| 1080 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 1081 ",-4194304,6," | |
| 1082 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet'," | |
| 1083 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1084 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 1085 ",1048576,0," | |
| 1086 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'" | |
| 1087 ",'google_chrome',NULL,NULL,NULL);" | |
| 1088 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 1089 ",1048576,0," | |
| 1090 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks'," | |
| 1091 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1092 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 1093 ",1048576,1," | |
| 1094 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'," | |
| 1095 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 1096 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 1097 ",2097152,2," | |
| 1098 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0," | |
| 1099 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL," | |
| 1100 "X'C2881000',X'C2881000');" | |
| 1101 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 1102 ",-1048576,8," | |
| 1103 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0," | |
| 1104 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL," | |
| 1105 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1" | |
| 1106 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756" | |
| 1107 "D2E6F72672F6F7468657212084146414756415346');" | |
| 1108 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 1109 ",0,9," | |
| 1110 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0," | |
| 1111 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000'," | |
| 1112 "X'C2881000');" | |
| 1113 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 1114 ",-917504,10," | |
| 1115 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0," | |
| 1116 "'ICANN | Internet Corporation for Assigned Names and Numbers'," | |
| 1117 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL," | |
| 1118 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504" | |
| 1119 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2" | |
| 1120 "E636F6D2F120744414146415346');" | |
| 1121 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 1122 ",1048576,11," | |
| 1123 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0," | |
| 1124 "'The WebKit Open Source Project','The WebKit Open Source Project'," | |
| 1125 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450" | |
| 1126 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E" | |
| 1127 "473259');" | |
| 1128 "CREATE TABLE models (model_id BLOB primary key, " | |
| 1129 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);" | |
| 1130 "INSERT INTO 'models' VALUES(X'C2881000',694,1);" | |
| 1131 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, " | |
| 1132 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, " | |
| 1133 "next_id INT default -2, cache_guid TEXT, " | |
| 1134 "notification_state BLOB);" | |
| 1135 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | |
| 1136 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542," | |
| 1137 "'9010788312004066376x-6609234393368420856x',X'C2881000');")); | |
| 1138 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1139 } | |
| 1140 | |
| 1141 void MigrationTest::SetUpVersion74Database(sql::Connection* connection) { | |
| 1142 ASSERT_TRUE(connection->is_open()); | |
| 1143 ASSERT_TRUE(connection->BeginTransaction()); | |
| 1144 ASSERT_TRUE(connection->Execute( | |
| 1145 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 1146 "INSERT INTO 'share_version' VALUES('nick@chromium.org',74);" | |
| 1147 "CREATE TABLE models (model_id BLOB primary key, last_download_timestamp" | |
| 1148 " INT, initial_sync_ended BOOLEAN default 0);" | |
| 1149 "INSERT INTO 'models' VALUES(X'C2881000',694,1);" | |
| 1150 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd" | |
| 1151 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de" | |
| 1152 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra" | |
| 1153 "tion_state INT default 0, bookmarks_added_during_autofill_migration" | |
| 1154 " INT default 0, autofill_migration_time INT default 0, autofill_ent" | |
| 1155 "ries_added_during_migration INT default 0, autofill_profiles_added_" | |
| 1156 "during_migration INT default 0);" | |
| 1157 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'" | |
| 1158 ",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542" | |
| 1159 ",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);" | |
| 1160 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas" | |
| 1161 "e_version bigint default -1,server_version bigint default 0,mtime b" | |
| 1162 "igint default 0,server_mtime bigint default 0,ctime bigint default " | |
| 1163 "0,server_ctime bigint default 0,server_position_in_parent bigint de" | |
| 1164 "fault 0,local_external_id bigint default 0,id varchar(255) default " | |
| 1165 "'r',parent_id varchar(255) default 'r',server_parent_id varchar(255" | |
| 1166 ") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)" | |
| 1167 " default 'r',is_unsynced bit default 0,is_unapplied_update bit defa" | |
| 1168 "ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d" | |
| 1169 "efault 0,server_is_del bit default 0,non_unique_name varchar,server" | |
| 1170 "_non_unique_name varchar(255),unique_server_tag varchar,unique_clie" | |
| 1171 "nt_tag varchar,specifics blob,server_specifics blob);" | |
| 1172 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 1173 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'" | |
| 1174 "');" | |
| 1175 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 1176 ",-2097152,4,'s_ID_2','s_ID" | |
| 1177 "_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted " | |
| 1178 "Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6" | |
| 1179 "36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67" | |
| 1180 "6F6F676C652E636F6D2F32120B4153414447414447414447');" | |
| 1181 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 1182 ",-3145728,3,'s_ID_4','s_ID" | |
| 1183 "_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W" | |
| 1184 "elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6" | |
| 1185 "76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E" | |
| 1186 "68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636" | |
| 1187 "F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');" | |
| 1188 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 1189 ",1048576,7,'s_ID_5','s_ID_" | |
| 1190 "9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU" | |
| 1191 "LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841" | |
| 1192 "47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6" | |
| 1193 "36F6D2F12084147464447415347');" | |
| 1194 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 1195 ",-4194304,6,'s_ID_6','s_ID" | |
| 1196 "_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL" | |
| 1197 ",NULL,X'C2881000',X'C2881000');" | |
| 1198 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 1199 ",1048576,0,'s_ID_7','r','r" | |
| 1200 "','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom" | |
| 1201 "e',NULL,NULL,NULL);" | |
| 1202 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 1203 ",1048576,0,'s_ID_8','s_ID_" | |
| 1204 "7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr" | |
| 1205 "ome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1206 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 1207 ",1048576,1,'s_ID_9','s_ID_" | |
| 1208 "8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'" | |
| 1209 ",'bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 1210 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 1211 ",2097152,2,'s_ID_10','s_I" | |
| 1212 "D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo" | |
| 1213 "kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1214 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 1215 ",-1048576,8,'s_ID_11','s_" | |
| 1216 "ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec" | |
| 1217 "ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747" | |
| 1218 "03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810" | |
| 1219 "290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120" | |
| 1220 "84146414756415346');" | |
| 1221 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 1222 ",0,9,'s_ID_12','s_ID_6','" | |
| 1223 "s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo" | |
| 1224 "okmarks',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1225 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 1226 ",-917504,10,'s_ID_13','s_" | |
| 1227 "ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co" | |
| 1228 "rporation for Assigned Names and Numbers','ICANN | Internet Corpora" | |
| 1229 "tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474" | |
| 1230 "703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C" | |
| 1231 "28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641" | |
| 1232 "5346');" | |
| 1233 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 1234 ",1048576,11,'s_ID_14','s_" | |
| 1235 "ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr" | |
| 1236 "oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687" | |
| 1237 "474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474" | |
| 1238 "703A2F2F7765626B69742E6F72672F781205504E473259');" | |
| 1239 )); | |
| 1240 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1241 } | |
| 1242 | |
| 1243 void MigrationTest::SetUpVersion75Database(sql::Connection* connection) { | |
| 1244 ASSERT_TRUE(connection->is_open()); | |
| 1245 ASSERT_TRUE(connection->BeginTransaction()); | |
| 1246 ASSERT_TRUE(connection->Execute( | |
| 1247 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 1248 "INSERT INTO 'share_version' VALUES('nick@chromium.org',75);" | |
| 1249 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd" | |
| 1250 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de" | |
| 1251 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra" | |
| 1252 "tion_state INT default 0,bookmarks_added_during_autofill_migration " | |
| 1253 "INT default 0, autofill_migration_time INT default 0, autofill_entr" | |
| 1254 "ies_added_during_migration INT default 0, autofill_profiles_added_d" | |
| 1255 "uring_migration INT default 0);" | |
| 1256 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org" | |
| 1257 "','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-655" | |
| 1258 "42,'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);" | |
| 1259 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, " | |
| 1260 "initial_sync_ended BOOLEAN default 0);" | |
| 1261 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);" | |
| 1262 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,ba" | |
| 1263 "se_version bigint default -1,server_version bigint default 0,mtime" | |
| 1264 " bigint default 0,server_mtime bigint default 0,ctime bigint defau" | |
| 1265 "lt 0,server_ctime bigint default 0,server_position_in_parent bigin" | |
| 1266 "t default 0,local_external_id bigint default 0,id varchar(255) def" | |
| 1267 "ault 'r',parent_id varchar(255) default 'r',server_parent_id varch" | |
| 1268 "ar(255) default 'r',prev_id varchar(255) default 'r',next_id varch" | |
| 1269 "ar(255) default 'r',is_unsynced bit default 0,is_unapplied_update " | |
| 1270 "bit default 0,is_del bit default 0,is_dir bit default 0,server_is_" | |
| 1271 "dir bit default 0,server_is_del bit default 0,non_unique_name varc" | |
| 1272 "har,server_non_unique_name varchar(255),unique_server_tag varchar," | |
| 1273 "unique_client_tag varchar,specifics blob,server_specifics blob);" | |
| 1274 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 1275 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL" | |
| 1276 "L,X'',X'');" | |
| 1277 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 1278 ",-2097152,4,'s_ID_" | |
| 1279 "2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite" | |
| 1280 "m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772" | |
| 1281 "E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874" | |
| 1282 "74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474" | |
| 1283 "14447');" | |
| 1284 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 1285 ",-3145728,3,'s_ID_" | |
| 1286 "4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to " | |
| 1287 "Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747" | |
| 1288 "03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65" | |
| 1289 "6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7" | |
| 1290 "777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765" | |
| 1291 "6C636F6D652E68746D6C1200');" | |
| 1292 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 1293 ",1048576,7,'s_ID_5" | |
| 1294 "','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo" | |
| 1295 "gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65" | |
| 1296 "2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777" | |
| 1297 "7772E676F6F676C652E636F6D2F12084147464447415347');" | |
| 1298 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 1299 ",-4194304,6,'s_ID_" | |
| 1300 "6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In" | |
| 1301 "ternet',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1302 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 1303 ",1048576,0,'s_ID_7" | |
| 1304 "','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','" | |
| 1305 "google_chrome',NULL,NULL,NULL);" | |
| 1306 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 1307 ",1048576,0,'s_ID_8" | |
| 1308 "','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'" | |
| 1309 ",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1310 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 1311 ",1048576,1,'s_ID_9" | |
| 1312 "','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B" | |
| 1313 "ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 1314 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 1315 ",2097152,2,'s_ID_" | |
| 1316 "10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks" | |
| 1317 "','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810" | |
| 1318 "00');" | |
| 1319 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 1320 ",-1048576,8,'s_ID" | |
| 1321 "_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr" | |
| 1322 "omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28" | |
| 1323 "810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641" | |
| 1324 "4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756" | |
| 1325 "D2E6F72672F6F7468657212084146414756415346');" | |
| 1326 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 1327 ",0,9,'s_ID_12','s" | |
| 1328 "_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark" | |
| 1329 "s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1330 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 1331 ",-917504,10,'s_ID" | |
| 1332 "_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |" | |
| 1333 " Internet Corporation for Assigned Names and Numbers','ICANN | " | |
| 1334 "Internet Corporation for Assigned Names and Numbers',NULL,NULL," | |
| 1335 "X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504" | |
| 1336 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361" | |
| 1337 "6E6E2E636F6D2F120744414146415346');" | |
| 1338 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 1339 ",1048576,11,'s_ID" | |
| 1340 "_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op" | |
| 1341 "en Source Project','The WebKit Open Source Project',NULL,NULL,X" | |
| 1342 "'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758'," | |
| 1343 "X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473" | |
| 1344 "259');" | |
| 1345 )); | |
| 1346 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1347 } | |
| 1348 | |
| 1349 void MigrationTest::SetUpVersion76Database(sql::Connection* connection) { | |
| 1350 ASSERT_TRUE(connection->is_open()); | |
| 1351 ASSERT_TRUE(connection->BeginTransaction()); | |
| 1352 ASSERT_TRUE(connection->Execute( | |
| 1353 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 1354 "INSERT INTO 'share_version' VALUES('nick@chromium.org',76);" | |
| 1355 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in" | |
| 1356 "itial_sync_ended BOOLEAN default 0);" | |
| 1357 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);" | |
| 1358 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base" | |
| 1359 "_version bigint default -1,server_version bigint default 0,mtime big" | |
| 1360 "int default 0,server_mtime bigint default 0,ctime bigint default 0,s" | |
| 1361 "erver_ctime bigint default 0,server_position_in_parent bigint defaul" | |
| 1362 "t 0,local_external_id bigint default 0,id varchar(255) default 'r',p" | |
| 1363 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" | |
| 1364 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" | |
| 1365 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" | |
| 1366 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," | |
| 1367 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" | |
| 1368 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" | |
| 1369 "har,specifics blob,server_specifics blob);" | |
| 1370 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1) | |
| 1371 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')" | |
| 1372 ";" | |
| 1373 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) | |
| 1374 ",-2097152,4,'s_ID_2','s_ID_9" | |
| 1375 "','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite" | |
| 1376 "m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6" | |
| 1377 "D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6" | |
| 1378 "76C652E636F6D2F32120B4153414447414447414447');" | |
| 1379 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4) | |
| 1380 ",-3145728,3,'s_ID_4','s_ID_9" | |
| 1381 "','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc" | |
| 1382 "ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6" | |
| 1383 "F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746" | |
| 1384 "D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6" | |
| 1385 "368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');" | |
| 1386 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5) | |
| 1387 ",1048576,7,'s_ID_5','s_ID_9'" | |
| 1388 ",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL," | |
| 1389 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741" | |
| 1390 "5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D" | |
| 1391 "2F12084147464447415347');" | |
| 1392 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6) | |
| 1393 ",-4194304,6,'s_ID_6','s_ID_9" | |
| 1394 "','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU" | |
| 1395 "LL,X'C2881000',X'C2881000');" | |
| 1396 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7) | |
| 1397 ",1048576,0,'s_ID_7','r','r'," | |
| 1398 "'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome'," | |
| 1399 "NULL,NULL,NULL);" | |
| 1400 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8) | |
| 1401 ",1048576,0,'s_ID_8','s_ID_7'" | |
| 1402 ",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome" | |
| 1403 "_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1404 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9) | |
| 1405 ",1048576,1,'s_ID_9','s_ID_8'" | |
| 1406 ",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b" | |
| 1407 "ookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 1408 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10) | |
| 1409 ",2097152,2,'s_ID_10','s_ID_" | |
| 1410 "8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma" | |
| 1411 "rks','other_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1412 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11) | |
| 1413 ",-1048576,8,'s_ID_11','s_ID" | |
| 1414 "_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)" | |
| 1415 "','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2" | |
| 1416 "F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1" | |
| 1417 "D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464" | |
| 1418 "14756415346');" | |
| 1419 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12) | |
| 1420 ",0,9,'s_ID_12','s_ID_6','s_" | |
| 1421 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm" | |
| 1422 "arks',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1423 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13) | |
| 1424 ",-917504,10,'s_ID_13','s_ID" | |
| 1425 "_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo" | |
| 1426 "ration for Assigned Names and Numbers','ICANN | Internet Corporation" | |
| 1427 " for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2" | |
| 1428 "F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102" | |
| 1429 "00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');" | |
| 1430 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14) | |
| 1431 ",1048576,11,'s_ID_14','s_ID" | |
| 1432 "_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje" | |
| 1433 "ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747" | |
| 1434 "03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2" | |
| 1435 "F2F7765626B69742E6F72672F781205504E473259');" | |
| 1436 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" | |
| 1437 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" | |
| 1438 "ult -2, cache_guid TEXT , notification_state BLOB);" | |
| 1439 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | |
| 1440 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'" | |
| 1441 "9010788312004066376x-6609234393368420856x',NULL);" | |
| 1442 )); | |
| 1443 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1444 } | |
| 1445 | |
| 1446 void MigrationTest::SetUpVersion77Database(sql::Connection* connection) { | |
| 1447 ASSERT_TRUE(connection->is_open()); | |
| 1448 ASSERT_TRUE(connection->BeginTransaction()); | |
| 1449 ASSERT_TRUE(connection->Execute( | |
| 1450 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" | |
| 1451 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);" | |
| 1452 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in" | |
| 1453 "itial_sync_ended BOOLEAN default 0);" | |
| 1454 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);" | |
| 1455 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base" | |
| 1456 "_version bigint default -1,server_version bigint default 0,server_po" | |
| 1457 "sition_in_parent bigint default 0,local_external_id bigint default 0" | |
| 1458 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d" | |
| 1459 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p" | |
| 1460 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" | |
| 1461 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" | |
| 1462 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" | |
| 1463 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," | |
| 1464 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" | |
| 1465 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" | |
| 1466 "har,specifics blob,server_specifics blob);" | |
| 1467 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) | |
| 1468 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');" | |
| 1469 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4," | |
| 1470 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_" | |
| 1471 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1" | |
| 1472 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X" | |
| 1473 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534" | |
| 1474 "14447414447414447');" | |
| 1475 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3," | |
| 1476 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_" | |
| 1477 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL" | |
| 1478 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6" | |
| 1479 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687" | |
| 1480 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656" | |
| 1481 "E2F77656C636F6D652E68746D6C1200');" | |
| 1482 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5) | |
| 1483 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','" | |
| 1484 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E" | |
| 1485 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67" | |
| 1486 "6F6F676C652E636F6D2F12084147464447415347');" | |
| 1487 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6," | |
| 1488 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1" | |
| 1489 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'" | |
| 1490 ");" | |
| 1491 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7) | |
| 1492 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo" | |
| 1493 "gle Chrome','google_chrome',NULL,NULL,NULL);" | |
| 1494 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8) | |
| 1495 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar" | |
| 1496 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');" | |
| 1497 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9) | |
| 1498 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'" | |
| 1499 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');" | |
| 1500 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2," | |
| 1501 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r'," | |
| 1502 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU" | |
| 1503 "LL,X'C2881000',X'C2881000');" | |
| 1504 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8," | |
| 1505 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'" | |
| 1506 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj" | |
| 1507 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756" | |
| 1508 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636" | |
| 1509 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');" | |
| 1510 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12) | |
| 1511 ",'s_ID_12','s_ID_6','s_" | |
| 1512 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm" | |
| 1513 "arks',NULL,NULL,X'C2881000',X'C2881000');" | |
| 1514 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10," | |
| 1515 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_" | |
| 1516 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names " | |
| 1517 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu" | |
| 1518 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636" | |
| 1519 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772" | |
| 1520 "E6963616E6E2E636F6D2F120744414146415346');" | |
| 1521 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11," | |
| 1522 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'" | |
| 1523 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc" | |
| 1524 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726" | |
| 1525 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7" | |
| 1526 "81205504E473259');" | |
| 1527 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" | |
| 1528 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" | |
| 1529 "ult -2, cache_guid TEXT , notification_state BLOB);" | |
| 1530 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | |
| 1531 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'" | |
| 1532 "9010788312004066376x-6609234393368420856x',NULL);" | |
| 1533 )); | |
| 1534 ASSERT_TRUE(connection->CommitTransaction()); | |
| 1535 } | |
| 1536 | |
| 1537 TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) { | |
| 1538 sql::Connection connection; | |
| 1539 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1540 | |
| 1541 SetUpVersion67Database(&connection); | |
| 1542 | |
| 1543 // Columns existing before version 67. | |
| 1544 ASSERT_TRUE(connection.DoesColumnExist("metas", "name")); | |
| 1545 ASSERT_TRUE(connection.DoesColumnExist("metas", "unsanitized_name")); | |
| 1546 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_name")); | |
| 1547 | |
| 1548 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1549 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1550 | |
| 1551 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1552 ASSERT_TRUE(dbs->MigrateVersion67To68()); | |
| 1553 ASSERT_EQ(68, dbs->GetVersion()); | |
| 1554 ASSERT_TRUE(dbs->needs_column_refresh_); | |
| 1555 } | |
| 1556 | |
| 1557 TEST_F(DirectoryBackingStoreTest, MigrateVersion68To69) { | |
| 1558 sql::Connection connection; | |
| 1559 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1560 SetUpVersion68Database(&connection); | |
| 1561 | |
| 1562 { | |
| 1563 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1564 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1565 | |
| 1566 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1567 ASSERT_TRUE(dbs->MigrateVersion68To69()); | |
| 1568 ASSERT_EQ(69, dbs->GetVersion()); | |
| 1569 ASSERT_TRUE(dbs->needs_column_refresh_); | |
| 1570 } | |
| 1571 | |
| 1572 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics")); | |
| 1573 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics")); | |
| 1574 sql::Statement s(connection.GetUniqueStatement("SELECT non_unique_name," | |
| 1575 "is_del, is_dir, id, specifics, server_specifics FROM metas " | |
| 1576 "WHERE metahandle = 2")); | |
| 1577 ASSERT_TRUE(s.Step()); | |
| 1578 ASSERT_EQ("Deleted Item", s.ColumnString(0)); | |
| 1579 ASSERT_TRUE(s.ColumnBool(1)); | |
| 1580 ASSERT_FALSE(s.ColumnBool(2)); | |
| 1581 ASSERT_EQ("s_ID_2", s.ColumnString(3)); | |
| 1582 sync_pb::EntitySpecifics specifics; | |
| 1583 specifics.ParseFromArray(s.ColumnBlob(4), s.ColumnByteLength(4)); | |
| 1584 ASSERT_TRUE(specifics.has_bookmark()); | |
| 1585 ASSERT_EQ("http://www.google.com/", specifics.bookmark().url()); | |
| 1586 ASSERT_EQ("AASGASGA", specifics.bookmark().favicon()); | |
| 1587 specifics.ParseFromArray(s.ColumnBlob(5), s.ColumnByteLength(5)); | |
| 1588 ASSERT_TRUE(specifics.has_bookmark()); | |
| 1589 ASSERT_EQ("http://www.google.com/2", specifics.bookmark().url()); | |
| 1590 ASSERT_EQ("ASADGADGADG", specifics.bookmark().favicon()); | |
| 1591 ASSERT_FALSE(s.Step()); | |
| 1592 } | |
| 1593 | |
| 1594 TEST_F(DirectoryBackingStoreTest, MigrateVersion69To70) { | |
| 1595 sql::Connection connection; | |
| 1596 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1597 SetUpVersion69Database(&connection); | |
| 1598 | |
| 1599 ASSERT_TRUE(connection.DoesColumnExist("metas", "singleton_tag")); | |
| 1600 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_server_tag")); | |
| 1601 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_client_tag")); | |
| 1602 | |
| 1603 { | |
| 1604 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1605 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1606 | |
| 1607 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1608 ASSERT_TRUE(dbs->MigrateVersion69To70()); | |
| 1609 ASSERT_EQ(70, dbs->GetVersion()); | |
| 1610 ASSERT_TRUE(dbs->needs_column_refresh_); | |
| 1611 } | |
| 1612 | |
| 1613 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag")); | |
| 1614 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag")); | |
| 1615 sql::Statement s(connection.GetUniqueStatement("SELECT id" | |
| 1616 " FROM metas WHERE unique_server_tag = 'google_chrome'")); | |
| 1617 ASSERT_TRUE(s.Step()); | |
| 1618 EXPECT_EQ("s_ID_7", s.ColumnString(0)); | |
| 1619 } | |
| 1620 | |
| 1621 TEST_F(DirectoryBackingStoreTest, MigrateVersion70To71) { | |
| 1622 sql::Connection connection; | |
| 1623 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1624 SetUpVersion70Database(&connection); | |
| 1625 | |
| 1626 ASSERT_TRUE(connection.DoesColumnExist("share_info", "last_sync_timestamp")); | |
| 1627 ASSERT_TRUE(connection.DoesColumnExist("share_info", "initial_sync_ended")); | |
| 1628 ASSERT_FALSE(connection.DoesTableExist("models")); | |
| 1629 | |
| 1630 { | |
| 1631 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1632 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1633 | |
| 1634 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1635 ASSERT_TRUE(dbs->MigrateVersion70To71()); | |
| 1636 ASSERT_EQ(71, dbs->GetVersion()); | |
| 1637 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1638 } | |
| 1639 | |
| 1640 ASSERT_FALSE(connection.DoesColumnExist("share_info", "last_sync_timestamp")); | |
| 1641 ASSERT_FALSE(connection.DoesColumnExist("share_info", "initial_sync_ended")); | |
| 1642 ASSERT_TRUE(connection.DoesTableExist("models")); | |
| 1643 ASSERT_TRUE(connection.DoesColumnExist("models", "initial_sync_ended")); | |
| 1644 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp")); | |
| 1645 ASSERT_TRUE(connection.DoesColumnExist("models", "model_id")); | |
| 1646 | |
| 1647 sql::Statement s(connection.GetUniqueStatement("SELECT model_id, " | |
| 1648 "initial_sync_ended, last_download_timestamp FROM models")); | |
| 1649 ASSERT_TRUE(s.Step()); | |
| 1650 std::string model_id = s.ColumnString(0); | |
| 1651 EXPECT_EQ("C2881000", base::HexEncode(model_id.data(), model_id.size())) | |
| 1652 << "Model ID is expected to be the empty BookmarkSpecifics proto."; | |
| 1653 EXPECT_TRUE(s.ColumnBool(1)); | |
| 1654 EXPECT_EQ(694, s.ColumnInt64(2)); | |
| 1655 ASSERT_FALSE(s.Step()); | |
| 1656 } | |
| 1657 | |
| 1658 | |
| 1659 TEST_F(DirectoryBackingStoreTest, MigrateVersion71To72) { | |
| 1660 sql::Connection connection; | |
| 1661 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1662 SetUpVersion71Database(&connection); | |
| 1663 | |
| 1664 ASSERT_TRUE(connection.DoesTableExist("extended_attributes")); | |
| 1665 | |
| 1666 { | |
| 1667 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1668 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1669 | |
| 1670 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1671 ASSERT_TRUE(dbs->MigrateVersion71To72()); | |
| 1672 ASSERT_EQ(72, dbs->GetVersion()); | |
| 1673 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1674 } | |
| 1675 | |
| 1676 ASSERT_FALSE(connection.DoesTableExist("extended_attributes")); | |
| 1677 } | |
| 1678 | |
| 1679 TEST_F(DirectoryBackingStoreTest, MigrateVersion72To73) { | |
| 1680 sql::Connection connection; | |
| 1681 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1682 SetUpVersion72Database(&connection); | |
| 1683 | |
| 1684 ASSERT_FALSE(connection.DoesColumnExist("share_info", "notification_state")); | |
| 1685 | |
| 1686 { | |
| 1687 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1688 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1689 | |
| 1690 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1691 ASSERT_TRUE(dbs->MigrateVersion72To73()); | |
| 1692 ASSERT_EQ(73, dbs->GetVersion()); | |
| 1693 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1694 } | |
| 1695 | |
| 1696 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state")); | |
| 1697 } | |
| 1698 | |
| 1699 TEST_F(DirectoryBackingStoreTest, MigrateVersion73To74) { | |
| 1700 sql::Connection connection; | |
| 1701 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1702 SetUpVersion73Database(&connection); | |
| 1703 | |
| 1704 ASSERT_FALSE( | |
| 1705 connection.DoesColumnExist("share_info", "autofill_migration_state")); | |
| 1706 ASSERT_FALSE( | |
| 1707 connection.DoesColumnExist("share_info", | |
| 1708 "bookmarks_added_during_autofill_migration")); | |
| 1709 ASSERT_FALSE( | |
| 1710 connection.DoesColumnExist("share_info", "autofill_migration_time")); | |
| 1711 ASSERT_FALSE( | |
| 1712 connection.DoesColumnExist("share_info", | |
| 1713 "autofill_entries_added_during_migration")); | |
| 1714 | |
| 1715 ASSERT_FALSE( | |
| 1716 connection.DoesColumnExist("share_info", | |
| 1717 "autofill_profiles_added_during_migration")); | |
| 1718 | |
| 1719 { | |
| 1720 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1721 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1722 | |
| 1723 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1724 ASSERT_TRUE(dbs->MigrateVersion73To74()); | |
| 1725 ASSERT_EQ(74, dbs->GetVersion()); | |
| 1726 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1727 } | |
| 1728 | |
| 1729 ASSERT_TRUE( | |
| 1730 connection.DoesColumnExist("share_info", "autofill_migration_state")); | |
| 1731 ASSERT_TRUE( | |
| 1732 connection.DoesColumnExist("share_info", | |
| 1733 "bookmarks_added_during_autofill_migration")); | |
| 1734 ASSERT_TRUE( | |
| 1735 connection.DoesColumnExist("share_info", "autofill_migration_time")); | |
| 1736 ASSERT_TRUE( | |
| 1737 connection.DoesColumnExist("share_info", | |
| 1738 "autofill_entries_added_during_migration")); | |
| 1739 | |
| 1740 ASSERT_TRUE( | |
| 1741 connection.DoesColumnExist("share_info", | |
| 1742 "autofill_profiles_added_during_migration")); | |
| 1743 } | |
| 1744 | |
| 1745 TEST_F(DirectoryBackingStoreTest, MigrateVersion74To75) { | |
| 1746 sql::Connection connection; | |
| 1747 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1748 SetUpVersion74Database(&connection); | |
| 1749 | |
| 1750 ASSERT_FALSE(connection.DoesColumnExist("models", "progress_marker")); | |
| 1751 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp")); | |
| 1752 | |
| 1753 { | |
| 1754 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1755 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1756 | |
| 1757 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1758 ASSERT_TRUE(dbs->MigrateVersion74To75()); | |
| 1759 ASSERT_EQ(75, dbs->GetVersion()); | |
| 1760 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1761 } | |
| 1762 | |
| 1763 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker")); | |
| 1764 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp")); | |
| 1765 } | |
| 1766 | |
| 1767 TEST_F(DirectoryBackingStoreTest, MigrateVersion75To76) { | |
| 1768 sql::Connection connection; | |
| 1769 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1770 SetUpVersion75Database(&connection); | |
| 1771 | |
| 1772 ASSERT_TRUE( | |
| 1773 connection.DoesColumnExist("share_info", "autofill_migration_state")); | |
| 1774 ASSERT_TRUE(connection.DoesColumnExist("share_info", | |
| 1775 "bookmarks_added_during_autofill_migration")); | |
| 1776 ASSERT_TRUE( | |
| 1777 connection.DoesColumnExist("share_info", "autofill_migration_time")); | |
| 1778 ASSERT_TRUE(connection.DoesColumnExist("share_info", | |
| 1779 "autofill_entries_added_during_migration")); | |
| 1780 ASSERT_TRUE(connection.DoesColumnExist("share_info", | |
| 1781 "autofill_profiles_added_during_migration")); | |
| 1782 | |
| 1783 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1784 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1785 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1786 ASSERT_TRUE(dbs->MigrateVersion75To76()); | |
| 1787 ASSERT_EQ(76, dbs->GetVersion()); | |
| 1788 ASSERT_TRUE(dbs->needs_column_refresh_); | |
| 1789 // Cannot actual refresh columns due to version 76 not containing all | |
| 1790 // necessary columns. | |
| 1791 } | |
| 1792 | |
| 1793 TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) { | |
| 1794 sql::Connection connection; | |
| 1795 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1796 SetUpVersion76Database(&connection); | |
| 1797 | |
| 1798 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1799 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1800 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1801 | |
| 1802 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(INCLUDE_DELETED_ITEMS), | |
| 1803 GetMetaProtoTimes(dbs->db_.get())); | |
| 1804 // Since the proto times are expected to be in a legacy format, they may not | |
| 1805 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes(). | |
| 1806 | |
| 1807 ASSERT_TRUE(dbs->MigrateVersion76To77()); | |
| 1808 ASSERT_EQ(77, dbs->GetVersion()); | |
| 1809 | |
| 1810 EXPECT_EQ(GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS), | |
| 1811 GetMetaProtoTimes(dbs->db_.get())); | |
| 1812 // Cannot actually load entries due to version 77 not having all required | |
| 1813 // columns. | |
| 1814 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1815 } | |
| 1816 | |
| 1817 TEST_F(DirectoryBackingStoreTest, MigrateVersion77To78) { | |
| 1818 sql::Connection connection; | |
| 1819 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1820 SetUpVersion77Database(&connection); | |
| 1821 | |
| 1822 ASSERT_FALSE(connection.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS")); | |
| 1823 | |
| 1824 { | |
| 1825 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1826 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1827 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1828 ASSERT_TRUE(dbs->MigrateVersion77To78()); | |
| 1829 ASSERT_EQ(78, dbs->GetVersion()); | |
| 1830 | |
| 1831 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1832 } | |
| 1833 | |
| 1834 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); | |
| 1835 } | |
| 1836 | |
| 1837 TEST_P(MigrationTest, ToCurrentVersion) { | |
| 1838 sql::Connection connection; | |
| 1839 ASSERT_TRUE(connection.OpenInMemory()); | |
| 1840 switch (GetParam()) { | |
| 1841 case 67: | |
| 1842 SetUpVersion67Database(&connection); | |
| 1843 break; | |
| 1844 case 68: | |
| 1845 SetUpVersion68Database(&connection); | |
| 1846 break; | |
| 1847 case 69: | |
| 1848 SetUpVersion69Database(&connection); | |
| 1849 break; | |
| 1850 case 70: | |
| 1851 SetUpVersion70Database(&connection); | |
| 1852 break; | |
| 1853 case 71: | |
| 1854 SetUpVersion71Database(&connection); | |
| 1855 break; | |
| 1856 case 72: | |
| 1857 SetUpVersion72Database(&connection); | |
| 1858 break; | |
| 1859 case 73: | |
| 1860 SetUpVersion73Database(&connection); | |
| 1861 break; | |
| 1862 case 74: | |
| 1863 SetUpVersion74Database(&connection); | |
| 1864 break; | |
| 1865 case 75: | |
| 1866 SetUpVersion75Database(&connection); | |
| 1867 break; | |
| 1868 case 76: | |
| 1869 SetUpVersion76Database(&connection); | |
| 1870 break; | |
| 1871 case 77: | |
| 1872 SetUpVersion77Database(&connection); | |
| 1873 break; | |
| 1874 default: | |
| 1875 // If you see this error, it may mean that you've increased the | |
| 1876 // database version number but you haven't finished adding unit tests | |
| 1877 // for the database migration code. You need to need to supply a | |
| 1878 // SetUpVersionXXDatabase function with a dump of the test database | |
| 1879 // at the old schema. Here's one way to do that: | |
| 1880 // 1. Start on a clean tree (with none of your pending schema changes). | |
| 1881 // 2. Set a breakpoint in this function and run the unit test. | |
| 1882 // 3. Allow this test to run to completion (step out of the call), | |
| 1883 // without allowing ~MigrationTest to execute. | |
| 1884 // 4. Examine this->temp_dir_ to determine the location of the | |
| 1885 // test database (it is currently of the version you need). | |
| 1886 // 5. Dump this using the sqlite3 command line tool: | |
| 1887 // > .output foo_dump.sql | |
| 1888 // > .dump | |
| 1889 // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or | |
| 1890 // LEGACY_META_PROTO_TIMES(x) if before Version 77). | |
| 1891 FAIL() << "Need to supply database dump for version " << GetParam(); | |
| 1892 } | |
| 1893 | |
| 1894 syncable::Directory::KernelLoadInfo dir_info; | |
| 1895 MetahandlesIndex index; | |
| 1896 STLElementDeleter<MetahandlesIndex> index_deleter(&index); | |
| 1897 | |
| 1898 { | |
| 1899 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 1900 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 1901 ASSERT_EQ(OPENED, dbs->Load(&index, &dir_info)); | |
| 1902 ASSERT_FALSE(dbs->needs_column_refresh_); | |
| 1903 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); | |
| 1904 } | |
| 1905 | |
| 1906 // Columns deleted in Version 67. | |
| 1907 ASSERT_FALSE(connection.DoesColumnExist("metas", "name")); | |
| 1908 ASSERT_FALSE(connection.DoesColumnExist("metas", "unsanitized_name")); | |
| 1909 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_name")); | |
| 1910 | |
| 1911 // Columns added in Version 68. | |
| 1912 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics")); | |
| 1913 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics")); | |
| 1914 | |
| 1915 // Columns deleted in Version 68. | |
| 1916 ASSERT_FALSE(connection.DoesColumnExist("metas", "is_bookmark_object")); | |
| 1917 ASSERT_FALSE(connection.DoesColumnExist("metas", | |
| 1918 "server_is_bookmark_object")); | |
| 1919 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_favicon")); | |
| 1920 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_url")); | |
| 1921 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_bookmark_url")); | |
| 1922 | |
| 1923 // Renamed a column in Version 70 | |
| 1924 ASSERT_FALSE(connection.DoesColumnExist("metas", "singleton_tag")); | |
| 1925 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag")); | |
| 1926 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag")); | |
| 1927 | |
| 1928 // Removed extended attributes in Version 72. | |
| 1929 ASSERT_FALSE(connection.DoesTableExist("extended_attributes")); | |
| 1930 | |
| 1931 // Columns added in Version 73. | |
| 1932 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state")); | |
| 1933 | |
| 1934 // Column replaced in version 75. | |
| 1935 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker")); | |
| 1936 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp")); | |
| 1937 | |
| 1938 // Columns removed in version 76. | |
| 1939 ASSERT_FALSE( | |
| 1940 connection.DoesColumnExist("share_info", "autofill_migration_state")); | |
| 1941 ASSERT_FALSE(connection.DoesColumnExist("share_info", | |
| 1942 "bookmarks_added_during_autofill_migration")); | |
| 1943 ASSERT_FALSE( | |
| 1944 connection.DoesColumnExist("share_info", "autofill_migration_time")); | |
| 1945 ASSERT_FALSE(connection.DoesColumnExist("share_info", | |
| 1946 "autofill_entries_added_during_migration")); | |
| 1947 ASSERT_FALSE(connection.DoesColumnExist("share_info", | |
| 1948 "autofill_profiles_added_during_migration")); | |
| 1949 | |
| 1950 // Column added in version 78. | |
| 1951 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); | |
| 1952 | |
| 1953 // Check download_progress state (v75 migration) | |
| 1954 ASSERT_EQ(694, | |
| 1955 dir_info.kernel_info.download_progress[syncable::BOOKMARKS] | |
| 1956 .timestamp_token_for_migration()); | |
| 1957 ASSERT_FALSE( | |
| 1958 dir_info.kernel_info.download_progress[syncable::BOOKMARKS] | |
| 1959 .has_token()); | |
| 1960 ASSERT_EQ(32904, | |
| 1961 dir_info.kernel_info.download_progress[syncable::BOOKMARKS] | |
| 1962 .data_type_id()); | |
| 1963 ASSERT_FALSE( | |
| 1964 dir_info.kernel_info.download_progress[syncable::THEMES] | |
| 1965 .has_timestamp_token_for_migration()); | |
| 1966 ASSERT_TRUE( | |
| 1967 dir_info.kernel_info.download_progress[syncable::THEMES] | |
| 1968 .has_token()); | |
| 1969 ASSERT_TRUE( | |
| 1970 dir_info.kernel_info.download_progress[syncable::THEMES] | |
| 1971 .token().empty()); | |
| 1972 ASSERT_EQ(41210, | |
| 1973 dir_info.kernel_info.download_progress[syncable::THEMES] | |
| 1974 .data_type_id()); | |
| 1975 | |
| 1976 // Check metas | |
| 1977 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS), | |
| 1978 GetMetaProtoTimes(&connection)); | |
| 1979 ExpectTimes(index, GetExpectedMetaTimes()); | |
| 1980 | |
| 1981 MetahandlesIndex::iterator it = index.begin(); | |
| 1982 ASSERT_TRUE(it != index.end()); | |
| 1983 ASSERT_EQ(1, (*it)->ref(META_HANDLE)); | |
| 1984 EXPECT_TRUE((*it)->ref(ID).IsRoot()); | |
| 1985 | |
| 1986 ASSERT_TRUE(++it != index.end()); | |
| 1987 ASSERT_EQ(6, (*it)->ref(META_HANDLE)); | |
| 1988 EXPECT_TRUE((*it)->ref(IS_DIR)); | |
| 1989 EXPECT_TRUE((*it)->ref(SERVER_IS_DIR)); | |
| 1990 EXPECT_FALSE( | |
| 1991 (*it)->ref(SPECIFICS).bookmark().has_url()); | |
| 1992 EXPECT_FALSE( | |
| 1993 (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); | |
| 1994 EXPECT_FALSE( | |
| 1995 (*it)->ref(SPECIFICS).bookmark().has_favicon()); | |
| 1996 EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); | |
| 1997 | |
| 1998 ASSERT_TRUE(++it != index.end()); | |
| 1999 ASSERT_EQ(7, (*it)->ref(META_HANDLE)); | |
| 2000 EXPECT_EQ("google_chrome", (*it)->ref(UNIQUE_SERVER_TAG)); | |
| 2001 EXPECT_FALSE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2002 EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2003 | |
| 2004 ASSERT_TRUE(++it != index.end()); | |
| 2005 ASSERT_EQ(8, (*it)->ref(META_HANDLE)); | |
| 2006 EXPECT_EQ("google_chrome_bookmarks", (*it)->ref(UNIQUE_SERVER_TAG)); | |
| 2007 EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2008 EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2009 | |
| 2010 ASSERT_TRUE(++it != index.end()); | |
| 2011 ASSERT_EQ(9, (*it)->ref(META_HANDLE)); | |
| 2012 EXPECT_EQ("bookmark_bar", (*it)->ref(UNIQUE_SERVER_TAG)); | |
| 2013 EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2014 EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2015 | |
| 2016 ASSERT_TRUE(++it != index.end()); | |
| 2017 ASSERT_EQ(10, (*it)->ref(META_HANDLE)); | |
| 2018 EXPECT_FALSE((*it)->ref(IS_DEL)); | |
| 2019 EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2020 EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2021 EXPECT_FALSE((*it)->ref(SPECIFICS).bookmark().has_url()); | |
| 2022 EXPECT_FALSE( | |
| 2023 (*it)->ref(SPECIFICS).bookmark().has_favicon()); | |
| 2024 EXPECT_FALSE( | |
| 2025 (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); | |
| 2026 EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); | |
| 2027 EXPECT_EQ("other_bookmarks", (*it)->ref(UNIQUE_SERVER_TAG)); | |
| 2028 EXPECT_EQ("Other Bookmarks", (*it)->ref(NON_UNIQUE_NAME)); | |
| 2029 EXPECT_EQ("Other Bookmarks", (*it)->ref(SERVER_NON_UNIQUE_NAME)); | |
| 2030 | |
| 2031 ASSERT_TRUE(++it != index.end()); | |
| 2032 ASSERT_EQ(11, (*it)->ref(META_HANDLE)); | |
| 2033 EXPECT_FALSE((*it)->ref(IS_DEL)); | |
| 2034 EXPECT_FALSE((*it)->ref(IS_DIR)); | |
| 2035 EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2036 EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2037 EXPECT_EQ("http://dev.chromium.org/", | |
| 2038 (*it)->ref(SPECIFICS).bookmark().url()); | |
| 2039 EXPECT_EQ("AGATWA", | |
| 2040 (*it)->ref(SPECIFICS).bookmark().favicon()); | |
| 2041 EXPECT_EQ("http://dev.chromium.org/other", | |
| 2042 (*it)->ref(SERVER_SPECIFICS).bookmark().url()); | |
| 2043 EXPECT_EQ("AFAGVASF", | |
| 2044 (*it)->ref(SERVER_SPECIFICS).bookmark().favicon()); | |
| 2045 EXPECT_EQ("", (*it)->ref(UNIQUE_SERVER_TAG)); | |
| 2046 EXPECT_EQ("Home (The Chromium Projects)", (*it)->ref(NON_UNIQUE_NAME)); | |
| 2047 EXPECT_EQ("Home (The Chromium Projects)", (*it)->ref(SERVER_NON_UNIQUE_NAME)); | |
| 2048 | |
| 2049 ASSERT_TRUE(++it != index.end()); | |
| 2050 ASSERT_EQ(12, (*it)->ref(META_HANDLE)); | |
| 2051 EXPECT_FALSE((*it)->ref(IS_DEL)); | |
| 2052 EXPECT_TRUE((*it)->ref(IS_DIR)); | |
| 2053 EXPECT_EQ("Extra Bookmarks", (*it)->ref(NON_UNIQUE_NAME)); | |
| 2054 EXPECT_EQ("Extra Bookmarks", (*it)->ref(SERVER_NON_UNIQUE_NAME)); | |
| 2055 EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); | |
| 2056 EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); | |
| 2057 EXPECT_FALSE( | |
| 2058 (*it)->ref(SPECIFICS).bookmark().has_url()); | |
| 2059 EXPECT_FALSE( | |
| 2060 (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); | |
| 2061 EXPECT_FALSE( | |
| 2062 (*it)->ref(SPECIFICS).bookmark().has_favicon()); | |
| 2063 EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); | |
| 2064 | |
| 2065 ASSERT_TRUE(++it != index.end()); | |
| 2066 ASSERT_EQ(13, (*it)->ref(META_HANDLE)); | |
| 2067 | |
| 2068 ASSERT_TRUE(++it != index.end()); | |
| 2069 ASSERT_EQ(14, (*it)->ref(META_HANDLE)); | |
| 2070 | |
| 2071 ASSERT_TRUE(++it == index.end()); | |
| 2072 } | |
| 2073 | |
| 2074 INSTANTIATE_TEST_CASE_P(DirectoryBackingStore, MigrationTest, | |
| 2075 testing::Range(67, kCurrentDBVersion)); | |
| 2076 | |
| 2077 TEST_F(DirectoryBackingStoreTest, ModelTypeIds) { | |
| 2078 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | |
| 2079 std::string model_id = | |
| 2080 TestDirectoryBackingStore::ModelTypeEnumToModelId(ModelTypeFromInt(i)); | |
| 2081 EXPECT_EQ(i, | |
| 2082 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(), | |
| 2083 model_id.size())); | |
| 2084 } | |
| 2085 } | |
| 2086 | |
| 2087 // TODO(109668): This had to be disabled because the latest API will | |
| 2088 // intentionally crash when a database is this badly corrupted. | |
| 2089 TEST_F(DirectoryBackingStoreTest, DISABLED_Corruption) { | |
| 2090 { | |
| 2091 scoped_ptr<OnDiskDirectoryBackingStore> dbs( | |
| 2092 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath())); | |
| 2093 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get())); | |
| 2094 } | |
| 2095 std::string bad_data("BAD DATA"); | |
| 2096 EXPECT_TRUE(file_util::WriteFile(GetDatabasePath(), bad_data.data(), | |
| 2097 bad_data.size())); | |
| 2098 { | |
| 2099 scoped_ptr<OnDiskDirectoryBackingStore> dbs( | |
| 2100 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath())); | |
| 2101 | |
| 2102 EXPECT_FALSE(LoadAndIgnoreReturnedData(dbs.get())); | |
| 2103 } | |
| 2104 } | |
| 2105 | |
| 2106 TEST_F(DirectoryBackingStoreTest, DeleteEntries) { | |
| 2107 sql::Connection connection; | |
| 2108 ASSERT_TRUE(connection.OpenInMemory()); | |
| 2109 | |
| 2110 SetUpCurrentDatabaseAndCheckVersion(&connection); | |
| 2111 scoped_ptr<TestDirectoryBackingStore> dbs( | |
| 2112 new TestDirectoryBackingStore(GetUsername(), &connection)); | |
| 2113 MetahandlesIndex index; | |
| 2114 Directory::KernelLoadInfo kernel_load_info; | |
| 2115 STLElementDeleter<MetahandlesIndex> index_deleter(&index); | |
| 2116 | |
| 2117 dbs->Load(&index, &kernel_load_info); | |
| 2118 size_t initial_size = index.size(); | |
| 2119 ASSERT_LT(0U, initial_size) << "Test requires entries to delete."; | |
| 2120 int64 first_to_die = (*index.begin())->ref(META_HANDLE); | |
| 2121 MetahandleSet to_delete; | |
| 2122 to_delete.insert(first_to_die); | |
| 2123 EXPECT_TRUE(dbs->DeleteEntries(to_delete)); | |
| 2124 | |
| 2125 STLDeleteElements(&index); | |
| 2126 dbs->LoadEntries(&index); | |
| 2127 | |
| 2128 EXPECT_EQ(initial_size - 1, index.size()); | |
| 2129 bool delete_failed = false; | |
| 2130 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); | |
| 2131 ++it) { | |
| 2132 if ((*it)->ref(META_HANDLE) == first_to_die) { | |
| 2133 delete_failed = true; | |
| 2134 break; | |
| 2135 } | |
| 2136 } | |
| 2137 EXPECT_FALSE(delete_failed); | |
| 2138 | |
| 2139 to_delete.clear(); | |
| 2140 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); | |
| 2141 ++it) { | |
| 2142 to_delete.insert((*it)->ref(META_HANDLE)); | |
| 2143 } | |
| 2144 | |
| 2145 EXPECT_TRUE(dbs->DeleteEntries(to_delete)); | |
| 2146 | |
| 2147 STLDeleteElements(&index); | |
| 2148 dbs->LoadEntries(&index); | |
| 2149 EXPECT_EQ(0U, index.size()); | |
| 2150 } | |
| 2151 | |
| 2152 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) { | |
| 2153 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); | |
| 2154 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | |
| 2155 EXPECT_EQ(24U, guid1.size()); | |
| 2156 EXPECT_EQ(24U, guid2.size()); | |
| 2157 // In theory this test can fail, but it won't before the universe | |
| 2158 // dies of heat death. | |
| 2159 EXPECT_NE(guid1, guid2); | |
| 2160 } | |
| 2161 | |
| 2162 } // namespace syncable | |
| OLD | NEW |