duckdb 0.6.2-dev781.0 → 0.6.2-dev891.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/column_reader.cpp +7 -0
- 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/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
|
@@ -63,9 +63,27 @@ void CatalogSet::PutEntry(EntryIndex index, unique_ptr<CatalogEntry> catalog_ent
|
|
|
63
63
|
entry->second.entry = move(catalog_entry);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
bool CatalogSet::CreateEntry(
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name, unique_ptr<CatalogEntry> value,
|
|
67
|
+
DependencyList &dependencies) {
|
|
68
|
+
if (value->internal && !catalog.IsSystemCatalog() && name != DEFAULT_SCHEMA) {
|
|
69
|
+
throw InternalException("Attempting to create internal entry \"%s\" in non-system catalog - internal entries "
|
|
70
|
+
"can only be created in the system catalog",
|
|
71
|
+
name);
|
|
72
|
+
}
|
|
73
|
+
if (!value->internal) {
|
|
74
|
+
if (!value->temporary && catalog.IsSystemCatalog()) {
|
|
75
|
+
throw InternalException(
|
|
76
|
+
"Attempting to create non-internal entry \"%s\" in system catalog - the system catalog "
|
|
77
|
+
"can only contain internal entries",
|
|
78
|
+
name);
|
|
79
|
+
}
|
|
80
|
+
if (value->temporary && !catalog.IsTemporaryCatalog()) {
|
|
81
|
+
throw InternalException("Attempting to create temporary entry \"%s\" in non-temporary catalog", name);
|
|
82
|
+
}
|
|
83
|
+
if (!value->temporary && catalog.IsTemporaryCatalog() && name != DEFAULT_SCHEMA) {
|
|
84
|
+
throw InternalException("Attempting to create non-temporary entry \"%s\" in temporary catalog", name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
69
87
|
// lock the catalog for writing
|
|
70
88
|
lock_guard<mutex> write_lock(catalog.write_lock);
|
|
71
89
|
// lock this catalog set to disallow reading
|
|
@@ -73,12 +91,12 @@ bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_
|
|
|
73
91
|
|
|
74
92
|
// first check if the entry exists in the unordered set
|
|
75
93
|
idx_t index;
|
|
76
|
-
auto mapping_value = GetMapping(
|
|
94
|
+
auto mapping_value = GetMapping(transaction, name);
|
|
77
95
|
if (mapping_value == nullptr || mapping_value->deleted) {
|
|
78
96
|
// if it does not: entry has never been created
|
|
79
97
|
|
|
80
98
|
// check if there is a default entry
|
|
81
|
-
auto entry = CreateDefaultEntry(
|
|
99
|
+
auto entry = CreateDefaultEntry(transaction, name, read_lock);
|
|
82
100
|
if (entry) {
|
|
83
101
|
return false;
|
|
84
102
|
}
|
|
@@ -93,12 +111,12 @@ bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_
|
|
|
93
111
|
|
|
94
112
|
auto entry_index = PutEntry(current_entry++, move(dummy_node));
|
|
95
113
|
index = entry_index.GetIndex();
|
|
96
|
-
PutMapping(
|
|
114
|
+
PutMapping(transaction, name, move(entry_index));
|
|
97
115
|
} else {
|
|
98
116
|
index = mapping_value->index.GetIndex();
|
|
99
117
|
auto ¤t = *mapping_value->index.GetEntry();
|
|
100
118
|
// if it does, we have to check version numbers
|
|
101
|
-
if (HasConflict(
|
|
119
|
+
if (HasConflict(transaction, current.timestamp)) {
|
|
102
120
|
// current version has been written to by a currently active
|
|
103
121
|
// transaction
|
|
104
122
|
throw TransactionException("Catalog write-write conflict on create with \"%s\"", current.name);
|
|
@@ -116,20 +134,28 @@ bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_
|
|
|
116
134
|
value->set = this;
|
|
117
135
|
|
|
118
136
|
// now add the dependency set of this object to the dependency manager
|
|
119
|
-
catalog.dependency_manager->AddObject(
|
|
137
|
+
catalog.dependency_manager->AddObject(transaction, value.get(), dependencies);
|
|
120
138
|
|
|
121
139
|
auto value_ptr = value.get();
|
|
122
140
|
EntryIndex entry_index(*this, index);
|
|
123
141
|
PutEntry(move(entry_index), move(value));
|
|
124
142
|
// push the old entry in the undo buffer for this transaction
|
|
125
|
-
transaction.
|
|
143
|
+
if (transaction.transaction) {
|
|
144
|
+
transaction.transaction->PushCatalogEntry(value_ptr->child.get());
|
|
145
|
+
}
|
|
126
146
|
return true;
|
|
127
147
|
}
|
|
128
148
|
|
|
129
|
-
bool CatalogSet::
|
|
149
|
+
bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
|
|
150
|
+
DependencyList &dependencies) {
|
|
151
|
+
return CreateEntry(catalog.GetCatalogTransaction(context), name, move(value), dependencies);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
bool CatalogSet::GetEntryInternal(CatalogTransaction transaction, EntryIndex &entry_index,
|
|
155
|
+
CatalogEntry *&catalog_entry) {
|
|
130
156
|
catalog_entry = entry_index.GetEntry().get();
|
|
131
157
|
// if it does: we have to retrieve the entry and to check version numbers
|
|
132
|
-
if (HasConflict(
|
|
158
|
+
if (HasConflict(transaction, catalog_entry->timestamp)) {
|
|
133
159
|
// current version has been written to by a currently active
|
|
134
160
|
// transaction
|
|
135
161
|
throw TransactionException("Catalog write-write conflict on alter with \"%s\"", catalog_entry->name);
|
|
@@ -143,9 +169,9 @@ bool CatalogSet::GetEntryInternal(ClientContext &context, EntryIndex &entry_inde
|
|
|
143
169
|
return true;
|
|
144
170
|
}
|
|
145
171
|
|
|
146
|
-
bool CatalogSet::GetEntryInternal(
|
|
172
|
+
bool CatalogSet::GetEntryInternal(CatalogTransaction transaction, const string &name, EntryIndex *entry_index,
|
|
147
173
|
CatalogEntry *&catalog_entry) {
|
|
148
|
-
auto mapping_value = GetMapping(
|
|
174
|
+
auto mapping_value = GetMapping(transaction, name);
|
|
149
175
|
if (mapping_value == nullptr || mapping_value->deleted) {
|
|
150
176
|
// the entry does not exist, check if we can create a default entry
|
|
151
177
|
return false;
|
|
@@ -153,34 +179,33 @@ bool CatalogSet::GetEntryInternal(ClientContext &context, const string &name, En
|
|
|
153
179
|
if (entry_index) {
|
|
154
180
|
*entry_index = mapping_value->index.Copy();
|
|
155
181
|
}
|
|
156
|
-
return GetEntryInternal(
|
|
182
|
+
return GetEntryInternal(transaction, mapping_value->index, catalog_entry);
|
|
157
183
|
}
|
|
158
184
|
|
|
159
|
-
bool CatalogSet::AlterOwnership(
|
|
185
|
+
bool CatalogSet::AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo *info) {
|
|
160
186
|
CatalogEntry *entry;
|
|
161
|
-
if (!GetEntryInternal(
|
|
187
|
+
if (!GetEntryInternal(transaction, info->name, nullptr, entry)) {
|
|
162
188
|
return false;
|
|
163
189
|
}
|
|
164
190
|
|
|
165
|
-
auto owner_entry = catalog.GetEntry(
|
|
191
|
+
auto owner_entry = catalog.GetEntry(transaction.GetContext(), info->owner_schema, info->owner_name);
|
|
166
192
|
if (!owner_entry) {
|
|
167
193
|
return false;
|
|
168
194
|
}
|
|
169
195
|
|
|
170
|
-
catalog.dependency_manager->AddOwnership(
|
|
196
|
+
catalog.dependency_manager->AddOwnership(transaction, owner_entry, entry);
|
|
171
197
|
|
|
172
198
|
return true;
|
|
173
199
|
}
|
|
174
200
|
|
|
175
|
-
bool CatalogSet::AlterEntry(
|
|
176
|
-
auto &transaction = Transaction::GetTransaction(context);
|
|
201
|
+
bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo *alter_info) {
|
|
177
202
|
// lock the catalog for writing
|
|
178
203
|
lock_guard<mutex> write_lock(catalog.write_lock);
|
|
179
204
|
|
|
180
205
|
// first check if the entry exists in the unordered set
|
|
181
206
|
EntryIndex entry_index;
|
|
182
207
|
CatalogEntry *entry;
|
|
183
|
-
if (!GetEntryInternal(
|
|
208
|
+
if (!GetEntryInternal(transaction, name, &entry_index, entry)) {
|
|
184
209
|
return false;
|
|
185
210
|
}
|
|
186
211
|
if (!alter_info->allow_internal && entry->internal) {
|
|
@@ -194,6 +219,10 @@ bool CatalogSet::AlterEntry(ClientContext &context, const string &name, AlterInf
|
|
|
194
219
|
// set the timestamp to the timestamp of the current transaction
|
|
195
220
|
// and point it to the updated table node
|
|
196
221
|
string original_name = entry->name;
|
|
222
|
+
if (!transaction.context) {
|
|
223
|
+
throw InternalException("Cannot AlterEntry without client context");
|
|
224
|
+
}
|
|
225
|
+
auto &context = *transaction.context;
|
|
197
226
|
auto value = entry->AlterEntry(context, alter_info);
|
|
198
227
|
if (!value) {
|
|
199
228
|
// alter failed, but did not result in an error
|
|
@@ -201,9 +230,9 @@ bool CatalogSet::AlterEntry(ClientContext &context, const string &name, AlterInf
|
|
|
201
230
|
}
|
|
202
231
|
|
|
203
232
|
if (value->name != original_name) {
|
|
204
|
-
auto mapping_value = GetMapping(
|
|
233
|
+
auto mapping_value = GetMapping(transaction, value->name);
|
|
205
234
|
if (mapping_value && !mapping_value->deleted) {
|
|
206
|
-
auto original_entry = GetEntryForTransaction(
|
|
235
|
+
auto original_entry = GetEntryForTransaction(transaction, mapping_value->index.GetEntry().get());
|
|
207
236
|
if (!original_entry->deleted) {
|
|
208
237
|
entry->UndoAlter(context, alter_info);
|
|
209
238
|
string rename_err_msg =
|
|
@@ -215,8 +244,8 @@ bool CatalogSet::AlterEntry(ClientContext &context, const string &name, AlterInf
|
|
|
215
244
|
|
|
216
245
|
if (value->name != original_name) {
|
|
217
246
|
// Do PutMapping and DeleteMapping after dependency check
|
|
218
|
-
PutMapping(
|
|
219
|
-
DeleteMapping(
|
|
247
|
+
PutMapping(transaction, value->name, entry_index.Copy());
|
|
248
|
+
DeleteMapping(transaction, original_name);
|
|
220
249
|
}
|
|
221
250
|
|
|
222
251
|
value->timestamp = transaction.transaction_id;
|
|
@@ -230,18 +259,21 @@ bool CatalogSet::AlterEntry(ClientContext &context, const string &name, AlterInf
|
|
|
230
259
|
BinaryData serialized_alter = serializer.GetData();
|
|
231
260
|
|
|
232
261
|
// push the old entry in the undo buffer for this transaction
|
|
233
|
-
transaction.
|
|
262
|
+
if (transaction.transaction) {
|
|
263
|
+
transaction.transaction->PushCatalogEntry(new_entry->child.get(), serialized_alter.data.get(),
|
|
264
|
+
serialized_alter.size);
|
|
265
|
+
}
|
|
234
266
|
|
|
235
267
|
// Check the dependency manager to verify that there are no conflicting dependencies with this alter
|
|
236
268
|
// Note that we do this AFTER the new entry has been entirely set up in the catalog set
|
|
237
269
|
// that is because in case the alter fails because of a dependency conflict, we need to be able to cleanly roll back
|
|
238
270
|
// to the old entry.
|
|
239
|
-
catalog.dependency_manager->AlterObject(
|
|
271
|
+
catalog.dependency_manager->AlterObject(transaction, entry, new_entry);
|
|
240
272
|
|
|
241
273
|
return true;
|
|
242
274
|
}
|
|
243
275
|
|
|
244
|
-
void CatalogSet::DropEntryDependencies(
|
|
276
|
+
void CatalogSet::DropEntryDependencies(CatalogTransaction transaction, EntryIndex &entry_index, CatalogEntry &entry,
|
|
245
277
|
bool cascade) {
|
|
246
278
|
// Stores the deleted value of the entry before starting the process
|
|
247
279
|
EntryDropper dropper(entry_index);
|
|
@@ -250,17 +282,16 @@ void CatalogSet::DropEntryDependencies(ClientContext &context, EntryIndex &entry
|
|
|
250
282
|
entry_index.GetEntry()->deleted = true;
|
|
251
283
|
|
|
252
284
|
// check any dependencies of this object
|
|
253
|
-
entry.catalog->dependency_manager->DropObject(
|
|
285
|
+
entry.catalog->dependency_manager->DropObject(transaction, &entry, cascade);
|
|
254
286
|
|
|
255
287
|
// dropper destructor is called here
|
|
256
288
|
// the destructor makes sure to return the value to the previous state
|
|
257
289
|
// dropper.~EntryDropper()
|
|
258
290
|
}
|
|
259
291
|
|
|
260
|
-
void CatalogSet::DropEntryInternal(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
DropEntryDependencies(context, entry_index, entry, cascade);
|
|
292
|
+
void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex entry_index, CatalogEntry &entry,
|
|
293
|
+
bool cascade) {
|
|
294
|
+
DropEntryDependencies(transaction, entry_index, entry, cascade);
|
|
264
295
|
|
|
265
296
|
// create a new entry and replace the currently stored one
|
|
266
297
|
// set the timestamp to the timestamp of the current transaction
|
|
@@ -273,27 +304,37 @@ void CatalogSet::DropEntryInternal(ClientContext &context, EntryIndex entry_inde
|
|
|
273
304
|
PutEntry(move(entry_index), move(value));
|
|
274
305
|
|
|
275
306
|
// push the old entry in the undo buffer for this transaction
|
|
276
|
-
transaction.
|
|
307
|
+
if (transaction.transaction) {
|
|
308
|
+
transaction.transaction->PushCatalogEntry(value_ptr->child.get());
|
|
309
|
+
}
|
|
277
310
|
}
|
|
278
311
|
|
|
279
|
-
bool CatalogSet::DropEntry(
|
|
312
|
+
bool CatalogSet::DropEntry(CatalogTransaction transaction, const string &name, bool cascade, bool allow_drop_internal) {
|
|
280
313
|
// lock the catalog for writing
|
|
281
314
|
lock_guard<mutex> write_lock(catalog.write_lock);
|
|
282
315
|
// we can only delete an entry that exists
|
|
283
316
|
EntryIndex entry_index;
|
|
284
317
|
CatalogEntry *entry;
|
|
285
|
-
if (!GetEntryInternal(
|
|
318
|
+
if (!GetEntryInternal(transaction, name, &entry_index, entry)) {
|
|
286
319
|
return false;
|
|
287
320
|
}
|
|
288
|
-
if (entry->internal) {
|
|
321
|
+
if (entry->internal && !allow_drop_internal) {
|
|
289
322
|
throw CatalogException("Cannot drop entry \"%s\" because it is an internal system entry", entry->name);
|
|
290
323
|
}
|
|
291
324
|
|
|
292
325
|
lock_guard<mutex> read_lock(catalog_lock);
|
|
293
|
-
DropEntryInternal(
|
|
326
|
+
DropEntryInternal(transaction, move(entry_index), *entry, cascade);
|
|
294
327
|
return true;
|
|
295
328
|
}
|
|
296
329
|
|
|
330
|
+
bool CatalogSet::DropEntry(ClientContext &context, const string &name, bool cascade, bool allow_drop_internal) {
|
|
331
|
+
return DropEntry(catalog.GetCatalogTransaction(context), name, cascade, allow_drop_internal);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
Catalog &CatalogSet::GetCatalog() {
|
|
335
|
+
return catalog;
|
|
336
|
+
}
|
|
337
|
+
|
|
297
338
|
void CatalogSet::CleanupEntry(CatalogEntry *catalog_entry) {
|
|
298
339
|
// destroy the backed up entry: it is no longer required
|
|
299
340
|
D_ASSERT(catalog_entry->parent);
|
|
@@ -318,13 +359,12 @@ void CatalogSet::CleanupEntry(CatalogEntry *catalog_entry) {
|
|
|
318
359
|
}
|
|
319
360
|
}
|
|
320
361
|
|
|
321
|
-
bool CatalogSet::HasConflict(
|
|
322
|
-
auto &transaction = Transaction::GetTransaction(context);
|
|
362
|
+
bool CatalogSet::HasConflict(CatalogTransaction transaction, transaction_t timestamp) {
|
|
323
363
|
return (timestamp >= TRANSACTION_ID_START && timestamp != transaction.transaction_id) ||
|
|
324
364
|
(timestamp < TRANSACTION_ID_START && timestamp > transaction.start_time);
|
|
325
365
|
}
|
|
326
366
|
|
|
327
|
-
MappingValue *CatalogSet::GetMapping(
|
|
367
|
+
MappingValue *CatalogSet::GetMapping(CatalogTransaction transaction, const string &name, bool get_latest) {
|
|
328
368
|
MappingValue *mapping_value;
|
|
329
369
|
auto entry = mapping.find(name);
|
|
330
370
|
if (entry != mapping.end()) {
|
|
@@ -337,7 +377,7 @@ MappingValue *CatalogSet::GetMapping(ClientContext &context, const string &name,
|
|
|
337
377
|
return mapping_value;
|
|
338
378
|
}
|
|
339
379
|
while (mapping_value->child) {
|
|
340
|
-
if (UseTimestamp(
|
|
380
|
+
if (UseTimestamp(transaction, mapping_value->timestamp)) {
|
|
341
381
|
break;
|
|
342
382
|
}
|
|
343
383
|
mapping_value = mapping_value->child.get();
|
|
@@ -346,12 +386,12 @@ MappingValue *CatalogSet::GetMapping(ClientContext &context, const string &name,
|
|
|
346
386
|
return mapping_value;
|
|
347
387
|
}
|
|
348
388
|
|
|
349
|
-
void CatalogSet::PutMapping(
|
|
389
|
+
void CatalogSet::PutMapping(CatalogTransaction transaction, const string &name, EntryIndex entry_index) {
|
|
350
390
|
auto entry = mapping.find(name);
|
|
351
391
|
auto new_value = make_unique<MappingValue>(move(entry_index));
|
|
352
|
-
new_value->timestamp =
|
|
392
|
+
new_value->timestamp = transaction.transaction_id;
|
|
353
393
|
if (entry != mapping.end()) {
|
|
354
|
-
if (HasConflict(
|
|
394
|
+
if (HasConflict(transaction, entry->second->timestamp)) {
|
|
355
395
|
throw TransactionException("Catalog write-write conflict on name \"%s\"", name);
|
|
356
396
|
}
|
|
357
397
|
new_value->child = move(entry->second);
|
|
@@ -360,19 +400,18 @@ void CatalogSet::PutMapping(ClientContext &context, const string &name, EntryInd
|
|
|
360
400
|
mapping[name] = move(new_value);
|
|
361
401
|
}
|
|
362
402
|
|
|
363
|
-
void CatalogSet::DeleteMapping(
|
|
403
|
+
void CatalogSet::DeleteMapping(CatalogTransaction transaction, const string &name) {
|
|
364
404
|
auto entry = mapping.find(name);
|
|
365
405
|
D_ASSERT(entry != mapping.end());
|
|
366
406
|
auto delete_marker = make_unique<MappingValue>(entry->second->index.Copy());
|
|
367
407
|
delete_marker->deleted = true;
|
|
368
|
-
delete_marker->timestamp =
|
|
408
|
+
delete_marker->timestamp = transaction.transaction_id;
|
|
369
409
|
delete_marker->child = move(entry->second);
|
|
370
410
|
delete_marker->child->parent = delete_marker.get();
|
|
371
411
|
mapping[name] = move(delete_marker);
|
|
372
412
|
}
|
|
373
413
|
|
|
374
|
-
bool CatalogSet::UseTimestamp(
|
|
375
|
-
auto &transaction = Transaction::GetTransaction(context);
|
|
414
|
+
bool CatalogSet::UseTimestamp(CatalogTransaction transaction, transaction_t timestamp) {
|
|
376
415
|
if (timestamp == transaction.transaction_id) {
|
|
377
416
|
// we created this version
|
|
378
417
|
return true;
|
|
@@ -384,9 +423,9 @@ bool CatalogSet::UseTimestamp(ClientContext &context, transaction_t timestamp) {
|
|
|
384
423
|
return false;
|
|
385
424
|
}
|
|
386
425
|
|
|
387
|
-
CatalogEntry *CatalogSet::GetEntryForTransaction(
|
|
426
|
+
CatalogEntry *CatalogSet::GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry *current) {
|
|
388
427
|
while (current->child) {
|
|
389
|
-
if (UseTimestamp(
|
|
428
|
+
if (UseTimestamp(transaction, current->timestamp)) {
|
|
390
429
|
break;
|
|
391
430
|
}
|
|
392
431
|
current = current->child.get();
|
|
@@ -407,14 +446,14 @@ CatalogEntry *CatalogSet::GetCommittedEntry(CatalogEntry *current) {
|
|
|
407
446
|
return current;
|
|
408
447
|
}
|
|
409
448
|
|
|
410
|
-
pair<string, idx_t> CatalogSet::SimilarEntry(
|
|
449
|
+
pair<string, idx_t> CatalogSet::SimilarEntry(CatalogTransaction transaction, const string &name) {
|
|
411
450
|
unique_lock<mutex> lock(catalog_lock);
|
|
412
|
-
CreateDefaultEntries(
|
|
451
|
+
CreateDefaultEntries(transaction, lock);
|
|
413
452
|
|
|
414
453
|
string result;
|
|
415
454
|
idx_t current_score = (idx_t)-1;
|
|
416
455
|
for (auto &kv : mapping) {
|
|
417
|
-
auto mapping_value = GetMapping(
|
|
456
|
+
auto mapping_value = GetMapping(transaction, kv.first);
|
|
418
457
|
if (mapping_value && !mapping_value->deleted) {
|
|
419
458
|
auto ldist = StringUtil::LevenshteinDistance(kv.first, name);
|
|
420
459
|
if (ldist < current_score) {
|
|
@@ -426,7 +465,7 @@ pair<string, idx_t> CatalogSet::SimilarEntry(ClientContext &context, const strin
|
|
|
426
465
|
return {result, current_score};
|
|
427
466
|
}
|
|
428
467
|
|
|
429
|
-
CatalogEntry *CatalogSet::CreateEntryInternal(
|
|
468
|
+
CatalogEntry *CatalogSet::CreateEntryInternal(CatalogTransaction transaction, unique_ptr<CatalogEntry> entry) {
|
|
430
469
|
if (mapping.find(entry->name) != mapping.end()) {
|
|
431
470
|
return nullptr;
|
|
432
471
|
}
|
|
@@ -437,12 +476,13 @@ CatalogEntry *CatalogSet::CreateEntryInternal(ClientContext &context, unique_ptr
|
|
|
437
476
|
entry->timestamp = 0;
|
|
438
477
|
|
|
439
478
|
auto entry_index = PutEntry(current_entry++, move(entry));
|
|
440
|
-
PutMapping(
|
|
479
|
+
PutMapping(transaction, name, move(entry_index));
|
|
441
480
|
mapping[name]->timestamp = 0;
|
|
442
481
|
return catalog_entry;
|
|
443
482
|
}
|
|
444
483
|
|
|
445
|
-
CatalogEntry *CatalogSet::CreateDefaultEntry(
|
|
484
|
+
CatalogEntry *CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, const string &name,
|
|
485
|
+
unique_lock<mutex> &lock) {
|
|
446
486
|
// no entry found with this name, check for defaults
|
|
447
487
|
if (!defaults || defaults->created_all_entries) {
|
|
448
488
|
// no defaults either: return null
|
|
@@ -450,8 +490,12 @@ CatalogEntry *CatalogSet::CreateDefaultEntry(ClientContext &context, const strin
|
|
|
450
490
|
}
|
|
451
491
|
// this catalog set has a default map defined
|
|
452
492
|
// check if there is a default entry that we can create with this name
|
|
493
|
+
if (!transaction.context) {
|
|
494
|
+
// no context - cannot create default entry
|
|
495
|
+
return nullptr;
|
|
496
|
+
}
|
|
453
497
|
lock.unlock();
|
|
454
|
-
auto entry = defaults->CreateDefaultEntry(context, name);
|
|
498
|
+
auto entry = defaults->CreateDefaultEntry(*transaction.context, name);
|
|
455
499
|
|
|
456
500
|
lock.lock();
|
|
457
501
|
if (!entry) {
|
|
@@ -459,7 +503,7 @@ CatalogEntry *CatalogSet::CreateDefaultEntry(ClientContext &context, const strin
|
|
|
459
503
|
return nullptr;
|
|
460
504
|
}
|
|
461
505
|
// there is a default entry! create it
|
|
462
|
-
auto result = CreateEntryInternal(
|
|
506
|
+
auto result = CreateEntryInternal(transaction, move(entry));
|
|
463
507
|
if (result) {
|
|
464
508
|
return result;
|
|
465
509
|
}
|
|
@@ -467,24 +511,28 @@ CatalogEntry *CatalogSet::CreateDefaultEntry(ClientContext &context, const strin
|
|
|
467
511
|
// this means somebody else created the entry first
|
|
468
512
|
// just retry?
|
|
469
513
|
lock.unlock();
|
|
470
|
-
return GetEntry(
|
|
514
|
+
return GetEntry(transaction, name);
|
|
471
515
|
}
|
|
472
516
|
|
|
473
|
-
CatalogEntry *CatalogSet::GetEntry(
|
|
517
|
+
CatalogEntry *CatalogSet::GetEntry(CatalogTransaction transaction, const string &name) {
|
|
474
518
|
unique_lock<mutex> lock(catalog_lock);
|
|
475
|
-
auto mapping_value = GetMapping(
|
|
519
|
+
auto mapping_value = GetMapping(transaction, name);
|
|
476
520
|
if (mapping_value != nullptr && !mapping_value->deleted) {
|
|
477
521
|
// we found an entry for this name
|
|
478
522
|
// check the version numbers
|
|
479
523
|
|
|
480
524
|
auto catalog_entry = mapping_value->index.GetEntry().get();
|
|
481
|
-
CatalogEntry *current = GetEntryForTransaction(
|
|
482
|
-
if (current->deleted || (current->name != name && !UseTimestamp(
|
|
525
|
+
CatalogEntry *current = GetEntryForTransaction(transaction, catalog_entry);
|
|
526
|
+
if (current->deleted || (current->name != name && !UseTimestamp(transaction, mapping_value->timestamp))) {
|
|
483
527
|
return nullptr;
|
|
484
528
|
}
|
|
485
529
|
return current;
|
|
486
530
|
}
|
|
487
|
-
return CreateDefaultEntry(
|
|
531
|
+
return CreateDefaultEntry(transaction, name, lock);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
CatalogEntry *CatalogSet::GetEntry(ClientContext &context, const string &name) {
|
|
535
|
+
return GetEntry(catalog.GetCatalogTransaction(context), name);
|
|
488
536
|
}
|
|
489
537
|
|
|
490
538
|
void CatalogSet::UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp) {
|
|
@@ -604,8 +652,8 @@ void CatalogSet::Undo(CatalogEntry *entry) {
|
|
|
604
652
|
catalog.ModifyCatalog();
|
|
605
653
|
}
|
|
606
654
|
|
|
607
|
-
void CatalogSet::CreateDefaultEntries(
|
|
608
|
-
if (!defaults || defaults->created_all_entries) {
|
|
655
|
+
void CatalogSet::CreateDefaultEntries(CatalogTransaction transaction, unique_lock<mutex> &lock) {
|
|
656
|
+
if (!defaults || defaults->created_all_entries || !transaction.context) {
|
|
609
657
|
return;
|
|
610
658
|
}
|
|
611
659
|
// this catalog set has a default set defined:
|
|
@@ -616,32 +664,36 @@ void CatalogSet::CreateDefaultEntries(ClientContext &context, unique_lock<mutex>
|
|
|
616
664
|
// we unlock during the CreateEntry, since it might reference other catalog sets...
|
|
617
665
|
// specifically for views this can happen since the view will be bound
|
|
618
666
|
lock.unlock();
|
|
619
|
-
auto entry = defaults->CreateDefaultEntry(context, default_entry);
|
|
667
|
+
auto entry = defaults->CreateDefaultEntry(*transaction.context, default_entry);
|
|
620
668
|
if (!entry) {
|
|
621
669
|
throw InternalException("Failed to create default entry for %s", default_entry);
|
|
622
670
|
}
|
|
623
671
|
|
|
624
672
|
lock.lock();
|
|
625
|
-
CreateEntryInternal(
|
|
673
|
+
CreateEntryInternal(transaction, move(entry));
|
|
626
674
|
}
|
|
627
675
|
}
|
|
628
676
|
defaults->created_all_entries = true;
|
|
629
677
|
}
|
|
630
678
|
|
|
631
|
-
void CatalogSet::Scan(
|
|
679
|
+
void CatalogSet::Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry *)> &callback) {
|
|
632
680
|
// lock the catalog set
|
|
633
681
|
unique_lock<mutex> lock(catalog_lock);
|
|
634
|
-
CreateDefaultEntries(
|
|
682
|
+
CreateDefaultEntries(transaction, lock);
|
|
635
683
|
|
|
636
684
|
for (auto &kv : entries) {
|
|
637
685
|
auto entry = kv.second.entry.get();
|
|
638
|
-
entry = GetEntryForTransaction(
|
|
686
|
+
entry = GetEntryForTransaction(transaction, entry);
|
|
639
687
|
if (!entry->deleted) {
|
|
640
688
|
callback(entry);
|
|
641
689
|
}
|
|
642
690
|
}
|
|
643
691
|
}
|
|
644
692
|
|
|
693
|
+
void CatalogSet::Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback) {
|
|
694
|
+
Scan(catalog.GetCatalogTransaction(context), callback);
|
|
695
|
+
}
|
|
696
|
+
|
|
645
697
|
void CatalogSet::Scan(const std::function<void(CatalogEntry *)> &callback) {
|
|
646
698
|
// lock the catalog set
|
|
647
699
|
lock_guard<mutex> lock(catalog_lock);
|
|
@@ -653,4 +705,14 @@ void CatalogSet::Scan(const std::function<void(CatalogEntry *)> &callback) {
|
|
|
653
705
|
}
|
|
654
706
|
}
|
|
655
707
|
}
|
|
708
|
+
|
|
709
|
+
void CatalogSet::Verify(Catalog &catalog_p) {
|
|
710
|
+
D_ASSERT(&catalog_p == &catalog);
|
|
711
|
+
vector<CatalogEntry *> entries;
|
|
712
|
+
Scan([&](CatalogEntry *entry) { entries.push_back(entry); });
|
|
713
|
+
for (auto &entry : entries) {
|
|
714
|
+
entry->Verify(catalog_p);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
656
718
|
} // namespace duckdb
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#include "duckdb/catalog/catalog_transaction.hpp"
|
|
2
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
3
|
+
#include "duckdb/transaction/transaction.hpp"
|
|
4
|
+
#include "duckdb/main/database.hpp"
|
|
5
|
+
|
|
6
|
+
namespace duckdb {
|
|
7
|
+
|
|
8
|
+
CatalogTransaction::CatalogTransaction(Catalog &catalog, ClientContext &context) {
|
|
9
|
+
auto &transaction = Transaction::Get(context, catalog);
|
|
10
|
+
this->db = &DatabaseInstance::GetDatabase(context);
|
|
11
|
+
this->transaction_id = transaction.transaction_id;
|
|
12
|
+
this->start_time = transaction.start_time;
|
|
13
|
+
this->transaction = &transaction;
|
|
14
|
+
this->context = &context;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
CatalogTransaction::CatalogTransaction(DatabaseInstance &db, transaction_t transaction_id_p, transaction_t start_time_p)
|
|
18
|
+
: db(&db), context(nullptr), transaction(nullptr), transaction_id(transaction_id_p), start_time(start_time_p) {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ClientContext &CatalogTransaction::GetContext() {
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw InternalException("Attempting to get a context in a CatalogTransaction without a context");
|
|
24
|
+
}
|
|
25
|
+
return *context;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace duckdb
|
|
@@ -39,7 +39,7 @@ static DefaultView internal_views[] = {
|
|
|
39
39
|
{"pg_catalog", "pg_index", "SELECT index_oid indexrelid, table_oid indrelid, 0 indnatts, 0 indnkeyatts, is_unique indisunique, is_primary indisprimary, false indisexclusion, true indimmediate, false indisclustered, true indisvalid, false indcheckxmin, true indisready, true indislive, false indisreplident, NULL::INT[] indkey, NULL::OID[] indcollation, NULL::OID[] indclass, NULL::INT[] indoption, expressions indexprs, NULL indpred FROM duckdb_indexes()"},
|
|
40
40
|
{"pg_catalog", "pg_indexes", "SELECT schema_name schemaname, table_name tablename, index_name indexname, NULL \"tablespace\", sql indexdef FROM duckdb_indexes()"},
|
|
41
41
|
{"pg_catalog", "pg_namespace", "SELECT oid, schema_name nspname, 0 nspowner, NULL nspacl FROM duckdb_schemas()"},
|
|
42
|
-
{"pg_catalog", "pg_proc", "SELECT f.function_oid oid, function_name proname, s.oid pronamespace, varargs provariadic, function_type = 'aggregate' proisagg, function_type = 'table' proretset, return_type prorettype, parameter_types proargtypes, parameters proargnames FROM duckdb_functions() f LEFT JOIN duckdb_schemas() s USING (schema_name)"},
|
|
42
|
+
{"pg_catalog", "pg_proc", "SELECT f.function_oid oid, function_name proname, s.oid pronamespace, varargs provariadic, function_type = 'aggregate' proisagg, function_type = 'table' proretset, return_type prorettype, parameter_types proargtypes, parameters proargnames FROM duckdb_functions() f LEFT JOIN duckdb_schemas() s USING (database_name, schema_name)"},
|
|
43
43
|
{"pg_catalog", "pg_sequence", "SELECT sequence_oid seqrelid, 0 seqtypid, start_value seqstart, increment_by seqincrement, max_value seqmax, min_value seqmin, 0 seqcache, cycle seqcycle FROM duckdb_sequences()"},
|
|
44
44
|
{"pg_catalog", "pg_sequences", "SELECT schema_name schemaname, sequence_name sequencename, 'duckdb' sequenceowner, 0 data_type, start_value, min_value, max_value, increment_by, cycle, 0 cache_size, last_value FROM duckdb_sequences()"},
|
|
45
45
|
{"pg_catalog", "pg_settings", "SELECT name, value setting, description short_desc, CASE WHEN input_type = 'VARCHAR' THEN 'string' WHEN input_type = 'BOOLEAN' THEN 'bool' WHEN input_type IN ('BIGINT', 'UBIGINT') THEN 'integer' ELSE input_type END vartype FROM duckdb_settings()"},
|
|
@@ -47,9 +47,9 @@ static DefaultView internal_views[] = {
|
|
|
47
47
|
{"pg_catalog", "pg_tablespace", "SELECT 0 oid, 'pg_default' spcname, 0 spcowner, NULL spcacl, NULL spcoptions"},
|
|
48
48
|
{"pg_catalog", "pg_type", "SELECT type_oid oid, format_pg_type(type_name) typname, schema_oid typnamespace, 0 typowner, type_size typlen, false typbyval, CASE WHEN logical_type='ENUM' THEN 'e' else 'b' end typtype, CASE WHEN type_category='NUMERIC' THEN 'N' WHEN type_category='STRING' THEN 'S' WHEN type_category='DATETIME' THEN 'D' WHEN type_category='BOOLEAN' THEN 'B' WHEN type_category='COMPOSITE' THEN 'C' WHEN type_category='USER' THEN 'U' ELSE 'X' END typcategory, false typispreferred, true typisdefined, NULL typdelim, NULL typrelid, NULL typsubscript, NULL typelem, NULL typarray, NULL typinput, NULL typoutput, NULL typreceive, NULL typsend, NULL typmodin, NULL typmodout, NULL typanalyze, 'd' typalign, 'p' typstorage, NULL typnotnull, NULL typbasetype, NULL typtypmod, NULL typndims, NULL typcollation, NULL typdefaultbin, NULL typdefault, NULL typacl FROM duckdb_types() WHERE type_size IS NOT NULL;"},
|
|
49
49
|
{"pg_catalog", "pg_views", "SELECT schema_name schemaname, view_name viewname, 'duckdb' viewowner, sql definition FROM duckdb_views()"},
|
|
50
|
-
{"information_schema", "columns", "SELECT
|
|
51
|
-
{"information_schema", "schemata", "SELECT
|
|
52
|
-
{"information_schema", "tables", "SELECT
|
|
50
|
+
{"information_schema", "columns", "SELECT database_name table_catalog, schema_name table_schema, table_name, column_name, column_index ordinal_position, column_default, CASE WHEN is_nullable THEN 'YES' ELSE 'NO' END is_nullable, data_type, character_maximum_length, NULL character_octet_length, numeric_precision, numeric_precision_radix, numeric_scale, NULL datetime_precision, NULL interval_type, NULL interval_precision, NULL character_set_catalog, NULL character_set_schema, NULL character_set_name, NULL collation_catalog, NULL collation_schema, NULL collation_name, NULL domain_catalog, NULL domain_schema, NULL domain_name, NULL udt_catalog, NULL udt_schema, NULL udt_name, NULL scope_catalog, NULL scope_schema, NULL scope_name, NULL maximum_cardinality, NULL dtd_identifier, NULL is_self_referencing, NULL is_identity, NULL identity_generation, NULL identity_start, NULL identity_increment, NULL identity_maximum, NULL identity_minimum, NULL identity_cycle, NULL is_generated, NULL generation_expression, NULL is_updatable FROM duckdb_columns;"},
|
|
51
|
+
{"information_schema", "schemata", "SELECT database_name catalog_name, schema_name, 'duckdb' schema_owner, NULL default_character_set_catalog, NULL default_character_set_schema, NULL default_character_set_name, sql sql_path FROM duckdb_schemas()"},
|
|
52
|
+
{"information_schema", "tables", "SELECT database_name table_catalog, schema_name table_schema, table_name, CASE WHEN temporary THEN 'LOCAL TEMPORARY' ELSE 'BASE TABLE' END table_type, NULL self_referencing_column_name, NULL reference_generation, NULL user_defined_type_catalog, NULL user_defined_type_schema, NULL user_defined_type_name, 'YES' is_insertable_into, 'NO' is_typed, CASE WHEN temporary THEN 'PRESERVE' ELSE NULL END commit_action FROM duckdb_tables() UNION ALL SELECT NULL table_catalog, schema_name table_schema, view_name table_name, 'VIEW' table_type, NULL self_referencing_column_name, NULL reference_generation, NULL user_defined_type_catalog, NULL user_defined_type_schema, NULL user_defined_type_name, 'NO' is_insertable_into, 'NO' is_typed, NULL commit_action FROM duckdb_views;"},
|
|
53
53
|
{nullptr, nullptr, nullptr}};
|
|
54
54
|
|
|
55
55
|
static unique_ptr<CreateViewInfo> GetDefaultView(const string &input_schema, const string &input_name) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#include "duckdb/catalog/dependency_list.hpp"
|
|
2
|
+
#include "duckdb/catalog/catalog_entry.hpp"
|
|
3
|
+
|
|
4
|
+
namespace duckdb {
|
|
5
|
+
|
|
6
|
+
void DependencyList::AddDependency(CatalogEntry *entry) {
|
|
7
|
+
if (entry->internal) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
set.insert(entry);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
} // namespace duckdb
|