duckdb 0.6.2-dev772.0 → 0.6.2-dev889.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 +1 -1
- package/package.json +1 -1
- package/src/connection.cpp +2 -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 +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timezone.cpp +6 -5
- package/src/duckdb/extension/json/json-extension.cpp +1 -1
- package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +516 -177
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +1 -0
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +66 -49
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +15 -16
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry.cpp +6 -2
- package/src/duckdb/src/catalog/catalog_search_path.cpp +177 -22
- package/src/duckdb/src/catalog/catalog_set.cpp +134 -72
- package/src/duckdb/src/catalog/catalog_transaction.cpp +28 -0
- package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
- package/src/duckdb/src/catalog/dependency_list.cpp +13 -0
- package/src/duckdb/src/catalog/dependency_manager.cpp +19 -13
- package/src/duckdb/src/common/constants.cpp +8 -0
- package/src/duckdb/src/common/enums/catalog_type.cpp +2 -0
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +1 -1
- package/src/duckdb/src/common/string_util.cpp +5 -1
- package/src/duckdb/src/execution/index/art/art.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +1 -0
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +72 -0
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +3 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +5 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -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 +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +10 -2
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +2 -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_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -2
- package/src/duckdb/src/function/built_in_functions.cpp +88 -0
- package/src/duckdb/src/function/function.cpp +0 -79
- package/src/duckdb/src/function/function_binder.cpp +2 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -1
- package/src/duckdb/src/function/scalar/date/current.cpp +2 -2
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +3 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +14 -17
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
- package/src/duckdb/src/function/scalar/system/system_functions.cpp +7 -4
- package/src/duckdb/src/function/table/checkpoint.cpp +37 -4
- package/src/duckdb/src/function/table/read_csv.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +32 -25
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +26 -22
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +22 -15
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +25 -18
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +16 -8
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +26 -19
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +24 -17
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +22 -16
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +20 -13
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +3 -4
- package/src/duckdb/src/function/table/system/pragma_database_list.cpp +20 -12
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +39 -24
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -7
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -2
- package/src/duckdb/src/function/table/system_functions.cpp +0 -1
- package/src/duckdb/src/function/table/table_scan.cpp +13 -10
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +102 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +21 -14
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +30 -11
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +35 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +32 -0
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +27 -0
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/constants.hpp +8 -3
- package/src/duckdb/src/include/duckdb/common/enums/catalog_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +33 -0
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +78 -0
- package/src/duckdb/src/include/duckdb/function/function.hpp +0 -61
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -2
- package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/uuid_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/range.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/summary.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -4
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +64 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +6 -6
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +69 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
- package/src/duckdb/src/include/duckdb/main/valid_checker.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_function_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +18 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +53 -56
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +39 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_aggregate_function_info.hpp +3 -18
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_collation_info.hpp +4 -13
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_copy_function_info.hpp +3 -12
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +5 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +3 -14
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +3 -19
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +7 -34
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +10 -2
- package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -1
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +13 -6
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -12
- package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -6
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -7
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +3 -1
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +64 -0
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +14 -23
- package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +12 -8
- package/src/duckdb/src/include/duckdb/transaction/transaction_manager.hpp +5 -10
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
- package/src/duckdb/src/main/attached_database.cpp +97 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +28 -22
- package/src/duckdb/src/main/client_data.cpp +5 -2
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/connection.cpp +1 -1
- package/src/duckdb/src/main/database.cpp +54 -40
- package/src/duckdb/src/main/database_manager.cpp +95 -0
- package/src/duckdb/src/main/materialized_query_result.cpp +1 -1
- package/src/duckdb/src/main/prepared_statement_data.cpp +1 -2
- package/src/duckdb/src/main/query_result.cpp +4 -4
- package/src/duckdb/src/main/settings/settings.cpp +22 -6
- package/src/duckdb/src/main/stream_query_result.cpp +1 -1
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +9 -3
- package/src/duckdb/src/parser/expression/function_expression.cpp +15 -13
- package/src/duckdb/src/parser/expression/window_expression.cpp +6 -4
- package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +7 -7
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +12 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +96 -98
- package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +27 -0
- package/src/duckdb/src/parser/parsed_data/create_collation_info.cpp +23 -0
- package/src/duckdb/src/parser/parsed_data/create_copy_function_info.cpp +21 -0
- package/src/duckdb/src/parser/parsed_data/create_info.cpp +3 -0
- package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +23 -0
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -1
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +28 -0
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +9 -3
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +49 -0
- package/src/duckdb/src/parser/statement/attach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +6 -2
- package/src/duckdb/src/parser/tableref/basetableref.cpp +9 -4
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +15 -13
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +17 -7
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +4 -9
- package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +5 -4
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +8 -10
- package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +32 -0
- package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +7 -2
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +5 -5
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +6 -13
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +6 -6
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +11 -2
- package/src/duckdb/src/parser/transform/statement/transform_export.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +12 -36
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +3 -1
- package/src/duckdb/src/parser/transform/statement/transform_use.cpp +21 -0
- package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +11 -3
- package/src/duckdb/src/parser/transformer.cpp +4 -0
- package/src/duckdb/src/planner/bind_context.cpp +11 -2
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +43 -13
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/statement/bind_attach.cpp +20 -0
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -4
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +79 -27
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +11 -7
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +13 -5
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +6 -3
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_prepare.cpp +0 -2
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +11 -6
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +10 -6
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +2 -4
- package/src/duckdb/src/planner/binder.cpp +17 -2
- package/src/duckdb/src/planner/logical_operator.cpp +5 -12
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -4
- package/src/duckdb/src/planner/operator/logical_create.cpp +1 -4
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -3
- package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_update.cpp +1 -1
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +1 -1
- package/src/duckdb/src/planner/planner.cpp +3 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +1 -1
- package/src/duckdb/src/storage/buffer_manager.cpp +5 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +10 -17
- package/src/duckdb/src/storage/data_table.cpp +34 -24
- package/src/duckdb/src/storage/local_storage.cpp +7 -3
- package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -3
- package/src/duckdb/src/storage/storage_manager.cpp +25 -42
- package/src/duckdb/src/storage/table/column_data.cpp +2 -1
- package/src/duckdb/src/storage/table/row_group.cpp +7 -2
- package/src/duckdb/src/storage/wal_replay.cpp +6 -22
- package/src/duckdb/src/storage/write_ahead_log.cpp +3 -3
- package/src/duckdb/src/transaction/meta_transaction.cpp +106 -0
- package/src/duckdb/src/transaction/transaction.cpp +21 -21
- package/src/duckdb/src/transaction/transaction_context.cpp +44 -8
- package/src/duckdb/src/transaction/transaction_manager.cpp +20 -20
- package/src/duckdb/src/transaction/undo_buffer.cpp +1 -3
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +2 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +27 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +99 -97
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +15206 -14793
- package/src/duckdb/ub_src_catalog.cpp +4 -0
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_function.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +0 -2
- package/src/duckdb/ub_src_main.cpp +4 -0
- package/src/duckdb/ub_src_parser_parsed_data.cpp +12 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +4 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/duckdb/ub_src_transaction.cpp +2 -0
- package/src/duckdb/src/function/table/system/pragma_functions.cpp +0 -120
|
@@ -54,6 +54,7 @@ unique_ptr<InsertStatement> Transformer::TransformInsert(duckdb_libpgquery::PGNo
|
|
|
54
54
|
auto qname = TransformQualifiedName(stmt->relation);
|
|
55
55
|
result->table = qname.name;
|
|
56
56
|
result->schema = qname.schema;
|
|
57
|
+
result->catalog = qname.catalog;
|
|
57
58
|
return result;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -10,60 +10,37 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
|
|
|
10
10
|
|
|
11
11
|
unique_ptr<AlterInfo> info;
|
|
12
12
|
|
|
13
|
+
AlterEntryData data;
|
|
14
|
+
data.if_exists = stmt->missing_ok;
|
|
15
|
+
data.catalog = stmt->relation->catalogname ? stmt->relation->catalogname : INVALID_CATALOG;
|
|
16
|
+
data.schema = stmt->relation->schemaname ? stmt->relation->schemaname : INVALID_SCHEMA;
|
|
17
|
+
if (stmt->relation->relname) {
|
|
18
|
+
data.name = stmt->relation->relname;
|
|
19
|
+
}
|
|
20
|
+
if (stmt->relation->schemaname) {
|
|
21
|
+
}
|
|
13
22
|
// first we check the type of ALTER
|
|
14
23
|
switch (stmt->renameType) {
|
|
15
24
|
case duckdb_libpgquery::PG_OBJECT_COLUMN: {
|
|
16
25
|
// change column name
|
|
17
26
|
|
|
18
|
-
// get the table and schema
|
|
19
|
-
string schema = INVALID_SCHEMA;
|
|
20
|
-
string table;
|
|
21
|
-
D_ASSERT(stmt->relation->relname);
|
|
22
|
-
if (stmt->relation->relname) {
|
|
23
|
-
table = stmt->relation->relname;
|
|
24
|
-
}
|
|
25
|
-
if (stmt->relation->schemaname) {
|
|
26
|
-
schema = stmt->relation->schemaname;
|
|
27
|
-
}
|
|
28
27
|
// get the old name and the new name
|
|
29
28
|
string old_name = stmt->subname;
|
|
30
29
|
string new_name = stmt->newname;
|
|
31
|
-
info = make_unique<RenameColumnInfo>(
|
|
30
|
+
info = make_unique<RenameColumnInfo>(move(data), old_name, new_name);
|
|
32
31
|
break;
|
|
33
32
|
}
|
|
34
33
|
case duckdb_libpgquery::PG_OBJECT_TABLE: {
|
|
35
34
|
// change table name
|
|
36
|
-
|
|
37
|
-
// get the table and schema
|
|
38
|
-
string schema = INVALID_SCHEMA;
|
|
39
|
-
string table;
|
|
40
|
-
D_ASSERT(stmt->relation->relname);
|
|
41
|
-
if (stmt->relation->relname) {
|
|
42
|
-
table = stmt->relation->relname;
|
|
43
|
-
}
|
|
44
|
-
if (stmt->relation->schemaname) {
|
|
45
|
-
schema = stmt->relation->schemaname;
|
|
46
|
-
}
|
|
47
35
|
string new_name = stmt->newname;
|
|
48
|
-
info = make_unique<RenameTableInfo>(
|
|
36
|
+
info = make_unique<RenameTableInfo>(move(data), new_name);
|
|
49
37
|
break;
|
|
50
38
|
}
|
|
51
39
|
|
|
52
40
|
case duckdb_libpgquery::PG_OBJECT_VIEW: {
|
|
53
41
|
// change view name
|
|
54
|
-
|
|
55
|
-
// get the view and schema
|
|
56
|
-
string schema = INVALID_SCHEMA;
|
|
57
|
-
string view;
|
|
58
|
-
D_ASSERT(stmt->relation->relname);
|
|
59
|
-
if (stmt->relation->relname) {
|
|
60
|
-
view = stmt->relation->relname;
|
|
61
|
-
}
|
|
62
|
-
if (stmt->relation->schemaname) {
|
|
63
|
-
schema = stmt->relation->schemaname;
|
|
64
|
-
}
|
|
65
42
|
string new_name = stmt->newname;
|
|
66
|
-
info = make_unique<RenameViewInfo>(
|
|
43
|
+
info = make_unique<RenameViewInfo>(move(data), new_name);
|
|
67
44
|
break;
|
|
68
45
|
}
|
|
69
46
|
case duckdb_libpgquery::PG_OBJECT_DATABASE:
|
|
@@ -71,7 +48,6 @@ unique_ptr<AlterStatement> Transformer::TransformRename(duckdb_libpgquery::PGNod
|
|
|
71
48
|
throw NotImplementedException("Schema element not supported yet!");
|
|
72
49
|
}
|
|
73
50
|
D_ASSERT(info);
|
|
74
|
-
info->if_exists = stmt->missing_ok;
|
|
75
51
|
|
|
76
52
|
auto result = make_unique<AlterStatement>();
|
|
77
53
|
result->info = move(info);
|
|
@@ -10,7 +10,9 @@ namespace duckdb {
|
|
|
10
10
|
static void TransformShowName(unique_ptr<PragmaStatement> &result, const string &name) {
|
|
11
11
|
auto &info = *result->info;
|
|
12
12
|
|
|
13
|
-
if (name == "\"
|
|
13
|
+
if (StringUtil::Lower(name) == "\"databases\"") {
|
|
14
|
+
info.name = "show_databases";
|
|
15
|
+
} else if (name == "\"tables\"") {
|
|
14
16
|
// show all tables
|
|
15
17
|
info.name = "show_tables";
|
|
16
18
|
} else if (name == "__show_tables_expanded") {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include "duckdb/parser/transformer.hpp"
|
|
2
|
+
#include "duckdb/parser/statement/set_statement.hpp"
|
|
3
|
+
|
|
4
|
+
namespace duckdb {
|
|
5
|
+
|
|
6
|
+
unique_ptr<SetStatement> Transformer::TransformUse(duckdb_libpgquery::PGNode *node) {
|
|
7
|
+
auto stmt = reinterpret_cast<duckdb_libpgquery::PGUseStmt *>(node);
|
|
8
|
+
auto qualified_name = TransformQualifiedName(stmt->name);
|
|
9
|
+
if (!IsInvalidCatalog(qualified_name.catalog)) {
|
|
10
|
+
throw ParserException("Expected \"USE database\" or \"USE database.schema\"");
|
|
11
|
+
}
|
|
12
|
+
string name;
|
|
13
|
+
if (IsInvalidSchema(qualified_name.schema)) {
|
|
14
|
+
name = qualified_name.name;
|
|
15
|
+
} else {
|
|
16
|
+
name = qualified_name.schema + "." + qualified_name.name;
|
|
17
|
+
}
|
|
18
|
+
return make_unique<SetVariableStatement>("schema", move(name), SetScope::AUTOMATIC);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace duckdb
|
|
@@ -10,6 +10,9 @@ unique_ptr<TableRef> Transformer::TransformRangeVar(duckdb_libpgquery::PGRangeVa
|
|
|
10
10
|
if (root->relname) {
|
|
11
11
|
result->table_name = root->relname;
|
|
12
12
|
}
|
|
13
|
+
if (root->catalogname) {
|
|
14
|
+
result->catalog_name = root->catalogname;
|
|
15
|
+
}
|
|
13
16
|
if (root->schemaname) {
|
|
14
17
|
result->schema_name = root->schemaname;
|
|
15
18
|
}
|
|
@@ -22,16 +25,21 @@ unique_ptr<TableRef> Transformer::TransformRangeVar(duckdb_libpgquery::PGRangeVa
|
|
|
22
25
|
|
|
23
26
|
QualifiedName Transformer::TransformQualifiedName(duckdb_libpgquery::PGRangeVar *root) {
|
|
24
27
|
QualifiedName qname;
|
|
25
|
-
if (root->
|
|
26
|
-
qname.
|
|
28
|
+
if (root->catalogname) {
|
|
29
|
+
qname.catalog = root->catalogname;
|
|
27
30
|
} else {
|
|
28
|
-
qname.
|
|
31
|
+
qname.catalog = INVALID_CATALOG;
|
|
29
32
|
}
|
|
30
33
|
if (root->schemaname) {
|
|
31
34
|
qname.schema = root->schemaname;
|
|
32
35
|
} else {
|
|
33
36
|
qname.schema = INVALID_SCHEMA;
|
|
34
37
|
}
|
|
38
|
+
if (root->relname) {
|
|
39
|
+
qname.name = root->relname;
|
|
40
|
+
} else {
|
|
41
|
+
qname.name = string();
|
|
42
|
+
}
|
|
35
43
|
return qname;
|
|
36
44
|
}
|
|
37
45
|
|
|
@@ -143,6 +143,10 @@ unique_ptr<SQLStatement> Transformer::TransformStatementInternal(duckdb_libpgque
|
|
|
143
143
|
return TransformCreateType(stmt);
|
|
144
144
|
case duckdb_libpgquery::T_PGAlterSeqStmt:
|
|
145
145
|
return TransformAlterSequence(stmt);
|
|
146
|
+
case duckdb_libpgquery::T_PGAttachStmt:
|
|
147
|
+
return TransformAttach(stmt);
|
|
148
|
+
case duckdb_libpgquery::T_PGUseStmt:
|
|
149
|
+
return TransformUse(stmt);
|
|
146
150
|
default:
|
|
147
151
|
throw NotImplementedException(NodetypeToString(stmt->type));
|
|
148
152
|
}
|
|
@@ -194,10 +194,13 @@ static bool ColumnIsGenerated(Binding *binding, column_t index) {
|
|
|
194
194
|
return table_entry->columns.GetColumn(LogicalIndex(index)).Generated();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &
|
|
198
|
-
const string &column_name) {
|
|
197
|
+
unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &catalog_name, const string &schema_name,
|
|
198
|
+
const string &table_name, const string &column_name) {
|
|
199
199
|
string error_message;
|
|
200
200
|
vector<string> names;
|
|
201
|
+
if (!catalog_name.empty()) {
|
|
202
|
+
names.push_back(catalog_name);
|
|
203
|
+
}
|
|
201
204
|
if (!schema_name.empty()) {
|
|
202
205
|
names.push_back(schema_name);
|
|
203
206
|
}
|
|
@@ -220,6 +223,12 @@ unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &sc
|
|
|
220
223
|
return move(result);
|
|
221
224
|
}
|
|
222
225
|
|
|
226
|
+
unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &schema_name, const string &table_name,
|
|
227
|
+
const string &column_name) {
|
|
228
|
+
string catalog_name;
|
|
229
|
+
return CreateColumnReference(catalog_name, schema_name, table_name, column_name);
|
|
230
|
+
}
|
|
231
|
+
|
|
223
232
|
Binding *BindContext::GetCTEBinding(const string &ctename) {
|
|
224
233
|
auto match = cte_bindings.find(ctename);
|
|
225
234
|
if (match == cte_bindings.end()) {
|
|
@@ -14,7 +14,7 @@ BindResult ExpressionBinder::BindExpression(CastExpression &expr, idx_t depth) {
|
|
|
14
14
|
}
|
|
15
15
|
// FIXME: We can also implement 'hello'::schema.custom_type; and pass by the schema down here.
|
|
16
16
|
// Right now just considering its DEFAULT_SCHEMA always
|
|
17
|
-
Binder::BindLogicalType(context, expr.cast_type,
|
|
17
|
+
Binder::BindLogicalType(context, expr.cast_type, INVALID_CATALOG, INVALID_SCHEMA);
|
|
18
18
|
// the children have been successfully resolved
|
|
19
19
|
auto &child = (BoundExpression &)*expr.child;
|
|
20
20
|
if (expr.try_cast) {
|
|
@@ -142,23 +142,36 @@ unique_ptr<ParsedExpression> ExpressionBinder::CreateStructExtract(unique_ptr<Pa
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
unique_ptr<ParsedExpression> ExpressionBinder::CreateStructPack(ColumnRefExpression &colref) {
|
|
145
|
-
D_ASSERT(colref.column_names.size() <=
|
|
145
|
+
D_ASSERT(colref.column_names.size() <= 3);
|
|
146
146
|
string error_message;
|
|
147
147
|
auto &table_name = colref.column_names.back();
|
|
148
148
|
auto binding = binder.bind_context.GetBinding(table_name, error_message);
|
|
149
149
|
if (!binding) {
|
|
150
150
|
return nullptr;
|
|
151
151
|
}
|
|
152
|
-
if (colref.column_names.size()
|
|
152
|
+
if (colref.column_names.size() >= 2) {
|
|
153
153
|
// "schema_name.table_name"
|
|
154
154
|
auto catalog_entry = binding->GetStandardEntry();
|
|
155
155
|
if (!catalog_entry) {
|
|
156
156
|
return nullptr;
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
if (catalog_entry->schema->name != schema_name || catalog_entry->name != table_name) {
|
|
158
|
+
if (catalog_entry->name != table_name) {
|
|
160
159
|
return nullptr;
|
|
161
160
|
}
|
|
161
|
+
if (colref.column_names.size() == 2) {
|
|
162
|
+
auto &qualifier = colref.column_names[0];
|
|
163
|
+
if (catalog_entry->catalog->GetName() != qualifier && catalog_entry->schema->name != qualifier) {
|
|
164
|
+
return nullptr;
|
|
165
|
+
}
|
|
166
|
+
} else if (colref.column_names.size() == 3) {
|
|
167
|
+
auto &catalog_name = colref.column_names[0];
|
|
168
|
+
auto &schema_name = colref.column_names[1];
|
|
169
|
+
if (catalog_entry->catalog->GetName() != catalog_name || catalog_entry->schema->name != schema_name) {
|
|
170
|
+
return nullptr;
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
throw InternalException("Expected 2 or 3 column names for CreateStructPack");
|
|
174
|
+
}
|
|
162
175
|
}
|
|
163
176
|
// We found the table, now create the struct_pack expression
|
|
164
177
|
vector<unique_ptr<ParsedExpression>> child_exprs;
|
|
@@ -207,22 +220,39 @@ unique_ptr<ParsedExpression> ExpressionBinder::QualifyColumnName(ColumnRefExpres
|
|
|
207
220
|
}
|
|
208
221
|
} else {
|
|
209
222
|
// two or more dots (i.e. "part1.part2.part3.part4...")
|
|
223
|
+
// -> part1 is a catalog, part2 is a schema, part3 is a table, part4 is a column name, part 5 and beyond are
|
|
224
|
+
// struct fields
|
|
225
|
+
// -> part1 is a catalog, part2 is a table, part3 is a column name, part4 and beyond are struct fields
|
|
210
226
|
// -> part1 is a schema, part2 is a table, part3 is a column name, part4 and beyond are struct fields
|
|
211
227
|
// -> part1 is a table, part2 is a column name, part3 and beyond are struct fields
|
|
212
228
|
// -> part1 is a column, part2 and beyond are struct fields
|
|
213
229
|
|
|
214
230
|
// we always prefer the most top-level view
|
|
215
231
|
// i.e. in case of multiple resolution options, we resolve in order:
|
|
216
|
-
// -> 1. resolve "part1" as a
|
|
217
|
-
// -> 2. resolve "part1" as a
|
|
218
|
-
// -> 3. resolve "part1" as a
|
|
232
|
+
// -> 1. resolve "part1" as a catalog
|
|
233
|
+
// -> 2. resolve "part1" as a schema
|
|
234
|
+
// -> 3. resolve "part1" as a table
|
|
235
|
+
// -> 4. resolve "part1" as a column
|
|
219
236
|
|
|
220
237
|
unique_ptr<ParsedExpression> result_expr;
|
|
221
238
|
idx_t struct_extract_start;
|
|
222
|
-
// first check if part1 is a
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
239
|
+
// first check if part1 is a catalog
|
|
240
|
+
if (colref.column_names.size() > 3 &&
|
|
241
|
+
binder.HasMatchingBinding(colref.column_names[0], colref.column_names[1], colref.column_names[2],
|
|
242
|
+
colref.column_names[3], error_message)) {
|
|
243
|
+
// part1 is a catalog - the column reference is "catalog.schema.table.column"
|
|
244
|
+
result_expr = binder.bind_context.CreateColumnReference(colref.column_names[0], colref.column_names[1],
|
|
245
|
+
colref.column_names[2], colref.column_names[3]);
|
|
246
|
+
struct_extract_start = 4;
|
|
247
|
+
} else if (binder.HasMatchingBinding(colref.column_names[0], INVALID_SCHEMA, colref.column_names[1],
|
|
248
|
+
colref.column_names[2], error_message)) {
|
|
249
|
+
// part1 is a catalog - the column reference is "catalog.table.column"
|
|
250
|
+
result_expr = binder.bind_context.CreateColumnReference(colref.column_names[0], INVALID_SCHEMA,
|
|
251
|
+
colref.column_names[1], colref.column_names[2]);
|
|
252
|
+
struct_extract_start = 3;
|
|
253
|
+
} else if (binder.HasMatchingBinding(colref.column_names[0], colref.column_names[1], colref.column_names[2],
|
|
254
|
+
error_message)) {
|
|
255
|
+
// part1 is a schema - the column reference is "schema.table.column"
|
|
226
256
|
// any additional fields are turned into struct_extract calls
|
|
227
257
|
result_expr = binder.bind_context.CreateColumnReference(colref.column_names[0], colref.column_names[1],
|
|
228
258
|
colref.column_names[2]);
|
|
@@ -238,8 +268,8 @@ unique_ptr<ParsedExpression> ExpressionBinder::QualifyColumnName(ColumnRefExpres
|
|
|
238
268
|
string col_error;
|
|
239
269
|
result_expr = QualifyColumnName(colref.column_names[0], col_error);
|
|
240
270
|
if (!result_expr) {
|
|
241
|
-
// it is not!
|
|
242
|
-
return
|
|
271
|
+
// it is not! Try creating an implicit struct_pack
|
|
272
|
+
return CreateStructPack(colref);
|
|
243
273
|
}
|
|
244
274
|
// it is! add the struct extract calls
|
|
245
275
|
struct_extract_start = 1;
|
|
@@ -33,7 +33,7 @@ unique_ptr<Expression> ExpressionBinder::PushCollation(ClientContext &context, u
|
|
|
33
33
|
// binary collation: just skip
|
|
34
34
|
return source;
|
|
35
35
|
}
|
|
36
|
-
auto &catalog = Catalog::
|
|
36
|
+
auto &catalog = Catalog::GetSystemCatalog(context);
|
|
37
37
|
auto splits = StringUtil::Split(StringUtil::Lower(collation), ".");
|
|
38
38
|
vector<CollateCatalogEntry *> entries;
|
|
39
39
|
for (auto &collation_argument : splits) {
|
|
@@ -24,9 +24,8 @@ BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t
|
|
|
24
24
|
// have unnest live in catalog, too
|
|
25
25
|
return BindUnnest(function, depth);
|
|
26
26
|
}
|
|
27
|
-
auto
|
|
28
|
-
|
|
29
|
-
false, error_context);
|
|
27
|
+
auto func = Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, function.catalog, function.schema,
|
|
28
|
+
function.function_name, false, error_context);
|
|
30
29
|
|
|
31
30
|
switch (func->type) {
|
|
32
31
|
case CatalogType::SCALAR_FUNCTION_ENTRY:
|
|
@@ -192,9 +192,8 @@ BindResult SelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
|
|
|
192
192
|
unique_ptr<FunctionData> bind_info;
|
|
193
193
|
if (window.type == ExpressionType::WINDOW_AGGREGATE) {
|
|
194
194
|
// Look up the aggregate function in the catalog
|
|
195
|
-
auto func =
|
|
196
|
-
|
|
197
|
-
context, window.schema, window.function_name, false, error_context);
|
|
195
|
+
auto func = Catalog::GetEntry<AggregateFunctionCatalogEntry>(context, window.catalog, window.schema,
|
|
196
|
+
window.function_name, false, error_context);
|
|
198
197
|
D_ASSERT(func->type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
|
|
199
198
|
|
|
200
199
|
// bind the aggregate
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "duckdb/planner/binder.hpp"
|
|
2
|
+
#include "duckdb/parser/statement/attach_statement.hpp"
|
|
3
|
+
#include "duckdb/parser/tableref/table_function_ref.hpp"
|
|
4
|
+
#include "duckdb/planner/tableref/bound_table_function.hpp"
|
|
5
|
+
#include "duckdb/planner/operator/logical_simple.hpp"
|
|
6
|
+
|
|
7
|
+
namespace duckdb {
|
|
8
|
+
|
|
9
|
+
BoundStatement Binder::Bind(AttachStatement &stmt) {
|
|
10
|
+
BoundStatement result;
|
|
11
|
+
result.types = {LogicalType::BOOLEAN};
|
|
12
|
+
result.names = {"Success"};
|
|
13
|
+
|
|
14
|
+
result.plan = make_unique<LogicalSimple>(LogicalOperatorType::LOGICAL_ATTACH, move(stmt.info));
|
|
15
|
+
properties.allow_stream_result = false;
|
|
16
|
+
properties.return_type = StatementReturnType::NOTHING;
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
} // namespace duckdb
|
|
@@ -34,8 +34,8 @@ BoundStatement Binder::BindCopyTo(CopyStatement &stmt) {
|
|
|
34
34
|
auto select_node = Bind(*stmt.select_statement);
|
|
35
35
|
|
|
36
36
|
// lookup the format in the catalog
|
|
37
|
-
auto
|
|
38
|
-
|
|
37
|
+
auto copy_function =
|
|
38
|
+
Catalog::GetEntry<CopyFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, stmt.info->format);
|
|
39
39
|
if (!copy_function->function.copy_to_bind) {
|
|
40
40
|
throw NotImplementedException("COPY TO is not supported for FORMAT \"%s\"", stmt.info->format);
|
|
41
41
|
}
|
|
@@ -94,6 +94,7 @@ BoundStatement Binder::BindCopyFrom(CopyStatement &stmt) {
|
|
|
94
94
|
InsertStatement insert;
|
|
95
95
|
insert.table = stmt.info->table;
|
|
96
96
|
insert.schema = stmt.info->schema;
|
|
97
|
+
insert.catalog = stmt.info->catalog;
|
|
97
98
|
insert.columns = stmt.info->select_list;
|
|
98
99
|
|
|
99
100
|
// bind the insert statement to the base table
|
|
@@ -103,13 +104,14 @@ BoundStatement Binder::BindCopyFrom(CopyStatement &stmt) {
|
|
|
103
104
|
auto &bound_insert = (LogicalInsert &)*insert_statement.plan;
|
|
104
105
|
|
|
105
106
|
// lookup the format in the catalog
|
|
106
|
-
auto &catalog = Catalog::
|
|
107
|
+
auto &catalog = Catalog::GetSystemCatalog(context);
|
|
107
108
|
auto copy_function = catalog.GetEntry<CopyFunctionCatalogEntry>(context, DEFAULT_SCHEMA, stmt.info->format);
|
|
108
109
|
if (!copy_function->function.copy_from_bind) {
|
|
109
110
|
throw NotImplementedException("COPY FROM is not supported for FORMAT \"%s\"", stmt.info->format);
|
|
110
111
|
}
|
|
111
112
|
// lookup the table to copy into
|
|
112
|
-
|
|
113
|
+
BindSchemaOrCatalog(stmt.info->catalog, stmt.info->schema);
|
|
114
|
+
auto table = Catalog::GetEntry<TableCatalogEntry>(context, stmt.info->catalog, stmt.info->schema, stmt.info->table);
|
|
113
115
|
vector<string> expected_names;
|
|
114
116
|
if (!bound_insert.column_index_map.empty()) {
|
|
115
117
|
expected_names.resize(bound_insert.expected_types.size());
|
|
@@ -143,6 +145,7 @@ BoundStatement Binder::Bind(CopyStatement &stmt) {
|
|
|
143
145
|
// copy table into file without a query
|
|
144
146
|
// generate SELECT * FROM table;
|
|
145
147
|
auto ref = make_unique<BaseTableRef>();
|
|
148
|
+
ref->catalog_name = stmt.info->catalog;
|
|
146
149
|
ref->schema_name = stmt.info->schema;
|
|
147
150
|
ref->table_name = stmt.info->table;
|
|
148
151
|
|
|
@@ -31,32 +31,83 @@
|
|
|
31
31
|
#include "duckdb/main/client_data.hpp"
|
|
32
32
|
#include "duckdb/parser/constraints/unique_constraint.hpp"
|
|
33
33
|
#include "duckdb/parser/constraints/list.hpp"
|
|
34
|
+
#include "duckdb/main/database_manager.hpp"
|
|
35
|
+
#include "duckdb/main/attached_database.hpp"
|
|
34
36
|
|
|
35
37
|
namespace duckdb {
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
39
|
+
void Binder::BindSchemaOrCatalog(ClientContext &context, string &catalog, string &schema) {
|
|
40
|
+
if (catalog.empty() && !schema.empty()) {
|
|
41
|
+
// schema is specified - but catalog is not
|
|
42
|
+
// try searching for the catalog instead
|
|
43
|
+
auto &db_manager = DatabaseManager::Get(context);
|
|
44
|
+
auto database = db_manager.GetDatabase(context, schema);
|
|
45
|
+
if (database) {
|
|
46
|
+
// we have a database with this name
|
|
47
|
+
// check if there is a schema
|
|
48
|
+
auto schema_obj = Catalog::GetSchema(context, INVALID_CATALOG, schema, true);
|
|
49
|
+
if (schema_obj) {
|
|
50
|
+
auto &attached = schema_obj->catalog->GetAttached();
|
|
51
|
+
throw BinderException(
|
|
52
|
+
"Ambiguous reference to catalog or schema \"%s\" - use a fully qualified path like \"%s.%s\"",
|
|
53
|
+
schema, attached.GetName(), schema);
|
|
54
|
+
}
|
|
55
|
+
catalog = schema;
|
|
56
|
+
schema = string();
|
|
57
|
+
}
|
|
40
58
|
}
|
|
59
|
+
}
|
|
41
60
|
|
|
61
|
+
void Binder::BindSchemaOrCatalog(string &catalog, string &schema) {
|
|
62
|
+
BindSchemaOrCatalog(context, catalog, schema);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
66
|
+
BindSchemaOrCatalog(info.catalog, info.schema);
|
|
67
|
+
if (IsInvalidCatalog(info.catalog) && info.temporary) {
|
|
68
|
+
info.catalog = TEMP_CATALOG;
|
|
69
|
+
}
|
|
70
|
+
auto &search_path = ClientData::Get(context).catalog_search_path;
|
|
71
|
+
if (IsInvalidCatalog(info.catalog) && IsInvalidSchema(info.schema)) {
|
|
72
|
+
auto &default_entry = search_path->GetDefault();
|
|
73
|
+
info.catalog = default_entry.catalog;
|
|
74
|
+
info.schema = default_entry.schema;
|
|
75
|
+
} else if (IsInvalidSchema(info.schema)) {
|
|
76
|
+
info.schema = search_path->GetDefaultSchema(info.catalog);
|
|
77
|
+
} else if (IsInvalidCatalog(info.catalog)) {
|
|
78
|
+
info.catalog = search_path->GetDefaultCatalog(info.schema);
|
|
79
|
+
}
|
|
80
|
+
if (IsInvalidCatalog(info.catalog)) {
|
|
81
|
+
info.catalog = DatabaseManager::GetDefaultDatabase(context);
|
|
82
|
+
}
|
|
42
83
|
if (!info.temporary) {
|
|
43
84
|
// non-temporary create: not read only
|
|
44
|
-
if (info.
|
|
45
|
-
throw ParserException("Only TEMPORARY table names can use the \"
|
|
85
|
+
if (info.catalog == TEMP_CATALOG) {
|
|
86
|
+
throw ParserException("Only TEMPORARY table names can use the \"%s\" catalog", TEMP_CATALOG);
|
|
46
87
|
}
|
|
47
|
-
properties.read_only = false;
|
|
48
88
|
} else {
|
|
49
|
-
if (info.
|
|
50
|
-
throw ParserException("TEMPORARY table names can *only* use the \"%s\"
|
|
89
|
+
if (info.catalog != TEMP_CATALOG) {
|
|
90
|
+
throw ParserException("TEMPORARY table names can *only* use the \"%s\" catalog", TEMP_CATALOG);
|
|
51
91
|
}
|
|
52
92
|
}
|
|
53
93
|
// fetch the schema in which we want to create the object
|
|
54
|
-
auto schema_obj = Catalog::
|
|
94
|
+
auto schema_obj = Catalog::GetSchema(context, info.catalog, info.schema);
|
|
55
95
|
D_ASSERT(schema_obj->type == CatalogType::SCHEMA_ENTRY);
|
|
56
96
|
info.schema = schema_obj->name;
|
|
97
|
+
if (!info.temporary) {
|
|
98
|
+
properties.modified_databases.insert(schema_obj->catalog->GetName());
|
|
99
|
+
}
|
|
57
100
|
return schema_obj;
|
|
58
101
|
}
|
|
59
102
|
|
|
103
|
+
SchemaCatalogEntry *Binder::BindCreateSchema(CreateInfo &info) {
|
|
104
|
+
auto schema = BindSchema(info);
|
|
105
|
+
if (schema->catalog->IsSystemCatalog()) {
|
|
106
|
+
throw BinderException("Cannot create entry in system catalog");
|
|
107
|
+
}
|
|
108
|
+
return schema;
|
|
109
|
+
}
|
|
110
|
+
|
|
60
111
|
void Binder::BindCreateViewInfo(CreateViewInfo &base) {
|
|
61
112
|
// bind the view as if it were a query so we can catch errors
|
|
62
113
|
// note that we bind the original, and replace the original with a copy
|
|
@@ -121,20 +172,20 @@ SchemaCatalogEntry *Binder::BindCreateFunctionInfo(CreateInfo &info) {
|
|
|
121
172
|
throw BinderException(error);
|
|
122
173
|
}
|
|
123
174
|
|
|
124
|
-
return
|
|
175
|
+
return BindCreateSchema(info);
|
|
125
176
|
}
|
|
126
177
|
|
|
127
|
-
void Binder::BindLogicalType(ClientContext &context, LogicalType &type, const string &schema) {
|
|
178
|
+
void Binder::BindLogicalType(ClientContext &context, LogicalType &type, const string &catalog, const string &schema) {
|
|
128
179
|
if (type.id() == LogicalTypeId::LIST) {
|
|
129
180
|
auto child_type = ListType::GetChildType(type);
|
|
130
|
-
BindLogicalType(context, child_type, schema);
|
|
181
|
+
BindLogicalType(context, child_type, catalog, schema);
|
|
131
182
|
auto alias = type.GetAlias();
|
|
132
183
|
type = LogicalType::LIST(child_type);
|
|
133
184
|
type.SetAlias(alias);
|
|
134
185
|
} else if (type.id() == LogicalTypeId::STRUCT || type.id() == LogicalTypeId::MAP) {
|
|
135
186
|
auto child_types = StructType::GetChildTypes(type);
|
|
136
187
|
for (auto &child_type : child_types) {
|
|
137
|
-
BindLogicalType(context, child_type.second, schema);
|
|
188
|
+
BindLogicalType(context, child_type.second, catalog, schema);
|
|
138
189
|
}
|
|
139
190
|
// Generate new Struct/Map Type
|
|
140
191
|
auto alias = type.GetAlias();
|
|
@@ -147,19 +198,17 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, const st
|
|
|
147
198
|
} else if (type.id() == LogicalTypeId::UNION) {
|
|
148
199
|
auto member_types = UnionType::CopyMemberTypes(type);
|
|
149
200
|
for (auto &member_type : member_types) {
|
|
150
|
-
BindLogicalType(context, member_type.second, schema);
|
|
201
|
+
BindLogicalType(context, member_type.second, catalog, schema);
|
|
151
202
|
}
|
|
152
203
|
// Generate new Union Type
|
|
153
204
|
auto alias = type.GetAlias();
|
|
154
205
|
type = LogicalType::UNION(member_types);
|
|
155
206
|
type.SetAlias(alias);
|
|
156
207
|
} else if (type.id() == LogicalTypeId::USER) {
|
|
157
|
-
|
|
158
|
-
type = catalog.GetType(context, schema, UserType::GetTypeName(type));
|
|
208
|
+
type = Catalog::GetType(context, catalog, schema, UserType::GetTypeName(type));
|
|
159
209
|
} else if (type.id() == LogicalTypeId::ENUM) {
|
|
160
210
|
auto &enum_type_name = EnumType::GetTypeName(type);
|
|
161
|
-
auto enum_type_catalog =
|
|
162
|
-
schema, enum_type_name, true);
|
|
211
|
+
auto enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, catalog, schema, enum_type_name, true);
|
|
163
212
|
LogicalType::SetCatalog(type, enum_type_catalog);
|
|
164
213
|
}
|
|
165
214
|
}
|
|
@@ -344,18 +393,18 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
344
393
|
case CatalogType::VIEW_ENTRY: {
|
|
345
394
|
auto &base = (CreateViewInfo &)*stmt.info;
|
|
346
395
|
// bind the schema
|
|
347
|
-
auto schema =
|
|
396
|
+
auto schema = BindCreateSchema(*stmt.info);
|
|
348
397
|
BindCreateViewInfo(base);
|
|
349
398
|
result.plan = make_unique<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_VIEW, move(stmt.info), schema);
|
|
350
399
|
break;
|
|
351
400
|
}
|
|
352
401
|
case CatalogType::SEQUENCE_ENTRY: {
|
|
353
|
-
auto schema =
|
|
402
|
+
auto schema = BindCreateSchema(*stmt.info);
|
|
354
403
|
result.plan = make_unique<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_SEQUENCE, move(stmt.info), schema);
|
|
355
404
|
break;
|
|
356
405
|
}
|
|
357
406
|
case CatalogType::TABLE_MACRO_ENTRY: {
|
|
358
|
-
auto schema =
|
|
407
|
+
auto schema = BindCreateSchema(*stmt.info);
|
|
359
408
|
result.plan = make_unique<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_MACRO, move(stmt.info), schema);
|
|
360
409
|
break;
|
|
361
410
|
}
|
|
@@ -393,6 +442,9 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
393
442
|
throw BinderException("Cannot create an index on the rowid!");
|
|
394
443
|
}
|
|
395
444
|
}
|
|
445
|
+
if (table->temporary) {
|
|
446
|
+
stmt.info->temporary = true;
|
|
447
|
+
}
|
|
396
448
|
|
|
397
449
|
auto create_index_info = unique_ptr_cast<CreateInfo, CreateIndexInfo>(move(stmt.info));
|
|
398
450
|
for (auto &index : get.column_ids) {
|
|
@@ -409,7 +461,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
409
461
|
}
|
|
410
462
|
case CatalogType::TABLE_ENTRY: {
|
|
411
463
|
auto &create_info = (CreateTableInfo &)*stmt.info;
|
|
412
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
413
464
|
// If there is a foreign key constraint, resolve primary key column's index from primary key column's name
|
|
414
465
|
unordered_set<SchemaCatalogEntry *> fk_schemas;
|
|
415
466
|
for (idx_t i = 0; i < create_info.constraints.size(); i++) {
|
|
@@ -432,7 +483,8 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
432
483
|
CheckForeignKeyTypes(create_info.columns, create_info.columns, fk);
|
|
433
484
|
} else {
|
|
434
485
|
// have to resolve referenced table
|
|
435
|
-
auto pk_table_entry_ptr =
|
|
486
|
+
auto pk_table_entry_ptr =
|
|
487
|
+
Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, fk.info.schema, fk.info.table);
|
|
436
488
|
fk_schemas.insert(pk_table_entry_ptr->schema);
|
|
437
489
|
FindMatchingPrimaryKeyColumns(pk_table_entry_ptr->columns, pk_table_entry_ptr->constraints, fk);
|
|
438
490
|
FindForeignKeyIndexes(pk_table_entry_ptr->columns, fk.pk_columns, fk.info.pk_keys);
|
|
@@ -457,7 +509,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
457
509
|
auto root = move(bound_info->query);
|
|
458
510
|
for (auto &fk_schema : fk_schemas) {
|
|
459
511
|
if (fk_schema != bound_info->schema) {
|
|
460
|
-
throw BinderException("Creating foreign keys across different schemas is not supported");
|
|
512
|
+
throw BinderException("Creating foreign keys across different schemas or catalogs is not supported");
|
|
461
513
|
}
|
|
462
514
|
}
|
|
463
515
|
|
|
@@ -473,7 +525,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
473
525
|
break;
|
|
474
526
|
}
|
|
475
527
|
case CatalogType::TYPE_ENTRY: {
|
|
476
|
-
auto schema =
|
|
528
|
+
auto schema = BindCreateSchema(*stmt.info);
|
|
477
529
|
auto &create_type_info = (CreateTypeInfo &)(*stmt.info);
|
|
478
530
|
result.plan = make_unique<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_TYPE, move(stmt.info), schema);
|
|
479
531
|
if (create_type_info.query) {
|
|
@@ -518,8 +570,8 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
518
570
|
// 2: create a type alias with a custom type.
|
|
519
571
|
// eg. CREATE TYPE a AS INT; CREATE TYPE b AS a;
|
|
520
572
|
// We set b to be an alias for the underlying type of a
|
|
521
|
-
auto
|
|
522
|
-
|
|
573
|
+
auto inner_type = Catalog::GetType(context, schema->catalog->GetName(), schema->name,
|
|
574
|
+
UserType::GetTypeName(create_type_info.type));
|
|
523
575
|
// clear to nullptr, we don't need this
|
|
524
576
|
LogicalType::SetCatalog(inner_type, nullptr);
|
|
525
577
|
inner_type.SetAlias(create_type_info.name);
|