duckdb 0.4.1-dev2385.0 → 0.4.1-dev2399.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
@@ -2459,6 +2459,7 @@ unique_ptr<CreateMacroInfo> TableMacroCatalogEntry::Deserialize(Deserializer &ma
2459
2459
 
2460
2460
 
2461
2461
 
2462
+
2462
2463
  //===----------------------------------------------------------------------===//
2463
2464
  // DuckDB
2464
2465
  //
@@ -2502,6 +2503,7 @@ private:
2502
2503
 
2503
2504
  } // namespace duckdb
2504
2505
 
2506
+
2505
2507
  //===----------------------------------------------------------------------===//
2506
2508
  // DuckDB
2507
2509
  //
@@ -2531,64 +2533,20 @@ public:
2531
2533
 
2532
2534
  } // namespace duckdb
2533
2535
 
2534
-
2535
-
2536
-
2537
-
2538
-
2539
-
2540
-
2541
-
2542
-
2543
-
2544
-
2545
-
2546
-
2547
-
2548
-
2549
-
2550
2536
  //===----------------------------------------------------------------------===//
2551
2537
  // DuckDB
2552
2538
  //
2553
- // duckdb/planner/constraints/bound_foreign_key_constraint.hpp
2539
+ // duckdb/common/algorithm.hpp
2554
2540
  //
2555
2541
  //
2556
2542
  //===----------------------------------------------------------------------===//
2557
2543
 
2558
2544
 
2559
2545
 
2546
+ #include <algorithm>
2560
2547
 
2561
2548
 
2562
2549
 
2563
- namespace duckdb {
2564
-
2565
- class BoundForeignKeyConstraint : public BoundConstraint {
2566
- public:
2567
- BoundForeignKeyConstraint(ForeignKeyInfo info_p, unordered_set<idx_t> pk_key_set_p,
2568
- unordered_set<idx_t> fk_key_set_p)
2569
- : BoundConstraint(ConstraintType::FOREIGN_KEY), info(move(info_p)), pk_key_set(move(pk_key_set_p)),
2570
- fk_key_set(move(fk_key_set_p)) {
2571
- #ifdef DEBUG
2572
- D_ASSERT(info.pk_keys.size() == pk_key_set.size());
2573
- for (auto &key : info.pk_keys) {
2574
- D_ASSERT(pk_key_set.find(key) != pk_key_set.end());
2575
- }
2576
- D_ASSERT(info.fk_keys.size() == fk_key_set.size());
2577
- for (auto &key : info.fk_keys) {
2578
- D_ASSERT(fk_key_set.find(key) != fk_key_set.end());
2579
- }
2580
- #endif
2581
- }
2582
-
2583
- ForeignKeyInfo info;
2584
- //! The same keys but stored as an unordered set
2585
- unordered_set<idx_t> pk_key_set;
2586
- //! The same keys but stored as an unordered set
2587
- unordered_set<idx_t> fk_key_set;
2588
- };
2589
-
2590
- } // namespace duckdb
2591
-
2592
2550
  //===----------------------------------------------------------------------===//
2593
2551
  // DuckDB
2594
2552
  //
@@ -2630,17 +2588,59 @@ public:
2630
2588
 
2631
2589
 
2632
2590
 
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2633
2600
  //===----------------------------------------------------------------------===//
2634
2601
  // DuckDB
2635
2602
  //
2636
- // duckdb/common/algorithm.hpp
2603
+ // duckdb/planner/constraints/bound_foreign_key_constraint.hpp
2637
2604
  //
2638
2605
  //
2639
2606
  //===----------------------------------------------------------------------===//
2640
2607
 
2641
2608
 
2642
2609
 
2643
- #include <algorithm>
2610
+
2611
+
2612
+
2613
+ namespace duckdb {
2614
+
2615
+ class BoundForeignKeyConstraint : public BoundConstraint {
2616
+ public:
2617
+ BoundForeignKeyConstraint(ForeignKeyInfo info_p, unordered_set<idx_t> pk_key_set_p,
2618
+ unordered_set<idx_t> fk_key_set_p)
2619
+ : BoundConstraint(ConstraintType::FOREIGN_KEY), info(move(info_p)), pk_key_set(move(pk_key_set_p)),
2620
+ fk_key_set(move(fk_key_set_p)) {
2621
+ #ifdef DEBUG
2622
+ D_ASSERT(info.pk_keys.size() == pk_key_set.size());
2623
+ for (auto &key : info.pk_keys) {
2624
+ D_ASSERT(pk_key_set.find(key) != pk_key_set.end());
2625
+ }
2626
+ D_ASSERT(info.fk_keys.size() == fk_key_set.size());
2627
+ for (auto &key : info.fk_keys) {
2628
+ D_ASSERT(fk_key_set.find(key) != fk_key_set.end());
2629
+ }
2630
+ #endif
2631
+ }
2632
+
2633
+ ForeignKeyInfo info;
2634
+ //! The same keys but stored as an unordered set
2635
+ unordered_set<idx_t> pk_key_set;
2636
+ //! The same keys but stored as an unordered set
2637
+ unordered_set<idx_t> fk_key_set;
2638
+ };
2639
+
2640
+ } // namespace duckdb
2641
+
2642
+
2643
+
2644
2644
 
2645
2645
  #include <sstream>
2646
2646
 
@@ -2659,7 +2659,7 @@ void FindForeignKeyInformation(CatalogEntry *entry, AlterForeignKeyType alter_fk
2659
2659
  }
2660
2660
  auto &fk = (ForeignKeyConstraint &)*cond;
2661
2661
  if (fk.info.type == ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE) {
2662
- fk_arrays.push_back(make_unique<AlterForeignKeyInfo>(fk.info.schema, fk.info.table, entry->name,
2662
+ fk_arrays.push_back(make_unique<AlterForeignKeyInfo>(fk.info.schema, fk.info.table, false, entry->name,
2663
2663
  fk.pk_columns, fk.fk_columns, fk.info.pk_keys,
2664
2664
  fk.info.fk_keys, alter_fk_type));
2665
2665
  } else if (fk.info.type == ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE &&
@@ -3025,6 +3025,9 @@ string SequenceCatalogEntry::ToSQL() {
3025
3025
 
3026
3026
 
3027
3027
 
3028
+
3029
+
3030
+
3028
3031
  //===----------------------------------------------------------------------===//
3029
3032
  // DuckDB
3030
3033
  //
@@ -3105,6 +3108,76 @@ public:
3105
3108
 
3106
3109
 
3107
3110
 
3111
+
3112
+ //===----------------------------------------------------------------------===//
3113
+ // DuckDB
3114
+ //
3115
+ // duckdb/parser/parsed_expression_iterator.hpp
3116
+ //
3117
+ //
3118
+ //===----------------------------------------------------------------------===//
3119
+
3120
+
3121
+
3122
+
3123
+
3124
+
3125
+ #include <functional>
3126
+
3127
+ namespace duckdb {
3128
+
3129
+ class ParsedExpressionIterator {
3130
+ public:
3131
+ static void EnumerateChildren(const ParsedExpression &expression,
3132
+ const std::function<void(const ParsedExpression &child)> &callback);
3133
+ static void EnumerateChildren(ParsedExpression &expr, const std::function<void(ParsedExpression &child)> &callback);
3134
+ static void EnumerateChildren(ParsedExpression &expr,
3135
+ const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3136
+
3137
+ static void EnumerateTableRefChildren(TableRef &ref,
3138
+ const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3139
+ static void EnumerateQueryNodeChildren(QueryNode &node,
3140
+ const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3141
+
3142
+ static void EnumerateQueryNodeModifiers(QueryNode &node,
3143
+ const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3144
+ };
3145
+
3146
+ } // namespace duckdb
3147
+
3148
+
3149
+ //===----------------------------------------------------------------------===//
3150
+ // DuckDB
3151
+ //
3152
+ // duckdb/planner/constraints/bound_check_constraint.hpp
3153
+ //
3154
+ //
3155
+ //===----------------------------------------------------------------------===//
3156
+
3157
+
3158
+
3159
+
3160
+
3161
+
3162
+
3163
+ namespace duckdb {
3164
+
3165
+ //! The CheckConstraint contains an expression that must evaluate to TRUE for
3166
+ //! every row in a table
3167
+ class BoundCheckConstraint : public BoundConstraint {
3168
+ public:
3169
+ BoundCheckConstraint() : BoundConstraint(ConstraintType::CHECK) {
3170
+ }
3171
+
3172
+ //! The expression
3173
+ unique_ptr<Expression> expression;
3174
+ //! The columns used by the CHECK constraint
3175
+ unordered_set<column_t> bound_columns;
3176
+ };
3177
+
3178
+ } // namespace duckdb
3179
+
3180
+
3108
3181
  //===----------------------------------------------------------------------===//
3109
3182
  // DuckDB
3110
3183
  //
@@ -3168,10 +3241,11 @@ public:
3168
3241
 
3169
3242
  } // namespace duckdb
3170
3243
 
3244
+
3171
3245
  //===----------------------------------------------------------------------===//
3172
3246
  // DuckDB
3173
3247
  //
3174
- // duckdb/planner/constraints/bound_check_constraint.hpp
3248
+ // duckdb/planner/expression_binder/alter_binder.hpp
3175
3249
  //
3176
3250
  //
3177
3251
  //===----------------------------------------------------------------------===//
@@ -3181,26 +3255,32 @@ public:
3181
3255
 
3182
3256
 
3183
3257
 
3184
-
3185
3258
  namespace duckdb {
3259
+ class TableCatalogEntry;
3186
3260
 
3187
- //! The CheckConstraint contains an expression that must evaluate to TRUE for
3188
- //! every row in a table
3189
- class BoundCheckConstraint : public BoundConstraint {
3261
+ //! The ALTER binder is responsible for binding an expression within alter statements
3262
+ class AlterBinder : public ExpressionBinder {
3190
3263
  public:
3191
- BoundCheckConstraint() : BoundConstraint(ConstraintType::CHECK) {
3192
- }
3264
+ AlterBinder(Binder &binder, ClientContext &context, TableCatalogEntry &table, vector<column_t> &bound_columns,
3265
+ LogicalType target_type);
3193
3266
 
3194
- //! The expression
3195
- unique_ptr<Expression> expression;
3196
- //! The columns used by the CHECK constraint
3197
- unordered_set<column_t> bound_columns;
3267
+ TableCatalogEntry &table;
3268
+ vector<column_t> &bound_columns;
3269
+
3270
+ protected:
3271
+ BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
3272
+ bool root_expression = false) override;
3273
+
3274
+ BindResult BindColumn(ColumnRefExpression &expr);
3275
+
3276
+ string UnsupportedAggregateMessage() override;
3198
3277
  };
3199
3278
 
3200
3279
  } // namespace duckdb
3201
3280
 
3202
3281
 
3203
3282
 
3283
+
3204
3284
  //===----------------------------------------------------------------------===//
3205
3285
  // DuckDB
3206
3286
  //
@@ -3445,86 +3525,6 @@ private:
3445
3525
  } // namespace duckdb
3446
3526
 
3447
3527
 
3448
-
3449
-
3450
-
3451
-
3452
-
3453
-
3454
- //===----------------------------------------------------------------------===//
3455
- // DuckDB
3456
- //
3457
- // duckdb/parser/parsed_expression_iterator.hpp
3458
- //
3459
- //
3460
- //===----------------------------------------------------------------------===//
3461
-
3462
-
3463
-
3464
-
3465
-
3466
-
3467
- #include <functional>
3468
-
3469
- namespace duckdb {
3470
-
3471
- class ParsedExpressionIterator {
3472
- public:
3473
- static void EnumerateChildren(const ParsedExpression &expression,
3474
- const std::function<void(const ParsedExpression &child)> &callback);
3475
- static void EnumerateChildren(ParsedExpression &expr, const std::function<void(ParsedExpression &child)> &callback);
3476
- static void EnumerateChildren(ParsedExpression &expr,
3477
- const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3478
-
3479
- static void EnumerateTableRefChildren(TableRef &ref,
3480
- const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3481
- static void EnumerateQueryNodeChildren(QueryNode &node,
3482
- const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3483
-
3484
- static void EnumerateQueryNodeModifiers(QueryNode &node,
3485
- const std::function<void(unique_ptr<ParsedExpression> &child)> &callback);
3486
- };
3487
-
3488
- } // namespace duckdb
3489
-
3490
- //===----------------------------------------------------------------------===//
3491
- // DuckDB
3492
- //
3493
- // duckdb/planner/expression_binder/alter_binder.hpp
3494
- //
3495
- //
3496
- //===----------------------------------------------------------------------===//
3497
-
3498
-
3499
-
3500
-
3501
-
3502
-
3503
- namespace duckdb {
3504
- class TableCatalogEntry;
3505
-
3506
- //! The ALTER binder is responsible for binding an expression within alter statements
3507
- class AlterBinder : public ExpressionBinder {
3508
- public:
3509
- AlterBinder(Binder &binder, ClientContext &context, TableCatalogEntry &table, vector<column_t> &bound_columns,
3510
- LogicalType target_type);
3511
-
3512
- TableCatalogEntry &table;
3513
- vector<column_t> &bound_columns;
3514
-
3515
- protected:
3516
- BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
3517
- bool root_expression = false) override;
3518
-
3519
- BindResult BindColumn(ColumnRefExpression &expr);
3520
-
3521
- string UnsupportedAggregateMessage() override;
3522
- };
3523
-
3524
- } // namespace duckdb
3525
-
3526
-
3527
-
3528
3528
  #include <sstream>
3529
3529
 
3530
3530
  namespace duckdb {
@@ -3545,6 +3545,10 @@ column_t TableCatalogEntry::GetColumnIndex(string &column_name, bool if_exists)
3545
3545
  throw BinderException("Table \"%s\" does not have a column with name \"%s\"", name, column_name);
3546
3546
  }
3547
3547
  }
3548
+ if (entry->second == COLUMN_IDENTIFIER_ROW_ID) {
3549
+ column_name = "rowid";
3550
+ return COLUMN_IDENTIFIER_ROW_ID;
3551
+ }
3548
3552
  column_name = GetColumnName(entry->second);
3549
3553
  return entry->second;
3550
3554
  }
@@ -3797,6 +3801,13 @@ unique_ptr<CatalogEntry> TableCatalogEntry::RenameColumn(ClientContext &context,
3797
3801
  }
3798
3802
 
3799
3803
  unique_ptr<CatalogEntry> TableCatalogEntry::AddColumn(ClientContext &context, AddColumnInfo &info) {
3804
+ auto col_name = info.new_column.GetName();
3805
+
3806
+ // We're checking for the opposite condition (ADD COLUMN IF _NOT_ EXISTS ...).
3807
+ if (info.if_column_not_exists && GetColumnIndex(col_name, true) != DConstants::INVALID_INDEX) {
3808
+ return nullptr;
3809
+ }
3810
+
3800
3811
  auto create_info = make_unique<CreateTableInfo>(schema->name, name);
3801
3812
  create_info->temporary = temporary;
3802
3813
 
@@ -3823,7 +3834,7 @@ unique_ptr<CatalogEntry> TableCatalogEntry::AddColumn(ClientContext &context, Ad
3823
3834
  }
3824
3835
 
3825
3836
  unique_ptr<CatalogEntry> TableCatalogEntry::RemoveColumn(ClientContext &context, RemoveColumnInfo &info) {
3826
- auto removed_index = GetColumnIndex(info.removed_column, info.if_exists);
3837
+ auto removed_index = GetColumnIndex(info.removed_column, info.if_column_exists);
3827
3838
  if (removed_index == DConstants::INVALID_INDEX) {
3828
3839
  return nullptr;
3829
3840
  }
@@ -160038,10 +160049,11 @@ string KeywordHelper::WriteOptionallyQuoted(const string &text, char quote) {
160038
160049
 
160039
160050
 
160040
160051
 
160052
+
160041
160053
  namespace duckdb {
160042
160054
 
160043
- AlterInfo::AlterInfo(AlterType type, string schema_p, string name_p)
160044
- : type(type), if_exists(false), schema(move(schema_p)), name(move(name_p)) {
160055
+ AlterInfo::AlterInfo(AlterType type, string schema_p, string name_p, bool if_exists)
160056
+ : type(type), if_exists(if_exists), schema(move(schema_p)), name(move(name_p)) {
160045
160057
  }
160046
160058
 
160047
160059
  AlterInfo::~AlterInfo() {
@@ -160078,8 +160090,8 @@ unique_ptr<AlterInfo> AlterInfo::Deserialize(Deserializer &source) {
160078
160090
  // ChangeOwnershipInfo
160079
160091
  //===--------------------------------------------------------------------===//
160080
160092
  ChangeOwnershipInfo::ChangeOwnershipInfo(CatalogType entry_catalog_type, string entry_schema_p, string entry_name_p,
160081
- string owner_schema_p, string owner_name_p)
160082
- : AlterInfo(AlterType::CHANGE_OWNERSHIP, move(entry_schema_p), move(entry_name_p)),
160093
+ string owner_schema_p, string owner_name_p, bool if_exists)
160094
+ : AlterInfo(AlterType::CHANGE_OWNERSHIP, move(entry_schema_p), move(entry_name_p), if_exists),
160083
160095
  entry_catalog_type(entry_catalog_type), owner_schema(move(owner_schema_p)), owner_name(move(owner_name_p)) {
160084
160096
  }
160085
160097
 
@@ -160088,7 +160100,8 @@ CatalogType ChangeOwnershipInfo::GetCatalogType() const {
160088
160100
  }
160089
160101
 
160090
160102
  unique_ptr<AlterInfo> ChangeOwnershipInfo::Copy() const {
160091
- return make_unique_base<AlterInfo, ChangeOwnershipInfo>(entry_catalog_type, schema, name, owner_schema, owner_name);
160103
+ return make_unique_base<AlterInfo, ChangeOwnershipInfo>(entry_catalog_type, schema, name, owner_schema, owner_name,
160104
+ if_exists);
160092
160105
  }
160093
160106
 
160094
160107
  void ChangeOwnershipInfo::Serialize(FieldWriter &writer) const {
@@ -160098,8 +160111,8 @@ void ChangeOwnershipInfo::Serialize(FieldWriter &writer) const {
160098
160111
  //===--------------------------------------------------------------------===//
160099
160112
  // AlterTableInfo
160100
160113
  //===--------------------------------------------------------------------===//
160101
- AlterTableInfo::AlterTableInfo(AlterTableType type, string schema_p, string table_p)
160102
- : AlterInfo(AlterType::ALTER_TABLE, move(move(schema_p)), move(table_p)), alter_table_type(type) {
160114
+ AlterTableInfo::AlterTableInfo(AlterTableType type, string schema_p, string table_p, bool if_exists)
160115
+ : AlterInfo(AlterType::ALTER_TABLE, move(move(schema_p)), move(table_p), if_exists), alter_table_type(type) {
160103
160116
  }
160104
160117
  AlterTableInfo::~AlterTableInfo() {
160105
160118
  }
@@ -160112,6 +160125,7 @@ void AlterTableInfo::Serialize(FieldWriter &writer) const {
160112
160125
  writer.WriteField<AlterTableType>(alter_table_type);
160113
160126
  writer.WriteString(schema);
160114
160127
  writer.WriteString(name);
160128
+ writer.WriteField(if_exists);
160115
160129
  SerializeAlterTable(writer);
160116
160130
  }
160117
160131
 
@@ -160119,26 +160133,28 @@ unique_ptr<AlterInfo> AlterTableInfo::Deserialize(FieldReader &reader) {
160119
160133
  auto type = reader.ReadRequired<AlterTableType>();
160120
160134
  auto schema = reader.ReadRequired<string>();
160121
160135
  auto table = reader.ReadRequired<string>();
160136
+ auto if_exists = reader.ReadRequired<bool>();
160137
+
160122
160138
  unique_ptr<AlterTableInfo> info;
160123
160139
  switch (type) {
160124
160140
  case AlterTableType::RENAME_COLUMN:
160125
- return RenameColumnInfo::Deserialize(reader, schema, table);
160141
+ return RenameColumnInfo::Deserialize(reader, schema, table, if_exists);
160126
160142
  case AlterTableType::RENAME_TABLE:
160127
- return RenameTableInfo::Deserialize(reader, schema, table);
160143
+ return RenameTableInfo::Deserialize(reader, schema, table, if_exists);
160128
160144
  case AlterTableType::ADD_COLUMN:
160129
- return AddColumnInfo::Deserialize(reader, schema, table);
160145
+ return AddColumnInfo::Deserialize(reader, schema, table, if_exists);
160130
160146
  case AlterTableType::REMOVE_COLUMN:
160131
- return RemoveColumnInfo::Deserialize(reader, schema, table);
160147
+ return RemoveColumnInfo::Deserialize(reader, schema, table, if_exists);
160132
160148
  case AlterTableType::ALTER_COLUMN_TYPE:
160133
- return ChangeColumnTypeInfo::Deserialize(reader, schema, table);
160149
+ return ChangeColumnTypeInfo::Deserialize(reader, schema, table, if_exists);
160134
160150
  case AlterTableType::SET_DEFAULT:
160135
- return SetDefaultInfo::Deserialize(reader, schema, table);
160151
+ return SetDefaultInfo::Deserialize(reader, schema, table, if_exists);
160136
160152
  case AlterTableType::FOREIGN_KEY_CONSTRAINT:
160137
- return AlterForeignKeyInfo::Deserialize(reader, schema, table);
160153
+ return AlterForeignKeyInfo::Deserialize(reader, schema, table, if_exists);
160138
160154
  case AlterTableType::SET_NOT_NULL:
160139
- return SetNotNullInfo::Deserialize(reader, schema, table);
160155
+ return SetNotNullInfo::Deserialize(reader, schema, table, if_exists);
160140
160156
  case AlterTableType::DROP_NOT_NULL:
160141
- return DropNotNullInfo::Deserialize(reader, schema, table);
160157
+ return DropNotNullInfo::Deserialize(reader, schema, table, if_exists);
160142
160158
  default:
160143
160159
  throw SerializationException("Unknown alter table type for deserialization!");
160144
160160
  }
@@ -160147,15 +160163,16 @@ unique_ptr<AlterInfo> AlterTableInfo::Deserialize(FieldReader &reader) {
160147
160163
  //===--------------------------------------------------------------------===//
160148
160164
  // RenameColumnInfo
160149
160165
  //===--------------------------------------------------------------------===//
160150
- RenameColumnInfo::RenameColumnInfo(string schema_p, string table_p, string old_name_p, string new_name_p)
160151
- : AlterTableInfo(AlterTableType::RENAME_COLUMN, move(schema_p), move(table_p)), old_name(move(old_name_p)),
160152
- new_name(move(new_name_p)) {
160166
+ RenameColumnInfo::RenameColumnInfo(string schema_p, string table_p, bool if_exists_p, string old_name_p,
160167
+ string new_name_p)
160168
+ : AlterTableInfo(AlterTableType::RENAME_COLUMN, move(schema_p), move(table_p), if_exists_p),
160169
+ old_name(move(old_name_p)), new_name(move(new_name_p)) {
160153
160170
  }
160154
160171
  RenameColumnInfo::~RenameColumnInfo() {
160155
160172
  }
160156
160173
 
160157
160174
  unique_ptr<AlterInfo> RenameColumnInfo::Copy() const {
160158
- return make_unique_base<AlterInfo, RenameColumnInfo>(schema, name, old_name, new_name);
160175
+ return make_unique_base<AlterInfo, RenameColumnInfo>(schema, name, if_exists, old_name, new_name);
160159
160176
  }
160160
160177
 
160161
160178
  void RenameColumnInfo::SerializeAlterTable(FieldWriter &writer) const {
@@ -160163,96 +160180,104 @@ void RenameColumnInfo::SerializeAlterTable(FieldWriter &writer) const {
160163
160180
  writer.WriteString(new_name);
160164
160181
  }
160165
160182
 
160166
- unique_ptr<AlterInfo> RenameColumnInfo::Deserialize(FieldReader &reader, string schema, string table) {
160183
+ unique_ptr<AlterInfo> RenameColumnInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160167
160184
  auto old_name = reader.ReadRequired<string>();
160168
160185
  auto new_name = reader.ReadRequired<string>();
160169
- return make_unique<RenameColumnInfo>(move(schema), move(table), old_name, new_name);
160186
+ return make_unique<RenameColumnInfo>(move(schema), move(table), if_exists, old_name, new_name);
160170
160187
  }
160171
160188
 
160172
160189
  //===--------------------------------------------------------------------===//
160173
160190
  // RenameTableInfo
160174
160191
  //===--------------------------------------------------------------------===//
160175
- RenameTableInfo::RenameTableInfo(string schema_p, string table_p, string new_name_p)
160176
- : AlterTableInfo(AlterTableType::RENAME_TABLE, move(schema_p), move(table_p)), new_table_name(move(new_name_p)) {
160192
+ RenameTableInfo::RenameTableInfo(string schema_p, string table_p, bool if_exists, string new_name_p)
160193
+ : AlterTableInfo(AlterTableType::RENAME_TABLE, move(schema_p), move(table_p), if_exists),
160194
+ new_table_name(move(new_name_p)) {
160177
160195
  }
160178
160196
  RenameTableInfo::~RenameTableInfo() {
160179
160197
  }
160180
160198
 
160181
160199
  unique_ptr<AlterInfo> RenameTableInfo::Copy() const {
160182
- return make_unique_base<AlterInfo, RenameTableInfo>(schema, name, new_table_name);
160200
+ return make_unique_base<AlterInfo, RenameTableInfo>(schema, name, if_exists, new_table_name);
160183
160201
  }
160184
160202
 
160185
160203
  void RenameTableInfo::SerializeAlterTable(FieldWriter &writer) const {
160186
160204
  writer.WriteString(new_table_name);
160187
160205
  }
160188
160206
 
160189
- unique_ptr<AlterInfo> RenameTableInfo::Deserialize(FieldReader &reader, string schema, string table) {
160207
+ unique_ptr<AlterInfo> RenameTableInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160190
160208
  auto new_name = reader.ReadRequired<string>();
160191
- return make_unique<RenameTableInfo>(move(schema), move(table), new_name);
160209
+ return make_unique<RenameTableInfo>(move(schema), move(table), if_exists, new_name);
160192
160210
  }
160193
160211
 
160194
160212
  //===--------------------------------------------------------------------===//
160195
160213
  // AddColumnInfo
160196
160214
  //===--------------------------------------------------------------------===//
160197
- AddColumnInfo::AddColumnInfo(string schema_p, string table_p, ColumnDefinition new_column)
160198
- : AlterTableInfo(AlterTableType::ADD_COLUMN, move(schema_p), move(table_p)), new_column(move(new_column)) {
160215
+ AddColumnInfo::AddColumnInfo(string schema_p, string table_p, bool if_exists_p, ColumnDefinition new_column,
160216
+ bool if_column_not_exists)
160217
+ : AlterTableInfo(AlterTableType::ADD_COLUMN, move(schema_p), move(table_p), if_exists_p),
160218
+ new_column(move(new_column)), if_column_not_exists(if_column_not_exists) {
160199
160219
  }
160220
+
160200
160221
  AddColumnInfo::~AddColumnInfo() {
160201
160222
  }
160202
160223
 
160203
160224
  unique_ptr<AlterInfo> AddColumnInfo::Copy() const {
160204
- return make_unique_base<AlterInfo, AddColumnInfo>(schema, name, new_column.Copy());
160225
+ return make_unique_base<AlterInfo, AddColumnInfo>(schema, name, if_exists, new_column.Copy(), if_column_not_exists);
160205
160226
  }
160206
160227
 
160207
160228
  void AddColumnInfo::SerializeAlterTable(FieldWriter &writer) const {
160208
160229
  writer.WriteSerializable(new_column);
160230
+ writer.WriteField<bool>(if_column_not_exists);
160209
160231
  }
160210
160232
 
160211
- unique_ptr<AlterInfo> AddColumnInfo::Deserialize(FieldReader &reader, string schema, string table) {
160233
+ unique_ptr<AlterInfo> AddColumnInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160212
160234
  auto new_column = reader.ReadRequiredSerializable<ColumnDefinition, ColumnDefinition>();
160213
- return make_unique<AddColumnInfo>(move(schema), move(table), move(new_column));
160235
+ auto if_column_not_exists = reader.ReadRequired<bool>();
160236
+ return make_unique<AddColumnInfo>(move(schema), move(table), if_exists, move(new_column), if_column_not_exists);
160214
160237
  }
160215
160238
 
160216
160239
  //===--------------------------------------------------------------------===//
160217
160240
  // RemoveColumnInfo
160218
160241
  //===--------------------------------------------------------------------===//
160219
- RemoveColumnInfo::RemoveColumnInfo(string schema, string table, string removed_column, bool if_exists, bool cascade)
160220
- : AlterTableInfo(AlterTableType::REMOVE_COLUMN, move(schema), move(table)), removed_column(move(removed_column)),
160221
- if_exists(if_exists), cascade(cascade) {
160242
+ RemoveColumnInfo::RemoveColumnInfo(string schema, string table, bool if_exists, string removed_column,
160243
+ bool if_column_exists, bool cascade)
160244
+ : AlterTableInfo(AlterTableType::REMOVE_COLUMN, move(schema), move(table), if_exists),
160245
+ removed_column(move(removed_column)), if_column_exists(if_column_exists), cascade(cascade) {
160222
160246
  }
160223
160247
  RemoveColumnInfo::~RemoveColumnInfo() {
160224
160248
  }
160225
160249
 
160226
160250
  unique_ptr<AlterInfo> RemoveColumnInfo::Copy() const {
160227
- return make_unique_base<AlterInfo, RemoveColumnInfo>(schema, name, removed_column, if_exists, cascade);
160251
+ return make_unique_base<AlterInfo, RemoveColumnInfo>(schema, name, if_exists, removed_column, if_column_exists,
160252
+ cascade);
160228
160253
  }
160229
160254
 
160230
160255
  void RemoveColumnInfo::SerializeAlterTable(FieldWriter &writer) const {
160231
160256
  writer.WriteString(removed_column);
160232
- writer.WriteField<bool>(if_exists);
160257
+ writer.WriteField<bool>(if_column_exists);
160233
160258
  writer.WriteField<bool>(cascade);
160234
160259
  }
160235
160260
 
160236
- unique_ptr<AlterInfo> RemoveColumnInfo::Deserialize(FieldReader &reader, string schema, string table) {
160261
+ unique_ptr<AlterInfo> RemoveColumnInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160237
160262
  auto new_name = reader.ReadRequired<string>();
160238
- auto if_exists = reader.ReadRequired<bool>();
160263
+ auto if_column_exists = reader.ReadRequired<bool>();
160239
160264
  auto cascade = reader.ReadRequired<bool>();
160240
- return make_unique<RemoveColumnInfo>(move(schema), move(table), new_name, if_exists, cascade);
160265
+ return make_unique<RemoveColumnInfo>(move(schema), move(table), if_exists, new_name, if_column_exists, cascade);
160241
160266
  }
160242
160267
 
160243
160268
  //===--------------------------------------------------------------------===//
160244
160269
  // ChangeColumnTypeInfo
160245
160270
  //===--------------------------------------------------------------------===//
160246
- ChangeColumnTypeInfo::ChangeColumnTypeInfo(string schema_p, string table_p, string column_name, LogicalType target_type,
160247
- unique_ptr<ParsedExpression> expression)
160248
- : AlterTableInfo(AlterTableType::ALTER_COLUMN_TYPE, move(schema_p), move(table_p)), column_name(move(column_name)),
160249
- target_type(move(target_type)), expression(move(expression)) {
160271
+ ChangeColumnTypeInfo::ChangeColumnTypeInfo(string schema_p, string table_p, bool if_exists_p, string column_name,
160272
+ LogicalType target_type, unique_ptr<ParsedExpression> expression)
160273
+ : AlterTableInfo(AlterTableType::ALTER_COLUMN_TYPE, move(schema_p), move(table_p), if_exists_p),
160274
+ column_name(move(column_name)), target_type(move(target_type)), expression(move(expression)) {
160250
160275
  }
160251
160276
  ChangeColumnTypeInfo::~ChangeColumnTypeInfo() {
160252
160277
  }
160253
160278
 
160254
160279
  unique_ptr<AlterInfo> ChangeColumnTypeInfo::Copy() const {
160255
- return make_unique_base<AlterInfo, ChangeColumnTypeInfo>(schema, name, column_name, target_type,
160280
+ return make_unique_base<AlterInfo, ChangeColumnTypeInfo>(schema, name, if_exists, column_name, target_type,
160256
160281
  expression->Copy());
160257
160282
  }
160258
160283
 
@@ -160262,27 +160287,28 @@ void ChangeColumnTypeInfo::SerializeAlterTable(FieldWriter &writer) const {
160262
160287
  writer.WriteOptional(expression);
160263
160288
  }
160264
160289
 
160265
- unique_ptr<AlterInfo> ChangeColumnTypeInfo::Deserialize(FieldReader &reader, string schema, string table) {
160290
+ unique_ptr<AlterInfo> ChangeColumnTypeInfo::Deserialize(FieldReader &reader, string schema, string table,
160291
+ bool if_exists) {
160266
160292
  auto column_name = reader.ReadRequired<string>();
160267
160293
  auto target_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
160268
160294
  auto expression = reader.ReadOptional<ParsedExpression>(nullptr);
160269
- return make_unique<ChangeColumnTypeInfo>(move(schema), move(table), move(column_name), move(target_type),
160295
+ return make_unique<ChangeColumnTypeInfo>(move(schema), move(table), if_exists, move(column_name), move(target_type),
160270
160296
  move(expression));
160271
160297
  }
160272
160298
 
160273
160299
  //===--------------------------------------------------------------------===//
160274
160300
  // SetDefaultInfo
160275
160301
  //===--------------------------------------------------------------------===//
160276
- SetDefaultInfo::SetDefaultInfo(string schema_p, string table_p, string column_name_p,
160302
+ SetDefaultInfo::SetDefaultInfo(string schema_p, string table_p, bool if_exists_p, string column_name_p,
160277
160303
  unique_ptr<ParsedExpression> new_default)
160278
- : AlterTableInfo(AlterTableType::SET_DEFAULT, move(schema_p), move(table_p)), column_name(move(column_name_p)),
160279
- expression(move(new_default)) {
160304
+ : AlterTableInfo(AlterTableType::SET_DEFAULT, move(schema_p), move(table_p), if_exists_p),
160305
+ column_name(move(column_name_p)), expression(move(new_default)) {
160280
160306
  }
160281
160307
  SetDefaultInfo::~SetDefaultInfo() {
160282
160308
  }
160283
160309
 
160284
160310
  unique_ptr<AlterInfo> SetDefaultInfo::Copy() const {
160285
- return make_unique_base<AlterInfo, SetDefaultInfo>(schema, name, column_name,
160311
+ return make_unique_base<AlterInfo, SetDefaultInfo>(schema, name, if_exists, column_name,
160286
160312
  expression ? expression->Copy() : nullptr);
160287
160313
  }
160288
160314
 
@@ -160291,72 +160317,74 @@ void SetDefaultInfo::SerializeAlterTable(FieldWriter &writer) const {
160291
160317
  writer.WriteOptional(expression);
160292
160318
  }
160293
160319
 
160294
- unique_ptr<AlterInfo> SetDefaultInfo::Deserialize(FieldReader &reader, string schema, string table) {
160320
+ unique_ptr<AlterInfo> SetDefaultInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160295
160321
  auto column_name = reader.ReadRequired<string>();
160296
160322
  auto new_default = reader.ReadOptional<ParsedExpression>(nullptr);
160297
- return make_unique<SetDefaultInfo>(move(schema), move(table), move(column_name), move(new_default));
160323
+ return make_unique<SetDefaultInfo>(move(schema), move(table), if_exists, move(column_name), move(new_default));
160298
160324
  }
160299
160325
 
160300
160326
  //===--------------------------------------------------------------------===//
160301
160327
  // SetNotNullInfo
160302
160328
  //===--------------------------------------------------------------------===//
160303
- SetNotNullInfo::SetNotNullInfo(string schema_p, string table_p, string column_name_p)
160304
- : AlterTableInfo(AlterTableType::SET_NOT_NULL, move(schema_p), move(table_p)), column_name(move(column_name_p)) {
160329
+ SetNotNullInfo::SetNotNullInfo(string schema_p, string table_p, bool if_exists_p, string column_name_p)
160330
+ : AlterTableInfo(AlterTableType::SET_NOT_NULL, move(schema_p), move(table_p), if_exists_p),
160331
+ column_name(move(column_name_p)) {
160305
160332
  }
160306
160333
  SetNotNullInfo::~SetNotNullInfo() {
160307
160334
  }
160308
160335
 
160309
160336
  unique_ptr<AlterInfo> SetNotNullInfo::Copy() const {
160310
- return make_unique_base<AlterInfo, SetNotNullInfo>(schema, name, column_name);
160337
+ return make_unique_base<AlterInfo, SetNotNullInfo>(schema, name, if_exists, column_name);
160311
160338
  }
160312
160339
 
160313
160340
  void SetNotNullInfo::SerializeAlterTable(FieldWriter &writer) const {
160314
160341
  writer.WriteString(column_name);
160315
160342
  }
160316
160343
 
160317
- unique_ptr<AlterInfo> SetNotNullInfo::Deserialize(FieldReader &reader, string schema, string table) {
160344
+ unique_ptr<AlterInfo> SetNotNullInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160318
160345
  auto column_name = reader.ReadRequired<string>();
160319
- return make_unique<SetNotNullInfo>(move(schema), move(table), move(column_name));
160346
+ return make_unique<SetNotNullInfo>(move(schema), move(table), if_exists, move(column_name));
160320
160347
  }
160321
160348
 
160322
160349
  //===--------------------------------------------------------------------===//
160323
160350
  // DropNotNullInfo
160324
160351
  //===--------------------------------------------------------------------===//
160325
- DropNotNullInfo::DropNotNullInfo(string schema_p, string table_p, string column_name_p)
160326
- : AlterTableInfo(AlterTableType::DROP_NOT_NULL, move(schema_p), move(table_p)), column_name(move(column_name_p)) {
160352
+ DropNotNullInfo::DropNotNullInfo(string schema_p, string table_p, bool if_exists_p, string column_name_p)
160353
+ : AlterTableInfo(AlterTableType::DROP_NOT_NULL, move(schema_p), move(table_p), if_exists_p),
160354
+ column_name(move(column_name_p)) {
160327
160355
  }
160328
160356
  DropNotNullInfo::~DropNotNullInfo() {
160329
160357
  }
160330
160358
 
160331
160359
  unique_ptr<AlterInfo> DropNotNullInfo::Copy() const {
160332
- return make_unique_base<AlterInfo, DropNotNullInfo>(schema, name, column_name);
160360
+ return make_unique_base<AlterInfo, DropNotNullInfo>(schema, name, if_exists, column_name);
160333
160361
  }
160334
160362
 
160335
160363
  void DropNotNullInfo::SerializeAlterTable(FieldWriter &writer) const {
160336
160364
  writer.WriteString(column_name);
160337
160365
  }
160338
160366
 
160339
- unique_ptr<AlterInfo> DropNotNullInfo::Deserialize(FieldReader &reader, string schema, string table) {
160367
+ unique_ptr<AlterInfo> DropNotNullInfo::Deserialize(FieldReader &reader, string schema, string table, bool if_exists) {
160340
160368
  auto column_name = reader.ReadRequired<string>();
160341
- return make_unique<DropNotNullInfo>(move(schema), move(table), move(column_name));
160369
+ return make_unique<DropNotNullInfo>(move(schema), move(table), if_exists, move(column_name));
160342
160370
  }
160343
160371
 
160344
160372
  //===--------------------------------------------------------------------===//
160345
160373
  // AlterForeignKeyInfo
160346
160374
  //===--------------------------------------------------------------------===//
160347
- AlterForeignKeyInfo::AlterForeignKeyInfo(string schema_p, string table_p, string fk_table, vector<string> pk_columns,
160348
- vector<string> fk_columns, vector<idx_t> pk_keys, vector<idx_t> fk_keys,
160349
- AlterForeignKeyType type_p)
160350
- : AlterTableInfo(AlterTableType::FOREIGN_KEY_CONSTRAINT, move(schema_p), move(table_p)), fk_table(move(fk_table)),
160351
- pk_columns(move(pk_columns)), fk_columns(move(fk_columns)), pk_keys(move(pk_keys)), fk_keys(move(fk_keys)),
160352
- type(type_p) {
160375
+ AlterForeignKeyInfo::AlterForeignKeyInfo(string schema_p, string table_p, bool if_exists_p, string fk_table,
160376
+ vector<string> pk_columns, vector<string> fk_columns, vector<idx_t> pk_keys,
160377
+ vector<idx_t> fk_keys, AlterForeignKeyType type_p)
160378
+ : AlterTableInfo(AlterTableType::FOREIGN_KEY_CONSTRAINT, move(schema_p), move(table_p), if_exists_p),
160379
+ fk_table(move(fk_table)), pk_columns(move(pk_columns)), fk_columns(move(fk_columns)), pk_keys(move(pk_keys)),
160380
+ fk_keys(move(fk_keys)), type(type_p) {
160353
160381
  }
160354
160382
  AlterForeignKeyInfo::~AlterForeignKeyInfo() {
160355
160383
  }
160356
160384
 
160357
160385
  unique_ptr<AlterInfo> AlterForeignKeyInfo::Copy() const {
160358
- return make_unique_base<AlterInfo, AlterForeignKeyInfo>(schema, name, fk_table, pk_columns, fk_columns, pk_keys,
160359
- fk_keys, type);
160386
+ return make_unique_base<AlterInfo, AlterForeignKeyInfo>(schema, name, if_exists, fk_table, pk_columns, fk_columns,
160387
+ pk_keys, fk_keys, type);
160360
160388
  }
160361
160389
 
160362
160390
  void AlterForeignKeyInfo::SerializeAlterTable(FieldWriter &writer) const {
@@ -160368,22 +160396,23 @@ void AlterForeignKeyInfo::SerializeAlterTable(FieldWriter &writer) const {
160368
160396
  writer.WriteField<AlterForeignKeyType>(type);
160369
160397
  }
160370
160398
 
160371
- unique_ptr<AlterInfo> AlterForeignKeyInfo::Deserialize(FieldReader &reader, string schema, string table) {
160399
+ unique_ptr<AlterInfo> AlterForeignKeyInfo::Deserialize(FieldReader &reader, string schema, string table,
160400
+ bool if_exists) {
160372
160401
  auto fk_table = reader.ReadRequired<string>();
160373
160402
  auto pk_columns = reader.ReadRequiredList<string>();
160374
160403
  auto fk_columns = reader.ReadRequiredList<string>();
160375
160404
  auto pk_keys = reader.ReadRequiredList<idx_t>();
160376
160405
  auto fk_keys = reader.ReadRequiredList<idx_t>();
160377
160406
  auto type = reader.ReadRequired<AlterForeignKeyType>();
160378
- return make_unique<AlterForeignKeyInfo>(move(schema), move(table), move(fk_table), move(pk_columns),
160407
+ return make_unique<AlterForeignKeyInfo>(move(schema), move(table), if_exists, move(fk_table), move(pk_columns),
160379
160408
  move(fk_columns), move(pk_keys), move(fk_keys), type);
160380
160409
  }
160381
160410
 
160382
160411
  //===--------------------------------------------------------------------===//
160383
160412
  // Alter View
160384
160413
  //===--------------------------------------------------------------------===//
160385
- AlterViewInfo::AlterViewInfo(AlterViewType type, string schema_p, string view_p)
160386
- : AlterInfo(AlterType::ALTER_VIEW, move(schema_p), move(view_p)), alter_view_type(type) {
160414
+ AlterViewInfo::AlterViewInfo(AlterViewType type, string schema_p, string view_p, bool if_exists_p)
160415
+ : AlterInfo(AlterType::ALTER_VIEW, move(schema_p), move(view_p), if_exists_p), alter_view_type(type) {
160387
160416
  }
160388
160417
  AlterViewInfo::~AlterViewInfo() {
160389
160418
  }
@@ -160396,6 +160425,7 @@ void AlterViewInfo::Serialize(FieldWriter &writer) const {
160396
160425
  writer.WriteField<AlterViewType>(alter_view_type);
160397
160426
  writer.WriteString(schema);
160398
160427
  writer.WriteString(name);
160428
+ writer.WriteField<bool>(if_exists);
160399
160429
  SerializeAlterView(writer);
160400
160430
  }
160401
160431
 
@@ -160403,10 +160433,11 @@ unique_ptr<AlterInfo> AlterViewInfo::Deserialize(FieldReader &reader) {
160403
160433
  auto type = reader.ReadRequired<AlterViewType>();
160404
160434
  auto schema = reader.ReadRequired<string>();
160405
160435
  auto view = reader.ReadRequired<string>();
160436
+ auto if_exists = reader.ReadRequired<bool>();
160406
160437
  unique_ptr<AlterViewInfo> info;
160407
160438
  switch (type) {
160408
160439
  case AlterViewType::RENAME_VIEW:
160409
- return RenameViewInfo::Deserialize(reader, schema, view);
160440
+ return RenameViewInfo::Deserialize(reader, schema, view, if_exists);
160410
160441
  default:
160411
160442
  throw SerializationException("Unknown alter view type for deserialization!");
160412
160443
  }
@@ -160415,23 +160446,24 @@ unique_ptr<AlterInfo> AlterViewInfo::Deserialize(FieldReader &reader) {
160415
160446
  //===--------------------------------------------------------------------===//
160416
160447
  // RenameViewInfo
160417
160448
  //===--------------------------------------------------------------------===//
160418
- RenameViewInfo::RenameViewInfo(string schema_p, string view_p, string new_name_p)
160419
- : AlterViewInfo(AlterViewType::RENAME_VIEW, move(schema_p), move(view_p)), new_view_name(move(new_name_p)) {
160449
+ RenameViewInfo::RenameViewInfo(string schema_p, string view_p, bool if_exists_p, string new_name_p)
160450
+ : AlterViewInfo(AlterViewType::RENAME_VIEW, move(schema_p), move(view_p), if_exists_p),
160451
+ new_view_name(move(new_name_p)) {
160420
160452
  }
160421
160453
  RenameViewInfo::~RenameViewInfo() {
160422
160454
  }
160423
160455
 
160424
160456
  unique_ptr<AlterInfo> RenameViewInfo::Copy() const {
160425
- return make_unique_base<AlterInfo, RenameViewInfo>(schema, name, new_view_name);
160457
+ return make_unique_base<AlterInfo, RenameViewInfo>(schema, name, if_exists, new_view_name);
160426
160458
  }
160427
160459
 
160428
160460
  void RenameViewInfo::SerializeAlterView(FieldWriter &writer) const {
160429
160461
  writer.WriteString(new_view_name);
160430
160462
  }
160431
160463
 
160432
- unique_ptr<AlterInfo> RenameViewInfo::Deserialize(FieldReader &reader, string schema, string view) {
160464
+ unique_ptr<AlterInfo> RenameViewInfo::Deserialize(FieldReader &reader, string schema, string view, bool if_exists) {
160433
160465
  auto new_name = reader.ReadRequired<string>();
160434
- return make_unique<RenameViewInfo>(move(schema), move(view), new_name);
160466
+ return make_unique<RenameViewInfo>(move(schema), move(view), if_exists, new_name);
160435
160467
  }
160436
160468
  } // namespace duckdb
160437
160469
 
@@ -171802,10 +171834,6 @@ LogicalType Transformer::TransformTypeName(duckdb_libpgquery::PGTypeName *type_n
171802
171834
  }
171803
171835
 
171804
171836
  } // namespace duckdb
171805
-
171806
-
171807
-
171808
-
171809
171837
  //===----------------------------------------------------------------------===//
171810
171838
  // DuckDB
171811
171839
  //
@@ -171831,6 +171859,10 @@ struct EnumClassHash {
171831
171859
 
171832
171860
 
171833
171861
 
171862
+
171863
+
171864
+
171865
+
171834
171866
  namespace duckdb {
171835
171867
 
171836
171868
  unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery::PGNode *node) {
@@ -171886,7 +171918,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
171886
171918
  throw InternalException("Wrong argument for %s. Expected either <schema>.<name> or <name>", opt_name);
171887
171919
  }
171888
171920
  auto info = make_unique<ChangeOwnershipInfo>(CatalogType::SEQUENCE_ENTRY, sequence_schema, sequence_name,
171889
- owner_schema, owner_name);
171921
+ owner_schema, owner_name, stmt->missing_ok);
171890
171922
  result->info = move(info);
171891
171923
  } else {
171892
171924
  throw NotImplementedException("ALTER SEQUENCE option not supported yet!");
@@ -171941,7 +171973,8 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
171941
171973
  throw ParserException("Adding columns with constraints not yet supported");
171942
171974
  }
171943
171975
  }
171944
- result->info = make_unique<AddColumnInfo>(qname.schema, qname.name, move(centry));
171976
+ result->info = make_unique<AddColumnInfo>(qname.schema, qname.name, stmt->missing_ok, move(centry),
171977
+ command->missing_ok);
171945
171978
  break;
171946
171979
  }
171947
171980
  case duckdb_libpgquery::PG_AT_DropColumn: {
@@ -171950,8 +171983,8 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
171950
171983
  if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
171951
171984
  throw ParserException("Dropping columns is only supported for tables");
171952
171985
  }
171953
- result->info =
171954
- make_unique<RemoveColumnInfo>(qname.schema, qname.name, command->name, command->missing_ok, cascade);
171986
+ result->info = make_unique<RemoveColumnInfo>(qname.schema, qname.name, stmt->missing_ok, command->name,
171987
+ command->missing_ok, cascade);
171955
171988
  break;
171956
171989
  }
171957
171990
  case duckdb_libpgquery::PG_AT_ColumnDefault: {
@@ -171960,7 +171993,8 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
171960
171993
  if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
171961
171994
  throw ParserException("Alter column's default is only supported for tables");
171962
171995
  }
171963
- result->info = make_unique<SetDefaultInfo>(qname.schema, qname.name, command->name, move(expr));
171996
+ result->info =
171997
+ make_unique<SetDefaultInfo>(qname.schema, qname.name, stmt->missing_ok, command->name, move(expr));
171964
171998
  break;
171965
171999
  }
171966
172000
  case duckdb_libpgquery::PG_AT_AlterColumnType: {
@@ -171977,16 +172011,16 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
171977
172011
  auto colref = make_unique<ColumnRefExpression>(command->name);
171978
172012
  expr = make_unique<CastExpression>(column_definition.Type(), move(colref));
171979
172013
  }
171980
- result->info = make_unique<ChangeColumnTypeInfo>(qname.schema, qname.name, command->name,
172014
+ result->info = make_unique<ChangeColumnTypeInfo>(qname.schema, qname.name, stmt->missing_ok, command->name,
171981
172015
  column_definition.Type(), move(expr));
171982
172016
  break;
171983
172017
  }
171984
172018
  case duckdb_libpgquery::PG_AT_SetNotNull: {
171985
- result->info = make_unique<SetNotNullInfo>(qname.schema, qname.name, command->name);
172019
+ result->info = make_unique<SetNotNullInfo>(qname.schema, qname.name, stmt->missing_ok, command->name);
171986
172020
  break;
171987
172021
  }
171988
172022
  case duckdb_libpgquery::PG_AT_DropNotNull: {
171989
- result->info = make_unique<DropNotNullInfo>(qname.schema, qname.name, command->name);
172023
+ result->info = make_unique<DropNotNullInfo>(qname.schema, qname.name, stmt->missing_ok, command->name);
171990
172024
  break;
171991
172025
  }
171992
172026
  case duckdb_libpgquery::PG_AT_DropConstraint:
@@ -171994,7 +172028,6 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
171994
172028
  throw NotImplementedException("ALTER TABLE option not supported yet!");
171995
172029
  }
171996
172030
  }
171997
- result->info->if_exists = stmt->missing_ok;
171998
172031
 
171999
172032
  return result;
172000
172033
  }
@@ -173166,7 +173199,7 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
173166
173199
  // get the old name and the new name
173167
173200
  string old_name = stmt->subname;
173168
173201
  string new_name = stmt->newname;
173169
- info = make_unique<RenameColumnInfo>(schema, table, old_name, new_name);
173202
+ info = make_unique<RenameColumnInfo>(schema, table, stmt->missing_ok, old_name, new_name);
173170
173203
  break;
173171
173204
  }
173172
173205
  case duckdb_libpgquery::PG_OBJECT_TABLE: {
@@ -173183,7 +173216,7 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
173183
173216
  schema = stmt->relation->schemaname;
173184
173217
  }
173185
173218
  string new_name = stmt->newname;
173186
- info = make_unique<RenameTableInfo>(schema, table, new_name);
173219
+ info = make_unique<RenameTableInfo>(schema, table, stmt->missing_ok, new_name);
173187
173220
  break;
173188
173221
  }
173189
173222
 
@@ -173201,7 +173234,7 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
173201
173234
  schema = stmt->relation->schemaname;
173202
173235
  }
173203
173236
  string new_name = stmt->newname;
173204
- info = make_unique<RenameViewInfo>(schema, view, new_name);
173237
+ info = make_unique<RenameViewInfo>(schema, view, stmt->missing_ok, new_name);
173205
173238
  break;
173206
173239
  }
173207
173240
  case duckdb_libpgquery::PG_OBJECT_DATABASE:
@@ -188565,6 +188598,10 @@ string PragmaHandler::HandlePragma(SQLStatement *statement) { // PragmaInfo &inf
188565
188598
 
188566
188599
 
188567
188600
 
188601
+
188602
+
188603
+
188604
+
188568
188605
  //===----------------------------------------------------------------------===//
188569
188606
  // DuckDB
188570
188607
  //
@@ -188658,9 +188695,6 @@ public:
188658
188695
  } // namespace duckdb
188659
188696
 
188660
188697
 
188661
-
188662
-
188663
-
188664
188698
  namespace duckdb {
188665
188699
 
188666
188700
  FlattenDependentJoins::FlattenDependentJoins(Binder &binder, const vector<CorrelatedColumnInfo> &correlated,
@@ -189045,7 +189079,10 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
189045
189079
  unique_ptr<Expression> condition;
189046
189080
  auto row_num_ref =
189047
189081
  make_unique<BoundColumnRefExpression>(rownum_alias, LogicalType::BIGINT, ColumnBinding(window_index, 0));
189048
- auto upper_bound = make_unique<BoundConstantExpression>(Value::BIGINT(limit.offset_val + limit.limit_val));
189082
+
189083
+ int64_t upper_bound_limit = NumericLimits<int64_t>::Maximum();
189084
+ TryAddOperator::Operation(limit.offset_val, limit.limit_val, upper_bound_limit);
189085
+ auto upper_bound = make_unique<BoundConstantExpression>(Value::BIGINT(upper_bound_limit));
189049
189086
  condition = make_unique<BoundComparisonExpression>(ExpressionType::COMPARE_LESSTHANOREQUALTO,
189050
189087
  row_num_ref->Copy(), move(upper_bound));
189051
189088
  // we only need to add "row_number >= offset + 1" if offset is bigger than 0
@@ -208171,7 +208208,7 @@ void StatementVerifier::CheckExpressions(const StatementVerifier &other) const {
208171
208208
  for (idx_t i = 0; i < expr_count; i++) {
208172
208209
  D_ASSERT(!select_list[i]->Equals(nullptr));
208173
208210
  // Run the ToString, to verify that it doesn't crash
208174
- auto str = select_list[i]->ToString();
208211
+ select_list[i]->ToString();
208175
208212
 
208176
208213
  if (select_list[i]->HasSubquery()) {
208177
208214
  continue;
@@ -208183,11 +208220,6 @@ void StatementVerifier::CheckExpressions(const StatementVerifier &other) const {
208183
208220
  D_ASSERT(select_list[i]->Hash() == other.select_list[i]->Hash());
208184
208221
 
208185
208222
  other.select_list[i]->Verify();
208186
-
208187
- // ToString round trip
208188
- auto parsed_list = Parser::ParseExpressionList(str);
208189
- D_ASSERT(parsed_list.size() == 1);
208190
- D_ASSERT(parsed_list[0]->Equals(select_list[i].get()));
208191
208223
  }
208192
208224
  }
208193
208225
  #endif