duckdb 0.7.2-dev2507.0 → 0.7.2-dev2675.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/binding.gyp +7 -7
- package/package.json +2 -2
- package/src/connection.cpp +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
- package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
- package/src/duckdb/extension/json/json-extension.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +3 -0
- package/src/duckdb/src/catalog/catalog.cpp +166 -127
- package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
- package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
- package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
- package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
- package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
- package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
- package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
- package/src/duckdb/src/common/types.cpp +15 -27
- package/src/duckdb/src/execution/index/art/art.cpp +286 -269
- package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
- package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/node.cpp +444 -379
- package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
- package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
- package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
- package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
- package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +17 -17
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/built_in_functions.cpp +10 -10
- package/src/duckdb/src/function/function_binder.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
- package/src/duckdb/src/function/table/arrow.cpp +5 -5
- package/src/duckdb/src/function/table/read_csv.cpp +5 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
- package/src/duckdb/src/function/table/table_scan.cpp +39 -37
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/udf_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/queue.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +0 -5
- package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
- package/src/duckdb/src/include/duckdb.h +26 -0
- package/src/duckdb/src/main/attached_database.cpp +12 -6
- package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
- package/src/duckdb/src/main/client_context.cpp +12 -11
- package/src/duckdb/src/main/database_manager.cpp +13 -12
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
- package/src/duckdb/src/parser/statement/insert_statement.cpp +15 -6
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +5 -7
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
- package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +56 -42
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +16 -11
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
- package/src/duckdb/src/planner/binder.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
- package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
- package/src/duckdb/src/storage/checkpoint_manager.cpp +57 -55
- package/src/duckdb/src/storage/data_table.cpp +9 -9
- package/src/duckdb/src/storage/index.cpp +18 -6
- package/src/duckdb/src/storage/local_storage.cpp +8 -2
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
- package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
- package/src/duckdb/src/storage/wal_replay.cpp +29 -31
- package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
- package/src/duckdb/src/transaction/cleanup_state.cpp +7 -1
- package/src/duckdb/src/transaction/commit_state.cpp +3 -4
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -12,8 +12,8 @@ CreateTableInfo::CreateTableInfo(string catalog_p, string schema_p, string name_
|
|
12
12
|
: CreateInfo(CatalogType::TABLE_ENTRY, std::move(schema_p), std::move(catalog_p)), table(std::move(name_p)) {
|
13
13
|
}
|
14
14
|
|
15
|
-
CreateTableInfo::CreateTableInfo(SchemaCatalogEntry
|
16
|
-
: CreateTableInfo(schema
|
15
|
+
CreateTableInfo::CreateTableInfo(SchemaCatalogEntry &schema, string name_p)
|
16
|
+
: CreateTableInfo(schema.catalog.GetName(), schema.name, std::move(name_p)) {
|
17
17
|
}
|
18
18
|
|
19
19
|
void CreateTableInfo::SerializeInternal(Serializer &serializer) const {
|
@@ -15,8 +15,8 @@ CreateViewInfo::CreateViewInfo(string catalog_p, string schema_p, string view_na
|
|
15
15
|
view_name(std::move(view_name_p)) {
|
16
16
|
}
|
17
17
|
|
18
|
-
CreateViewInfo::CreateViewInfo(SchemaCatalogEntry
|
19
|
-
: CreateViewInfo(schema
|
18
|
+
CreateViewInfo::CreateViewInfo(SchemaCatalogEntry &schema, string view_name)
|
19
|
+
: CreateViewInfo(schema.catalog.GetName(), schema.name, std::move(view_name)) {
|
20
20
|
}
|
21
21
|
|
22
22
|
unique_ptr<CreateInfo> CreateViewInfo::Copy() const {
|
@@ -27,9 +27,10 @@ InsertStatement::InsertStatement()
|
|
27
27
|
}
|
28
28
|
|
29
29
|
InsertStatement::InsertStatement(const InsertStatement &other)
|
30
|
-
: SQLStatement(other),
|
31
|
-
|
32
|
-
columns(other.columns), table(other.table), schema(other.schema), catalog(other.catalog)
|
30
|
+
: SQLStatement(other), select_statement(unique_ptr_cast<SQLStatement, SelectStatement>(
|
31
|
+
other.select_statement ? other.select_statement->Copy() : nullptr)),
|
32
|
+
columns(other.columns), table(other.table), schema(other.schema), catalog(other.catalog),
|
33
|
+
default_values(other.default_values) {
|
33
34
|
cte_map = other.cte_map.Copy();
|
34
35
|
for (auto &expr : other.returning_list) {
|
35
36
|
returning_list.emplace_back(expr->Copy());
|
@@ -93,10 +94,15 @@ string InsertStatement::ToString() const {
|
|
93
94
|
result += " ";
|
94
95
|
auto values_list = GetValuesList();
|
95
96
|
if (values_list) {
|
97
|
+
D_ASSERT(!default_values);
|
96
98
|
values_list->alias = string();
|
97
99
|
result += values_list->ToString();
|
98
|
-
} else {
|
100
|
+
} else if (select_statement) {
|
101
|
+
D_ASSERT(!default_values);
|
99
102
|
result += select_statement->ToString();
|
103
|
+
} else {
|
104
|
+
D_ASSERT(default_values);
|
105
|
+
result += "DEFAULT VALUES";
|
100
106
|
}
|
101
107
|
if (!or_replace_shorthand_set && on_conflict_info) {
|
102
108
|
auto &conflict_info = *on_conflict_info;
|
@@ -155,7 +161,10 @@ unique_ptr<SQLStatement> InsertStatement::Copy() const {
|
|
155
161
|
return unique_ptr<InsertStatement>(new InsertStatement(*this));
|
156
162
|
}
|
157
163
|
|
158
|
-
ExpressionListRef
|
164
|
+
optional_ptr<ExpressionListRef> InsertStatement::GetValuesList() const {
|
165
|
+
if (!select_statement) {
|
166
|
+
return nullptr;
|
167
|
+
}
|
159
168
|
if (select_statement->node->type != QueryNodeType::SELECT_NODE) {
|
160
169
|
return nullptr;
|
161
170
|
}
|
@@ -178,7 +187,7 @@ ExpressionListRef *InsertStatement::GetValuesList() const {
|
|
178
187
|
if (!node.from_table || node.from_table->type != TableReferenceType::EXPRESSION_LIST) {
|
179
188
|
return nullptr;
|
180
189
|
}
|
181
|
-
return
|
190
|
+
return &node.from_table->Cast<ExpressionListRef>();
|
182
191
|
}
|
183
192
|
|
184
193
|
} // namespace duckdb
|
@@ -108,7 +108,7 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
108
108
|
pk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
109
109
|
}
|
110
110
|
}
|
111
|
-
if (pk_columns.size() != fk_columns.size()) {
|
111
|
+
if (!pk_columns.empty() && pk_columns.size() != fk_columns.size()) {
|
112
112
|
throw ParserException("The number of referencing and referenced columns for foreign keys must be the same");
|
113
113
|
}
|
114
114
|
return make_uniq<ForeignKeyConstraint>(pk_columns, fk_columns, std::move(fk_info));
|
@@ -13,15 +13,24 @@
|
|
13
13
|
|
14
14
|
namespace duckdb {
|
15
15
|
|
16
|
-
void Transformer::TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr
|
16
|
+
void Transformer::TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr,
|
17
|
+
const char *window_name) {
|
17
18
|
D_ASSERT(window_spec);
|
18
19
|
D_ASSERT(expr);
|
19
20
|
|
20
21
|
// next: partitioning/ordering expressions
|
21
22
|
if (window_spec->partitionClause) {
|
23
|
+
if (window_name && !expr->partitions.empty()) {
|
24
|
+
throw ParserException("Cannot override PARTITION BY clause of window \"%s\"", window_name);
|
25
|
+
}
|
22
26
|
TransformExpressionList(*window_spec->partitionClause, expr->partitions);
|
23
27
|
}
|
24
|
-
|
28
|
+
if (window_spec->orderClause) {
|
29
|
+
if (window_name && !expr->orders.empty()) {
|
30
|
+
throw ParserException("Cannot override ORDER BY clause of window \"%s\"", window_name);
|
31
|
+
}
|
32
|
+
TransformOrderBy(window_spec->orderClause, expr->orders);
|
33
|
+
}
|
25
34
|
}
|
26
35
|
|
27
36
|
void Transformer::TransformWindowFrame(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr) {
|
@@ -198,6 +207,7 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
198
207
|
D_ASSERT(window_spec);
|
199
208
|
}
|
200
209
|
auto window_ref = window_spec;
|
210
|
+
auto window_name = window_ref->refname;
|
201
211
|
if (window_ref->refname) {
|
202
212
|
auto it = window_clauses.find(StringUtil::Lower(string(window_spec->refname)));
|
203
213
|
if (it == window_clauses.end()) {
|
@@ -208,6 +218,9 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
208
218
|
}
|
209
219
|
in_window_definition = true;
|
210
220
|
TransformWindowDef(window_ref, expr.get());
|
221
|
+
if (window_ref != window_spec) {
|
222
|
+
TransformWindowDef(window_spec, expr.get(), window_name);
|
223
|
+
}
|
211
224
|
TransformWindowFrame(window_spec, expr.get());
|
212
225
|
in_window_definition = false;
|
213
226
|
expr->query_location = root->location;
|
@@ -299,9 +312,9 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
299
312
|
std::move(filter_expr), std::move(order_bys),
|
300
313
|
root->agg_distinct, false, root->export_state);
|
301
314
|
lowercase_name = "list_sort";
|
302
|
-
order_bys.reset();
|
303
|
-
filter_expr.reset();
|
304
|
-
children.clear();
|
315
|
+
order_bys.reset(); // NOLINT
|
316
|
+
filter_expr.reset(); // NOLINT
|
317
|
+
children.clear(); // NOLINT
|
305
318
|
children.emplace_back(std::move(unordered));
|
306
319
|
children.emplace_back(std::move(sense));
|
307
320
|
children.emplace_back(std::move(nulls));
|
@@ -61,13 +61,14 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
|
|
61
61
|
throw InternalException("Wrong argument for %s. Expected either <schema>.<name> or <name>", opt_name);
|
62
62
|
}
|
63
63
|
auto info = make_uniq<ChangeOwnershipInfo>(CatalogType::SEQUENCE_ENTRY, sequence_catalog, sequence_schema,
|
64
|
-
sequence_name, owner_schema, owner_name,
|
64
|
+
sequence_name, owner_schema, owner_name,
|
65
|
+
TransformOnEntryNotFound(stmt->missing_ok));
|
65
66
|
result->info = std::move(info);
|
66
67
|
} else {
|
67
68
|
throw NotImplementedException("ALTER SEQUENCE option not supported yet!");
|
68
69
|
}
|
69
70
|
}
|
70
|
-
result->info->
|
71
|
+
result->info->if_not_found = TransformOnEntryNotFound(stmt->missing_ok);
|
71
72
|
return result;
|
72
73
|
}
|
73
74
|
} // namespace duckdb
|
@@ -6,6 +6,10 @@
|
|
6
6
|
|
7
7
|
namespace duckdb {
|
8
8
|
|
9
|
+
OnEntryNotFound Transformer::TransformOnEntryNotFound(bool missing_ok) {
|
10
|
+
return missing_ok ? OnEntryNotFound::RETURN_NULL : OnEntryNotFound::THROW_EXCEPTION;
|
11
|
+
}
|
12
|
+
|
9
13
|
unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode *node) {
|
10
14
|
auto stmt = reinterpret_cast<duckdb_libpgquery::PGAlterTableStmt *>(node);
|
11
15
|
D_ASSERT(stmt);
|
@@ -21,7 +25,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
21
25
|
// first we check the type of ALTER
|
22
26
|
for (auto c = stmt->cmds->head; c != nullptr; c = c->next) {
|
23
27
|
auto command = reinterpret_cast<duckdb_libpgquery::PGAlterTableCmd *>(lfirst(c));
|
24
|
-
AlterEntryData data(qname.catalog, qname.schema, qname.name, stmt->missing_ok);
|
28
|
+
AlterEntryData data(qname.catalog, qname.schema, qname.name, TransformOnEntryNotFound(stmt->missing_ok));
|
25
29
|
// TODO: Include more options for command->subtype
|
26
30
|
switch (command->subtype) {
|
27
31
|
case duckdb_libpgquery::PG_AT_AddColumn: {
|
@@ -10,7 +10,7 @@ unique_ptr<DetachStatement> Transformer::TransformDetach(duckdb_libpgquery::PGNo
|
|
10
10
|
auto result = make_uniq<DetachStatement>();
|
11
11
|
auto info = make_uniq<DetachInfo>();
|
12
12
|
info->name = stmt->db_name;
|
13
|
-
info->
|
13
|
+
info->if_not_found = TransformOnEntryNotFound(stmt->missing_ok);
|
14
14
|
|
15
15
|
result->info = std::move(info);
|
16
16
|
return result;
|
@@ -80,7 +80,7 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGNode *n
|
|
80
80
|
}
|
81
81
|
}
|
82
82
|
info.cascade = stmt->behavior == duckdb_libpgquery::PGDropBehavior::PG_DROP_CASCADE;
|
83
|
-
info.
|
83
|
+
info.if_not_found = TransformOnEntryNotFound(stmt->missing_ok);
|
84
84
|
return std::move(result);
|
85
85
|
}
|
86
86
|
|
@@ -26,12 +26,6 @@ unique_ptr<InsertStatement> Transformer::TransformInsert(duckdb_libpgquery::PGNo
|
|
26
26
|
auto stmt = reinterpret_cast<duckdb_libpgquery::PGInsertStmt *>(node);
|
27
27
|
D_ASSERT(stmt);
|
28
28
|
|
29
|
-
if (!stmt->selectStmt) {
|
30
|
-
// TODO: This should be easy to add, we already support DEFAULT in the values list,
|
31
|
-
// this could probably just be transformed into VALUES (DEFAULT, DEFAULT, DEFAULT, ..) in the Binder
|
32
|
-
throw ParserException("DEFAULT VALUES clause is not supported!");
|
33
|
-
}
|
34
|
-
|
35
29
|
auto result = make_uniq<InsertStatement>();
|
36
30
|
if (stmt->withClause) {
|
37
31
|
TransformCTE(reinterpret_cast<duckdb_libpgquery::PGWithClause *>(stmt->withClause), result->cte_map);
|
@@ -49,7 +43,11 @@ unique_ptr<InsertStatement> Transformer::TransformInsert(duckdb_libpgquery::PGNo
|
|
49
43
|
if (stmt->returningList) {
|
50
44
|
Transformer::TransformExpressionList(*(stmt->returningList), result->returning_list);
|
51
45
|
}
|
52
|
-
|
46
|
+
if (stmt->selectStmt) {
|
47
|
+
result->select_statement = TransformSelect(stmt->selectStmt, false);
|
48
|
+
} else {
|
49
|
+
result->default_values = true;
|
50
|
+
}
|
53
51
|
|
54
52
|
auto qname = TransformQualifiedName(stmt->relation);
|
55
53
|
result->table = qname.name;
|
@@ -13,7 +13,7 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
|
|
13
13
|
unique_ptr<AlterInfo> info;
|
14
14
|
|
15
15
|
AlterEntryData data;
|
16
|
-
data.
|
16
|
+
data.if_not_found = TransformOnEntryNotFound(stmt->missing_ok);
|
17
17
|
data.catalog = stmt->relation->catalogname ? stmt->relation->catalogname : INVALID_CATALOG;
|
18
18
|
data.schema = stmt->relation->schemaname ? stmt->relation->schemaname : INVALID_SCHEMA;
|
19
19
|
if (stmt->relation->relname) {
|
@@ -60,13 +60,13 @@ static Value NegatePercentileValue(const Value &v, const bool desc) {
|
|
60
60
|
static void NegatePercentileFractions(ClientContext &context, unique_ptr<ParsedExpression> &fractions, bool desc) {
|
61
61
|
D_ASSERT(fractions.get());
|
62
62
|
D_ASSERT(fractions->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
63
|
-
auto &bound =
|
63
|
+
auto &bound = BoundExpression::GetExpression(*fractions);
|
64
64
|
|
65
|
-
if (!bound
|
65
|
+
if (!bound->IsFoldable()) {
|
66
66
|
return;
|
67
67
|
}
|
68
68
|
|
69
|
-
Value value = ExpressionExecutor::EvaluateScalar(context, *bound
|
69
|
+
Value value = ExpressionExecutor::EvaluateScalar(context, *bound);
|
70
70
|
if (value.type().id() == LogicalTypeId::LIST) {
|
71
71
|
vector<Value> values;
|
72
72
|
for (const auto &element_val : ListValue::GetChildren(value)) {
|
@@ -75,14 +75,13 @@ static void NegatePercentileFractions(ClientContext &context, unique_ptr<ParsedE
|
|
75
75
|
if (values.empty()) {
|
76
76
|
throw BinderException("Empty list in percentile not allowed");
|
77
77
|
}
|
78
|
-
bound
|
78
|
+
bound = make_uniq<BoundConstantExpression>(Value::LIST(values));
|
79
79
|
} else {
|
80
|
-
bound
|
80
|
+
bound = make_uniq<BoundConstantExpression>(NegatePercentileValue(value, desc));
|
81
81
|
}
|
82
82
|
}
|
83
83
|
|
84
|
-
BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr,
|
85
|
-
idx_t depth) {
|
84
|
+
BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFunctionCatalogEntry &func, idx_t depth) {
|
86
85
|
// first bind the child of the aggregate expression (if any)
|
87
86
|
this->bound_aggregate = true;
|
88
87
|
unique_ptr<Expression> bound_filter;
|
@@ -138,8 +137,8 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
138
137
|
if (!success) {
|
139
138
|
throw BinderException(error);
|
140
139
|
}
|
141
|
-
auto &bound_expr = aggr.children[i]
|
142
|
-
ExtractCorrelatedExpressions(binder, *bound_expr
|
140
|
+
auto &bound_expr = BoundExpression::GetExpression(*aggr.children[i]);
|
141
|
+
ExtractCorrelatedExpressions(binder, *bound_expr);
|
143
142
|
}
|
144
143
|
if (aggr.filter) {
|
145
144
|
bool success = aggregate_binder.BindCorrelatedColumns(aggr.filter);
|
@@ -147,8 +146,8 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
147
146
|
if (!success) {
|
148
147
|
throw BinderException(error);
|
149
148
|
}
|
150
|
-
auto &bound_expr = aggr.filter
|
151
|
-
ExtractCorrelatedExpressions(binder, *bound_expr
|
149
|
+
auto &bound_expr = BoundExpression::GetExpression(*aggr.filter);
|
150
|
+
ExtractCorrelatedExpressions(binder, *bound_expr);
|
152
151
|
}
|
153
152
|
if (aggr.order_bys && !aggr.order_bys->orders.empty()) {
|
154
153
|
for (auto &order : aggr.order_bys->orders) {
|
@@ -156,8 +155,8 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
156
155
|
if (!success) {
|
157
156
|
throw BinderException(error);
|
158
157
|
}
|
159
|
-
auto &bound_expr = order.expression
|
160
|
-
ExtractCorrelatedExpressions(binder, *bound_expr
|
158
|
+
auto &bound_expr = BoundExpression::GetExpression(*order.expression);
|
159
|
+
ExtractCorrelatedExpressions(binder, *bound_expr);
|
161
160
|
}
|
162
161
|
}
|
163
162
|
} else {
|
@@ -172,8 +171,8 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
172
171
|
}
|
173
172
|
|
174
173
|
if (aggr.filter) {
|
175
|
-
auto &child = (
|
176
|
-
bound_filter = BoundCastExpression::AddCastToType(context, std::move(child
|
174
|
+
auto &child = BoundExpression::GetExpression(*aggr.filter);
|
175
|
+
bound_filter = BoundCastExpression::AddCastToType(context, std::move(child), LogicalType::BOOLEAN);
|
177
176
|
}
|
178
177
|
|
179
178
|
// all children bound successfully
|
@@ -184,29 +183,29 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
184
183
|
|
185
184
|
if (ordered_set_agg) {
|
186
185
|
for (auto &order : aggr.order_bys->orders) {
|
187
|
-
auto &child = (
|
188
|
-
types.push_back(child
|
189
|
-
arguments.push_back(child
|
190
|
-
children.push_back(std::move(child
|
186
|
+
auto &child = BoundExpression::GetExpression(*order.expression);
|
187
|
+
types.push_back(child->return_type);
|
188
|
+
arguments.push_back(child->return_type);
|
189
|
+
children.push_back(std::move(child));
|
191
190
|
}
|
192
191
|
aggr.order_bys->orders.clear();
|
193
192
|
}
|
194
193
|
|
195
194
|
for (idx_t i = 0; i < aggr.children.size(); i++) {
|
196
|
-
auto &child = (
|
197
|
-
types.push_back(child
|
198
|
-
arguments.push_back(child
|
199
|
-
children.push_back(std::move(child
|
195
|
+
auto &child = BoundExpression::GetExpression(*aggr.children[i]);
|
196
|
+
types.push_back(child->return_type);
|
197
|
+
arguments.push_back(child->return_type);
|
198
|
+
children.push_back(std::move(child));
|
200
199
|
}
|
201
200
|
|
202
201
|
// bind the aggregate
|
203
202
|
FunctionBinder function_binder(context);
|
204
|
-
idx_t best_function = function_binder.BindFunction(func
|
203
|
+
idx_t best_function = function_binder.BindFunction(func.name, func.functions, types, error);
|
205
204
|
if (best_function == DConstants::INVALID_INDEX) {
|
206
205
|
throw BinderException(binder.FormatError(aggr, error));
|
207
206
|
}
|
208
207
|
// found a matching function!
|
209
|
-
auto bound_function = func
|
208
|
+
auto bound_function = func.functions.GetFunctionByOffset(best_function);
|
210
209
|
|
211
210
|
// Bind any sort columns, unless the aggregate is order-insensitive
|
212
211
|
unique_ptr<BoundOrderModifier> order_bys;
|
@@ -214,10 +213,10 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_pt
|
|
214
213
|
order_bys = make_uniq<BoundOrderModifier>();
|
215
214
|
auto &config = DBConfig::GetConfig(context);
|
216
215
|
for (auto &order : aggr.order_bys->orders) {
|
217
|
-
auto &order_expr = (
|
216
|
+
auto &order_expr = BoundExpression::GetExpression(*order.expression);
|
218
217
|
const auto sense = config.ResolveOrder(order.type);
|
219
218
|
const auto null_order = config.ResolveNullOrder(sense, order.null_order);
|
220
|
-
order_bys->orders.emplace_back(sense, null_order, std::move(order_expr
|
219
|
+
order_bys->orders.emplace_back(sense, null_order, std::move(order_expr));
|
221
220
|
}
|
222
221
|
}
|
223
222
|
|
@@ -18,44 +18,44 @@ BindResult ExpressionBinder::BindExpression(BetweenExpression &expr, idx_t depth
|
|
18
18
|
return BindResult(error);
|
19
19
|
}
|
20
20
|
// the children have been successfully resolved
|
21
|
-
auto &input = (
|
22
|
-
auto &lower = (
|
23
|
-
auto &upper = (
|
21
|
+
auto &input = BoundExpression::GetExpression(*expr.input);
|
22
|
+
auto &lower = BoundExpression::GetExpression(*expr.lower);
|
23
|
+
auto &upper = BoundExpression::GetExpression(*expr.upper);
|
24
24
|
|
25
|
-
auto input_sql_type = input
|
26
|
-
auto lower_sql_type = lower
|
27
|
-
auto upper_sql_type = upper
|
25
|
+
auto input_sql_type = input->return_type;
|
26
|
+
auto lower_sql_type = lower->return_type;
|
27
|
+
auto upper_sql_type = upper->return_type;
|
28
28
|
|
29
29
|
// cast the input types to the same type
|
30
30
|
// now obtain the result type of the input types
|
31
31
|
auto input_type = BoundComparisonExpression::BindComparison(input_sql_type, lower_sql_type);
|
32
32
|
input_type = BoundComparisonExpression::BindComparison(input_type, upper_sql_type);
|
33
33
|
// add casts (if necessary)
|
34
|
-
input
|
35
|
-
lower
|
36
|
-
upper
|
34
|
+
input = BoundCastExpression::AddCastToType(context, std::move(input), input_type);
|
35
|
+
lower = BoundCastExpression::AddCastToType(context, std::move(lower), input_type);
|
36
|
+
upper = BoundCastExpression::AddCastToType(context, std::move(upper), input_type);
|
37
37
|
if (input_type.id() == LogicalTypeId::VARCHAR) {
|
38
38
|
// handle collation
|
39
39
|
auto collation = StringType::GetCollation(input_type);
|
40
|
-
input
|
41
|
-
lower
|
42
|
-
upper
|
40
|
+
input = PushCollation(context, std::move(input), collation, false);
|
41
|
+
lower = PushCollation(context, std::move(lower), collation, false);
|
42
|
+
upper = PushCollation(context, std::move(upper), collation, false);
|
43
43
|
}
|
44
|
-
if (!input
|
44
|
+
if (!input->HasSideEffects() && !input->HasParameter() && !input->HasSubquery()) {
|
45
45
|
// the expression does not have side effects and can be copied: create two comparisons
|
46
46
|
// the reason we do this is that individual comparisons are easier to handle in optimizers
|
47
47
|
// if both comparisons remain they will be folded together again into a single BETWEEN in the optimizer
|
48
48
|
auto left_compare = make_uniq<BoundComparisonExpression>(ExpressionType::COMPARE_GREATERTHANOREQUALTO,
|
49
|
-
input
|
49
|
+
input->Copy(), std::move(lower));
|
50
50
|
auto right_compare = make_uniq<BoundComparisonExpression>(ExpressionType::COMPARE_LESSTHANOREQUALTO,
|
51
|
-
std::move(input
|
51
|
+
std::move(input), std::move(upper));
|
52
52
|
return BindResult(make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND,
|
53
53
|
std::move(left_compare), std::move(right_compare)));
|
54
54
|
} else {
|
55
55
|
// expression has side effects: we cannot duplicate it
|
56
56
|
// create a bound_between directly
|
57
|
-
return BindResult(
|
58
|
-
|
57
|
+
return BindResult(
|
58
|
+
make_uniq<BoundBetweenExpression>(std::move(input), std::move(lower), std::move(upper), true, true));
|
59
59
|
}
|
60
60
|
}
|
61
61
|
|
@@ -18,26 +18,26 @@ BindResult ExpressionBinder::BindExpression(CaseExpression &expr, idx_t depth) {
|
|
18
18
|
}
|
19
19
|
// the children have been successfully resolved
|
20
20
|
// figure out the result type of the CASE expression
|
21
|
-
auto
|
21
|
+
auto &else_expr = BoundExpression::GetExpression(*expr.else_expr);
|
22
|
+
auto return_type = else_expr->return_type;
|
22
23
|
for (auto &check : expr.case_checks) {
|
23
|
-
auto &then_expr = (
|
24
|
-
return_type = LogicalType::MaxLogicalType(return_type, then_expr
|
24
|
+
auto &then_expr = BoundExpression::GetExpression(*check.then_expr);
|
25
|
+
return_type = LogicalType::MaxLogicalType(return_type, then_expr->return_type);
|
25
26
|
}
|
26
27
|
|
27
28
|
// bind all the individual components of the CASE statement
|
28
29
|
auto result = make_uniq<BoundCaseExpression>(return_type);
|
29
30
|
for (idx_t i = 0; i < expr.case_checks.size(); i++) {
|
30
31
|
auto &check = expr.case_checks[i];
|
31
|
-
auto &when_expr = (
|
32
|
-
auto &then_expr = (
|
32
|
+
auto &when_expr = BoundExpression::GetExpression(*check.when_expr);
|
33
|
+
auto &then_expr = BoundExpression::GetExpression(*check.then_expr);
|
33
34
|
BoundCaseCheck result_check;
|
34
35
|
result_check.when_expr =
|
35
|
-
BoundCastExpression::AddCastToType(context, std::move(when_expr
|
36
|
-
result_check.then_expr = BoundCastExpression::AddCastToType(context, std::move(then_expr
|
36
|
+
BoundCastExpression::AddCastToType(context, std::move(when_expr), LogicalType::BOOLEAN);
|
37
|
+
result_check.then_expr = BoundCastExpression::AddCastToType(context, std::move(then_expr), return_type);
|
37
38
|
result->case_checks.push_back(std::move(result_check));
|
38
39
|
}
|
39
|
-
|
40
|
-
result->else_expr = BoundCastExpression::AddCastToType(context, std::move(else_expr.expr), return_type);
|
40
|
+
result->else_expr = BoundCastExpression::AddCastToType(context, std::move(else_expr), return_type);
|
41
41
|
return BindResult(std::move(result));
|
42
42
|
}
|
43
43
|
} // namespace duckdb
|
@@ -16,17 +16,17 @@ BindResult ExpressionBinder::BindExpression(CastExpression &expr, idx_t depth) {
|
|
16
16
|
// Right now just considering its DEFAULT_SCHEMA always
|
17
17
|
Binder::BindLogicalType(context, expr.cast_type);
|
18
18
|
// the children have been successfully resolved
|
19
|
-
auto &child = (
|
19
|
+
auto &child = BoundExpression::GetExpression(*expr.child);
|
20
20
|
if (expr.try_cast) {
|
21
|
-
if (child
|
21
|
+
if (child->return_type == expr.cast_type) {
|
22
22
|
// no cast required: type matches
|
23
|
-
return BindResult(std::move(child
|
23
|
+
return BindResult(std::move(child));
|
24
24
|
}
|
25
|
-
child
|
25
|
+
child = BoundCastExpression::AddCastToType(context, std::move(child), expr.cast_type, true);
|
26
26
|
} else {
|
27
27
|
// otherwise add a cast to the target type
|
28
|
-
child
|
28
|
+
child = BoundCastExpression::AddCastToType(context, std::move(child), expr.cast_type);
|
29
29
|
}
|
30
|
-
return BindResult(std::move(child
|
30
|
+
return BindResult(std::move(child));
|
31
31
|
}
|
32
32
|
} // namespace duckdb
|
@@ -10,17 +10,17 @@ BindResult ExpressionBinder::BindExpression(CollateExpression &expr, idx_t depth
|
|
10
10
|
if (!error.empty()) {
|
11
11
|
return BindResult(error);
|
12
12
|
}
|
13
|
-
auto &child = expr.child
|
14
|
-
if (child
|
13
|
+
auto &child = BoundExpression::GetExpression(*expr.child);
|
14
|
+
if (child->HasParameter()) {
|
15
15
|
throw ParameterNotResolvedException();
|
16
16
|
}
|
17
|
-
if (child
|
17
|
+
if (child->return_type.id() != LogicalTypeId::VARCHAR) {
|
18
18
|
throw BinderException("collations are only supported for type varchar");
|
19
19
|
}
|
20
20
|
// Validate the collation, but don't use it
|
21
|
-
PushCollation(context, child
|
22
|
-
child
|
23
|
-
return BindResult(std::move(child
|
21
|
+
PushCollation(context, child->Copy(), expr.collation, false);
|
22
|
+
child->return_type = LogicalType::VARCHAR_COLLATION(expr.collation);
|
23
|
+
return BindResult(std::move(child));
|
24
24
|
}
|
25
25
|
|
26
26
|
} // namespace duckdb
|
@@ -204,13 +204,13 @@ unique_ptr<ParsedExpression> ExpressionBinder::CreateStructPack(ColumnRefExpress
|
|
204
204
|
}
|
205
205
|
if (colref.column_names.size() == 2) {
|
206
206
|
auto &qualifier = colref.column_names[0];
|
207
|
-
if (catalog_entry->catalog
|
207
|
+
if (catalog_entry->catalog.GetName() != qualifier && catalog_entry->schema.name != qualifier) {
|
208
208
|
return nullptr;
|
209
209
|
}
|
210
210
|
} else if (colref.column_names.size() == 3) {
|
211
211
|
auto &catalog_name = colref.column_names[0];
|
212
212
|
auto &schema_name = colref.column_names[1];
|
213
|
-
if (catalog_entry->catalog
|
213
|
+
if (catalog_entry->catalog.GetName() != catalog_name || catalog_entry->schema.name != schema_name) {
|
214
214
|
return nullptr;
|
215
215
|
}
|
216
216
|
} else {
|
@@ -35,28 +35,29 @@ unique_ptr<Expression> ExpressionBinder::PushCollation(ClientContext &context, u
|
|
35
35
|
}
|
36
36
|
auto &catalog = Catalog::GetSystemCatalog(context);
|
37
37
|
auto splits = StringUtil::Split(StringUtil::Lower(collation), ".");
|
38
|
-
vector<CollateCatalogEntry
|
38
|
+
vector<reference<CollateCatalogEntry>> entries;
|
39
39
|
for (auto &collation_argument : splits) {
|
40
|
-
auto collation_entry = catalog.GetEntry<CollateCatalogEntry>(context, DEFAULT_SCHEMA, collation_argument);
|
41
|
-
if (collation_entry
|
40
|
+
auto &collation_entry = catalog.GetEntry<CollateCatalogEntry>(context, DEFAULT_SCHEMA, collation_argument);
|
41
|
+
if (collation_entry.combinable) {
|
42
42
|
entries.insert(entries.begin(), collation_entry);
|
43
43
|
} else {
|
44
|
-
if (!entries.empty() && !entries.back()
|
45
|
-
throw BinderException("Cannot combine collation types \"%s\" and \"%s\"", entries.back()
|
46
|
-
collation_entry
|
44
|
+
if (!entries.empty() && !entries.back().get().combinable) {
|
45
|
+
throw BinderException("Cannot combine collation types \"%s\" and \"%s\"", entries.back().get().name,
|
46
|
+
collation_entry.name);
|
47
47
|
}
|
48
48
|
entries.push_back(collation_entry);
|
49
49
|
}
|
50
50
|
}
|
51
|
-
for (auto &
|
52
|
-
|
51
|
+
for (auto &entry : entries) {
|
52
|
+
auto &collation_entry = entry.get();
|
53
|
+
if (equality_only && collation_entry.not_required_for_equality) {
|
53
54
|
continue;
|
54
55
|
}
|
55
56
|
vector<unique_ptr<Expression>> children;
|
56
57
|
children.push_back(std::move(source));
|
57
58
|
|
58
59
|
FunctionBinder function_binder(context);
|
59
|
-
auto function = function_binder.BindScalarFunction(collation_entry
|
60
|
+
auto function = function_binder.BindScalarFunction(collation_entry.function, std::move(children));
|
60
61
|
source = std::move(function);
|
61
62
|
}
|
62
63
|
return source;
|
@@ -119,28 +120,27 @@ BindResult ExpressionBinder::BindExpression(ComparisonExpression &expr, idx_t de
|
|
119
120
|
return BindResult(error);
|
120
121
|
}
|
121
122
|
// the children have been successfully resolved
|
122
|
-
auto &left = (
|
123
|
-
auto &right = (
|
124
|
-
auto left_sql_type = left
|
125
|
-
auto right_sql_type = right
|
123
|
+
auto &left = BoundExpression::GetExpression(*expr.left);
|
124
|
+
auto &right = BoundExpression::GetExpression(*expr.right);
|
125
|
+
auto left_sql_type = left->return_type;
|
126
|
+
auto right_sql_type = right->return_type;
|
126
127
|
// cast the input types to the same type
|
127
128
|
// now obtain the result type of the input types
|
128
129
|
auto input_type = BoundComparisonExpression::BindComparison(left_sql_type, right_sql_type);
|
129
130
|
// add casts (if necessary)
|
130
|
-
left
|
131
|
-
|
132
|
-
right
|
133
|
-
|
131
|
+
left = BoundCastExpression::AddCastToType(context, std::move(left), input_type,
|
132
|
+
input_type.id() == LogicalTypeId::ENUM);
|
133
|
+
right = BoundCastExpression::AddCastToType(context, std::move(right), input_type,
|
134
|
+
input_type.id() == LogicalTypeId::ENUM);
|
134
135
|
|
135
136
|
if (input_type.id() == LogicalTypeId::VARCHAR) {
|
136
137
|
// handle collation
|
137
138
|
auto collation = StringType::GetCollation(input_type);
|
138
|
-
left
|
139
|
-
right.
|
140
|
-
PushCollation(context, std::move(right.expr), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
139
|
+
left = PushCollation(context, std::move(left), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
140
|
+
right = PushCollation(context, std::move(right), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
141
141
|
}
|
142
142
|
// now create the bound comparison expression
|
143
|
-
return BindResult(make_uniq<BoundComparisonExpression>(expr.type, std::move(left
|
143
|
+
return BindResult(make_uniq<BoundComparisonExpression>(expr.type, std::move(left), std::move(right)));
|
144
144
|
}
|
145
145
|
|
146
146
|
} // namespace duckdb
|
@@ -19,9 +19,8 @@ BindResult ExpressionBinder::BindExpression(ConjunctionExpression &expr, idx_t d
|
|
19
19
|
// and construct the bound conjunction expression
|
20
20
|
auto result = make_uniq<BoundConjunctionExpression>(expr.type);
|
21
21
|
for (auto &child_expr : expr.children) {
|
22
|
-
auto &child = (
|
23
|
-
result->children.push_back(
|
24
|
-
BoundCastExpression::AddCastToType(context, std::move(child.expr), LogicalType::BOOLEAN));
|
22
|
+
auto &child = BoundExpression::GetExpression(*child_expr);
|
23
|
+
result->children.push_back(BoundCastExpression::AddCastToType(context, std::move(child), LogicalType::BOOLEAN));
|
25
24
|
}
|
26
25
|
// now create the bound conjunction expression
|
27
26
|
return BindResult(std::move(result));
|