| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sql/meta_table.h" | 5 #include "sql/meta_table.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "sql/connection.h" | 9 #include "sql/connection.h" |
| 10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (!DoesTableExist(db)) { | 45 if (!DoesTableExist(db)) { |
| 46 if (!db_->Execute("CREATE TABLE meta" | 46 if (!db_->Execute("CREATE TABLE meta" |
| 47 "(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR)")) | 47 "(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR)")) |
| 48 return false; | 48 return false; |
| 49 | 49 |
| 50 // Note: there is no index over the meta table. We currently only have a | 50 // Note: there is no index over the meta table. We currently only have a |
| 51 // couple of keys, so it doesn't matter. If we start storing more stuff in | 51 // couple of keys, so it doesn't matter. If we start storing more stuff in |
| 52 // there, we should create an index. | 52 // there, we should create an index. |
| 53 SetVersionNumber(version); | 53 SetVersionNumber(version); |
| 54 SetCompatibleVersionNumber(compatible_version); | 54 SetCompatibleVersionNumber(compatible_version); |
| 55 } else { |
| 56 db_->AddSparseHistogram(".Version", GetVersionNumber()); |
| 55 } | 57 } |
| 56 return transaction.Commit(); | 58 return transaction.Commit(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void MetaTable::Reset() { | 61 void MetaTable::Reset() { |
| 60 db_ = NULL; | 62 db_ = NULL; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void MetaTable::SetVersionNumber(int version) { | 65 void MetaTable::SetVersionNumber(int version) { |
| 64 DCHECK_GT(version, 0); | 66 DCHECK_GT(version, 0); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 146 |
| 145 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) { | 147 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) { |
| 146 DCHECK(db_ && statement); | 148 DCHECK(db_ && statement); |
| 147 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE, | 149 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE, |
| 148 "SELECT value FROM meta WHERE key=?")); | 150 "SELECT value FROM meta WHERE key=?")); |
| 149 statement->BindCString(0, key); | 151 statement->BindCString(0, key); |
| 150 return statement->Step(); | 152 return statement->Step(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 } // namespace sql | 155 } // namespace sql |
| OLD | NEW |