Fix race condition in gyp/ninja builds.
[chromium-blink-merge.git] / sync / syncable / directory_backing_store_unittest.cc
blob88e49cf90d1f713fe37504201c06a688efc6bea3
1 // Copyright 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.
5 #include "testing/gtest/include/gtest/gtest.h"
7 #include <string>
9 #include "base/file_util.h"
10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/stl_util.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "sql/connection.h"
16 #include "sql/statement.h"
17 #include "sync/base/sync_export.h"
18 #include "sync/internal_api/public/base/node_ordinal.h"
19 #include "sync/protocol/bookmark_specifics.pb.h"
20 #include "sync/protocol/sync.pb.h"
21 #include "sync/syncable/directory_backing_store.h"
22 #include "sync/syncable/on_disk_directory_backing_store.h"
23 #include "sync/syncable/syncable-inl.h"
24 #include "sync/test/test_directory_backing_store.h"
25 #include "sync/util/time.h"
26 #include "testing/gtest/include/gtest/gtest-param-test.h"
28 namespace syncer {
29 namespace syncable {
31 SYNC_EXPORT_PRIVATE extern const int32 kCurrentDBVersion;
33 class MigrationTest : public testing::TestWithParam<int> {
34 public:
35 virtual void SetUp() {
36 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
39 protected:
40 std::string GetUsername() {
41 return "nick@chromium.org";
44 base::FilePath GetDatabasePath() {
45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename);
48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) {
49 Directory::MetahandlesMap tmp_handles_map;
50 JournalIndex delete_journals;
51 STLValueDeleter<Directory::MetahandlesMap> deleter(&tmp_handles_map);
52 Directory::KernelLoadInfo kernel_load_info;
53 return dbs->Load(&tmp_handles_map, &delete_journals, &kernel_load_info) ==
54 OPENED;
57 void SetUpVersion67Database(sql::Connection* connection);
58 void SetUpVersion68Database(sql::Connection* connection);
59 void SetUpVersion69Database(sql::Connection* connection);
60 void SetUpVersion70Database(sql::Connection* connection);
61 void SetUpVersion71Database(sql::Connection* connection);
62 void SetUpVersion72Database(sql::Connection* connection);
63 void SetUpVersion73Database(sql::Connection* connection);
64 void SetUpVersion74Database(sql::Connection* connection);
65 void SetUpVersion75Database(sql::Connection* connection);
66 void SetUpVersion76Database(sql::Connection* connection);
67 void SetUpVersion77Database(sql::Connection* connection);
68 void SetUpVersion78Database(sql::Connection* connection);
69 void SetUpVersion79Database(sql::Connection* connection);
70 void SetUpVersion80Database(sql::Connection* connection);
71 void SetUpVersion81Database(sql::Connection* connection);
72 void SetUpVersion82Database(sql::Connection* connection);
73 void SetUpVersion83Database(sql::Connection* connection);
74 void SetUpVersion84Database(sql::Connection* connection);
75 void SetUpVersion85Database(sql::Connection* connection);
76 void SetUpVersion86Database(sql::Connection* connection);
77 void SetUpVersion87Database(sql::Connection* connection);
78 void SetUpVersion88Database(sql::Connection* connection);
80 void SetUpCurrentDatabaseAndCheckVersion(sql::Connection* connection) {
81 SetUpVersion88Database(connection); // Prepopulates data.
82 scoped_ptr<TestDirectoryBackingStore> dbs(
83 new TestDirectoryBackingStore(GetUsername(), connection));
84 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
86 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
87 ASSERT_FALSE(dbs->needs_column_refresh_);
90 private:
91 base::ScopedTempDir temp_dir_;
94 class DirectoryBackingStoreTest : public MigrationTest {};
96 #if defined(OS_WIN)
98 // On Windows, we used to store timestamps in FILETIME format.
99 #define LEGACY_META_PROTO_TIMES_1 129079956640320000LL
100 #define LEGACY_META_PROTO_TIMES_2 128976886618480000LL
101 #define LEGACY_META_PROTO_TIMES_4 129002163642690000LL
102 #define LEGACY_META_PROTO_TIMES_5 129001555500000000LL
103 #define LEGACY_META_PROTO_TIMES_6 129053976170000000LL
104 #define LEGACY_META_PROTO_TIMES_7 128976864758480000LL
105 #define LEGACY_META_PROTO_TIMES_8 128976864758480000LL
106 #define LEGACY_META_PROTO_TIMES_9 128976864758480000LL
107 #define LEGACY_META_PROTO_TIMES_10 128976864758480000LL
108 #define LEGACY_META_PROTO_TIMES_11 129079956948440000LL
109 #define LEGACY_META_PROTO_TIMES_12 129079957513650000LL
110 #define LEGACY_META_PROTO_TIMES_13 129079957985300000LL
111 #define LEGACY_META_PROTO_TIMES_14 129079958383000000LL
113 #define LEGACY_META_PROTO_TIMES_STR_1 "129079956640320000"
114 #define LEGACY_META_PROTO_TIMES_STR_2 "128976886618480000"
115 #define LEGACY_META_PROTO_TIMES_STR_4 "129002163642690000"
116 #define LEGACY_META_PROTO_TIMES_STR_5 "129001555500000000"
117 #define LEGACY_META_PROTO_TIMES_STR_6 "129053976170000000"
118 #define LEGACY_META_PROTO_TIMES_STR_7 "128976864758480000"
119 #define LEGACY_META_PROTO_TIMES_STR_8 "128976864758480000"
120 #define LEGACY_META_PROTO_TIMES_STR_9 "128976864758480000"
121 #define LEGACY_META_PROTO_TIMES_STR_10 "128976864758480000"
122 #define LEGACY_META_PROTO_TIMES_STR_11 "129079956948440000"
123 #define LEGACY_META_PROTO_TIMES_STR_12 "129079957513650000"
124 #define LEGACY_META_PROTO_TIMES_STR_13 "129079957985300000"
125 #define LEGACY_META_PROTO_TIMES_STR_14 "129079958383000000"
127 // Generated via:
129 // ruby -ane '$F[1].sub!("LEGACY_", ""); $F[2] = Integer($F[2].sub!("LL", "")) /
130 // 10000 - 11644473600000; print "#{$F[0]} #{$F[1]} #{$F[2]}LL"'
132 // Magic numbers taken from
133 // http://stackoverflow.com/questions/5398557/
134 // java-library-for-dealing-with-win32-filetime .
136 // Now we store them in Java format (ms since the Unix epoch).
137 #define META_PROTO_TIMES_1 1263522064032LL
138 #define META_PROTO_TIMES_2 1253215061848LL
139 #define META_PROTO_TIMES_4 1255742764269LL
140 #define META_PROTO_TIMES_5 1255681950000LL
141 #define META_PROTO_TIMES_6 1260924017000LL
142 #define META_PROTO_TIMES_7 1253212875848LL
143 #define META_PROTO_TIMES_8 1253212875848LL
144 #define META_PROTO_TIMES_9 1253212875848LL
145 #define META_PROTO_TIMES_10 1253212875848LL
146 #define META_PROTO_TIMES_11 1263522094844LL
147 #define META_PROTO_TIMES_12 1263522151365LL
148 #define META_PROTO_TIMES_13 1263522198530LL
149 #define META_PROTO_TIMES_14 1263522238300LL
151 #define META_PROTO_TIMES_STR_1 "1263522064032"
152 #define META_PROTO_TIMES_STR_2 "1253215061848"
153 #define META_PROTO_TIMES_STR_4 "1255742764269"
154 #define META_PROTO_TIMES_STR_5 "1255681950000"
155 #define META_PROTO_TIMES_STR_6 "1260924017000"
156 #define META_PROTO_TIMES_STR_7 "1253212875848"
157 #define META_PROTO_TIMES_STR_8 "1253212875848"
158 #define META_PROTO_TIMES_STR_9 "1253212875848"
159 #define META_PROTO_TIMES_STR_10 "1253212875848"
160 #define META_PROTO_TIMES_STR_11 "1263522094844"
161 #define META_PROTO_TIMES_STR_12 "1263522151365"
162 #define META_PROTO_TIMES_STR_13 "1263522198530"
163 #define META_PROTO_TIMES_STR_14 "1263522238300"
165 #else
167 // On other platforms, we used to store timestamps in time_t format (s
168 // since the Unix epoch).
169 #define LEGACY_META_PROTO_TIMES_1 1263522064LL
170 #define LEGACY_META_PROTO_TIMES_2 1253215061LL
171 #define LEGACY_META_PROTO_TIMES_4 1255742764LL
172 #define LEGACY_META_PROTO_TIMES_5 1255681950LL
173 #define LEGACY_META_PROTO_TIMES_6 1260924017LL
174 #define LEGACY_META_PROTO_TIMES_7 1253212875LL
175 #define LEGACY_META_PROTO_TIMES_8 1253212875LL
176 #define LEGACY_META_PROTO_TIMES_9 1253212875LL
177 #define LEGACY_META_PROTO_TIMES_10 1253212875LL
178 #define LEGACY_META_PROTO_TIMES_11 1263522094LL
179 #define LEGACY_META_PROTO_TIMES_12 1263522151LL
180 #define LEGACY_META_PROTO_TIMES_13 1263522198LL
181 #define LEGACY_META_PROTO_TIMES_14 1263522238LL
183 #define LEGACY_META_PROTO_TIMES_STR_1 "1263522064"
184 #define LEGACY_META_PROTO_TIMES_STR_2 "1253215061"
185 #define LEGACY_META_PROTO_TIMES_STR_4 "1255742764"
186 #define LEGACY_META_PROTO_TIMES_STR_5 "1255681950"
187 #define LEGACY_META_PROTO_TIMES_STR_6 "1260924017"
188 #define LEGACY_META_PROTO_TIMES_STR_7 "1253212875"
189 #define LEGACY_META_PROTO_TIMES_STR_8 "1253212875"
190 #define LEGACY_META_PROTO_TIMES_STR_9 "1253212875"
191 #define LEGACY_META_PROTO_TIMES_STR_10 "1253212875"
192 #define LEGACY_META_PROTO_TIMES_STR_11 "1263522094"
193 #define LEGACY_META_PROTO_TIMES_STR_12 "1263522151"
194 #define LEGACY_META_PROTO_TIMES_STR_13 "1263522198"
195 #define LEGACY_META_PROTO_TIMES_STR_14 "1263522238"
197 // Now we store them in Java format (ms since the Unix epoch).
198 #define META_PROTO_TIMES_1 1263522064000LL
199 #define META_PROTO_TIMES_2 1253215061000LL
200 #define META_PROTO_TIMES_4 1255742764000LL
201 #define META_PROTO_TIMES_5 1255681950000LL
202 #define META_PROTO_TIMES_6 1260924017000LL
203 #define META_PROTO_TIMES_7 1253212875000LL
204 #define META_PROTO_TIMES_8 1253212875000LL
205 #define META_PROTO_TIMES_9 1253212875000LL
206 #define META_PROTO_TIMES_10 1253212875000LL
207 #define META_PROTO_TIMES_11 1263522094000LL
208 #define META_PROTO_TIMES_12 1263522151000LL
209 #define META_PROTO_TIMES_13 1263522198000LL
210 #define META_PROTO_TIMES_14 1263522238000LL
212 #define META_PROTO_TIMES_STR_1 "1263522064000"
213 #define META_PROTO_TIMES_STR_2 "1253215061000"
214 #define META_PROTO_TIMES_STR_4 "1255742764000"
215 #define META_PROTO_TIMES_STR_5 "1255681950000"
216 #define META_PROTO_TIMES_STR_6 "1260924017000"
217 #define META_PROTO_TIMES_STR_7 "1253212875000"
218 #define META_PROTO_TIMES_STR_8 "1253212875000"
219 #define META_PROTO_TIMES_STR_9 "1253212875000"
220 #define META_PROTO_TIMES_STR_10 "1253212875000"
221 #define META_PROTO_TIMES_STR_11 "1263522094000"
222 #define META_PROTO_TIMES_STR_12 "1263522151000"
223 #define META_PROTO_TIMES_STR_13 "1263522198000"
224 #define META_PROTO_TIMES_STR_14 "1263522238000"
226 #endif
228 // Helper macros for the database dumps in the SetUpVersion*Database
229 // functions.
230 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x
231 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x
232 #define LEGACY_PROTO_TIME_VALS(x) \
233 LEGACY_META_PROTO_TIMES_STR(x) "," \
234 LEGACY_META_PROTO_TIMES_STR(x) "," \
235 LEGACY_META_PROTO_TIMES_STR(x) "," \
236 LEGACY_META_PROTO_TIMES_STR(x)
237 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
238 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x
239 #define META_PROTO_TIMES_VALS(x) \
240 META_PROTO_TIMES_STR(x) "," \
241 META_PROTO_TIMES_STR(x) "," \
242 META_PROTO_TIMES_STR(x) "," \
243 META_PROTO_TIMES_STR(x)
245 namespace {
247 // Helper functions for testing.
249 enum ShouldIncludeDeletedItems {
250 INCLUDE_DELETED_ITEMS,
251 DONT_INCLUDE_DELETED_ITEMS
254 // Returns a map from metahandle -> expected legacy time (in proto
255 // format).
256 std::map<int64, int64> GetExpectedLegacyMetaProtoTimes(
257 enum ShouldIncludeDeletedItems include_deleted) {
258 std::map<int64, int64> expected_legacy_meta_proto_times;
259 expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1);
260 if (include_deleted == INCLUDE_DELETED_ITEMS) {
261 expected_legacy_meta_proto_times[2] = LEGACY_META_PROTO_TIMES(2);
262 expected_legacy_meta_proto_times[4] = LEGACY_META_PROTO_TIMES(4);
263 expected_legacy_meta_proto_times[5] = LEGACY_META_PROTO_TIMES(5);
265 expected_legacy_meta_proto_times[6] = LEGACY_META_PROTO_TIMES(6);
266 expected_legacy_meta_proto_times[7] = LEGACY_META_PROTO_TIMES(7);
267 expected_legacy_meta_proto_times[8] = LEGACY_META_PROTO_TIMES(8);
268 expected_legacy_meta_proto_times[9] = LEGACY_META_PROTO_TIMES(9);
269 expected_legacy_meta_proto_times[10] = LEGACY_META_PROTO_TIMES(10);
270 expected_legacy_meta_proto_times[11] = LEGACY_META_PROTO_TIMES(11);
271 expected_legacy_meta_proto_times[12] = LEGACY_META_PROTO_TIMES(12);
272 expected_legacy_meta_proto_times[13] = LEGACY_META_PROTO_TIMES(13);
273 expected_legacy_meta_proto_times[14] = LEGACY_META_PROTO_TIMES(14);
274 return expected_legacy_meta_proto_times;
277 // Returns a map from metahandle -> expected time (in proto format).
278 std::map<int64, int64> GetExpectedMetaProtoTimes(
279 enum ShouldIncludeDeletedItems include_deleted) {
280 std::map<int64, int64> expected_meta_proto_times;
281 expected_meta_proto_times[1] = META_PROTO_TIMES(1);
282 if (include_deleted == INCLUDE_DELETED_ITEMS) {
283 expected_meta_proto_times[2] = META_PROTO_TIMES(2);
284 expected_meta_proto_times[4] = META_PROTO_TIMES(4);
285 expected_meta_proto_times[5] = META_PROTO_TIMES(5);
287 expected_meta_proto_times[6] = META_PROTO_TIMES(6);
288 expected_meta_proto_times[7] = META_PROTO_TIMES(7);
289 expected_meta_proto_times[8] = META_PROTO_TIMES(8);
290 expected_meta_proto_times[9] = META_PROTO_TIMES(9);
291 expected_meta_proto_times[10] = META_PROTO_TIMES(10);
292 expected_meta_proto_times[11] = META_PROTO_TIMES(11);
293 expected_meta_proto_times[12] = META_PROTO_TIMES(12);
294 expected_meta_proto_times[13] = META_PROTO_TIMES(13);
295 expected_meta_proto_times[14] = META_PROTO_TIMES(14);
296 return expected_meta_proto_times;
299 // Returns a map from metahandle -> expected time (as a Time object).
300 std::map<int64, base::Time> GetExpectedMetaTimes() {
301 std::map<int64, base::Time> expected_meta_times;
302 const std::map<int64, int64>& expected_meta_proto_times =
303 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS);
304 for (std::map<int64, int64>::const_iterator it =
305 expected_meta_proto_times.begin();
306 it != expected_meta_proto_times.end(); ++it) {
307 expected_meta_times[it->first] = ProtoTimeToTime(it->second);
309 return expected_meta_times;
312 // Extracts a map from metahandle -> time (in proto format) from the
313 // given database.
314 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) {
315 sql::Statement s(db->GetCachedStatement(
316 SQL_FROM_HERE,
317 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime "
318 "FROM metas"));
319 EXPECT_EQ(5, s.ColumnCount());
320 std::map<int64, int64> meta_times;
321 while (s.Step()) {
322 int64 metahandle = s.ColumnInt64(0);
323 int64 mtime = s.ColumnInt64(1);
324 int64 server_mtime = s.ColumnInt64(2);
325 int64 ctime = s.ColumnInt64(3);
326 int64 server_ctime = s.ColumnInt64(4);
327 EXPECT_EQ(mtime, server_mtime);
328 EXPECT_EQ(mtime, ctime);
329 EXPECT_EQ(mtime, server_ctime);
330 meta_times[metahandle] = mtime;
332 EXPECT_TRUE(s.Succeeded());
333 return meta_times;
336 ::testing::AssertionResult AssertTimesMatch(const char* t1_expr,
337 const char* t2_expr,
338 const base::Time& t1,
339 const base::Time& t2) {
340 if (t1 == t2)
341 return ::testing::AssertionSuccess();
343 return ::testing::AssertionFailure()
344 << t1_expr << " and " << t2_expr
345 << " (internal values: " << t1.ToInternalValue()
346 << " and " << t2.ToInternalValue()
347 << ") (proto time: " << TimeToProtoTime(t1)
348 << " and " << TimeToProtoTime(t2)
349 << ") do not match";
352 // Expect that all time fields of the given entry kernel will be the
353 // given time.
354 void ExpectTime(const EntryKernel& entry_kernel,
355 const base::Time& expected_time) {
356 EXPECT_PRED_FORMAT2(AssertTimesMatch,
357 expected_time, entry_kernel.ref(CTIME));
358 EXPECT_PRED_FORMAT2(AssertTimesMatch,
359 expected_time, entry_kernel.ref(SERVER_CTIME));
360 EXPECT_PRED_FORMAT2(AssertTimesMatch,
361 expected_time, entry_kernel.ref(MTIME));
362 EXPECT_PRED_FORMAT2(AssertTimesMatch,
363 expected_time, entry_kernel.ref(SERVER_MTIME));
366 // Expect that all the entries in |entries| have times matching those in
367 // the given map (from metahandle to expect time).
368 void ExpectTimes(const Directory::MetahandlesMap& handles_map,
369 const std::map<int64, base::Time>& expected_times) {
370 for (Directory::MetahandlesMap::const_iterator it = handles_map.begin();
371 it != handles_map.end(); ++it) {
372 int64 meta_handle = it->first;
373 SCOPED_TRACE(meta_handle);
374 std::map<int64, base::Time>::const_iterator it2 =
375 expected_times.find(meta_handle);
376 if (it2 == expected_times.end()) {
377 ADD_FAILURE() << "Could not find expected time for " << meta_handle;
378 continue;
380 ExpectTime(*it->second, it2->second);
384 } // namespace
386 void MigrationTest::SetUpVersion67Database(sql::Connection* connection) {
387 // This is a version 67 database dump whose contents were backformed from
388 // the contents of the version 68 database dump (the v68 migration was
389 // actually written first).
390 ASSERT_TRUE(connection->is_open());
391 ASSERT_TRUE(connection->BeginTransaction());
392 ASSERT_TRUE(connection->Execute(
393 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
394 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
395 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
396 "base_version bigint default -1,server_version bigint default 0,"
397 "mtime bigint default 0,server_mtime bigint default 0,"
398 "ctime bigint default 0,server_ctime bigint default 0,"
399 "server_position_in_parent bigint default 0,"
400 "local_external_id bigint default 0,id varchar(255) default 'r',"
401 "parent_id varchar(255) default 'r',"
402 "server_parent_id varchar(255) default 'r',"
403 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
404 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
405 "is_del bit default 0,is_dir bit default 0,"
406 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
407 "server_is_del bit default 0,server_is_bookmark_object bit default 0,"
408 "name varchar(255), " /* COLLATE PATHNAME, */
409 "unsanitized_name varchar(255)," /* COLLATE PATHNAME, */
410 "non_unique_name varchar,"
411 "server_name varchar(255)," /* COLLATE PATHNAME */
412 "server_non_unique_name varchar,"
413 "bookmark_url varchar,server_bookmark_url varchar,"
414 "singleton_tag varchar,bookmark_favicon blob,"
415 "server_bookmark_favicon blob);"
416 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
417 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
418 "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);"
419 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
420 ",-2097152,"
421 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
422 "'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',"
423 "'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA',"
424 "'ASADGADGADG');"
425 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
426 ",-3145728,"
427 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
428 "'Welcome to Chromium',NULL,'Welcome to Chromium',"
429 "'Welcome to Chromium','Welcome to Chromium',"
430 "'http://www.google.com/chrome/intl/en/welcome.html',"
431 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
432 "NULL);"
433 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
434 ",1048576,"
435 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
436 "'Google',NULL,'Google','Google','Google','http://www.google.com/',"
437 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
438 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
439 ",-4194304,"
440 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
441 "'The Internet',NULL,'The Internet','The Internet',"
442 "'The Internet',NULL,NULL,NULL,NULL,NULL);"
443 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
445 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
446 "'Google Chrome',NULL,'Google Chrome','Google Chrome',"
447 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);"
448 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
449 ",1048576,"
450 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
451 "NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,"
452 "'google_chrome_bookmarks',NULL,NULL);"
453 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
455 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
456 "1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',"
457 "NULL,NULL,'bookmark_bar',NULL,NULL);"
458 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
459 ",2097152,"
460 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
461 "'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',"
462 "'Other Bookmarks',NULL,NULL,'other_bookmarks',"
463 "NULL,NULL);"
464 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
465 ",-1048576,"
466 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
467 "'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',"
468 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
469 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
470 "'AGATWA','AFAGVASF');"
471 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
472 ",0,9,"
473 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
474 "'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',"
475 "'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
476 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
477 ",-917504,"
478 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
479 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
480 "'ICANN Internet Corporation for Assigned Names and Numbers',"
481 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
482 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
483 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
484 "'http://www.icann.com/','http://www.icann.com/',NULL,"
485 "'PNGAXF0AAFF','DAAFASF');"
486 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
487 ",1048576,"
488 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
489 "'The WebKit Open Source Project',NULL,"
490 "'The WebKit Open Source Project','The WebKit Open Source Project',"
491 "'The WebKit Open Source Project','http://webkit.org/',"
492 "'http://webkit.org/x',NULL,'PNGX','PNG2Y');"
493 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
494 "last_sync_timestamp INT, name VARCHAR(128), "
495 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
496 "db_create_version VARCHAR(128), db_create_time int, "
497 "next_id bigint default -2, cache_guid VARCHAR(32));"
498 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
499 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
500 "'Unknown',1263522064,-65542,"
501 "'9010788312004066376x-6609234393368420856x');"
502 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
503 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
504 ASSERT_TRUE(connection->CommitTransaction());
507 void MigrationTest::SetUpVersion68Database(sql::Connection* connection) {
508 // This sets up an actual version 68 database dump. The IDs were
509 // canonicalized to be less huge, and the favicons were overwritten
510 // with random junk so that they didn't contain any unprintable
511 // characters. A few server URLs were tweaked so that they'd be
512 // different from the local URLs. Lastly, the custom collation on
513 // the server_non_unique_name column was removed.
514 ASSERT_TRUE(connection->is_open());
515 ASSERT_TRUE(connection->BeginTransaction());
516 ASSERT_TRUE(connection->Execute(
517 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
518 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
519 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
520 "base_version bigint default -1,server_version bigint default 0,"
521 "mtime bigint default 0,server_mtime bigint default 0,"
522 "ctime bigint default 0,server_ctime bigint default 0,"
523 "server_position_in_parent bigint default 0,"
524 "local_external_id bigint default 0,id varchar(255) default 'r',"
525 "parent_id varchar(255) default 'r',"
526 "server_parent_id varchar(255) default 'r',"
527 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
528 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
529 "is_del bit default 0,is_dir bit default 0,"
530 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
531 "server_is_del bit default 0,"
532 "server_is_bookmark_object bit default 0,"
533 "non_unique_name varchar,server_non_unique_name varchar(255),"
534 "bookmark_url varchar,server_bookmark_url varchar,"
535 "singleton_tag varchar,bookmark_favicon blob,"
536 "server_bookmark_favicon blob);"
537 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
538 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
539 "NULL,NULL,NULL,NULL,NULL,NULL);"
540 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
541 ",-2097152,"
542 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
543 "'Deleted Item','Deleted Item','http://www.google.com/',"
544 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');"
545 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
546 ",-3145728,"
547 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
548 "'Welcome to Chromium','Welcome to Chromium',"
549 "'http://www.google.com/chrome/intl/en/welcome.html',"
550 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
551 "NULL);"
552 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
553 ",1048576,"
554 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
555 "'Google','Google','http://www.google.com/',"
556 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
557 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
558 ",-4194304,"
559 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
560 "'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);"
561 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
563 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
564 "'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL,"
565 "NULL);"
566 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
567 ",1048576,"
568 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
569 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);"
570 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
572 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
573 "1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,"
574 "NULL);"
575 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
576 ",2097152,"
577 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
578 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
579 "NULL,NULL);"
580 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
581 ",-1048576,"
582 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
583 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
584 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
585 "'AGATWA','AFAGVASF');"
586 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
587 ",0,9,"
588 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
589 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
590 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
591 ",-917504,"
592 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
593 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
594 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
595 "'http://www.icann.com/','http://www.icann.com/',NULL,"
596 "'PNGAXF0AAFF','DAAFASF');"
597 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
598 ",1048576,"
599 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
600 "'The WebKit Open Source Project','The WebKit Open Source Project',"
601 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');"
602 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
603 "last_sync_timestamp INT, name VARCHAR(128), "
604 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
605 "db_create_version VARCHAR(128), db_create_time int, "
606 "next_id bigint default -2, cache_guid VARCHAR(32));"
607 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
608 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
609 "'Unknown',1263522064,-65542,"
610 "'9010788312004066376x-6609234393368420856x');"
611 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
612 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
613 ASSERT_TRUE(connection->CommitTransaction());
616 void MigrationTest::SetUpVersion69Database(sql::Connection* connection) {
617 ASSERT_TRUE(connection->is_open());
618 ASSERT_TRUE(connection->BeginTransaction());
619 ASSERT_TRUE(connection->Execute(
620 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
621 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
622 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
623 "base_version bigint default -1,server_version bigint default 0,"
624 "mtime bigint default 0,server_mtime bigint default 0,"
625 "ctime bigint default 0,server_ctime bigint default 0,"
626 "server_position_in_parent bigint default 0,"
627 "local_external_id bigint default 0,id varchar(255) default 'r',"
628 "parent_id varchar(255) default 'r',"
629 "server_parent_id varchar(255) default 'r',"
630 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
631 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
632 "is_del bit default 0,is_dir bit default 0,"
633 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
634 "server_is_del bit default 0,"
635 "server_is_bookmark_object bit default 0,"
636 "non_unique_name varchar,server_non_unique_name varchar(255),"
637 "bookmark_url varchar,server_bookmark_url varchar,"
638 "singleton_tag varchar,bookmark_favicon blob,"
639 "server_bookmark_favicon blob, specifics blob, "
640 "server_specifics blob);"
641 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
642 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"
643 "NULL,NULL,X'',X'');"
644 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
645 ",-2097152,"
646 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
647 "'Deleted Item','Deleted Item','http://www.google.com/',"
648 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG',"
649 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415"
650 "34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F"
651 "6D2F32120B4153414447414447414447');"
652 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
653 ",-3145728,"
654 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
655 "'Welcome to Chromium','Welcome to Chromium',"
656 "'http://www.google.com/chrome/intl/en/welcome.html',"
657 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,NULL,"
658 "X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
659 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168"
660 "7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6"
661 "56E2F77656C636F6D652E68746D6C1200');"
662 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
663 ",1048576,7,"
664 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
665 "'Google','Google','http://www.google.com/',"
666 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166"
667 "87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'"
668 "C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464"
669 "447415347');"
670 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
671 ",-4194304,6"
672 ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet',"
673 "'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');"
674 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
675 ",1048576,0,"
676 "'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome',"
677 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);"
678 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
679 ",1048576,0,"
680 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
681 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL,"
682 "X'C2881000',X'C2881000');"
683 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
684 ",1048576,1,"
685 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1,"
686 "'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL,"
687 "X'C2881000',X'C2881000');"
688 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
689 ",2097152,2,"
690 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
691 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
692 "NULL,NULL,X'C2881000',X'C2881000');"
693 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
694 ",-1048576,"
695 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
696 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
697 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
698 "'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6"
699 "9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576"
700 "2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');"
701 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
702 ",0,9,"
703 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
704 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL,"
705 "X'C2881000',X'C2881000');"
706 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
707 ",-917504,"
708 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
709 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
710 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
711 "'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF',"
712 "'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"
713 "20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963"
714 "616E6E2E636F6D2F120744414146415346');"
715 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
716 ",1048576,11,"
717 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
718 "'The WebKit Open Source Project','The WebKit Open Source Project',"
719 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y',"
720 "X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C2"
721 "88101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259');"
722 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
723 "last_sync_timestamp INT, name VARCHAR(128), "
724 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
725 "db_create_version VARCHAR(128), db_create_time int, "
726 "next_id bigint default -2, cache_guid VARCHAR(32));"
727 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
728 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
729 "'Unknown',1263522064,-65542,"
730 "'9010788312004066376x-6609234393368420856x');"
731 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
732 "INSERT INTO share_version VALUES('nick@chromium.org',69);"
734 ASSERT_TRUE(connection->CommitTransaction());
737 void MigrationTest::SetUpVersion70Database(sql::Connection* connection) {
738 ASSERT_TRUE(connection->is_open());
739 ASSERT_TRUE(connection->BeginTransaction());
740 ASSERT_TRUE(connection->Execute(
741 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
742 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
743 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
744 "last_sync_timestamp INT, name VARCHAR(128), "
745 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
746 "db_create_version VARCHAR(128), db_create_time int, "
747 "next_id bigint default -2, cache_guid VARCHAR(32));"
748 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
749 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
750 "'Unknown',1263522064,-65542,"
751 "'9010788312004066376x-6609234393368420856x');"
752 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
753 "INSERT INTO share_version VALUES('nick@chromium.org',70);"
754 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
755 "base_version bigint default -1,server_version bigint default 0,"
756 "mtime bigint default 0,server_mtime bigint default 0,"
757 "ctime bigint default 0,server_ctime bigint default 0,"
758 "server_position_in_parent bigint default 0,"
759 "local_external_id bigint default 0,id varchar(255) default 'r',"
760 "parent_id varchar(255) default 'r',"
761 "server_parent_id varchar(255) default 'r',"
762 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
763 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
764 "is_del bit default 0,is_dir bit default 0,"
765 "server_is_dir bit default 0,server_is_del bit default 0,"
766 "non_unique_name varchar,server_non_unique_name varchar(255),"
767 "unique_server_tag varchar,unique_client_tag varchar,"
768 "specifics blob,server_specifics blob);"
769 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
770 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
771 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) ","
772 "-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,"
773 "1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A"
774 "2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026"
775 "0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741"
776 "4447414447');"
777 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
778 ",-3145728,"
779 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
780 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A"
781 "31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74"
782 "6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F"
783 "2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
784 "6C636F6D652E68746D6C1200');"
785 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
786 ",1048576,7,"
787 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
788 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6"
789 "52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777"
790 "72E676F6F676C652E636F6D2F12084147464447415347');"
791 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
792 ",-4194304,"
793 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
794 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
795 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
796 ",1048576,0,"
797 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome',"
798 "'Google Chrome','google_chrome',NULL,NULL,NULL);"
799 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
800 ",1048576,0,"
801 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
802 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',"
803 "X'C2881000');"
804 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
805 ",1048576,"
806 "1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,"
807 "'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',"
808 "X'C2881000');"
809 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
811 "2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
812 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
813 "X'C2881000',X'C2881000');"
814 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
815 ",-1048576,"
816 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
817 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
818 "NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F"
819 "72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872"
820 "6F6D69756D2E6F72672F6F7468657212084146414756415346');"
821 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
822 ",0,9,"
823 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
824 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
825 "X'C2881000');"
826 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
827 ",-917504,"
828 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
829 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
830 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
831 "NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F"
832 "120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69"
833 "63616E6E2E636F6D2F120744414146415346');"
834 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
835 ",1048576,"
836 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
837 "'The WebKit Open Source Project','The WebKit Open Source Project',"
838 "NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
839 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F78120550"
840 "4E473259');"
842 ASSERT_TRUE(connection->CommitTransaction());
845 void MigrationTest::SetUpVersion71Database(sql::Connection* connection) {
846 ASSERT_TRUE(connection->is_open());
847 ASSERT_TRUE(connection->BeginTransaction());
848 ASSERT_TRUE(connection->Execute(
849 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
850 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
851 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
852 "INSERT INTO 'share_version' VALUES('nick@chromium.org',71);"
853 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
854 "base_version bigint default -1,server_version bigint default 0,"
855 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
856 "default 0,server_ctime bigint default 0,server_position_in_parent "
857 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
858 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
859 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
860 "varchar(255) default 'r',is_unsynced bit default 0,"
861 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
862 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
863 "non_unique_name varchar,server_non_unique_name varchar(255),"
864 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
865 "server_specifics blob);"
866 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
867 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
868 "NULL,NULL,X'',X'');"
869 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
870 ",-2097152,4,"
871 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
872 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
873 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
874 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
875 "47');"
876 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
877 ",-3145728,3,"
878 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
879 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
880 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
881 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
882 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
883 "652E68746D6C1200');"
884 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
885 ",1048576,7,"
886 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
887 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
888 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
889 "76F6F676C652E636F6D2F12084147464447415347');"
890 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
891 ",-4194304,6,"
892 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
893 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
894 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
895 ",1048576,0,"
896 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
897 ",'google_chrome',NULL,NULL,NULL);"
898 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
899 ",1048576,0,"
900 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
901 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
902 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
903 ",1048576,1,"
904 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
905 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
906 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
907 ",2097152,2,"
908 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
909 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
910 "X'C2881000',X'C2881000');"
911 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
912 ",-1048576,8,"
913 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
914 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
915 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
916 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
917 "D2E6F72672F6F7468657212084146414756415346');"
918 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
919 ",0,9,"
920 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
921 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
922 "X'C2881000');"
923 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
924 ",-917504,10,"
925 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
926 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
927 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
928 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
929 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
930 "E636F6D2F120744414146415346');"
931 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
932 ",1048576,11,"
933 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
934 "'The WebKit Open Source Project','The WebKit Open Source Project',"
935 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
936 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
937 "473259');"
938 "CREATE TABLE models (model_id BLOB primary key, "
939 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
940 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
941 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
942 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
943 "next_id INT default -2, cache_guid TEXT);"
944 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
945 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
946 "'9010788312004066376x-6609234393368420856x');"));
947 ASSERT_TRUE(connection->CommitTransaction());
950 void MigrationTest::SetUpVersion72Database(sql::Connection* connection) {
951 ASSERT_TRUE(connection->is_open());
952 ASSERT_TRUE(connection->BeginTransaction());
953 ASSERT_TRUE(connection->Execute(
954 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
955 "INSERT INTO 'share_version' VALUES('nick@chromium.org',72);"
956 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
957 "base_version bigint default -1,server_version bigint default 0,"
958 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
959 "default 0,server_ctime bigint default 0,server_position_in_parent "
960 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
961 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
962 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
963 "varchar(255) default 'r',is_unsynced bit default 0,"
964 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
965 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
966 "non_unique_name varchar,server_non_unique_name varchar(255),"
967 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
968 "server_specifics blob);"
969 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
970 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
971 "NULL,NULL,X'',X'');"
972 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
973 ",-2097152,4,"
974 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
975 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
976 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
977 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
978 "47');"
979 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
980 ",-3145728,3,"
981 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
982 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
983 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
984 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
985 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
986 "652E68746D6C1200');"
987 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
988 ",1048576,7,"
989 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
990 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
991 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
992 "76F6F676C652E636F6D2F12084147464447415347');"
993 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
994 ",-4194304,6,"
995 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
996 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
997 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
998 ",1048576,0,"
999 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1000 ",'google_chrome',NULL,NULL,NULL);"
1001 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1002 ",1048576,0,"
1003 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1004 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1005 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1006 ",1048576,1,"
1007 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1008 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1009 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1010 ",2097152,2,"
1011 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1012 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1013 "X'C2881000',X'C2881000');"
1014 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1015 ",-1048576,8,"
1016 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1017 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1018 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1019 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1020 "D2E6F72672F6F7468657212084146414756415346');"
1021 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1022 ",0,9,"
1023 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1024 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1025 "X'C2881000');"
1026 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1027 ",-917504,10,"
1028 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1029 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1030 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1031 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1032 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1033 "E636F6D2F120744414146415346');"
1034 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1035 ",1048576,11,"
1036 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1037 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1038 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1039 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1040 "473259');"
1041 "CREATE TABLE models (model_id BLOB primary key, "
1042 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1043 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1044 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1045 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1046 "next_id INT default -2, cache_guid TEXT);"
1047 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1048 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1049 "'9010788312004066376x-6609234393368420856x');"));
1050 ASSERT_TRUE(connection->CommitTransaction());
1053 void MigrationTest::SetUpVersion73Database(sql::Connection* connection) {
1054 ASSERT_TRUE(connection->is_open());
1055 ASSERT_TRUE(connection->BeginTransaction());
1056 ASSERT_TRUE(connection->Execute(
1057 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1058 "INSERT INTO 'share_version' VALUES('nick@chromium.org',73);"
1059 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
1060 "base_version bigint default -1,server_version bigint default 0,"
1061 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
1062 "default 0,server_ctime bigint default 0,server_position_in_parent "
1063 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
1064 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
1065 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
1066 "varchar(255) default 'r',is_unsynced bit default 0,"
1067 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
1068 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
1069 "non_unique_name varchar,server_non_unique_name varchar(255),"
1070 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
1071 "server_specifics blob);"
1072 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1073 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
1074 "NULL,NULL,X'',X'');"
1075 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1076 ",-2097152,4,"
1077 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
1078 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
1079 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
1080 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
1081 "47');"
1082 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1083 ",-3145728,3,"
1084 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
1085 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
1086 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
1087 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
1088 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
1089 "652E68746D6C1200');"
1090 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1091 ",1048576,7,"
1092 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
1093 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
1094 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
1095 "76F6F676C652E636F6D2F12084147464447415347');"
1096 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1097 ",-4194304,6,"
1098 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
1099 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
1100 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1101 ",1048576,0,"
1102 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1103 ",'google_chrome',NULL,NULL,NULL);"
1104 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1105 ",1048576,0,"
1106 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1107 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1108 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1109 ",1048576,1,"
1110 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1111 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1112 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1113 ",2097152,2,"
1114 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1115 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1116 "X'C2881000',X'C2881000');"
1117 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1118 ",-1048576,8,"
1119 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1120 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1121 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1122 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1123 "D2E6F72672F6F7468657212084146414756415346');"
1124 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1125 ",0,9,"
1126 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1127 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1128 "X'C2881000');"
1129 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1130 ",-917504,10,"
1131 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1132 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1133 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1134 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1135 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1136 "E636F6D2F120744414146415346');"
1137 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1138 ",1048576,11,"
1139 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1140 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1141 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1142 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1143 "473259');"
1144 "CREATE TABLE models (model_id BLOB primary key, "
1145 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1146 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1147 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1148 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1149 "next_id INT default -2, cache_guid TEXT, "
1150 "notification_state BLOB);"
1151 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1152 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1153 "'9010788312004066376x-6609234393368420856x',X'C2881000');"));
1154 ASSERT_TRUE(connection->CommitTransaction());
1157 void MigrationTest::SetUpVersion74Database(sql::Connection* connection) {
1158 ASSERT_TRUE(connection->is_open());
1159 ASSERT_TRUE(connection->BeginTransaction());
1160 ASSERT_TRUE(connection->Execute(
1161 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1162 "INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"
1163 "CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"
1164 " INT, initial_sync_ended BOOLEAN default 0);"
1165 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1166 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1167 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1168 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1169 "tion_state INT default 0, bookmarks_added_during_autofill_migration"
1170 " INT default 0, autofill_migration_time INT default 0, autofill_ent"
1171 "ries_added_during_migration INT default 0, autofill_profiles_added_"
1172 "during_migration INT default 0);"
1173 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"
1174 ",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"
1175 ",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1176 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"
1177 "e_version bigint default -1,server_version bigint default 0,mtime b"
1178 "igint default 0,server_mtime bigint default 0,ctime bigint default "
1179 "0,server_ctime bigint default 0,server_position_in_parent bigint de"
1180 "fault 0,local_external_id bigint default 0,id varchar(255) default "
1181 "'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"
1182 ") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"
1183 " default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"
1184 "ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"
1185 "efault 0,server_is_del bit default 0,non_unique_name varchar,server"
1186 "_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"
1187 "nt_tag varchar,specifics blob,server_specifics blob);"
1188 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1189 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"
1190 "');"
1191 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1192 ",-2097152,4,'s_ID_2','s_ID"
1193 "_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "
1194 "Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1195 "36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"
1196 "6F6F676C652E636F6D2F32120B4153414447414447414447');"
1197 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1198 ",-3145728,3,'s_ID_4','s_ID"
1199 "_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"
1200 "elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"
1201 "76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"
1202 "68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"
1203 "F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1204 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1205 ",1048576,7,'s_ID_5','s_ID_"
1206 "9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"
1207 "LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"
1208 "47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1209 "36F6D2F12084147464447415347');"
1210 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1211 ",-4194304,6,'s_ID_6','s_ID"
1212 "_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"
1213 ",NULL,X'C2881000',X'C2881000');"
1214 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1215 ",1048576,0,'s_ID_7','r','r"
1216 "','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"
1217 "e',NULL,NULL,NULL);"
1218 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1219 ",1048576,0,'s_ID_8','s_ID_"
1220 "7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"
1221 "ome_bookmarks',NULL,X'C2881000',X'C2881000');"
1222 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1223 ",1048576,1,'s_ID_9','s_ID_"
1224 "8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
1225 ",'bookmark_bar',NULL,X'C2881000',X'C2881000');"
1226 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1227 ",2097152,2,'s_ID_10','s_I"
1228 "D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
1229 "kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1230 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1231 ",-1048576,8,'s_ID_11','s_"
1232 "ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"
1233 "ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"
1234 "03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"
1235 "290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"
1236 "84146414756415346');"
1237 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1238 ",0,9,'s_ID_12','s_ID_6','"
1239 "s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"
1240 "okmarks',NULL,NULL,X'C2881000',X'C2881000');"
1241 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1242 ",-917504,10,'s_ID_13','s_"
1243 "ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"
1244 "rporation for Assigned Names and Numbers','ICANN | Internet Corpora"
1245 "tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"
1246 "703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"
1247 "28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"
1248 "5346');"
1249 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1250 ",1048576,11,'s_ID_14','s_"
1251 "ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"
1252 "oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"
1253 "474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"
1254 "703A2F2F7765626B69742E6F72672F781205504E473259');"
1256 ASSERT_TRUE(connection->CommitTransaction());
1259 void MigrationTest::SetUpVersion75Database(sql::Connection* connection) {
1260 ASSERT_TRUE(connection->is_open());
1261 ASSERT_TRUE(connection->BeginTransaction());
1262 ASSERT_TRUE(connection->Execute(
1263 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1264 "INSERT INTO 'share_version' VALUES('nick@chromium.org',75);"
1265 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1266 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1267 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1268 "tion_state INT default 0,bookmarks_added_during_autofill_migration "
1269 "INT default 0, autofill_migration_time INT default 0, autofill_entr"
1270 "ies_added_during_migration INT default 0, autofill_profiles_added_d"
1271 "uring_migration INT default 0);"
1272 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org"
1273 "','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-655"
1274 "42,'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1275 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
1276 "initial_sync_ended BOOLEAN default 0);"
1277 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1278 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,ba"
1279 "se_version bigint default -1,server_version bigint default 0,mtime"
1280 " bigint default 0,server_mtime bigint default 0,ctime bigint defau"
1281 "lt 0,server_ctime bigint default 0,server_position_in_parent bigin"
1282 "t default 0,local_external_id bigint default 0,id varchar(255) def"
1283 "ault 'r',parent_id varchar(255) default 'r',server_parent_id varch"
1284 "ar(255) default 'r',prev_id varchar(255) default 'r',next_id varch"
1285 "ar(255) default 'r',is_unsynced bit default 0,is_unapplied_update "
1286 "bit default 0,is_del bit default 0,is_dir bit default 0,server_is_"
1287 "dir bit default 0,server_is_del bit default 0,non_unique_name varc"
1288 "har,server_non_unique_name varchar(255),unique_server_tag varchar,"
1289 "unique_client_tag varchar,specifics blob,server_specifics blob);"
1290 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1291 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"
1292 "L,X'',X'');"
1293 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1294 ",-2097152,4,'s_ID_"
1295 "2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite"
1296 "m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772"
1297 "E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874"
1298 "74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474"
1299 "14447');"
1300 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1301 ",-3145728,3,'s_ID_"
1302 "4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to "
1303 "Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747"
1304 "03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65"
1305 "6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7"
1306 "777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
1307 "6C636F6D652E68746D6C1200');"
1308 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1309 ",1048576,7,'s_ID_5"
1310 "','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo"
1311 "gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65"
1312 "2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777"
1313 "7772E676F6F676C652E636F6D2F12084147464447415347');"
1314 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1315 ",-4194304,6,'s_ID_"
1316 "6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In"
1317 "ternet',NULL,NULL,X'C2881000',X'C2881000');"
1318 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1319 ",1048576,0,'s_ID_7"
1320 "','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','"
1321 "google_chrome',NULL,NULL,NULL);"
1322 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1323 ",1048576,0,'s_ID_8"
1324 "','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'"
1325 ",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1326 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1327 ",1048576,1,'s_ID_9"
1328 "','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B"
1329 "ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1330 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1331 ",2097152,2,'s_ID_"
1332 "10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks"
1333 "','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810"
1334 "00');"
1335 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1336 ",-1048576,8,'s_ID"
1337 "_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr"
1338 "omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28"
1339 "810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641"
1340 "4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1341 "D2E6F72672F6F7468657212084146414756415346');"
1342 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1343 ",0,9,'s_ID_12','s"
1344 "_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark"
1345 "s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');"
1346 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1347 ",-917504,10,'s_ID"
1348 "_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |"
1349 " Internet Corporation for Assigned Names and Numbers','ICANN | "
1350 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,"
1351 "X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1352 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361"
1353 "6E6E2E636F6D2F120744414146415346');"
1354 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1355 ",1048576,11,'s_ID"
1356 "_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op"
1357 "en Source Project','The WebKit Open Source Project',NULL,NULL,X"
1358 "'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',"
1359 "X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473"
1360 "259');"
1362 ASSERT_TRUE(connection->CommitTransaction());
1365 void MigrationTest::SetUpVersion76Database(sql::Connection* connection) {
1366 ASSERT_TRUE(connection->is_open());
1367 ASSERT_TRUE(connection->BeginTransaction());
1368 ASSERT_TRUE(connection->Execute(
1369 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1370 "INSERT INTO 'share_version' VALUES('nick@chromium.org',76);"
1371 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1372 "itial_sync_ended BOOLEAN default 0);"
1373 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1374 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1375 "_version bigint default -1,server_version bigint default 0,mtime big"
1376 "int default 0,server_mtime bigint default 0,ctime bigint default 0,s"
1377 "erver_ctime bigint default 0,server_position_in_parent bigint defaul"
1378 "t 0,local_external_id bigint default 0,id varchar(255) default 'r',p"
1379 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1380 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1381 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1382 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1383 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1384 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1385 "har,specifics blob,server_specifics blob);"
1386 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1387 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')"
1389 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1390 ",-2097152,4,'s_ID_2','s_ID_9"
1391 "','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite"
1392 "m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6"
1393 "D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6"
1394 "76C652E636F6D2F32120B4153414447414447414447');"
1395 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1396 ",-3145728,3,'s_ID_4','s_ID_9"
1397 "','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc"
1398 "ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6"
1399 "F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746"
1400 "D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6"
1401 "368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1402 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1403 ",1048576,7,'s_ID_5','s_ID_9'"
1404 ",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL,"
1405 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741"
1406 "5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D"
1407 "2F12084147464447415347');"
1408 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1409 ",-4194304,6,'s_ID_6','s_ID_9"
1410 "','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU"
1411 "LL,X'C2881000',X'C2881000');"
1412 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1413 ",1048576,0,'s_ID_7','r','r',"
1414 "'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome',"
1415 "NULL,NULL,NULL);"
1416 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1417 ",1048576,0,'s_ID_8','s_ID_7'"
1418 ",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome"
1419 "_bookmarks',NULL,X'C2881000',X'C2881000');"
1420 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1421 ",1048576,1,'s_ID_9','s_ID_8'"
1422 ",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b"
1423 "ookmark_bar',NULL,X'C2881000',X'C2881000');"
1424 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1425 ",2097152,2,'s_ID_10','s_ID_"
1426 "8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma"
1427 "rks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1428 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1429 ",-1048576,8,'s_ID_11','s_ID"
1430 "_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)"
1431 "','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2"
1432 "F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1"
1433 "D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464"
1434 "14756415346');"
1435 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1436 ",0,9,'s_ID_12','s_ID_6','s_"
1437 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1438 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1439 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1440 ",-917504,10,'s_ID_13','s_ID"
1441 "_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo"
1442 "ration for Assigned Names and Numbers','ICANN | Internet Corporation"
1443 " for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2"
1444 "F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102"
1445 "00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');"
1446 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1447 ",1048576,11,'s_ID_14','s_ID"
1448 "_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje"
1449 "ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747"
1450 "03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2"
1451 "F2F7765626B69742E6F72672F781205504E473259');"
1452 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1453 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1454 "ult -2, cache_guid TEXT , notification_state BLOB);"
1455 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1456 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1457 "9010788312004066376x-6609234393368420856x',NULL);"
1459 ASSERT_TRUE(connection->CommitTransaction());
1462 void MigrationTest::SetUpVersion77Database(sql::Connection* connection) {
1463 ASSERT_TRUE(connection->is_open());
1464 ASSERT_TRUE(connection->BeginTransaction());
1465 ASSERT_TRUE(connection->Execute(
1466 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1467 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);"
1468 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1469 "itial_sync_ended BOOLEAN default 0);"
1470 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1471 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1472 "_version bigint default -1,server_version bigint default 0,server_po"
1473 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1474 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1475 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1476 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1477 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1478 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1479 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1480 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1481 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1482 "har,specifics blob,server_specifics blob);"
1483 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1)
1484 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
1485 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1486 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1487 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1488 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1489 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1490 "14447414447414447');"
1491 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1492 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1493 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1494 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1495 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1496 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1497 "E2F77656C636F6D652E68746D6C1200');"
1498 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5)
1499 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','"
1500 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E"
1501 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67"
1502 "6F6F676C652E636F6D2F12084147464447415347');"
1503 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1504 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1505 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1506 ");"
1507 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7)
1508 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo"
1509 "gle Chrome','google_chrome',NULL,NULL,NULL);"
1510 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8)
1511 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar"
1512 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1513 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9)
1514 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'"
1515 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1516 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1517 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1518 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1519 "LL,X'C2881000',X'C2881000');"
1520 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1521 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1522 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1523 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1524 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1525 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');"
1526 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12)
1527 ",'s_ID_12','s_ID_6','s_"
1528 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1529 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1530 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1531 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1532 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1533 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1534 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1535 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1536 "E6963616E6E2E636F6D2F120744414146415346');"
1537 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1538 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1539 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1540 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1541 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1542 "81205504E473259');"
1543 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1544 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1545 "ult -2, cache_guid TEXT , notification_state BLOB);"
1546 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1547 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1548 "9010788312004066376x-6609234393368420856x',NULL);"
1550 ASSERT_TRUE(connection->CommitTransaction());
1553 void MigrationTest::SetUpVersion78Database(sql::Connection* connection) {
1554 ASSERT_TRUE(connection->is_open());
1555 ASSERT_TRUE(connection->BeginTransaction());
1556 ASSERT_TRUE(connection->Execute(
1557 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1558 "INSERT INTO 'share_version' VALUES('nick@chromium.org',78);"
1559 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1560 "itial_sync_ended BOOLEAN default 0);"
1561 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1562 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1563 "_version bigint default -1,server_version bigint default 0,server_po"
1564 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1565 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1566 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1567 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1568 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1569 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1570 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1571 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1572 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1573 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1574 ");"
1575 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1576 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1577 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1578 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1579 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1580 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1581 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1582 "14447414447414447',NULL);"
1583 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1584 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1585 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1586 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1587 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1588 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1589 "E2F77656C636F6D652E68746D6C1200',NULL);"
1590 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1591 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1592 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1593 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1594 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1595 "ULL);"
1596 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1597 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1598 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1599 ",NULL);"
1600 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1601 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1602 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1603 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1604 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1605 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1606 "00',X'C2881000',NULL);"
1607 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1608 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1609 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1610 "000',X'C2881000',NULL);"
1611 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1612 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1613 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1614 "LL,X'C2881000',X'C2881000',NULL);"
1615 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1616 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1617 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1618 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1619 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1620 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1621 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1622 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1623 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1624 "2881000',X'C2881000',NULL);"
1625 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1626 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1627 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1628 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1629 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1630 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1631 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1632 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1633 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1634 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1635 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1636 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1637 "81205504E473259',NULL);"
1638 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1639 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1640 "ult -2, cache_guid TEXT , notification_state BLOB);"
1641 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1642 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1643 "9010788312004066376x-6609234393368420856x',NULL);"
1645 ASSERT_TRUE(connection->CommitTransaction());
1648 void MigrationTest::SetUpVersion79Database(sql::Connection* connection) {
1649 ASSERT_TRUE(connection->is_open());
1650 ASSERT_TRUE(connection->BeginTransaction());
1651 ASSERT_TRUE(connection->Execute(
1652 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1653 "INSERT INTO 'share_version' VALUES('nick@chromium.org',79);"
1654 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1655 "itial_sync_ended BOOLEAN default 0);"
1656 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1657 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1658 "_version bigint default -1,server_version bigint default 0,server_po"
1659 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1660 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1661 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1662 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1663 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1664 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1665 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1666 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1667 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1668 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1669 ");"
1670 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1671 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1672 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1673 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1674 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1675 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1676 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1677 "14447414447414447',NULL);"
1678 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1679 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1680 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1681 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1682 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1683 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1684 "E2F77656C636F6D652E68746D6C1200',NULL);"
1685 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1686 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1687 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1688 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1689 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1690 "ULL);"
1691 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1692 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1693 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1694 ",NULL);"
1695 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1696 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1697 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1698 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1699 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1700 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1701 "00',X'C2881000',NULL);"
1702 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1703 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1704 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1705 "000',X'C2881000',NULL);"
1706 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1707 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1708 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1709 "LL,X'C2881000',X'C2881000',NULL);"
1710 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1711 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1712 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1713 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1714 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1715 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1716 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1717 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1718 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1719 "2881000',X'C2881000',NULL);"
1720 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1721 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1722 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1723 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1724 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1725 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1726 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1727 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1728 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1729 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1730 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1731 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1732 "81205504E473259',NULL);"
1733 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1734 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1735 "ult -2, cache_guid TEXT , notification_state BLOB);"
1736 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1737 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1738 "-131078,'9010788312004066376x-6609234393368420856x',NULL);"
1740 ASSERT_TRUE(connection->CommitTransaction());
1743 void MigrationTest::SetUpVersion80Database(sql::Connection* connection) {
1744 ASSERT_TRUE(connection->is_open());
1745 ASSERT_TRUE(connection->BeginTransaction());
1746 ASSERT_TRUE(connection->Execute(
1747 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1748 "INSERT INTO 'share_version' VALUES('nick@chromium.org',80);"
1749 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1750 "itial_sync_ended BOOLEAN default 0);"
1751 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1752 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1753 "_version bigint default -1,server_version bigint default 0,server_po"
1754 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1755 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1756 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1757 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1758 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1759 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1760 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1761 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1762 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1763 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1764 ");"
1765 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1766 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1767 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1768 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1769 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1770 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1771 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1772 "14447414447414447',NULL);"
1773 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1774 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1775 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1776 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1777 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1778 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1779 "E2F77656C636F6D652E68746D6C1200',NULL);"
1780 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1781 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1782 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1783 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1784 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1785 "ULL);"
1786 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1787 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1788 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1789 ",NULL);"
1790 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1791 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1792 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1793 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1794 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1795 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1796 "00',X'C2881000',NULL);"
1797 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1798 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1799 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1800 "000',X'C2881000',NULL);"
1801 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1802 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1803 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1804 "LL,X'C2881000',X'C2881000',NULL);"
1805 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1806 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1807 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1808 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1809 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1810 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1811 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1812 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1813 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1814 "2881000',X'C2881000',NULL);"
1815 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1816 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1817 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1818 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1819 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1820 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1821 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1822 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1823 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1824 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1825 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1826 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1827 "81205504E473259',NULL);"
1828 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1829 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1830 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1831 "blob);"
1832 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1833 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1834 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"
1836 ASSERT_TRUE(connection->CommitTransaction());
1840 // Helper definitions to create the version 81 DB tables.
1841 namespace {
1843 const int V80_ROW_COUNT = 13;
1844 const int64 V80_POSITIONS[V80_ROW_COUNT] = {
1846 -2097152,
1847 -3145728,
1848 1048576,
1849 -4194304,
1850 1048576,
1851 1048576,
1852 1048576,
1853 2097152,
1854 -1048576,
1856 -917504,
1857 1048576
1860 std::string V81_Ordinal(int n) {
1861 return Int64ToNodeOrdinal(V80_POSITIONS[n]).ToInternalValue();
1864 } //namespace
1866 // Unlike the earlier versions, the rows for version 81 are generated
1867 // programmatically to accurately handle unprintable characters for the
1868 // server_ordinal_in_parent field.
1869 void MigrationTest::SetUpVersion81Database(sql::Connection* connection) {
1870 ASSERT_TRUE(connection->is_open());
1871 ASSERT_TRUE(connection->BeginTransaction());
1872 ASSERT_TRUE(connection->Execute(
1873 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1874 "INSERT INTO 'share_version' VALUES('nick@chromium.org',81);"
1875 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1876 "itial_sync_ended BOOLEAN default 0);"
1877 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1878 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1879 "_version bigint default -1,server_version bigint default 0, "
1880 "local_external_id bigint default 0"
1881 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1882 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1883 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1884 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1885 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1886 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1887 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1888 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1889 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1890 ", server_ordinal_in_parent blob);"
1891 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1892 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1893 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1894 "blob);"
1895 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1896 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1897 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
1899 const char* insert_stmts[V80_ROW_COUNT] = {
1900 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1901 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
1902 "INSERT INTO 'metas' VALUES(2,669,669,4,"
1903 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1904 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1905 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1906 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1907 "14447414447414447',NULL,?);",
1908 "INSERT INTO 'metas' VALUES(4,681,681,3,"
1909 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1910 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1911 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1912 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1913 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1914 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
1915 "INSERT INTO 'metas' VALUES(5,677,677,7,"
1916 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1917 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1918 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1919 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1920 "ULL,?);",
1921 "INSERT INTO 'metas' VALUES(6,694,694,6,"
1922 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1923 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1924 ",NULL,?);",
1925 "INSERT INTO 'metas' VALUES(7,663,663,0,"
1926 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1927 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
1928 "INSERT INTO 'metas' VALUES(8,664,664,0,"
1929 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1930 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1931 "00',X'C2881000',NULL,?);",
1932 "INSERT INTO 'metas' VALUES(9,665,665,1,"
1933 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1934 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1935 "000',X'C2881000',NULL,?);",
1936 "INSERT INTO 'metas' VALUES(10,666,666,2,"
1937 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1938 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1939 "LL,X'C2881000',X'C2881000',NULL,?);",
1940 "INSERT INTO 'metas' VALUES(11,683,683,8,"
1941 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1942 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1943 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1944 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1945 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
1946 "INSERT INTO 'metas' VALUES(12,685,685,9,"
1947 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1948 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1949 "2881000',X'C2881000',NULL,?);",
1950 "INSERT INTO 'metas' VALUES(13,687,687,10,"
1951 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1952 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1953 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1954 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1955 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1956 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
1957 "INSERT INTO 'metas' VALUES(14,692,692,11,"
1958 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1959 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1960 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1961 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1962 "81205504E473259',NULL,?);" };
1964 for (int i = 0; i < V80_ROW_COUNT; i++) {
1965 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
1966 std::string ord = V81_Ordinal(i);
1967 s.BindBlob(0, ord.data(), ord.length());
1968 ASSERT_TRUE(s.Run());
1969 s.Reset(true);
1971 ASSERT_TRUE(connection->CommitTransaction());
1974 void MigrationTest::SetUpVersion82Database(sql::Connection* connection) {
1975 ASSERT_TRUE(connection->is_open());
1976 ASSERT_TRUE(connection->BeginTransaction());
1977 ASSERT_TRUE(connection->Execute(
1978 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1979 "INSERT INTO 'share_version' VALUES('nick@chromium.org',82);"
1980 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1981 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
1982 "default 0);"
1983 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
1984 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1985 "_version bigint default -1,server_version bigint default 0, "
1986 "local_external_id bigint default 0"
1987 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1988 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1989 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1990 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1991 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1992 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1993 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1994 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1995 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1996 ", server_ordinal_in_parent blob);"
1997 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1998 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1999 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2000 "blob);"
2001 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2002 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2003 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2005 const char* insert_stmts[V80_ROW_COUNT] = {
2006 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2007 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
2008 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2009 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2010 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2011 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2012 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2013 "14447414447414447',NULL,?);",
2014 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2015 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2016 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2017 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2018 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2019 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2020 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
2021 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2022 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2023 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2024 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2025 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2026 "ULL,?);",
2027 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2028 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2029 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2030 ",NULL,?);",
2031 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2032 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2033 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
2034 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2035 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2036 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2037 "00',X'C2881000',NULL,?);",
2038 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2039 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2040 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2041 "000',X'C2881000',NULL,?);",
2042 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2043 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2044 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2045 "LL,X'C2881000',X'C2881000',NULL,?);",
2046 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2047 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2048 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2049 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2050 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2051 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
2052 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2053 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2054 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2055 "2881000',X'C2881000',NULL,?);",
2056 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2057 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2058 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2059 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2060 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2061 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2062 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
2063 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2064 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2065 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2066 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2067 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2068 "81205504E473259',NULL,?);" };
2070 for (int i = 0; i < V80_ROW_COUNT; i++) {
2071 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2072 std::string ord = V81_Ordinal(i);
2073 s.BindBlob(0, ord.data(), ord.length());
2074 ASSERT_TRUE(s.Run());
2075 s.Reset(true);
2077 ASSERT_TRUE(connection->CommitTransaction());
2080 void MigrationTest::SetUpVersion83Database(sql::Connection* connection) {
2081 ASSERT_TRUE(connection->is_open());
2082 ASSERT_TRUE(connection->BeginTransaction());
2083 ASSERT_TRUE(connection->Execute(
2084 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2085 "INSERT INTO 'share_version' VALUES('nick@chromium.org',83);"
2086 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2087 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2088 "default 0);"
2089 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2090 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2091 "_version bigint default -1,server_version bigint default 0, "
2092 "local_external_id bigint default 0"
2093 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2094 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2095 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2096 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2097 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2098 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2099 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2100 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2101 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2102 ", server_ordinal_in_parent blob, transaction_version bigint default "
2103 "0);"
2104 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2105 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2106 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2107 "blob);"
2108 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2109 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2110 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2112 const char* insert_stmts[V80_ROW_COUNT] = {
2113 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2114 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2115 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2116 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2117 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2118 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2119 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2120 "14447414447414447',NULL,?,0);",
2121 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2122 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2123 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2124 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2125 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2126 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2127 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2128 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2129 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2130 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2131 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2132 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2133 "ULL,?,0);",
2134 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2135 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2136 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2137 ",NULL,?,0);",
2138 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2139 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2140 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2142 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2143 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2144 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2145 "00',X'C2881000',NULL,?,0);",
2146 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2147 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2148 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2149 "000',X'C2881000',NULL,?,0);",
2150 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2151 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2152 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2153 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2154 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2155 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2156 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2157 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2158 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2159 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2160 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2161 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2162 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2163 "2881000',X'C2881000',NULL,?,0);",
2164 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2165 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2166 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2167 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2168 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2169 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2170 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2171 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2172 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2173 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2174 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2175 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2176 "81205504E473259',NULL,?,0);" };
2178 for (int i = 0; i < V80_ROW_COUNT; i++) {
2179 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2180 std::string ord = V81_Ordinal(i);
2181 s.BindBlob(0, ord.data(), ord.length());
2182 ASSERT_TRUE(s.Run());
2183 s.Reset(true);
2185 ASSERT_TRUE(connection->CommitTransaction());
2188 void MigrationTest::SetUpVersion84Database(sql::Connection* connection) {
2189 ASSERT_TRUE(connection->is_open());
2190 ASSERT_TRUE(connection->BeginTransaction());
2191 ASSERT_TRUE(connection->Execute(
2192 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2193 "INSERT INTO 'share_version' VALUES('nick@chromium.org',84);"
2194 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2195 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2196 "default 0);"
2197 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2198 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2199 "_version bigint default -1,server_version bigint default 0, "
2200 "local_external_id bigint default 0"
2201 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2202 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2203 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2204 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2205 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2206 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2207 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2208 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2209 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2210 ", server_ordinal_in_parent blob, transaction_version bigint default "
2211 "0);"
2212 "CREATE TABLE 'deleted_metas'"
2213 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2214 "_version bigint default -1,server_version bigint default 0, "
2215 "local_external_id bigint default 0"
2216 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2217 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2218 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2219 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2220 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2221 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2222 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2223 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2224 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2225 ", server_ordinal_in_parent blob, transaction_version bigint default "
2226 "0);"
2227 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2228 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2229 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2230 "blob);"
2231 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2232 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2233 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2235 const char* insert_stmts[V80_ROW_COUNT] = {
2236 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2237 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2238 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2239 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2240 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2241 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2242 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2243 "14447414447414447',NULL,?,0);",
2244 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2245 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2246 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2247 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2248 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2249 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2250 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2251 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2252 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2253 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2254 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2255 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2256 "ULL,?,0);",
2257 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2258 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2259 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2260 ",NULL,?,0);",
2261 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2262 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2263 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2265 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2266 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2267 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2268 "00',X'C2881000',NULL,?,0);",
2269 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2270 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2271 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2272 "000',X'C2881000',NULL,?,0);",
2273 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2274 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2275 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2276 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2277 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2278 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2279 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2280 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2281 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2282 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2283 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2284 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2285 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2286 "2881000',X'C2881000',NULL,?,0);",
2287 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2288 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2289 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2290 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2291 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2292 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2293 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2294 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2295 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2296 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2297 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2298 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2299 "81205504E473259',NULL,?,0);" };
2301 for (int i = 0; i < V80_ROW_COUNT; i++) {
2302 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2303 std::string ord = V81_Ordinal(i);
2304 s.BindBlob(0, ord.data(), ord.length());
2305 ASSERT_TRUE(s.Run());
2306 s.Reset(true);
2308 ASSERT_TRUE(connection->CommitTransaction());
2311 void MigrationTest::SetUpVersion85Database(sql::Connection* connection) {
2312 ASSERT_TRUE(connection->is_open());
2313 ASSERT_TRUE(connection->BeginTransaction());
2314 ASSERT_TRUE(connection->Execute(
2315 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2316 "INSERT INTO 'share_version' VALUES('nick@chromium.org',85);"
2317 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
2318 "transaction_version BIGINT default 0);"
2319 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605', 1);"
2320 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2321 "_version bigint default -1,server_version bigint default 0, "
2322 "local_external_id bigint default 0"
2323 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2324 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2325 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2326 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2327 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2328 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2329 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2330 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2331 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2332 ", server_ordinal_in_parent blob, transaction_version bigint default "
2333 "0);"
2334 "CREATE TABLE 'deleted_metas'"
2335 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2336 "_version bigint default -1,server_version bigint default 0, "
2337 "local_external_id bigint default 0"
2338 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2339 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2340 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2341 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2342 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2343 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2344 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2345 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2346 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2347 ", server_ordinal_in_parent blob, transaction_version bigint default "
2348 "0);"
2349 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2350 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2351 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2352 "blob);"
2353 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2354 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2355 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2357 const char* insert_stmts[V80_ROW_COUNT] = {
2358 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2359 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2360 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2361 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2362 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2363 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2364 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2365 "14447414447414447',NULL,?,0);",
2366 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2367 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2368 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2369 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2370 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2371 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2372 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2373 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2374 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2375 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2376 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2377 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2378 "ULL,?,0);",
2379 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2380 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2381 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2382 ",NULL,?,0);",
2383 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2384 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2385 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2387 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2388 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2389 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2390 "00',X'C2881000',NULL,?,0);",
2391 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2392 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2393 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2394 "000',X'C2881000',NULL,?,0);",
2395 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2396 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2397 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2398 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2399 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2400 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2401 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2402 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2403 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2404 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2405 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2406 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2407 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2408 "2881000',X'C2881000',NULL,?,0);",
2409 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2410 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2411 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2412 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2413 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2414 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2415 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2416 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2417 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2418 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2419 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2420 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2421 "81205504E473259',NULL,?,0);" };
2423 for (int i = 0; i < V80_ROW_COUNT; i++) {
2424 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2425 std::string ord = V81_Ordinal(i);
2426 s.BindBlob(0, ord.data(), ord.length());
2427 ASSERT_TRUE(s.Run());
2428 s.Reset(true);
2430 ASSERT_TRUE(connection->CommitTransaction());
2433 void MigrationTest::SetUpVersion86Database(sql::Connection* connection) {
2434 ASSERT_TRUE(connection->is_open());
2435 ASSERT_TRUE(connection->BeginTransaction());
2436 ASSERT_TRUE(connection->Execute(
2437 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2438 "INSERT INTO 'share_version' VALUES('nick@chromium.org',86);"
2439 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2440 " transaction_version BIGINT default 0);"
2441 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2442 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,b"
2443 "ase_version bigint default -1,server_version bigint default 0,local_e"
2444 "xternal_id bigint default 0,transaction_version bigint default 0,mtim"
2445 "e bigint default 0,server_mtime bigint default 0,ctime bigint default"
2446 " 0,server_ctime bigint default 0,id varchar(255) default 'r',parent_i"
2447 "d varchar(255) default 'r',server_parent_id varchar(255) default 'r',"
2448 "is_unsynced bit default 0,is_unapplied_update bit default 0,is_del bi"
2449 "t default 0,is_dir bit default 0,server_is_dir bit default 0,server_i"
2450 "s_del bit default 0,non_unique_name varchar,server_non_unique_name va"
2451 "rchar(255),unique_server_tag varchar,unique_client_tag varchar,unique"
2452 "_bookmark_tag varchar,specifics blob,server_specifics blob,base_serve"
2453 "r_specifics blob,server_unique_position blob,unique_position blob);"
2454 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2455 META_PROTO_TIMES_VALS(1)
2456 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,"
2457 "X'',X'',X'',NULL,X'2200',X'2200');"
2458 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2459 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The"
2460 " Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D653"
2461 "273625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFF"
2462 "FFFC000006754307476346749735A5734654D653273625336557753582F77673D',X'"
2463 "22247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582"
2464 "F77673D');"
2465 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2466 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome"
2467 "','Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2"
2468 "200');"
2469 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2470 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Boo"
2471 "kmarks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'"
2472 "C2881000',NULL,X'2200',X'2200');"
2473 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2474 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Boo"
2475 "kmark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C2881"
2476 "000',NULL,X'2200',X'2200');"
2477 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2478 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'O"
2479 "ther Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C28810"
2480 "00',X'C2881000',NULL,X'2200',X'2200');"
2481 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2482 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'H"
2483 "ome (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL"
2484 ",X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C28810"
2485 "220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641474154574"
2486 "1',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74"
2487 "68657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D"
2488 "623579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF00000505"
2489 "14C784A456D623579366267644237646A7A2B62314130346E493D');"
2490 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2491 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'E"
2492 "xtra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6"
2493 "F616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'222"
2494 "480000000000000007867626A704A646134635A6F616C376A49513338734B46324837"
2495 "773D',X'222480000000000000007867626A704A646134635A6F616C376A495133387"
2496 "34B46324837773D');"
2497 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2498 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2499 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2500 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2501 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2502 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2503 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2504 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2505 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2506 "4179672B304A614A514B3452384A413D');"
2507 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2508 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2509 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2510 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2511 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2512 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2513 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2514 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2515 "9552F6E644C553D');"
2516 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2517 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2518 "al_external_id bigint default 0,transaction_version bigint default 0,"
2519 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2520 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2521 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2522 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2523 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2524 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2525 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2526 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2527 "erver_specifics blob,server_unique_position blob,unique_position blob"
2528 ");"
2529 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birt"
2530 "hday TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
2531 "fault -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB"
2532 ");"
2533 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.or"
2534 "g','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-13107"
2535 "8,'9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2536 ASSERT_TRUE(connection->CommitTransaction());
2539 void MigrationTest::SetUpVersion87Database(sql::Connection* connection) {
2540 ASSERT_TRUE(connection->is_open());
2541 ASSERT_TRUE(connection->BeginTransaction());
2542 ASSERT_TRUE(connection->Execute(
2543 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2544 "INSERT INTO 'share_version' VALUES('nick@chromium.org',87);"
2545 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr"
2546 "ansaction_version BIGINT default 0);"
2547 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2548 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2549 "_version bigint default -1,server_version bigint default 0,local_exte"
2550 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2551 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2552 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2553 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2554 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2555 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2556 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2557 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2558 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2559 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2560 "ment_metadata blob);"
2561 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2562 META_PROTO_TIMES_VALS(1)
2563 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2564 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2565 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2566 META_PROTO_TIMES_VALS(6)
2567 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2568 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2569 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2570 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2571 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2572 "77673D',NULL);"
2573 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2574 META_PROTO_TIMES_VALS(7)
2575 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2576 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2577 "00',NULL);"
2578 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2579 META_PROTO_TIMES_VALS(8)
2580 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2581 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2582 "2881000',NULL,X'2200',X'2200',NULL);"
2583 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2584 META_PROTO_TIMES_VALS(9)
2585 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2586 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2587 "00',NULL,X'2200',X'2200',NULL);"
2588 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2589 META_PROTO_TIMES_VALS(10)
2590 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2591 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2592 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2593 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2594 META_PROTO_TIMES_VALS(11)
2595 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2596 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2597 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2598 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2599 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2600 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2601 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2602 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2603 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2604 META_PROTO_TIMES_VALS(12)
2605 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2606 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2607 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2608 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2609 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2610 "4B46324837773D',NULL);"
2611 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2612 META_PROTO_TIMES_VALS(13)
2613 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2614 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2615 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2616 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2617 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2618 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2619 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2620 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2621 "4179672B304A614A514B3452384A413D',NULL);"
2622 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2623 META_PROTO_TIMES_VALS(14)
2624 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2625 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2626 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2627 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2628 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2629 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2630 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2631 "9552F6E644C553D',NULL);"
2632 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2633 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2634 "al_external_id bigint default 0,transaction_version bigint default 0,"
2635 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2636 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2637 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2638 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2639 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2640 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2641 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2642 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2643 "erver_specifics blob,server_unique_position blob,unique_position blob"
2644 ",attachment_metadata blob);"
2645 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2646 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2647 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2648 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2649 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2650 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2651 ASSERT_TRUE(connection->CommitTransaction());
2654 void MigrationTest::SetUpVersion88Database(sql::Connection* connection) {
2655 ASSERT_TRUE(connection->is_open());
2656 ASSERT_TRUE(connection->BeginTransaction());
2657 ASSERT_TRUE(connection->Execute(
2658 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2659 "INSERT INTO 'share_version' VALUES('nick@chromium.org',88);"
2660 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2661 " transaction_version BIGINT default 0, context BLOB);"
2662 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
2663 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2664 "_version bigint default -1,server_version bigint default 0,local_exte"
2665 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2666 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2667 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2668 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2669 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2670 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2671 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2672 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2673 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2674 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2675 "ment_metadata blob);"
2676 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2677 META_PROTO_TIMES_VALS(1)
2678 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2679 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2680 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2681 META_PROTO_TIMES_VALS(6)
2682 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2683 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2684 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2685 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2686 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2687 "77673D',NULL);"
2688 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2689 META_PROTO_TIMES_VALS(7)
2690 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2691 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2692 "00',NULL);"
2693 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2694 META_PROTO_TIMES_VALS(8)
2695 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2696 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2697 "2881000',NULL,X'2200',X'2200',NULL);"
2698 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2699 META_PROTO_TIMES_VALS(9)
2700 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2701 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2702 "00',NULL,X'2200',X'2200',NULL);"
2703 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2704 META_PROTO_TIMES_VALS(10)
2705 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2706 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2707 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2708 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2709 META_PROTO_TIMES_VALS(11)
2710 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2711 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2712 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2713 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2714 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2715 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2716 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2717 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2718 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2719 META_PROTO_TIMES_VALS(12)
2720 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2721 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2722 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2723 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2724 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2725 "4B46324837773D',NULL);"
2726 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2727 META_PROTO_TIMES_VALS(13)
2728 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2729 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2730 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2731 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2732 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2733 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2734 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2735 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2736 "4179672B304A614A514B3452384A413D',NULL);"
2737 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2738 META_PROTO_TIMES_VALS(14)
2739 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2740 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2741 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2742 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2743 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2744 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2745 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2746 "9552F6E644C553D',NULL);"
2747 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2748 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2749 "al_external_id bigint default 0,transaction_version bigint default 0,"
2750 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2751 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2752 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2753 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2754 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2755 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2756 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2757 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2758 "erver_specifics blob,server_unique_position blob,unique_position blob"
2759 ",attachment_metadata blob);"
2760 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2761 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2762 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2763 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2764 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2765 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2766 ASSERT_TRUE(connection->CommitTransaction());
2769 TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) {
2770 sql::Connection connection;
2771 ASSERT_TRUE(connection.OpenInMemory());
2773 SetUpVersion67Database(&connection);
2775 // Columns existing before version 67.
2776 ASSERT_TRUE(connection.DoesColumnExist("metas", "name"));
2777 ASSERT_TRUE(connection.DoesColumnExist("metas", "unsanitized_name"));
2778 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_name"));
2780 scoped_ptr<TestDirectoryBackingStore> dbs(
2781 new TestDirectoryBackingStore(GetUsername(), &connection));
2783 ASSERT_FALSE(dbs->needs_column_refresh_);
2784 ASSERT_TRUE(dbs->MigrateVersion67To68());
2785 ASSERT_EQ(68, dbs->GetVersion());
2786 ASSERT_TRUE(dbs->needs_column_refresh_);
2789 TEST_F(DirectoryBackingStoreTest, MigrateVersion68To69) {
2790 sql::Connection connection;
2791 ASSERT_TRUE(connection.OpenInMemory());
2792 SetUpVersion68Database(&connection);
2795 scoped_ptr<TestDirectoryBackingStore> dbs(
2796 new TestDirectoryBackingStore(GetUsername(), &connection));
2798 ASSERT_FALSE(dbs->needs_column_refresh_);
2799 ASSERT_TRUE(dbs->MigrateVersion68To69());
2800 ASSERT_EQ(69, dbs->GetVersion());
2801 ASSERT_TRUE(dbs->needs_column_refresh_);
2804 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics"));
2805 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics"));
2806 sql::Statement s(connection.GetUniqueStatement("SELECT non_unique_name,"
2807 "is_del, is_dir, id, specifics, server_specifics FROM metas "
2808 "WHERE metahandle = 2"));
2809 ASSERT_TRUE(s.Step());
2810 ASSERT_EQ("Deleted Item", s.ColumnString(0));
2811 ASSERT_TRUE(s.ColumnBool(1));
2812 ASSERT_FALSE(s.ColumnBool(2));
2813 ASSERT_EQ("s_ID_2", s.ColumnString(3));
2814 sync_pb::EntitySpecifics specifics;
2815 specifics.ParseFromArray(s.ColumnBlob(4), s.ColumnByteLength(4));
2816 ASSERT_TRUE(specifics.has_bookmark());
2817 ASSERT_EQ("http://www.google.com/", specifics.bookmark().url());
2818 ASSERT_EQ("AASGASGA", specifics.bookmark().favicon());
2819 specifics.ParseFromArray(s.ColumnBlob(5), s.ColumnByteLength(5));
2820 ASSERT_TRUE(specifics.has_bookmark());
2821 ASSERT_EQ("http://www.google.com/2", specifics.bookmark().url());
2822 ASSERT_EQ("ASADGADGADG", specifics.bookmark().favicon());
2823 ASSERT_FALSE(s.Step());
2826 TEST_F(DirectoryBackingStoreTest, MigrateVersion69To70) {
2827 sql::Connection connection;
2828 ASSERT_TRUE(connection.OpenInMemory());
2829 SetUpVersion69Database(&connection);
2831 ASSERT_TRUE(connection.DoesColumnExist("metas", "singleton_tag"));
2832 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_server_tag"));
2833 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_client_tag"));
2836 scoped_ptr<TestDirectoryBackingStore> dbs(
2837 new TestDirectoryBackingStore(GetUsername(), &connection));
2839 ASSERT_FALSE(dbs->needs_column_refresh_);
2840 ASSERT_TRUE(dbs->MigrateVersion69To70());
2841 ASSERT_EQ(70, dbs->GetVersion());
2842 ASSERT_TRUE(dbs->needs_column_refresh_);
2845 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag"));
2846 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag"));
2847 sql::Statement s(connection.GetUniqueStatement("SELECT id"
2848 " FROM metas WHERE unique_server_tag = 'google_chrome'"));
2849 ASSERT_TRUE(s.Step());
2850 EXPECT_EQ("s_ID_7", s.ColumnString(0));
2853 TEST_F(DirectoryBackingStoreTest, MigrateVersion70To71) {
2854 sql::Connection connection;
2855 ASSERT_TRUE(connection.OpenInMemory());
2856 SetUpVersion70Database(&connection);
2858 ASSERT_TRUE(connection.DoesColumnExist("share_info", "last_sync_timestamp"));
2859 ASSERT_TRUE(connection.DoesColumnExist("share_info", "initial_sync_ended"));
2860 ASSERT_FALSE(connection.DoesTableExist("models"));
2863 scoped_ptr<TestDirectoryBackingStore> dbs(
2864 new TestDirectoryBackingStore(GetUsername(), &connection));
2866 ASSERT_FALSE(dbs->needs_column_refresh_);
2867 ASSERT_TRUE(dbs->MigrateVersion70To71());
2868 ASSERT_EQ(71, dbs->GetVersion());
2869 ASSERT_FALSE(dbs->needs_column_refresh_);
2872 ASSERT_FALSE(connection.DoesColumnExist("share_info", "last_sync_timestamp"));
2873 ASSERT_FALSE(connection.DoesColumnExist("share_info", "initial_sync_ended"));
2874 ASSERT_TRUE(connection.DoesTableExist("models"));
2875 ASSERT_TRUE(connection.DoesColumnExist("models", "initial_sync_ended"));
2876 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp"));
2877 ASSERT_TRUE(connection.DoesColumnExist("models", "model_id"));
2879 sql::Statement s(connection.GetUniqueStatement("SELECT model_id, "
2880 "initial_sync_ended, last_download_timestamp FROM models"));
2881 ASSERT_TRUE(s.Step());
2882 std::string model_id = s.ColumnString(0);
2883 EXPECT_EQ("C2881000", base::HexEncode(model_id.data(), model_id.size()))
2884 << "Model ID is expected to be the empty BookmarkSpecifics proto.";
2885 EXPECT_TRUE(s.ColumnBool(1));
2886 EXPECT_EQ(694, s.ColumnInt64(2));
2887 ASSERT_FALSE(s.Step());
2891 TEST_F(DirectoryBackingStoreTest, MigrateVersion71To72) {
2892 sql::Connection connection;
2893 ASSERT_TRUE(connection.OpenInMemory());
2894 SetUpVersion71Database(&connection);
2896 ASSERT_TRUE(connection.DoesTableExist("extended_attributes"));
2899 scoped_ptr<TestDirectoryBackingStore> dbs(
2900 new TestDirectoryBackingStore(GetUsername(), &connection));
2902 ASSERT_FALSE(dbs->needs_column_refresh_);
2903 ASSERT_TRUE(dbs->MigrateVersion71To72());
2904 ASSERT_EQ(72, dbs->GetVersion());
2905 ASSERT_FALSE(dbs->needs_column_refresh_);
2908 ASSERT_FALSE(connection.DoesTableExist("extended_attributes"));
2911 TEST_F(DirectoryBackingStoreTest, MigrateVersion72To73) {
2912 sql::Connection connection;
2913 ASSERT_TRUE(connection.OpenInMemory());
2914 SetUpVersion72Database(&connection);
2916 ASSERT_FALSE(connection.DoesColumnExist("share_info", "notification_state"));
2919 scoped_ptr<TestDirectoryBackingStore> dbs(
2920 new TestDirectoryBackingStore(GetUsername(), &connection));
2922 ASSERT_FALSE(dbs->needs_column_refresh_);
2923 ASSERT_TRUE(dbs->MigrateVersion72To73());
2924 ASSERT_EQ(73, dbs->GetVersion());
2925 ASSERT_FALSE(dbs->needs_column_refresh_);
2928 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state"));
2931 TEST_F(DirectoryBackingStoreTest, MigrateVersion73To74) {
2932 sql::Connection connection;
2933 ASSERT_TRUE(connection.OpenInMemory());
2934 SetUpVersion73Database(&connection);
2936 ASSERT_FALSE(
2937 connection.DoesColumnExist("share_info", "autofill_migration_state"));
2938 ASSERT_FALSE(
2939 connection.DoesColumnExist("share_info",
2940 "bookmarks_added_during_autofill_migration"));
2941 ASSERT_FALSE(
2942 connection.DoesColumnExist("share_info", "autofill_migration_time"));
2943 ASSERT_FALSE(
2944 connection.DoesColumnExist("share_info",
2945 "autofill_entries_added_during_migration"));
2947 ASSERT_FALSE(
2948 connection.DoesColumnExist("share_info",
2949 "autofill_profiles_added_during_migration"));
2952 scoped_ptr<TestDirectoryBackingStore> dbs(
2953 new TestDirectoryBackingStore(GetUsername(), &connection));
2955 ASSERT_FALSE(dbs->needs_column_refresh_);
2956 ASSERT_TRUE(dbs->MigrateVersion73To74());
2957 ASSERT_EQ(74, dbs->GetVersion());
2958 ASSERT_FALSE(dbs->needs_column_refresh_);
2961 ASSERT_TRUE(
2962 connection.DoesColumnExist("share_info", "autofill_migration_state"));
2963 ASSERT_TRUE(
2964 connection.DoesColumnExist("share_info",
2965 "bookmarks_added_during_autofill_migration"));
2966 ASSERT_TRUE(
2967 connection.DoesColumnExist("share_info", "autofill_migration_time"));
2968 ASSERT_TRUE(
2969 connection.DoesColumnExist("share_info",
2970 "autofill_entries_added_during_migration"));
2972 ASSERT_TRUE(
2973 connection.DoesColumnExist("share_info",
2974 "autofill_profiles_added_during_migration"));
2977 TEST_F(DirectoryBackingStoreTest, MigrateVersion74To75) {
2978 sql::Connection connection;
2979 ASSERT_TRUE(connection.OpenInMemory());
2980 SetUpVersion74Database(&connection);
2982 ASSERT_FALSE(connection.DoesColumnExist("models", "progress_marker"));
2983 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp"));
2986 scoped_ptr<TestDirectoryBackingStore> dbs(
2987 new TestDirectoryBackingStore(GetUsername(), &connection));
2989 ASSERT_FALSE(dbs->needs_column_refresh_);
2990 ASSERT_TRUE(dbs->MigrateVersion74To75());
2991 ASSERT_EQ(75, dbs->GetVersion());
2992 ASSERT_FALSE(dbs->needs_column_refresh_);
2995 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker"));
2996 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp"));
2999 TEST_F(DirectoryBackingStoreTest, MigrateVersion75To76) {
3000 sql::Connection connection;
3001 ASSERT_TRUE(connection.OpenInMemory());
3002 SetUpVersion75Database(&connection);
3004 ASSERT_TRUE(
3005 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3006 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3007 "bookmarks_added_during_autofill_migration"));
3008 ASSERT_TRUE(
3009 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3010 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3011 "autofill_entries_added_during_migration"));
3012 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3013 "autofill_profiles_added_during_migration"));
3015 scoped_ptr<TestDirectoryBackingStore> dbs(
3016 new TestDirectoryBackingStore(GetUsername(), &connection));
3017 ASSERT_FALSE(dbs->needs_column_refresh_);
3018 ASSERT_TRUE(dbs->MigrateVersion75To76());
3019 ASSERT_EQ(76, dbs->GetVersion());
3020 ASSERT_TRUE(dbs->needs_column_refresh_);
3021 // Cannot actual refresh columns due to version 76 not containing all
3022 // necessary columns.
3025 TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) {
3026 sql::Connection connection;
3027 ASSERT_TRUE(connection.OpenInMemory());
3028 SetUpVersion76Database(&connection);
3030 scoped_ptr<TestDirectoryBackingStore> dbs(
3031 new TestDirectoryBackingStore(GetUsername(), &connection));
3032 ASSERT_FALSE(dbs->needs_column_refresh_);
3034 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(INCLUDE_DELETED_ITEMS),
3035 GetMetaProtoTimes(dbs->db_.get()));
3036 // Since the proto times are expected to be in a legacy format, they may not
3037 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes().
3039 ASSERT_TRUE(dbs->MigrateVersion76To77());
3040 ASSERT_EQ(77, dbs->GetVersion());
3042 EXPECT_EQ(GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS),
3043 GetMetaProtoTimes(dbs->db_.get()));
3044 // Cannot actually load entries due to version 77 not having all required
3045 // columns.
3046 ASSERT_FALSE(dbs->needs_column_refresh_);
3049 TEST_F(DirectoryBackingStoreTest, MigrateVersion77To78) {
3050 sql::Connection connection;
3051 ASSERT_TRUE(connection.OpenInMemory());
3052 SetUpVersion77Database(&connection);
3054 ASSERT_FALSE(connection.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS"));
3057 scoped_ptr<TestDirectoryBackingStore> dbs(
3058 new TestDirectoryBackingStore(GetUsername(), &connection));
3059 ASSERT_FALSE(dbs->needs_column_refresh_);
3060 ASSERT_TRUE(dbs->MigrateVersion77To78());
3061 ASSERT_EQ(78, dbs->GetVersion());
3063 ASSERT_FALSE(dbs->needs_column_refresh_);
3066 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics"));
3069 TEST_F(DirectoryBackingStoreTest, MigrateVersion78To79) {
3070 const int kInitialNextId = -65542;
3072 sql::Connection connection;
3073 ASSERT_TRUE(connection.OpenInMemory());
3074 SetUpVersion78Database(&connection);
3076 // Double-check the original next_id is what we think it is.
3077 sql::Statement s(connection.GetUniqueStatement(
3078 "SELECT next_id FROM share_info"));
3079 s.Step();
3080 ASSERT_EQ(kInitialNextId, s.ColumnInt(0));
3082 scoped_ptr<TestDirectoryBackingStore> dbs(
3083 new TestDirectoryBackingStore(GetUsername(), &connection));
3084 ASSERT_FALSE(dbs->needs_column_refresh_);
3085 ASSERT_TRUE(dbs->MigrateVersion78To79());
3086 ASSERT_EQ(79, dbs->GetVersion());
3087 ASSERT_FALSE(dbs->needs_column_refresh_);
3089 // Ensure the next_id has been incremented.
3090 Directory::MetahandlesMap handles_map;
3091 JournalIndex delete_journals;;
3092 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3093 Directory::KernelLoadInfo load_info;
3095 s.Clear();
3096 ASSERT_TRUE(dbs->Load(&handles_map, &delete_journals, &load_info));
3097 EXPECT_LE(load_info.kernel_info.next_id, kInitialNextId - 65536);
3100 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) {
3101 sql::Connection connection;
3102 ASSERT_TRUE(connection.OpenInMemory());
3103 SetUpVersion79Database(&connection);
3105 scoped_ptr<TestDirectoryBackingStore> dbs(
3106 new TestDirectoryBackingStore(GetUsername(), &connection));
3107 ASSERT_FALSE(dbs->needs_column_refresh_);
3108 ASSERT_TRUE(dbs->MigrateVersion79To80());
3109 ASSERT_EQ(80, dbs->GetVersion());
3110 ASSERT_FALSE(dbs->needs_column_refresh_);
3112 // Ensure the bag_of_chips has been set.
3113 Directory::MetahandlesMap handles_map;
3114 JournalIndex delete_journals;;
3115 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3116 Directory::KernelLoadInfo load_info;
3118 ASSERT_TRUE(dbs->Load(&handles_map, &delete_journals, &load_info));
3119 // Check that the initial value is the serialization of an empty ChipBag.
3120 sync_pb::ChipBag chip_bag;
3121 std::string serialized_chip_bag;
3122 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag));
3123 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips);
3126 TEST_F(DirectoryBackingStoreTest, MigrateVersion80To81) {
3127 sql::Connection connection;
3128 ASSERT_TRUE(connection.OpenInMemory());
3129 SetUpVersion80Database(&connection);
3131 sql::Statement s(connection.GetUniqueStatement(
3132 "SELECT metahandle, server_position_in_parent "
3133 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3134 ASSERT_TRUE(s.Step());
3135 ASSERT_EQ(sql::COLUMN_TYPE_INTEGER, s.ColumnType(1));
3137 scoped_ptr<TestDirectoryBackingStore> dbs(
3138 new TestDirectoryBackingStore(GetUsername(), &connection));
3139 ASSERT_TRUE(dbs->MigrateVersion80To81());
3140 ASSERT_EQ(81, dbs->GetVersion());
3142 // Test that ordinal values are preserved correctly.
3143 sql::Statement new_s(connection.GetUniqueStatement(
3144 "SELECT metahandle, server_ordinal_in_parent "
3145 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3146 ASSERT_TRUE(new_s.Step());
3147 ASSERT_EQ(sql::COLUMN_TYPE_BLOB, new_s.ColumnType(1));
3149 std::string expected_ordinal = Int64ToNodeOrdinal(1048576).ToInternalValue();
3150 std::string actual_ordinal;
3151 new_s.ColumnBlobAsString(1, &actual_ordinal);
3152 ASSERT_EQ(expected_ordinal, actual_ordinal);
3155 TEST_F(DirectoryBackingStoreTest, MigrateVersion81To82) {
3156 sql::Connection connection;
3157 ASSERT_TRUE(connection.OpenInMemory());
3158 SetUpVersion81Database(&connection);
3159 ASSERT_FALSE(connection.DoesColumnExist("models", "transaction_version"));
3161 scoped_ptr<TestDirectoryBackingStore> dbs(
3162 new TestDirectoryBackingStore(GetUsername(), &connection));
3163 ASSERT_FALSE(dbs->needs_column_refresh_);
3164 ASSERT_TRUE(dbs->MigrateVersion81To82());
3165 ASSERT_EQ(82, dbs->GetVersion());
3166 ASSERT_FALSE(dbs->needs_column_refresh_);
3168 ASSERT_TRUE(connection.DoesColumnExist("models", "transaction_version"));
3171 TEST_F(DirectoryBackingStoreTest, MigrateVersion82To83) {
3172 sql::Connection connection;
3173 ASSERT_TRUE(connection.OpenInMemory());
3174 SetUpVersion82Database(&connection);
3175 ASSERT_FALSE(connection.DoesColumnExist("metas", "transaction_version"));
3177 scoped_ptr<TestDirectoryBackingStore> dbs(
3178 new TestDirectoryBackingStore(GetUsername(), &connection));
3179 ASSERT_TRUE(dbs->MigrateVersion82To83());
3180 ASSERT_EQ(83, dbs->GetVersion());
3182 ASSERT_TRUE(connection.DoesColumnExist("metas", "transaction_version"));
3185 TEST_F(DirectoryBackingStoreTest, MigrateVersion83To84) {
3186 sql::Connection connection;
3187 ASSERT_TRUE(connection.OpenInMemory());
3188 SetUpVersion83Database(&connection);
3189 ASSERT_FALSE(connection.DoesTableExist("deleted_metas"));
3191 scoped_ptr<TestDirectoryBackingStore> dbs(
3192 new TestDirectoryBackingStore(GetUsername(), &connection));
3193 ASSERT_TRUE(dbs->MigrateVersion83To84());
3194 ASSERT_EQ(84, dbs->GetVersion());
3196 ASSERT_TRUE(connection.DoesTableExist("deleted_metas"));
3199 TEST_F(DirectoryBackingStoreTest, MigrateVersion84To85) {
3200 sql::Connection connection;
3201 ASSERT_TRUE(connection.OpenInMemory());
3202 SetUpVersion84Database(&connection);
3203 ASSERT_TRUE(connection.DoesColumnExist("models", "initial_sync_ended"));
3205 scoped_ptr<TestDirectoryBackingStore> dbs(
3206 new TestDirectoryBackingStore(GetUsername(), &connection));
3207 ASSERT_TRUE(dbs->MigrateVersion84To85());
3208 ASSERT_EQ(85, dbs->GetVersion());
3209 ASSERT_FALSE(connection.DoesColumnExist("models", "initial_sync_ended"));
3212 TEST_F(DirectoryBackingStoreTest, MigrateVersion85To86) {
3213 sql::Connection connection;
3214 ASSERT_TRUE(connection.OpenInMemory());
3215 SetUpVersion85Database(&connection);
3216 EXPECT_TRUE(connection.DoesColumnExist("metas", "next_id"));
3217 EXPECT_TRUE(connection.DoesColumnExist("metas", "prev_id"));
3218 EXPECT_TRUE(connection.DoesColumnExist("metas", "server_ordinal_in_parent"));
3219 EXPECT_FALSE(connection.DoesColumnExist("metas", "unique_position"));
3220 EXPECT_FALSE(connection.DoesColumnExist("metas", "server_unique_position"));
3221 EXPECT_FALSE(connection.DoesColumnExist("metas", "unique_bookmark_tag"));
3223 scoped_ptr<TestDirectoryBackingStore> dbs(
3224 new TestDirectoryBackingStore(GetUsername(), &connection));
3225 ASSERT_TRUE(dbs->MigrateVersion85To86());
3226 EXPECT_EQ(86, dbs->GetVersion());
3227 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_position"));
3228 EXPECT_TRUE(connection.DoesColumnExist("metas", "server_unique_position"));
3229 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_bookmark_tag"));
3230 ASSERT_TRUE(dbs->needs_column_refresh_);
3233 TEST_F(DirectoryBackingStoreTest, MigrateVersion86To87) {
3234 sql::Connection connection;
3235 EXPECT_TRUE(connection.OpenInMemory());
3236 SetUpVersion86Database(&connection);
3237 EXPECT_FALSE(connection.DoesColumnExist("metas", "attachment_metadata"));
3239 scoped_ptr<TestDirectoryBackingStore> dbs(
3240 new TestDirectoryBackingStore(GetUsername(), &connection));
3241 EXPECT_TRUE(dbs->MigrateVersion86To87());
3242 EXPECT_EQ(87, dbs->GetVersion());
3243 EXPECT_TRUE(connection.DoesColumnExist("metas", "attachment_metadata"));
3244 EXPECT_TRUE(dbs->needs_column_refresh_);
3247 TEST_F(DirectoryBackingStoreTest, MigrateVersion87To88) {
3248 sql::Connection connection;
3249 ASSERT_TRUE(connection.OpenInMemory());
3250 SetUpVersion87Database(&connection);
3252 scoped_ptr<TestDirectoryBackingStore> dbs(
3253 new TestDirectoryBackingStore(GetUsername(), &connection));
3254 ASSERT_TRUE(dbs->MigrateVersion87To88());
3255 ASSERT_EQ(88, dbs->GetVersion());
3256 ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
3259 // The purpose of this test case is to make it easier to get a dump of the
3260 // database so you can implement a SetUpVersionYDatabase method. Here's what
3261 // you should do:
3263 // 1. Say you're going from version X to version Y. Write the migration
3264 // method MigrateVersionXToY.
3265 // 2. Update the test below to call SetUpVersionXDatabase and then
3266 // MigrateVersionXToY. You now have a database at version Y. Let's dump it.
3267 // 3. Set a breakpoint to stop execution just after the connection is
3268 // destroyed. Examine temp_dir_ to find the version Y database that was
3269 // created on disk. E.g. (gdb) p temp_dir_.path().value().c_str()
3270 // 4. Dump the database using the sqlite3 command line tool:
3271 // > .output foo_dump.sql
3272 // > .dump
3273 // 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or
3274 // LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write
3275 // a SetupVersionYDatabase method.
3276 TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) {
3278 sql::Connection connection;
3279 ASSERT_TRUE(connection.Open(GetDatabasePath()));
3280 SetUpVersion87Database(&connection); // Update this.
3282 scoped_ptr<TestDirectoryBackingStore> dbs(
3283 new TestDirectoryBackingStore(GetUsername(), &connection));
3284 ASSERT_TRUE(dbs->MigrateVersion87To88()); // Update this.
3285 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3286 EXPECT_EQ(88, dbs->GetVersion()); // Update this.
3287 ASSERT_FALSE(dbs->needs_column_refresh_);
3289 // Set breakpoint here.
3292 TEST_F(DirectoryBackingStoreTest, DetectInvalidPosition) {
3293 sql::Connection connection;
3294 ASSERT_TRUE(connection.OpenInMemory());
3295 SetUpVersion86Database(&connection);
3297 scoped_ptr<TestDirectoryBackingStore> dbs(
3298 new TestDirectoryBackingStore(GetUsername(), &connection));
3299 ASSERT_EQ(86, dbs->GetVersion());
3301 // Insert row with bad position.
3302 sql::Statement s(connection.GetUniqueStatement(
3303 "INSERT INTO metas "
3304 "( id, metahandle, is_dir, ctime, mtime,"
3305 " unique_position, server_unique_position) "
3306 "VALUES('c-invalid', 9999, 1, 0, 0, 'BAD_POS', 'BAD_POS')"));
3307 ASSERT_TRUE(s.Run());
3309 // Trying to unpack this entry should signal that the DB is corrupted.
3310 Directory::MetahandlesMap handles_map;
3311 JournalIndex delete_journals;;
3312 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3313 Directory::KernelLoadInfo kernel_load_info;
3314 ASSERT_EQ(FAILED_DATABASE_CORRUPT,
3315 dbs->Load(&handles_map, &delete_journals, &kernel_load_info));
3318 TEST_P(MigrationTest, ToCurrentVersion) {
3319 sql::Connection connection;
3320 ASSERT_TRUE(connection.OpenInMemory());
3321 switch (GetParam()) {
3322 case 67:
3323 SetUpVersion67Database(&connection);
3324 break;
3325 case 68:
3326 SetUpVersion68Database(&connection);
3327 break;
3328 case 69:
3329 SetUpVersion69Database(&connection);
3330 break;
3331 case 70:
3332 SetUpVersion70Database(&connection);
3333 break;
3334 case 71:
3335 SetUpVersion71Database(&connection);
3336 break;
3337 case 72:
3338 SetUpVersion72Database(&connection);
3339 break;
3340 case 73:
3341 SetUpVersion73Database(&connection);
3342 break;
3343 case 74:
3344 SetUpVersion74Database(&connection);
3345 break;
3346 case 75:
3347 SetUpVersion75Database(&connection);
3348 break;
3349 case 76:
3350 SetUpVersion76Database(&connection);
3351 break;
3352 case 77:
3353 SetUpVersion77Database(&connection);
3354 break;
3355 case 78:
3356 SetUpVersion78Database(&connection);
3357 break;
3358 case 79:
3359 SetUpVersion79Database(&connection);
3360 break;
3361 case 80:
3362 SetUpVersion80Database(&connection);
3363 break;
3364 case 81:
3365 SetUpVersion81Database(&connection);
3366 break;
3367 case 82:
3368 SetUpVersion82Database(&connection);
3369 break;
3370 case 83:
3371 SetUpVersion83Database(&connection);
3372 break;
3373 case 84:
3374 SetUpVersion84Database(&connection);
3375 break;
3376 case 85:
3377 SetUpVersion85Database(&connection);
3378 break;
3379 case 86:
3380 SetUpVersion86Database(&connection);
3381 break;
3382 case 87:
3383 SetUpVersion87Database(&connection);
3384 break;
3385 case 88:
3386 SetUpVersion88Database(&connection);
3387 break;
3388 default:
3389 // If you see this error, it may mean that you've increased the
3390 // database version number but you haven't finished adding unit tests
3391 // for the database migration code. You need to need to supply a
3392 // SetUpVersionYDatabase function with a dump of the test database
3393 // at the new schema. See the MigrateToLatestAndDump test case.
3394 FAIL() << "Need to supply database dump for version " << GetParam();
3397 syncable::Directory::KernelLoadInfo dir_info;
3398 Directory::MetahandlesMap handles_map;
3399 JournalIndex delete_journals;;
3400 STLValueDeleter<Directory::MetahandlesMap> index_deleter(&handles_map);
3403 scoped_ptr<TestDirectoryBackingStore> dbs(
3404 new TestDirectoryBackingStore(GetUsername(), &connection));
3405 ASSERT_EQ(OPENED, dbs->Load(&handles_map, &delete_journals, &dir_info));
3406 ASSERT_FALSE(dbs->needs_column_refresh_);
3407 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
3410 // Columns deleted in Version 67.
3411 ASSERT_FALSE(connection.DoesColumnExist("metas", "name"));
3412 ASSERT_FALSE(connection.DoesColumnExist("metas", "unsanitized_name"));
3413 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_name"));
3415 // Columns added in Version 68.
3416 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics"));
3417 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics"));
3419 // Columns deleted in Version 68.
3420 ASSERT_FALSE(connection.DoesColumnExist("metas", "is_bookmark_object"));
3421 ASSERT_FALSE(connection.DoesColumnExist("metas",
3422 "server_is_bookmark_object"));
3423 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_favicon"));
3424 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_url"));
3425 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_bookmark_url"));
3427 // Renamed a column in Version 70
3428 ASSERT_FALSE(connection.DoesColumnExist("metas", "singleton_tag"));
3429 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag"));
3430 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag"));
3432 // Removed extended attributes in Version 72.
3433 ASSERT_FALSE(connection.DoesTableExist("extended_attributes"));
3435 // Columns added in Version 73.
3436 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state"));
3438 // Column replaced in version 75.
3439 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker"));
3440 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp"));
3442 // Columns removed in version 76.
3443 ASSERT_FALSE(
3444 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3445 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3446 "bookmarks_added_during_autofill_migration"));
3447 ASSERT_FALSE(
3448 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3449 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3450 "autofill_entries_added_during_migration"));
3451 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3452 "autofill_profiles_added_during_migration"));
3454 // Column added in version 78.
3455 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics"));
3457 // Column added in version 82.
3458 ASSERT_TRUE(connection.DoesColumnExist("models", "transaction_version"));
3460 // Column added in version 83.
3461 ASSERT_TRUE(connection.DoesColumnExist("metas", "transaction_version"));
3463 // Table added in version 84.
3464 ASSERT_TRUE(connection.DoesTableExist("deleted_metas"));
3466 // Column removed in version 85.
3467 ASSERT_FALSE(connection.DoesColumnExist("models", "initial_sync_ended"));
3469 // Columns removed in version 86.
3470 ASSERT_FALSE(connection.DoesColumnExist("metas", "next_id"));
3471 ASSERT_FALSE(connection.DoesColumnExist("metas", "prev_id"));
3472 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_ordinal_in_parent"));
3474 // Column added in version 87.
3475 ASSERT_TRUE(connection.DoesColumnExist("metas", "attachment_metadata"));
3477 // Column added in version 88.
3478 ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
3480 // Check download_progress state (v75 migration)
3481 ASSERT_EQ(694,
3482 dir_info.kernel_info.download_progress[BOOKMARKS]
3483 .timestamp_token_for_migration());
3484 ASSERT_FALSE(
3485 dir_info.kernel_info.download_progress[BOOKMARKS]
3486 .has_token());
3487 ASSERT_EQ(32904,
3488 dir_info.kernel_info.download_progress[BOOKMARKS]
3489 .data_type_id());
3490 ASSERT_FALSE(
3491 dir_info.kernel_info.download_progress[THEMES]
3492 .has_timestamp_token_for_migration());
3493 ASSERT_TRUE(
3494 dir_info.kernel_info.download_progress[THEMES]
3495 .has_token());
3496 ASSERT_TRUE(
3497 dir_info.kernel_info.download_progress[THEMES]
3498 .token().empty());
3499 ASSERT_EQ(41210,
3500 dir_info.kernel_info.download_progress[THEMES]
3501 .data_type_id());
3503 // Check metas
3504 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS),
3505 GetMetaProtoTimes(&connection));
3506 ExpectTimes(handles_map, GetExpectedMetaTimes());
3508 Directory::MetahandlesMap::iterator it = handles_map.find(1);
3509 ASSERT_TRUE(it != handles_map.end());
3510 ASSERT_EQ(1, it->second->ref(META_HANDLE));
3511 EXPECT_TRUE(it->second->ref(ID).IsRoot());
3512 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3513 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3514 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3515 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3517 // Items 2, 4, and 5 were deleted.
3518 it = handles_map.find(2);
3519 ASSERT_TRUE(it == handles_map.end());
3520 it = handles_map.find(4);
3521 ASSERT_TRUE(it == handles_map.end());
3522 it = handles_map.find(5);
3523 ASSERT_TRUE(it == handles_map.end());
3525 it = handles_map.find(6);
3526 ASSERT_EQ(6, it->second->ref(META_HANDLE));
3527 EXPECT_TRUE(it->second->ref(IS_DIR));
3528 EXPECT_TRUE(it->second->ref(SERVER_IS_DIR));
3529 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3530 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3531 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3532 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3533 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3534 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3535 EXPECT_EQ(UniquePosition::kSuffixLength,
3536 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3537 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3539 it = handles_map.find(7);
3540 ASSERT_EQ(7, it->second->ref(META_HANDLE));
3541 EXPECT_EQ("google_chrome", it->second->ref(UNIQUE_SERVER_TAG));
3542 EXPECT_FALSE(it->second->ref(SPECIFICS).has_bookmark());
3543 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3544 // Make sure we didn't assign positions to google_chrome.
3545 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3546 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3547 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3548 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3550 it = handles_map.find(8);
3551 ASSERT_EQ(8, it->second->ref(META_HANDLE));
3552 EXPECT_EQ("google_chrome_bookmarks", it->second->ref(UNIQUE_SERVER_TAG));
3553 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3554 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3555 ASSERT_EQ(it->second->ref(ID).value(), "s_ID_8");
3556 // Make sure we didn't mistake the bookmark root node for a real bookmark.
3557 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3558 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3559 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3560 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3562 it = handles_map.find(9);
3563 ASSERT_EQ(9, it->second->ref(META_HANDLE));
3564 EXPECT_EQ("bookmark_bar", it->second->ref(UNIQUE_SERVER_TAG));
3565 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3566 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3567 // Make sure we didn't assign positions to bookmark_bar.
3568 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3569 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3570 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3571 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3573 it = handles_map.find(10);
3574 ASSERT_EQ(10, it->second->ref(META_HANDLE));
3575 EXPECT_FALSE(it->second->ref(IS_DEL));
3576 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3577 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3578 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3579 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3580 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3581 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3582 EXPECT_EQ("other_bookmarks", it->second->ref(UNIQUE_SERVER_TAG));
3583 EXPECT_EQ("Other Bookmarks", it->second->ref(NON_UNIQUE_NAME));
3584 EXPECT_EQ("Other Bookmarks", it->second->ref(SERVER_NON_UNIQUE_NAME));
3585 ASSERT_EQ(it->second->ref(ID).value(), "s_ID_10");
3586 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3587 // Make sure we didn't assign positions to server-created folders, either.
3588 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3589 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3590 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3591 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3593 it = handles_map.find(11);
3594 ASSERT_EQ(11, it->second->ref(META_HANDLE));
3595 EXPECT_FALSE(it->second->ref(IS_DEL));
3596 EXPECT_FALSE(it->second->ref(IS_DIR));
3597 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3598 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3599 EXPECT_EQ("http://dev.chromium.org/",
3600 it->second->ref(SPECIFICS).bookmark().url());
3601 EXPECT_EQ("AGATWA", it->second->ref(SPECIFICS).bookmark().favicon());
3602 EXPECT_EQ("http://dev.chromium.org/other",
3603 it->second->ref(SERVER_SPECIFICS).bookmark().url());
3604 EXPECT_EQ("AFAGVASF", it->second->ref(SERVER_SPECIFICS).bookmark().favicon());
3605 EXPECT_EQ("", it->second->ref(UNIQUE_SERVER_TAG));
3606 EXPECT_EQ("Home (The Chromium Projects)", it->second->ref(NON_UNIQUE_NAME));
3607 EXPECT_EQ("Home (The Chromium Projects)",
3608 it->second->ref(SERVER_NON_UNIQUE_NAME));
3609 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3610 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3611 EXPECT_EQ(UniquePosition::kSuffixLength,
3612 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3613 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3615 it = handles_map.find(12);
3616 ASSERT_EQ(12, it->second->ref(META_HANDLE));
3617 EXPECT_FALSE(it->second->ref(IS_DEL));
3618 EXPECT_TRUE(it->second->ref(IS_DIR));
3619 EXPECT_EQ("Extra Bookmarks", it->second->ref(NON_UNIQUE_NAME));
3620 EXPECT_EQ("Extra Bookmarks", it->second->ref(SERVER_NON_UNIQUE_NAME));
3621 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3622 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3623 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3624 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3625 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3626 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3627 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3628 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3629 EXPECT_EQ(UniquePosition::kSuffixLength,
3630 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3631 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3633 it = handles_map.find(13);
3634 ASSERT_EQ(13, it->second->ref(META_HANDLE));
3635 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3636 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3637 EXPECT_EQ(UniquePosition::kSuffixLength,
3638 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3639 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3641 it = handles_map.find(14);
3642 ASSERT_EQ(14, it->second->ref(META_HANDLE));
3643 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3644 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3645 EXPECT_EQ(UniquePosition::kSuffixLength,
3646 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3647 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3649 ASSERT_EQ(static_cast<size_t>(10), handles_map.size());
3651 // Make sure that the syncable::Directory and the migration code agree on
3652 // which items should or should not have unique position values. This test
3653 // may become obsolete if the directory's definition of that function
3654 // changes, but, until then, this is a useful test.
3655 for (it = handles_map.begin(); it != handles_map.end(); it++) {
3656 SCOPED_TRACE(it->second->ref(ID));
3657 if (it->second->ShouldMaintainPosition()) {
3658 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3659 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3660 EXPECT_FALSE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3661 } else {
3662 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3663 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3664 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3669 INSTANTIATE_TEST_CASE_P(DirectoryBackingStore, MigrationTest,
3670 testing::Range(67, kCurrentDBVersion + 1));
3672 TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
3673 ModelTypeSet protocol_types = ProtocolTypes();
3674 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
3675 iter.Inc()) {
3676 std::string model_id =
3677 TestDirectoryBackingStore::ModelTypeEnumToModelId(iter.Get());
3678 EXPECT_EQ(iter.Get(),
3679 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(),
3680 model_id.size()));
3684 namespace {
3686 class OnDiskDirectoryBackingStoreForTest : public OnDiskDirectoryBackingStore {
3687 public:
3688 OnDiskDirectoryBackingStoreForTest(const std::string& dir_name,
3689 const base::FilePath& backing_filepath);
3690 virtual ~OnDiskDirectoryBackingStoreForTest();
3691 bool DidFailFirstOpenAttempt();
3693 protected:
3694 virtual void ReportFirstTryOpenFailure() OVERRIDE;
3696 private:
3697 bool first_open_failed_;
3700 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest(
3701 const std::string& dir_name,
3702 const base::FilePath& backing_filepath) :
3703 OnDiskDirectoryBackingStore(dir_name, backing_filepath),
3704 first_open_failed_(false) { }
3706 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { }
3708 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() {
3709 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK.
3710 first_open_failed_ = true;
3713 bool OnDiskDirectoryBackingStoreForTest::DidFailFirstOpenAttempt() {
3714 return first_open_failed_;
3717 } // namespace
3719 // This is a whitebox test intended to exercise the code path where the on-disk
3720 // directory load code decides to delete the current directory and start fresh.
3722 // This is considered "minor" corruption because the database recreation is
3723 // expected to succeed. The alternative, where recreation does not succeed (ie.
3724 // due to read-only file system), is not tested here.
3725 TEST_F(DirectoryBackingStoreTest, MinorCorruption) {
3727 scoped_ptr<OnDiskDirectoryBackingStore> dbs(
3728 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
3729 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3732 // Corrupt the root node.
3734 sql::Connection connection;
3735 ASSERT_TRUE(connection.Open(GetDatabasePath()));
3736 ASSERT_TRUE(connection.Execute(
3737 "UPDATE metas SET parent_id='bogus' WHERE id = 'r';"));
3741 scoped_ptr<OnDiskDirectoryBackingStoreForTest> dbs(
3742 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
3743 GetDatabasePath()));
3745 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3746 EXPECT_TRUE(dbs->DidFailFirstOpenAttempt());
3750 TEST_F(DirectoryBackingStoreTest, DeleteEntries) {
3751 sql::Connection connection;
3752 ASSERT_TRUE(connection.OpenInMemory());
3754 SetUpCurrentDatabaseAndCheckVersion(&connection);
3755 scoped_ptr<TestDirectoryBackingStore> dbs(
3756 new TestDirectoryBackingStore(GetUsername(), &connection));
3757 Directory::MetahandlesMap handles_map;
3758 JournalIndex delete_journals;
3759 Directory::KernelLoadInfo kernel_load_info;
3760 STLValueDeleter<Directory::MetahandlesMap> index_deleter(&handles_map);
3762 dbs->Load(&handles_map, &delete_journals, &kernel_load_info);
3763 size_t initial_size = handles_map.size();
3764 ASSERT_LT(0U, initial_size) << "Test requires handles_map to delete.";
3765 int64 first_to_die = handles_map.begin()->second->ref(META_HANDLE);
3766 MetahandleSet to_delete;
3767 to_delete.insert(first_to_die);
3768 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE,
3769 to_delete));
3771 STLDeleteValues(&handles_map);
3772 dbs->LoadEntries(&handles_map);
3774 EXPECT_EQ(initial_size - 1, handles_map.size());
3775 bool delete_failed = false;
3776 for (Directory::MetahandlesMap::iterator it = handles_map.begin();
3777 it != handles_map.end(); ++it) {
3778 if (it->first == first_to_die) {
3779 delete_failed = true;
3780 break;
3783 EXPECT_FALSE(delete_failed);
3785 to_delete.clear();
3786 for (Directory::MetahandlesMap::iterator it = handles_map.begin();
3787 it != handles_map.end(); ++it) {
3788 to_delete.insert(it->first);
3791 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE,
3792 to_delete));
3794 STLDeleteValues(&handles_map);
3795 dbs->LoadEntries(&handles_map);
3796 EXPECT_EQ(0U, handles_map.size());
3799 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) {
3800 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID();
3801 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID();
3802 EXPECT_EQ(24U, guid1.size());
3803 EXPECT_EQ(24U, guid2.size());
3804 // In theory this test can fail, but it won't before the universe
3805 // dies of heat death.
3806 EXPECT_NE(guid1, guid2);
3809 } // namespace syncable
3810 } // namespace syncer