duckdb 0.4.1-dev1344.0 → 0.4.1-dev1349.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.4.1-dev1344.0",
4
+ "version": "0.4.1-dev1349.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -36395,11 +36395,12 @@ public:
36395
36395
  DUCKDB_API bool IsEnabled() const;
36396
36396
  DUCKDB_API bool IsDetailedEnabled() const;
36397
36397
  DUCKDB_API ProfilerPrintFormat GetPrintFormat() const;
36398
+ DUCKDB_API bool PrintOptimizerOutput() const;
36398
36399
  DUCKDB_API string GetSaveLocation() const;
36399
36400
 
36400
36401
  DUCKDB_API static QueryProfiler &Get(ClientContext &context);
36401
36402
 
36402
- DUCKDB_API void StartQuery(string query, bool is_explain_analyze = false);
36403
+ DUCKDB_API void StartQuery(string query, bool is_explain_analyze = false, bool start_at_optimizer = false);
36403
36404
  DUCKDB_API void EndQuery();
36404
36405
 
36405
36406
  DUCKDB_API void StartExplainAnalyze();
@@ -36412,8 +36413,8 @@ public:
36412
36413
 
36413
36414
  DUCKDB_API void Initialize(PhysicalOperator *root);
36414
36415
 
36415
- DUCKDB_API string QueryTreeToString(bool print_optimizer_output = false) const;
36416
- DUCKDB_API void QueryTreeToStream(std::ostream &str, bool print_optimizer_output = false) const;
36416
+ DUCKDB_API string QueryTreeToString() const;
36417
+ DUCKDB_API void QueryTreeToStream(std::ostream &str) const;
36417
36418
  DUCKDB_API void Print();
36418
36419
 
36419
36420
  //! return the printed as a string. Unlike ToString, which is always formatted as a string,
@@ -119125,6 +119126,17 @@ unique_ptr<QueryResult> ClientContext::FetchResultInternal(ClientContextLock &lo
119125
119126
  return result;
119126
119127
  }
119127
119128
 
119129
+ static bool IsExplainAnalyze(SQLStatement *statement) {
119130
+ if (!statement) {
119131
+ return false;
119132
+ }
119133
+ if (statement->type != StatementType::EXPLAIN_STATEMENT) {
119134
+ return false;
119135
+ }
119136
+ auto &explain = (ExplainStatement &)*statement;
119137
+ return explain.explain_type == ExplainType::EXPLAIN_ANALYZE;
119138
+ }
119139
+
119128
119140
  shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientContextLock &lock, const string &query,
119129
119141
  unique_ptr<SQLStatement> statement,
119130
119142
  vector<Value> *values) {
@@ -119132,6 +119144,7 @@ shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientC
119132
119144
  auto result = make_shared<PreparedStatementData>(statement_type);
119133
119145
 
119134
119146
  auto &profiler = QueryProfiler::Get(*this);
119147
+ profiler.StartQuery(query, IsExplainAnalyze(statement.get()), true);
119135
119148
  profiler.StartPhase("planner");
119136
119149
  Planner planner(*this);
119137
119150
  if (values) {
@@ -119423,17 +119436,6 @@ bool ClientContext::IsActiveResult(ClientContextLock &lock, BaseQueryResult *res
119423
119436
  return active_query->open_result == result;
119424
119437
  }
119425
119438
 
119426
- static bool IsExplainAnalyze(SQLStatement *statement) {
119427
- if (!statement) {
119428
- return false;
119429
- }
119430
- if (statement->type != StatementType::EXPLAIN_STATEMENT) {
119431
- return false;
119432
- }
119433
- auto &explain = (ExplainStatement &)*statement;
119434
- return explain.explain_type == ExplainType::EXPLAIN_ANALYZE;
119435
- }
119436
-
119437
119439
  unique_ptr<PendingQueryResult> ClientContext::PendingStatementOrPreparedStatementInternal(
119438
119440
  ClientContextLock &lock, const string &query, unique_ptr<SQLStatement> statement,
119439
119441
  shared_ptr<PreparedStatementData> &prepared, PendingQueryParameters parameters) {
@@ -120707,6 +120709,67 @@ idx_t DBConfig::ParseMemoryLimit(const string &arg) {
120707
120709
 
120708
120710
 
120709
120711
 
120712
+ //===----------------------------------------------------------------------===//
120713
+ // DuckDB
120714
+ //
120715
+ // duckdb/main/connection_manager.hpp
120716
+ //
120717
+ //
120718
+ //===----------------------------------------------------------------------===//
120719
+
120720
+
120721
+
120722
+
120723
+
120724
+
120725
+
120726
+
120727
+ namespace duckdb {
120728
+ class ClientContext;
120729
+ class DatabaseInstance;
120730
+
120731
+ class ConnectionManager {
120732
+ public:
120733
+ ConnectionManager() {
120734
+ }
120735
+
120736
+ void AddConnection(ClientContext &context) {
120737
+ lock_guard<mutex> lock(connections_lock);
120738
+ connections.insert(make_pair(&context, weak_ptr<ClientContext>(context.shared_from_this())));
120739
+ }
120740
+
120741
+ void RemoveConnection(ClientContext &context) {
120742
+ lock_guard<mutex> lock(connections_lock);
120743
+ connections.erase(&context);
120744
+ }
120745
+
120746
+ vector<shared_ptr<ClientContext>> GetConnectionList() {
120747
+ vector<shared_ptr<ClientContext>> result;
120748
+ for (auto &it : connections) {
120749
+ auto connection = it.second.lock();
120750
+ if (!connection) {
120751
+ connections.erase(it.first);
120752
+ continue;
120753
+ } else {
120754
+ result.push_back(move(connection));
120755
+ }
120756
+ }
120757
+
120758
+ return result;
120759
+ }
120760
+
120761
+ static ConnectionManager &Get(DatabaseInstance &db);
120762
+ static ConnectionManager &Get(ClientContext &context);
120763
+
120764
+ public:
120765
+ mutex connections_lock;
120766
+ unordered_map<ClientContext *, weak_ptr<ClientContext>> connections;
120767
+ };
120768
+
120769
+ } // namespace duckdb
120770
+
120771
+
120772
+
120710
120773
  //===----------------------------------------------------------------------===//
120711
120774
  // DuckDB
120712
120775
  //
@@ -120784,7 +120847,7 @@ public:
120784
120847
  //===----------------------------------------------------------------------===//
120785
120848
  // DuckDB
120786
120849
  //
120787
- // duckdb/main/relation/table_relation.hpp
120850
+ // duckdb/main/relation/table_function_relation.hpp
120788
120851
  //
120789
120852
  //
120790
120853
  //===----------------------------------------------------------------------===//
@@ -120793,26 +120856,29 @@ public:
120793
120856
 
120794
120857
 
120795
120858
 
120796
-
120797
120859
  namespace duckdb {
120798
120860
 
120799
- class TableRelation : public Relation {
120861
+ class TableFunctionRelation : public Relation {
120800
120862
  public:
120801
- TableRelation(const std::shared_ptr<ClientContext> &context, unique_ptr<TableDescription> description);
120863
+ TableFunctionRelation(const std::shared_ptr<ClientContext> &context, string name, vector<Value> parameters,
120864
+ named_parameter_map_t named_parameters, shared_ptr<Relation> input_relation_p = nullptr);
120802
120865
 
120803
- unique_ptr<TableDescription> description;
120866
+ TableFunctionRelation(const std::shared_ptr<ClientContext> &context, string name, vector<Value> parameters,
120867
+ shared_ptr<Relation> input_relation_p = nullptr);
120868
+
120869
+ string name;
120870
+ vector<Value> parameters;
120871
+ named_parameter_map_t named_parameters;
120872
+ vector<ColumnDefinition> columns;
120873
+ shared_ptr<Relation> input_relation;
120804
120874
 
120805
120875
  public:
120806
120876
  unique_ptr<QueryNode> GetQueryNode() override;
120877
+ unique_ptr<TableRef> GetTableRef() override;
120807
120878
 
120808
120879
  const vector<ColumnDefinition> &Columns() override;
120809
120880
  string ToString(idx_t depth) override;
120810
120881
  string GetAlias() override;
120811
-
120812
- unique_ptr<TableRef> GetTableRef() override;
120813
-
120814
- void Update(const string &update, const string &condition = string()) override;
120815
- void Delete(const string &condition = string()) override;
120816
120882
  };
120817
120883
 
120818
120884
  } // namespace duckdb
@@ -120820,7 +120886,7 @@ public:
120820
120886
  //===----------------------------------------------------------------------===//
120821
120887
  // DuckDB
120822
120888
  //
120823
- // duckdb/main/relation/table_function_relation.hpp
120889
+ // duckdb/main/relation/table_relation.hpp
120824
120890
  //
120825
120891
  //
120826
120892
  //===----------------------------------------------------------------------===//
@@ -120829,29 +120895,26 @@ public:
120829
120895
 
120830
120896
 
120831
120897
 
120898
+
120832
120899
  namespace duckdb {
120833
120900
 
120834
- class TableFunctionRelation : public Relation {
120901
+ class TableRelation : public Relation {
120835
120902
  public:
120836
- TableFunctionRelation(const std::shared_ptr<ClientContext> &context, string name, vector<Value> parameters,
120837
- named_parameter_map_t named_parameters, shared_ptr<Relation> input_relation_p = nullptr);
120838
-
120839
- TableFunctionRelation(const std::shared_ptr<ClientContext> &context, string name, vector<Value> parameters,
120840
- shared_ptr<Relation> input_relation_p = nullptr);
120903
+ TableRelation(const std::shared_ptr<ClientContext> &context, unique_ptr<TableDescription> description);
120841
120904
 
120842
- string name;
120843
- vector<Value> parameters;
120844
- named_parameter_map_t named_parameters;
120845
- vector<ColumnDefinition> columns;
120846
- shared_ptr<Relation> input_relation;
120905
+ unique_ptr<TableDescription> description;
120847
120906
 
120848
120907
  public:
120849
120908
  unique_ptr<QueryNode> GetQueryNode() override;
120850
- unique_ptr<TableRef> GetTableRef() override;
120851
120909
 
120852
120910
  const vector<ColumnDefinition> &Columns() override;
120853
120911
  string ToString(idx_t depth) override;
120854
120912
  string GetAlias() override;
120913
+
120914
+ unique_ptr<TableRef> GetTableRef() override;
120915
+
120916
+ void Update(const string &update, const string &condition = string()) override;
120917
+ void Delete(const string &condition = string()) override;
120855
120918
  };
120856
120919
 
120857
120920
  } // namespace duckdb
@@ -120930,66 +120993,6 @@ public:
120930
120993
 
120931
120994
 
120932
120995
 
120933
- //===----------------------------------------------------------------------===//
120934
- // DuckDB
120935
- //
120936
- // duckdb/main/connection_manager.hpp
120937
- //
120938
- //
120939
- //===----------------------------------------------------------------------===//
120940
-
120941
-
120942
-
120943
-
120944
-
120945
-
120946
-
120947
-
120948
- namespace duckdb {
120949
- class ClientContext;
120950
- class DatabaseInstance;
120951
-
120952
- class ConnectionManager {
120953
- public:
120954
- ConnectionManager() {
120955
- }
120956
-
120957
- void AddConnection(ClientContext &context) {
120958
- lock_guard<mutex> lock(connections_lock);
120959
- connections.insert(make_pair(&context, weak_ptr<ClientContext>(context.shared_from_this())));
120960
- }
120961
-
120962
- void RemoveConnection(ClientContext &context) {
120963
- lock_guard<mutex> lock(connections_lock);
120964
- connections.erase(&context);
120965
- }
120966
-
120967
- vector<shared_ptr<ClientContext>> GetConnectionList() {
120968
- vector<shared_ptr<ClientContext>> result;
120969
- for (auto &it : connections) {
120970
- auto connection = it.second.lock();
120971
- if (!connection) {
120972
- connections.erase(it.first);
120973
- continue;
120974
- } else {
120975
- result.push_back(move(connection));
120976
- }
120977
- }
120978
-
120979
- return result;
120980
- }
120981
-
120982
- static ConnectionManager &Get(DatabaseInstance &db);
120983
- static ConnectionManager &Get(ClientContext &context);
120984
-
120985
- public:
120986
- mutex connections_lock;
120987
- unordered_map<ClientContext *, weak_ptr<ClientContext>> connections;
120988
- };
120989
-
120990
- } // namespace duckdb
120991
-
120992
-
120993
120996
 
120994
120997
  namespace duckdb {
120995
120998
 
@@ -130828,6 +130831,10 @@ ProfilerPrintFormat QueryProfiler::GetPrintFormat() const {
130828
130831
  return ClientConfig::GetConfig(context).profiler_print_format;
130829
130832
  }
130830
130833
 
130834
+ bool QueryProfiler::PrintOptimizerOutput() const {
130835
+ return GetPrintFormat() == ProfilerPrintFormat::QUERY_TREE_OPTIMIZER || IsDetailedEnabled();
130836
+ }
130837
+
130831
130838
  string QueryProfiler::GetSaveLocation() const {
130832
130839
  return is_explain_analyze ? string() : ClientConfig::GetConfig(context).profiler_save_location;
130833
130840
  }
@@ -130836,13 +130843,22 @@ QueryProfiler &QueryProfiler::Get(ClientContext &context) {
130836
130843
  return *ClientData::Get(context).profiler;
130837
130844
  }
130838
130845
 
130839
- void QueryProfiler::StartQuery(string query, bool is_explain_analyze) {
130846
+ void QueryProfiler::StartQuery(string query, bool is_explain_analyze, bool start_at_optimizer) {
130840
130847
  if (is_explain_analyze) {
130841
130848
  StartExplainAnalyze();
130842
130849
  }
130843
130850
  if (!IsEnabled()) {
130844
130851
  return;
130845
130852
  }
130853
+ if (start_at_optimizer && !PrintOptimizerOutput()) {
130854
+ // This is the StartQuery call before the optimizer, but we don't have to print optimizer output
130855
+ return;
130856
+ }
130857
+ if (running) {
130858
+ // Called while already running: this should only happen when we print optimizer output
130859
+ D_ASSERT(PrintOptimizerOutput());
130860
+ return;
130861
+ }
130846
130862
  this->running = true;
130847
130863
  this->query = move(query);
130848
130864
  tree_map.clear();
@@ -130933,11 +130949,10 @@ string QueryProfiler::ToString() const {
130933
130949
  const auto format = GetPrintFormat();
130934
130950
  switch (format) {
130935
130951
  case ProfilerPrintFormat::QUERY_TREE:
130952
+ case ProfilerPrintFormat::QUERY_TREE_OPTIMIZER:
130936
130953
  return QueryTreeToString();
130937
130954
  case ProfilerPrintFormat::JSON:
130938
130955
  return ToJSON();
130939
- case ProfilerPrintFormat::QUERY_TREE_OPTIMIZER:
130940
- return QueryTreeToString(true);
130941
130956
  default:
130942
130957
  throw InternalException("Unknown ProfilerPrintFormat \"%s\"", format);
130943
130958
  }
@@ -131133,13 +131148,13 @@ static string RenderTiming(double timing) {
131133
131148
  return timing_s + "s";
131134
131149
  }
131135
131150
 
131136
- string QueryProfiler::QueryTreeToString(bool print_optimizer_output) const {
131151
+ string QueryProfiler::QueryTreeToString() const {
131137
131152
  std::stringstream str;
131138
- QueryTreeToStream(str, print_optimizer_output);
131153
+ QueryTreeToStream(str);
131139
131154
  return str.str();
131140
131155
  }
131141
131156
 
131142
- void QueryProfiler::QueryTreeToStream(std::ostream &ss, bool print_optimizer_output) const {
131157
+ void QueryProfiler::QueryTreeToStream(std::ostream &ss) const {
131143
131158
  if (!IsEnabled()) {
131144
131159
  ss << "Query profiling is disabled. Call "
131145
131160
  "Connection::EnableProfiling() to enable profiling!";
@@ -131163,7 +131178,7 @@ void QueryProfiler::QueryTreeToStream(std::ostream &ss, bool print_optimizer_out
131163
131178
  ss << "│└───────────────────────────────────┘│\n";
131164
131179
  ss << "└─────────────────────────────────────┘\n";
131165
131180
  // print phase timings
131166
- if (print_optimizer_output) {
131181
+ if (PrintOptimizerOutput()) {
131167
131182
  bool has_previous_phase = false;
131168
131183
  for (const auto &entry : GetOrderedPhaseTimings()) {
131169
131184
  if (!StringUtil::Contains(entry.first, " > ")) {
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "457bc43db"
15
- #define DUCKDB_VERSION "v0.4.1-dev1344"
14
+ #define DUCKDB_SOURCE_ID "8c44f8fc1"
15
+ #define DUCKDB_VERSION "v0.4.1-dev1349"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //