duckdb 0.5.2-dev2251.0 → 0.5.2-dev2264.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.5.2-dev2251.0",
5
+ "version": "0.5.2-dev2264.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -81718,6 +81718,16 @@ bool ParallelCSVReader::SetPosition(DataChunk &insert_chunk) {
81718
81718
  if (buffer->buffer->IsCSVFileFirstBuffer() && start_buffer == position_buffer &&
81719
81719
  start_buffer == buffer->buffer->GetStart()) {
81720
81720
  // First buffer doesn't need any setting
81721
+ // Unless we have a header
81722
+ if (options.header && options.auto_detect) {
81723
+ for (; position_buffer < end_buffer; position_buffer++) {
81724
+ if (StringUtil::CharacterIsNewline((*buffer)[position_buffer])) {
81725
+ position_buffer++;
81726
+ return true;
81727
+ }
81728
+ }
81729
+ return false;
81730
+ }
81721
81731
  return true;
81722
81732
  }
81723
81733
 
@@ -81841,8 +81851,9 @@ normal : {
81841
81851
  goto add_value;
81842
81852
  } else if (StringUtil::CharacterIsNewline(c)) {
81843
81853
  // newline: add row
81844
- D_ASSERT(try_add_line || column == insert_chunk.ColumnCount() - 1);
81845
- goto add_row;
81854
+ if (column > 0 || try_add_line) {
81855
+ goto add_row;
81856
+ }
81846
81857
  }
81847
81858
  }
81848
81859
  if (!BufferRemainder()) {
@@ -82016,9 +82027,8 @@ final_state : {
82016
82027
  }
82017
82028
  // If this is the last buffer, we have to read the last value
82018
82029
  if (buffer->buffer->IsCSVFileLastBuffer() || (buffer->next_buffer->IsCSVFileLastBuffer())) {
82019
- if (column > 0 || position_buffer > start_buffer) {
82030
+ if (column > 0 || try_add_line) {
82020
82031
  // remaining values to be added to the chunk
82021
- D_ASSERT(column == insert_chunk.ColumnCount() - 1);
82022
82032
  AddValue(buffer->GetValue(start_buffer, position_buffer, offset), column, escape_positions, has_quotes);
82023
82033
  if (try_add_line) {
82024
82034
  bool success = column == sql_types.size();
@@ -126407,13 +126417,10 @@ static unique_ptr<GlobalTableFunctionState> ParallelCSVInitGlobal(ClientContext
126407
126417
  return make_unique<ParallelCSVGlobalState>();
126408
126418
  }
126409
126419
  unique_ptr<CSVFileHandle> file_handle;
126410
- if (bind_data.initial_reader) {
126411
- file_handle = move(bind_data.initial_reader->file_handle);
126412
- bind_data.initial_reader.reset();
126413
- } else {
126414
- bind_data.options.file_path = bind_data.files[0];
126415
- file_handle = ReadCSV::OpenCSV(bind_data.options, context);
126416
- }
126420
+
126421
+ bind_data.options.file_path = bind_data.files[0];
126422
+ file_handle = ReadCSV::OpenCSV(bind_data.options, context);
126423
+
126417
126424
  idx_t rows_to_skip = bind_data.options.skip_rows + (bind_data.options.has_header ? 1 : 0);
126418
126425
  return make_unique<ParallelCSVGlobalState>(context, move(file_handle), bind_data.files,
126419
126426
  context.db->NumberOfThreads(), bind_data.options.buffer_size,
@@ -191299,6 +191306,10 @@ public:
191299
191306
  protected:
191300
191307
  BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
191301
191308
  bool root_expression = false) override;
191309
+
191310
+ // check certain column ref Names to make sure they are supported in the returning statement
191311
+ // (i.e rowid)
191312
+ BindResult BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth);
191302
191313
  };
191303
191314
 
191304
191315
  } // namespace duckdb
@@ -191383,13 +191394,13 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
191383
191394
  unique_ptr<LogicalOperator> del_as_logicaloperator = move(del);
191384
191395
  return BindReturning(move(stmt.returning_list), table, update_table_index, move(del_as_logicaloperator),
191385
191396
  move(result));
191386
- } else {
191387
- result.plan = move(del);
191388
- result.names = {"Count"};
191389
- result.types = {LogicalType::BIGINT};
191390
- properties.allow_stream_result = false;
191391
- properties.return_type = StatementReturnType::CHANGED_ROWS;
191392
191397
  }
191398
+ result.plan = move(del);
191399
+ result.names = {"Count"};
191400
+ result.types = {LogicalType::BIGINT};
191401
+ properties.allow_stream_result = false;
191402
+ properties.return_type = StatementReturnType::CHANGED_ROWS;
191403
+
191393
191404
  return result;
191394
191405
  }
191395
191406
 
@@ -191952,13 +191963,13 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
191952
191963
 
191953
191964
  return BindReturning(move(stmt.returning_list), table, insert_table_index, move(index_as_logicaloperator),
191954
191965
  move(result));
191955
- } else {
191956
- D_ASSERT(result.types.size() == result.names.size());
191957
- result.plan = move(insert);
191958
- properties.allow_stream_result = false;
191959
- properties.return_type = StatementReturnType::CHANGED_ROWS;
191960
- return result;
191961
191966
  }
191967
+
191968
+ D_ASSERT(result.types.size() == result.names.size());
191969
+ result.plan = move(insert);
191970
+ properties.allow_stream_result = false;
191971
+ properties.return_type = StatementReturnType::CHANGED_ROWS;
191972
+ return result;
191962
191973
  }
191963
191974
 
191964
191975
  } // namespace duckdb
@@ -192609,15 +192620,14 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
192609
192620
 
192610
192621
  return BindReturning(move(stmt.returning_list), table, update_table_index, move(update_as_logicaloperator),
192611
192622
  move(result));
192612
-
192613
- } else {
192614
- update->table_index = 0;
192615
- result.names = {"Count"};
192616
- result.types = {LogicalType::BIGINT};
192617
- result.plan = move(update);
192618
- properties.allow_stream_result = false;
192619
- properties.return_type = StatementReturnType::CHANGED_ROWS;
192620
192623
  }
192624
+
192625
+ update->table_index = 0;
192626
+ result.names = {"Count"};
192627
+ result.types = {LogicalType::BIGINT};
192628
+ result.plan = move(update);
192629
+ properties.allow_stream_result = false;
192630
+ properties.return_type = StatementReturnType::CHANGED_ROWS;
192621
192631
  return result;
192622
192632
  }
192623
192633
 
@@ -196821,6 +196831,14 @@ namespace duckdb {
196821
196831
  ReturningBinder::ReturningBinder(Binder &binder, ClientContext &context) : ExpressionBinder(binder, context) {
196822
196832
  }
196823
196833
 
196834
+ BindResult ReturningBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth) {
196835
+ auto &expr = **expr_ptr;
196836
+ if (expr.GetName() == "rowid") {
196837
+ return BindResult("rowid is not supported in returning statements");
196838
+ }
196839
+ return ExpressionBinder::BindExpression(expr_ptr, depth);
196840
+ }
196841
+
196824
196842
  BindResult ReturningBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth, bool root_expression) {
196825
196843
  auto &expr = **expr_ptr;
196826
196844
  switch (expr.GetExpressionClass()) {
@@ -196828,6 +196846,8 @@ BindResult ReturningBinder::BindExpression(unique_ptr<ParsedExpression> *expr_pt
196828
196846
  return BindResult("SUBQUERY is not supported in returning statements");
196829
196847
  case ExpressionClass::BOUND_SUBQUERY:
196830
196848
  return BindResult("BOUND SUBQUERY is not supported in returning statements");
196849
+ case ExpressionClass::COLUMN_REF:
196850
+ return BindColumnRef(expr_ptr, depth);
196831
196851
  default:
196832
196852
  return ExpressionBinder::BindExpression(expr_ptr, depth);
196833
196853
  }
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 "2d34ffb455"
15
- #define DUCKDB_VERSION "v0.5.2-dev2251"
14
+ #define DUCKDB_SOURCE_ID "a2a67f76e8"
15
+ #define DUCKDB_VERSION "v0.5.2-dev2264"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //