duckdb 0.8.2-dev1549.0 → 0.8.2-dev1559.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
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.8.2-dev1549.0",
5
+ "version": "0.8.2-dev1559.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.2-dev1549"
2
+ #define DUCKDB_VERSION "0.8.2-dev1559"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "b4c1529172"
5
+ #define DUCKDB_SOURCE_ID "fa204ca892"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -218,6 +218,10 @@ private:
218
218
  reference_set_t<ViewCatalogEntry> bound_views;
219
219
 
220
220
  private:
221
+ //! Get the root binder (binder with no parent)
222
+ Binder *GetRootBinder();
223
+ //! Determine the depth of the binder
224
+ idx_t GetBinderDepth() const;
221
225
  //! Bind the expressions of generated columns to check for errors
222
226
  void BindGeneratedColumns(BoundCreateTableInfo &info);
223
227
  //! Bind the default values of the columns of a table
@@ -21,7 +21,31 @@
21
21
 
22
22
  namespace duckdb {
23
23
 
24
+ Binder *Binder::GetRootBinder() {
25
+ Binder *root = this;
26
+ while (root->parent) {
27
+ root = root->parent.get();
28
+ }
29
+ return root;
30
+ }
31
+
32
+ idx_t Binder::GetBinderDepth() const {
33
+ const Binder *root = this;
34
+ idx_t depth = 1;
35
+ while (root->parent) {
36
+ depth++;
37
+ root = root->parent.get();
38
+ }
39
+ return depth;
40
+ }
41
+
24
42
  shared_ptr<Binder> Binder::CreateBinder(ClientContext &context, optional_ptr<Binder> parent, bool inherit_ctes) {
43
+ auto depth = parent ? parent->GetBinderDepth() : 0;
44
+ if (depth > context.config.max_expression_depth) {
45
+ throw BinderException("Max expression depth limit of %lld exceeded. Use \"SET max_expression_depth TO x\" to "
46
+ "increase the maximum expression depth.",
47
+ context.config.max_expression_depth);
48
+ }
25
49
  return make_shared<Binder>(true, context, parent ? parent->shared_from_this() : nullptr, inherit_ctes);
26
50
  }
27
51
 
@@ -271,11 +295,8 @@ void Binder::AddBoundView(ViewCatalogEntry &view) {
271
295
  }
272
296
 
273
297
  idx_t Binder::GenerateTableIndex() {
274
- D_ASSERT(parent.get() != this);
275
- if (parent) {
276
- return parent->GenerateTableIndex();
277
- }
278
- return bound_tables++;
298
+ auto root_binder = GetRootBinder();
299
+ return root_binder->bound_tables++;
279
300
  }
280
301
 
281
302
  void Binder::PushExpressionBinder(ExpressionBinder &binder) {
@@ -301,18 +322,13 @@ bool Binder::HasActiveBinder() {
301
322
  }
302
323
 
303
324
  vector<reference<ExpressionBinder>> &Binder::GetActiveBinders() {
304
- if (parent) {
305
- return parent->GetActiveBinders();
306
- }
307
- return active_binders;
325
+ auto root_binder = GetRootBinder();
326
+ return root_binder->active_binders;
308
327
  }
309
328
 
310
329
  void Binder::AddUsingBindingSet(unique_ptr<UsingColumnSet> set) {
311
- if (parent) {
312
- parent->AddUsingBindingSet(std::move(set));
313
- return;
314
- }
315
- bind_context.AddUsingBindingSet(std::move(set));
330
+ auto root_binder = GetRootBinder();
331
+ root_binder->bind_context.AddUsingBindingSet(std::move(set));
316
332
  }
317
333
 
318
334
  void Binder::MoveCorrelatedExpressions(Binder &other) {
@@ -381,17 +397,14 @@ bool Binder::HasMatchingBinding(const string &catalog_name, const string &schema
381
397
  }
382
398
 
383
399
  void Binder::SetBindingMode(BindingMode mode) {
384
- if (parent) {
385
- parent->SetBindingMode(mode);
386
- }
387
- this->mode = mode;
400
+ auto root_binder = GetRootBinder();
401
+ // FIXME: this used to also set the 'mode' for the current binder, was that necessary?
402
+ root_binder->mode = mode;
388
403
  }
389
404
 
390
405
  BindingMode Binder::GetBindingMode() {
391
- if (parent) {
392
- return parent->GetBindingMode();
393
- }
394
- return mode;
406
+ auto root_binder = GetRootBinder();
407
+ return root_binder->mode;
395
408
  }
396
409
 
397
410
  void Binder::SetCanContainNulls(bool can_contain_nulls_p) {
@@ -399,18 +412,13 @@ void Binder::SetCanContainNulls(bool can_contain_nulls_p) {
399
412
  }
400
413
 
401
414
  void Binder::AddTableName(string table_name) {
402
- if (parent) {
403
- parent->AddTableName(std::move(table_name));
404
- return;
405
- }
406
- table_names.insert(std::move(table_name));
415
+ auto root_binder = GetRootBinder();
416
+ root_binder->table_names.insert(std::move(table_name));
407
417
  }
408
418
 
409
419
  const unordered_set<string> &Binder::GetTableNames() {
410
- if (parent) {
411
- return parent->GetTableNames();
412
- }
413
- return table_names;
420
+ auto root_binder = GetRootBinder();
421
+ return root_binder->table_names;
414
422
  }
415
423
 
416
424
  string Binder::FormatError(ParsedExpression &expr_context, const string &message) {