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

Side by Side Diff: Source/WebCore/platform/sql/SQLiteStatement.cpp

Issue 13643002: Rename LOG() to LOG_INFO() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rebase Created 7 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 int SQLiteStatement::prepare() 62 int SQLiteStatement::prepare()
63 { 63 {
64 ASSERT(!m_isPrepared); 64 ASSERT(!m_isPrepared);
65 65
66 MutexLocker databaseLock(m_database.databaseMutex()); 66 MutexLocker databaseLock(m_database.databaseMutex());
67 if (m_database.isInterrupted()) 67 if (m_database.isInterrupted())
68 return SQLITE_INTERRUPT; 68 return SQLITE_INTERRUPT;
69 69
70 const void* tail = 0; 70 const void* tail = 0;
71 LOG(SQLDatabase, "SQL - prepare - %s", m_query.ascii().data()); 71 LOG_INFO(SQLDatabase, "SQL - prepare - %s", m_query.ascii().data());
72 String strippedQuery = m_query.stripWhiteSpace(); 72 String strippedQuery = m_query.stripWhiteSpace();
73 const UChar* nullTermed = strippedQuery.charactersWithNullTermination(); 73 const UChar* nullTermed = strippedQuery.charactersWithNullTermination();
74 int error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), nullTermed, -1, &m_statement, &tail); 74 int error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), nullTermed, -1, &m_statement, &tail);
75 75
76 // Starting with version 3.6.16, sqlite has a patch (http://www.sqlite.org/s rc/ci/256ec3c6af) 76 // Starting with version 3.6.16, sqlite has a patch (http://www.sqlite.org/s rc/ci/256ec3c6af)
77 // that should make sure sqlite3_prepare16_v2 doesn't return a SQLITE_SCHEMA error. 77 // that should make sure sqlite3_prepare16_v2 doesn't return a SQLITE_SCHEMA error.
78 // If we're using an older sqlite version, try to emulate the patch. 78 // If we're using an older sqlite version, try to emulate the patch.
79 if (error == SQLITE_SCHEMA) { 79 if (error == SQLITE_SCHEMA) {
80 sqlite3_finalize(m_statement); 80 sqlite3_finalize(m_statement);
81 error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), m_query.character sWithNullTermination(), -1, &m_statement, &tail); 81 error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), m_query.character sWithNullTermination(), -1, &m_statement, &tail);
82 } 82 }
83 83
84 if (error != SQLITE_OK) 84 if (error != SQLITE_OK)
85 LOG(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, m_query .ascii().data(), sqlite3_errmsg(m_database.sqlite3Handle())); 85 LOG_INFO(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, m_ query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Handle()));
86 const UChar* ch = static_cast<const UChar*>(tail); 86 const UChar* ch = static_cast<const UChar*>(tail);
87 if (ch && *ch) 87 if (ch && *ch)
88 error = SQLITE_ERROR; 88 error = SQLITE_ERROR;
89 #ifndef NDEBUG 89 #ifndef NDEBUG
90 m_isPrepared = error == SQLITE_OK; 90 m_isPrepared = error == SQLITE_OK;
91 #endif 91 #endif
92 return error; 92 return error;
93 } 93 }
94 94
95 int SQLiteStatement::step() 95 int SQLiteStatement::step()
96 { 96 {
97 MutexLocker databaseLock(m_database.databaseMutex()); 97 MutexLocker databaseLock(m_database.databaseMutex());
98 if (m_database.isInterrupted()) 98 if (m_database.isInterrupted())
99 return SQLITE_INTERRUPT; 99 return SQLITE_INTERRUPT;
100 //ASSERT(m_isPrepared); 100 //ASSERT(m_isPrepared);
101 101
102 if (!m_statement) 102 if (!m_statement)
103 return SQLITE_OK; 103 return SQLITE_OK;
104 104
105 // The database needs to update its last changes count before each statement 105 // The database needs to update its last changes count before each statement
106 // in order to compute properly the lastChanges() return value. 106 // in order to compute properly the lastChanges() return value.
107 m_database.updateLastChangesCount(); 107 m_database.updateLastChangesCount();
108 108
109 LOG(SQLDatabase, "SQL - step - %s", m_query.ascii().data()); 109 LOG_INFO(SQLDatabase, "SQL - step - %s", m_query.ascii().data());
110 int error = sqlite3_step(m_statement); 110 int error = sqlite3_step(m_statement);
111 if (error != SQLITE_DONE && error != SQLITE_ROW) { 111 if (error != SQLITE_DONE && error != SQLITE_ROW) {
112 LOG(SQLDatabase, "sqlite3_step failed (%i)\nQuery - %s\nError - %s", 112 LOG_INFO(SQLDatabase, "sqlite3_step failed (%i)\nQuery - %s\nError - %s" ,
113 error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Hand le())); 113 error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite 3Handle()));
114 } 114 }
115 115
116 return error; 116 return error;
117 } 117 }
118 118
119 int SQLiteStatement::finalize() 119 int SQLiteStatement::finalize()
120 { 120 {
121 #ifndef NDEBUG 121 #ifndef NDEBUG
122 m_isPrepared = false; 122 m_isPrepared = false;
123 #endif 123 #endif
124 if (!m_statement) 124 if (!m_statement)
125 return SQLITE_OK; 125 return SQLITE_OK;
126 LOG(SQLDatabase, "SQL - finalize - %s", m_query.ascii().data()); 126 LOG_INFO(SQLDatabase, "SQL - finalize - %s", m_query.ascii().data());
127 int result = sqlite3_finalize(m_statement); 127 int result = sqlite3_finalize(m_statement);
128 m_statement = 0; 128 m_statement = 0;
129 return result; 129 return result;
130 } 130 }
131 131
132 int SQLiteStatement::reset() 132 int SQLiteStatement::reset()
133 { 133 {
134 ASSERT(m_isPrepared); 134 ASSERT(m_isPrepared);
135 if (!m_statement) 135 if (!m_statement)
136 return SQLITE_OK; 136 return SQLITE_OK;
137 LOG(SQLDatabase, "SQL - reset - %s", m_query.ascii().data()); 137 LOG_INFO(SQLDatabase, "SQL - reset - %s", m_query.ascii().data());
138 return sqlite3_reset(m_statement); 138 return sqlite3_reset(m_statement);
139 } 139 }
140 140
141 bool SQLiteStatement::executeCommand() 141 bool SQLiteStatement::executeCommand()
142 { 142 {
143 if (!m_statement && prepare() != SQLITE_OK) 143 if (!m_statement && prepare() != SQLITE_OK)
144 return false; 144 return false;
145 ASSERT(m_isPrepared); 145 ASSERT(m_isPrepared);
146 if (step() != SQLITE_DONE) { 146 if (step() != SQLITE_DONE) {
147 finalize(); 147 finalize();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 result[i] = (static_cast<const unsigned char*>(blob))[i]; 432 result[i] = (static_cast<const unsigned char*>(blob))[i];
433 } 433 }
434 434
435 const void* SQLiteStatement::getColumnBlob(int col, int& size) 435 const void* SQLiteStatement::getColumnBlob(int col, int& size)
436 { 436 {
437 ASSERT(col >= 0); 437 ASSERT(col >= 0);
438 438
439 size = 0; 439 size = 0;
440 440
441 if (finalize() != SQLITE_OK) 441 if (finalize() != SQLITE_OK)
442 LOG(SQLDatabase, "Finalize failed"); 442 LOG_INFO(SQLDatabase, "Finalize failed");
443 if (prepare() != SQLITE_OK) { 443 if (prepare() != SQLITE_OK) {
444 LOG(SQLDatabase, "Prepare failed"); 444 LOG_INFO(SQLDatabase, "Prepare failed");
445 return 0; 445 return 0;
446 } 446 }
447 if (step() != SQLITE_ROW) { 447 if (step() != SQLITE_ROW) {
448 LOG(SQLDatabase, "Step wasn't a row"); 448 LOG_INFO(SQLDatabase, "Step wasn't a row");
449 return 0; 449 return 0;
450 } 450 }
451 451
452 if (columnCount() <= col) 452 if (columnCount() <= col)
453 return 0; 453 return 0;
454 454
455 const void* blob = sqlite3_column_blob(m_statement, col); 455 const void* blob = sqlite3_column_blob(m_statement, col);
456 if (!blob) 456 if (!blob)
457 return 0; 457 return 0;
458 458
(...skipping 10 matching lines...) Expand all
469 if (m_statement) 469 if (m_statement)
470 finalize(); 470 finalize();
471 if (prepare() != SQLITE_OK) 471 if (prepare() != SQLITE_OK)
472 return false; 472 return false;
473 473
474 while (step() == SQLITE_ROW) 474 while (step() == SQLITE_ROW)
475 v.append(getColumnText(col)); 475 v.append(getColumnText(col));
476 bool result = true; 476 bool result = true;
477 if (m_database.lastError() != SQLITE_DONE) { 477 if (m_database.lastError() != SQLITE_DONE) {
478 result = false; 478 result = false;
479 LOG(SQLDatabase, "Error reading results from database query %s", m_query .ascii().data()); 479 LOG_INFO(SQLDatabase, "Error reading results from database query %s", m_ query.ascii().data());
480 } 480 }
481 finalize(); 481 finalize();
482 return result; 482 return result;
483 } 483 }
484 484
485 bool SQLiteStatement::returnIntResults(int col, Vector<int>& v) 485 bool SQLiteStatement::returnIntResults(int col, Vector<int>& v)
486 { 486 {
487 v.clear(); 487 v.clear();
488 488
489 if (m_statement) 489 if (m_statement)
490 finalize(); 490 finalize();
491 if (prepare() != SQLITE_OK) 491 if (prepare() != SQLITE_OK)
492 return false; 492 return false;
493 493
494 while (step() == SQLITE_ROW) 494 while (step() == SQLITE_ROW)
495 v.append(getColumnInt(col)); 495 v.append(getColumnInt(col));
496 bool result = true; 496 bool result = true;
497 if (m_database.lastError() != SQLITE_DONE) { 497 if (m_database.lastError() != SQLITE_DONE) {
498 result = false; 498 result = false;
499 LOG(SQLDatabase, "Error reading results from database query %s", m_query .ascii().data()); 499 LOG_INFO(SQLDatabase, "Error reading results from database query %s", m_ query.ascii().data());
500 } 500 }
501 finalize(); 501 finalize();
502 return result; 502 return result;
503 } 503 }
504 504
505 bool SQLiteStatement::returnInt64Results(int col, Vector<int64_t>& v) 505 bool SQLiteStatement::returnInt64Results(int col, Vector<int64_t>& v)
506 { 506 {
507 v.clear(); 507 v.clear();
508 508
509 if (m_statement) 509 if (m_statement)
510 finalize(); 510 finalize();
511 if (prepare() != SQLITE_OK) 511 if (prepare() != SQLITE_OK)
512 return false; 512 return false;
513 513
514 while (step() == SQLITE_ROW) 514 while (step() == SQLITE_ROW)
515 v.append(getColumnInt64(col)); 515 v.append(getColumnInt64(col));
516 bool result = true; 516 bool result = true;
517 if (m_database.lastError() != SQLITE_DONE) { 517 if (m_database.lastError() != SQLITE_DONE) {
518 result = false; 518 result = false;
519 LOG(SQLDatabase, "Error reading results from database query %s", m_query .ascii().data()); 519 LOG_INFO(SQLDatabase, "Error reading results from database query %s", m_ query.ascii().data());
520 } 520 }
521 finalize(); 521 finalize();
522 return result; 522 return result;
523 } 523 }
524 524
525 bool SQLiteStatement::returnDoubleResults(int col, Vector<double>& v) 525 bool SQLiteStatement::returnDoubleResults(int col, Vector<double>& v)
526 { 526 {
527 v.clear(); 527 v.clear();
528 528
529 if (m_statement) 529 if (m_statement)
530 finalize(); 530 finalize();
531 if (prepare() != SQLITE_OK) 531 if (prepare() != SQLITE_OK)
532 return false; 532 return false;
533 533
534 while (step() == SQLITE_ROW) 534 while (step() == SQLITE_ROW)
535 v.append(getColumnDouble(col)); 535 v.append(getColumnDouble(col));
536 bool result = true; 536 bool result = true;
537 if (m_database.lastError() != SQLITE_DONE) { 537 if (m_database.lastError() != SQLITE_DONE) {
538 result = false; 538 result = false;
539 LOG(SQLDatabase, "Error reading results from database query %s", m_query .ascii().data()); 539 LOG_INFO(SQLDatabase, "Error reading results from database query %s", m_ query.ascii().data());
540 } 540 }
541 finalize(); 541 finalize();
542 return result; 542 return result;
543 } 543 }
544 544
545 bool SQLiteStatement::isExpired() 545 bool SQLiteStatement::isExpired()
546 { 546 {
547 return !m_statement || sqlite3_expired(m_statement); 547 return !m_statement || sqlite3_expired(m_statement);
548 } 548 }
549 549
550 } // namespace WebCore 550 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/platform/sql/SQLiteDatabase.cpp ('k') | Source/WebCore/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698