| Index: sync/syncable/directory_backing_store.cc
|
| diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc
|
| index 9b8e0dba855edc22128e0cb4aab84d96ec485da5..c1e8254a90ebe42aaaa5742cb5356001a6ec20b6 100644
|
| --- a/sync/syncable/directory_backing_store.cc
|
| +++ b/sync/syncable/directory_backing_store.cc
|
| @@ -27,6 +27,8 @@
|
| #include "sync/syncable/syncable-inl.h"
|
| #include "sync/syncable/syncable_columns.h"
|
| #include "sync/util/time.h"
|
| +#include "sync/internal_api/public/base/ordinal.h"
|
| +#include "sync/internal_api/public/base/node_ordinal.h"
|
|
|
| using std::string;
|
|
|
| @@ -39,7 +41,7 @@ static const string::size_type kUpdateStatementBufferSize = 2048;
|
|
|
| // Increment this version whenever updating DB tables.
|
| extern const int32 kCurrentDBVersion; // Global visibility for our unittest.
|
| -const int32 kCurrentDBVersion = 80;
|
| +const int32 kCurrentDBVersion = 81;
|
|
|
| // Iterate over the fields of |entry| and bind each to |statement| for
|
| // updating. Returns the number of args bound.
|
| @@ -48,6 +50,14 @@ void BindFields(const EntryKernel& entry,
|
| int index = 0;
|
| int i = 0;
|
| for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
|
| + // Store SERVER_POSITION_IN_PARENT as a string for eventual shift
|
| + // to using ordinals instead of int64's
|
| + if(i == SERVER_POSITION_IN_PARENT) {
|
| + NodeOrdinal ordinal = Int64ToNodeOrdinal(
|
| + entry.ref(SERVER_POSITION_IN_PARENT));
|
| + statement->BindString(index++, ordinal.ToInternalValue());
|
| + continue;
|
| + }
|
| statement->BindInt64(index++, entry.ref(static_cast<Int64Field>(i)));
|
| }
|
| for ( ; i < TIME_FIELDS_END; ++i) {
|
| @@ -78,6 +88,14 @@ EntryKernel* UnpackEntry(sql::Statement* statement) {
|
| DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT));
|
| int i = 0;
|
| for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
|
| + // Store SERVER_POSITION_IN_PARENT as a string for eventual shift
|
| + // to using ordinals instead of int64's
|
| + if(i == SERVER_POSITION_IN_PARENT) {
|
| + int64 server_position = NodeOrdinalToInt64(
|
| + NodeOrdinal(statement->ColumnString(i)));
|
| + kernel->put(static_cast<Int64Field>(i), server_position);
|
| + continue;
|
| + }
|
| kernel->put(static_cast<Int64Field>(i), statement->ColumnInt64(i));
|
| }
|
| for ( ; i < TIME_FIELDS_END; ++i) {
|
| @@ -323,6 +341,13 @@ bool DirectoryBackingStore::InitializeTables() {
|
| version_on_disk = 80;
|
| }
|
|
|
| + // Version 81 changes the server_position_in_parent_field from an int64
|
| + // to a string.
|
| + if (version_on_disk == 80) {
|
| + if (MigrateVersion80To81())
|
| + version_on_disk = 81;
|
| + }
|
| +
|
| // If one of the migrations requested it, drop columns that aren't current.
|
| // It's only safe to do this after migrating all the way to the current
|
| // version.
|
| @@ -968,6 +993,7 @@ bool DirectoryBackingStore::MigrateVersion78To79() {
|
| SetVersion(79);
|
| return true;
|
| }
|
| +
|
| bool DirectoryBackingStore::MigrateVersion79To80() {
|
| if (!db_->Execute(
|
| "ALTER TABLE share_info ADD COLUMN bag_of_chips BLOB"))
|
| @@ -982,6 +1008,18 @@ bool DirectoryBackingStore::MigrateVersion79To80() {
|
| return true;
|
| }
|
|
|
| +bool DirectoryBackingStore::MigrateVersion80To81() {
|
| + // Version 81 changes server_position_in_parent from a potentially lossy
|
| + // bigint to an unbounded fidelity ordinal represented as a varchar
|
| + if (!db_->Execute(
|
| + "ALTER TABLE metas"
|
| + "ALTER COLUMN server_position_in_parent VARCHAR(255)")) {
|
| + return false;
|
| + }
|
| + SetVersion(81);
|
| + return true;
|
| +}
|
| +
|
| bool DirectoryBackingStore::CreateTables() {
|
| DVLOG(1) << "First run, creating tables";
|
| // Create two little tables share_version and share_info
|
|
|