From bce5189f4d3b7ed976e363a60ff0cc29967c0e8b Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 7 Jan 2020 12:30:40 -0800 Subject: [PATCH] Fix error message (#6264) Summary: Fix an error message when CURRENT is not found. Test plan (dev server) ``` make check ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/6264 Differential Revision: D19300699 Pulled By: riversand963 fbshipit-source-id: 303fa206386a125960ecca1dbdeff07422690caf --- db/c.cc | 16 ++++++++-------- db/c_test.c | 3 ++- db/db_impl/db_impl_open.cc | 13 +++++++------ include/rocksdb/c.h | 5 ++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/db/c.cc b/db/c.cc index 42a7e337c..42a686640 100644 --- a/db/c.cc +++ b/db/c.cc @@ -852,15 +852,15 @@ void rocksdb_delete_cf( Slice(key, keylen))); } -void rocksdb_delete_range_cf( - rocksdb_t* db, - const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, - const char* end_key, size_t end_key_len, - char** errptr) { +void rocksdb_delete_range_cf(rocksdb_t* db, + const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, + const char* end_key, size_t end_key_len, + char** errptr) { SaveError(errptr, db->rep->DeleteRange(options->rep, column_family->rep, - Slice(start_key, start_key_len), Slice(end_key, end_key_len))); + Slice(start_key, start_key_len), + Slice(end_key, end_key_len))); } void rocksdb_merge( diff --git a/db/c_test.c b/db/c_test.c index 874c81f2d..bee1837d0 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -1265,7 +1265,8 @@ int main(int argc, char** argv) { rocksdb_delete_cf(db, woptions, handles[1], "foo", 3, &err); CheckNoError(err); - rocksdb_delete_range_cf(db, woptions, handles[1], "foobar2", 7, "foobar4", 7, &err); + rocksdb_delete_range_cf(db, woptions, handles[1], "foobar2", 7, "foobar4", + 7, &err); CheckNoError(err); CheckGetCF(db, roptions, handles[1], "foo", NULL); diff --git a/db/db_impl/db_impl_open.cc b/db/db_impl/db_impl_open.cc index b41a001a6..8027d786b 100644 --- a/db/db_impl/db_impl_open.cc +++ b/db/db_impl/db_impl_open.cc @@ -363,7 +363,8 @@ Status DBImpl::Recover( return s; } - s = env_->FileExists(CurrentFileName(dbname_)); + std::string current_fname = CurrentFileName(dbname_); + s = env_->FileExists(current_fname); if (s.IsNotFound()) { if (immutable_db_options_.create_if_missing) { // Has to be called only after Identity File creation is successful @@ -376,7 +377,7 @@ Status DBImpl::Recover( } } else { return Status::InvalidArgument( - dbname_, "does not exist (create_if_missing is false)"); + current_fname, "does not exist (create_if_missing is false)"); } } else if (s.ok()) { if (immutable_db_options_.error_if_exists) { @@ -394,14 +395,14 @@ Status DBImpl::Recover( FileOptions customized_fs(file_options_); customized_fs.use_direct_reads |= immutable_db_options_.use_direct_io_for_flush_and_compaction; - s = fs_->NewRandomAccessFile(CurrentFileName(dbname_), customized_fs, - &idfile, nullptr); + s = fs_->NewRandomAccessFile(current_fname, customized_fs, &idfile, + nullptr); if (!s.ok()) { std::string error_str = s.ToString(); // Check if unsupported Direct I/O is the root cause customized_fs.use_direct_reads = false; - s = fs_->NewRandomAccessFile(CurrentFileName(dbname_), customized_fs, - &idfile, nullptr); + s = fs_->NewRandomAccessFile(current_fname, customized_fs, &idfile, + nullptr); if (s.ok()) { return Status::InvalidArgument( "Direct I/O is not supported by the specified DB."); diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 55db255c9..dca9a8ecf 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -269,9 +269,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_delete_cf( extern ROCKSDB_LIBRARY_API void rocksdb_delete_range_cf( rocksdb_t* db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, - const char* end_key, size_t end_key_len, + rocksdb_column_family_handle_t* column_family, const char* start_key, + size_t start_key_len, const char* end_key, size_t end_key_len, char** errptr); extern ROCKSDB_LIBRARY_API void rocksdb_merge(