duckdb 0.4.1-dev815.0 → 0.4.1-dev829.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-dev815.0",
4
+ "version": "0.4.1-dev829.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -162662,6 +162662,31 @@ LogicalType Transformer::TransformTypeName(duckdb_libpgquery::PGTypeName *type_n
162662
162662
 
162663
162663
 
162664
162664
 
162665
+ //===----------------------------------------------------------------------===//
162666
+ // DuckDB
162667
+ //
162668
+ // duckdb/common/enum_class_hash.hpp
162669
+ //
162670
+ //
162671
+ //===----------------------------------------------------------------------===//
162672
+
162673
+
162674
+
162675
+ #include <cstddef>
162676
+
162677
+ namespace duckdb {
162678
+ /* For compatibility with older C++ STL, an explicit hash class
162679
+ is required for enums with C++ sets and maps */
162680
+ struct EnumClassHash {
162681
+ template <typename T>
162682
+ std::size_t operator()(T t) const {
162683
+ return static_cast<std::size_t>(t);
162684
+ }
162685
+ };
162686
+ } // namespace duckdb
162687
+
162688
+
162689
+
162665
162690
  namespace duckdb {
162666
162691
 
162667
162692
  unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery::PGNode *node) {
@@ -162677,12 +162702,18 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
162677
162702
  throw InternalException("Expected an argument for ALTER SEQUENCE.");
162678
162703
  }
162679
162704
 
162705
+ unordered_set<SequenceInfo, EnumClassHash> used;
162680
162706
  duckdb_libpgquery::PGListCell *cell = nullptr;
162681
162707
  for_each_cell(cell, stmt->options->head) {
162682
162708
  auto *def_elem = reinterpret_cast<duckdb_libpgquery::PGDefElem *>(cell->data.ptr_value);
162683
162709
  string opt_name = string(def_elem->defname);
162684
162710
 
162685
162711
  if (opt_name == "owned_by") {
162712
+ if (used.find(SequenceInfo::SEQ_OWN) != used.end()) {
162713
+ throw ParserException("Owned by value should be passed as most once");
162714
+ }
162715
+ used.insert(SequenceInfo::SEQ_OWN);
162716
+
162686
162717
  auto val = (duckdb_libpgquery::PGValue *)def_elem->arg;
162687
162718
  if (!val) {
162688
162719
  throw InternalException("Expected an argument for option %s", opt_name);
@@ -162733,8 +162764,11 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
162733
162764
  D_ASSERT(stmt);
162734
162765
  D_ASSERT(stmt->relation);
162735
162766
 
162736
- auto result = make_unique<AlterStatement>();
162767
+ if (stmt->cmds->length != 1) {
162768
+ throw ParserException("Only one ALTER command per statement is supported");
162769
+ }
162737
162770
 
162771
+ auto result = make_unique<AlterStatement>();
162738
162772
  auto qname = TransformQualifiedName(stmt->relation);
162739
162773
 
162740
162774
  // first we check the type of ALTER
@@ -162744,6 +162778,10 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
162744
162778
  switch (command->subtype) {
162745
162779
  case duckdb_libpgquery::PG_AT_AddColumn: {
162746
162780
  auto cdef = (duckdb_libpgquery::PGColumnDef *)command->def;
162781
+
162782
+ if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
162783
+ throw ParserException("Adding columns is only supported for tables");
162784
+ }
162747
162785
  if (cdef->category == duckdb_libpgquery::COL_GENERATED) {
162748
162786
  throw ParserException("Adding generated columns after table creation is not supported yet");
162749
162787
  }
@@ -162763,20 +162801,31 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
162763
162801
  }
162764
162802
  case duckdb_libpgquery::PG_AT_DropColumn: {
162765
162803
  bool cascade = command->behavior == duckdb_libpgquery::PG_DROP_CASCADE;
162804
+
162805
+ if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
162806
+ throw ParserException("Dropping columns is only supported for tables");
162807
+ }
162766
162808
  result->info =
162767
162809
  make_unique<RemoveColumnInfo>(qname.schema, qname.name, command->name, command->missing_ok, cascade);
162768
162810
  break;
162769
162811
  }
162770
162812
  case duckdb_libpgquery::PG_AT_ColumnDefault: {
162771
162813
  auto expr = TransformExpression(command->def);
162814
+
162815
+ if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
162816
+ throw ParserException("Alter column's default is only supported for tables");
162817
+ }
162772
162818
  result->info = make_unique<SetDefaultInfo>(qname.schema, qname.name, command->name, move(expr));
162773
162819
  break;
162774
162820
  }
162775
162821
  case duckdb_libpgquery::PG_AT_AlterColumnType: {
162776
162822
  auto cdef = (duckdb_libpgquery::PGColumnDef *)command->def;
162777
162823
  auto column_definition = TransformColumnDefinition(cdef);
162778
-
162779
162824
  unique_ptr<ParsedExpression> expr;
162825
+
162826
+ if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
162827
+ throw ParserException("Alter column's type is only supported for tables");
162828
+ }
162780
162829
  if (cdef->raw_default) {
162781
162830
  expr = TransformExpression(cdef->raw_default);
162782
162831
  } else {
@@ -163128,6 +163177,8 @@ unique_ptr<CreateStatement> Transformer::TransformCreateSchema(duckdb_libpgquery
163128
163177
 
163129
163178
 
163130
163179
 
163180
+
163181
+
163131
163182
  namespace duckdb {
163132
163183
 
163133
163184
  unique_ptr<CreateStatement> Transformer::TransformCreateSequence(duckdb_libpgquery::PGNode *node) {
@@ -163141,27 +163192,35 @@ unique_ptr<CreateStatement> Transformer::TransformCreateSequence(duckdb_libpgque
163141
163192
  info->name = qname.name;
163142
163193
 
163143
163194
  if (stmt->options) {
163195
+ unordered_set<SequenceInfo, EnumClassHash> used;
163144
163196
  duckdb_libpgquery::PGListCell *cell = nullptr;
163145
163197
  for_each_cell(cell, stmt->options->head) {
163146
163198
  auto *def_elem = reinterpret_cast<duckdb_libpgquery::PGDefElem *>(cell->data.ptr_value);
163147
163199
  string opt_name = string(def_elem->defname);
163148
-
163149
163200
  auto val = (duckdb_libpgquery::PGValue *)def_elem->arg;
163150
- if (def_elem->defaction == duckdb_libpgquery::PG_DEFELEM_UNSPEC && !val) { // e.g. NO MINVALUE
163151
- continue;
163152
- }
163153
- D_ASSERT(val);
163154
- int64_t opt_value;
163155
- if (val->type == duckdb_libpgquery::T_PGInteger) {
163156
- opt_value = val->val.ival;
163157
- } else if (val->type == duckdb_libpgquery::T_PGFloat) {
163158
- if (!TryCast::Operation<string_t, int64_t>(string_t(val->val.str), opt_value, true)) {
163201
+ bool nodef = def_elem->defaction == duckdb_libpgquery::PG_DEFELEM_UNSPEC && !val; // e.g. NO MINVALUE
163202
+ int64_t opt_value = 0;
163203
+
163204
+ if (val) {
163205
+ if (val->type == duckdb_libpgquery::T_PGInteger) {
163206
+ opt_value = val->val.ival;
163207
+ } else if (val->type == duckdb_libpgquery::T_PGFloat) {
163208
+ if (!TryCast::Operation<string_t, int64_t>(string_t(val->val.str), opt_value, true)) {
163209
+ throw ParserException("Expected an integer argument for option %s", opt_name);
163210
+ }
163211
+ } else {
163159
163212
  throw ParserException("Expected an integer argument for option %s", opt_name);
163160
163213
  }
163161
- } else {
163162
- throw ParserException("Expected an integer argument for option %s", opt_name);
163163
163214
  }
163164
163215
  if (opt_name == "increment") {
163216
+ if (used.find(SequenceInfo::SEQ_INC) != used.end()) {
163217
+ throw ParserException("Increment value should be passed as most once");
163218
+ }
163219
+ used.insert(SequenceInfo::SEQ_INC);
163220
+ if (nodef) {
163221
+ continue;
163222
+ }
163223
+
163165
163224
  info->increment = opt_value;
163166
163225
  if (info->increment == 0) {
163167
163226
  throw ParserException("Increment must not be zero");
@@ -163174,18 +163233,50 @@ unique_ptr<CreateStatement> Transformer::TransformCreateSequence(duckdb_libpgque
163174
163233
  info->max_value = NumericLimits<int64_t>::Maximum();
163175
163234
  }
163176
163235
  } else if (opt_name == "minvalue") {
163236
+ if (used.find(SequenceInfo::SEQ_MIN) != used.end()) {
163237
+ throw ParserException("Minvalue should be passed as most once");
163238
+ }
163239
+ used.insert(SequenceInfo::SEQ_MIN);
163240
+ if (nodef) {
163241
+ continue;
163242
+ }
163243
+
163177
163244
  info->min_value = opt_value;
163178
163245
  if (info->increment > 0) {
163179
163246
  info->start_value = info->min_value;
163180
163247
  }
163181
163248
  } else if (opt_name == "maxvalue") {
163249
+ if (used.find(SequenceInfo::SEQ_MAX) != used.end()) {
163250
+ throw ParserException("Maxvalue should be passed as most once");
163251
+ }
163252
+ used.insert(SequenceInfo::SEQ_MAX);
163253
+ if (nodef) {
163254
+ continue;
163255
+ }
163256
+
163182
163257
  info->max_value = opt_value;
163183
163258
  if (info->increment < 0) {
163184
163259
  info->start_value = info->max_value;
163185
163260
  }
163186
163261
  } else if (opt_name == "start") {
163262
+ if (used.find(SequenceInfo::SEQ_START) != used.end()) {
163263
+ throw ParserException("Start value should be passed as most once");
163264
+ }
163265
+ used.insert(SequenceInfo::SEQ_START);
163266
+ if (nodef) {
163267
+ continue;
163268
+ }
163269
+
163187
163270
  info->start_value = opt_value;
163188
163271
  } else if (opt_name == "cycle") {
163272
+ if (used.find(SequenceInfo::SEQ_CYCLE) != used.end()) {
163273
+ throw ParserException("Cycle value should be passed as most once");
163274
+ }
163275
+ used.insert(SequenceInfo::SEQ_CYCLE);
163276
+ if (nodef) {
163277
+ continue;
163278
+ }
163279
+
163189
163280
  info->cycle = opt_value > 0;
163190
163281
  } else {
163191
163282
  throw ParserException("Unrecognized option \"%s\" for CREATE SEQUENCE", opt_name);
@@ -163966,6 +164057,7 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
163966
164057
  throw NotImplementedException("Schema element not supported yet!");
163967
164058
  }
163968
164059
  D_ASSERT(info);
164060
+ info->if_exists = stmt->missing_ok;
163969
164061
 
163970
164062
  auto result = make_unique<AlterStatement>();
163971
164063
  result->info = move(info);
@@ -164537,6 +164629,9 @@ unique_ptr<TableRef> Transformer::TransformRangeSubselect(duckdb_libpgquery::PGR
164537
164629
  if (!subquery) {
164538
164630
  return nullptr;
164539
164631
  }
164632
+ if (root->lateral) {
164633
+ throw NotImplementedException("LATERAL not implemented");
164634
+ }
164540
164635
  auto result = make_unique<SubqueryRef>(move(subquery));
164541
164636
  result->alias = TransformAlias(root->alias, result->column_name_alias);
164542
164637
  if (root->sample) {
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 "4650df619"
15
- #define DUCKDB_VERSION "v0.4.1-dev815"
14
+ #define DUCKDB_SOURCE_ID "195b7b47b"
15
+ #define DUCKDB_VERSION "v0.4.1-dev829"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -12208,6 +12208,21 @@ public:
12208
12208
 
12209
12209
  namespace duckdb {
12210
12210
 
12211
+ enum class SequenceInfo : uint8_t {
12212
+ // Sequence start
12213
+ SEQ_START,
12214
+ // Sequence increment
12215
+ SEQ_INC,
12216
+ // Sequence minimum value
12217
+ SEQ_MIN,
12218
+ // Sequence maximum value
12219
+ SEQ_MAX,
12220
+ // Sequence cycle option
12221
+ SEQ_CYCLE,
12222
+ // Sequence owner table
12223
+ SEQ_OWN
12224
+ };
12225
+
12211
12226
  struct CreateSequenceInfo : public CreateInfo {
12212
12227
  CreateSequenceInfo()
12213
12228
  : CreateInfo(CatalogType::SEQUENCE_ENTRY, INVALID_SCHEMA), name(string()), usage_count(0), increment(1),