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
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
#include "duckdb/parser/parsed_data/create_table_info.hpp"
|
|
2
|
+
#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
|
|
3
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
2
4
|
|
|
3
5
|
namespace duckdb {
|
|
4
6
|
|
|
5
7
|
CreateTableInfo::CreateTableInfo() : CreateInfo(CatalogType::TABLE_ENTRY, INVALID_SCHEMA) {
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
CreateTableInfo::CreateTableInfo(string schema_p, string name_p)
|
|
9
|
-
: CreateInfo(CatalogType::TABLE_ENTRY, move(schema_p)), table(move(name_p)) {
|
|
10
|
+
CreateTableInfo::CreateTableInfo(string catalog_p, string schema_p, string name_p)
|
|
11
|
+
: CreateInfo(CatalogType::TABLE_ENTRY, move(schema_p), move(catalog_p)), table(move(name_p)) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
CreateTableInfo::CreateTableInfo(SchemaCatalogEntry *schema, string name_p)
|
|
15
|
+
: CreateTableInfo(schema->catalog->GetName(), schema->name, move(name_p)) {
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
void CreateTableInfo::SerializeInternal(Serializer &serializer) const {
|
|
@@ -33,7 +39,7 @@ unique_ptr<CreateTableInfo> CreateTableInfo::Deserialize(Deserializer &deseriali
|
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
unique_ptr<CreateInfo> CreateTableInfo::Copy() const {
|
|
36
|
-
auto result = make_unique<CreateTableInfo>(schema, table);
|
|
42
|
+
auto result = make_unique<CreateTableInfo>(catalog, schema, table);
|
|
37
43
|
CopyProperties(*result);
|
|
38
44
|
result->columns = columns.Copy();
|
|
39
45
|
for (auto &constraint : constraints) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#include "duckdb/parser/parsed_data/create_view_info.hpp"
|
|
2
|
+
#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
|
|
3
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
4
|
+
|
|
5
|
+
namespace duckdb {
|
|
6
|
+
|
|
7
|
+
CreateViewInfo::CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
8
|
+
}
|
|
9
|
+
CreateViewInfo::CreateViewInfo(string catalog_p, string schema_p, string view_name_p)
|
|
10
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, move(schema_p), move(catalog_p)), view_name(move(view_name_p)) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
CreateViewInfo::CreateViewInfo(SchemaCatalogEntry *schema, string view_name)
|
|
14
|
+
: CreateViewInfo(schema->catalog->GetName(), schema->name, move(view_name)) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
unique_ptr<CreateInfo> CreateViewInfo::Copy() const {
|
|
18
|
+
auto result = make_unique<CreateViewInfo>(catalog, schema, view_name);
|
|
19
|
+
CopyProperties(*result);
|
|
20
|
+
result->aliases = aliases;
|
|
21
|
+
result->types = types;
|
|
22
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23
|
+
return move(result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
unique_ptr<CreateViewInfo> CreateViewInfo::Deserialize(Deserializer &deserializer) {
|
|
27
|
+
auto result = make_unique<CreateViewInfo>();
|
|
28
|
+
result->DeserializeBase(deserializer);
|
|
29
|
+
|
|
30
|
+
FieldReader reader(deserializer);
|
|
31
|
+
result->view_name = reader.ReadRequired<string>();
|
|
32
|
+
result->aliases = reader.ReadRequiredList<string>();
|
|
33
|
+
result->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
|
|
34
|
+
result->query = reader.ReadOptional<SelectStatement>(nullptr);
|
|
35
|
+
reader.Finalize();
|
|
36
|
+
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void CreateViewInfo::SerializeInternal(Serializer &serializer) const {
|
|
41
|
+
FieldWriter writer(serializer);
|
|
42
|
+
writer.WriteString(view_name);
|
|
43
|
+
writer.WriteList<string>(aliases);
|
|
44
|
+
writer.WriteRegularSerializableList(types);
|
|
45
|
+
writer.WriteOptional(query);
|
|
46
|
+
writer.Finalize();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} // namespace duckdb
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include "duckdb/parser/statement/attach_statement.hpp"
|
|
2
|
+
|
|
3
|
+
namespace duckdb {
|
|
4
|
+
|
|
5
|
+
AttachStatement::AttachStatement() : SQLStatement(StatementType::ATTACH_STATEMENT) {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
AttachStatement::AttachStatement(const AttachStatement &other) : SQLStatement(other), info(other.info->Copy()) {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
unique_ptr<SQLStatement> AttachStatement::Copy() const {
|
|
12
|
+
return unique_ptr<AttachStatement>(new AttachStatement(*this));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
} // namespace duckdb
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
namespace duckdb {
|
|
6
6
|
|
|
7
|
-
InsertStatement::InsertStatement()
|
|
7
|
+
InsertStatement::InsertStatement()
|
|
8
|
+
: SQLStatement(StatementType::INSERT_STATEMENT), schema(DEFAULT_SCHEMA), catalog(INVALID_CATALOG) {
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
InsertStatement::InsertStatement(const InsertStatement &other)
|
|
11
12
|
: SQLStatement(other),
|
|
12
13
|
select_statement(unique_ptr_cast<SQLStatement, SelectStatement>(other.select_statement->Copy())),
|
|
13
|
-
columns(other.columns), table(other.table), schema(other.schema) {
|
|
14
|
+
columns(other.columns), table(other.table), schema(other.schema), catalog(other.catalog) {
|
|
14
15
|
cte_map = other.cte_map.Copy();
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -18,6 +19,9 @@ string InsertStatement::ToString() const {
|
|
|
18
19
|
string result;
|
|
19
20
|
result = cte_map.ToString();
|
|
20
21
|
result += "INSERT INTO ";
|
|
22
|
+
if (!catalog.empty()) {
|
|
23
|
+
result += KeywordHelper::WriteOptionallyQuoted(catalog) + ".";
|
|
24
|
+
}
|
|
21
25
|
if (!schema.empty()) {
|
|
22
26
|
result += KeywordHelper::WriteOptionallyQuoted(schema) + ".";
|
|
23
27
|
}
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
namespace duckdb {
|
|
7
7
|
|
|
8
8
|
string BaseTableRef::ToString() const {
|
|
9
|
-
string
|
|
10
|
-
|
|
9
|
+
string result;
|
|
10
|
+
result += catalog_name.empty() ? "" : (KeywordHelper::WriteOptionallyQuoted(catalog_name) + ".");
|
|
11
|
+
result += schema_name.empty() ? "" : (KeywordHelper::WriteOptionallyQuoted(schema_name) + ".");
|
|
12
|
+
result += KeywordHelper::WriteOptionallyQuoted(table_name);
|
|
11
13
|
return BaseToString(result, column_name_alias);
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -16,14 +18,15 @@ bool BaseTableRef::Equals(const TableRef *other_p) const {
|
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
20
|
auto other = (BaseTableRef *)other_p;
|
|
19
|
-
return other->
|
|
20
|
-
column_name_alias == other->column_name_alias;
|
|
21
|
+
return other->catalog_name == catalog_name && other->schema_name == schema_name &&
|
|
22
|
+
other->table_name == table_name && column_name_alias == other->column_name_alias;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
void BaseTableRef::Serialize(FieldWriter &writer) const {
|
|
24
26
|
writer.WriteString(schema_name);
|
|
25
27
|
writer.WriteString(table_name);
|
|
26
28
|
writer.WriteList<string>(column_name_alias);
|
|
29
|
+
writer.WriteString(catalog_name);
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
unique_ptr<TableRef> BaseTableRef::Deserialize(FieldReader &reader) {
|
|
@@ -32,6 +35,7 @@ unique_ptr<TableRef> BaseTableRef::Deserialize(FieldReader &reader) {
|
|
|
32
35
|
result->schema_name = reader.ReadRequired<string>();
|
|
33
36
|
result->table_name = reader.ReadRequired<string>();
|
|
34
37
|
result->column_name_alias = reader.ReadRequiredList<string>();
|
|
38
|
+
result->catalog_name = reader.ReadField<string>(INVALID_CATALOG);
|
|
35
39
|
|
|
36
40
|
return move(result);
|
|
37
41
|
}
|
|
@@ -39,6 +43,7 @@ unique_ptr<TableRef> BaseTableRef::Deserialize(FieldReader &reader) {
|
|
|
39
43
|
unique_ptr<TableRef> BaseTableRef::Copy() {
|
|
40
44
|
auto copy = make_unique<BaseTableRef>();
|
|
41
45
|
|
|
46
|
+
copy->catalog_name = catalog_name;
|
|
42
47
|
copy->schema_name = schema_name;
|
|
43
48
|
copy->table_name = table_name;
|
|
44
49
|
copy->column_name_alias = column_name_alias;
|
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
namespace duckdb {
|
|
7
7
|
|
|
8
|
+
static void ParseSchemaTableNameFK(duckdb_libpgquery::PGRangeVar *input, ForeignKeyInfo &fk_info) {
|
|
9
|
+
if (input->catalogname) {
|
|
10
|
+
throw ParserException("FOREIGN KEY constraints cannot be defined cross-database");
|
|
11
|
+
}
|
|
12
|
+
if (input->schemaname) {
|
|
13
|
+
fk_info.schema = input->schemaname;
|
|
14
|
+
} else {
|
|
15
|
+
fk_info.schema = "";
|
|
16
|
+
};
|
|
17
|
+
fk_info.table = input->relname;
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGListCell *cell) {
|
|
9
21
|
auto constraint = reinterpret_cast<duckdb_libpgquery::PGConstraint *>(cell->data.ptr_value);
|
|
10
22
|
switch (constraint->contype) {
|
|
@@ -27,12 +39,7 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
|
27
39
|
case duckdb_libpgquery::PG_CONSTR_FOREIGN: {
|
|
28
40
|
ForeignKeyInfo fk_info;
|
|
29
41
|
fk_info.type = ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
|
30
|
-
|
|
31
|
-
fk_info.schema = constraint->pktable->schemaname;
|
|
32
|
-
} else {
|
|
33
|
-
fk_info.schema = "";
|
|
34
|
-
}
|
|
35
|
-
fk_info.table = constraint->pktable->relname;
|
|
42
|
+
ParseSchemaTableNameFK(constraint->pktable, fk_info);
|
|
36
43
|
vector<string> pk_columns, fk_columns;
|
|
37
44
|
for (auto kc = constraint->fk_attrs->head; kc; kc = kc->next) {
|
|
38
45
|
fk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
|
@@ -92,14 +99,9 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
|
92
99
|
case duckdb_libpgquery::PG_CONSTR_FOREIGN: {
|
|
93
100
|
ForeignKeyInfo fk_info;
|
|
94
101
|
fk_info.type = ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
|
95
|
-
|
|
96
|
-
fk_info.schema = constraint->pktable->schemaname;
|
|
97
|
-
} else {
|
|
98
|
-
fk_info.schema = "";
|
|
99
|
-
}
|
|
100
|
-
fk_info.table = constraint->pktable->relname;
|
|
101
|
-
vector<string> pk_columns, fk_columns;
|
|
102
|
+
ParseSchemaTableNameFK(constraint->pktable, fk_info);
|
|
102
103
|
|
|
104
|
+
vector<string> pk_columns, fk_columns;
|
|
103
105
|
fk_columns.emplace_back(column.Name().c_str());
|
|
104
106
|
if (constraint->pk_attrs) {
|
|
105
107
|
for (auto kc = constraint->pk_attrs->head; kc; kc = kc->next) {
|
|
@@ -96,15 +96,24 @@ void Transformer::TransformWindowFrame(duckdb_libpgquery::PGWindowDef *window_sp
|
|
|
96
96
|
|
|
97
97
|
unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::PGFuncCall *root) {
|
|
98
98
|
auto name = root->funcname;
|
|
99
|
-
string schema, function_name;
|
|
100
|
-
if (name->length ==
|
|
99
|
+
string catalog, schema, function_name;
|
|
100
|
+
if (name->length == 3) {
|
|
101
|
+
// catalog + schema + name
|
|
102
|
+
catalog = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->data.ptr_value)->val.str;
|
|
103
|
+
schema = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->next->data.ptr_value)->val.str;
|
|
104
|
+
function_name = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->next->next->data.ptr_value)->val.str;
|
|
105
|
+
} else if (name->length == 2) {
|
|
101
106
|
// schema + name
|
|
107
|
+
catalog = INVALID_CATALOG;
|
|
102
108
|
schema = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->data.ptr_value)->val.str;
|
|
103
109
|
function_name = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->next->data.ptr_value)->val.str;
|
|
104
|
-
} else {
|
|
110
|
+
} else if (name->length == 1) {
|
|
105
111
|
// unqualified name
|
|
112
|
+
catalog = INVALID_CATALOG;
|
|
106
113
|
schema = INVALID_SCHEMA;
|
|
107
114
|
function_name = reinterpret_cast<duckdb_libpgquery::PGValue *>(name->head->data.ptr_value)->val.str;
|
|
115
|
+
} else {
|
|
116
|
+
throw InternalException("TransformFuncCall - Expected 1, 2 or 3 qualifications");
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
auto lowercase_name = StringUtil::Lower(function_name);
|
|
@@ -134,7 +143,7 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
|
134
143
|
throw ParserException("IGNORE NULLS is not supported for windowed aggregates");
|
|
135
144
|
}
|
|
136
145
|
|
|
137
|
-
auto expr = make_unique<WindowExpression>(win_fun_type, schema, lowercase_name);
|
|
146
|
+
auto expr = make_unique<WindowExpression>(win_fun_type, move(catalog), move(schema), lowercase_name);
|
|
138
147
|
expr->ignore_nulls = root->agg_ignore_nulls;
|
|
139
148
|
|
|
140
149
|
if (root->agg_filter) {
|
|
@@ -282,8 +291,9 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
|
282
291
|
return move(coalesce_op);
|
|
283
292
|
}
|
|
284
293
|
|
|
285
|
-
auto function = make_unique<FunctionExpression>(schema, lowercase_name.c_str(), move(children),
|
|
286
|
-
move(order_bys), root->agg_distinct, false,
|
|
294
|
+
auto function = make_unique<FunctionExpression>(move(catalog), move(schema), lowercase_name.c_str(), move(children),
|
|
295
|
+
move(filter_expr), move(order_bys), root->agg_distinct, false,
|
|
296
|
+
root->export_state);
|
|
287
297
|
function->query_location = root->location;
|
|
288
298
|
|
|
289
299
|
return move(function);
|
|
@@ -330,7 +340,7 @@ unique_ptr<ParsedExpression> Transformer::TransformSQLValueFunction(duckdb_libpg
|
|
|
330
340
|
D_ASSERT(node);
|
|
331
341
|
vector<unique_ptr<ParsedExpression>> children;
|
|
332
342
|
auto fname = SQLValueOpToString(node->op);
|
|
333
|
-
return make_unique<FunctionExpression>(
|
|
343
|
+
return make_unique<FunctionExpression>(fname, move(children));
|
|
334
344
|
}
|
|
335
345
|
|
|
336
346
|
} // namespace duckdb
|
|
@@ -15,21 +15,17 @@
|
|
|
15
15
|
namespace duckdb {
|
|
16
16
|
|
|
17
17
|
unique_ptr<ParsedExpression> Transformer::TransformUnaryOperator(const string &op, unique_ptr<ParsedExpression> child) {
|
|
18
|
-
const auto schema = DEFAULT_SCHEMA;
|
|
19
|
-
|
|
20
18
|
vector<unique_ptr<ParsedExpression>> children;
|
|
21
19
|
children.push_back(move(child));
|
|
22
20
|
|
|
23
21
|
// built-in operator function
|
|
24
|
-
auto result = make_unique<FunctionExpression>(
|
|
22
|
+
auto result = make_unique<FunctionExpression>(op, move(children));
|
|
25
23
|
result->is_operator = true;
|
|
26
24
|
return move(result);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(const string &op, unique_ptr<ParsedExpression> left,
|
|
30
28
|
unique_ptr<ParsedExpression> right) {
|
|
31
|
-
const auto schema = DEFAULT_SCHEMA;
|
|
32
|
-
|
|
33
29
|
vector<unique_ptr<ParsedExpression>> children;
|
|
34
30
|
children.push_back(move(left));
|
|
35
31
|
children.push_back(move(right));
|
|
@@ -38,7 +34,7 @@ unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(const string &
|
|
|
38
34
|
// rewrite 'asdf' SIMILAR TO '.*sd.*' into regexp_full_match('asdf', '.*sd.*')
|
|
39
35
|
bool invert_similar = op == "!~";
|
|
40
36
|
|
|
41
|
-
auto result = make_unique<FunctionExpression>(
|
|
37
|
+
auto result = make_unique<FunctionExpression>("regexp_full_match", move(children));
|
|
42
38
|
if (invert_similar) {
|
|
43
39
|
return make_unique<OperatorExpression>(ExpressionType::OPERATOR_NOT, move(result));
|
|
44
40
|
} else {
|
|
@@ -51,7 +47,7 @@ unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(const string &
|
|
|
51
47
|
return make_unique<ComparisonExpression>(target_type, move(children[0]), move(children[1]));
|
|
52
48
|
}
|
|
53
49
|
// not a special operator: convert to a function expression
|
|
54
|
-
auto result = make_unique<FunctionExpression>(
|
|
50
|
+
auto result = make_unique<FunctionExpression>(op, move(children));
|
|
55
51
|
result->is_operator = true;
|
|
56
52
|
return move(result);
|
|
57
53
|
}
|
|
@@ -165,9 +161,8 @@ unique_ptr<ParsedExpression> Transformer::TransformAExprInternal(duckdb_libpgque
|
|
|
165
161
|
// NOT SIMILAR TO
|
|
166
162
|
invert_similar = true;
|
|
167
163
|
}
|
|
168
|
-
const auto schema = DEFAULT_SCHEMA;
|
|
169
164
|
const auto regex_function = "regexp_full_match";
|
|
170
|
-
auto result = make_unique<FunctionExpression>(
|
|
165
|
+
auto result = make_unique<FunctionExpression>(regex_function, move(children));
|
|
171
166
|
|
|
172
167
|
if (invert_similar) {
|
|
173
168
|
return make_unique<OperatorExpression>(ExpressionType::OPERATOR_NOT, move(result));
|
|
@@ -812,6 +812,10 @@ std::string Transformer::NodetypeToString(duckdb_libpgquery::PGNodeTag type) { /
|
|
|
812
812
|
return "T_TsmRoutine";
|
|
813
813
|
case duckdb_libpgquery::T_PGForeignKeyCacheInfo:
|
|
814
814
|
return "T_ForeignKeyCacheInfo";
|
|
815
|
+
case duckdb_libpgquery::T_PGAttachStmt:
|
|
816
|
+
return "T_PGAttachStmt";
|
|
817
|
+
case duckdb_libpgquery::T_PGUseStmt:
|
|
818
|
+
return "T_PGUseStmt";
|
|
815
819
|
default:
|
|
816
820
|
return "(UNKNOWN)";
|
|
817
821
|
}
|
|
@@ -13,6 +13,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
|
|
|
13
13
|
auto result = make_unique<AlterStatement>();
|
|
14
14
|
|
|
15
15
|
auto qname = TransformQualifiedName(stmt->sequence);
|
|
16
|
+
auto sequence_catalog = qname.catalog;
|
|
16
17
|
auto sequence_schema = qname.schema;
|
|
17
18
|
auto sequence_name = qname.name;
|
|
18
19
|
|
|
@@ -48,8 +49,8 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
|
|
|
48
49
|
opt_values.emplace_back(target->name);
|
|
49
50
|
}
|
|
50
51
|
D_ASSERT(!opt_values.empty());
|
|
51
|
-
string owner_schema =
|
|
52
|
-
string owner_name
|
|
52
|
+
string owner_schema = INVALID_SCHEMA;
|
|
53
|
+
string owner_name;
|
|
53
54
|
if (opt_values.size() == 2) {
|
|
54
55
|
owner_schema = opt_values[0];
|
|
55
56
|
owner_name = opt_values[1];
|
|
@@ -59,8 +60,8 @@ unique_ptr<AlterStatement> Transformer::TransformAlterSequence(duckdb_libpgquery
|
|
|
59
60
|
} else {
|
|
60
61
|
throw InternalException("Wrong argument for %s. Expected either <schema>.<name> or <name>", opt_name);
|
|
61
62
|
}
|
|
62
|
-
auto info = make_unique<ChangeOwnershipInfo>(CatalogType::SEQUENCE_ENTRY,
|
|
63
|
-
owner_schema, owner_name, stmt->missing_ok);
|
|
63
|
+
auto info = make_unique<ChangeOwnershipInfo>(CatalogType::SEQUENCE_ENTRY, sequence_catalog, sequence_schema,
|
|
64
|
+
sequence_name, owner_schema, owner_name, stmt->missing_ok);
|
|
64
65
|
result->info = move(info);
|
|
65
66
|
} else {
|
|
66
67
|
throw NotImplementedException("ALTER SEQUENCE option not supported yet!");
|
|
@@ -21,6 +21,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
|
21
21
|
// first we check the type of ALTER
|
|
22
22
|
for (auto c = stmt->cmds->head; c != nullptr; c = c->next) {
|
|
23
23
|
auto command = reinterpret_cast<duckdb_libpgquery::PGAlterTableCmd *>(lfirst(c));
|
|
24
|
+
AlterEntryData data(qname.catalog, qname.schema, qname.name, stmt->missing_ok);
|
|
24
25
|
// TODO: Include more options for command->subtype
|
|
25
26
|
switch (command->subtype) {
|
|
26
27
|
case duckdb_libpgquery::PG_AT_AddColumn: {
|
|
@@ -43,8 +44,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
|
43
44
|
throw ParserException("Adding columns with constraints not yet supported");
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
result->info = make_unique<AddColumnInfo>(
|
|
47
|
-
command->missing_ok);
|
|
47
|
+
result->info = make_unique<AddColumnInfo>(move(data), move(centry), command->missing_ok);
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
case duckdb_libpgquery::PG_AT_DropColumn: {
|
|
@@ -53,8 +53,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
|
53
53
|
if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
|
|
54
54
|
throw ParserException("Dropping columns is only supported for tables");
|
|
55
55
|
}
|
|
56
|
-
result->info = make_unique<RemoveColumnInfo>(
|
|
57
|
-
command->missing_ok, cascade);
|
|
56
|
+
result->info = make_unique<RemoveColumnInfo>(move(data), command->name, command->missing_ok, cascade);
|
|
58
57
|
break;
|
|
59
58
|
}
|
|
60
59
|
case duckdb_libpgquery::PG_AT_ColumnDefault: {
|
|
@@ -63,8 +62,7 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
|
63
62
|
if (stmt->relkind != duckdb_libpgquery::PG_OBJECT_TABLE) {
|
|
64
63
|
throw ParserException("Alter column's default is only supported for tables");
|
|
65
64
|
}
|
|
66
|
-
result->info =
|
|
67
|
-
make_unique<SetDefaultInfo>(qname.schema, qname.name, stmt->missing_ok, command->name, move(expr));
|
|
65
|
+
result->info = make_unique<SetDefaultInfo>(move(data), command->name, move(expr));
|
|
68
66
|
break;
|
|
69
67
|
}
|
|
70
68
|
case duckdb_libpgquery::PG_AT_AlterColumnType: {
|
|
@@ -81,16 +79,16 @@ unique_ptr<AlterStatement> Transformer::TransformAlter(duckdb_libpgquery::PGNode
|
|
|
81
79
|
auto colref = make_unique<ColumnRefExpression>(command->name);
|
|
82
80
|
expr = make_unique<CastExpression>(column_definition.Type(), move(colref));
|
|
83
81
|
}
|
|
84
|
-
result->info =
|
|
85
|
-
|
|
82
|
+
result->info =
|
|
83
|
+
make_unique<ChangeColumnTypeInfo>(move(data), command->name, column_definition.Type(), move(expr));
|
|
86
84
|
break;
|
|
87
85
|
}
|
|
88
86
|
case duckdb_libpgquery::PG_AT_SetNotNull: {
|
|
89
|
-
result->info = make_unique<SetNotNullInfo>(
|
|
87
|
+
result->info = make_unique<SetNotNullInfo>(move(data), command->name);
|
|
90
88
|
break;
|
|
91
89
|
}
|
|
92
90
|
case duckdb_libpgquery::PG_AT_DropNotNull: {
|
|
93
|
-
result->info = make_unique<DropNotNullInfo>(
|
|
91
|
+
result->info = make_unique<DropNotNullInfo>(move(data), command->name);
|
|
94
92
|
break;
|
|
95
93
|
}
|
|
96
94
|
case duckdb_libpgquery::PG_AT_DropConstraint:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#include "duckdb/parser/transformer.hpp"
|
|
2
|
+
#include "duckdb/parser/statement/attach_statement.hpp"
|
|
3
|
+
#include "duckdb/parser/expression/constant_expression.hpp"
|
|
4
|
+
#include "duckdb/common/string_util.hpp"
|
|
5
|
+
|
|
6
|
+
namespace duckdb {
|
|
7
|
+
|
|
8
|
+
unique_ptr<AttachStatement> Transformer::TransformAttach(duckdb_libpgquery::PGNode *node) {
|
|
9
|
+
auto stmt = reinterpret_cast<duckdb_libpgquery::PGAttachStmt *>(node);
|
|
10
|
+
auto result = make_unique<AttachStatement>();
|
|
11
|
+
auto info = make_unique<AttachInfo>();
|
|
12
|
+
info->name = stmt->name ? stmt->name : string();
|
|
13
|
+
info->path = stmt->path;
|
|
14
|
+
|
|
15
|
+
if (stmt->options) {
|
|
16
|
+
duckdb_libpgquery::PGListCell *cell = nullptr;
|
|
17
|
+
for_each_cell(cell, stmt->options->head) {
|
|
18
|
+
auto *def_elem = reinterpret_cast<duckdb_libpgquery::PGDefElem *>(cell->data.ptr_value);
|
|
19
|
+
Value val;
|
|
20
|
+
if (def_elem->arg) {
|
|
21
|
+
val = TransformValue(*((duckdb_libpgquery::PGValue *)def_elem->arg))->value;
|
|
22
|
+
} else {
|
|
23
|
+
val = Value::BOOLEAN(true);
|
|
24
|
+
}
|
|
25
|
+
info->options[StringUtil::Lower(def_elem->defname)] = move(val);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
result->info = move(info);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // namespace duckdb
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include "duckdb/parser/transformer.hpp"
|
|
2
2
|
#include "duckdb/parser/expression/function_expression.hpp"
|
|
3
3
|
#include "duckdb/parser/statement/call_statement.hpp"
|
|
4
|
+
#include "duckdb/parser/expression/constant_expression.hpp"
|
|
4
5
|
|
|
5
6
|
namespace duckdb {
|
|
6
7
|
|
|
@@ -9,9 +10,13 @@ unique_ptr<SQLStatement> Transformer::TransformCheckpoint(duckdb_libpgquery::PGN
|
|
|
9
10
|
|
|
10
11
|
vector<unique_ptr<ParsedExpression>> children;
|
|
11
12
|
// transform into "CALL checkpoint()" or "CALL force_checkpoint()"
|
|
13
|
+
auto checkpoint_name = checkpoint->force ? "force_checkpoint" : "checkpoint";
|
|
12
14
|
auto result = make_unique<CallStatement>();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
auto function = make_unique<FunctionExpression>(checkpoint_name, move(children));
|
|
16
|
+
if (checkpoint->name) {
|
|
17
|
+
function->children.push_back(make_unique<ConstantExpression>(Value(checkpoint->name)));
|
|
18
|
+
}
|
|
19
|
+
result->function = move(function);
|
|
15
20
|
return move(result);
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -91,6 +91,7 @@ unique_ptr<CopyStatement> Transformer::TransformCopy(duckdb_libpgquery::PGNode *
|
|
|
91
91
|
auto &table = *reinterpret_cast<BaseTableRef *>(ref.get());
|
|
92
92
|
info.table = table.table_name;
|
|
93
93
|
info.schema = table.schema_name;
|
|
94
|
+
info.catalog = table.catalog_name;
|
|
94
95
|
} else {
|
|
95
96
|
result->select_statement = TransformSelectNode((duckdb_libpgquery::PGSelectStmt *)stmt->query);
|
|
96
97
|
}
|
|
@@ -32,6 +32,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateFunction(duckdb_libpgque
|
|
|
32
32
|
|
|
33
33
|
auto info =
|
|
34
34
|
make_unique<CreateMacroInfo>((stmt->function ? CatalogType::MACRO_ENTRY : CatalogType::TABLE_MACRO_ENTRY));
|
|
35
|
+
info->catalog = qname.catalog;
|
|
35
36
|
info->schema = qname.schema;
|
|
36
37
|
info->name = qname.name;
|
|
37
38
|
|
|
@@ -11,6 +11,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateSchema(duckdb_libpgquery
|
|
|
11
11
|
auto info = make_unique<CreateSchemaInfo>();
|
|
12
12
|
|
|
13
13
|
D_ASSERT(stmt->schemaname);
|
|
14
|
+
info->catalog = stmt->catalogname ? stmt->catalogname : INVALID_CATALOG;
|
|
14
15
|
info->schema = stmt->schemaname;
|
|
15
16
|
info->on_conflict = TransformOnConflict(stmt->onconflict);
|
|
16
17
|
|
|
@@ -14,6 +14,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateSequence(duckdb_libpgque
|
|
|
14
14
|
auto info = make_unique<CreateSequenceInfo>();
|
|
15
15
|
|
|
16
16
|
auto qname = TransformQualifiedName(stmt->sequence);
|
|
17
|
+
info->catalog = qname.catalog;
|
|
17
18
|
info->schema = qname.schema;
|
|
18
19
|
info->name = qname.name;
|
|
19
20
|
|
|
@@ -78,11 +78,11 @@ unique_ptr<CreateStatement> Transformer::TransformCreateTable(duckdb_libpgquery:
|
|
|
78
78
|
}
|
|
79
79
|
D_ASSERT(stmt->relation);
|
|
80
80
|
|
|
81
|
-
info->
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
info->table =
|
|
81
|
+
info->catalog = INVALID_CATALOG;
|
|
82
|
+
auto qname = TransformQualifiedName(stmt->relation);
|
|
83
|
+
info->catalog = qname.catalog;
|
|
84
|
+
info->schema = qname.schema;
|
|
85
|
+
info->table = qname.name;
|
|
86
86
|
info->on_conflict = TransformOnConflict(stmt->onconflict);
|
|
87
87
|
info->temporary =
|
|
88
88
|
stmt->relation->relpersistence == duckdb_libpgquery::PGPostgresRelPersistence::PG_RELPERSISTENCE_TEMP;
|
|
@@ -21,6 +21,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateTableAs(duckdb_libpgquer
|
|
|
21
21
|
|
|
22
22
|
auto result = make_unique<CreateStatement>();
|
|
23
23
|
auto info = make_unique<CreateTableInfo>();
|
|
24
|
+
info->catalog = qname.catalog;
|
|
24
25
|
info->schema = qname.schema;
|
|
25
26
|
info->table = qname.name;
|
|
26
27
|
info->on_conflict = TransformOnConflict(stmt->onconflict);
|
|
@@ -6,18 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
namespace duckdb {
|
|
8
8
|
|
|
9
|
-
vector<string> ReadPgListToString(duckdb_libpgquery::PGList *column_list) {
|
|
10
|
-
vector<string> result;
|
|
11
|
-
if (!column_list) {
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
for (auto c = column_list->head; c != nullptr; c = lnext(c)) {
|
|
15
|
-
auto target = (duckdb_libpgquery::PGResTarget *)(c->data.ptr_value);
|
|
16
|
-
result.emplace_back(target->name);
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
Vector ReadPgListToVector(duckdb_libpgquery::PGList *column_list, idx_t &size) {
|
|
22
10
|
if (!column_list) {
|
|
23
11
|
Vector result(LogicalType::VARCHAR);
|
|
@@ -51,7 +39,12 @@ unique_ptr<CreateStatement> Transformer::TransformCreateType(duckdb_libpgquery::
|
|
|
51
39
|
D_ASSERT(stmt);
|
|
52
40
|
auto result = make_unique<CreateStatement>();
|
|
53
41
|
auto info = make_unique<CreateTypeInfo>();
|
|
54
|
-
|
|
42
|
+
|
|
43
|
+
auto qualified_name = TransformQualifiedName(stmt->typeName);
|
|
44
|
+
info->catalog = qualified_name.catalog;
|
|
45
|
+
info->schema = qualified_name.schema;
|
|
46
|
+
info->name = qualified_name.name;
|
|
47
|
+
|
|
55
48
|
switch (stmt->kind) {
|
|
56
49
|
case duckdb_libpgquery::PG_NEWTYPE_ENUM: {
|
|
57
50
|
info->internal = false;
|
|
@@ -15,13 +15,13 @@ unique_ptr<CreateStatement> Transformer::TransformCreateView(duckdb_libpgquery::
|
|
|
15
15
|
auto result = make_unique<CreateStatement>();
|
|
16
16
|
auto info = make_unique<CreateViewInfo>();
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
info->view_name =
|
|
18
|
+
auto qname = TransformQualifiedName(stmt->view);
|
|
19
|
+
info->catalog = qname.catalog;
|
|
20
|
+
info->schema = qname.schema;
|
|
21
|
+
info->view_name = qname.name;
|
|
22
22
|
info->temporary = !stmt->view->relpersistence;
|
|
23
|
-
if (info->temporary) {
|
|
24
|
-
info->
|
|
23
|
+
if (info->temporary && IsInvalidCatalog(info->catalog)) {
|
|
24
|
+
info->catalog = TEMP_CATALOG;
|
|
25
25
|
}
|
|
26
26
|
info->on_conflict = TransformOnConflict(stmt->onconflict);
|
|
27
27
|
|
|
@@ -36,6 +36,9 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGNode *n
|
|
|
36
36
|
case duckdb_libpgquery::PG_OBJECT_TYPE:
|
|
37
37
|
info.type = CatalogType::TYPE_ENTRY;
|
|
38
38
|
break;
|
|
39
|
+
case duckdb_libpgquery::PG_OBJECT_DATABASE:
|
|
40
|
+
info.type = CatalogType::DATABASE_ENTRY;
|
|
41
|
+
break;
|
|
39
42
|
default:
|
|
40
43
|
throw NotImplementedException("Cannot drop this type yet");
|
|
41
44
|
}
|
|
@@ -52,11 +55,17 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGNode *n
|
|
|
52
55
|
}
|
|
53
56
|
default: {
|
|
54
57
|
auto view_list = (duckdb_libpgquery::PGList *)stmt->objects->head->data.ptr_value;
|
|
55
|
-
if (view_list->length ==
|
|
58
|
+
if (view_list->length == 3) {
|
|
59
|
+
info.catalog = ((duckdb_libpgquery::PGValue *)view_list->head->data.ptr_value)->val.str;
|
|
60
|
+
info.schema = ((duckdb_libpgquery::PGValue *)view_list->head->next->data.ptr_value)->val.str;
|
|
61
|
+
info.name = ((duckdb_libpgquery::PGValue *)view_list->head->next->next->data.ptr_value)->val.str;
|
|
62
|
+
} else if (view_list->length == 2) {
|
|
56
63
|
info.schema = ((duckdb_libpgquery::PGValue *)view_list->head->data.ptr_value)->val.str;
|
|
57
64
|
info.name = ((duckdb_libpgquery::PGValue *)view_list->head->next->data.ptr_value)->val.str;
|
|
58
|
-
} else {
|
|
65
|
+
} else if (view_list->length == 1) {
|
|
59
66
|
info.name = ((duckdb_libpgquery::PGValue *)view_list->head->data.ptr_value)->val.str;
|
|
67
|
+
} else {
|
|
68
|
+
throw ParserException("Expected \"catalog.schema.name\", \"schema.name\"or \"name\"");
|
|
60
69
|
}
|
|
61
70
|
break;
|
|
62
71
|
}
|
|
@@ -12,7 +12,11 @@ unique_ptr<ExportStatement> Transformer::TransformExport(duckdb_libpgquery::PGNo
|
|
|
12
12
|
// handle export options
|
|
13
13
|
TransformCopyOptions(*info, stmt->options);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
auto result = make_unique<ExportStatement>(move(info));
|
|
16
|
+
if (stmt->database) {
|
|
17
|
+
result->database = stmt->database;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
} // namespace duckdb
|