Skip to content

Commit

Permalink
trying what cursor told me to do
Browse files Browse the repository at this point in the history
  • Loading branch information
meztez committed Jan 6, 2025
1 parent 560eee1 commit 0e03670
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ void RProgressBarDisplay::Finish() {
Update(100);
}

static void SetDefaultConfigArguments(ClientContext &context) {
auto progress_display = Rf_GetOption(RStrings::get().progress_display_sym, R_BaseEnv);
if (Rf_isFunction(progress_display)) {
auto &config = ClientConfig::GetConfig(context);
config.enable_progress_bar = true;
}

// Set the function used to create the display for the progress bar
context.config.display_create_func = RProgressBarDisplay::Create;
}

[[cpp11::register]] duckdb::db_eptr_t rapi_startup(std::string dbdir, bool readonly, cpp11::list configsexp, bool environment_scan) {
const char *dbdirchar;

Expand Down Expand Up @@ -102,6 +91,14 @@ static void SetDefaultConfigArguments(ClientContext &context) {
data2->wrapper = wrapper;
config.replacement_scans.emplace_back(EnvironmentScanReplacement, std::move(data2));
}

// Set progress bar configuration on the main database config
auto progress_display = Rf_GetOption(RStrings::get().progress_display_sym, R_BaseEnv);
if (Rf_isFunction(progress_display)) {
config.enable_progress_bar = true;
}
config.display_create_func = RProgressBarDisplay::Create;

wrapper->db = make_uniq<DuckDB>(dbdirchar, &config);

auto &instance = *wrapper->db->instance;
Expand All @@ -122,7 +119,7 @@ static void SetDefaultConfigArguments(ClientContext &context) {
CreateTableFunctionInfo info(scan_fun);
Connection conn(*wrapper->db);
auto &context = *conn.context;
SetDefaultConfigArguments(context);

auto &catalog = Catalog::GetSystemCatalog(context);
context.transaction.BeginTransaction();

Expand Down

0 comments on commit 0e03670

Please sign in to comment.