Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgerrets committed Aug 7, 2024
1 parent 240df41 commit 83a0b1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/include/duckdb/main/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ struct DBConfigOptions {
//! Because those clients do not like it when threads other than the main thread call into R, for e.g., arrow scans
bool initialize_in_main_thread = false;

string GetDifference(const DBConfigOptions &other) const;
string GetDifferenceFormatted(const DBConfigOptions &other) const;

bool operator==(const DBConfigOptions &other) const;
};
Expand Down Expand Up @@ -322,7 +322,7 @@ struct DBConfig {
DUCKDB_API static vector<string> GetOptionNames();
DUCKDB_API static bool IsInMemoryDatabase(const char *database_path);

string GetOptionDifference(const DBConfig &other) const;
string GetOptionDifferenceFormatted(const DBConfig &other) const;

DUCKDB_API void AddExtensionOption(const string &name, string description, LogicalType parameter,
const Value &default_value = Value(), set_option_callback_t function = nullptr);
Expand Down
9 changes: 5 additions & 4 deletions src/main/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ void DBConfig::AddExtensionOption(const string &name, string description, Logica
}
}

string DBConfig::GetOptionDifference(const DBConfig &other) const {
return options.GetDifference(other.options);
string DBConfig::GetOptionDifferenceFormatted(const DBConfig &other) const {
return options.GetDifferenceFormatted(other.options);
}

bool DBConfig::IsInMemoryDatabase(const char *database_path) {
Expand Down Expand Up @@ -477,11 +477,12 @@ idx_t DBConfig::ParseMemoryLimitSlurm(const string &arg) {
return NumericCast<idx_t>(static_cast<double>(multiplier) * limit);
}

string DBConfigOptions::GetDifference(const DBConfigOptions &other) const {
string DBConfigOptions::GetDifferenceFormatted(const DBConfigOptions &other) const {
string message;

if (other.access_mode != access_mode) {
message = StringUtil::Format("access mode differs:\n\t%s versus %s", EnumUtil::ToChars(access_mode), EnumUtil::ToChars(other.access_mode));
message = StringUtil::Format("access mode differs:\n\t%s versus %s", EnumUtil::ToChars(access_mode),
EnumUtil::ToChars(other.access_mode));
}
if (other.user_options != user_options) {
message += "\nuser options differ:";
Expand Down
6 changes: 4 additions & 2 deletions src/main/db_instance_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ shared_ptr<DuckDB> DBInstanceCache::GetInstanceInternal(const string &database,
}
// the database instance exists - check that the config matches
if (db_instance->instance->config != config) {
throw duckdb::ConnectionException("Can't open a connection to same database file with a different configuration "
"than existing connections:\n" + config.GetOptionDifference(db_instance->instance->config));
throw duckdb::ConnectionException(
"Can't open a connection to same database file with a different configuration "
"than existing connections:\n" +
config.GetOptionDifferenceFormatted(db_instance->instance->config));
}
return db_instance;
}
Expand Down

0 comments on commit 83a0b1a

Please sign in to comment.