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"
9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h"
17 #include "sql/connection.h"
18 #include "sql/statement.h"
19 #include "sql/test/scoped_error_ignorer.h"
20 #include "sql/test/test_helpers.h"
21 #include "sync/base/sync_export.h"
22 #include "sync/internal_api/public/base/node_ordinal.h"
23 #include "sync/protocol/bookmark_specifics.pb.h"
24 #include "sync/protocol/sync.pb.h"
25 #include "sync/syncable/directory.h"
26 #include "sync/syncable/directory_backing_store.h"
27 #include "sync/syncable/on_disk_directory_backing_store.h"
28 #include "sync/syncable/syncable-inl.h"
29 #include "sync/test/directory_backing_store_corruption_testing.h"
30 #include "sync/test/test_directory_backing_store.h"
31 #include "sync/util/time.h"
32 #include "testing/gtest/include/gtest/gtest-param-test.h"
38 // A handler that simply sets |catastrophic_error_handler_was_called| to true.
39 void CatastrophicErrorHandler(bool* catastrophic_error_handler_was_called
) {
40 *catastrophic_error_handler_was_called
= true;
43 // Create a dirty EntryKernel with an ID derived from |id| + |id_suffix|.
44 scoped_ptr
<EntryKernel
> CreateEntry(int id
, const std::string
&id_suffix
) {
45 scoped_ptr
<EntryKernel
> entry(new EntryKernel());
46 std::string id_string
= base::Int64ToString(id
) + id_suffix
;
47 entry
->put(ID
, Id::CreateFromClientString(id_string
));
48 entry
->put(META_HANDLE
, id
);
49 entry
->mark_dirty(NULL
);
55 SYNC_EXPORT_PRIVATE
extern const int32 kCurrentDBVersion
;
57 class MigrationTest
: public testing::TestWithParam
<int> {
59 void SetUp() override
{ ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir()); }
62 std::string
GetUsername() {
63 return "nick@chromium.org";
66 base::FilePath
GetDatabasePath() {
67 return temp_dir_
.path().Append(Directory::kSyncDatabaseFilename
);
70 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore
*dbs
) {
71 Directory::MetahandlesMap tmp_handles_map
;
72 JournalIndex delete_journals
;
73 MetahandleSet metahandles_to_purge
;
74 STLValueDeleter
<Directory::MetahandlesMap
> deleter(&tmp_handles_map
);
75 Directory::KernelLoadInfo kernel_load_info
;
76 return dbs
->Load(&tmp_handles_map
, &delete_journals
, &metahandles_to_purge
,
77 &kernel_load_info
) == OPENED
;
80 void SetUpVersion67Database(sql::Connection
* connection
);
81 void SetUpVersion68Database(sql::Connection
* connection
);
82 void SetUpVersion69Database(sql::Connection
* connection
);
83 void SetUpVersion70Database(sql::Connection
* connection
);
84 void SetUpVersion71Database(sql::Connection
* connection
);
85 void SetUpVersion72Database(sql::Connection
* connection
);
86 void SetUpVersion73Database(sql::Connection
* connection
);
87 void SetUpVersion74Database(sql::Connection
* connection
);
88 void SetUpVersion75Database(sql::Connection
* connection
);
89 void SetUpVersion76Database(sql::Connection
* connection
);
90 void SetUpVersion77Database(sql::Connection
* connection
);
91 void SetUpVersion78Database(sql::Connection
* connection
);
92 void SetUpVersion79Database(sql::Connection
* connection
);
93 void SetUpVersion80Database(sql::Connection
* connection
);
94 void SetUpVersion81Database(sql::Connection
* connection
);
95 void SetUpVersion82Database(sql::Connection
* connection
);
96 void SetUpVersion83Database(sql::Connection
* connection
);
97 void SetUpVersion84Database(sql::Connection
* connection
);
98 void SetUpVersion85Database(sql::Connection
* connection
);
99 void SetUpVersion86Database(sql::Connection
* connection
);
100 void SetUpVersion87Database(sql::Connection
* connection
);
101 void SetUpVersion88Database(sql::Connection
* connection
);
102 void SetUpVersion89Database(sql::Connection
* connection
);
104 void SetUpCurrentDatabaseAndCheckVersion(sql::Connection
* connection
) {
105 SetUpVersion89Database(connection
); // Prepopulates data.
106 scoped_ptr
<TestDirectoryBackingStore
> dbs(
107 new TestDirectoryBackingStore(GetUsername(), connection
));
108 ASSERT_EQ(kCurrentDBVersion
, dbs
->GetVersion());
110 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
111 ASSERT_FALSE(dbs
->needs_column_refresh());
115 base::MessageLoop message_loop_
;
116 base::ScopedTempDir temp_dir_
;
119 class DirectoryBackingStoreTest
: public MigrationTest
{};
123 // On Windows, we used to store timestamps in FILETIME format.
124 #define LEGACY_META_PROTO_TIMES_1 129079956640320000LL
125 #define LEGACY_META_PROTO_TIMES_2 128976886618480000LL
126 #define LEGACY_META_PROTO_TIMES_4 129002163642690000LL
127 #define LEGACY_META_PROTO_TIMES_5 129001555500000000LL
128 #define LEGACY_META_PROTO_TIMES_6 129053976170000000LL
129 #define LEGACY_META_PROTO_TIMES_7 128976864758480000LL
130 #define LEGACY_META_PROTO_TIMES_8 128976864758480000LL
131 #define LEGACY_META_PROTO_TIMES_9 128976864758480000LL
132 #define LEGACY_META_PROTO_TIMES_10 128976864758480000LL
133 #define LEGACY_META_PROTO_TIMES_11 129079956948440000LL
134 #define LEGACY_META_PROTO_TIMES_12 129079957513650000LL
135 #define LEGACY_META_PROTO_TIMES_13 129079957985300000LL
136 #define LEGACY_META_PROTO_TIMES_14 129079958383000000LL
138 #define LEGACY_META_PROTO_TIMES_STR_1 "129079956640320000"
139 #define LEGACY_META_PROTO_TIMES_STR_2 "128976886618480000"
140 #define LEGACY_META_PROTO_TIMES_STR_4 "129002163642690000"
141 #define LEGACY_META_PROTO_TIMES_STR_5 "129001555500000000"
142 #define LEGACY_META_PROTO_TIMES_STR_6 "129053976170000000"
143 #define LEGACY_META_PROTO_TIMES_STR_7 "128976864758480000"
144 #define LEGACY_META_PROTO_TIMES_STR_8 "128976864758480000"
145 #define LEGACY_META_PROTO_TIMES_STR_9 "128976864758480000"
146 #define LEGACY_META_PROTO_TIMES_STR_10 "128976864758480000"
147 #define LEGACY_META_PROTO_TIMES_STR_11 "129079956948440000"
148 #define LEGACY_META_PROTO_TIMES_STR_12 "129079957513650000"
149 #define LEGACY_META_PROTO_TIMES_STR_13 "129079957985300000"
150 #define LEGACY_META_PROTO_TIMES_STR_14 "129079958383000000"
154 // ruby -ane '$F[1].sub!("LEGACY_", ""); $F[2] = Integer($F[2].sub!("LL", "")) /
155 // 10000 - 11644473600000; print "#{$F[0]} #{$F[1]} #{$F[2]}LL"'
157 // Magic numbers taken from
158 // http://stackoverflow.com/questions/5398557/
159 // java-library-for-dealing-with-win32-filetime .
161 // Now we store them in Java format (ms since the Unix epoch).
162 #define META_PROTO_TIMES_1 1263522064032LL
163 #define META_PROTO_TIMES_2 1253215061848LL
164 #define META_PROTO_TIMES_4 1255742764269LL
165 #define META_PROTO_TIMES_5 1255681950000LL
166 #define META_PROTO_TIMES_6 1260924017000LL
167 #define META_PROTO_TIMES_7 1253212875848LL
168 #define META_PROTO_TIMES_8 1253212875848LL
169 #define META_PROTO_TIMES_9 1253212875848LL
170 #define META_PROTO_TIMES_10 1253212875848LL
171 #define META_PROTO_TIMES_11 1263522094844LL
172 #define META_PROTO_TIMES_12 1263522151365LL
173 #define META_PROTO_TIMES_13 1263522198530LL
174 #define META_PROTO_TIMES_14 1263522238300LL
176 #define META_PROTO_TIMES_STR_1 "1263522064032"
177 #define META_PROTO_TIMES_STR_2 "1253215061848"
178 #define META_PROTO_TIMES_STR_4 "1255742764269"
179 #define META_PROTO_TIMES_STR_5 "1255681950000"
180 #define META_PROTO_TIMES_STR_6 "1260924017000"
181 #define META_PROTO_TIMES_STR_7 "1253212875848"
182 #define META_PROTO_TIMES_STR_8 "1253212875848"
183 #define META_PROTO_TIMES_STR_9 "1253212875848"
184 #define META_PROTO_TIMES_STR_10 "1253212875848"
185 #define META_PROTO_TIMES_STR_11 "1263522094844"
186 #define META_PROTO_TIMES_STR_12 "1263522151365"
187 #define META_PROTO_TIMES_STR_13 "1263522198530"
188 #define META_PROTO_TIMES_STR_14 "1263522238300"
192 // On other platforms, we used to store timestamps in time_t format (s
193 // since the Unix epoch).
194 #define LEGACY_META_PROTO_TIMES_1 1263522064LL
195 #define LEGACY_META_PROTO_TIMES_2 1253215061LL
196 #define LEGACY_META_PROTO_TIMES_4 1255742764LL
197 #define LEGACY_META_PROTO_TIMES_5 1255681950LL
198 #define LEGACY_META_PROTO_TIMES_6 1260924017LL
199 #define LEGACY_META_PROTO_TIMES_7 1253212875LL
200 #define LEGACY_META_PROTO_TIMES_8 1253212875LL
201 #define LEGACY_META_PROTO_TIMES_9 1253212875LL
202 #define LEGACY_META_PROTO_TIMES_10 1253212875LL
203 #define LEGACY_META_PROTO_TIMES_11 1263522094LL
204 #define LEGACY_META_PROTO_TIMES_12 1263522151LL
205 #define LEGACY_META_PROTO_TIMES_13 1263522198LL
206 #define LEGACY_META_PROTO_TIMES_14 1263522238LL
208 #define LEGACY_META_PROTO_TIMES_STR_1 "1263522064"
209 #define LEGACY_META_PROTO_TIMES_STR_2 "1253215061"
210 #define LEGACY_META_PROTO_TIMES_STR_4 "1255742764"
211 #define LEGACY_META_PROTO_TIMES_STR_5 "1255681950"
212 #define LEGACY_META_PROTO_TIMES_STR_6 "1260924017"
213 #define LEGACY_META_PROTO_TIMES_STR_7 "1253212875"
214 #define LEGACY_META_PROTO_TIMES_STR_8 "1253212875"
215 #define LEGACY_META_PROTO_TIMES_STR_9 "1253212875"
216 #define LEGACY_META_PROTO_TIMES_STR_10 "1253212875"
217 #define LEGACY_META_PROTO_TIMES_STR_11 "1263522094"
218 #define LEGACY_META_PROTO_TIMES_STR_12 "1263522151"
219 #define LEGACY_META_PROTO_TIMES_STR_13 "1263522198"
220 #define LEGACY_META_PROTO_TIMES_STR_14 "1263522238"
222 // Now we store them in Java format (ms since the Unix epoch).
223 #define META_PROTO_TIMES_1 1263522064000LL
224 #define META_PROTO_TIMES_2 1253215061000LL
225 #define META_PROTO_TIMES_4 1255742764000LL
226 #define META_PROTO_TIMES_5 1255681950000LL
227 #define META_PROTO_TIMES_6 1260924017000LL
228 #define META_PROTO_TIMES_7 1253212875000LL
229 #define META_PROTO_TIMES_8 1253212875000LL
230 #define META_PROTO_TIMES_9 1253212875000LL
231 #define META_PROTO_TIMES_10 1253212875000LL
232 #define META_PROTO_TIMES_11 1263522094000LL
233 #define META_PROTO_TIMES_12 1263522151000LL
234 #define META_PROTO_TIMES_13 1263522198000LL
235 #define META_PROTO_TIMES_14 1263522238000LL
237 #define META_PROTO_TIMES_STR_1 "1263522064000"
238 #define META_PROTO_TIMES_STR_2 "1253215061000"
239 #define META_PROTO_TIMES_STR_4 "1255742764000"
240 #define META_PROTO_TIMES_STR_5 "1255681950000"
241 #define META_PROTO_TIMES_STR_6 "1260924017000"
242 #define META_PROTO_TIMES_STR_7 "1253212875000"
243 #define META_PROTO_TIMES_STR_8 "1253212875000"
244 #define META_PROTO_TIMES_STR_9 "1253212875000"
245 #define META_PROTO_TIMES_STR_10 "1253212875000"
246 #define META_PROTO_TIMES_STR_11 "1263522094000"
247 #define META_PROTO_TIMES_STR_12 "1263522151000"
248 #define META_PROTO_TIMES_STR_13 "1263522198000"
249 #define META_PROTO_TIMES_STR_14 "1263522238000"
253 // Helper macros for the database dumps in the SetUpVersion*Database
255 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x
256 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x
257 #define LEGACY_PROTO_TIME_VALS(x) \
258 LEGACY_META_PROTO_TIMES_STR(x) "," \
259 LEGACY_META_PROTO_TIMES_STR(x) "," \
260 LEGACY_META_PROTO_TIMES_STR(x) "," \
261 LEGACY_META_PROTO_TIMES_STR(x)
262 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
263 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x
264 #define META_PROTO_TIMES_VALS(x) \
265 META_PROTO_TIMES_STR(x) "," \
266 META_PROTO_TIMES_STR(x) "," \
267 META_PROTO_TIMES_STR(x) "," \
268 META_PROTO_TIMES_STR(x)
272 // Helper functions for testing.
274 enum ShouldIncludeDeletedItems
{
275 INCLUDE_DELETED_ITEMS
,
276 DONT_INCLUDE_DELETED_ITEMS
279 // Returns a map from metahandle -> expected legacy time (in proto
281 std::map
<int64
, int64
> GetExpectedLegacyMetaProtoTimes(
282 enum ShouldIncludeDeletedItems include_deleted
) {
283 std::map
<int64
, int64
> expected_legacy_meta_proto_times
;
284 expected_legacy_meta_proto_times
[1] = LEGACY_META_PROTO_TIMES(1);
285 if (include_deleted
== INCLUDE_DELETED_ITEMS
) {
286 expected_legacy_meta_proto_times
[2] = LEGACY_META_PROTO_TIMES(2);
287 expected_legacy_meta_proto_times
[4] = LEGACY_META_PROTO_TIMES(4);
288 expected_legacy_meta_proto_times
[5] = LEGACY_META_PROTO_TIMES(5);
290 expected_legacy_meta_proto_times
[6] = LEGACY_META_PROTO_TIMES(6);
291 expected_legacy_meta_proto_times
[7] = LEGACY_META_PROTO_TIMES(7);
292 expected_legacy_meta_proto_times
[8] = LEGACY_META_PROTO_TIMES(8);
293 expected_legacy_meta_proto_times
[9] = LEGACY_META_PROTO_TIMES(9);
294 expected_legacy_meta_proto_times
[10] = LEGACY_META_PROTO_TIMES(10);
295 expected_legacy_meta_proto_times
[11] = LEGACY_META_PROTO_TIMES(11);
296 expected_legacy_meta_proto_times
[12] = LEGACY_META_PROTO_TIMES(12);
297 expected_legacy_meta_proto_times
[13] = LEGACY_META_PROTO_TIMES(13);
298 expected_legacy_meta_proto_times
[14] = LEGACY_META_PROTO_TIMES(14);
299 return expected_legacy_meta_proto_times
;
302 // Returns a map from metahandle -> expected time (in proto format).
303 std::map
<int64
, int64
> GetExpectedMetaProtoTimes(
304 enum ShouldIncludeDeletedItems include_deleted
) {
305 std::map
<int64
, int64
> expected_meta_proto_times
;
306 expected_meta_proto_times
[1] = META_PROTO_TIMES(1);
307 if (include_deleted
== INCLUDE_DELETED_ITEMS
) {
308 expected_meta_proto_times
[2] = META_PROTO_TIMES(2);
309 expected_meta_proto_times
[4] = META_PROTO_TIMES(4);
310 expected_meta_proto_times
[5] = META_PROTO_TIMES(5);
312 expected_meta_proto_times
[6] = META_PROTO_TIMES(6);
313 expected_meta_proto_times
[7] = META_PROTO_TIMES(7);
314 expected_meta_proto_times
[8] = META_PROTO_TIMES(8);
315 expected_meta_proto_times
[9] = META_PROTO_TIMES(9);
316 expected_meta_proto_times
[10] = META_PROTO_TIMES(10);
317 expected_meta_proto_times
[11] = META_PROTO_TIMES(11);
318 expected_meta_proto_times
[12] = META_PROTO_TIMES(12);
319 expected_meta_proto_times
[13] = META_PROTO_TIMES(13);
320 expected_meta_proto_times
[14] = META_PROTO_TIMES(14);
321 return expected_meta_proto_times
;
324 // Returns a map from metahandle -> expected time (as a Time object).
325 std::map
<int64
, base::Time
> GetExpectedMetaTimes() {
326 std::map
<int64
, base::Time
> expected_meta_times
;
327 const std::map
<int64
, int64
>& expected_meta_proto_times
=
328 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS
);
329 for (std::map
<int64
, int64
>::const_iterator it
=
330 expected_meta_proto_times
.begin();
331 it
!= expected_meta_proto_times
.end(); ++it
) {
332 expected_meta_times
[it
->first
] = ProtoTimeToTime(it
->second
);
334 return expected_meta_times
;
337 // Extracts a map from metahandle -> time (in proto format) from the
339 std::map
<int64
, int64
> GetMetaProtoTimes(sql::Connection
*db
) {
340 sql::Statement
s(db
->GetCachedStatement(
342 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime "
344 EXPECT_EQ(5, s
.ColumnCount());
345 std::map
<int64
, int64
> meta_times
;
347 int64 metahandle
= s
.ColumnInt64(0);
348 int64 mtime
= s
.ColumnInt64(1);
349 int64 server_mtime
= s
.ColumnInt64(2);
350 int64 ctime
= s
.ColumnInt64(3);
351 int64 server_ctime
= s
.ColumnInt64(4);
352 EXPECT_EQ(mtime
, server_mtime
);
353 EXPECT_EQ(mtime
, ctime
);
354 EXPECT_EQ(mtime
, server_ctime
);
355 meta_times
[metahandle
] = mtime
;
357 EXPECT_TRUE(s
.Succeeded());
361 ::testing::AssertionResult
AssertTimesMatch(const char* t1_expr
,
363 const base::Time
& t1
,
364 const base::Time
& t2
) {
366 return ::testing::AssertionSuccess();
368 return ::testing::AssertionFailure()
369 << t1_expr
<< " and " << t2_expr
370 << " (internal values: " << t1
.ToInternalValue()
371 << " and " << t2
.ToInternalValue()
372 << ") (proto time: " << TimeToProtoTime(t1
)
373 << " and " << TimeToProtoTime(t2
)
377 // Expect that all time fields of the given entry kernel will be the
379 void ExpectTime(const EntryKernel
& entry_kernel
,
380 const base::Time
& expected_time
) {
381 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
382 expected_time
, entry_kernel
.ref(CTIME
));
383 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
384 expected_time
, entry_kernel
.ref(SERVER_CTIME
));
385 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
386 expected_time
, entry_kernel
.ref(MTIME
));
387 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
388 expected_time
, entry_kernel
.ref(SERVER_MTIME
));
391 // Expect that all the entries in |entries| have times matching those in
392 // the given map (from metahandle to expect time).
393 void ExpectTimes(const Directory::MetahandlesMap
& handles_map
,
394 const std::map
<int64
, base::Time
>& expected_times
) {
395 for (Directory::MetahandlesMap::const_iterator it
= handles_map
.begin();
396 it
!= handles_map
.end(); ++it
) {
397 int64 meta_handle
= it
->first
;
398 SCOPED_TRACE(meta_handle
);
399 std::map
<int64
, base::Time
>::const_iterator it2
=
400 expected_times
.find(meta_handle
);
401 if (it2
== expected_times
.end()) {
402 ADD_FAILURE() << "Could not find expected time for " << meta_handle
;
405 ExpectTime(*it
->second
, it2
->second
);
411 void MigrationTest::SetUpVersion67Database(sql::Connection
* connection
) {
412 // This is a version 67 database dump whose contents were backformed from
413 // the contents of the version 68 database dump (the v68 migration was
414 // actually written first).
415 ASSERT_TRUE(connection
->is_open());
416 ASSERT_TRUE(connection
->BeginTransaction());
417 ASSERT_TRUE(connection
->Execute(
418 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
419 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
420 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
421 "base_version bigint default -1,server_version bigint default 0,"
422 "mtime bigint default 0,server_mtime bigint default 0,"
423 "ctime bigint default 0,server_ctime bigint default 0,"
424 "server_position_in_parent bigint default 0,"
425 "local_external_id bigint default 0,id varchar(255) default 'r',"
426 "parent_id varchar(255) default 'r',"
427 "server_parent_id varchar(255) default 'r',"
428 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
429 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
430 "is_del bit default 0,is_dir bit default 0,"
431 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
432 "server_is_del bit default 0,server_is_bookmark_object bit default 0,"
433 "name varchar(255), " /* COLLATE PATHNAME, */
434 "unsanitized_name varchar(255)," /* COLLATE PATHNAME, */
435 "non_unique_name varchar,"
436 "server_name varchar(255)," /* COLLATE PATHNAME */
437 "server_non_unique_name varchar,"
438 "bookmark_url varchar,server_bookmark_url varchar,"
439 "singleton_tag varchar,bookmark_favicon blob,"
440 "server_bookmark_favicon blob);"
441 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
442 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
443 "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);"
444 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
446 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
447 "'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',"
448 "'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA',"
450 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
452 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
453 "'Welcome to Chromium',NULL,'Welcome to Chromium',"
454 "'Welcome to Chromium','Welcome to Chromium',"
455 "'http://www.google.com/chrome/intl/en/welcome.html',"
456 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
458 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
460 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
461 "'Google',NULL,'Google','Google','Google','http://www.google.com/',"
462 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
463 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
465 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
466 "'The Internet',NULL,'The Internet','The Internet',"
467 "'The Internet',NULL,NULL,NULL,NULL,NULL);"
468 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
470 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
471 "'Google Chrome',NULL,'Google Chrome','Google Chrome',"
472 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);"
473 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
475 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
476 "NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,"
477 "'google_chrome_bookmarks',NULL,NULL);"
478 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
480 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
481 "1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',"
482 "NULL,NULL,'bookmark_bar',NULL,NULL);"
483 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
485 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
486 "'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',"
487 "'Other Bookmarks',NULL,NULL,'other_bookmarks',"
489 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
491 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
492 "'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',"
493 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
494 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
495 "'AGATWA','AFAGVASF');"
496 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
498 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
499 "'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',"
500 "'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
501 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
503 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
504 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
505 "'ICANN Internet Corporation for Assigned Names and Numbers',"
506 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
507 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
508 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
509 "'http://www.icann.com/','http://www.icann.com/',NULL,"
510 "'PNGAXF0AAFF','DAAFASF');"
511 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
513 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
514 "'The WebKit Open Source Project',NULL,"
515 "'The WebKit Open Source Project','The WebKit Open Source Project',"
516 "'The WebKit Open Source Project','http://webkit.org/',"
517 "'http://webkit.org/x',NULL,'PNGX','PNG2Y');"
518 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
519 "last_sync_timestamp INT, name VARCHAR(128), "
520 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
521 "db_create_version VARCHAR(128), db_create_time int, "
522 "next_id bigint default -2, cache_guid VARCHAR(32));"
523 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
524 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
525 "'Unknown',1263522064,-65542,"
526 "'9010788312004066376x-6609234393368420856x');"
527 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
528 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
529 ASSERT_TRUE(connection
->CommitTransaction());
532 void MigrationTest::SetUpVersion68Database(sql::Connection
* connection
) {
533 // This sets up an actual version 68 database dump. The IDs were
534 // canonicalized to be less huge, and the favicons were overwritten
535 // with random junk so that they didn't contain any unprintable
536 // characters. A few server URLs were tweaked so that they'd be
537 // different from the local URLs. Lastly, the custom collation on
538 // the server_non_unique_name column was removed.
539 ASSERT_TRUE(connection
->is_open());
540 ASSERT_TRUE(connection
->BeginTransaction());
541 ASSERT_TRUE(connection
->Execute(
542 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
543 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
544 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
545 "base_version bigint default -1,server_version bigint default 0,"
546 "mtime bigint default 0,server_mtime bigint default 0,"
547 "ctime bigint default 0,server_ctime bigint default 0,"
548 "server_position_in_parent bigint default 0,"
549 "local_external_id bigint default 0,id varchar(255) default 'r',"
550 "parent_id varchar(255) default 'r',"
551 "server_parent_id varchar(255) default 'r',"
552 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
553 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
554 "is_del bit default 0,is_dir bit default 0,"
555 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
556 "server_is_del bit default 0,"
557 "server_is_bookmark_object bit default 0,"
558 "non_unique_name varchar,server_non_unique_name varchar(255),"
559 "bookmark_url varchar,server_bookmark_url varchar,"
560 "singleton_tag varchar,bookmark_favicon blob,"
561 "server_bookmark_favicon blob);"
562 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
563 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
564 "NULL,NULL,NULL,NULL,NULL,NULL);"
565 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
567 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
568 "'Deleted Item','Deleted Item','http://www.google.com/',"
569 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');"
570 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
572 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
573 "'Welcome to Chromium','Welcome to Chromium',"
574 "'http://www.google.com/chrome/intl/en/welcome.html',"
575 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
577 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
579 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
580 "'Google','Google','http://www.google.com/',"
581 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
582 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
584 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
585 "'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);"
586 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
588 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
589 "'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL,"
591 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
593 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
594 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);"
595 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
597 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
598 "1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,"
600 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
602 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
603 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
605 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
607 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
608 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
609 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
610 "'AGATWA','AFAGVASF');"
611 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
613 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
614 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
615 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
617 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
618 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
619 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
620 "'http://www.icann.com/','http://www.icann.com/',NULL,"
621 "'PNGAXF0AAFF','DAAFASF');"
622 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
624 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
625 "'The WebKit Open Source Project','The WebKit Open Source Project',"
626 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');"
627 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
628 "last_sync_timestamp INT, name VARCHAR(128), "
629 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
630 "db_create_version VARCHAR(128), db_create_time int, "
631 "next_id bigint default -2, cache_guid VARCHAR(32));"
632 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
633 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
634 "'Unknown',1263522064,-65542,"
635 "'9010788312004066376x-6609234393368420856x');"
636 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
637 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
638 ASSERT_TRUE(connection
->CommitTransaction());
641 void MigrationTest::SetUpVersion69Database(sql::Connection
* connection
) {
642 ASSERT_TRUE(connection
->is_open());
643 ASSERT_TRUE(connection
->BeginTransaction());
644 ASSERT_TRUE(connection
->Execute(
645 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
646 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
647 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
648 "base_version bigint default -1,server_version bigint default 0,"
649 "mtime bigint default 0,server_mtime bigint default 0,"
650 "ctime bigint default 0,server_ctime bigint default 0,"
651 "server_position_in_parent bigint default 0,"
652 "local_external_id bigint default 0,id varchar(255) default 'r',"
653 "parent_id varchar(255) default 'r',"
654 "server_parent_id varchar(255) default 'r',"
655 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
656 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
657 "is_del bit default 0,is_dir bit default 0,"
658 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
659 "server_is_del bit default 0,"
660 "server_is_bookmark_object bit default 0,"
661 "non_unique_name varchar,server_non_unique_name varchar(255),"
662 "bookmark_url varchar,server_bookmark_url varchar,"
663 "singleton_tag varchar,bookmark_favicon blob,"
664 "server_bookmark_favicon blob, specifics blob, "
665 "server_specifics blob);"
666 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
667 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"
668 "NULL,NULL,X'',X'');"
669 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
671 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
672 "'Deleted Item','Deleted Item','http://www.google.com/',"
673 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG',"
674 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415"
675 "34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F"
676 "6D2F32120B4153414447414447414447');"
677 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
679 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
680 "'Welcome to Chromium','Welcome to Chromium',"
681 "'http://www.google.com/chrome/intl/en/welcome.html',"
682 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,NULL,"
683 "X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
684 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168"
685 "7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6"
686 "56E2F77656C636F6D652E68746D6C1200');"
687 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
689 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
690 "'Google','Google','http://www.google.com/',"
691 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166"
692 "87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'"
693 "C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464"
695 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
697 ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet',"
698 "'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');"
699 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
701 "'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome',"
702 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);"
703 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
705 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
706 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL,"
707 "X'C2881000',X'C2881000');"
708 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
710 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1,"
711 "'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL,"
712 "X'C2881000',X'C2881000');"
713 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
715 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
716 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
717 "NULL,NULL,X'C2881000',X'C2881000');"
718 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
720 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
721 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
722 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
723 "'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6"
724 "9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576"
725 "2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');"
726 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
728 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
729 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL,"
730 "X'C2881000',X'C2881000');"
731 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
733 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
734 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
735 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
736 "'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF',"
737 "'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"
738 "20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963"
739 "616E6E2E636F6D2F120744414146415346');"
740 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
742 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
743 "'The WebKit Open Source Project','The WebKit Open Source Project',"
744 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y',"
745 "X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C2"
746 "88101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259');"
747 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
748 "last_sync_timestamp INT, name VARCHAR(128), "
749 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
750 "db_create_version VARCHAR(128), db_create_time int, "
751 "next_id bigint default -2, cache_guid VARCHAR(32));"
752 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
753 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
754 "'Unknown',1263522064,-65542,"
755 "'9010788312004066376x-6609234393368420856x');"
756 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
757 "INSERT INTO share_version VALUES('nick@chromium.org',69);"
759 ASSERT_TRUE(connection
->CommitTransaction());
762 void MigrationTest::SetUpVersion70Database(sql::Connection
* connection
) {
763 ASSERT_TRUE(connection
->is_open());
764 ASSERT_TRUE(connection
->BeginTransaction());
765 ASSERT_TRUE(connection
->Execute(
766 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
767 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
768 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
769 "last_sync_timestamp INT, name VARCHAR(128), "
770 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
771 "db_create_version VARCHAR(128), db_create_time int, "
772 "next_id bigint default -2, cache_guid VARCHAR(32));"
773 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
774 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
775 "'Unknown',1263522064,-65542,"
776 "'9010788312004066376x-6609234393368420856x');"
777 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
778 "INSERT INTO share_version VALUES('nick@chromium.org',70);"
779 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
780 "base_version bigint default -1,server_version bigint default 0,"
781 "mtime bigint default 0,server_mtime bigint default 0,"
782 "ctime bigint default 0,server_ctime bigint default 0,"
783 "server_position_in_parent bigint default 0,"
784 "local_external_id bigint default 0,id varchar(255) default 'r',"
785 "parent_id varchar(255) default 'r',"
786 "server_parent_id varchar(255) default 'r',"
787 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
788 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
789 "is_del bit default 0,is_dir bit default 0,"
790 "server_is_dir bit default 0,server_is_del bit default 0,"
791 "non_unique_name varchar,server_non_unique_name varchar(255),"
792 "unique_server_tag varchar,unique_client_tag varchar,"
793 "specifics blob,server_specifics blob);"
794 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
795 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
796 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) ","
797 "-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,"
798 "1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A"
799 "2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026"
800 "0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741"
802 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
804 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
805 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A"
806 "31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74"
807 "6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F"
808 "2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
809 "6C636F6D652E68746D6C1200');"
810 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
812 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
813 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6"
814 "52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777"
815 "72E676F6F676C652E636F6D2F12084147464447415347');"
816 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
818 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
819 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
820 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
822 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome',"
823 "'Google Chrome','google_chrome',NULL,NULL,NULL);"
824 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
826 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
827 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',"
829 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
831 "1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,"
832 "'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',"
834 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
836 "2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
837 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
838 "X'C2881000',X'C2881000');"
839 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
841 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
842 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
843 "NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F"
844 "72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872"
845 "6F6D69756D2E6F72672F6F7468657212084146414756415346');"
846 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
848 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
849 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
851 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
853 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
854 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
855 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
856 "NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F"
857 "120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69"
858 "63616E6E2E636F6D2F120744414146415346');"
859 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
861 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
862 "'The WebKit Open Source Project','The WebKit Open Source Project',"
863 "NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
864 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F78120550"
867 ASSERT_TRUE(connection
->CommitTransaction());
870 void MigrationTest::SetUpVersion71Database(sql::Connection
* connection
) {
871 ASSERT_TRUE(connection
->is_open());
872 ASSERT_TRUE(connection
->BeginTransaction());
873 ASSERT_TRUE(connection
->Execute(
874 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
875 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
876 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
877 "INSERT INTO 'share_version' VALUES('nick@chromium.org',71);"
878 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
879 "base_version bigint default -1,server_version bigint default 0,"
880 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
881 "default 0,server_ctime bigint default 0,server_position_in_parent "
882 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
883 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
884 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
885 "varchar(255) default 'r',is_unsynced bit default 0,"
886 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
887 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
888 "non_unique_name varchar,server_non_unique_name varchar(255),"
889 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
890 "server_specifics blob);"
891 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
892 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
893 "NULL,NULL,X'',X'');"
894 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
896 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
897 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
898 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
899 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
901 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
903 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
904 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
905 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
906 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
907 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
908 "652E68746D6C1200');"
909 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
911 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
912 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
913 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
914 "76F6F676C652E636F6D2F12084147464447415347');"
915 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
917 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
918 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
919 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
921 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
922 ",'google_chrome',NULL,NULL,NULL);"
923 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
925 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
926 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
927 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
929 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
930 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
931 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
933 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
934 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
935 "X'C2881000',X'C2881000');"
936 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
938 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
939 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
940 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
941 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
942 "D2E6F72672F6F7468657212084146414756415346');"
943 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
945 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
946 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
948 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
950 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
951 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
952 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
953 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
954 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
955 "E636F6D2F120744414146415346');"
956 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
958 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
959 "'The WebKit Open Source Project','The WebKit Open Source Project',"
960 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
961 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
963 "CREATE TABLE models (model_id BLOB primary key, "
964 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
965 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
966 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
967 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
968 "next_id INT default -2, cache_guid TEXT);"
969 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
970 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
971 "'9010788312004066376x-6609234393368420856x');"));
972 ASSERT_TRUE(connection
->CommitTransaction());
975 void MigrationTest::SetUpVersion72Database(sql::Connection
* connection
) {
976 ASSERT_TRUE(connection
->is_open());
977 ASSERT_TRUE(connection
->BeginTransaction());
978 ASSERT_TRUE(connection
->Execute(
979 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
980 "INSERT INTO 'share_version' VALUES('nick@chromium.org',72);"
981 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
982 "base_version bigint default -1,server_version bigint default 0,"
983 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
984 "default 0,server_ctime bigint default 0,server_position_in_parent "
985 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
986 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
987 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
988 "varchar(255) default 'r',is_unsynced bit default 0,"
989 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
990 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
991 "non_unique_name varchar,server_non_unique_name varchar(255),"
992 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
993 "server_specifics blob);"
994 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
995 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
996 "NULL,NULL,X'',X'');"
997 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
999 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
1000 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
1001 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
1002 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
1004 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1006 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
1007 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
1008 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
1009 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
1010 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
1011 "652E68746D6C1200');"
1012 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1014 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
1015 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
1016 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
1017 "76F6F676C652E636F6D2F12084147464447415347');"
1018 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1020 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
1021 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
1022 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1024 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1025 ",'google_chrome',NULL,NULL,NULL);"
1026 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1028 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1029 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1030 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1032 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1033 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1034 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1036 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1037 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1038 "X'C2881000',X'C2881000');"
1039 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1041 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1042 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1043 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1044 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1045 "D2E6F72672F6F7468657212084146414756415346');"
1046 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1048 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1049 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1051 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1053 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1054 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1055 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1056 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1057 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1058 "E636F6D2F120744414146415346');"
1059 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1061 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1062 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1063 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1064 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1066 "CREATE TABLE models (model_id BLOB primary key, "
1067 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1068 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1069 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1070 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1071 "next_id INT default -2, cache_guid TEXT);"
1072 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1073 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1074 "'9010788312004066376x-6609234393368420856x');"));
1075 ASSERT_TRUE(connection
->CommitTransaction());
1078 void MigrationTest::SetUpVersion73Database(sql::Connection
* connection
) {
1079 ASSERT_TRUE(connection
->is_open());
1080 ASSERT_TRUE(connection
->BeginTransaction());
1081 ASSERT_TRUE(connection
->Execute(
1082 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1083 "INSERT INTO 'share_version' VALUES('nick@chromium.org',73);"
1084 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
1085 "base_version bigint default -1,server_version bigint default 0,"
1086 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
1087 "default 0,server_ctime bigint default 0,server_position_in_parent "
1088 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
1089 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
1090 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
1091 "varchar(255) default 'r',is_unsynced bit default 0,"
1092 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
1093 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
1094 "non_unique_name varchar,server_non_unique_name varchar(255),"
1095 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
1096 "server_specifics blob);"
1097 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1098 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
1099 "NULL,NULL,X'',X'');"
1100 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1102 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
1103 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
1104 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
1105 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
1107 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1109 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
1110 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
1111 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
1112 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
1113 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
1114 "652E68746D6C1200');"
1115 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1117 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
1118 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
1119 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
1120 "76F6F676C652E636F6D2F12084147464447415347');"
1121 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1123 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
1124 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
1125 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1127 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1128 ",'google_chrome',NULL,NULL,NULL);"
1129 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1131 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1132 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1133 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1135 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1136 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1137 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1139 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1140 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1141 "X'C2881000',X'C2881000');"
1142 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1144 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1145 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1146 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1147 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1148 "D2E6F72672F6F7468657212084146414756415346');"
1149 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1151 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1152 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1154 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1156 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1157 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1158 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1159 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1160 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1161 "E636F6D2F120744414146415346');"
1162 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1164 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1165 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1166 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1167 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1169 "CREATE TABLE models (model_id BLOB primary key, "
1170 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1171 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1172 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1173 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1174 "next_id INT default -2, cache_guid TEXT, "
1175 "notification_state BLOB);"
1176 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1177 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1178 "'9010788312004066376x-6609234393368420856x',X'C2881000');"));
1179 ASSERT_TRUE(connection
->CommitTransaction());
1182 void MigrationTest::SetUpVersion74Database(sql::Connection
* connection
) {
1183 ASSERT_TRUE(connection
->is_open());
1184 ASSERT_TRUE(connection
->BeginTransaction());
1185 ASSERT_TRUE(connection
->Execute(
1186 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1187 "INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"
1188 "CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"
1189 " INT, initial_sync_ended BOOLEAN default 0);"
1190 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1191 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1192 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1193 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1194 "tion_state INT default 0, bookmarks_added_during_autofill_migration"
1195 " INT default 0, autofill_migration_time INT default 0, autofill_ent"
1196 "ries_added_during_migration INT default 0, autofill_profiles_added_"
1197 "during_migration INT default 0);"
1198 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"
1199 ",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"
1200 ",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1201 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"
1202 "e_version bigint default -1,server_version bigint default 0,mtime b"
1203 "igint default 0,server_mtime bigint default 0,ctime bigint default "
1204 "0,server_ctime bigint default 0,server_position_in_parent bigint de"
1205 "fault 0,local_external_id bigint default 0,id varchar(255) default "
1206 "'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"
1207 ") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"
1208 " default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"
1209 "ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"
1210 "efault 0,server_is_del bit default 0,non_unique_name varchar,server"
1211 "_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"
1212 "nt_tag varchar,specifics blob,server_specifics blob);"
1213 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1214 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"
1216 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1217 ",-2097152,4,'s_ID_2','s_ID"
1218 "_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "
1219 "Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1220 "36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"
1221 "6F6F676C652E636F6D2F32120B4153414447414447414447');"
1222 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1223 ",-3145728,3,'s_ID_4','s_ID"
1224 "_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"
1225 "elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"
1226 "76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"
1227 "68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"
1228 "F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1229 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1230 ",1048576,7,'s_ID_5','s_ID_"
1231 "9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"
1232 "LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"
1233 "47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1234 "36F6D2F12084147464447415347');"
1235 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1236 ",-4194304,6,'s_ID_6','s_ID"
1237 "_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"
1238 ",NULL,X'C2881000',X'C2881000');"
1239 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1240 ",1048576,0,'s_ID_7','r','r"
1241 "','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"
1242 "e',NULL,NULL,NULL);"
1243 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1244 ",1048576,0,'s_ID_8','s_ID_"
1245 "7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"
1246 "ome_bookmarks',NULL,X'C2881000',X'C2881000');"
1247 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1248 ",1048576,1,'s_ID_9','s_ID_"
1249 "8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
1250 ",'bookmark_bar',NULL,X'C2881000',X'C2881000');"
1251 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1252 ",2097152,2,'s_ID_10','s_I"
1253 "D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
1254 "kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1255 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1256 ",-1048576,8,'s_ID_11','s_"
1257 "ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"
1258 "ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"
1259 "03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"
1260 "290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"
1261 "84146414756415346');"
1262 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1263 ",0,9,'s_ID_12','s_ID_6','"
1264 "s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"
1265 "okmarks',NULL,NULL,X'C2881000',X'C2881000');"
1266 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1267 ",-917504,10,'s_ID_13','s_"
1268 "ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"
1269 "rporation for Assigned Names and Numbers','ICANN | Internet Corpora"
1270 "tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"
1271 "703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"
1272 "28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"
1274 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1275 ",1048576,11,'s_ID_14','s_"
1276 "ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"
1277 "oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"
1278 "474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"
1279 "703A2F2F7765626B69742E6F72672F781205504E473259');"
1281 ASSERT_TRUE(connection
->CommitTransaction());
1284 void MigrationTest::SetUpVersion75Database(sql::Connection
* connection
) {
1285 ASSERT_TRUE(connection
->is_open());
1286 ASSERT_TRUE(connection
->BeginTransaction());
1287 ASSERT_TRUE(connection
->Execute(
1288 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1289 "INSERT INTO 'share_version' VALUES('nick@chromium.org',75);"
1290 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1291 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1292 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1293 "tion_state INT default 0,bookmarks_added_during_autofill_migration "
1294 "INT default 0, autofill_migration_time INT default 0, autofill_entr"
1295 "ies_added_during_migration INT default 0, autofill_profiles_added_d"
1296 "uring_migration INT default 0);"
1297 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org"
1298 "','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-655"
1299 "42,'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1300 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
1301 "initial_sync_ended BOOLEAN default 0);"
1302 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1303 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,ba"
1304 "se_version bigint default -1,server_version bigint default 0,mtime"
1305 " bigint default 0,server_mtime bigint default 0,ctime bigint defau"
1306 "lt 0,server_ctime bigint default 0,server_position_in_parent bigin"
1307 "t default 0,local_external_id bigint default 0,id varchar(255) def"
1308 "ault 'r',parent_id varchar(255) default 'r',server_parent_id varch"
1309 "ar(255) default 'r',prev_id varchar(255) default 'r',next_id varch"
1310 "ar(255) default 'r',is_unsynced bit default 0,is_unapplied_update "
1311 "bit default 0,is_del bit default 0,is_dir bit default 0,server_is_"
1312 "dir bit default 0,server_is_del bit default 0,non_unique_name varc"
1313 "har,server_non_unique_name varchar(255),unique_server_tag varchar,"
1314 "unique_client_tag varchar,specifics blob,server_specifics blob);"
1315 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1316 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"
1318 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1319 ",-2097152,4,'s_ID_"
1320 "2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite"
1321 "m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772"
1322 "E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874"
1323 "74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474"
1325 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1326 ",-3145728,3,'s_ID_"
1327 "4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to "
1328 "Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747"
1329 "03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65"
1330 "6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7"
1331 "777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
1332 "6C636F6D652E68746D6C1200');"
1333 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1334 ",1048576,7,'s_ID_5"
1335 "','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo"
1336 "gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65"
1337 "2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777"
1338 "7772E676F6F676C652E636F6D2F12084147464447415347');"
1339 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1340 ",-4194304,6,'s_ID_"
1341 "6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In"
1342 "ternet',NULL,NULL,X'C2881000',X'C2881000');"
1343 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1344 ",1048576,0,'s_ID_7"
1345 "','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','"
1346 "google_chrome',NULL,NULL,NULL);"
1347 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1348 ",1048576,0,'s_ID_8"
1349 "','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'"
1350 ",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1351 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1352 ",1048576,1,'s_ID_9"
1353 "','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B"
1354 "ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1355 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1357 "10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks"
1358 "','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810"
1360 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1362 "_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr"
1363 "omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28"
1364 "810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641"
1365 "4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1366 "D2E6F72672F6F7468657212084146414756415346');"
1367 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1369 "_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark"
1370 "s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');"
1371 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1373 "_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |"
1374 " Internet Corporation for Assigned Names and Numbers','ICANN | "
1375 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,"
1376 "X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1377 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361"
1378 "6E6E2E636F6D2F120744414146415346');"
1379 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1381 "_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op"
1382 "en Source Project','The WebKit Open Source Project',NULL,NULL,X"
1383 "'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',"
1384 "X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473"
1387 ASSERT_TRUE(connection
->CommitTransaction());
1390 void MigrationTest::SetUpVersion76Database(sql::Connection
* connection
) {
1391 ASSERT_TRUE(connection
->is_open());
1392 ASSERT_TRUE(connection
->BeginTransaction());
1393 ASSERT_TRUE(connection
->Execute(
1394 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1395 "INSERT INTO 'share_version' VALUES('nick@chromium.org',76);"
1396 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1397 "itial_sync_ended BOOLEAN default 0);"
1398 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1399 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1400 "_version bigint default -1,server_version bigint default 0,mtime big"
1401 "int default 0,server_mtime bigint default 0,ctime bigint default 0,s"
1402 "erver_ctime bigint default 0,server_position_in_parent bigint defaul"
1403 "t 0,local_external_id bigint default 0,id varchar(255) default 'r',p"
1404 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1405 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1406 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1407 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1408 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1409 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1410 "har,specifics blob,server_specifics blob);"
1411 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1412 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')"
1414 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1415 ",-2097152,4,'s_ID_2','s_ID_9"
1416 "','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite"
1417 "m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6"
1418 "D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6"
1419 "76C652E636F6D2F32120B4153414447414447414447');"
1420 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1421 ",-3145728,3,'s_ID_4','s_ID_9"
1422 "','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc"
1423 "ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6"
1424 "F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746"
1425 "D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6"
1426 "368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1427 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1428 ",1048576,7,'s_ID_5','s_ID_9'"
1429 ",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL,"
1430 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741"
1431 "5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D"
1432 "2F12084147464447415347');"
1433 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1434 ",-4194304,6,'s_ID_6','s_ID_9"
1435 "','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU"
1436 "LL,X'C2881000',X'C2881000');"
1437 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1438 ",1048576,0,'s_ID_7','r','r',"
1439 "'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome',"
1441 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1442 ",1048576,0,'s_ID_8','s_ID_7'"
1443 ",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome"
1444 "_bookmarks',NULL,X'C2881000',X'C2881000');"
1445 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1446 ",1048576,1,'s_ID_9','s_ID_8'"
1447 ",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b"
1448 "ookmark_bar',NULL,X'C2881000',X'C2881000');"
1449 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1450 ",2097152,2,'s_ID_10','s_ID_"
1451 "8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma"
1452 "rks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1453 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1454 ",-1048576,8,'s_ID_11','s_ID"
1455 "_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)"
1456 "','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2"
1457 "F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1"
1458 "D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464"
1460 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1461 ",0,9,'s_ID_12','s_ID_6','s_"
1462 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1463 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1464 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1465 ",-917504,10,'s_ID_13','s_ID"
1466 "_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo"
1467 "ration for Assigned Names and Numbers','ICANN | Internet Corporation"
1468 " for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2"
1469 "F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102"
1470 "00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');"
1471 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1472 ",1048576,11,'s_ID_14','s_ID"
1473 "_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje"
1474 "ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747"
1475 "03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2"
1476 "F2F7765626B69742E6F72672F781205504E473259');"
1477 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1478 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1479 "ult -2, cache_guid TEXT , notification_state BLOB);"
1480 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1481 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1482 "9010788312004066376x-6609234393368420856x',NULL);"
1484 ASSERT_TRUE(connection
->CommitTransaction());
1487 void MigrationTest::SetUpVersion77Database(sql::Connection
* connection
) {
1488 ASSERT_TRUE(connection
->is_open());
1489 ASSERT_TRUE(connection
->BeginTransaction());
1490 ASSERT_TRUE(connection
->Execute(
1491 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1492 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);"
1493 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1494 "itial_sync_ended BOOLEAN default 0);"
1495 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1496 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1497 "_version bigint default -1,server_version bigint default 0,server_po"
1498 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1499 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1500 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1501 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1502 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1503 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1504 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1505 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1506 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1507 "har,specifics blob,server_specifics blob);"
1508 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1)
1509 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
1510 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1511 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1512 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1513 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1514 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1515 "14447414447414447');"
1516 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1517 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1518 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1519 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1520 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1521 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1522 "E2F77656C636F6D652E68746D6C1200');"
1523 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5)
1524 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','"
1525 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E"
1526 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67"
1527 "6F6F676C652E636F6D2F12084147464447415347');"
1528 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1529 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1530 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1532 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7)
1533 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo"
1534 "gle Chrome','google_chrome',NULL,NULL,NULL);"
1535 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8)
1536 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar"
1537 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1538 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9)
1539 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'"
1540 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1541 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1542 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1543 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1544 "LL,X'C2881000',X'C2881000');"
1545 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1546 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1547 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1548 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1549 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1550 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');"
1551 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12)
1552 ",'s_ID_12','s_ID_6','s_"
1553 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1554 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1555 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1556 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1557 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1558 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1559 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1560 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1561 "E6963616E6E2E636F6D2F120744414146415346');"
1562 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1563 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1564 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1565 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1566 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1567 "81205504E473259');"
1568 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1569 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1570 "ult -2, cache_guid TEXT , notification_state BLOB);"
1571 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1572 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1573 "9010788312004066376x-6609234393368420856x',NULL);"
1575 ASSERT_TRUE(connection
->CommitTransaction());
1578 void MigrationTest::SetUpVersion78Database(sql::Connection
* connection
) {
1579 ASSERT_TRUE(connection
->is_open());
1580 ASSERT_TRUE(connection
->BeginTransaction());
1581 ASSERT_TRUE(connection
->Execute(
1582 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1583 "INSERT INTO 'share_version' VALUES('nick@chromium.org',78);"
1584 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1585 "itial_sync_ended BOOLEAN default 0);"
1586 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1587 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1588 "_version bigint default -1,server_version bigint default 0,server_po"
1589 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1590 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1591 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1592 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1593 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1594 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1595 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1596 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1597 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1598 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1600 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1601 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1602 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1603 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1604 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1605 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1606 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1607 "14447414447414447',NULL);"
1608 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1609 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1610 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1611 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1612 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1613 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1614 "E2F77656C636F6D652E68746D6C1200',NULL);"
1615 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1616 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1617 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1618 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1619 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1621 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1622 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1623 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1625 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1626 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1627 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1628 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1629 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1630 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1631 "00',X'C2881000',NULL);"
1632 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1633 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1634 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1635 "000',X'C2881000',NULL);"
1636 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1637 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1638 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1639 "LL,X'C2881000',X'C2881000',NULL);"
1640 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1641 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1642 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1643 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1644 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1645 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1646 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1647 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1648 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1649 "2881000',X'C2881000',NULL);"
1650 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1651 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1652 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1653 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1654 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1655 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1656 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1657 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1658 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1659 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1660 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1661 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1662 "81205504E473259',NULL);"
1663 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1664 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1665 "ult -2, cache_guid TEXT , notification_state BLOB);"
1666 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1667 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1668 "9010788312004066376x-6609234393368420856x',NULL);"
1670 ASSERT_TRUE(connection
->CommitTransaction());
1673 void MigrationTest::SetUpVersion79Database(sql::Connection
* connection
) {
1674 ASSERT_TRUE(connection
->is_open());
1675 ASSERT_TRUE(connection
->BeginTransaction());
1676 ASSERT_TRUE(connection
->Execute(
1677 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1678 "INSERT INTO 'share_version' VALUES('nick@chromium.org',79);"
1679 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1680 "itial_sync_ended BOOLEAN default 0);"
1681 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1682 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1683 "_version bigint default -1,server_version bigint default 0,server_po"
1684 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1685 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1686 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1687 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1688 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1689 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1690 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1691 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1692 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1693 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1695 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1696 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1697 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1698 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1699 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1700 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1701 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1702 "14447414447414447',NULL);"
1703 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1704 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1705 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1706 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1707 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1708 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1709 "E2F77656C636F6D652E68746D6C1200',NULL);"
1710 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1711 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1712 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1713 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1714 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1716 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1717 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1718 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1720 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1721 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1722 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1723 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1724 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1725 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1726 "00',X'C2881000',NULL);"
1727 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1728 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1729 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1730 "000',X'C2881000',NULL);"
1731 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1732 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1733 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1734 "LL,X'C2881000',X'C2881000',NULL);"
1735 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1736 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1737 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1738 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1739 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1740 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1741 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1742 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1743 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1744 "2881000',X'C2881000',NULL);"
1745 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1746 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1747 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1748 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1749 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1750 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1751 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1752 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1753 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1754 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1755 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1756 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1757 "81205504E473259',NULL);"
1758 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1759 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1760 "ult -2, cache_guid TEXT , notification_state BLOB);"
1761 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1762 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1763 "-131078,'9010788312004066376x-6609234393368420856x',NULL);"
1765 ASSERT_TRUE(connection
->CommitTransaction());
1768 void MigrationTest::SetUpVersion80Database(sql::Connection
* connection
) {
1769 ASSERT_TRUE(connection
->is_open());
1770 ASSERT_TRUE(connection
->BeginTransaction());
1771 ASSERT_TRUE(connection
->Execute(
1772 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1773 "INSERT INTO 'share_version' VALUES('nick@chromium.org',80);"
1774 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1775 "itial_sync_ended BOOLEAN default 0);"
1776 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1777 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1778 "_version bigint default -1,server_version bigint default 0,server_po"
1779 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1780 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1781 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1782 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1783 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1784 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1785 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1786 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1787 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1788 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1790 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1791 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1792 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1793 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1794 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1795 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1796 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1797 "14447414447414447',NULL);"
1798 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1799 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1800 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1801 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1802 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1803 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1804 "E2F77656C636F6D652E68746D6C1200',NULL);"
1805 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1806 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1807 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1808 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1809 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1811 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1812 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1813 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1815 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1816 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1817 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1818 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1819 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1820 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1821 "00',X'C2881000',NULL);"
1822 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1823 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1824 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1825 "000',X'C2881000',NULL);"
1826 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1827 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1828 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1829 "LL,X'C2881000',X'C2881000',NULL);"
1830 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1831 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1832 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1833 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1834 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1835 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1836 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1837 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1838 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1839 "2881000',X'C2881000',NULL);"
1840 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1841 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1842 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1843 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1844 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1845 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1846 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1847 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1848 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1849 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1850 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1851 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1852 "81205504E473259',NULL);"
1853 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1854 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1855 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1857 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1858 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1859 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"
1861 ASSERT_TRUE(connection
->CommitTransaction());
1865 // Helper definitions to create the version 81 DB tables.
1868 const int V80_ROW_COUNT
= 13;
1869 const int64 V80_POSITIONS
[V80_ROW_COUNT
] = {
1885 std::string
V81_Ordinal(int n
) {
1886 return Int64ToNodeOrdinal(V80_POSITIONS
[n
]).ToInternalValue();
1891 // Unlike the earlier versions, the rows for version 81 are generated
1892 // programmatically to accurately handle unprintable characters for the
1893 // server_ordinal_in_parent field.
1894 void MigrationTest::SetUpVersion81Database(sql::Connection
* connection
) {
1895 ASSERT_TRUE(connection
->is_open());
1896 ASSERT_TRUE(connection
->BeginTransaction());
1897 ASSERT_TRUE(connection
->Execute(
1898 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1899 "INSERT INTO 'share_version' VALUES('nick@chromium.org',81);"
1900 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1901 "itial_sync_ended BOOLEAN default 0);"
1902 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1903 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1904 "_version bigint default -1,server_version bigint default 0, "
1905 "local_external_id bigint default 0"
1906 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1907 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1908 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1909 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1910 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1911 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1912 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1913 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1914 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1915 ", server_ordinal_in_parent blob);"
1916 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1917 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1918 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1920 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1921 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1922 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
1924 const char* insert_stmts
[V80_ROW_COUNT
] = {
1925 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1926 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
1927 "INSERT INTO 'metas' VALUES(2,669,669,4,"
1928 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1929 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1930 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1931 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1932 "14447414447414447',NULL,?);",
1933 "INSERT INTO 'metas' VALUES(4,681,681,3,"
1934 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1935 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1936 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1937 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1938 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1939 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
1940 "INSERT INTO 'metas' VALUES(5,677,677,7,"
1941 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1942 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1943 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1944 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1946 "INSERT INTO 'metas' VALUES(6,694,694,6,"
1947 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1948 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1950 "INSERT INTO 'metas' VALUES(7,663,663,0,"
1951 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1952 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
1953 "INSERT INTO 'metas' VALUES(8,664,664,0,"
1954 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1955 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1956 "00',X'C2881000',NULL,?);",
1957 "INSERT INTO 'metas' VALUES(9,665,665,1,"
1958 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1959 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1960 "000',X'C2881000',NULL,?);",
1961 "INSERT INTO 'metas' VALUES(10,666,666,2,"
1962 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1963 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1964 "LL,X'C2881000',X'C2881000',NULL,?);",
1965 "INSERT INTO 'metas' VALUES(11,683,683,8,"
1966 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1967 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1968 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1969 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1970 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
1971 "INSERT INTO 'metas' VALUES(12,685,685,9,"
1972 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1973 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1974 "2881000',X'C2881000',NULL,?);",
1975 "INSERT INTO 'metas' VALUES(13,687,687,10,"
1976 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1977 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1978 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1979 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1980 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1981 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
1982 "INSERT INTO 'metas' VALUES(14,692,692,11,"
1983 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1984 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1985 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1986 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1987 "81205504E473259',NULL,?);" };
1989 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
1990 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
1991 std::string ord
= V81_Ordinal(i
);
1992 s
.BindBlob(0, ord
.data(), ord
.length());
1993 ASSERT_TRUE(s
.Run());
1996 ASSERT_TRUE(connection
->CommitTransaction());
1999 void MigrationTest::SetUpVersion82Database(sql::Connection
* connection
) {
2000 ASSERT_TRUE(connection
->is_open());
2001 ASSERT_TRUE(connection
->BeginTransaction());
2002 ASSERT_TRUE(connection
->Execute(
2003 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2004 "INSERT INTO 'share_version' VALUES('nick@chromium.org',82);"
2005 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2006 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2008 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2009 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2010 "_version bigint default -1,server_version bigint default 0, "
2011 "local_external_id bigint default 0"
2012 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2013 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2014 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2015 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2016 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2017 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2018 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2019 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2020 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2021 ", server_ordinal_in_parent blob);"
2022 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2023 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2024 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2026 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2027 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2028 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2030 const char* insert_stmts
[V80_ROW_COUNT
] = {
2031 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2032 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
2033 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2034 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2035 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2036 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2037 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2038 "14447414447414447',NULL,?);",
2039 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2040 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2041 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2042 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2043 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2044 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2045 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
2046 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2047 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2048 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2049 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2050 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2052 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2053 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2054 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2056 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2057 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2058 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
2059 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2060 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2061 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2062 "00',X'C2881000',NULL,?);",
2063 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2064 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2065 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2066 "000',X'C2881000',NULL,?);",
2067 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2068 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2069 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2070 "LL,X'C2881000',X'C2881000',NULL,?);",
2071 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2072 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2073 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2074 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2075 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2076 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
2077 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2078 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2079 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2080 "2881000',X'C2881000',NULL,?);",
2081 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2082 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2083 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2084 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2085 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2086 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2087 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
2088 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2089 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2090 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2091 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2092 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2093 "81205504E473259',NULL,?);" };
2095 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2096 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2097 std::string ord
= V81_Ordinal(i
);
2098 s
.BindBlob(0, ord
.data(), ord
.length());
2099 ASSERT_TRUE(s
.Run());
2102 ASSERT_TRUE(connection
->CommitTransaction());
2105 void MigrationTest::SetUpVersion83Database(sql::Connection
* connection
) {
2106 ASSERT_TRUE(connection
->is_open());
2107 ASSERT_TRUE(connection
->BeginTransaction());
2108 ASSERT_TRUE(connection
->Execute(
2109 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2110 "INSERT INTO 'share_version' VALUES('nick@chromium.org',83);"
2111 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2112 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2114 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2115 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2116 "_version bigint default -1,server_version bigint default 0, "
2117 "local_external_id bigint default 0"
2118 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2119 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2120 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2121 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2122 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2123 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2124 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2125 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2126 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2127 ", server_ordinal_in_parent blob, transaction_version bigint default "
2129 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2130 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2131 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2133 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2134 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2135 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2137 const char* insert_stmts
[V80_ROW_COUNT
] = {
2138 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2139 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2140 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2141 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2142 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2143 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2144 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2145 "14447414447414447',NULL,?,0);",
2146 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2147 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2148 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2149 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2150 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2151 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2152 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2153 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2154 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2155 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2156 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2157 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2159 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2160 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2161 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2163 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2164 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2165 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2167 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2168 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2169 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2170 "00',X'C2881000',NULL,?,0);",
2171 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2172 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2173 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2174 "000',X'C2881000',NULL,?,0);",
2175 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2176 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2177 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2178 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2179 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2180 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2181 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2182 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2183 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2184 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2185 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2186 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2187 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2188 "2881000',X'C2881000',NULL,?,0);",
2189 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2190 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2191 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2192 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2193 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2194 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2195 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2196 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2197 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2198 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2199 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2200 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2201 "81205504E473259',NULL,?,0);" };
2203 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2204 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2205 std::string ord
= V81_Ordinal(i
);
2206 s
.BindBlob(0, ord
.data(), ord
.length());
2207 ASSERT_TRUE(s
.Run());
2210 ASSERT_TRUE(connection
->CommitTransaction());
2213 void MigrationTest::SetUpVersion84Database(sql::Connection
* connection
) {
2214 ASSERT_TRUE(connection
->is_open());
2215 ASSERT_TRUE(connection
->BeginTransaction());
2216 ASSERT_TRUE(connection
->Execute(
2217 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2218 "INSERT INTO 'share_version' VALUES('nick@chromium.org',84);"
2219 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2220 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2222 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2223 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2224 "_version bigint default -1,server_version bigint default 0, "
2225 "local_external_id bigint default 0"
2226 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2227 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2228 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2229 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2230 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2231 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2232 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2233 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2234 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2235 ", server_ordinal_in_parent blob, transaction_version bigint default "
2237 "CREATE TABLE 'deleted_metas'"
2238 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2239 "_version bigint default -1,server_version bigint default 0, "
2240 "local_external_id bigint default 0"
2241 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2242 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2243 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2244 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2245 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2246 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2247 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2248 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2249 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2250 ", server_ordinal_in_parent blob, transaction_version bigint default "
2252 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2253 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2254 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2256 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2257 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2258 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2260 const char* insert_stmts
[V80_ROW_COUNT
] = {
2261 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2262 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2263 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2264 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2265 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2266 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2267 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2268 "14447414447414447',NULL,?,0);",
2269 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2270 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2271 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2272 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2273 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2274 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2275 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2276 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2277 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2278 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2279 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2280 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2282 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2283 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2284 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2286 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2287 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2288 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2290 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2291 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2292 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2293 "00',X'C2881000',NULL,?,0);",
2294 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2295 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2296 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2297 "000',X'C2881000',NULL,?,0);",
2298 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2299 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2300 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2301 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2302 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2303 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2304 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2305 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2306 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2307 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2308 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2309 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2310 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2311 "2881000',X'C2881000',NULL,?,0);",
2312 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2313 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2314 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2315 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2316 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2317 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2318 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2319 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2320 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2321 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2322 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2323 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2324 "81205504E473259',NULL,?,0);" };
2326 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2327 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2328 std::string ord
= V81_Ordinal(i
);
2329 s
.BindBlob(0, ord
.data(), ord
.length());
2330 ASSERT_TRUE(s
.Run());
2333 ASSERT_TRUE(connection
->CommitTransaction());
2336 void MigrationTest::SetUpVersion85Database(sql::Connection
* connection
) {
2337 ASSERT_TRUE(connection
->is_open());
2338 ASSERT_TRUE(connection
->BeginTransaction());
2339 ASSERT_TRUE(connection
->Execute(
2340 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2341 "INSERT INTO 'share_version' VALUES('nick@chromium.org',85);"
2342 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
2343 "transaction_version BIGINT default 0);"
2344 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605', 1);"
2345 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2346 "_version bigint default -1,server_version bigint default 0, "
2347 "local_external_id bigint default 0"
2348 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2349 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2350 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2351 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2352 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2353 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2354 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2355 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2356 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2357 ", server_ordinal_in_parent blob, transaction_version bigint default "
2359 "CREATE TABLE 'deleted_metas'"
2360 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2361 "_version bigint default -1,server_version bigint default 0, "
2362 "local_external_id bigint default 0"
2363 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2364 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2365 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2366 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2367 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2368 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2369 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2370 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2371 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2372 ", server_ordinal_in_parent blob, transaction_version bigint default "
2374 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2375 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2376 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2378 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2379 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2380 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2382 const char* insert_stmts
[V80_ROW_COUNT
] = {
2383 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2384 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2385 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2386 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2387 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2388 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2389 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2390 "14447414447414447',NULL,?,0);",
2391 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2392 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2393 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2394 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2395 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2396 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2397 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2398 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2399 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2400 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2401 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2402 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2404 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2405 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2406 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2408 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2409 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2410 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2412 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2413 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2414 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2415 "00',X'C2881000',NULL,?,0);",
2416 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2417 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2418 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2419 "000',X'C2881000',NULL,?,0);",
2420 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2421 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2422 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2423 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2424 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2425 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2426 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2427 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2428 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2429 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2430 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2431 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2432 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2433 "2881000',X'C2881000',NULL,?,0);",
2434 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2435 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2436 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2437 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2438 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2439 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2440 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2441 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2442 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2443 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2444 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2445 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2446 "81205504E473259',NULL,?,0);" };
2448 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2449 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2450 std::string ord
= V81_Ordinal(i
);
2451 s
.BindBlob(0, ord
.data(), ord
.length());
2452 ASSERT_TRUE(s
.Run());
2455 ASSERT_TRUE(connection
->CommitTransaction());
2458 void MigrationTest::SetUpVersion86Database(sql::Connection
* connection
) {
2459 ASSERT_TRUE(connection
->is_open());
2460 ASSERT_TRUE(connection
->BeginTransaction());
2461 ASSERT_TRUE(connection
->Execute(
2462 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2463 "INSERT INTO 'share_version' VALUES('nick@chromium.org',86);"
2464 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2465 " transaction_version BIGINT default 0);"
2466 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2467 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,b"
2468 "ase_version bigint default -1,server_version bigint default 0,local_e"
2469 "xternal_id bigint default 0,transaction_version bigint default 0,mtim"
2470 "e bigint default 0,server_mtime bigint default 0,ctime bigint default"
2471 " 0,server_ctime bigint default 0,id varchar(255) default 'r',parent_i"
2472 "d varchar(255) default 'r',server_parent_id varchar(255) default 'r',"
2473 "is_unsynced bit default 0,is_unapplied_update bit default 0,is_del bi"
2474 "t default 0,is_dir bit default 0,server_is_dir bit default 0,server_i"
2475 "s_del bit default 0,non_unique_name varchar,server_non_unique_name va"
2476 "rchar(255),unique_server_tag varchar,unique_client_tag varchar,unique"
2477 "_bookmark_tag varchar,specifics blob,server_specifics blob,base_serve"
2478 "r_specifics blob,server_unique_position blob,unique_position blob);"
2479 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2480 META_PROTO_TIMES_VALS(1)
2481 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,"
2482 "X'',X'',X'',NULL,X'2200',X'2200');"
2483 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2484 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The"
2485 " Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D653"
2486 "273625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFF"
2487 "FFFC000006754307476346749735A5734654D653273625336557753582F77673D',X'"
2488 "22247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582"
2490 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2491 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome"
2492 "','Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2"
2494 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2495 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Boo"
2496 "kmarks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'"
2497 "C2881000',NULL,X'2200',X'2200');"
2498 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2499 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Boo"
2500 "kmark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C2881"
2501 "000',NULL,X'2200',X'2200');"
2502 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2503 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'O"
2504 "ther Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C28810"
2505 "00',X'C2881000',NULL,X'2200',X'2200');"
2506 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2507 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'H"
2508 "ome (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL"
2509 ",X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C28810"
2510 "220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641474154574"
2511 "1',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74"
2512 "68657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D"
2513 "623579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF00000505"
2514 "14C784A456D623579366267644237646A7A2B62314130346E493D');"
2515 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2516 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'E"
2517 "xtra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6"
2518 "F616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'222"
2519 "480000000000000007867626A704A646134635A6F616C376A49513338734B46324837"
2520 "773D',X'222480000000000000007867626A704A646134635A6F616C376A495133387"
2521 "34B46324837773D');"
2522 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2523 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2524 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2525 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2526 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2527 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2528 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2529 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2530 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2531 "4179672B304A614A514B3452384A413D');"
2532 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2533 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2534 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2535 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2536 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2537 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2538 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2539 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2540 "9552F6E644C553D');"
2541 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2542 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2543 "al_external_id bigint default 0,transaction_version bigint default 0,"
2544 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2545 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2546 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2547 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2548 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2549 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2550 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2551 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2552 "erver_specifics blob,server_unique_position blob,unique_position blob"
2554 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birt"
2555 "hday TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
2556 "fault -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB"
2558 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.or"
2559 "g','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-13107"
2560 "8,'9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2561 ASSERT_TRUE(connection
->CommitTransaction());
2564 void MigrationTest::SetUpVersion87Database(sql::Connection
* connection
) {
2565 ASSERT_TRUE(connection
->is_open());
2566 ASSERT_TRUE(connection
->BeginTransaction());
2567 ASSERT_TRUE(connection
->Execute(
2568 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2569 "INSERT INTO 'share_version' VALUES('nick@chromium.org',87);"
2570 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr"
2571 "ansaction_version BIGINT default 0);"
2572 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2573 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2574 "_version bigint default -1,server_version bigint default 0,local_exte"
2575 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2576 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2577 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2578 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2579 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2580 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2581 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2582 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2583 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2584 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2585 "ment_metadata blob);"
2586 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2587 META_PROTO_TIMES_VALS(1)
2588 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2589 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2590 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2591 META_PROTO_TIMES_VALS(6)
2592 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2593 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2594 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2595 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2596 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2598 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2599 META_PROTO_TIMES_VALS(7)
2600 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2601 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2603 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2604 META_PROTO_TIMES_VALS(8)
2605 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2606 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2607 "2881000',NULL,X'2200',X'2200',NULL);"
2608 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2609 META_PROTO_TIMES_VALS(9)
2610 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2611 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2612 "00',NULL,X'2200',X'2200',NULL);"
2613 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2614 META_PROTO_TIMES_VALS(10)
2615 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2616 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2617 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2618 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2619 META_PROTO_TIMES_VALS(11)
2620 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2621 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2622 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2623 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2624 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2625 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2626 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2627 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2628 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2629 META_PROTO_TIMES_VALS(12)
2630 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2631 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2632 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2633 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2634 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2635 "4B46324837773D',NULL);"
2636 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2637 META_PROTO_TIMES_VALS(13)
2638 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2639 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2640 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2641 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2642 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2643 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2644 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2645 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2646 "4179672B304A614A514B3452384A413D',NULL);"
2647 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2648 META_PROTO_TIMES_VALS(14)
2649 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2650 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2651 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2652 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2653 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2654 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2655 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2656 "9552F6E644C553D',NULL);"
2657 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2658 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2659 "al_external_id bigint default 0,transaction_version bigint default 0,"
2660 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2661 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2662 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2663 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2664 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2665 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2666 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2667 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2668 "erver_specifics blob,server_unique_position blob,unique_position blob"
2669 ",attachment_metadata blob);"
2670 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2671 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2672 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2673 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2674 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2675 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2676 ASSERT_TRUE(connection
->CommitTransaction());
2679 void MigrationTest::SetUpVersion88Database(sql::Connection
* connection
) {
2680 ASSERT_TRUE(connection
->is_open());
2681 ASSERT_TRUE(connection
->BeginTransaction());
2682 ASSERT_TRUE(connection
->Execute(
2683 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2684 "INSERT INTO 'share_version' VALUES('nick@chromium.org',88);"
2685 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2686 " transaction_version BIGINT default 0, context BLOB);"
2687 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
2688 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2689 "_version bigint default -1,server_version bigint default 0,local_exte"
2690 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2691 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2692 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2693 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2694 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2695 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2696 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2697 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2698 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2699 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2700 "ment_metadata blob);"
2701 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2702 META_PROTO_TIMES_VALS(1)
2703 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2704 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2705 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2706 META_PROTO_TIMES_VALS(6)
2707 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2708 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2709 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2710 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2711 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2713 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2714 META_PROTO_TIMES_VALS(7)
2715 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2716 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2718 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2719 META_PROTO_TIMES_VALS(8)
2720 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2721 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2722 "2881000',NULL,X'2200',X'2200',NULL);"
2723 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2724 META_PROTO_TIMES_VALS(9)
2725 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2726 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2727 "00',NULL,X'2200',X'2200',NULL);"
2728 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2729 META_PROTO_TIMES_VALS(10)
2730 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2731 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2732 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2733 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2734 META_PROTO_TIMES_VALS(11)
2735 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2736 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2737 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2738 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2739 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2740 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2741 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2742 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2743 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2744 META_PROTO_TIMES_VALS(12)
2745 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2746 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2747 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2748 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2749 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2750 "4B46324837773D',NULL);"
2751 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2752 META_PROTO_TIMES_VALS(13)
2753 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2754 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2755 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2756 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2757 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2758 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2759 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2760 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2761 "4179672B304A614A514B3452384A413D',NULL);"
2762 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2763 META_PROTO_TIMES_VALS(14)
2764 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2765 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2766 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2767 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2768 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2769 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2770 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2771 "9552F6E644C553D',NULL);"
2772 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2773 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2774 "al_external_id bigint default 0,transaction_version bigint default 0,"
2775 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2776 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2777 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2778 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2779 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2780 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2781 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2782 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2783 "erver_specifics blob,server_unique_position blob,unique_position blob"
2784 ",attachment_metadata blob);"
2785 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2786 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2787 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2788 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2789 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2790 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2791 ASSERT_TRUE(connection
->CommitTransaction());
2795 void MigrationTest::SetUpVersion89Database(sql::Connection
* connection
) {
2796 ASSERT_TRUE(connection
->is_open());
2797 ASSERT_TRUE(connection
->BeginTransaction());
2798 ASSERT_TRUE(connection
->Execute(
2799 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2800 "INSERT INTO 'share_version' VALUES('nick@chromium.org',89);"
2801 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr"
2802 "ansaction_version BIGINT default 0, context BLOB);"
2803 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
2804 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2805 "_version bigint default -1,server_version bigint default 0,local_exte"
2806 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2807 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2808 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2809 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2810 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2811 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2812 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2813 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2814 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2815 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2816 "ment_metadata blob,server_attachment_metadata blob);"
2817 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2818 META_PROTO_TIMES_VALS(1)
2819 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',X'',NULL,X'2200'"
2820 ",X'2200',NULL,NULL);"
2821 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2822 META_PROTO_TIMES_VALS(6)
2823 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The Internet','The Internet'"
2824 ",NULL,NULL,X'6754307476346749735A5734654D653273625336557753582F77673D"
2825 "',X'C2881000',X'C2881000',NULL,X'22247FFFFFFFFFC000006754307476346749"
2826 "735A5734654D653273625336557753582F77673D',X'22247FFFFFFFFFC0000067543"
2827 "07476346749735A5734654D653273625336557753582F77673D',NULL,NULL);"
2828 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2829 META_PROTO_TIMES_VALS(7)
2830 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google"
2831 "_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2200',NULL,NULL);"
2832 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2833 META_PROTO_TIMES_VALS(8)
2834 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Bookmarks','Bookmarks','goog"
2835 "le_chrome_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'"
2837 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2838 META_PROTO_TIMES_VALS(9)
2839 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
2840 ",'bookmark_bar',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'2200'"
2842 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2843 META_PROTO_TIMES_VALS(10)
2844 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
2845 "kmarks','other_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'220"
2846 "0',X'2200',NULL,NULL);"
2847 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2848 META_PROTO_TIMES_VALS(11)
2849 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Home (The Chromium Projects"
2850 ")','Home (The Chromium Projects)',NULL,NULL,X'50514C784A456D623579366"
2851 "267644237646A7A2B62314130346E493D',X'C28810220A18687474703A2F2F646576"
2852 "2E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1D687474703"
2853 "A2F2F6465762E6368726F6D69756D2E6F72672F6F7468657212084146414756415346"
2854 "',NULL,X'22247FFFFFFFFFF0000050514C784A456D623579366267644237646A7A2B"
2855 "62314130346E493D',X'22247FFFFFFFFFF0000050514C784A456D623579366267644"
2856 "237646A7A2B62314130346E493D',NULL,NULL);"
2857 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2858 META_PROTO_TIMES_VALS(12)
2859 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Extra Bookmarks','Extra Boo"
2860 "kmarks',NULL,NULL,X'7867626A704A646134635A6F616C376A49513338734B46324"
2861 "837773D',X'C2881000',X'C2881000',NULL,X'222480000000000000007867626A7"
2862 "04A646134635A6F616C376A49513338734B46324837773D',X'222480000000000000"
2863 "007867626A704A646134635A6F616C376A49513338734B46324837773D',NULL,NULL"
2865 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2866 META_PROTO_TIMES_VALS(13)
2867 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'ICANN | Internet Corporatio"
2868 "n for Assigned Names and Numbers','ICANN | Internet Corporation for A"
2869 "ssigned Names and Numbers',NULL,NULL,X'3142756B572F774176695650417967"
2870 "2B304A614A514B3452384A413D',X'C28810240A15687474703A2F2F7777772E69636"
2871 "16E6E2E636F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F"
2872 "2F7777772E6963616E6E2E636F6D2F120744414146415346',NULL,X'22247FFFFFFF"
2873 "FFF200003142756B572F7741766956504179672B304A614A514B3452384A413D',X'2"
2874 "2247FFFFFFFFFF200003142756B572F7741766956504179672B304A614A514B345238"
2875 "4A413D',NULL,NULL);"
2876 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2877 META_PROTO_TIMES_VALS(14)
2878 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'The WebKit Open Source Proj"
2879 "ect','The WebKit Open Source Project',NULL,NULL,X'5A5678314E797636457"
2880 "9524D3177494F7236563159552F6E644C553D',X'C288101A0A12687474703A2F2F77"
2881 "65626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2F2F7765626"
2882 "B69742E6F72672F781205504E473259',NULL,X'222480000000001000005A5678314"
2883 "E7976364579524D3177494F7236563159552F6E644C553D',X'222480000000001000"
2884 "005A5678314E7976364579524D3177494F7236563159552F6E644C553D',NULL,NULL"
2886 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2887 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2888 "al_external_id bigint default 0,transaction_version bigint default 0,"
2889 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2890 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2891 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2892 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2893 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2894 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2895 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2896 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2897 "erver_specifics blob,server_unique_position blob,unique_position blob"
2898 ",attachment_metadata blob,server_attachment_metadata blob);"
2899 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2900 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2901 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2902 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2903 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2904 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2905 ASSERT_TRUE(connection
->CommitTransaction());
2909 TEST_F(DirectoryBackingStoreTest
, MigrateVersion67To68
) {
2910 sql::Connection connection
;
2911 ASSERT_TRUE(connection
.OpenInMemory());
2913 SetUpVersion67Database(&connection
);
2915 // Columns existing before version 67.
2916 ASSERT_TRUE(connection
.DoesColumnExist("metas", "name"));
2917 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unsanitized_name"));
2918 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_name"));
2920 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2921 new TestDirectoryBackingStore(GetUsername(), &connection
));
2923 ASSERT_FALSE(dbs
->needs_column_refresh());
2924 ASSERT_TRUE(dbs
->MigrateVersion67To68());
2925 ASSERT_EQ(68, dbs
->GetVersion());
2926 ASSERT_TRUE(dbs
->needs_column_refresh());
2929 TEST_F(DirectoryBackingStoreTest
, MigrateVersion68To69
) {
2930 sql::Connection connection
;
2931 ASSERT_TRUE(connection
.OpenInMemory());
2932 SetUpVersion68Database(&connection
);
2935 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2936 new TestDirectoryBackingStore(GetUsername(), &connection
));
2938 ASSERT_FALSE(dbs
->needs_column_refresh());
2939 ASSERT_TRUE(dbs
->MigrateVersion68To69());
2940 ASSERT_EQ(69, dbs
->GetVersion());
2941 ASSERT_TRUE(dbs
->needs_column_refresh());
2944 ASSERT_TRUE(connection
.DoesColumnExist("metas", "specifics"));
2945 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_specifics"));
2946 sql::Statement
s(connection
.GetUniqueStatement("SELECT non_unique_name,"
2947 "is_del, is_dir, id, specifics, server_specifics FROM metas "
2948 "WHERE metahandle = 2"));
2949 ASSERT_TRUE(s
.Step());
2950 ASSERT_EQ("Deleted Item", s
.ColumnString(0));
2951 ASSERT_TRUE(s
.ColumnBool(1));
2952 ASSERT_FALSE(s
.ColumnBool(2));
2953 ASSERT_EQ("s_ID_2", s
.ColumnString(3));
2954 sync_pb::EntitySpecifics specifics
;
2955 specifics
.ParseFromArray(s
.ColumnBlob(4), s
.ColumnByteLength(4));
2956 ASSERT_TRUE(specifics
.has_bookmark());
2957 ASSERT_EQ("http://www.google.com/", specifics
.bookmark().url());
2958 ASSERT_EQ("AASGASGA", specifics
.bookmark().favicon());
2959 specifics
.ParseFromArray(s
.ColumnBlob(5), s
.ColumnByteLength(5));
2960 ASSERT_TRUE(specifics
.has_bookmark());
2961 ASSERT_EQ("http://www.google.com/2", specifics
.bookmark().url());
2962 ASSERT_EQ("ASADGADGADG", specifics
.bookmark().favicon());
2963 ASSERT_FALSE(s
.Step());
2966 TEST_F(DirectoryBackingStoreTest
, MigrateVersion69To70
) {
2967 sql::Connection connection
;
2968 ASSERT_TRUE(connection
.OpenInMemory());
2969 SetUpVersion69Database(&connection
);
2971 ASSERT_TRUE(connection
.DoesColumnExist("metas", "singleton_tag"));
2972 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unique_server_tag"));
2973 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unique_client_tag"));
2976 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2977 new TestDirectoryBackingStore(GetUsername(), &connection
));
2979 ASSERT_FALSE(dbs
->needs_column_refresh());
2980 ASSERT_TRUE(dbs
->MigrateVersion69To70());
2981 ASSERT_EQ(70, dbs
->GetVersion());
2982 ASSERT_TRUE(dbs
->needs_column_refresh());
2985 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_server_tag"));
2986 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_client_tag"));
2987 sql::Statement
s(connection
.GetUniqueStatement("SELECT id"
2988 " FROM metas WHERE unique_server_tag = 'google_chrome'"));
2989 ASSERT_TRUE(s
.Step());
2990 EXPECT_EQ("s_ID_7", s
.ColumnString(0));
2993 TEST_F(DirectoryBackingStoreTest
, MigrateVersion70To71
) {
2994 sql::Connection connection
;
2995 ASSERT_TRUE(connection
.OpenInMemory());
2996 SetUpVersion70Database(&connection
);
2998 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "last_sync_timestamp"));
2999 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "initial_sync_ended"));
3000 ASSERT_FALSE(connection
.DoesTableExist("models"));
3003 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3004 new TestDirectoryBackingStore(GetUsername(), &connection
));
3006 ASSERT_FALSE(dbs
->needs_column_refresh());
3007 ASSERT_TRUE(dbs
->MigrateVersion70To71());
3008 ASSERT_EQ(71, dbs
->GetVersion());
3009 ASSERT_FALSE(dbs
->needs_column_refresh());
3012 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "last_sync_timestamp"));
3013 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "initial_sync_ended"));
3014 ASSERT_TRUE(connection
.DoesTableExist("models"));
3015 ASSERT_TRUE(connection
.DoesColumnExist("models", "initial_sync_ended"));
3016 ASSERT_TRUE(connection
.DoesColumnExist("models", "last_download_timestamp"));
3017 ASSERT_TRUE(connection
.DoesColumnExist("models", "model_id"));
3019 sql::Statement
s(connection
.GetUniqueStatement("SELECT model_id, "
3020 "initial_sync_ended, last_download_timestamp FROM models"));
3021 ASSERT_TRUE(s
.Step());
3022 std::string model_id
= s
.ColumnString(0);
3023 EXPECT_EQ("C2881000", base::HexEncode(model_id
.data(), model_id
.size()))
3024 << "Model ID is expected to be the empty BookmarkSpecifics proto.";
3025 EXPECT_TRUE(s
.ColumnBool(1));
3026 EXPECT_EQ(694, s
.ColumnInt64(2));
3027 ASSERT_FALSE(s
.Step());
3031 TEST_F(DirectoryBackingStoreTest
, MigrateVersion71To72
) {
3032 sql::Connection connection
;
3033 ASSERT_TRUE(connection
.OpenInMemory());
3034 SetUpVersion71Database(&connection
);
3036 ASSERT_TRUE(connection
.DoesTableExist("extended_attributes"));
3039 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3040 new TestDirectoryBackingStore(GetUsername(), &connection
));
3042 ASSERT_FALSE(dbs
->needs_column_refresh());
3043 ASSERT_TRUE(dbs
->MigrateVersion71To72());
3044 ASSERT_EQ(72, dbs
->GetVersion());
3045 ASSERT_FALSE(dbs
->needs_column_refresh());
3048 ASSERT_FALSE(connection
.DoesTableExist("extended_attributes"));
3051 TEST_F(DirectoryBackingStoreTest
, MigrateVersion72To73
) {
3052 sql::Connection connection
;
3053 ASSERT_TRUE(connection
.OpenInMemory());
3054 SetUpVersion72Database(&connection
);
3056 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "notification_state"));
3059 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3060 new TestDirectoryBackingStore(GetUsername(), &connection
));
3062 ASSERT_FALSE(dbs
->needs_column_refresh());
3063 ASSERT_TRUE(dbs
->MigrateVersion72To73());
3064 ASSERT_EQ(73, dbs
->GetVersion());
3065 ASSERT_FALSE(dbs
->needs_column_refresh());
3068 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "notification_state"));
3071 TEST_F(DirectoryBackingStoreTest
, MigrateVersion73To74
) {
3072 sql::Connection connection
;
3073 ASSERT_TRUE(connection
.OpenInMemory());
3074 SetUpVersion73Database(&connection
);
3077 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
3079 connection
.DoesColumnExist("share_info",
3080 "bookmarks_added_during_autofill_migration"));
3082 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
3084 connection
.DoesColumnExist("share_info",
3085 "autofill_entries_added_during_migration"));
3088 connection
.DoesColumnExist("share_info",
3089 "autofill_profiles_added_during_migration"));
3092 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3093 new TestDirectoryBackingStore(GetUsername(), &connection
));
3095 ASSERT_FALSE(dbs
->needs_column_refresh());
3096 ASSERT_TRUE(dbs
->MigrateVersion73To74());
3097 ASSERT_EQ(74, dbs
->GetVersion());
3098 ASSERT_FALSE(dbs
->needs_column_refresh());
3102 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
3104 connection
.DoesColumnExist("share_info",
3105 "bookmarks_added_during_autofill_migration"));
3107 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
3109 connection
.DoesColumnExist("share_info",
3110 "autofill_entries_added_during_migration"));
3113 connection
.DoesColumnExist("share_info",
3114 "autofill_profiles_added_during_migration"));
3117 TEST_F(DirectoryBackingStoreTest
, MigrateVersion74To75
) {
3118 sql::Connection connection
;
3119 ASSERT_TRUE(connection
.OpenInMemory());
3120 SetUpVersion74Database(&connection
);
3122 ASSERT_FALSE(connection
.DoesColumnExist("models", "progress_marker"));
3123 ASSERT_TRUE(connection
.DoesColumnExist("models", "last_download_timestamp"));
3126 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3127 new TestDirectoryBackingStore(GetUsername(), &connection
));
3129 ASSERT_FALSE(dbs
->needs_column_refresh());
3130 ASSERT_TRUE(dbs
->MigrateVersion74To75());
3131 ASSERT_EQ(75, dbs
->GetVersion());
3132 ASSERT_FALSE(dbs
->needs_column_refresh());
3135 ASSERT_TRUE(connection
.DoesColumnExist("models", "progress_marker"));
3136 ASSERT_FALSE(connection
.DoesColumnExist("models", "last_download_timestamp"));
3139 TEST_F(DirectoryBackingStoreTest
, MigrateVersion75To76
) {
3140 sql::Connection connection
;
3141 ASSERT_TRUE(connection
.OpenInMemory());
3142 SetUpVersion75Database(&connection
);
3145 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
3146 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
3147 "bookmarks_added_during_autofill_migration"));
3149 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
3150 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
3151 "autofill_entries_added_during_migration"));
3152 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
3153 "autofill_profiles_added_during_migration"));
3155 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3156 new TestDirectoryBackingStore(GetUsername(), &connection
));
3157 ASSERT_FALSE(dbs
->needs_column_refresh());
3158 ASSERT_TRUE(dbs
->MigrateVersion75To76());
3159 ASSERT_EQ(76, dbs
->GetVersion());
3160 ASSERT_TRUE(dbs
->needs_column_refresh());
3161 // Cannot actual refresh columns due to version 76 not containing all
3162 // necessary columns.
3165 TEST_F(DirectoryBackingStoreTest
, MigrateVersion76To77
) {
3166 sql::Connection connection
;
3167 ASSERT_TRUE(connection
.OpenInMemory());
3168 SetUpVersion76Database(&connection
);
3170 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3171 new TestDirectoryBackingStore(GetUsername(), &connection
));
3172 ASSERT_FALSE(dbs
->needs_column_refresh());
3174 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(INCLUDE_DELETED_ITEMS
),
3175 GetMetaProtoTimes(&connection
));
3176 // Since the proto times are expected to be in a legacy format, they may not
3177 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes().
3179 ASSERT_TRUE(dbs
->MigrateVersion76To77());
3180 ASSERT_EQ(77, dbs
->GetVersion());
3182 EXPECT_EQ(GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS
),
3183 GetMetaProtoTimes(&connection
));
3184 // Cannot actually load entries due to version 77 not having all required
3186 ASSERT_FALSE(dbs
->needs_column_refresh());
3189 TEST_F(DirectoryBackingStoreTest
, MigrateVersion77To78
) {
3190 sql::Connection connection
;
3191 ASSERT_TRUE(connection
.OpenInMemory());
3192 SetUpVersion77Database(&connection
);
3194 ASSERT_FALSE(connection
.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS"));
3197 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3198 new TestDirectoryBackingStore(GetUsername(), &connection
));
3199 ASSERT_FALSE(dbs
->needs_column_refresh());
3200 ASSERT_TRUE(dbs
->MigrateVersion77To78());
3201 ASSERT_EQ(78, dbs
->GetVersion());
3203 ASSERT_FALSE(dbs
->needs_column_refresh());
3206 ASSERT_TRUE(connection
.DoesColumnExist("metas", "base_server_specifics"));
3209 TEST_F(DirectoryBackingStoreTest
, MigrateVersion78To79
) {
3210 sql::Connection connection
;
3211 ASSERT_TRUE(connection
.OpenInMemory());
3212 SetUpVersion78Database(&connection
);
3214 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3215 new TestDirectoryBackingStore(GetUsername(), &connection
));
3216 ASSERT_FALSE(dbs
->needs_column_refresh());
3217 ASSERT_TRUE(dbs
->MigrateVersion78To79());
3218 ASSERT_EQ(79, dbs
->GetVersion());
3219 ASSERT_FALSE(dbs
->needs_column_refresh());
3222 TEST_F(DirectoryBackingStoreTest
, MigrateVersion79To80
) {
3223 sql::Connection connection
;
3224 ASSERT_TRUE(connection
.OpenInMemory());
3225 SetUpVersion79Database(&connection
);
3227 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3228 new TestDirectoryBackingStore(GetUsername(), &connection
));
3229 ASSERT_FALSE(dbs
->needs_column_refresh());
3230 ASSERT_TRUE(dbs
->MigrateVersion79To80());
3231 ASSERT_EQ(80, dbs
->GetVersion());
3232 ASSERT_FALSE(dbs
->needs_column_refresh());
3234 // Ensure the bag_of_chips has been set.
3235 Directory::MetahandlesMap handles_map
;
3236 JournalIndex delete_journals
;
3237 MetahandleSet metahandles_to_purge
;
3238 STLValueDeleter
<Directory::MetahandlesMap
> deleter(&handles_map
);
3239 Directory::KernelLoadInfo load_info
;
3241 ASSERT_TRUE(dbs
->Load(&handles_map
, &delete_journals
, &metahandles_to_purge
,
3243 // Check that the initial value is the serialization of an empty ChipBag.
3244 sync_pb::ChipBag chip_bag
;
3245 std::string serialized_chip_bag
;
3246 ASSERT_TRUE(chip_bag
.SerializeToString(&serialized_chip_bag
));
3247 EXPECT_EQ(serialized_chip_bag
, load_info
.kernel_info
.bag_of_chips
);
3250 TEST_F(DirectoryBackingStoreTest
, MigrateVersion80To81
) {
3251 sql::Connection connection
;
3252 ASSERT_TRUE(connection
.OpenInMemory());
3253 SetUpVersion80Database(&connection
);
3255 sql::Statement
s(connection
.GetUniqueStatement(
3256 "SELECT metahandle, server_position_in_parent "
3257 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3258 ASSERT_TRUE(s
.Step());
3259 ASSERT_EQ(sql::COLUMN_TYPE_INTEGER
, s
.ColumnType(1));
3261 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3262 new TestDirectoryBackingStore(GetUsername(), &connection
));
3263 ASSERT_TRUE(dbs
->MigrateVersion80To81());
3264 ASSERT_EQ(81, dbs
->GetVersion());
3266 // Test that ordinal values are preserved correctly.
3267 sql::Statement
new_s(connection
.GetUniqueStatement(
3268 "SELECT metahandle, server_ordinal_in_parent "
3269 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3270 ASSERT_TRUE(new_s
.Step());
3271 ASSERT_EQ(sql::COLUMN_TYPE_BLOB
, new_s
.ColumnType(1));
3273 std::string expected_ordinal
= Int64ToNodeOrdinal(1048576).ToInternalValue();
3274 std::string actual_ordinal
;
3275 new_s
.ColumnBlobAsString(1, &actual_ordinal
);
3276 ASSERT_EQ(expected_ordinal
, actual_ordinal
);
3279 TEST_F(DirectoryBackingStoreTest
, MigrateVersion81To82
) {
3280 sql::Connection connection
;
3281 ASSERT_TRUE(connection
.OpenInMemory());
3282 SetUpVersion81Database(&connection
);
3283 ASSERT_FALSE(connection
.DoesColumnExist("models", "transaction_version"));
3285 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3286 new TestDirectoryBackingStore(GetUsername(), &connection
));
3287 ASSERT_FALSE(dbs
->needs_column_refresh());
3288 ASSERT_TRUE(dbs
->MigrateVersion81To82());
3289 ASSERT_EQ(82, dbs
->GetVersion());
3290 ASSERT_FALSE(dbs
->needs_column_refresh());
3292 ASSERT_TRUE(connection
.DoesColumnExist("models", "transaction_version"));
3295 TEST_F(DirectoryBackingStoreTest
, MigrateVersion82To83
) {
3296 sql::Connection connection
;
3297 ASSERT_TRUE(connection
.OpenInMemory());
3298 SetUpVersion82Database(&connection
);
3299 ASSERT_FALSE(connection
.DoesColumnExist("metas", "transaction_version"));
3301 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3302 new TestDirectoryBackingStore(GetUsername(), &connection
));
3303 ASSERT_TRUE(dbs
->MigrateVersion82To83());
3304 ASSERT_EQ(83, dbs
->GetVersion());
3306 ASSERT_TRUE(connection
.DoesColumnExist("metas", "transaction_version"));
3309 TEST_F(DirectoryBackingStoreTest
, MigrateVersion83To84
) {
3310 sql::Connection connection
;
3311 ASSERT_TRUE(connection
.OpenInMemory());
3312 SetUpVersion83Database(&connection
);
3313 ASSERT_FALSE(connection
.DoesTableExist("deleted_metas"));
3315 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3316 new TestDirectoryBackingStore(GetUsername(), &connection
));
3317 ASSERT_TRUE(dbs
->MigrateVersion83To84());
3318 ASSERT_EQ(84, dbs
->GetVersion());
3320 ASSERT_TRUE(connection
.DoesTableExist("deleted_metas"));
3323 TEST_F(DirectoryBackingStoreTest
, MigrateVersion84To85
) {
3324 sql::Connection connection
;
3325 ASSERT_TRUE(connection
.OpenInMemory());
3326 SetUpVersion84Database(&connection
);
3327 ASSERT_TRUE(connection
.DoesColumnExist("models", "initial_sync_ended"));
3329 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3330 new TestDirectoryBackingStore(GetUsername(), &connection
));
3331 ASSERT_TRUE(dbs
->MigrateVersion84To85());
3332 ASSERT_EQ(85, dbs
->GetVersion());
3333 ASSERT_FALSE(connection
.DoesColumnExist("models", "initial_sync_ended"));
3336 TEST_F(DirectoryBackingStoreTest
, MigrateVersion85To86
) {
3337 sql::Connection connection
;
3338 ASSERT_TRUE(connection
.OpenInMemory());
3339 SetUpVersion85Database(&connection
);
3340 EXPECT_TRUE(connection
.DoesColumnExist("metas", "next_id"));
3341 EXPECT_TRUE(connection
.DoesColumnExist("metas", "prev_id"));
3342 EXPECT_TRUE(connection
.DoesColumnExist("metas", "server_ordinal_in_parent"));
3343 EXPECT_FALSE(connection
.DoesColumnExist("metas", "unique_position"));
3344 EXPECT_FALSE(connection
.DoesColumnExist("metas", "server_unique_position"));
3345 EXPECT_FALSE(connection
.DoesColumnExist("metas", "unique_bookmark_tag"));
3347 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3348 new TestDirectoryBackingStore(GetUsername(), &connection
));
3349 ASSERT_TRUE(dbs
->MigrateVersion85To86());
3350 EXPECT_EQ(86, dbs
->GetVersion());
3351 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_position"));
3352 EXPECT_TRUE(connection
.DoesColumnExist("metas", "server_unique_position"));
3353 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_bookmark_tag"));
3354 ASSERT_TRUE(dbs
->needs_column_refresh());
3357 TEST_F(DirectoryBackingStoreTest
, MigrateVersion86To87
) {
3358 sql::Connection connection
;
3359 EXPECT_TRUE(connection
.OpenInMemory());
3360 SetUpVersion86Database(&connection
);
3361 EXPECT_FALSE(connection
.DoesColumnExist("metas", "attachment_metadata"));
3363 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3364 new TestDirectoryBackingStore(GetUsername(), &connection
));
3365 EXPECT_TRUE(dbs
->MigrateVersion86To87());
3366 EXPECT_EQ(87, dbs
->GetVersion());
3367 EXPECT_TRUE(connection
.DoesColumnExist("metas", "attachment_metadata"));
3368 EXPECT_TRUE(dbs
->needs_column_refresh());
3371 TEST_F(DirectoryBackingStoreTest
, MigrateVersion87To88
) {
3372 sql::Connection connection
;
3373 ASSERT_TRUE(connection
.OpenInMemory());
3374 SetUpVersion87Database(&connection
);
3376 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3377 new TestDirectoryBackingStore(GetUsername(), &connection
));
3378 ASSERT_TRUE(dbs
->MigrateVersion87To88());
3379 ASSERT_EQ(88, dbs
->GetVersion());
3380 ASSERT_TRUE(connection
.DoesColumnExist("models", "context"));
3383 TEST_F(DirectoryBackingStoreTest
, MigrateVersion88To89
) {
3384 sql::Connection connection
;
3385 ASSERT_TRUE(connection
.OpenInMemory());
3386 SetUpVersion88Database(&connection
);
3388 connection
.DoesColumnExist("metas", "server_attachment_metadata"));
3390 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3391 new TestDirectoryBackingStore(GetUsername(), &connection
));
3392 ASSERT_TRUE(dbs
->MigrateVersion88To89());
3393 ASSERT_EQ(89, dbs
->GetVersion());
3395 connection
.DoesColumnExist("metas", "server_attachment_metadata"));
3396 EXPECT_TRUE(dbs
->needs_column_refresh());
3399 // The purpose of this test case is to make it easier to get a dump of the
3400 // database so you can implement a SetUpVersionYDatabase method. Here's what
3403 // 1. Say you're going from version X to version Y. Write the migration
3404 // method MigrateVersionXToY.
3405 // 2. Update the test below to call SetUpVersionXDatabase and then
3406 // MigrateVersionXToY. You now have a database at version Y. Let's dump it.
3407 // 3. Set a breakpoint to stop execution just after the connection is
3408 // destroyed. Examine temp_dir_ to find the version Y database that was
3409 // created on disk. E.g. (gdb) p temp_dir_.path().value().c_str()
3410 // 4. Dump the database using the sqlite3 command line tool:
3411 // > .output foo_dump.sql
3413 // 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or
3414 // LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write
3415 // a SetupVersionYDatabase method.
3416 TEST_F(DirectoryBackingStoreTest
, MigrateToLatestAndDump
) {
3418 sql::Connection connection
;
3419 ASSERT_TRUE(connection
.Open(GetDatabasePath()));
3420 SetUpVersion88Database(&connection
); // Update this.
3422 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3423 new TestDirectoryBackingStore(GetUsername(), &connection
));
3424 ASSERT_TRUE(dbs
->MigrateVersion88To89()); // Update this.
3425 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
3426 EXPECT_EQ(89, dbs
->GetVersion()); // Update this.
3427 ASSERT_FALSE(dbs
->needs_column_refresh());
3429 // Set breakpoint here.
3432 TEST_F(DirectoryBackingStoreTest
, DetectInvalidPosition
) {
3433 sql::Connection connection
;
3434 ASSERT_TRUE(connection
.OpenInMemory());
3435 SetUpVersion86Database(&connection
);
3437 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3438 new TestDirectoryBackingStore(GetUsername(), &connection
));
3439 ASSERT_EQ(86, dbs
->GetVersion());
3441 // Insert row with bad position.
3442 sql::Statement
s(connection
.GetUniqueStatement(
3443 "INSERT INTO metas "
3444 "( id, metahandle, is_dir, ctime, mtime,"
3445 " unique_position, server_unique_position) "
3446 "VALUES('c-invalid', 9999, 1, 0, 0, 'BAD_POS', 'BAD_POS')"));
3447 ASSERT_TRUE(s
.Run());
3449 // Trying to unpack this entry should signal that the DB is corrupted.
3450 Directory::MetahandlesMap handles_map
;
3451 JournalIndex delete_journals
;
3452 MetahandleSet metahandles_to_purge
;
3453 STLValueDeleter
<Directory::MetahandlesMap
> deleter(&handles_map
);
3454 Directory::KernelLoadInfo kernel_load_info
;
3455 ASSERT_EQ(FAILED_DATABASE_CORRUPT
,
3456 dbs
->Load(&handles_map
, &delete_journals
, &metahandles_to_purge
,
3457 &kernel_load_info
));
3460 TEST_P(MigrationTest
, ToCurrentVersion
) {
3461 sql::Connection connection
;
3462 ASSERT_TRUE(connection
.OpenInMemory());
3463 switch (GetParam()) {
3465 SetUpVersion67Database(&connection
);
3468 SetUpVersion68Database(&connection
);
3471 SetUpVersion69Database(&connection
);
3474 SetUpVersion70Database(&connection
);
3477 SetUpVersion71Database(&connection
);
3480 SetUpVersion72Database(&connection
);
3483 SetUpVersion73Database(&connection
);
3486 SetUpVersion74Database(&connection
);
3489 SetUpVersion75Database(&connection
);
3492 SetUpVersion76Database(&connection
);
3495 SetUpVersion77Database(&connection
);
3498 SetUpVersion78Database(&connection
);
3501 SetUpVersion79Database(&connection
);
3504 SetUpVersion80Database(&connection
);
3507 SetUpVersion81Database(&connection
);
3510 SetUpVersion82Database(&connection
);
3513 SetUpVersion83Database(&connection
);
3516 SetUpVersion84Database(&connection
);
3519 SetUpVersion85Database(&connection
);
3522 SetUpVersion86Database(&connection
);
3525 SetUpVersion87Database(&connection
);
3528 SetUpVersion88Database(&connection
);
3531 SetUpVersion89Database(&connection
);
3534 // If you see this error, it may mean that you've increased the
3535 // database version number but you haven't finished adding unit tests
3536 // for the database migration code. You need to need to supply a
3537 // SetUpVersionYDatabase function with a dump of the test database
3538 // at the new schema. See the MigrateToLatestAndDump test case.
3539 FAIL() << "Need to supply database dump for version " << GetParam();
3542 syncable::Directory::KernelLoadInfo dir_info
;
3543 Directory::MetahandlesMap handles_map
;
3544 JournalIndex delete_journals
;
3545 MetahandleSet metahandles_to_purge
;
3546 STLValueDeleter
<Directory::MetahandlesMap
> index_deleter(&handles_map
);
3549 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3550 new TestDirectoryBackingStore(GetUsername(), &connection
));
3551 ASSERT_EQ(OPENED
, dbs
->Load(&handles_map
, &delete_journals
,
3552 &metahandles_to_purge
, &dir_info
));
3553 if (!metahandles_to_purge
.empty())
3554 dbs
->DeleteEntries(metahandles_to_purge
);
3555 ASSERT_FALSE(dbs
->needs_column_refresh());
3556 ASSERT_EQ(kCurrentDBVersion
, dbs
->GetVersion());
3559 // Columns deleted in Version 67.
3560 ASSERT_FALSE(connection
.DoesColumnExist("metas", "name"));
3561 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unsanitized_name"));
3562 ASSERT_FALSE(connection
.DoesColumnExist("metas", "server_name"));
3564 // Columns added in Version 68.
3565 ASSERT_TRUE(connection
.DoesColumnExist("metas", "specifics"));
3566 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_specifics"));
3568 // Columns deleted in Version 68.
3569 ASSERT_FALSE(connection
.DoesColumnExist("metas", "is_bookmark_object"));
3570 ASSERT_FALSE(connection
.DoesColumnExist("metas",
3571 "server_is_bookmark_object"));
3572 ASSERT_FALSE(connection
.DoesColumnExist("metas", "bookmark_favicon"));
3573 ASSERT_FALSE(connection
.DoesColumnExist("metas", "bookmark_url"));
3574 ASSERT_FALSE(connection
.DoesColumnExist("metas", "server_bookmark_url"));
3576 // Renamed a column in Version 70
3577 ASSERT_FALSE(connection
.DoesColumnExist("metas", "singleton_tag"));
3578 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unique_server_tag"));
3579 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unique_client_tag"));
3581 // Removed extended attributes in Version 72.
3582 ASSERT_FALSE(connection
.DoesTableExist("extended_attributes"));
3584 // Columns added in Version 73.
3585 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "notification_state"));
3587 // Column replaced in version 75.
3588 ASSERT_TRUE(connection
.DoesColumnExist("models", "progress_marker"));
3589 ASSERT_FALSE(connection
.DoesColumnExist("models", "last_download_timestamp"));
3591 // Columns removed in version 76.
3593 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
3594 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3595 "bookmarks_added_during_autofill_migration"));
3597 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
3598 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3599 "autofill_entries_added_during_migration"));
3600 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3601 "autofill_profiles_added_during_migration"));
3603 // Column added in version 78.
3604 ASSERT_TRUE(connection
.DoesColumnExist("metas", "base_server_specifics"));
3606 // Column added in version 82.
3607 ASSERT_TRUE(connection
.DoesColumnExist("models", "transaction_version"));
3609 // Column added in version 83.
3610 ASSERT_TRUE(connection
.DoesColumnExist("metas", "transaction_version"));
3612 // Table added in version 84.
3613 ASSERT_TRUE(connection
.DoesTableExist("deleted_metas"));
3615 // Column removed in version 85.
3616 ASSERT_FALSE(connection
.DoesColumnExist("models", "initial_sync_ended"));
3618 // Columns removed in version 86.
3619 ASSERT_FALSE(connection
.DoesColumnExist("metas", "next_id"));
3620 ASSERT_FALSE(connection
.DoesColumnExist("metas", "prev_id"));
3621 ASSERT_FALSE(connection
.DoesColumnExist("metas", "server_ordinal_in_parent"));
3623 // Column added in version 87.
3624 ASSERT_TRUE(connection
.DoesColumnExist("metas", "attachment_metadata"));
3626 // Column added in version 88.
3627 ASSERT_TRUE(connection
.DoesColumnExist("models", "context"));
3629 // Column added in version 89.
3631 connection
.DoesColumnExist("metas", "server_attachment_metadata"));
3633 // Check download_progress state (v75 migration)
3635 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3636 .timestamp_token_for_migration());
3638 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3641 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3644 dir_info
.kernel_info
.download_progress
[THEMES
]
3645 .has_timestamp_token_for_migration());
3647 dir_info
.kernel_info
.download_progress
[THEMES
]
3650 dir_info
.kernel_info
.download_progress
[THEMES
]
3653 dir_info
.kernel_info
.download_progress
[THEMES
]
3657 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS
),
3658 GetMetaProtoTimes(&connection
));
3659 ExpectTimes(handles_map
, GetExpectedMetaTimes());
3661 Directory::MetahandlesMap::iterator it
= handles_map
.find(1);
3662 ASSERT_TRUE(it
!= handles_map
.end());
3663 ASSERT_EQ(1, it
->second
->ref(META_HANDLE
));
3664 EXPECT_TRUE(it
->second
->ref(ID
).IsRoot());
3665 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3666 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3667 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3668 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3669 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3671 // Items 2, 4, and 5 were deleted.
3672 it
= handles_map
.find(2);
3673 ASSERT_TRUE(it
== handles_map
.end());
3674 it
= handles_map
.find(4);
3675 ASSERT_TRUE(it
== handles_map
.end());
3676 it
= handles_map
.find(5);
3677 ASSERT_TRUE(it
== handles_map
.end());
3679 it
= handles_map
.find(6);
3680 ASSERT_EQ(6, it
->second
->ref(META_HANDLE
));
3681 EXPECT_TRUE(it
->second
->ref(IS_DIR
));
3682 EXPECT_TRUE(it
->second
->ref(SERVER_IS_DIR
));
3683 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_url());
3684 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_url());
3685 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_favicon());
3686 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3687 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3688 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3689 EXPECT_EQ(UniquePosition::kSuffixLength
,
3690 it
->second
->ref(UNIQUE_BOOKMARK_TAG
).length());
3691 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3692 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3694 it
= handles_map
.find(7);
3695 ASSERT_EQ(7, it
->second
->ref(META_HANDLE
));
3696 EXPECT_EQ("google_chrome", it
->second
->ref(UNIQUE_SERVER_TAG
));
3697 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).has_bookmark());
3698 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3699 // Make sure we didn't assign positions to google_chrome.
3700 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3701 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3702 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3703 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3704 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3706 it
= handles_map
.find(8);
3707 ASSERT_EQ(8, it
->second
->ref(META_HANDLE
));
3708 EXPECT_EQ("google_chrome_bookmarks", it
->second
->ref(UNIQUE_SERVER_TAG
));
3709 EXPECT_TRUE(it
->second
->ref(SPECIFICS
).has_bookmark());
3710 EXPECT_TRUE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3711 ASSERT_EQ(it
->second
->ref(ID
).value(), "s_ID_8");
3712 // Make sure we didn't mistake the bookmark root node for a real bookmark.
3713 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3714 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3715 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3716 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3717 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3719 it
= handles_map
.find(9);
3720 ASSERT_EQ(9, it
->second
->ref(META_HANDLE
));
3721 EXPECT_EQ("bookmark_bar", it
->second
->ref(UNIQUE_SERVER_TAG
));
3722 EXPECT_TRUE(it
->second
->ref(SPECIFICS
).has_bookmark());
3723 EXPECT_TRUE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3724 // Make sure we didn't assign positions to bookmark_bar.
3725 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3726 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3727 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3728 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3729 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3731 it
= handles_map
.find(10);
3732 ASSERT_EQ(10, it
->second
->ref(META_HANDLE
));
3733 EXPECT_FALSE(it
->second
->ref(IS_DEL
));
3734 EXPECT_TRUE(it
->second
->ref(SPECIFICS
).has_bookmark());
3735 EXPECT_TRUE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3736 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_url());
3737 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_favicon());
3738 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_url());
3739 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3740 EXPECT_EQ("other_bookmarks", it
->second
->ref(UNIQUE_SERVER_TAG
));
3741 EXPECT_EQ("Other Bookmarks", it
->second
->ref(NON_UNIQUE_NAME
));
3742 EXPECT_EQ("Other Bookmarks", it
->second
->ref(SERVER_NON_UNIQUE_NAME
));
3743 ASSERT_EQ(it
->second
->ref(ID
).value(), "s_ID_10");
3744 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3745 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3746 // Make sure we didn't assign positions to server-created folders, either.
3747 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3748 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3749 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3750 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3751 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3753 it
= handles_map
.find(11);
3754 ASSERT_EQ(11, it
->second
->ref(META_HANDLE
));
3755 EXPECT_FALSE(it
->second
->ref(IS_DEL
));
3756 EXPECT_FALSE(it
->second
->ref(IS_DIR
));
3757 EXPECT_TRUE(it
->second
->ref(SPECIFICS
).has_bookmark());
3758 EXPECT_TRUE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3759 EXPECT_EQ("http://dev.chromium.org/",
3760 it
->second
->ref(SPECIFICS
).bookmark().url());
3761 EXPECT_EQ("AGATWA", it
->second
->ref(SPECIFICS
).bookmark().favicon());
3762 EXPECT_EQ("http://dev.chromium.org/other",
3763 it
->second
->ref(SERVER_SPECIFICS
).bookmark().url());
3764 EXPECT_EQ("AFAGVASF", it
->second
->ref(SERVER_SPECIFICS
).bookmark().favicon());
3765 EXPECT_EQ("", it
->second
->ref(UNIQUE_SERVER_TAG
));
3766 EXPECT_EQ("Home (The Chromium Projects)", it
->second
->ref(NON_UNIQUE_NAME
));
3767 EXPECT_EQ("Home (The Chromium Projects)",
3768 it
->second
->ref(SERVER_NON_UNIQUE_NAME
));
3769 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3770 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3771 EXPECT_EQ(UniquePosition::kSuffixLength
,
3772 it
->second
->ref(UNIQUE_BOOKMARK_TAG
).length());
3773 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3775 it
= handles_map
.find(12);
3776 ASSERT_EQ(12, it
->second
->ref(META_HANDLE
));
3777 EXPECT_FALSE(it
->second
->ref(IS_DEL
));
3778 EXPECT_TRUE(it
->second
->ref(IS_DIR
));
3779 EXPECT_EQ("Extra Bookmarks", it
->second
->ref(NON_UNIQUE_NAME
));
3780 EXPECT_EQ("Extra Bookmarks", it
->second
->ref(SERVER_NON_UNIQUE_NAME
));
3781 EXPECT_TRUE(it
->second
->ref(SPECIFICS
).has_bookmark());
3782 EXPECT_TRUE(it
->second
->ref(SERVER_SPECIFICS
).has_bookmark());
3783 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_url());
3784 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_url());
3785 EXPECT_FALSE(it
->second
->ref(SPECIFICS
).bookmark().has_favicon());
3786 EXPECT_FALSE(it
->second
->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3787 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3788 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3789 EXPECT_EQ(UniquePosition::kSuffixLength
,
3790 it
->second
->ref(UNIQUE_BOOKMARK_TAG
).length());
3791 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3792 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3794 it
= handles_map
.find(13);
3795 ASSERT_EQ(13, it
->second
->ref(META_HANDLE
));
3796 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3797 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3798 EXPECT_EQ(UniquePosition::kSuffixLength
,
3799 it
->second
->ref(UNIQUE_BOOKMARK_TAG
).length());
3800 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3801 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3803 it
= handles_map
.find(14);
3804 ASSERT_EQ(14, it
->second
->ref(META_HANDLE
));
3805 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3806 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3807 EXPECT_EQ(UniquePosition::kSuffixLength
,
3808 it
->second
->ref(UNIQUE_BOOKMARK_TAG
).length());
3809 EXPECT_TRUE(it
->second
->ref(ATTACHMENT_METADATA
).IsInitialized());
3810 EXPECT_TRUE(it
->second
->ref(SERVER_ATTACHMENT_METADATA
).IsInitialized());
3812 ASSERT_EQ(static_cast<size_t>(10), handles_map
.size());
3814 // Make sure that the syncable::Directory and the migration code agree on
3815 // which items should or should not have unique position values. This test
3816 // may become obsolete if the directory's definition of that function
3817 // changes, but, until then, this is a useful test.
3818 for (it
= handles_map
.begin(); it
!= handles_map
.end(); it
++) {
3819 SCOPED_TRACE(it
->second
->ref(ID
));
3820 if (it
->second
->ShouldMaintainPosition()) {
3821 EXPECT_TRUE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3822 EXPECT_TRUE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3823 EXPECT_FALSE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3825 EXPECT_FALSE(it
->second
->ref(UNIQUE_POSITION
).IsValid());
3826 EXPECT_FALSE(it
->second
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3827 EXPECT_TRUE(it
->second
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3832 INSTANTIATE_TEST_CASE_P(DirectoryBackingStore
, MigrationTest
,
3833 testing::Range(67, kCurrentDBVersion
+ 1));
3835 TEST_F(DirectoryBackingStoreTest
, ModelTypeIds
) {
3836 ModelTypeSet protocol_types
= ProtocolTypes();
3837 for (ModelTypeSet::Iterator iter
= protocol_types
.First(); iter
.Good();
3839 std::string model_id
=
3840 TestDirectoryBackingStore::ModelTypeEnumToModelId(iter
.Get());
3841 EXPECT_EQ(iter
.Get(),
3842 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id
.data(),
3849 class OnDiskDirectoryBackingStoreForTest
: public OnDiskDirectoryBackingStore
{
3851 OnDiskDirectoryBackingStoreForTest(const std::string
& dir_name
,
3852 const base::FilePath
& backing_filepath
);
3853 ~OnDiskDirectoryBackingStoreForTest() override
;
3854 bool DidFailFirstOpenAttempt();
3857 void ReportFirstTryOpenFailure() override
;
3860 bool first_open_failed_
;
3863 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest(
3864 const std::string
& dir_name
,
3865 const base::FilePath
& backing_filepath
) :
3866 OnDiskDirectoryBackingStore(dir_name
, backing_filepath
),
3867 first_open_failed_(false) { }
3869 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { }
3871 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() {
3872 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK.
3873 first_open_failed_
= true;
3876 bool OnDiskDirectoryBackingStoreForTest::DidFailFirstOpenAttempt() {
3877 return first_open_failed_
;
3882 // This is a whitebox test intended to exercise the code path where the on-disk
3883 // directory load code decides to delete the current directory and start fresh.
3885 // This is considered "minor" corruption because the database recreation is
3886 // expected to succeed. The alternative, where recreation does not succeed (ie.
3887 // due to read-only file system), is not tested here.
3888 TEST_F(DirectoryBackingStoreTest
, MinorCorruption
) {
3890 scoped_ptr
<OnDiskDirectoryBackingStore
> dbs(
3891 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
3892 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
3895 // Corrupt the root node.
3897 sql::Connection connection
;
3898 ASSERT_TRUE(connection
.Open(GetDatabasePath()));
3899 ASSERT_TRUE(connection
.Execute(
3900 "UPDATE metas SET parent_id='bogus' WHERE id = 'r';"));
3904 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
3905 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
3906 GetDatabasePath()));
3908 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
3909 EXPECT_TRUE(dbs
->DidFailFirstOpenAttempt());
3913 TEST_F(DirectoryBackingStoreTest
, DeleteEntries
) {
3914 sql::Connection connection
;
3915 ASSERT_TRUE(connection
.OpenInMemory());
3917 SetUpCurrentDatabaseAndCheckVersion(&connection
);
3918 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3919 new TestDirectoryBackingStore(GetUsername(), &connection
));
3920 Directory::MetahandlesMap handles_map
;
3921 JournalIndex delete_journals
;
3922 MetahandleSet metahandles_to_purge
;
3923 Directory::KernelLoadInfo kernel_load_info
;
3924 STLValueDeleter
<Directory::MetahandlesMap
> index_deleter(&handles_map
);
3926 dbs
->Load(&handles_map
, &delete_journals
, &metahandles_to_purge
,
3928 size_t initial_size
= handles_map
.size();
3929 ASSERT_LT(0U, initial_size
) << "Test requires handles_map to delete.";
3930 int64 first_to_die
= handles_map
.begin()->second
->ref(META_HANDLE
);
3931 MetahandleSet to_delete
;
3932 to_delete
.insert(first_to_die
);
3933 EXPECT_TRUE(dbs
->DeleteEntries(to_delete
));
3935 STLDeleteValues(&handles_map
);
3936 metahandles_to_purge
.clear();
3937 dbs
->LoadEntries(&handles_map
, &metahandles_to_purge
);
3939 EXPECT_EQ(initial_size
- 1, handles_map
.size());
3940 bool delete_failed
= false;
3941 for (Directory::MetahandlesMap::iterator it
= handles_map
.begin();
3942 it
!= handles_map
.end(); ++it
) {
3943 if (it
->first
== first_to_die
) {
3944 delete_failed
= true;
3948 EXPECT_FALSE(delete_failed
);
3951 for (Directory::MetahandlesMap::iterator it
= handles_map
.begin();
3952 it
!= handles_map
.end(); ++it
) {
3953 to_delete
.insert(it
->first
);
3956 EXPECT_TRUE(dbs
->DeleteEntries(to_delete
));
3958 STLDeleteValues(&handles_map
);
3959 metahandles_to_purge
.clear();
3960 dbs
->LoadEntries(&handles_map
, &metahandles_to_purge
);
3961 EXPECT_EQ(0U, handles_map
.size());
3964 TEST_F(DirectoryBackingStoreTest
, GenerateCacheGUID
) {
3965 const std::string
& guid1
= TestDirectoryBackingStore::GenerateCacheGUID();
3966 const std::string
& guid2
= TestDirectoryBackingStore::GenerateCacheGUID();
3967 EXPECT_EQ(24U, guid1
.size());
3968 EXPECT_EQ(24U, guid2
.size());
3969 // In theory this test can fail, but it won't before the universe
3970 // dies of heat death.
3971 EXPECT_NE(guid1
, guid2
);
3974 TEST_F(DirectoryBackingStoreTest
, IncreaseDatabasePageSizeFrom4KTo32K
) {
3975 sql::Connection connection
;
3976 ASSERT_TRUE(connection
.Open(GetDatabasePath()));
3978 SetUpCurrentDatabaseAndCheckVersion(&connection
);
3979 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3980 new TestDirectoryBackingStore(GetUsername(), &connection
));
3981 Directory::MetahandlesMap handles_map
;
3982 JournalIndex delete_journals
;
3983 MetahandleSet metahandles_to_purge
;
3984 Directory::KernelLoadInfo kernel_load_info
;
3985 STLValueDeleter
<Directory::MetahandlesMap
> index_deleter(&handles_map
);
3987 DirOpenResult open_result
= dbs
->Load(
3988 &handles_map
, &delete_journals
, &metahandles_to_purge
, &kernel_load_info
);
3989 EXPECT_EQ(open_result
, OPENED
);
3991 // Set up database's page size to 4096
3992 EXPECT_TRUE(dbs
->db_
->Execute("PRAGMA page_size=4096;"));
3993 EXPECT_TRUE(dbs
->Vacuum());
3995 // Check if update is successful.
3997 dbs
->GetDatabasePageSize(&pageSize
);
3998 EXPECT_TRUE(32768 != pageSize
);
3999 dbs
->db_
->set_page_size(32768);
4000 dbs
->IncreasePageSizeTo32K();
4002 dbs
->GetDatabasePageSize(&pageSize
);
4003 EXPECT_EQ(32768, pageSize
);
4006 // See that a catastrophic error handler remains set across instances of the
4007 // underlying sql:Connection.
4008 TEST_F(DirectoryBackingStoreTest
, CatastrophicErrorHandler_KeptAcrossReset
) {
4009 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
4010 new OnDiskDirectoryBackingStoreForTest(GetUsername(), GetDatabasePath()));
4011 // See that by default there is no catastrophic error handler.
4012 ASSERT_FALSE(dbs
->db_
->has_error_callback());
4013 // Set one and see that it was set.
4014 dbs
->SetCatastrophicErrorHandler(
4015 base::Bind(&CatastrophicErrorHandler
, nullptr));
4016 ASSERT_TRUE(dbs
->db_
->has_error_callback());
4017 // Recreate the Connection and see that the handler remains set.
4018 dbs
->ResetAndCreateConnection();
4019 ASSERT_TRUE(dbs
->db_
->has_error_callback());
4022 // Verify that database corruption encountered during Load will trigger the
4023 // catastrohpic error handler.
4024 TEST_F(DirectoryBackingStoreTest
,
4025 CatastrophicErrorHandler_InvocationDuringLoad
) {
4026 bool was_called
= false;
4027 const base::Closure handler
=
4028 base::Bind(&CatastrophicErrorHandler
, &was_called
);
4030 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
4031 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
4032 GetDatabasePath()));
4033 dbs
->SetCatastrophicErrorHandler(handler
);
4034 ASSERT_TRUE(dbs
->db_
->has_error_callback());
4035 // Load the DB, and save one entry.
4036 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
4037 ASSERT_FALSE(dbs
->DidFailFirstOpenAttempt());
4038 Directory::SaveChangesSnapshot snapshot
;
4039 snapshot
.dirty_metas
.insert(CreateEntry(2, "").release());
4040 ASSERT_TRUE(dbs
->SaveChanges(snapshot
));
4043 base::RunLoop().RunUntilIdle();
4044 // No catastrophic errors have happened. See that it hasn't be called yet.
4045 ASSERT_FALSE(was_called
);
4047 // Corrupt the DB. Some forms of corruption (like this one) will be detected
4048 // upon loading the Sync DB.
4049 ASSERT_TRUE(sql::test::CorruptSizeInHeader(GetDatabasePath()));
4052 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
4053 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
4054 GetDatabasePath()));
4055 dbs
->SetCatastrophicErrorHandler(handler
);
4056 ASSERT_TRUE(dbs
->db_
->has_error_callback());
4058 // The corruption will be detected when we attempt to load the data. Use a
4059 // ScopedErrorIgnorer to ensure we don't crash in debug builds.
4060 sql::ScopedErrorIgnorer error_ignorer
;
4061 error_ignorer
.IgnoreError(SQLITE_CORRUPT
);
4062 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
4063 ASSERT_TRUE(error_ignorer
.CheckIgnoredErrors());
4065 // See that the first open failed as expected.
4066 ASSERT_TRUE(dbs
->DidFailFirstOpenAttempt());
4069 // At this point the handler has been posted but not executed.
4070 ASSERT_FALSE(was_called
);
4071 // Pump the message loop and see that it is executed.
4072 base::RunLoop().RunUntilIdle();
4073 ASSERT_TRUE(was_called
);
4076 // Verify that database corruption encountered during SaveChanges will trigger
4077 // the catastrohpic error handler.
4078 TEST_F(DirectoryBackingStoreTest
,
4079 CatastrophicErrorHandler_InvocationDuringSaveChanges
) {
4080 bool was_called
= false;
4081 const base::Closure handler
=
4082 base::Bind(&CatastrophicErrorHandler
, &was_called
);
4083 // Create a DB with many entries.
4084 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
4085 new OnDiskDirectoryBackingStoreForTest(GetUsername(), GetDatabasePath()));
4086 dbs
->SetCatastrophicErrorHandler(handler
);
4087 ASSERT_TRUE(dbs
->db_
->has_error_callback());
4088 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
4089 ASSERT_FALSE(dbs
->DidFailFirstOpenAttempt());
4090 Directory::SaveChangesSnapshot snapshot
;
4091 const std::string
suffix(400, 'o');
4092 for (int i
= 0; i
< corruption_testing::kNumEntriesRequiredForCorruption
;
4094 scoped_ptr
<EntryKernel
> large_entry
= CreateEntry(i
, suffix
);
4095 snapshot
.dirty_metas
.insert(large_entry
.release());
4097 ASSERT_TRUE(dbs
->SaveChanges(snapshot
));
4099 ASSERT_TRUE(corruption_testing::CorruptDatabase(GetDatabasePath()));
4100 // Attempt to save all those entries again. See that it fails (because of the
4103 // If this test fails because SaveChanges returned true, it may mean you need
4104 // to increase the number of entries written to the DB. See also
4105 // |kNumEntriesRequiredForCorruption|.
4106 ASSERT_FALSE(dbs
->SaveChanges(snapshot
));
4107 // At this point the handler has been posted but not executed.
4108 ASSERT_FALSE(was_called
);
4109 // Pump the message loop and see that it is executed.
4110 base::RunLoop().RunUntilIdle();
4111 ASSERT_TRUE(was_called
);
4114 } // namespace syncable
4115 } // namespace syncer