Commit bd62311a authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

sql: Replace NULL with nullptr.

Change-Id: Ie3ad5785f82ccafdbcc630a5a26423ecc0b6c4bc
Reviewed-on: https://chromium-review.googlesource.com/1137846
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575937}
parent 814121a7
...@@ -79,10 +79,10 @@ class ScopedWritableSchema { ...@@ -79,10 +79,10 @@ class ScopedWritableSchema {
public: public:
explicit ScopedWritableSchema(sqlite3* db) explicit ScopedWritableSchema(sqlite3* db)
: db_(db) { : db_(db) {
sqlite3_exec(db_, "PRAGMA writable_schema=1", NULL, NULL, NULL); sqlite3_exec(db_, "PRAGMA writable_schema=1", nullptr, nullptr, nullptr);
} }
~ScopedWritableSchema() { ~ScopedWritableSchema() {
sqlite3_exec(db_, "PRAGMA writable_schema=0", NULL, NULL, NULL); sqlite3_exec(db_, "PRAGMA writable_schema=0", nullptr, nullptr, nullptr);
} }
private: private:
...@@ -131,12 +131,12 @@ bool ValidAttachmentPoint(const char* attachment_point) { ...@@ -131,12 +131,12 @@ bool ValidAttachmentPoint(const char* attachment_point) {
// Helper to get the sqlite3_file* associated with the "main" database. // Helper to get the sqlite3_file* associated with the "main" database.
int GetSqlite3File(sqlite3* db, sqlite3_file** file) { int GetSqlite3File(sqlite3* db, sqlite3_file** file) {
*file = NULL; *file = nullptr;
int rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_FILE_POINTER, file); int rc = sqlite3_file_control(db, nullptr, SQLITE_FCNTL_FILE_POINTER, file);
if (rc != SQLITE_OK) if (rc != SQLITE_OK)
return rc; return rc;
// TODO(shess): NULL in file->pMethods has been observed on android_dbg // TODO(shess): null in file->pMethods has been observed on android_dbg
// content_unittests, even though it should not be possible. // content_unittests, even though it should not be possible.
// http://crbug.com/329982 // http://crbug.com/329982
if (!*file || !(*file)->pMethods) if (!*file || !(*file)->pMethods)
...@@ -178,7 +178,7 @@ std::string AsUTF8ForSQL(const base::FilePath& path) { ...@@ -178,7 +178,7 @@ std::string AsUTF8ForSQL(const base::FilePath& path) {
namespace sql { namespace sql {
// static // static
Connection::ErrorExpecterCallback* Connection::current_expecter_cb_ = NULL; Connection::ErrorExpecterCallback* Connection::current_expecter_cb_ = nullptr;
// static // static
bool Connection::IsExpectedSqliteError(int error) { bool Connection::IsExpectedSqliteError(int error) {
...@@ -199,14 +199,14 @@ void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { ...@@ -199,14 +199,14 @@ void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) {
// static // static
void Connection::SetErrorExpecter(Connection::ErrorExpecterCallback* cb) { void Connection::SetErrorExpecter(Connection::ErrorExpecterCallback* cb) {
CHECK(current_expecter_cb_ == NULL); CHECK(!current_expecter_cb_);
current_expecter_cb_ = cb; current_expecter_cb_ = cb;
} }
// static // static
void Connection::ResetErrorExpecter() { void Connection::ResetErrorExpecter() {
CHECK(current_expecter_cb_); CHECK(current_expecter_cb_);
current_expecter_cb_ = NULL; current_expecter_cb_ = nullptr;
} }
bool StatementID::operator<(const StatementID& other) const { bool StatementID::operator<(const StatementID& other) const {
...@@ -242,9 +242,9 @@ void Connection::StatementRef::Close(bool forced) { ...@@ -242,9 +242,9 @@ void Connection::StatementRef::Close(bool forced) {
// of the function. http://crbug.com/136655. // of the function. http://crbug.com/136655.
AssertIOAllowed(); AssertIOAllowed();
sqlite3_finalize(stmt_); sqlite3_finalize(stmt_);
stmt_ = NULL; stmt_ = nullptr;
} }
connection_ = NULL; // The connection may be getting deleted. connection_ = nullptr; // The connection may be getting deleted.
// Forced close is expected to happen from a statement error // Forced close is expected to happen from a statement error
// handler. In that case maintain the sense of |was_valid_| which // handler. In that case maintain the sense of |was_valid_| which
...@@ -253,7 +253,7 @@ void Connection::StatementRef::Close(bool forced) { ...@@ -253,7 +253,7 @@ void Connection::StatementRef::Close(bool forced) {
} }
Connection::Connection() Connection::Connection()
: db_(NULL), : db_(nullptr),
page_size_(0), page_size_(0),
cache_size_(0), cache_size_(0),
exclusive_locking_(false), exclusive_locking_(false),
...@@ -266,13 +266,12 @@ Connection::Connection() ...@@ -266,13 +266,12 @@ Connection::Connection()
mmap_disabled_(false), mmap_disabled_(false),
mmap_enabled_(false), mmap_enabled_(false),
total_changes_at_last_release_(0), total_changes_at_last_release_(0),
stats_histogram_(NULL), stats_histogram_(nullptr),
commit_time_histogram_(NULL), commit_time_histogram_(nullptr),
autocommit_time_histogram_(NULL), autocommit_time_histogram_(nullptr),
update_time_histogram_(NULL), update_time_histogram_(nullptr),
query_time_histogram_(NULL), query_time_histogram_(nullptr),
clock_(new TimeSource()) { clock_(new TimeSource()) {}
}
Connection::~Connection() { Connection::~Connection() {
Close(); Close();
...@@ -410,7 +409,7 @@ void Connection::CloseInternal(bool forced) { ...@@ -410,7 +409,7 @@ void Connection::CloseInternal(bool forced) {
DLOG(DCHECK) << "sqlite3_close failed: " << GetErrorMessage(); DLOG(DCHECK) << "sqlite3_close failed: " << GetErrorMessage();
} }
} }
db_ = NULL; db_ = nullptr;
} }
void Connection::Close() { void Connection::Close() {
...@@ -440,7 +439,7 @@ void Connection::Preload() { ...@@ -440,7 +439,7 @@ void Connection::Preload() {
if (preload_size < 1) if (preload_size < 1)
return; return;
sqlite3_file* file = NULL; sqlite3_file* file = nullptr;
sqlite3_int64 file_size = 0; sqlite3_int64 file_size = 0;
int rc = GetSqlite3FileAndSize(db_, &file, &file_size); int rc = GetSqlite3FileAndSize(db_, &file, &file_size);
if (rc != SQLITE_OK) if (rc != SQLITE_OK)
...@@ -881,7 +880,7 @@ size_t Connection::GetAppropriateMmapSize() { ...@@ -881,7 +880,7 @@ size_t Connection::GetAppropriateMmapSize() {
// Read more of the database looking for errors. The VFS interface is used // Read more of the database looking for errors. The VFS interface is used
// to assure that the reads are valid for SQLite. |g_reads_allowed| is used // to assure that the reads are valid for SQLite. |g_reads_allowed| is used
// to limit checking to 20MB per run of Chromium. // to limit checking to 20MB per run of Chromium.
sqlite3_file* file = NULL; sqlite3_file* file = nullptr;
sqlite3_int64 db_size = 0; sqlite3_int64 db_size = 0;
if (SQLITE_OK != GetSqlite3FileAndSize(db_, &file, &db_size)) { if (SQLITE_OK != GetSqlite3FileAndSize(db_, &file, &db_size)) {
RecordOneEvent(EVENT_MMAP_VFS_FAILURE); RecordOneEvent(EVENT_MMAP_VFS_FAILURE);
...@@ -1081,7 +1080,7 @@ bool Connection::Raze() { ...@@ -1081,7 +1080,7 @@ bool Connection::Raze() {
// TODO(shess): Maybe it would be worthwhile to just truncate from // TODO(shess): Maybe it would be worthwhile to just truncate from
// the get-go? // the get-go?
if (rc == SQLITE_NOTADB || rc == SQLITE_IOERR_SHORT_READ) { if (rc == SQLITE_NOTADB || rc == SQLITE_IOERR_SHORT_READ) {
sqlite3_file* file = NULL; sqlite3_file* file = nullptr;
rc = GetSqlite3File(db_, &file); rc = GetSqlite3File(db_, &file);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
DLOG(DCHECK) << "Failure getting file handle."; DLOG(DCHECK) << "Failure getting file handle.";
...@@ -1167,7 +1166,7 @@ bool Connection::Delete(const base::FilePath& path) { ...@@ -1167,7 +1166,7 @@ bool Connection::Delete(const base::FilePath& path) {
EnsureSqliteInitialized(); EnsureSqliteInitialized();
sqlite3_vfs* vfs = sqlite3_vfs_find(NULL); sqlite3_vfs* vfs = sqlite3_vfs_find(nullptr);
CHECK(vfs); CHECK(vfs);
CHECK(vfs->xDelete); CHECK(vfs->xDelete);
CHECK(vfs->xAccess); CHECK(vfs->xAccess);
...@@ -1315,7 +1314,7 @@ int Connection::ExecuteAndReturnErrorCode(const char* sql) { ...@@ -1315,7 +1314,7 @@ int Connection::ExecuteAndReturnErrorCode(const char* sql) {
RecordOneEvent(EVENT_EXECUTE); RecordOneEvent(EVENT_EXECUTE);
int rc = SQLITE_OK; int rc = SQLITE_OK;
while ((rc == SQLITE_OK) && *sql) { while ((rc == SQLITE_OK) && *sql) {
sqlite3_stmt *stmt = NULL; sqlite3_stmt* stmt = nullptr;
const char *leftover_sql; const char *leftover_sql;
const base::TimeTicks before = Now(); const base::TimeTicks before = Now();
...@@ -1376,7 +1375,7 @@ bool Connection::Execute(const char* sql) { ...@@ -1376,7 +1375,7 @@ bool Connection::Execute(const char* sql) {
int error = ExecuteAndReturnErrorCode(sql); int error = ExecuteAndReturnErrorCode(sql);
if (error != SQLITE_OK) if (error != SQLITE_OK)
error = OnSqliteError(error, NULL, sql); error = OnSqliteError(error, nullptr, sql);
// This needs to be a FATAL log because the error case of arriving here is // This needs to be a FATAL log because the error case of arriving here is
// that there's a malformed SQL statement. This can arise in development if // that there's a malformed SQL statement. This can arise in development if
...@@ -1437,14 +1436,14 @@ scoped_refptr<Connection::StatementRef> Connection::GetStatementImpl( ...@@ -1437,14 +1436,14 @@ scoped_refptr<Connection::StatementRef> Connection::GetStatementImpl(
if (!db_) if (!db_)
return base::MakeRefCounted<StatementRef>(nullptr, nullptr, poisoned_); return base::MakeRefCounted<StatementRef>(nullptr, nullptr, poisoned_);
sqlite3_stmt* stmt = NULL; sqlite3_stmt* stmt = nullptr;
int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
// This is evidence of a syntax error in the incoming SQL. // This is evidence of a syntax error in the incoming SQL.
DCHECK_NE(rc, SQLITE_ERROR) << "SQL compile error " << GetErrorMessage(); DCHECK_NE(rc, SQLITE_ERROR) << "SQL compile error " << GetErrorMessage();
// It could also be database corruption. // It could also be database corruption.
OnSqliteError(rc, NULL, sql); OnSqliteError(rc, nullptr, sql);
return base::MakeRefCounted<StatementRef>(nullptr, nullptr, false); return base::MakeRefCounted<StatementRef>(nullptr, nullptr, false);
} }
return base::MakeRefCounted<StatementRef>(tracking_db, stmt, true); return base::MakeRefCounted<StatementRef>(tracking_db, stmt, true);
...@@ -1452,7 +1451,7 @@ scoped_refptr<Connection::StatementRef> Connection::GetStatementImpl( ...@@ -1452,7 +1451,7 @@ scoped_refptr<Connection::StatementRef> Connection::GetStatementImpl(
scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement( scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement(
const char* sql) const { const char* sql) const {
return GetStatementImpl(NULL, sql); return GetStatementImpl(nullptr, sql);
} }
std::string Connection::GetSchema() const { std::string Connection::GetSchema() const {
...@@ -1485,8 +1484,8 @@ bool Connection::IsSQLValid(const char* sql) { ...@@ -1485,8 +1484,8 @@ bool Connection::IsSQLValid(const char* sql) {
return false; return false;
} }
sqlite3_stmt* stmt = NULL; sqlite3_stmt* stmt = nullptr;
if (sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL) != SQLITE_OK) if (sqlite3_prepare_v2(db_, sql, -1, &stmt, nullptr) != SQLITE_OK)
return false; return false;
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
...@@ -1570,7 +1569,7 @@ int Connection::GetLastErrno() const { ...@@ -1570,7 +1569,7 @@ int Connection::GetLastErrno() const {
return -1; return -1;
int err = 0; int err = 0;
if (SQLITE_OK != sqlite3_file_control(db_, NULL, SQLITE_LAST_ERRNO, &err)) if (SQLITE_OK != sqlite3_file_control(db_, nullptr, SQLITE_LAST_ERRNO, &err))
return -2; return -2;
return err; return err;
...@@ -1643,7 +1642,7 @@ bool Connection::OpenInternal(const std::string& file_name, ...@@ -1643,7 +1642,7 @@ bool Connection::OpenInternal(const std::string& file_name,
// purposes. // purposes.
base::UmaHistogramSparse("Sqlite.OpenFailure", err); base::UmaHistogramSparse("Sqlite.OpenFailure", err);
OnSqliteError(err, NULL, "-- sqlite3_open()"); OnSqliteError(err, nullptr, "-- sqlite3_open()");
bool was_poisoned = poisoned_; bool was_poisoned = poisoned_;
Close(); Close();
...@@ -1681,7 +1680,7 @@ bool Connection::OpenInternal(const std::string& file_name, ...@@ -1681,7 +1680,7 @@ bool Connection::OpenInternal(const std::string& file_name,
// this to avoid the extra memory overhead. // this to avoid the extra memory overhead.
// This must be called immediatly after opening the database before any SQL // This must be called immediatly after opening the database before any SQL
// statements are run. // statements are run.
sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0); sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, nullptr, 0, 0);
// Enable extended result codes to provide more color on I/O errors. // Enable extended result codes to provide more color on I/O errors.
// Not having extended result codes is not a fatal problem, as // Not having extended result codes is not a fatal problem, as
...@@ -1779,14 +1778,14 @@ bool Connection::OpenInternal(const std::string& file_name, ...@@ -1779,14 +1778,14 @@ bool Connection::OpenInternal(const std::string& file_name,
// Database sizes seem to be bimodal, some clients have consistently small // Database sizes seem to be bimodal, some clients have consistently small
// databases (<20k) while other clients have a broad distribution of sizes // databases (<20k) while other clients have a broad distribution of sizes
// (hundreds of kilobytes to many megabytes). // (hundreds of kilobytes to many megabytes).
sqlite3_file* file = NULL; sqlite3_file* file = nullptr;
sqlite3_int64 db_size = 0; sqlite3_int64 db_size = 0;
int rc = GetSqlite3FileAndSize(db_, &file, &db_size); int rc = GetSqlite3FileAndSize(db_, &file, &db_size);
if (rc == SQLITE_OK && db_size > 16 * 1024) { if (rc == SQLITE_OK && db_size > 16 * 1024) {
int chunk_size = 4 * 1024; int chunk_size = 4 * 1024;
if (db_size > 128 * 1024) if (db_size > 128 * 1024)
chunk_size = 32 * 1024; chunk_size = 32 * 1024;
sqlite3_file_control(db_, NULL, SQLITE_FCNTL_CHUNK_SIZE, &chunk_size); sqlite3_file_control(db_, nullptr, SQLITE_FCNTL_CHUNK_SIZE, &chunk_size);
} }
// Enable memory-mapped access. The explicit-disable case is because SQLite // Enable memory-mapped access. The explicit-disable case is because SQLite
......
...@@ -585,11 +585,11 @@ class SQL_EXPORT Connection { ...@@ -585,11 +585,11 @@ class SQL_EXPORT Connection {
// |connection| is the sql::Connection instance associated with // |connection| is the sql::Connection instance associated with
// the statement, and is used for tracking outstanding statements // the statement, and is used for tracking outstanding statements
// and for error handling. Set to NULL for invalid or untracked // and for error handling. Set to nullptr for invalid or untracked
// refs. |stmt| is the actual statement, and should only be NULL // refs. |stmt| is the actual statement, and should only be null
// to create an invalid ref. |was_valid| indicates whether the // to create an invalid ref. |was_valid| indicates whether the
// statement should be considered valid for diagnistic purposes. // statement should be considered valid for diagnistic purposes.
// |was_valid| can be true for NULL |stmt| if the connection has // |was_valid| can be true for a null |stmt| if the connection has
// been forcibly closed by an error handler. // been forcibly closed by an error handler.
StatementRef(Connection* connection, sqlite3_stmt* stmt, bool was_valid); StatementRef(Connection* connection, sqlite3_stmt* stmt, bool was_valid);
...@@ -601,18 +601,20 @@ class SQL_EXPORT Connection { ...@@ -601,18 +601,20 @@ class SQL_EXPORT Connection {
// for diagnostic checks. // for diagnostic checks.
bool was_valid() const { return was_valid_; } bool was_valid() const { return was_valid_; }
// If we've not been linked to a connection, this will be NULL. // If we've not been linked to a connection, this will be null.
// TODO(shess): connection_ can be NULL in case of GetUntrackedStatement(), //
// which prevents Statement::OnError() from forwarding errors. // TODO(shess): connection_ can be nullptr in case of
// GetUntrackedStatement(), which prevents Statement::OnError() from
// forwarding errors.
Connection* connection() const { return connection_; } Connection* connection() const { return connection_; }
// Returns the sqlite statement if any. If the statement is not active, // Returns the sqlite statement if any. If the statement is not active,
// this will return NULL. // this will return nullptr.
sqlite3_stmt* stmt() const { return stmt_; } sqlite3_stmt* stmt() const { return stmt_; }
// Destroys the compiled statement and marks it NULL. The statement will // Destroys the compiled statement and sets it to nullptr. The statement
// no longer be active. |forced| is used to indicate if orderly-shutdown // will no longer be active. |forced| is used to indicate if
// checks should apply (see Connection::RazeAndClose()). // orderly-shutdown checks should apply (see Connection::RazeAndClose()).
void Close(bool forced); void Close(bool forced);
// Check whether the current thread is allowed to make IO calls, but only // Check whether the current thread is allowed to make IO calls, but only
...@@ -643,10 +645,10 @@ class SQL_EXPORT Connection { ...@@ -643,10 +645,10 @@ class SQL_EXPORT Connection {
// Called when a sqlite function returns an error, which is passed // Called when a sqlite function returns an error, which is passed
// as |err|. The return value is the error code to be reflected // as |err|. The return value is the error code to be reflected
// back to client code. |stmt| is non-NULL if the error relates to // back to client code. |stmt| is non-null if the error relates to
// an sql::Statement instance. |sql| is non-NULL if the error // an sql::Statement instance. |sql| is non-nullptr if the error
// relates to non-statement sql code (Execute, for instance). Both // relates to non-statement sql code (Execute, for instance). Both
// can be NULL, but both should never be set. // can be null, but both should never be set.
// NOTE(shess): Originally, the return value was intended to allow // NOTE(shess): Originally, the return value was intended to allow
// error handlers to transparently convert errors into success. // error handlers to transparently convert errors into success.
// Unfortunately, transactions are not generally restartable, so // Unfortunately, transactions are not generally restartable, so
...@@ -659,7 +661,7 @@ class SQL_EXPORT Connection { ...@@ -659,7 +661,7 @@ class SQL_EXPORT Connection {
// Implementation helper for GetUniqueStatement() and GetUntrackedStatement(). // Implementation helper for GetUniqueStatement() and GetUntrackedStatement().
// |tracking_db| is the db the resulting ref should register with for // |tracking_db| is the db the resulting ref should register with for
// outstanding statement tracking, which should be |this| to track or NULL to // outstanding statement tracking, which should be |this| to track or null to
// not track. // not track.
scoped_refptr<StatementRef> GetStatementImpl( scoped_refptr<StatementRef> GetStatementImpl(
sql::Connection* tracking_db, const char* sql) const; sql::Connection* tracking_db, const char* sql) const;
...@@ -751,7 +753,7 @@ class SQL_EXPORT Connection { ...@@ -751,7 +753,7 @@ class SQL_EXPORT Connection {
bool GetMmapAltStatus(int64_t* status); bool GetMmapAltStatus(int64_t* status);
bool SetMmapAltStatus(int64_t status); bool SetMmapAltStatus(int64_t status);
// The actual sqlite database. Will be NULL before Init has been called or if // The actual sqlite database. Will be null before Init has been called or if
// Init resulted in an error. // Init resulted in an error.
sqlite3* db_; sqlite3* db_;
......
...@@ -92,12 +92,12 @@ class ScopedScalarFunction { ...@@ -92,12 +92,12 @@ class ScopedScalarFunction {
int args, int args,
base::RepeatingCallback<void(sqlite3_context*, int, sqlite3_value**)> cb) base::RepeatingCallback<void(sqlite3_context*, int, sqlite3_value**)> cb)
: db_(db.db_), function_name_(function_name), cb_(std::move(cb)) { : db_(db.db_), function_name_(function_name), cb_(std::move(cb)) {
sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8, sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8, this,
this, &Run, NULL, NULL, NULL); &Run, nullptr, nullptr, nullptr);
} }
~ScopedScalarFunction() { ~ScopedScalarFunction() {
sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8, sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8, nullptr,
NULL, NULL, NULL, NULL, NULL); nullptr, nullptr, nullptr, nullptr);
} }
private: private:
...@@ -121,9 +121,7 @@ class ScopedCommitHook { ...@@ -121,9 +121,7 @@ class ScopedCommitHook {
: db_(db.db_), cb_(std::move(cb)) { : db_(db.db_), cb_(std::move(cb)) {
sqlite3_commit_hook(db_, &Run, this); sqlite3_commit_hook(db_, &Run, this);
} }
~ScopedCommitHook() { ~ScopedCommitHook() { sqlite3_commit_hook(db_, nullptr, nullptr); }
sqlite3_commit_hook(db_, NULL, NULL);
}
private: private:
static int Run(void* p) { static int Run(void* p) {
...@@ -1445,7 +1443,7 @@ TEST_F(SQLConnectionTest, CollectDiagnosticInfo) { ...@@ -1445,7 +1443,7 @@ TEST_F(SQLConnectionTest, CollectDiagnosticInfo) {
// Some other error doesn't include the statment. // Some other error doesn't include the statment.
// TODO(shess): This is weak. // TODO(shess): This is weak.
const std::string full_info = db().CollectErrorInfo(SQLITE_FULL, NULL); const std::string full_info = db().CollectErrorInfo(SQLITE_FULL, nullptr);
EXPECT_EQ(std::string::npos, full_info.find(kSimpleSql)); EXPECT_EQ(std::string::npos, full_info.find(kSimpleSql));
// A table to see in the SQLITE_ERROR results. // A table to see in the SQLITE_ERROR results.
......
...@@ -55,8 +55,7 @@ void RecordDeprecationEvent(DeprecationEventType deprecation_event) { ...@@ -55,8 +55,7 @@ void RecordDeprecationEvent(DeprecationEventType deprecation_event) {
namespace sql { namespace sql {
MetaTable::MetaTable() : db_(NULL) { MetaTable::MetaTable() : db_(nullptr) {}
}
MetaTable::~MetaTable() = default; MetaTable::~MetaTable() = default;
...@@ -147,7 +146,7 @@ bool MetaTable::Init(Connection* db, int version, int compatible_version) { ...@@ -147,7 +146,7 @@ bool MetaTable::Init(Connection* db, int version, int compatible_version) {
DCHECK(!db_ && db); DCHECK(!db_ && db);
db_ = db; db_ = db;
// If values stored are null or missing entirely, 0 will be reported. // If values stored are nullptr or missing entirely, 0 will be reported.
// Require new clients to start with a greater initial version. // Require new clients to start with a greater initial version.
DCHECK_GT(version, 0); DCHECK_GT(version, 0);
DCHECK_GT(compatible_version, 0); DCHECK_GT(compatible_version, 0);
...@@ -178,7 +177,7 @@ bool MetaTable::Init(Connection* db, int version, int compatible_version) { ...@@ -178,7 +177,7 @@ bool MetaTable::Init(Connection* db, int version, int compatible_version) {
} }
void MetaTable::Reset() { void MetaTable::Reset() {
db_ = NULL; db_ = nullptr;
} }
void MetaTable::SetVersionNumber(int version) { void MetaTable::SetVersionNumber(int version) {
......
...@@ -370,7 +370,7 @@ void Recovery::Shutdown(Recovery::Disposition raze) { ...@@ -370,7 +370,7 @@ void Recovery::Shutdown(Recovery::Disposition raze) {
} else if (raze == POISON) { } else if (raze == POISON) {
db_->Poison(); db_->Poison();
} }
db_ = NULL; db_ = nullptr;
} }
bool Recovery::AutoRecoverTable(const char* table_name, bool Recovery::AutoRecoverTable(const char* table_name,
......
...@@ -70,7 +70,7 @@ class SQL_EXPORT Recovery { ...@@ -70,7 +70,7 @@ class SQL_EXPORT Recovery {
// and attach the existing database to it at "corrupt". To prevent // and attach the existing database to it at "corrupt". To prevent
// deadlock, all transactions on |connection| are rolled back. // deadlock, all transactions on |connection| are rolled back.
// //
// Returns NULL in case of failure, with no cleanup done on the // Returns nullptr in case of failure, with no cleanup done on the
// original connection (except for breaking the transactions). The // original connection (except for breaking the transactions). The
// caller should Raze() or otherwise cleanup as appropriate. // caller should Raze() or otherwise cleanup as appropriate.
// //
...@@ -123,7 +123,7 @@ class SQL_EXPORT Recovery { ...@@ -123,7 +123,7 @@ class SQL_EXPORT Recovery {
// //
// NOTE(shess): Due to a flaw in the recovery virtual table, at this // NOTE(shess): Due to a flaw in the recovery virtual table, at this
// time this code injects the DEFAULT value of the target table in // time this code injects the DEFAULT value of the target table in
// locations where the recovery table returns NULL. This is not // locations where the recovery table returns nullptr. This is not
// entirely correct, because it happens both when there is a short // entirely correct, because it happens both when there is a short
// row (correct) but also where there is an actual NULL value // row (correct) but also where there is an actual NULL value
// (incorrect). // (incorrect).
......
...@@ -541,7 +541,7 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableNullFilter) { ...@@ -541,7 +541,7 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableNullFilter) {
"CREATE TABLE x (id INTEGER, t TEXT NOT NULL)"; "CREATE TABLE x (id INTEGER, t TEXT NOT NULL)";
ASSERT_TRUE(db().Execute(kOrigSchema)); ASSERT_TRUE(db().Execute(kOrigSchema));
ASSERT_TRUE(db().Execute("INSERT INTO x VALUES (5, null)")); ASSERT_TRUE(db().Execute("INSERT INTO x VALUES (5, NULL)"));
ASSERT_TRUE(db().Execute("INSERT INTO x VALUES (15, 'this is a test')")); ASSERT_TRUE(db().Execute("INSERT INTO x VALUES (15, 'this is a test')"));
// Create a lame-duck table which will not be propagated by recovery to // Create a lame-duck table which will not be propagated by recovery to
...@@ -577,8 +577,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithRowid) { ...@@ -577,8 +577,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithRowid) {
static const char kCreateSql[] = static const char kCreateSql[] =
"CREATE TABLE x (t TEXT, id INTEGER PRIMARY KEY NOT NULL)"; "CREATE TABLE x (t TEXT, id INTEGER PRIMARY KEY NOT NULL)";
ASSERT_TRUE(db().Execute(kCreateSql)); ASSERT_TRUE(db().Execute(kCreateSql));
ASSERT_TRUE(db().Execute("INSERT INTO x VALUES ('This is a test', null)")); ASSERT_TRUE(db().Execute("INSERT INTO x VALUES ('This is a test', NULL)"));
ASSERT_TRUE(db().Execute("INSERT INTO x VALUES ('That was a test', null)")); ASSERT_TRUE(db().Execute("INSERT INTO x VALUES ('That was a test', NULL)"));
// Save aside a copy of the original schema and data. // Save aside a copy of the original schema and data.
const std::string orig_schema(GetSchema(&db())); const std::string orig_schema(GetSchema(&db()));
......
...@@ -38,7 +38,7 @@ using sql::test::ExecuteWithResults; ...@@ -38,7 +38,7 @@ using sql::test::ExecuteWithResults;
void CaptureErrorCallback(int* error_pointer, std::string* sql_text, void CaptureErrorCallback(int* error_pointer, std::string* sql_text,
int error, sql::Statement* stmt) { int error, sql::Statement* stmt) {
*error_pointer = error; *error_pointer = error;
const char* text = stmt ? stmt->GetSQLStatement() : NULL; const char* text = stmt ? stmt->GetSQLStatement() : nullptr;
*sql_text = text ? text : "no statement available"; *sql_text = text ? text : "no statement available";
} }
...@@ -339,8 +339,8 @@ TEST_F(SQLiteFeaturesTest, DISABLED_TimeMachine) { ...@@ -339,8 +339,8 @@ TEST_F(SQLiteFeaturesTest, DISABLED_TimeMachine) {
base::ScopedCFTypeRef<CFURLRef> journalURL(CFURLRefForPath(journal)); base::ScopedCFTypeRef<CFURLRef> journalURL(CFURLRefForPath(journal));
// Not excluded to start. // Not excluded to start.
EXPECT_FALSE(CSBackupIsItemExcluded(dbURL, NULL)); EXPECT_FALSE(CSBackupIsItemExcluded(dbURL, nullptr));
EXPECT_FALSE(CSBackupIsItemExcluded(journalURL, NULL)); EXPECT_FALSE(CSBackupIsItemExcluded(journalURL, nullptr));
// Exclude the main database file. // Exclude the main database file.
EXPECT_TRUE(base::mac::SetFileBackupExclusion(db_path())); EXPECT_TRUE(base::mac::SetFileBackupExclusion(db_path()));
...@@ -348,7 +348,7 @@ TEST_F(SQLiteFeaturesTest, DISABLED_TimeMachine) { ...@@ -348,7 +348,7 @@ TEST_F(SQLiteFeaturesTest, DISABLED_TimeMachine) {
Boolean excluded_by_path = FALSE; Boolean excluded_by_path = FALSE;
EXPECT_TRUE(CSBackupIsItemExcluded(dbURL, &excluded_by_path)); EXPECT_TRUE(CSBackupIsItemExcluded(dbURL, &excluded_by_path));
EXPECT_FALSE(excluded_by_path); EXPECT_FALSE(excluded_by_path);
EXPECT_FALSE(CSBackupIsItemExcluded(journalURL, NULL)); EXPECT_FALSE(CSBackupIsItemExcluded(journalURL, nullptr));
EXPECT_TRUE(db().Open(db_path())); EXPECT_TRUE(db().Open(db_path()));
ASSERT_TRUE(db().Execute("INSERT INTO t VALUES (1)")); ASSERT_TRUE(db().Execute("INSERT INTO t VALUES (1)"));
...@@ -478,9 +478,9 @@ TEST_F(SQLiteFeaturesTest, WALNoClose) { ...@@ -478,9 +478,9 @@ TEST_F(SQLiteFeaturesTest, WALNoClose) {
ASSERT_TRUE(Reopen()); ASSERT_TRUE(Reopen());
ASSERT_TRUE(db().Execute("PRAGMA journal_mode = WAL")); ASSERT_TRUE(db().Execute("PRAGMA journal_mode = WAL"));
ASSERT_TRUE(db().Execute("ALTER TABLE foo ADD COLUMN c")); ASSERT_TRUE(db().Execute("ALTER TABLE foo ADD COLUMN c"));
ASSERT_EQ( ASSERT_EQ(SQLITE_OK,
SQLITE_OK, sqlite3_db_config(db().db_, SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, 1,
sqlite3_db_config(db().db_, SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, 1, NULL)); nullptr));
ASSERT_TRUE(GetPathExists(wal_path)); ASSERT_TRUE(GetPathExists(wal_path));
db().Close(); db().Close();
ASSERT_TRUE(GetPathExists(wal_path)); ASSERT_TRUE(GetPathExists(wal_path));
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace sql { namespace sql {
// This empty constructor initializes our reference with an empty one so that // This empty constructor initializes our reference with an empty one so that
// we don't have to NULL-check the ref_ to see if the statement is valid: we // we don't have to null-check the ref_ to see if the statement is valid: we
// only have to check the ref's validity bit. // only have to check the ref's validity bit.
Statement::Statement() Statement::Statement()
: ref_(base::MakeRefCounted<Connection::StatementRef>(nullptr, : ref_(base::MakeRefCounted<Connection::StatementRef>(nullptr,
...@@ -288,7 +288,7 @@ int Statement::ColumnByteLength(int col) const { ...@@ -288,7 +288,7 @@ int Statement::ColumnByteLength(int col) const {
const void* Statement::ColumnBlob(int col) const { const void* Statement::ColumnBlob(int col) const {
if (!CheckValid()) if (!CheckValid())
return NULL; return nullptr;
return sqlite3_column_blob(ref_->stmt(), col); return sqlite3_column_blob(ref_->stmt(), col);
} }
...@@ -358,7 +358,7 @@ int Statement::CheckError(int err) { ...@@ -358,7 +358,7 @@ int Statement::CheckError(int err) {
// Please don't add DCHECKs here, OnSqliteError() already has them. // Please don't add DCHECKs here, OnSqliteError() already has them.
succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
if (!succeeded_ && ref_.get() && ref_->connection()) if (!succeeded_ && ref_.get() && ref_->connection())
return ref_->connection()->OnSqliteError(err, this, NULL); return ref_->connection()->OnSqliteError(err, this, nullptr);
return err; return err;
} }
......
...@@ -136,7 +136,7 @@ class SQL_EXPORT Statement { ...@@ -136,7 +136,7 @@ class SQL_EXPORT Statement {
// When reading a blob, you can get a raw pointer to the underlying data, // When reading a blob, you can get a raw pointer to the underlying data,
// along with the length, or you can just ask us to copy the blob into a // along with the length, or you can just ask us to copy the blob into a
// vector. Danger! ColumnBlob may return NULL if there is no data! // vector. Danger! ColumnBlob may return nullptr if there is no data!
int ColumnByteLength(int col) const; int ColumnByteLength(int col) const;
const void* ColumnBlob(int col) const; const void* ColumnBlob(int col) const;
bool ColumnBlobAsString(int col, std::string* blob) const; bool ColumnBlobAsString(int col, std::string* blob) const;
...@@ -188,7 +188,7 @@ class SQL_EXPORT Statement { ...@@ -188,7 +188,7 @@ class SQL_EXPORT Statement {
// The actual sqlite statement. This may be unique to us, or it may be cached // The actual sqlite statement. This may be unique to us, or it may be cached
// by the connection, which is why it's refcounted. This pointer is // by the connection, which is why it's refcounted. This pointer is
// guaranteed non-NULL. // guaranteed non-null.
scoped_refptr<Connection::StatementRef> ref_; scoped_refptr<Connection::StatementRef> ref_;
// Set after Step() or Run() are called, reset by Reset(). Used to // Set after Step() or Run() are called, reset by Reset(). Used to
......
...@@ -38,7 +38,7 @@ void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) { ...@@ -38,7 +38,7 @@ void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) {
base::ScopedFILE file(base::OpenFile( base::ScopedFILE file(base::OpenFile(
db_path(), db_path(),
type == TYPE_OVERWRITE_AND_TRUNCATE ? "wb" : "rb+")); type == TYPE_OVERWRITE_AND_TRUNCATE ? "wb" : "rb+"));
ASSERT_TRUE(file.get() != NULL); ASSERT_TRUE(file.get());
ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET)); ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
const char* kJunk = "Now is the winter of our discontent."; const char* kJunk = "Now is the winter of our discontent.";
...@@ -47,7 +47,7 @@ void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) { ...@@ -47,7 +47,7 @@ void SQLTestBase::WriteJunkToDatabase(WriteJunkType type) {
void SQLTestBase::TruncateDatabase() { void SQLTestBase::TruncateDatabase() {
base::ScopedFILE file(base::OpenFile(db_path(), "rb+")); base::ScopedFILE file(base::OpenFile(db_path(), "rb+"));
ASSERT_TRUE(file.get() != NULL); ASSERT_TRUE(file);
ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET)); ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET));
ASSERT_TRUE(base::TruncateFile(file.get())); ASSERT_TRUE(base::TruncateFile(file.get()));
} }
......
...@@ -390,7 +390,7 @@ sqlite3_vfs* VFSWrapper() { ...@@ -390,7 +390,7 @@ sqlite3_vfs* VFSWrapper() {
// Return existing version if already registered. // Return existing version if already registered.
{ {
sqlite3_vfs* vfs = sqlite3_vfs_find(kVFSName); sqlite3_vfs* vfs = sqlite3_vfs_find(kVFSName);
if (vfs != nullptr) if (vfs)
return vfs; return vfs;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment