duckdb 0.6.2-dev447.0 → 0.6.2-dev480.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/duckdb.cpp CHANGED
@@ -38,6 +38,7 @@ public:
38
38
 
39
39
  DUCKDB_API void Set(const string &new_value, bool is_set_schema);
40
40
  DUCKDB_API void Set(vector<string> &new_paths, bool is_set_schema = false);
41
+ DUCKDB_API void Reset();
41
42
 
42
43
  DUCKDB_API const vector<string> &Get();
43
44
  DUCKDB_API const vector<string> &GetSetPaths() {
@@ -4982,6 +4983,10 @@ string CatalogEntry::ToSQL() {
4982
4983
  namespace duckdb {
4983
4984
 
4984
4985
  CatalogSearchPath::CatalogSearchPath(ClientContext &context_p) : context(context_p) {
4986
+ Reset();
4987
+ }
4988
+
4989
+ void CatalogSearchPath::Reset() {
4985
4990
  SetPaths(ParsePaths(""));
4986
4991
  }
4987
4992
 
@@ -8506,10 +8511,12 @@ private:
8506
8511
  //! The QueryProfilerHistory can be used to access the profiler of previous queries
8507
8512
  class QueryProfilerHistory {
8508
8513
  private:
8514
+ static constexpr uint64_t DEFAULT_SIZE = 20;
8515
+
8509
8516
  //! Previous Query profilers
8510
8517
  deque<pair<transaction_t, shared_ptr<QueryProfiler>>> prev_profilers;
8511
8518
  //! Previous Query profilers size
8512
- uint64_t prev_profilers_size = 20;
8519
+ uint64_t prev_profilers_size = DEFAULT_SIZE;
8513
8520
 
8514
8521
  public:
8515
8522
  deque<pair<transaction_t, shared_ptr<QueryProfiler>>> &GetPrevProfilers() {
@@ -8529,6 +8536,9 @@ public:
8529
8536
  void SetProfilerHistorySize(uint64_t size) {
8530
8537
  this->prev_profilers_size = size;
8531
8538
  }
8539
+ void ResetProfilerHistorySize() {
8540
+ this->prev_profilers_size = DEFAULT_SIZE;
8541
+ }
8532
8542
  };
8533
8543
  } // namespace duckdb
8534
8544
 
@@ -10000,6 +10010,17 @@ string CatalogTypeToString(CatalogType type) {
10000
10010
  namespace duckdb {
10001
10011
 
10002
10012
  // LCOV_EXCL_START
10013
+
10014
+ vector<string> ListCompressionTypes(void) {
10015
+ vector<string> compression_types;
10016
+ uint8_t amount_of_compression_options = (uint8_t)CompressionType::COMPRESSION_COUNT;
10017
+ compression_types.reserve(amount_of_compression_options);
10018
+ for (uint8_t i = 0; i < amount_of_compression_options; i++) {
10019
+ compression_types.push_back(CompressionTypeToString((CompressionType)i));
10020
+ }
10021
+ return compression_types;
10022
+ }
10023
+
10003
10024
  CompressionType CompressionTypeFromString(const string &str) {
10004
10025
  auto compression = StringUtil::Lower(str);
10005
10026
  if (compression == "uncompressed") {
@@ -10544,6 +10565,8 @@ string LogicalOperatorToString(LogicalOperatorType type) {
10544
10565
  return "EXPORT";
10545
10566
  case LogicalOperatorType::LOGICAL_SET:
10546
10567
  return "SET";
10568
+ case LogicalOperatorType::LOGICAL_RESET:
10569
+ return "RESET";
10547
10570
  case LogicalOperatorType::LOGICAL_LOAD:
10548
10571
  return "LOAD";
10549
10572
  case LogicalOperatorType::LOGICAL_INVALID:
@@ -10732,6 +10755,8 @@ string PhysicalOperatorToString(PhysicalOperatorType type) {
10732
10755
  return "EXPORT";
10733
10756
  case PhysicalOperatorType::SET:
10734
10757
  return "SET";
10758
+ case PhysicalOperatorType::RESET:
10759
+ return "RESET";
10735
10760
  case PhysicalOperatorType::LOAD:
10736
10761
  return "LOAD";
10737
10762
  case PhysicalOperatorType::INOUT_FUNCTION:
@@ -71940,6 +71965,123 @@ string PhysicalReservoirSample::ParamsToString() const {
71940
71965
  }
71941
71966
 
71942
71967
  } // namespace duckdb
71968
+ //===----------------------------------------------------------------------===//
71969
+ // DuckDB
71970
+ //
71971
+ // duckdb/execution/operator/helper/physical_reset.hpp
71972
+ //
71973
+ //
71974
+ //===----------------------------------------------------------------------===//
71975
+
71976
+
71977
+
71978
+
71979
+
71980
+
71981
+
71982
+ namespace duckdb {
71983
+
71984
+ struct DBConfig;
71985
+ struct ExtensionOption;
71986
+
71987
+ //! PhysicalReset represents a RESET operation (e.g. RESET a = 42)
71988
+ class PhysicalReset : public PhysicalOperator {
71989
+ public:
71990
+ PhysicalReset(const std::string &name_p, SetScope scope_p, idx_t estimated_cardinality)
71991
+ : PhysicalOperator(PhysicalOperatorType::RESET, {LogicalType::BOOLEAN}, estimated_cardinality), name(name_p),
71992
+ scope(scope_p) {
71993
+ }
71994
+
71995
+ public:
71996
+ // Source interface
71997
+ void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
71998
+ LocalSourceState &lstate) const override;
71999
+
72000
+ public:
72001
+ const std::string name;
72002
+ const SetScope scope;
72003
+
72004
+ private:
72005
+ void ResetExtensionVariable(ExecutionContext &context, DBConfig &config, ExtensionOption &extension_option) const;
72006
+ };
72007
+
72008
+ } // namespace duckdb
72009
+
72010
+
72011
+
72012
+
72013
+
72014
+
72015
+ namespace duckdb {
72016
+
72017
+ void PhysicalReset::ResetExtensionVariable(ExecutionContext &context, DBConfig &config,
72018
+ ExtensionOption &extension_option) const {
72019
+ if (extension_option.set_function) {
72020
+ extension_option.set_function(context.client, scope, extension_option.default_value);
72021
+ }
72022
+ if (scope == SetScope::GLOBAL) {
72023
+ config.ResetOption(name);
72024
+ } else {
72025
+ auto &client_config = ClientConfig::GetConfig(context.client);
72026
+ client_config.set_variables[name] = extension_option.default_value;
72027
+ }
72028
+ }
72029
+
72030
+ void PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
72031
+ LocalSourceState &lstate) const {
72032
+ auto option = DBConfig::GetOptionByName(name);
72033
+ if (!option) {
72034
+ // check if this is an extra extension variable
72035
+ auto &config = DBConfig::GetConfig(context.client);
72036
+ auto entry = config.extension_parameters.find(name);
72037
+ if (entry == config.extension_parameters.end()) {
72038
+ // it is not!
72039
+ // get a list of all options
72040
+ vector<string> potential_names = DBConfig::GetOptionNames();
72041
+ for (auto &entry : config.extension_parameters) {
72042
+ potential_names.push_back(entry.first);
72043
+ }
72044
+
72045
+ throw CatalogException("unrecognized configuration parameter \"%s\"\n%s", name,
72046
+ StringUtil::CandidatesErrorMessage(potential_names, name, "Did you mean"));
72047
+ }
72048
+ ResetExtensionVariable(context, config, entry->second);
72049
+ return;
72050
+ }
72051
+
72052
+ // Transform scope
72053
+ SetScope variable_scope = scope;
72054
+ if (variable_scope == SetScope::AUTOMATIC) {
72055
+ if (option->set_local) {
72056
+ variable_scope = SetScope::SESSION;
72057
+ } else {
72058
+ D_ASSERT(option->set_global);
72059
+ variable_scope = SetScope::GLOBAL;
72060
+ }
72061
+ }
72062
+
72063
+ switch (variable_scope) {
72064
+ case SetScope::GLOBAL: {
72065
+ if (!option->set_global) {
72066
+ throw CatalogException("option \"%s\" cannot be reset globally", name);
72067
+ }
72068
+ auto &db = DatabaseInstance::GetDatabase(context.client);
72069
+ auto &config = DBConfig::GetConfig(context.client);
72070
+ config.ResetOption(&db, *option);
72071
+ break;
72072
+ }
72073
+ case SetScope::SESSION:
72074
+ if (!option->reset_local) {
72075
+ throw CatalogException("option \"%s\" cannot be reset locally", name);
72076
+ }
72077
+ option->reset_local(context.client);
72078
+ break;
72079
+ default:
72080
+ throw InternalException("Unsupported SetScope for variable");
72081
+ }
72082
+ }
72083
+
72084
+ } // namespace duckdb
71943
72085
 
71944
72086
 
71945
72087
 
@@ -72015,6 +72157,9 @@ void PhysicalResultCollector::BuildPipelines(Pipeline &current, MetaPipeline &me
72015
72157
 
72016
72158
  namespace duckdb {
72017
72159
 
72160
+ struct DBConfig;
72161
+ struct ExtensionOption;
72162
+
72018
72163
  //! PhysicalSet represents a SET operation (e.g. SET a = 42)
72019
72164
  class PhysicalSet : public PhysicalOperator {
72020
72165
  public:
@@ -72032,6 +72177,9 @@ public:
72032
72177
  const std::string name;
72033
72178
  const Value value;
72034
72179
  const SetScope scope;
72180
+
72181
+ private:
72182
+ void SetExtensionVariable(ExecutionContext &context, DBConfig &config, ExtensionOption &extension_option) const;
72035
72183
  };
72036
72184
 
72037
72185
  } // namespace duckdb
@@ -72043,6 +72191,21 @@ public:
72043
72191
 
72044
72192
  namespace duckdb {
72045
72193
 
72194
+ void PhysicalSet::SetExtensionVariable(ExecutionContext &context, DBConfig &config,
72195
+ ExtensionOption &extension_option) const {
72196
+ auto &target_type = extension_option.type;
72197
+ Value target_value = value.CastAs(context.client, target_type);
72198
+ if (extension_option.set_function) {
72199
+ extension_option.set_function(context.client, scope, target_value);
72200
+ }
72201
+ if (scope == SetScope::GLOBAL) {
72202
+ config.SetOption(name, move(target_value));
72203
+ } else {
72204
+ auto &client_config = ClientConfig::GetConfig(context.client);
72205
+ client_config.set_variables[name] = move(target_value);
72206
+ }
72207
+ }
72208
+
72046
72209
  void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
72047
72210
  LocalSourceState &lstate) const {
72048
72211
  auto option = DBConfig::GetOptionByName(name);
@@ -72061,19 +72224,7 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
72061
72224
  throw CatalogException("unrecognized configuration parameter \"%s\"\n%s", name,
72062
72225
  StringUtil::CandidatesErrorMessage(potential_names, name, "Did you mean"));
72063
72226
  }
72064
- //! it is!
72065
- auto &extension_option = entry->second;
72066
- auto &target_type = extension_option.type;
72067
- Value target_value = value.CastAs(context.client, target_type);
72068
- if (extension_option.set_function) {
72069
- extension_option.set_function(context.client, scope, target_value);
72070
- }
72071
- if (scope == SetScope::GLOBAL) {
72072
- config.SetOption(name, move(target_value));
72073
- } else {
72074
- auto &client_config = ClientConfig::GetConfig(context.client);
72075
- client_config.set_variables[name] = move(target_value);
72076
- }
72227
+ SetExtensionVariable(context, config, entry->second);
72077
72228
  return;
72078
72229
  }
72079
72230
  SetScope variable_scope = scope;
@@ -89978,6 +90129,55 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCTERef &op
89978
90129
 
89979
90130
  } // namespace duckdb
89980
90131
 
90132
+ //===----------------------------------------------------------------------===//
90133
+ // DuckDB
90134
+ //
90135
+ // duckdb/planner/operator/logical_reset.hpp
90136
+ //
90137
+ //
90138
+ //===----------------------------------------------------------------------===//
90139
+
90140
+
90141
+
90142
+
90143
+
90144
+
90145
+
90146
+
90147
+ namespace duckdb {
90148
+
90149
+ class LogicalReset : public LogicalOperator {
90150
+ public:
90151
+ LogicalReset(std::string name_p, SetScope scope_p)
90152
+ : LogicalOperator(LogicalOperatorType::LOGICAL_RESET), name(name_p), scope(scope_p) {
90153
+ }
90154
+
90155
+ std::string name;
90156
+ SetScope scope;
90157
+
90158
+ public:
90159
+ void Serialize(FieldWriter &writer) const override;
90160
+ static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
90161
+ idx_t EstimateCardinality(ClientContext &context) override;
90162
+
90163
+ protected:
90164
+ void ResolveTypes() override {
90165
+ types.emplace_back(LogicalType::BOOLEAN);
90166
+ }
90167
+ };
90168
+
90169
+ } // namespace duckdb
90170
+
90171
+
90172
+
90173
+ namespace duckdb {
90174
+
90175
+ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalReset &op) {
90176
+ return make_unique<PhysicalReset>(op.name, op.scope, op.estimated_cardinality);
90177
+ }
90178
+
90179
+ } // namespace duckdb
90180
+
89981
90181
 
89982
90182
 
89983
90183
  //===----------------------------------------------------------------------===//
@@ -90925,6 +91125,9 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOperator &
90925
91125
  case LogicalOperatorType::LOGICAL_SET:
90926
91126
  plan = CreatePlan((LogicalSet &)op);
90927
91127
  break;
91128
+ case LogicalOperatorType::LOGICAL_RESET:
91129
+ plan = CreatePlan((LogicalReset &)op);
91130
+ break;
90928
91131
  case LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR:
90929
91132
  plan = ((LogicalExtensionOperator &)op).CreatePlan(context, *this);
90930
91133
 
@@ -137868,6 +138071,7 @@ struct AccessModeSetting {
137868
138071
  static constexpr const char *Description = "Access mode of the database (AUTOMATIC, READ_ONLY or READ_WRITE)";
137869
138072
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137870
138073
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138074
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137871
138075
  static Value GetSetting(ClientContext &context);
137872
138076
  };
137873
138077
 
@@ -137877,6 +138081,7 @@ struct CheckpointThresholdSetting {
137877
138081
  "The WAL size threshold at which to automatically trigger a checkpoint (e.g. 1GB)";
137878
138082
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137879
138083
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138084
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137880
138085
  static Value GetSetting(ClientContext &context);
137881
138086
  };
137882
138087
 
@@ -137886,6 +138091,7 @@ struct DebugCheckpointAbort {
137886
138091
  "DEBUG SETTING: trigger an abort while checkpointing for testing purposes";
137887
138092
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137888
138093
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138094
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137889
138095
  static Value GetSetting(ClientContext &context);
137890
138096
  };
137891
138097
 
@@ -137895,6 +138101,7 @@ struct DebugForceExternal {
137895
138101
  "DEBUG SETTING: force out-of-core computation for operators that support it, used for testing";
137896
138102
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137897
138103
  static void SetLocal(ClientContext &context, const Value &parameter);
138104
+ static void ResetLocal(ClientContext &context);
137898
138105
  static Value GetSetting(ClientContext &context);
137899
138106
  };
137900
138107
 
@@ -137904,6 +138111,7 @@ struct DebugForceNoCrossProduct {
137904
138111
  "DEBUG SETTING: Force disable cross product generation when hyper graph isn't connected, used for testing";
137905
138112
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137906
138113
  static void SetLocal(ClientContext &context, const Value &parameter);
138114
+ static void ResetLocal(ClientContext &context);
137907
138115
  static Value GetSetting(ClientContext &context);
137908
138116
  };
137909
138117
 
@@ -137912,6 +138120,7 @@ struct DebugWindowMode {
137912
138120
  static constexpr const char *Description = "DEBUG SETTING: switch window mode to use";
137913
138121
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137914
138122
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138123
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137915
138124
  static Value GetSetting(ClientContext &context);
137916
138125
  };
137917
138126
 
@@ -137920,7 +138129,9 @@ struct DefaultCollationSetting {
137920
138129
  static constexpr const char *Description = "The collation setting used when none is specified";
137921
138130
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137922
138131
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138132
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137923
138133
  static void SetLocal(ClientContext &context, const Value &parameter);
138134
+ static void ResetLocal(ClientContext &context);
137924
138135
  static Value GetSetting(ClientContext &context);
137925
138136
  };
137926
138137
 
@@ -137929,6 +138140,7 @@ struct DefaultOrderSetting {
137929
138140
  static constexpr const char *Description = "The order type used when none is specified (ASC or DESC)";
137930
138141
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137931
138142
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138143
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137932
138144
  static Value GetSetting(ClientContext &context);
137933
138145
  };
137934
138146
 
@@ -137937,6 +138149,7 @@ struct DefaultNullOrderSetting {
137937
138149
  static constexpr const char *Description = "Null ordering used when none is specified (NULLS_FIRST or NULLS_LAST)";
137938
138150
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137939
138151
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138152
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137940
138153
  static Value GetSetting(ClientContext &context);
137941
138154
  };
137942
138155
 
@@ -137945,6 +138158,7 @@ struct DisabledOptimizersSetting {
137945
138158
  static constexpr const char *Description = "DEBUG SETTING: disable a specific set of optimizers (comma separated)";
137946
138159
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137947
138160
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138161
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137948
138162
  static Value GetSetting(ClientContext &context);
137949
138163
  };
137950
138164
 
@@ -137955,6 +138169,7 @@ struct EnableExternalAccessSetting {
137955
138169
  "readers, pandas replacement scans, etc)";
137956
138170
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137957
138171
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138172
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137958
138173
  static Value GetSetting(ClientContext &context);
137959
138174
  };
137960
138175
 
@@ -137964,6 +138179,7 @@ struct EnableFSSTVectors {
137964
138179
  "Allow scans on FSST compressed segments to emit compressed vectors to utilize late decompression";
137965
138180
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137966
138181
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138182
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137967
138183
  static Value GetSetting(ClientContext &context);
137968
138184
  };
137969
138185
 
@@ -137972,6 +138188,7 @@ struct AllowUnsignedExtensionsSetting {
137972
138188
  static constexpr const char *Description = "Allow to load extensions with invalid or missing signatures";
137973
138189
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137974
138190
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138191
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137975
138192
  static Value GetSetting(ClientContext &context);
137976
138193
  };
137977
138194
 
@@ -137980,6 +138197,7 @@ struct EnableObjectCacheSetting {
137980
138197
  static constexpr const char *Description = "Whether or not object cache is used to cache e.g. Parquet metadata";
137981
138198
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
137982
138199
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138200
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137983
138201
  static Value GetSetting(ClientContext &context);
137984
138202
  };
137985
138203
 
@@ -137987,6 +138205,7 @@ struct EnableHTTPMetadataCacheSetting {
137987
138205
  static constexpr const char *Name = "enable_http_metadata_cache";
137988
138206
  static constexpr const char *Description = "Whether or not the global http metadata is used to cache HTTP metadata";
137989
138207
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138208
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
137990
138209
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
137991
138210
  static Value GetSetting(ClientContext &context);
137992
138211
  };
@@ -137997,6 +138216,7 @@ struct EnableProfilingSetting {
137997
138216
  "Enables profiling, and sets the output format (JSON, QUERY_TREE, QUERY_TREE_OPTIMIZER)";
137998
138217
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
137999
138218
  static void SetLocal(ClientContext &context, const Value &parameter);
138219
+ static void ResetLocal(ClientContext &context);
138000
138220
  static Value GetSetting(ClientContext &context);
138001
138221
  };
138002
138222
 
@@ -138006,6 +138226,7 @@ struct EnableProgressBarSetting {
138006
138226
  "Enables the progress bar, printing progress to the terminal for long queries";
138007
138227
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138008
138228
  static void SetLocal(ClientContext &context, const Value &parameter);
138229
+ static void ResetLocal(ClientContext &context);
138009
138230
  static Value GetSetting(ClientContext &context);
138010
138231
  };
138011
138232
  struct EnableProgressBarPrintSetting {
@@ -138014,6 +138235,7 @@ struct EnableProgressBarPrintSetting {
138014
138235
  "Controls the printing of the progress bar, when 'enable_progress_bar' is true";
138015
138236
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138016
138237
  static void SetLocal(ClientContext &context, const Value &parameter);
138238
+ static void ResetLocal(ClientContext &context);
138017
138239
  static Value GetSetting(ClientContext &context);
138018
138240
  };
138019
138241
 
@@ -138022,6 +138244,7 @@ struct ExperimentalParallelCSVSetting {
138022
138244
  static constexpr const char *Description = "Whether or not to use the experimental parallel CSV reader";
138023
138245
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138024
138246
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138247
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138025
138248
  static Value GetSetting(ClientContext &context);
138026
138249
  };
138027
138250
 
@@ -138030,6 +138253,7 @@ struct ExplainOutputSetting {
138030
138253
  static constexpr const char *Description = "Output of EXPLAIN statements (ALL, OPTIMIZED_ONLY, PHYSICAL_ONLY)";
138031
138254
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138032
138255
  static void SetLocal(ClientContext &context, const Value &parameter);
138256
+ static void ResetLocal(ClientContext &context);
138033
138257
  static Value GetSetting(ClientContext &context);
138034
138258
  };
138035
138259
 
@@ -138038,6 +138262,7 @@ struct ExternalThreadsSetting {
138038
138262
  static constexpr const char *Description = "The number of external threads that work on DuckDB tasks.";
138039
138263
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BIGINT;
138040
138264
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138265
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138041
138266
  static Value GetSetting(ClientContext &context);
138042
138267
  };
138043
138268
 
@@ -138046,6 +138271,7 @@ struct FileSearchPathSetting {
138046
138271
  static constexpr const char *Description = "A comma separated list of directories to search for input files";
138047
138272
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138048
138273
  static void SetLocal(ClientContext &context, const Value &parameter);
138274
+ static void ResetLocal(ClientContext &context);
138049
138275
  static Value GetSetting(ClientContext &context);
138050
138276
  };
138051
138277
 
@@ -138054,6 +138280,7 @@ struct ForceCompressionSetting {
138054
138280
  static constexpr const char *Description = "DEBUG SETTING: forces a specific compression method to be used";
138055
138281
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138056
138282
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138283
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138057
138284
  static Value GetSetting(ClientContext &context);
138058
138285
  };
138059
138286
 
@@ -138062,6 +138289,7 @@ struct ForceBitpackingModeSetting {
138062
138289
  static constexpr const char *Description = "DEBUG SETTING: forces a specific bitpacking mode";
138063
138290
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138064
138291
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138292
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138065
138293
  static Value GetSetting(ClientContext &context);
138066
138294
  };
138067
138295
 
@@ -138070,6 +138298,7 @@ struct HomeDirectorySetting {
138070
138298
  static constexpr const char *Description = "Sets the home directory used by the system";
138071
138299
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138072
138300
  static void SetLocal(ClientContext &context, const Value &parameter);
138301
+ static void ResetLocal(ClientContext &context);
138073
138302
  static Value GetSetting(ClientContext &context);
138074
138303
  };
138075
138304
 
@@ -138079,6 +138308,7 @@ struct LogQueryPathSetting {
138079
138308
  "Specifies the path to which queries should be logged (default: empty string, queries are not logged)";
138080
138309
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138081
138310
  static void SetLocal(ClientContext &context, const Value &parameter);
138311
+ static void ResetLocal(ClientContext &context);
138082
138312
  static Value GetSetting(ClientContext &context);
138083
138313
  };
138084
138314
 
@@ -138089,6 +138319,7 @@ struct MaximumExpressionDepthSetting {
138089
138319
  "expressions might lead to stack overflow errors.";
138090
138320
  static constexpr const LogicalTypeId InputType = LogicalTypeId::UBIGINT;
138091
138321
  static void SetLocal(ClientContext &context, const Value &parameter);
138322
+ static void ResetLocal(ClientContext &context);
138092
138323
  static Value GetSetting(ClientContext &context);
138093
138324
  };
138094
138325
 
@@ -138097,6 +138328,7 @@ struct MaximumMemorySetting {
138097
138328
  static constexpr const char *Description = "The maximum memory of the system (e.g. 1GB)";
138098
138329
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138099
138330
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138331
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138100
138332
  static Value GetSetting(ClientContext &context);
138101
138333
  };
138102
138334
 
@@ -138105,6 +138337,7 @@ struct PasswordSetting {
138105
138337
  static constexpr const char *Description = "The password to use. Ignored for legacy compatibility.";
138106
138338
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138107
138339
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138340
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138108
138341
  static Value GetSetting(ClientContext &context);
138109
138342
  };
138110
138343
 
@@ -138113,6 +138346,7 @@ struct PerfectHashThresholdSetting {
138113
138346
  static constexpr const char *Description = "Threshold in bytes for when to use a perfect hash table (default: 12)";
138114
138347
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BIGINT;
138115
138348
  static void SetLocal(ClientContext &context, const Value &parameter);
138349
+ static void ResetLocal(ClientContext &context);
138116
138350
  static Value GetSetting(ClientContext &context);
138117
138351
  };
138118
138352
 
@@ -138122,6 +138356,7 @@ struct PreserveIdentifierCase {
138122
138356
  "Whether or not to preserve the identifier case, instead of always lowercasing all non-quoted identifiers";
138123
138357
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138124
138358
  static void SetLocal(ClientContext &context, const Value &parameter);
138359
+ static void ResetLocal(ClientContext &context);
138125
138360
  static Value GetSetting(ClientContext &context);
138126
138361
  };
138127
138362
 
@@ -138132,6 +138367,7 @@ struct PreserveInsertionOrder {
138132
138367
  "that do not contain ORDER BY clauses.";
138133
138368
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138134
138369
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138370
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138135
138371
  static Value GetSetting(ClientContext &context);
138136
138372
  };
138137
138373
 
@@ -138140,6 +138376,7 @@ struct ProfilerHistorySize {
138140
138376
  static constexpr const char *Description = "Sets the profiler history size";
138141
138377
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BIGINT;
138142
138378
  static void SetLocal(ClientContext &context, const Value &parameter);
138379
+ static void ResetLocal(ClientContext &context);
138143
138380
  static Value GetSetting(ClientContext &context);
138144
138381
  };
138145
138382
 
@@ -138149,6 +138386,7 @@ struct ProfileOutputSetting {
138149
138386
  "The file to which profile output should be saved, or empty to print to the terminal";
138150
138387
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138151
138388
  static void SetLocal(ClientContext &context, const Value &parameter);
138389
+ static void ResetLocal(ClientContext &context);
138152
138390
  static Value GetSetting(ClientContext &context);
138153
138391
  };
138154
138392
 
@@ -138157,6 +138395,7 @@ struct ProfilingModeSetting {
138157
138395
  static constexpr const char *Description = "The profiling mode (STANDARD or DETAILED)";
138158
138396
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138159
138397
  static void SetLocal(ClientContext &context, const Value &parameter);
138398
+ static void ResetLocal(ClientContext &context);
138160
138399
  static Value GetSetting(ClientContext &context);
138161
138400
  };
138162
138401
 
@@ -138166,6 +138405,7 @@ struct ProgressBarTimeSetting {
138166
138405
  "Sets the time (in milliseconds) how long a query needs to take before we start printing a progress bar";
138167
138406
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BIGINT;
138168
138407
  static void SetLocal(ClientContext &context, const Value &parameter);
138408
+ static void ResetLocal(ClientContext &context);
138169
138409
  static Value GetSetting(ClientContext &context);
138170
138410
  };
138171
138411
 
@@ -138175,6 +138415,7 @@ struct SchemaSetting {
138175
138415
  "Sets the default search schema. Equivalent to setting search_path to a single value.";
138176
138416
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138177
138417
  static void SetLocal(ClientContext &context, const Value &parameter);
138418
+ static void ResetLocal(ClientContext &context);
138178
138419
  static Value GetSetting(ClientContext &context);
138179
138420
  };
138180
138421
 
@@ -138184,6 +138425,7 @@ struct SearchPathSetting {
138184
138425
  "Sets the default search search path as a comma-separated list of values";
138185
138426
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138186
138427
  static void SetLocal(ClientContext &context, const Value &parameter);
138428
+ static void ResetLocal(ClientContext &context);
138187
138429
  static Value GetSetting(ClientContext &context);
138188
138430
  };
138189
138431
 
@@ -138192,6 +138434,7 @@ struct TempDirectorySetting {
138192
138434
  static constexpr const char *Description = "Set the directory to which to write temp files";
138193
138435
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138194
138436
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138437
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138195
138438
  static Value GetSetting(ClientContext &context);
138196
138439
  };
138197
138440
 
@@ -138200,6 +138443,7 @@ struct ThreadsSetting {
138200
138443
  static constexpr const char *Description = "The number of total threads used by the system.";
138201
138444
  static constexpr const LogicalTypeId InputType = LogicalTypeId::BIGINT;
138202
138445
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138446
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138203
138447
  static Value GetSetting(ClientContext &context);
138204
138448
  };
138205
138449
 
@@ -138208,30 +138452,53 @@ struct UsernameSetting {
138208
138452
  static constexpr const char *Description = "The username to use. Ignored for legacy compatibility.";
138209
138453
  static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
138210
138454
  static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
138455
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
138211
138456
  static Value GetSetting(ClientContext &context);
138212
138457
  };
138213
138458
 
138214
138459
  } // namespace duckdb
138215
138460
 
138216
138461
 
138462
+ #ifndef DUCKDB_NO_THREADS
138463
+
138464
+ #endif
138465
+
138217
138466
  namespace duckdb {
138218
138467
 
138219
138468
  #define DUCKDB_GLOBAL(_PARAM) \
138220
- { _PARAM::Name, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, nullptr, _PARAM::GetSetting }
138469
+ { \
138470
+ _PARAM::Name, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, nullptr, _PARAM::ResetGlobal, \
138471
+ nullptr, _PARAM::GetSetting \
138472
+ }
138221
138473
  #define DUCKDB_GLOBAL_ALIAS(_ALIAS, _PARAM) \
138222
- { _ALIAS, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, nullptr, _PARAM::GetSetting }
138474
+ { \
138475
+ _ALIAS, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, nullptr, _PARAM::ResetGlobal, nullptr, \
138476
+ _PARAM::GetSetting \
138477
+ }
138223
138478
 
138224
138479
  #define DUCKDB_LOCAL(_PARAM) \
138225
- { _PARAM::Name, _PARAM::Description, _PARAM::InputType, nullptr, _PARAM::SetLocal, _PARAM::GetSetting }
138480
+ { \
138481
+ _PARAM::Name, _PARAM::Description, _PARAM::InputType, nullptr, _PARAM::SetLocal, nullptr, _PARAM::ResetLocal, \
138482
+ _PARAM::GetSetting \
138483
+ }
138226
138484
  #define DUCKDB_LOCAL_ALIAS(_ALIAS, _PARAM) \
138227
- { _ALIAS, _PARAM::Description, _PARAM::InputType, nullptr, _PARAM::SetLocal, _PARAM::GetSetting }
138485
+ { \
138486
+ _ALIAS, _PARAM::Description, _PARAM::InputType, nullptr, _PARAM::SetLocal, nullptr, _PARAM::ResetLocal, \
138487
+ _PARAM::GetSetting \
138488
+ }
138228
138489
 
138229
138490
  #define DUCKDB_GLOBAL_LOCAL(_PARAM) \
138230
- { _PARAM::Name, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, _PARAM::SetLocal, _PARAM::GetSetting }
138491
+ { \
138492
+ _PARAM::Name, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, _PARAM::SetLocal, \
138493
+ _PARAM::ResetGlobal, _PARAM::ResetLocal, _PARAM::GetSetting \
138494
+ }
138231
138495
  #define DUCKDB_GLOBAL_LOCAL_ALIAS(_ALIAS, _PARAM) \
138232
- { _ALIAS, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, _PARAM::SetLocal, _PARAM::GetSetting }
138496
+ { \
138497
+ _ALIAS, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, _PARAM::SetLocal, _PARAM::ResetGlobal, \
138498
+ _PARAM::ResetLocal, _PARAM::GetSetting \
138499
+ }
138233
138500
  #define FINAL_SETTING \
138234
- { nullptr, nullptr, LogicalTypeId::INVALID, nullptr, nullptr, nullptr }
138501
+ { nullptr, nullptr, LogicalTypeId::INVALID, nullptr, nullptr, nullptr, nullptr, nullptr }
138235
138502
 
138236
138503
  static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting),
138237
138504
  DUCKDB_GLOBAL(CheckpointThresholdSetting),
@@ -138335,24 +138602,68 @@ void DBConfig::SetOption(DatabaseInstance *db, const ConfigurationOption &option
138335
138602
  if (!option.set_global) {
138336
138603
  throw InternalException("Could not set option \"%s\" as a global option", option.name);
138337
138604
  }
138605
+ D_ASSERT(option.reset_global);
138338
138606
  Value input = value.DefaultCastAs(option.parameter_type);
138339
138607
  option.set_global(db, *this, input);
138340
138608
  }
138341
138609
 
138610
+ void DBConfig::ResetOption(DatabaseInstance *db, const ConfigurationOption &option) {
138611
+ lock_guard<mutex> l(config_lock);
138612
+ if (!option.reset_global) {
138613
+ throw InternalException("Could not reset option \"%s\" as a global option", option.name);
138614
+ }
138615
+ D_ASSERT(option.set_global);
138616
+ option.reset_global(db, *this);
138617
+ }
138618
+
138342
138619
  void DBConfig::SetOption(const string &name, Value value) {
138343
138620
  lock_guard<mutex> l(config_lock);
138344
138621
  options.set_variables[name] = move(value);
138345
138622
  }
138346
138623
 
138347
- void DBConfig::AddExtensionOption(string name, string description, LogicalType parameter,
138348
- set_option_callback_t function) {
138349
- extension_parameters.insert(make_pair(move(name), ExtensionOption(move(description), move(parameter), function)));
138624
+ void DBConfig::ResetOption(const string &name) {
138625
+ lock_guard<mutex> l(config_lock);
138626
+ auto extension_option = extension_parameters.find(name);
138627
+ D_ASSERT(extension_option != extension_parameters.end());
138628
+ auto &default_value = extension_option->second.default_value;
138629
+ if (!default_value.IsNull()) {
138630
+ // Default is not NULL, override the setting
138631
+ options.set_variables[name] = default_value;
138632
+ } else {
138633
+ // Otherwise just remove it from the 'set_variables' map
138634
+ options.set_variables.erase(name);
138635
+ }
138636
+ }
138637
+
138638
+ void DBConfig::AddExtensionOption(const string &name, string description, LogicalType parameter,
138639
+ const Value &default_value, set_option_callback_t function) {
138640
+ extension_parameters.insert(
138641
+ make_pair(name, ExtensionOption(move(description), move(parameter), function, default_value)));
138642
+ if (!default_value.IsNull()) {
138643
+ // Default value is set, insert it into the 'set_variables' list
138644
+ options.set_variables[name] = default_value;
138645
+ }
138350
138646
  }
138351
138647
 
138352
138648
  CastFunctionSet &DBConfig::GetCastFunctions() {
138353
138649
  return *cast_functions;
138354
138650
  }
138355
138651
 
138652
+ void DBConfig::SetDefaultMaxMemory() {
138653
+ auto memory = FileSystem::GetAvailableMemory();
138654
+ if (memory != DConstants::INVALID_INDEX) {
138655
+ options.maximum_memory = memory * 8 / 10;
138656
+ }
138657
+ }
138658
+
138659
+ void DBConfig::SetDefaultMaxThreads() {
138660
+ #ifndef DUCKDB_NO_THREADS
138661
+ options.maximum_threads = std::thread::hardware_concurrency();
138662
+ #else
138663
+ options.maximum_threads = 1;
138664
+ #endif
138665
+ }
138666
+
138356
138667
  idx_t DBConfig::ParseMemoryLimit(const string &arg) {
138357
138668
  if (arg[0] == '-' || arg == "null" || arg == "none") {
138358
138669
  return DConstants::INVALID_INDEX;
@@ -139263,17 +139574,10 @@ void DatabaseInstance::Configure(DBConfig &new_config) {
139263
139574
  config.file_system = make_unique<VirtualFileSystem>();
139264
139575
  }
139265
139576
  if (config.options.maximum_memory == (idx_t)-1) {
139266
- auto memory = FileSystem::GetAvailableMemory();
139267
- if (memory != DConstants::INVALID_INDEX) {
139268
- config.options.maximum_memory = memory * 8 / 10;
139269
- }
139577
+ config.SetDefaultMaxMemory();
139270
139578
  }
139271
139579
  if (new_config.options.maximum_threads == (idx_t)-1) {
139272
- #ifndef DUCKDB_NO_THREADS
139273
- config.options.maximum_threads = std::thread::hardware_concurrency();
139274
- #else
139275
- config.options.maximum_threads = 1;
139276
- #endif
139580
+ config.SetDefaultMaxThreads();
139277
139581
  }
139278
139582
  config.allocator = move(new_config.allocator);
139279
139583
  if (!config.allocator) {
@@ -152358,6 +152662,10 @@ void AccessModeSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const
152358
152662
  }
152359
152663
  }
152360
152664
 
152665
+ void AccessModeSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152666
+ config.options.access_mode = DBConfig().options.access_mode;
152667
+ }
152668
+
152361
152669
  Value AccessModeSetting::GetSetting(ClientContext &context) {
152362
152670
  auto &config = DBConfig::GetConfig(context);
152363
152671
  switch (config.options.access_mode) {
@@ -152380,6 +152688,10 @@ void CheckpointThresholdSetting::SetGlobal(DatabaseInstance *db, DBConfig &confi
152380
152688
  config.options.checkpoint_wal_size = new_limit;
152381
152689
  }
152382
152690
 
152691
+ void CheckpointThresholdSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152692
+ config.options.checkpoint_wal_size = DBConfig().options.checkpoint_wal_size;
152693
+ }
152694
+
152383
152695
  Value CheckpointThresholdSetting::GetSetting(ClientContext &context) {
152384
152696
  auto &config = DBConfig::GetConfig(context);
152385
152697
  return Value(StringUtil::BytesToHumanReadableString(config.options.checkpoint_wal_size));
@@ -152404,13 +152716,35 @@ void DebugCheckpointAbort::SetGlobal(DatabaseInstance *db, DBConfig &config, con
152404
152716
  }
152405
152717
  }
152406
152718
 
152719
+ void DebugCheckpointAbort::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152720
+ config.options.checkpoint_abort = DBConfig().options.checkpoint_abort;
152721
+ }
152722
+
152407
152723
  Value DebugCheckpointAbort::GetSetting(ClientContext &context) {
152408
- return Value();
152724
+ auto &config = DBConfig::GetConfig(*context.db);
152725
+ auto setting = config.options.checkpoint_abort;
152726
+ switch (setting) {
152727
+ case CheckpointAbort::NO_ABORT:
152728
+ return "none";
152729
+ case CheckpointAbort::DEBUG_ABORT_BEFORE_TRUNCATE:
152730
+ return "before_truncate";
152731
+ case CheckpointAbort::DEBUG_ABORT_BEFORE_HEADER:
152732
+ return "before_header";
152733
+ case CheckpointAbort::DEBUG_ABORT_AFTER_FREE_LIST_WRITE:
152734
+ return "after_free_list_write";
152735
+ default:
152736
+ throw InternalException("Type not implemented for CheckpointAbort");
152737
+ }
152409
152738
  }
152410
152739
 
152411
152740
  //===--------------------------------------------------------------------===//
152412
152741
  // Debug Force External
152413
152742
  //===--------------------------------------------------------------------===//
152743
+
152744
+ void DebugForceExternal::ResetLocal(ClientContext &context) {
152745
+ ClientConfig::GetConfig(context).force_external = ClientConfig().force_external;
152746
+ }
152747
+
152414
152748
  void DebugForceExternal::SetLocal(ClientContext &context, const Value &input) {
152415
152749
  ClientConfig::GetConfig(context).force_external = input.GetValue<bool>();
152416
152750
  }
@@ -152422,6 +152756,11 @@ Value DebugForceExternal::GetSetting(ClientContext &context) {
152422
152756
  //===--------------------------------------------------------------------===//
152423
152757
  // Debug Force NoCrossProduct
152424
152758
  //===--------------------------------------------------------------------===//
152759
+
152760
+ void DebugForceNoCrossProduct::ResetLocal(ClientContext &context) {
152761
+ ClientConfig::GetConfig(context).force_no_cross_product = ClientConfig().force_no_cross_product;
152762
+ }
152763
+
152425
152764
  void DebugForceNoCrossProduct::SetLocal(ClientContext &context, const Value &input) {
152426
152765
  ClientConfig::GetConfig(context).force_no_cross_product = input.GetValue<bool>();
152427
152766
  }
@@ -152446,6 +152785,10 @@ void DebugWindowMode::SetGlobal(DatabaseInstance *db, DBConfig &config, const Va
152446
152785
  }
152447
152786
  }
152448
152787
 
152788
+ void DebugWindowMode::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152789
+ config.options.window_mode = DBConfig().options.window_mode;
152790
+ }
152791
+
152449
152792
  Value DebugWindowMode::GetSetting(ClientContext &context) {
152450
152793
  return Value();
152451
152794
  }
@@ -152458,6 +152801,15 @@ void DefaultCollationSetting::SetGlobal(DatabaseInstance *db, DBConfig &config,
152458
152801
  config.options.collation = parameter;
152459
152802
  }
152460
152803
 
152804
+ void DefaultCollationSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152805
+ config.options.collation = DBConfig().options.collation;
152806
+ }
152807
+
152808
+ void DefaultCollationSetting::ResetLocal(ClientContext &context) {
152809
+ auto &config = DBConfig::GetConfig(context);
152810
+ config.options.collation = DBConfig().options.collation;
152811
+ }
152812
+
152461
152813
  void DefaultCollationSetting::SetLocal(ClientContext &context, const Value &input) {
152462
152814
  auto parameter = input.ToString();
152463
152815
  // bind the collation to verify that it exists
@@ -152486,6 +152838,10 @@ void DefaultOrderSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, cons
152486
152838
  }
152487
152839
  }
152488
152840
 
152841
+ void DefaultOrderSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152842
+ config.options.default_order_type = DBConfig().options.default_order_type;
152843
+ }
152844
+
152489
152845
  Value DefaultOrderSetting::GetSetting(ClientContext &context) {
152490
152846
  auto &config = DBConfig::GetConfig(context);
152491
152847
  switch (config.options.default_order_type) {
@@ -152516,6 +152872,10 @@ void DefaultNullOrderSetting::SetGlobal(DatabaseInstance *db, DBConfig &config,
152516
152872
  }
152517
152873
  }
152518
152874
 
152875
+ void DefaultNullOrderSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152876
+ config.options.default_null_order = DBConfig().options.default_null_order;
152877
+ }
152878
+
152519
152879
  Value DefaultNullOrderSetting::GetSetting(ClientContext &context) {
152520
152880
  auto &config = DBConfig::GetConfig(context);
152521
152881
  switch (config.options.default_null_order) {
@@ -152545,6 +152905,10 @@ void DisabledOptimizersSetting::SetGlobal(DatabaseInstance *db, DBConfig &config
152545
152905
  config.options.disabled_optimizers = move(disabled_optimizers);
152546
152906
  }
152547
152907
 
152908
+ void DisabledOptimizersSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152909
+ config.options.disabled_optimizers = DBConfig().options.disabled_optimizers;
152910
+ }
152911
+
152548
152912
  Value DisabledOptimizersSetting::GetSetting(ClientContext &context) {
152549
152913
  auto &config = DBConfig::GetConfig(context);
152550
152914
  string result;
@@ -152568,6 +152932,13 @@ void EnableExternalAccessSetting::SetGlobal(DatabaseInstance *db, DBConfig &conf
152568
152932
  config.options.enable_external_access = new_value;
152569
152933
  }
152570
152934
 
152935
+ void EnableExternalAccessSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152936
+ if (db) {
152937
+ throw InvalidInputException("Cannot change enable_external_access setting while database is running");
152938
+ }
152939
+ config.options.enable_external_access = DBConfig().options.enable_external_access;
152940
+ }
152941
+
152571
152942
  Value EnableExternalAccessSetting::GetSetting(ClientContext &context) {
152572
152943
  auto &config = DBConfig::GetConfig(context);
152573
152944
  return Value::BOOLEAN(config.options.enable_external_access);
@@ -152580,6 +152951,10 @@ void EnableFSSTVectors::SetGlobal(DatabaseInstance *db, DBConfig &config, const
152580
152951
  config.options.enable_fsst_vectors = input.GetValue<bool>();
152581
152952
  }
152582
152953
 
152954
+ void EnableFSSTVectors::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152955
+ config.options.enable_fsst_vectors = DBConfig().options.enable_fsst_vectors;
152956
+ }
152957
+
152583
152958
  Value EnableFSSTVectors::GetSetting(ClientContext &context) {
152584
152959
  auto &config = DBConfig::GetConfig(context);
152585
152960
  return Value::BOOLEAN(config.options.enable_fsst_vectors);
@@ -152596,6 +152971,13 @@ void AllowUnsignedExtensionsSetting::SetGlobal(DatabaseInstance *db, DBConfig &c
152596
152971
  config.options.allow_unsigned_extensions = new_value;
152597
152972
  }
152598
152973
 
152974
+ void AllowUnsignedExtensionsSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152975
+ if (db) {
152976
+ throw InvalidInputException("Cannot change allow_unsigned_extensions setting while database is running");
152977
+ }
152978
+ config.options.allow_unsigned_extensions = DBConfig().options.allow_unsigned_extensions;
152979
+ }
152980
+
152599
152981
  Value AllowUnsignedExtensionsSetting::GetSetting(ClientContext &context) {
152600
152982
  auto &config = DBConfig::GetConfig(context);
152601
152983
  return Value::BOOLEAN(config.options.allow_unsigned_extensions);
@@ -152608,6 +152990,10 @@ void EnableObjectCacheSetting::SetGlobal(DatabaseInstance *db, DBConfig &config,
152608
152990
  config.options.object_cache_enable = input.GetValue<bool>();
152609
152991
  }
152610
152992
 
152993
+ void EnableObjectCacheSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
152994
+ config.options.object_cache_enable = DBConfig().options.object_cache_enable;
152995
+ }
152996
+
152611
152997
  Value EnableObjectCacheSetting::GetSetting(ClientContext &context) {
152612
152998
  auto &config = DBConfig::GetConfig(context);
152613
152999
  return Value::BOOLEAN(config.options.object_cache_enable);
@@ -152620,6 +153006,10 @@ void EnableHTTPMetadataCacheSetting::SetGlobal(DatabaseInstance *db, DBConfig &c
152620
153006
  config.options.http_metadata_cache_enable = input.GetValue<bool>();
152621
153007
  }
152622
153008
 
153009
+ void EnableHTTPMetadataCacheSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153010
+ config.options.http_metadata_cache_enable = DBConfig().options.http_metadata_cache_enable;
153011
+ }
153012
+
152623
153013
  Value EnableHTTPMetadataCacheSetting::GetSetting(ClientContext &context) {
152624
153014
  auto &config = DBConfig::GetConfig(context);
152625
153015
  return Value::BOOLEAN(config.options.http_metadata_cache_enable);
@@ -152628,6 +153018,14 @@ Value EnableHTTPMetadataCacheSetting::GetSetting(ClientContext &context) {
152628
153018
  //===--------------------------------------------------------------------===//
152629
153019
  // Enable Profiling
152630
153020
  //===--------------------------------------------------------------------===//
153021
+
153022
+ void EnableProfilingSetting::ResetLocal(ClientContext &context) {
153023
+ auto &config = ClientConfig::GetConfig(context);
153024
+ config.profiler_print_format = ClientConfig().profiler_print_format;
153025
+ config.enable_profiler = ClientConfig().enable_profiler;
153026
+ config.emit_profiler_output = ClientConfig().emit_profiler_output;
153027
+ }
153028
+
152631
153029
  void EnableProfilingSetting::SetLocal(ClientContext &context, const Value &input) {
152632
153030
  auto parameter = StringUtil::Lower(input.ToString());
152633
153031
 
@@ -152666,6 +153064,11 @@ Value EnableProfilingSetting::GetSetting(ClientContext &context) {
152666
153064
  //===--------------------------------------------------------------------===//
152667
153065
  // Enable Progress Bar
152668
153066
  //===--------------------------------------------------------------------===//
153067
+
153068
+ void EnableProgressBarSetting::ResetLocal(ClientContext &context) {
153069
+ ClientConfig::GetConfig(context).enable_progress_bar = ClientConfig().enable_progress_bar;
153070
+ }
153071
+
152669
153072
  void EnableProgressBarSetting::SetLocal(ClientContext &context, const Value &input) {
152670
153073
  ClientConfig::GetConfig(context).enable_progress_bar = input.GetValue<bool>();
152671
153074
  }
@@ -152681,6 +153084,10 @@ void EnableProgressBarPrintSetting::SetLocal(ClientContext &context, const Value
152681
153084
  ClientConfig::GetConfig(context).print_progress_bar = input.GetValue<bool>();
152682
153085
  }
152683
153086
 
153087
+ void EnableProgressBarPrintSetting::ResetLocal(ClientContext &context) {
153088
+ ClientConfig::GetConfig(context).print_progress_bar = ClientConfig().print_progress_bar;
153089
+ }
153090
+
152684
153091
  Value EnableProgressBarPrintSetting::GetSetting(ClientContext &context) {
152685
153092
  return Value::BOOLEAN(ClientConfig::GetConfig(context).print_progress_bar);
152686
153093
  }
@@ -152692,6 +153099,10 @@ void ExperimentalParallelCSVSetting::SetGlobal(DatabaseInstance *db, DBConfig &c
152692
153099
  config.options.experimental_parallel_csv_reader = input.GetValue<bool>();
152693
153100
  }
152694
153101
 
153102
+ void ExperimentalParallelCSVSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153103
+ config.options.experimental_parallel_csv_reader = DBConfig().options.experimental_parallel_csv_reader;
153104
+ }
153105
+
152695
153106
  Value ExperimentalParallelCSVSetting::GetSetting(ClientContext &context) {
152696
153107
  auto &config = DBConfig::GetConfig(context);
152697
153108
  return Value::BIGINT(config.options.experimental_parallel_csv_reader);
@@ -152700,6 +153111,11 @@ Value ExperimentalParallelCSVSetting::GetSetting(ClientContext &context) {
152700
153111
  //===--------------------------------------------------------------------===//
152701
153112
  // Explain Output
152702
153113
  //===--------------------------------------------------------------------===//
153114
+
153115
+ void ExplainOutputSetting::ResetLocal(ClientContext &context) {
153116
+ ClientConfig::GetConfig(context).explain_output_type = ClientConfig().explain_output_type;
153117
+ }
153118
+
152703
153119
  void ExplainOutputSetting::SetLocal(ClientContext &context, const Value &input) {
152704
153120
  auto parameter = StringUtil::Lower(input.ToString());
152705
153121
  if (parameter == "all") {
@@ -152734,6 +153150,10 @@ void ExternalThreadsSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, c
152734
153150
  config.options.external_threads = input.GetValue<int64_t>();
152735
153151
  }
152736
153152
 
153153
+ void ExternalThreadsSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153154
+ config.options.external_threads = DBConfig().options.external_threads;
153155
+ }
153156
+
152737
153157
  Value ExternalThreadsSetting::GetSetting(ClientContext &context) {
152738
153158
  auto &config = DBConfig::GetConfig(context);
152739
153159
  return Value::BIGINT(config.options.external_threads);
@@ -152742,6 +153162,12 @@ Value ExternalThreadsSetting::GetSetting(ClientContext &context) {
152742
153162
  //===--------------------------------------------------------------------===//
152743
153163
  // File Search Path
152744
153164
  //===--------------------------------------------------------------------===//
153165
+
153166
+ void FileSearchPathSetting::ResetLocal(ClientContext &context) {
153167
+ auto &client_data = ClientData::Get(context);
153168
+ client_data.file_search_path.clear();
153169
+ }
153170
+
152745
153171
  void FileSearchPathSetting::SetLocal(ClientContext &context, const Value &input) {
152746
153172
  auto parameter = input.ToString();
152747
153173
  auto &client_data = ClientData::Get(context);
@@ -152758,20 +153184,25 @@ Value FileSearchPathSetting::GetSetting(ClientContext &context) {
152758
153184
  //===--------------------------------------------------------------------===//
152759
153185
  void ForceCompressionSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
152760
153186
  auto compression = StringUtil::Lower(input.ToString());
152761
- if (compression == "none") {
153187
+ if (compression == "none" || compression == "auto") {
152762
153188
  config.options.force_compression = CompressionType::COMPRESSION_AUTO;
152763
153189
  } else {
152764
153190
  auto compression_type = CompressionTypeFromString(compression);
152765
153191
  if (compression_type == CompressionType::COMPRESSION_AUTO) {
152766
- throw ParserException("Unrecognized option for force_compression, expected none, uncompressed, rle, "
152767
- "dictionary, pfor, chimp, patas, bitpacking or fsst");
153192
+ auto compression_types = StringUtil::Join(ListCompressionTypes(), ", ");
153193
+ throw ParserException("Unrecognized option for PRAGMA force_compression, expected %s", compression_types);
152768
153194
  }
152769
153195
  config.options.force_compression = compression_type;
152770
153196
  }
152771
153197
  }
152772
153198
 
153199
+ void ForceCompressionSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153200
+ config.options.force_compression = DBConfig().options.force_compression;
153201
+ }
153202
+
152773
153203
  Value ForceCompressionSetting::GetSetting(ClientContext &context) {
152774
- return Value(CompressionTypeToString(context.db->config.options.force_compression));
153204
+ auto &config = DBConfig::GetConfig(*context.db);
153205
+ return CompressionTypeToString(config.options.force_compression);
152775
153206
  }
152776
153207
 
152777
153208
  //===--------------------------------------------------------------------===//
@@ -152792,6 +153223,10 @@ void ForceBitpackingModeSetting::SetGlobal(DatabaseInstance *db, DBConfig &confi
152792
153223
  }
152793
153224
  }
152794
153225
 
153226
+ void ForceBitpackingModeSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153227
+ config.options.force_bitpacking_mode = DBConfig().options.force_bitpacking_mode;
153228
+ }
153229
+
152795
153230
  Value ForceBitpackingModeSetting::GetSetting(ClientContext &context) {
152796
153231
  return Value(BitpackingModeToString(context.db->config.options.force_bitpacking_mode));
152797
153232
  }
@@ -152799,6 +153234,11 @@ Value ForceBitpackingModeSetting::GetSetting(ClientContext &context) {
152799
153234
  //===--------------------------------------------------------------------===//
152800
153235
  // Home Directory
152801
153236
  //===--------------------------------------------------------------------===//
153237
+
153238
+ void HomeDirectorySetting::ResetLocal(ClientContext &context) {
153239
+ ClientConfig::GetConfig(context).home_directory = ClientConfig().home_directory;
153240
+ }
153241
+
152802
153242
  void HomeDirectorySetting::SetLocal(ClientContext &context, const Value &input) {
152803
153243
  auto &config = ClientConfig::GetConfig(context);
152804
153244
  config.home_directory = input.IsNull() ? string() : input.ToString();
@@ -152812,6 +153252,13 @@ Value HomeDirectorySetting::GetSetting(ClientContext &context) {
152812
153252
  //===--------------------------------------------------------------------===//
152813
153253
  // Log Query Path
152814
153254
  //===--------------------------------------------------------------------===//
153255
+
153256
+ void LogQueryPathSetting::ResetLocal(ClientContext &context) {
153257
+ auto &client_data = ClientData::Get(context);
153258
+ // TODO: verify that this does the right thing
153259
+ client_data.log_query_writer = move(ClientData(context).log_query_writer);
153260
+ }
153261
+
152815
153262
  void LogQueryPathSetting::SetLocal(ClientContext &context, const Value &input) {
152816
153263
  auto &client_data = ClientData::Get(context);
152817
153264
  auto path = input.ToString();
@@ -152833,6 +153280,11 @@ Value LogQueryPathSetting::GetSetting(ClientContext &context) {
152833
153280
  //===--------------------------------------------------------------------===//
152834
153281
  // Maximum Expression Depth
152835
153282
  //===--------------------------------------------------------------------===//
153283
+
153284
+ void MaximumExpressionDepthSetting::ResetLocal(ClientContext &context) {
153285
+ ClientConfig::GetConfig(context).max_expression_depth = ClientConfig().max_expression_depth;
153286
+ }
153287
+
152836
153288
  void MaximumExpressionDepthSetting::SetLocal(ClientContext &context, const Value &input) {
152837
153289
  ClientConfig::GetConfig(context).max_expression_depth = input.GetValue<uint64_t>();
152838
153290
  }
@@ -152851,6 +153303,10 @@ void MaximumMemorySetting::SetGlobal(DatabaseInstance *db, DBConfig &config, con
152851
153303
  }
152852
153304
  }
152853
153305
 
153306
+ void MaximumMemorySetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153307
+ config.SetDefaultMaxMemory();
153308
+ }
153309
+
152854
153310
  Value MaximumMemorySetting::GetSetting(ClientContext &context) {
152855
153311
  auto &config = DBConfig::GetConfig(context);
152856
153312
  return Value(StringUtil::BytesToHumanReadableString(config.options.maximum_memory));
@@ -152863,6 +153319,10 @@ void PasswordSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Va
152863
153319
  // nop
152864
153320
  }
152865
153321
 
153322
+ void PasswordSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153323
+ // nop
153324
+ }
153325
+
152866
153326
  Value PasswordSetting::GetSetting(ClientContext &context) {
152867
153327
  return Value();
152868
153328
  }
@@ -152870,6 +153330,11 @@ Value PasswordSetting::GetSetting(ClientContext &context) {
152870
153330
  //===--------------------------------------------------------------------===//
152871
153331
  // Perfect Hash Threshold
152872
153332
  //===--------------------------------------------------------------------===//
153333
+
153334
+ void PerfectHashThresholdSetting::ResetLocal(ClientContext &context) {
153335
+ ClientConfig::GetConfig(context).perfect_ht_threshold = ClientConfig().perfect_ht_threshold;
153336
+ }
153337
+
152873
153338
  void PerfectHashThresholdSetting::SetLocal(ClientContext &context, const Value &input) {
152874
153339
  auto bits = input.GetValue<int32_t>();
152875
153340
  if (bits < 0 || bits > 32) {
@@ -152885,6 +153350,11 @@ Value PerfectHashThresholdSetting::GetSetting(ClientContext &context) {
152885
153350
  //===--------------------------------------------------------------------===//
152886
153351
  // PreserveIdentifierCase
152887
153352
  //===--------------------------------------------------------------------===//
153353
+
153354
+ void PreserveIdentifierCase::ResetLocal(ClientContext &context) {
153355
+ ClientConfig::GetConfig(context).preserve_identifier_case = ClientConfig().preserve_identifier_case;
153356
+ }
153357
+
152888
153358
  void PreserveIdentifierCase::SetLocal(ClientContext &context, const Value &input) {
152889
153359
  ClientConfig::GetConfig(context).preserve_identifier_case = input.GetValue<bool>();
152890
153360
  }
@@ -152900,6 +153370,10 @@ void PreserveInsertionOrder::SetGlobal(DatabaseInstance *db, DBConfig &config, c
152900
153370
  config.options.preserve_insertion_order = input.GetValue<bool>();
152901
153371
  }
152902
153372
 
153373
+ void PreserveInsertionOrder::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153374
+ config.options.preserve_insertion_order = DBConfig().options.preserve_insertion_order;
153375
+ }
153376
+
152903
153377
  Value PreserveInsertionOrder::GetSetting(ClientContext &context) {
152904
153378
  auto &config = DBConfig::GetConfig(context);
152905
153379
  return Value::BOOLEAN(config.options.preserve_insertion_order);
@@ -152908,6 +153382,12 @@ Value PreserveInsertionOrder::GetSetting(ClientContext &context) {
152908
153382
  //===--------------------------------------------------------------------===//
152909
153383
  // Profiler History Size
152910
153384
  //===--------------------------------------------------------------------===//
153385
+
153386
+ void ProfilerHistorySize::ResetLocal(ClientContext &context) {
153387
+ auto &client_data = ClientData::Get(context);
153388
+ client_data.query_profiler_history->ResetProfilerHistorySize();
153389
+ }
153390
+
152911
153391
  void ProfilerHistorySize::SetLocal(ClientContext &context, const Value &input) {
152912
153392
  auto size = input.GetValue<int64_t>();
152913
153393
  if (size <= 0) {
@@ -152924,6 +153404,11 @@ Value ProfilerHistorySize::GetSetting(ClientContext &context) {
152924
153404
  //===--------------------------------------------------------------------===//
152925
153405
  // Profile Output
152926
153406
  //===--------------------------------------------------------------------===//
153407
+
153408
+ void ProfileOutputSetting::ResetLocal(ClientContext &context) {
153409
+ ClientConfig::GetConfig(context).profiler_save_location = ClientConfig().profiler_save_location;
153410
+ }
153411
+
152927
153412
  void ProfileOutputSetting::SetLocal(ClientContext &context, const Value &input) {
152928
153413
  auto &config = ClientConfig::GetConfig(context);
152929
153414
  auto parameter = input.ToString();
@@ -152938,6 +153423,13 @@ Value ProfileOutputSetting::GetSetting(ClientContext &context) {
152938
153423
  //===--------------------------------------------------------------------===//
152939
153424
  // Profiling Mode
152940
153425
  //===--------------------------------------------------------------------===//
153426
+
153427
+ void ProfilingModeSetting::ResetLocal(ClientContext &context) {
153428
+ ClientConfig::GetConfig(context).enable_profiler = ClientConfig().enable_profiler;
153429
+ ClientConfig::GetConfig(context).enable_detailed_profiling = ClientConfig().enable_detailed_profiling;
153430
+ ClientConfig::GetConfig(context).emit_profiler_output = ClientConfig().emit_profiler_output;
153431
+ }
153432
+
152941
153433
  void ProfilingModeSetting::SetLocal(ClientContext &context, const Value &input) {
152942
153434
  auto parameter = StringUtil::Lower(input.ToString());
152943
153435
  auto &config = ClientConfig::GetConfig(context);
@@ -152965,6 +153457,12 @@ Value ProfilingModeSetting::GetSetting(ClientContext &context) {
152965
153457
  //===--------------------------------------------------------------------===//
152966
153458
  // Progress Bar Time
152967
153459
  //===--------------------------------------------------------------------===//
153460
+
153461
+ void ProgressBarTimeSetting::ResetLocal(ClientContext &context) {
153462
+ ClientConfig::GetConfig(context).wait_time = ClientConfig().wait_time;
153463
+ ClientConfig::GetConfig(context).enable_progress_bar = ClientConfig().enable_progress_bar;
153464
+ }
153465
+
152968
153466
  void ProgressBarTimeSetting::SetLocal(ClientContext &context, const Value &input) {
152969
153467
  ClientConfig::GetConfig(context).wait_time = input.GetValue<int32_t>();
152970
153468
  ClientConfig::GetConfig(context).enable_progress_bar = true;
@@ -152977,6 +153475,13 @@ Value ProgressBarTimeSetting::GetSetting(ClientContext &context) {
152977
153475
  //===--------------------------------------------------------------------===//
152978
153476
  // Schema
152979
153477
  //===--------------------------------------------------------------------===//
153478
+
153479
+ void SchemaSetting::ResetLocal(ClientContext &context) {
153480
+ // FIXME: catalog_search_path is controlled by both SchemaSetting and SearchPathSetting
153481
+ auto &client_data = ClientData::Get(context);
153482
+ client_data.catalog_search_path->Reset();
153483
+ }
153484
+
152980
153485
  void SchemaSetting::SetLocal(ClientContext &context, const Value &input) {
152981
153486
  auto parameter = input.ToString();
152982
153487
  auto &client_data = ClientData::Get(context);
@@ -152990,6 +153495,13 @@ Value SchemaSetting::GetSetting(ClientContext &context) {
152990
153495
  //===--------------------------------------------------------------------===//
152991
153496
  // Search Path
152992
153497
  //===--------------------------------------------------------------------===//
153498
+
153499
+ void SearchPathSetting::ResetLocal(ClientContext &context) {
153500
+ // FIXME: catalog_search_path is controlled by both SchemaSetting and SearchPathSetting
153501
+ auto &client_data = ClientData::Get(context);
153502
+ client_data.catalog_search_path->Reset();
153503
+ }
153504
+
152993
153505
  void SearchPathSetting::SetLocal(ClientContext &context, const Value &input) {
152994
153506
  auto parameter = input.ToString();
152995
153507
  auto &client_data = ClientData::Get(context);
@@ -153013,6 +153525,15 @@ void TempDirectorySetting::SetGlobal(DatabaseInstance *db, DBConfig &config, con
153013
153525
  }
153014
153526
  }
153015
153527
 
153528
+ void TempDirectorySetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153529
+ config.options.temporary_directory = DBConfig().options.temporary_directory;
153530
+ config.options.use_temporary_directory = DBConfig().options.use_temporary_directory;
153531
+ if (db) {
153532
+ auto &buffer_manager = BufferManager::GetBufferManager(*db);
153533
+ buffer_manager.SetTemporaryDirectory(config.options.temporary_directory);
153534
+ }
153535
+ }
153536
+
153016
153537
  Value TempDirectorySetting::GetSetting(ClientContext &context) {
153017
153538
  auto &buffer_manager = BufferManager::GetBufferManager(context);
153018
153539
  return Value(buffer_manager.GetTemporaryDirectory());
@@ -153028,6 +153549,10 @@ void ThreadsSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Val
153028
153549
  }
153029
153550
  }
153030
153551
 
153552
+ void ThreadsSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153553
+ config.SetDefaultMaxThreads();
153554
+ }
153555
+
153031
153556
  Value ThreadsSetting::GetSetting(ClientContext &context) {
153032
153557
  auto &config = DBConfig::GetConfig(context);
153033
153558
  return Value::BIGINT(config.options.maximum_threads);
@@ -153040,6 +153565,10 @@ void UsernameSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Va
153040
153565
  // nop
153041
153566
  }
153042
153567
 
153568
+ void UsernameSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
153569
+ // nop
153570
+ }
153571
+
153043
153572
  Value UsernameSetting::GetSetting(ClientContext &context) {
153044
153573
  return Value();
153045
153574
  }
@@ -157104,6 +157633,7 @@ void EstimatedProperties::SetCost(double new_cost) {
157104
157633
 
157105
157634
 
157106
157635
 
157636
+
157107
157637
 
157108
157638
 
157109
157639
  namespace duckdb {
@@ -178800,7 +179330,14 @@ private:
178800
179330
  unique_ptr<ExecuteStatement> TransformExecute(duckdb_libpgquery::PGNode *node);
178801
179331
  unique_ptr<CallStatement> TransformCall(duckdb_libpgquery::PGNode *node);
178802
179332
  unique_ptr<DropStatement> TransformDeallocate(duckdb_libpgquery::PGNode *node);
179333
+
179334
+ //===--------------------------------------------------------------------===//
179335
+ // SetStatement Transform
179336
+ //===--------------------------------------------------------------------===//
178803
179337
  unique_ptr<SetStatement> TransformSet(duckdb_libpgquery::PGNode *node);
179338
+ unique_ptr<SetStatement> TransformSetVariable(duckdb_libpgquery::PGVariableSetStmt *stmt);
179339
+ unique_ptr<SetStatement> TransformResetVariable(duckdb_libpgquery::PGVariableSetStmt *stmt);
179340
+
178804
179341
  unique_ptr<SQLStatement> TransformCheckpoint(duckdb_libpgquery::PGNode *node);
178805
179342
  unique_ptr<LoadStatement> TransformLoad(duckdb_libpgquery::PGNode *node);
178806
179343
 
@@ -180793,38 +181330,94 @@ string SelectStatement::ToString() const {
180793
181330
 
180794
181331
 
180795
181332
 
181333
+ //===----------------------------------------------------------------------===//
181334
+ // DuckDB
181335
+ //
181336
+ // duckdb/common/enums/set_type.hpp
181337
+ //
181338
+ //
181339
+ //===----------------------------------------------------------------------===//
181340
+
181341
+
181342
+
181343
+
181344
+
181345
+ namespace duckdb {
181346
+
181347
+ enum class SetType : uint8_t { SET = 0, RESET = 1 };
181348
+
181349
+ } // namespace duckdb
181350
+
180796
181351
 
180797
181352
 
180798
181353
 
180799
181354
  namespace duckdb {
180800
181355
 
180801
181356
  class SetStatement : public SQLStatement {
180802
- public:
180803
- SetStatement(std::string name_p, Value value_p, SetScope scope_p);
180804
-
180805
181357
  protected:
181358
+ SetStatement(std::string name_p, SetScope scope_p, SetType type_p);
180806
181359
  SetStatement(const SetStatement &other) = default;
180807
181360
 
180808
181361
  public:
180809
181362
  unique_ptr<SQLStatement> Copy() const override;
180810
181363
 
181364
+ public:
180811
181365
  std::string name;
180812
- Value value;
180813
181366
  SetScope scope;
181367
+ SetType set_type;
181368
+ };
181369
+
181370
+ class SetVariableStatement : public SetStatement {
181371
+ public:
181372
+ SetVariableStatement(std::string name_p, Value value_p, SetScope scope_p);
181373
+
181374
+ protected:
181375
+ SetVariableStatement(const SetVariableStatement &other) = default;
181376
+
181377
+ public:
181378
+ unique_ptr<SQLStatement> Copy() const override;
181379
+
181380
+ public:
181381
+ Value value;
180814
181382
  };
181383
+
181384
+ class ResetVariableStatement : public SetStatement {
181385
+ public:
181386
+ ResetVariableStatement(std::string name_p, SetScope scope_p);
181387
+
181388
+ protected:
181389
+ ResetVariableStatement(const ResetVariableStatement &other) = default;
181390
+ };
181391
+
180815
181392
  } // namespace duckdb
180816
181393
 
180817
181394
 
180818
181395
  namespace duckdb {
180819
181396
 
180820
- SetStatement::SetStatement(std::string name_p, Value value_p, SetScope scope_p)
180821
- : SQLStatement(StatementType::SET_STATEMENT), name(move(name_p)), value(move(value_p)), scope(scope_p) {
181397
+ SetStatement::SetStatement(std::string name_p, SetScope scope_p, SetType type_p)
181398
+ : SQLStatement(StatementType::SET_STATEMENT), name(move(name_p)), scope(scope_p), set_type(type_p) {
180822
181399
  }
180823
181400
 
180824
181401
  unique_ptr<SQLStatement> SetStatement::Copy() const {
180825
181402
  return unique_ptr<SetStatement>(new SetStatement(*this));
180826
181403
  }
180827
181404
 
181405
+ // Set Variable
181406
+
181407
+ SetVariableStatement::SetVariableStatement(std::string name_p, Value value_p, SetScope scope_p)
181408
+ : SetStatement(move(name_p), scope_p, SetType::SET), value(move(value_p)) {
181409
+ }
181410
+
181411
+ unique_ptr<SQLStatement> SetVariableStatement::Copy() const {
181412
+ return unique_ptr<SetVariableStatement>(new SetVariableStatement(*this));
181413
+ }
181414
+
181415
+ // Reset Variable
181416
+
181417
+ ResetVariableStatement::ResetVariableStatement(std::string name_p, SetScope scope_p)
181418
+ : SetStatement(move(name_p), scope_p, SetType::RESET) {
181419
+ }
181420
+
180828
181421
  } // namespace duckdb
180829
181422
  //===----------------------------------------------------------------------===//
180830
181423
  // DuckDB
@@ -185658,7 +186251,7 @@ unique_ptr<SQLStatement> Transformer::TransformPragma(duckdb_libpgquery::PGNode
185658
186251
  if (sqlite_compat_pragmas.find(info.name) != sqlite_compat_pragmas.end()) {
185659
186252
  break;
185660
186253
  }
185661
- auto set_statement = make_unique<SetStatement>(info.name, info.parameters[0], SetScope::AUTOMATIC);
186254
+ auto set_statement = make_unique<SetVariableStatement>(info.name, info.parameters[0], SetScope::AUTOMATIC);
185662
186255
  return move(set_statement);
185663
186256
  }
185664
186257
  case duckdb_libpgquery::PG_PRAGMA_TYPE_CALL:
@@ -186011,15 +186604,21 @@ SetScope ToSetScope(duckdb_libpgquery::VariableSetScope pg_scope) {
186011
186604
  }
186012
186605
  }
186013
186606
 
186014
- } // namespace
186607
+ SetType ToSetType(duckdb_libpgquery::VariableSetKind pg_kind) {
186608
+ switch (pg_kind) {
186609
+ case duckdb_libpgquery::VariableSetKind::VAR_SET_VALUE:
186610
+ return SetType::SET;
186611
+ case duckdb_libpgquery::VariableSetKind::VAR_RESET:
186612
+ return SetType::RESET;
186613
+ default:
186614
+ throw NotImplementedException("Can only SET or RESET a variable");
186615
+ }
186616
+ }
186015
186617
 
186016
- unique_ptr<SetStatement> Transformer::TransformSet(duckdb_libpgquery::PGNode *node) {
186017
- D_ASSERT(node->type == duckdb_libpgquery::T_PGVariableSetStmt);
186018
- auto stmt = reinterpret_cast<duckdb_libpgquery::PGVariableSetStmt *>(node);
186618
+ } // namespace
186019
186619
 
186020
- if (stmt->kind != duckdb_libpgquery::VariableSetKind::VAR_SET_VALUE) {
186021
- throw ParserException("Can only SET a variable to a value");
186022
- }
186620
+ unique_ptr<SetStatement> Transformer::TransformSetVariable(duckdb_libpgquery::PGVariableSetStmt *stmt) {
186621
+ D_ASSERT(stmt->kind == duckdb_libpgquery::VariableSetKind::VAR_SET_VALUE);
186023
186622
 
186024
186623
  if (stmt->scope == duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_LOCAL) {
186025
186624
  throw NotImplementedException("SET LOCAL is not implemented.");
@@ -186035,7 +186634,36 @@ unique_ptr<SetStatement> Transformer::TransformSet(duckdb_libpgquery::PGNode *no
186035
186634
 
186036
186635
  auto value = TransformValue(((duckdb_libpgquery::PGAConst *)stmt->args->head->data.ptr_value)->val)->value;
186037
186636
 
186038
- return make_unique<SetStatement>(name, value, ToSetScope(stmt->scope));
186637
+ return make_unique<SetVariableStatement>(name, value, ToSetScope(stmt->scope));
186638
+ }
186639
+
186640
+ unique_ptr<SetStatement> Transformer::TransformResetVariable(duckdb_libpgquery::PGVariableSetStmt *stmt) {
186641
+ D_ASSERT(stmt->kind == duckdb_libpgquery::VariableSetKind::VAR_RESET);
186642
+
186643
+ if (stmt->scope == duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_LOCAL) {
186644
+ throw NotImplementedException("RESET LOCAL is not implemented.");
186645
+ }
186646
+
186647
+ auto name = std::string(stmt->name);
186648
+ D_ASSERT(!name.empty()); // parser protect us!
186649
+
186650
+ return make_unique<ResetVariableStatement>(name, ToSetScope(stmt->scope));
186651
+ }
186652
+
186653
+ unique_ptr<SetStatement> Transformer::TransformSet(duckdb_libpgquery::PGNode *node) {
186654
+ D_ASSERT(node->type == duckdb_libpgquery::T_PGVariableSetStmt);
186655
+ auto stmt = reinterpret_cast<duckdb_libpgquery::PGVariableSetStmt *>(node);
186656
+
186657
+ SetType set_type = ToSetType(stmt->kind);
186658
+
186659
+ switch (set_type) {
186660
+ case SetType::SET:
186661
+ return TransformSetVariable(stmt);
186662
+ case SetType::RESET:
186663
+ return TransformResetVariable(stmt);
186664
+ default:
186665
+ throw NotImplementedException("Type not implemented for SetType");
186666
+ }
186039
186667
  }
186040
186668
 
186041
186669
  } // namespace duckdb
@@ -193525,11 +194153,12 @@ BoundStatement Binder::Bind(SelectStatement &stmt) {
193525
194153
 
193526
194154
 
193527
194155
 
194156
+
193528
194157
  #include <algorithm>
193529
194158
 
193530
194159
  namespace duckdb {
193531
194160
 
193532
- BoundStatement Binder::Bind(SetStatement &stmt) {
194161
+ BoundStatement Binder::Bind(SetVariableStatement &stmt) {
193533
194162
  BoundStatement result;
193534
194163
  result.types = {LogicalType::BOOLEAN};
193535
194164
  result.names = {"Success"};
@@ -193539,6 +194168,31 @@ BoundStatement Binder::Bind(SetStatement &stmt) {
193539
194168
  return result;
193540
194169
  }
193541
194170
 
194171
+ BoundStatement Binder::Bind(ResetVariableStatement &stmt) {
194172
+ BoundStatement result;
194173
+ result.types = {LogicalType::BOOLEAN};
194174
+ result.names = {"Success"};
194175
+
194176
+ result.plan = make_unique<LogicalReset>(stmt.name, stmt.scope);
194177
+ properties.return_type = StatementReturnType::NOTHING;
194178
+ return result;
194179
+ }
194180
+
194181
+ BoundStatement Binder::Bind(SetStatement &stmt) {
194182
+ switch (stmt.set_type) {
194183
+ case SetType::SET: {
194184
+ auto &set_stmt = (SetVariableStatement &)stmt;
194185
+ return Bind(set_stmt);
194186
+ }
194187
+ case SetType::RESET: {
194188
+ auto &set_stmt = (ResetVariableStatement &)stmt;
194189
+ return Bind(set_stmt);
194190
+ }
194191
+ default:
194192
+ throw NotImplementedException("Type not implemented for SetType");
194193
+ }
194194
+ }
194195
+
193542
194196
  } // namespace duckdb
193543
194197
 
193544
194198
 
@@ -200027,6 +200681,9 @@ unique_ptr<LogicalOperator> LogicalOperator::Deserialize(Deserializer &deseriali
200027
200681
  case LogicalOperatorType::LOGICAL_SET:
200028
200682
  result = LogicalSet::Deserialize(state, reader);
200029
200683
  break;
200684
+ case LogicalOperatorType::LOGICAL_RESET:
200685
+ result = LogicalReset::Deserialize(state, reader);
200686
+ break;
200030
200687
  case LogicalOperatorType::LOGICAL_LOAD:
200031
200688
  result = LogicalSimple::Deserialize(state, reader);
200032
200689
  break;
@@ -201617,6 +202274,27 @@ vector<idx_t> LogicalRecursiveCTE::GetTableIndex() const {
201617
202274
 
201618
202275
 
201619
202276
 
202277
+ namespace duckdb {
202278
+
202279
+ void LogicalReset::Serialize(FieldWriter &writer) const {
202280
+ writer.WriteString(name);
202281
+ writer.WriteField(scope);
202282
+ }
202283
+
202284
+ unique_ptr<LogicalOperator> LogicalReset::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
202285
+ auto name = reader.ReadRequired<std::string>();
202286
+ auto scope = reader.ReadRequired<SetScope>();
202287
+ return make_unique<LogicalReset>(name, scope);
202288
+ }
202289
+
202290
+ idx_t LogicalReset::EstimateCardinality(ClientContext &context) {
202291
+ return 1;
202292
+ }
202293
+
202294
+ } // namespace duckdb
202295
+
202296
+
202297
+
201620
202298
  namespace duckdb {
201621
202299
 
201622
202300
  LogicalSample::LogicalSample(unique_ptr<SampleOptions> sample_options_p, unique_ptr<LogicalOperator> child)
@@ -287214,7 +287892,7 @@ static const yytype_uint16 yyrline[] =
287214
287892
  148, 7, 14, 20, 28, 29, 8, 22, 36, 48,
287215
287893
  56, 70, 71, 72, 73, 74, 87, 88, 93, 94,
287216
287894
  98, 99, 7, 18, 31, 35, 42, 53, 54, 60,
287217
- 61, 9, 19, 2, 7, 14, 24, 25, 32, 3,
287895
+ 61, 9, 19, 2, 7, 15, 26, 27, 34, 3,
287218
287896
  10, 17, 24, 31, 38, 45, 52, 61, 61, 63,
287219
287897
  64, 68, 69, 6, 8, 21, 34, 52, 74, 75,
287220
287898
  76, 77, 11, 24, 37, 54, 55, 56, 61, 74,
@@ -310995,27 +311673,29 @@ yyreduce:
310995
311673
  {
310996
311674
  PGVariableSetStmt *n = makeNode(PGVariableSetStmt);
310997
311675
  n->kind = VAR_RESET;
311676
+ n->scope = VAR_SET_SCOPE_GLOBAL;
310998
311677
  n->name = (yyvsp[(1) - (1)].str);
310999
311678
  (yyval.vsetstmt) = n;
311000
311679
  ;}
311001
311680
  break;
311002
311681
 
311003
311682
  case 1295:
311004
- #line 15 "third_party/libpg_query/grammar/statements/variable_reset.y"
311683
+ #line 16 "third_party/libpg_query/grammar/statements/variable_reset.y"
311005
311684
  {
311006
311685
  PGVariableSetStmt *n = makeNode(PGVariableSetStmt);
311007
311686
  n->kind = VAR_RESET_ALL;
311687
+ n->scope = VAR_SET_SCOPE_GLOBAL;
311008
311688
  (yyval.vsetstmt) = n;
311009
311689
  ;}
311010
311690
  break;
311011
311691
 
311012
311692
  case 1296:
311013
- #line 24 "third_party/libpg_query/grammar/statements/variable_reset.y"
311693
+ #line 26 "third_party/libpg_query/grammar/statements/variable_reset.y"
311014
311694
  { (yyval.vsetstmt) = (yyvsp[(1) - (1)].vsetstmt); ;}
311015
311695
  break;
311016
311696
 
311017
311697
  case 1297:
311018
- #line 26 "third_party/libpg_query/grammar/statements/variable_reset.y"
311698
+ #line 28 "third_party/libpg_query/grammar/statements/variable_reset.y"
311019
311699
  {
311020
311700
  PGVariableSetStmt *n = makeNode(PGVariableSetStmt);
311021
311701
  n->kind = VAR_RESET;
@@ -311025,7 +311705,7 @@ yyreduce:
311025
311705
  break;
311026
311706
 
311027
311707
  case 1298:
311028
- #line 33 "third_party/libpg_query/grammar/statements/variable_reset.y"
311708
+ #line 35 "third_party/libpg_query/grammar/statements/variable_reset.y"
311029
311709
  {
311030
311710
  PGVariableSetStmt *n = makeNode(PGVariableSetStmt);
311031
311711
  n->kind = VAR_RESET;
@@ -311313,7 +311993,7 @@ yyreduce:
311313
311993
 
311314
311994
 
311315
311995
  /* Line 1267 of yacc.c. */
311316
- #line 26643 "third_party/libpg_query/grammar/grammar_out.cpp"
311996
+ #line 26645 "third_party/libpg_query/grammar/grammar_out.cpp"
311317
311997
  default: break;
311318
311998
  }
311319
311999
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);