Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: sql/recovery.cc

Issue 382673002: Fixes for re-enabling more MSVC level 4 warnings: misc edition #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/ext/platform_canvas_unittest.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/recovery.h" 5 #include "sql/recovery.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // to the recovered table. 348 // to the recovered table.
349 std::vector<std::string> insert_columns; 349 std::vector<std::string> insert_columns;
350 350
351 // If PRIMARY KEY is a single INTEGER column, then it is an alias 351 // If PRIMARY KEY is a single INTEGER column, then it is an alias
352 // for ROWID. The primary key can be compound, so this can only be 352 // for ROWID. The primary key can be compound, so this can only be
353 // determined after processing all column data and tracking what is 353 // determined after processing all column data and tracking what is
354 // seen. |pk_column_count| counts the columns in the primary key. 354 // seen. |pk_column_count| counts the columns in the primary key.
355 // |rowid_decl| stores the ROWID version of the last INTEGER column 355 // |rowid_decl| stores the ROWID version of the last INTEGER column
356 // seen, which is at |rowid_ofs| in |create_column_decls|. 356 // seen, which is at |rowid_ofs| in |create_column_decls|.
357 size_t pk_column_count = 0; 357 size_t pk_column_count = 0;
358 size_t rowid_ofs; // Only valid if rowid_decl is set. 358 size_t rowid_ofs = 0; // Only valid if rowid_decl is set.
359 std::string rowid_decl; // ROWID version of column |rowid_ofs|. 359 std::string rowid_decl; // ROWID version of column |rowid_ofs|.
360 360
361 while (s.Step()) { 361 while (s.Step()) {
362 const std::string column_name(s.ColumnString(1)); 362 const std::string column_name(s.ColumnString(1));
363 const std::string column_type(s.ColumnString(2)); 363 const std::string column_type(s.ColumnString(2));
364 const bool not_null = s.ColumnBool(3); 364 const bool not_null = s.ColumnBool(3);
365 const int default_type = s.ColumnType(4); 365 const int default_type = s.ColumnType(4);
366 const bool default_is_null = (default_type == COLUMN_TYPE_NULL); 366 const bool default_is_null = (default_type == COLUMN_TYPE_NULL);
367 const int pk_column = s.ColumnInt(5); 367 const int pk_column = s.ColumnInt(5);
368 368
369 if (pk_column > 0) { 369 if (pk_column > 0) {
370 // TODO(shess): http://www.sqlite.org/pragma.html#pragma_table_info 370 // TODO(shess): http://www.sqlite.org/pragma.html#pragma_table_info
371 // documents column 5 as the index of the column in the primary key 371 // documents column 5 as the index of the column in the primary key
372 // (zero for not in primary key). I find that it is always 1 for 372 // (zero for not in primary key). I find that it is always 1 for
373 // columns in the primary key. Since this code is very dependent on 373 // columns in the primary key. Since this code is very dependent on
374 // that pragma, review if the implementation changes. 374 // that pragma, review if the implementation changes.
375 DCHECK_EQ(pk_column, 1); 375 DCHECK_EQ(1, pk_column);
376 ++pk_column_count; 376 ++pk_column_count;
377 } 377 }
378 378
379 // Construct column declaration as "name type [optional constraint]". 379 // Construct column declaration as "name type [optional constraint]".
380 std::string column_decl = column_name; 380 std::string column_decl = column_name;
381 381
382 // SQLite's affinity detection is documented at: 382 // SQLite's affinity detection is documented at:
383 // http://www.sqlite.org/datatype3.html#affname 383 // http://www.sqlite.org/datatype3.html#affname
384 // The gist of it is that CHAR, TEXT, and INT use substring matches. 384 // The gist of it is that CHAR, TEXT, and INT use substring matches.
385 // TODO(shess): It would be nice to unit test the type handling, 385 // TODO(shess): It would be nice to unit test the type handling,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 527 }
528 return false; 528 return false;
529 } 529 }
530 530
531 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION); 531 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION);
532 *version = recovery_version.ColumnInt(0); 532 *version = recovery_version.ColumnInt(0);
533 return true; 533 return true;
534 } 534 }
535 535
536 } // namespace sql 536 } // namespace sql
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas_unittest.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698