duckdb 0.8.1-dev96.0 → 0.8.1
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 +8 -8
- package/package.json +3 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +5 -4
- package/src/duckdb/extension/icu/icu-strptime.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfsubs.cpp +0 -2
- package/src/duckdb/extension/json/buffered_json_reader.cpp +23 -14
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +6 -6
- package/src/duckdb/extension/json/include/json_common.hpp +12 -2
- package/src/duckdb/extension/json/include/json_scan.hpp +5 -2
- package/src/duckdb/extension/json/json_functions/json_contains.cpp +5 -0
- package/src/duckdb/extension/json/json_functions/json_create.cpp +10 -10
- package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +5 -3
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +11 -11
- package/src/duckdb/extension/json/json_functions/read_json.cpp +2 -1
- package/src/duckdb/extension/json/json_functions.cpp +6 -3
- package/src/duckdb/extension/json/json_scan.cpp +43 -27
- package/src/duckdb/extension/parquet/column_reader.cpp +5 -1
- package/src/duckdb/extension/parquet/include/decode_utils.hpp +6 -0
- package/src/duckdb/extension/parquet/parquet-extension.cpp +26 -1
- package/src/duckdb/src/catalog/catalog.cpp +5 -17
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +7 -1
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +121 -0
- package/src/duckdb/src/catalog/catalog_search_path.cpp +49 -12
- package/src/duckdb/src/catalog/default/default_types.cpp +9 -84
- package/src/duckdb/src/common/adbc/adbc.cpp +118 -12
- package/src/duckdb/src/common/adbc/driver_manager.cpp +0 -20
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +11 -12
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +4 -3
- package/src/duckdb/src/common/exception.cpp +4 -1
- package/src/duckdb/src/common/exception_format_value.cpp +24 -15
- package/src/duckdb/src/common/multi_file_reader.cpp +3 -0
- package/src/duckdb/src/common/random_engine.cpp +1 -1
- package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +5 -4
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +44 -7
- package/src/duckdb/src/common/types/time.cpp +2 -8
- package/src/duckdb/src/common/types/timestamp.cpp +37 -1
- package/src/duckdb/src/common/types/value.cpp +1 -0
- package/src/duckdb/src/common/types.cpp +4 -0
- package/src/duckdb/src/core_functions/aggregate/algebraic/avg.cpp +30 -33
- package/src/duckdb/src/core_functions/aggregate/algebraic/covar.cpp +0 -4
- package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +30 -33
- package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +52 -65
- package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +48 -48
- package/src/duckdb/src/core_functions/aggregate/distributive/bitstring_agg.cpp +39 -40
- package/src/duckdb/src/core_functions/aggregate/distributive/bool.cpp +32 -32
- package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +34 -34
- package/src/duckdb/src/core_functions/aggregate/distributive/kurtosis.cpp +30 -31
- package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +88 -100
- package/src/duckdb/src/core_functions/aggregate/distributive/product.cpp +17 -17
- package/src/duckdb/src/core_functions/aggregate/distributive/skew.cpp +25 -27
- package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +37 -38
- package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +22 -22
- package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +44 -80
- package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +49 -51
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +104 -122
- package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +57 -93
- package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +22 -23
- package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +18 -19
- package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +16 -18
- package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +22 -25
- package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +19 -24
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +18 -23
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +14 -18
- package/src/duckdb/src/core_functions/function_list.cpp +1 -0
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +3 -0
- package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
- package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +23 -6
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/map/map_concat.cpp +3 -0
- package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +3 -3
- package/src/duckdb/src/execution/index/art/art.cpp +80 -7
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +20 -1
- package/src/duckdb/src/execution/index/art/leaf.cpp +11 -11
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +10 -0
- package/src/duckdb/src/execution/index/art/node.cpp +48 -35
- package/src/duckdb/src/execution/index/art/node16.cpp +3 -0
- package/src/duckdb/src/execution/index/art/node256.cpp +1 -0
- package/src/duckdb/src/execution/index/art/node4.cpp +3 -0
- package/src/duckdb/src/execution/index/art/node48.cpp +2 -0
- package/src/duckdb/src/execution/index/art/prefix.cpp +2 -0
- package/src/duckdb/src/execution/join_hashtable.cpp +2 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +26 -9
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +3 -6
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +1 -0
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +8 -3
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +0 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +29 -3
- package/src/duckdb/src/execution/reservoir_sample.cpp +18 -4
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +159 -21
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +67 -74
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +7 -7
- package/src/duckdb/src/function/cast/list_casts.cpp +2 -4
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +1 -1
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +6 -2
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
- package/src/duckdb/src/function/table/arrow.cpp +2 -2
- package/src/duckdb/src/function/table/checkpoint.cpp +3 -0
- package/src/duckdb/src/function/table/read_csv.cpp +15 -17
- package/src/duckdb/src/function/table/repeat.cpp +3 -0
- package/src/duckdb/src/function/table/repeat_row.cpp +8 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +4 -4
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +81 -25
- package/src/duckdb/src/function/table/table_scan.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +0 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +11 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +8 -2
- package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +97 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_converter.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_options.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/arrow/result_arrow_wrapper.hpp +0 -1
- package/src/duckdb/src/include/duckdb/common/bit_utils.hpp +16 -22
- package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/time.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +4 -14
- package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +92 -57
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +20 -24
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +36 -39
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +57 -53
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +8 -9
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +16 -18
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/sum_helpers.hpp +7 -8
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +10 -4
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +13 -3
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +9 -30
- package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +95 -0
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -2
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +142 -136
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
- package/src/duckdb/src/include/duckdb/optimizer/unnest_rewriter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +12 -3
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +0 -2
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +5 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +6 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/byte_reader.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +13 -13
- package/src/duckdb/src/include/duckdb/storage/index.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +0 -6
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +0 -2
- package/src/duckdb/src/main/attached_database.cpp +8 -0
- package/src/duckdb/src/main/capi/arrow-c.cpp +4 -4
- package/src/duckdb/src/main/capi/config-c.cpp +2 -5
- package/src/duckdb/src/main/client_context.cpp +4 -3
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/database.cpp +1 -0
- package/src/duckdb/src/main/database_manager.cpp +21 -0
- package/src/duckdb/src/main/query_result.cpp +6 -2
- package/src/duckdb/src/main/settings/settings.cpp +41 -6
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +27 -16
- package/src/duckdb/src/parallel/executor.cpp +38 -14
- package/src/duckdb/src/parallel/meta_pipeline.cpp +17 -3
- package/src/duckdb/src/parser/column_definition.cpp +5 -8
- package/src/duckdb/src/parser/parsed_data/create_info.cpp +0 -3
- package/src/duckdb/src/parser/parser.cpp +95 -35
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +1 -0
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +3 -0
- package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +0 -2
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +0 -3
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
- package/src/duckdb/src/parser/transformer.cpp +0 -2
- package/src/duckdb/src/planner/bind_context.cpp +3 -4
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +0 -2
- package/src/duckdb/src/planner/binder/expression/bind_positional_reference_expression.cpp +8 -3
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +31 -15
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +0 -27
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +18 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +0 -25
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -114
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +6 -1
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +5 -0
- package/src/duckdb/src/planner/bound_result_modifier.cpp +14 -0
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +6 -5
- package/src/duckdb/src/planner/expression/bound_default_expression.cpp +7 -1
- package/src/duckdb/src/planner/expression.cpp +3 -0
- package/src/duckdb/src/planner/expression_binder.cpp +3 -2
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +5 -4
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +14 -2
- package/src/duckdb/src/planner/planner.cpp +5 -15
- package/src/duckdb/src/storage/data_table.cpp +10 -8
- package/src/duckdb/src/storage/index.cpp +13 -0
- package/src/duckdb/src/storage/storage_manager.cpp +6 -0
- package/src/duckdb/src/storage/table/column_data.cpp +7 -3
- package/src/duckdb/src/storage/table/list_column_data.cpp +5 -4
- package/src/duckdb/src/storage/table/row_group.cpp +4 -3
- package/src/duckdb/src/storage/table/row_group_collection.cpp +6 -3
- package/src/duckdb/src/storage/table/standard_column_data.cpp +4 -3
- package/src/duckdb/src/storage/table/struct_column_data.cpp +4 -3
- package/src/duckdb/src/storage/wal_replay.cpp +4 -5
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +0 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +0 -14
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12828 -12956
- package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3 -0
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +4 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
- package/src/duckdb/ub_src_parser_transform_statement.cpp +0 -2
- package/test/extension.test.ts +11 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -46
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -27
@@ -82,6 +82,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
82
82
|
DUCKDB_GLOBAL(ForceBitpackingModeSetting),
|
83
83
|
DUCKDB_LOCAL(HomeDirectorySetting),
|
84
84
|
DUCKDB_LOCAL(LogQueryPathSetting),
|
85
|
+
DUCKDB_GLOBAL(LockConfigurationSetting),
|
85
86
|
DUCKDB_GLOBAL(ImmediateTransactionModeSetting),
|
86
87
|
DUCKDB_LOCAL(IntegerDivisionSetting),
|
87
88
|
DUCKDB_LOCAL(MaximumExpressionDepthSetting),
|
@@ -104,6 +105,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
104
105
|
DUCKDB_GLOBAL(TempDirectorySetting),
|
105
106
|
DUCKDB_GLOBAL(ThreadsSetting),
|
106
107
|
DUCKDB_GLOBAL(UsernameSetting),
|
108
|
+
DUCKDB_GLOBAL(ExportLargeBufferArrow),
|
107
109
|
DUCKDB_GLOBAL_ALIAS("user", UsernameSetting),
|
108
110
|
DUCKDB_GLOBAL_ALIAS("wal_autocheckpoint", CheckpointThresholdSetting),
|
109
111
|
DUCKDB_GLOBAL_ALIAS("worker_threads", ThreadsSetting),
|
@@ -43,6 +43,11 @@ void DatabaseManager::AddDatabase(ClientContext &context, unique_ptr<AttachedDat
|
|
43
43
|
}
|
44
44
|
|
45
45
|
void DatabaseManager::DetachDatabase(ClientContext &context, const string &name, OnEntryNotFound if_not_found) {
|
46
|
+
if (GetDefaultDatabase(context) == name) {
|
47
|
+
throw BinderException("Cannot detach database \"%s\" because it is the default database. Select a different "
|
48
|
+
"database using `USE` to allow detaching this database",
|
49
|
+
name);
|
50
|
+
}
|
46
51
|
if (!databases->DropEntry(context, name, false, true)) {
|
47
52
|
if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
|
48
53
|
throw BinderException("Failed to detach database with name \"%s\": database not found", name);
|
@@ -82,6 +87,22 @@ const string &DatabaseManager::GetDefaultDatabase(ClientContext &context) {
|
|
82
87
|
return default_entry.catalog;
|
83
88
|
}
|
84
89
|
|
90
|
+
// LCOV_EXCL_START
|
91
|
+
void DatabaseManager::SetDefaultDatabase(ClientContext &context, const string &new_value) {
|
92
|
+
auto db_entry = GetDatabase(context, new_value);
|
93
|
+
|
94
|
+
if (!db_entry) {
|
95
|
+
throw InternalException("Database \"%s\" not found", new_value);
|
96
|
+
} else if (db_entry->IsTemporary()) {
|
97
|
+
throw InternalException("Cannot set the default database to a temporary database");
|
98
|
+
} else if (db_entry->IsSystem()) {
|
99
|
+
throw InternalException("Cannot set the default database to a system database");
|
100
|
+
}
|
101
|
+
|
102
|
+
default_database = new_value;
|
103
|
+
}
|
104
|
+
// LCOV_EXCL_STOP
|
105
|
+
|
85
106
|
vector<reference<AttachedDatabase>> DatabaseManager::GetDatabases(ClientContext &context) {
|
86
107
|
vector<reference<AttachedDatabase>> result;
|
87
108
|
databases->Scan(context, [&](CatalogEntry &entry) { result.push_back(entry.Cast<AttachedDatabase>()); });
|
@@ -3,7 +3,6 @@
|
|
3
3
|
#include "duckdb/common/vector.hpp"
|
4
4
|
#include "duckdb/main/client_context.hpp"
|
5
5
|
#include "duckdb/common/box_renderer.hpp"
|
6
|
-
|
7
6
|
namespace duckdb {
|
8
7
|
|
9
8
|
BaseQueryResult::BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties_p,
|
@@ -71,7 +70,8 @@ idx_t CurrentChunk::RemainingSize() {
|
|
71
70
|
return data_chunk->size() - position;
|
72
71
|
}
|
73
72
|
|
74
|
-
QueryResult::QueryResult(QueryResultType type, PreservedError error)
|
73
|
+
QueryResult::QueryResult(QueryResultType type, PreservedError error)
|
74
|
+
: BaseQueryResult(type, std::move(error)), client_properties("UTC", ArrowOffsetSize::REGULAR) {
|
75
75
|
}
|
76
76
|
|
77
77
|
QueryResult::~QueryResult() {
|
@@ -164,6 +164,10 @@ string QueryResult::HeaderToString() {
|
|
164
164
|
return result;
|
165
165
|
}
|
166
166
|
|
167
|
+
ArrowOptions QueryResult::GetArrowOptions(QueryResult &query_result) {
|
168
|
+
return {query_result.client_properties.arrow_offset_size, query_result.client_properties.time_zone};
|
169
|
+
}
|
170
|
+
|
167
171
|
string QueryResult::GetConfigTimezone(QueryResult &query_result) {
|
168
172
|
return query_result.client_properties.time_zone;
|
169
173
|
}
|
@@ -151,7 +151,7 @@ void OrderedAggregateThreshold::ResetLocal(ClientContext &context) {
|
|
151
151
|
|
152
152
|
void OrderedAggregateThreshold::SetLocal(ClientContext &context, const Value &input) {
|
153
153
|
const auto param = input.GetValue<uint64_t>();
|
154
|
-
if (
|
154
|
+
if (param <= 0) {
|
155
155
|
throw ParserException("Invalid option for PRAGMA ordered_aggregate_threshold, value must be positive");
|
156
156
|
}
|
157
157
|
ClientConfig::GetConfig(context).ordered_aggregate_threshold = param;
|
@@ -189,7 +189,7 @@ Value DebugWindowMode::GetSetting(ClientContext &context) {
|
|
189
189
|
// Debug AsOf Join
|
190
190
|
//===--------------------------------------------------------------------===//
|
191
191
|
void DebugAsOfIEJoin::ResetLocal(ClientContext &context) {
|
192
|
-
ClientConfig::GetConfig(context).
|
192
|
+
ClientConfig::GetConfig(context).force_asof_iejoin = ClientConfig().force_asof_iejoin;
|
193
193
|
}
|
194
194
|
|
195
195
|
void DebugAsOfIEJoin::SetLocal(ClientContext &context, const Value &input) {
|
@@ -433,7 +433,6 @@ Value EnableHTTPMetadataCacheSetting::GetSetting(ClientContext &context) {
|
|
433
433
|
//===--------------------------------------------------------------------===//
|
434
434
|
// Enable Profiling
|
435
435
|
//===--------------------------------------------------------------------===//
|
436
|
-
|
437
436
|
void EnableProfilingSetting::ResetLocal(ClientContext &context) {
|
438
437
|
auto &config = ClientConfig::GetConfig(context);
|
439
438
|
config.profiler_print_format = ClientConfig().profiler_print_format;
|
@@ -718,10 +717,10 @@ Value IntegerDivisionSetting::GetSetting(ClientContext &context) {
|
|
718
717
|
auto &config = ClientConfig::GetConfig(context);
|
719
718
|
return Value(config.integer_division);
|
720
719
|
}
|
720
|
+
|
721
721
|
//===--------------------------------------------------------------------===//
|
722
722
|
// Log Query Path
|
723
723
|
//===--------------------------------------------------------------------===//
|
724
|
-
|
725
724
|
void LogQueryPathSetting::ResetLocal(ClientContext &context) {
|
726
725
|
auto &client_data = ClientData::Get(context);
|
727
726
|
// TODO: verify that this does the right thing
|
@@ -745,6 +744,23 @@ Value LogQueryPathSetting::GetSetting(ClientContext &context) {
|
|
745
744
|
return client_data.log_query_writer ? Value(client_data.log_query_writer->path) : Value();
|
746
745
|
}
|
747
746
|
|
747
|
+
//===--------------------------------------------------------------------===//
|
748
|
+
// Lock Configuration
|
749
|
+
//===--------------------------------------------------------------------===//
|
750
|
+
void LockConfigurationSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
|
751
|
+
auto new_value = input.GetValue<bool>();
|
752
|
+
config.options.lock_configuration = new_value;
|
753
|
+
}
|
754
|
+
|
755
|
+
void LockConfigurationSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
|
756
|
+
config.options.lock_configuration = DBConfig().options.lock_configuration;
|
757
|
+
}
|
758
|
+
|
759
|
+
Value LockConfigurationSetting::GetSetting(ClientContext &context) {
|
760
|
+
auto &config = DBConfig::GetConfig(context);
|
761
|
+
return Value::BOOLEAN(config.options.lock_configuration);
|
762
|
+
}
|
763
|
+
|
748
764
|
//===--------------------------------------------------------------------===//
|
749
765
|
// Immediate Transaction Mode
|
750
766
|
//===--------------------------------------------------------------------===//
|
@@ -879,6 +895,25 @@ Value PreserveInsertionOrder::GetSetting(ClientContext &context) {
|
|
879
895
|
return Value::BOOLEAN(config.options.preserve_insertion_order);
|
880
896
|
}
|
881
897
|
|
898
|
+
//===--------------------------------------------------------------------===//
|
899
|
+
// ExportLargeBufferArrow
|
900
|
+
//===--------------------------------------------------------------------===//
|
901
|
+
void ExportLargeBufferArrow::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
|
902
|
+
auto export_large_buffers_arrow = input.GetValue<bool>();
|
903
|
+
|
904
|
+
config.options.arrow_offset_size = export_large_buffers_arrow ? ArrowOffsetSize::LARGE : ArrowOffsetSize::REGULAR;
|
905
|
+
}
|
906
|
+
|
907
|
+
void ExportLargeBufferArrow::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
|
908
|
+
config.options.arrow_offset_size = DBConfig().options.arrow_offset_size;
|
909
|
+
}
|
910
|
+
|
911
|
+
Value ExportLargeBufferArrow::GetSetting(ClientContext &context) {
|
912
|
+
auto &config = DBConfig::GetConfig(context);
|
913
|
+
bool export_large_buffers_arrow = config.options.arrow_offset_size == ArrowOffsetSize::LARGE;
|
914
|
+
return Value::BOOLEAN(export_large_buffers_arrow);
|
915
|
+
}
|
916
|
+
|
882
917
|
//===--------------------------------------------------------------------===//
|
883
918
|
// Profiler History Size
|
884
919
|
//===--------------------------------------------------------------------===//
|
@@ -988,7 +1023,7 @@ void SchemaSetting::ResetLocal(ClientContext &context) {
|
|
988
1023
|
void SchemaSetting::SetLocal(ClientContext &context, const Value &input) {
|
989
1024
|
auto parameter = input.ToString();
|
990
1025
|
auto &client_data = ClientData::Get(context);
|
991
|
-
client_data.catalog_search_path->Set(CatalogSearchEntry::Parse(parameter),
|
1026
|
+
client_data.catalog_search_path->Set(CatalogSearchEntry::Parse(parameter), CatalogSetPathType::SET_SCHEMA);
|
992
1027
|
}
|
993
1028
|
|
994
1029
|
Value SchemaSetting::GetSetting(ClientContext &context) {
|
@@ -1008,7 +1043,7 @@ void SearchPathSetting::ResetLocal(ClientContext &context) {
|
|
1008
1043
|
void SearchPathSetting::SetLocal(ClientContext &context, const Value &input) {
|
1009
1044
|
auto parameter = input.ToString();
|
1010
1045
|
auto &client_data = ClientData::Get(context);
|
1011
|
-
client_data.catalog_search_path->Set(CatalogSearchEntry::ParseList(parameter),
|
1046
|
+
client_data.catalog_search_path->Set(CatalogSearchEntry::ParseList(parameter), CatalogSetPathType::SET_SCHEMAS);
|
1012
1047
|
}
|
1013
1048
|
|
1014
1049
|
Value SearchPathSetting::GetSetting(ClientContext &context) {
|
@@ -26,11 +26,7 @@ void UnnestRewriterPlanUpdater::VisitExpression(unique_ptr<Expression> *expressi
|
|
26
26
|
for (idx_t i = 0; i < replace_bindings.size(); i++) {
|
27
27
|
if (bound_column_ref.binding == replace_bindings[i].old_binding) {
|
28
28
|
bound_column_ref.binding = replace_bindings[i].new_binding;
|
29
|
-
|
30
|
-
// previously pointing to the LOGICAL_DELIM_GET
|
31
|
-
if (bound_column_ref.binding.table_index == replace_bindings[i].old_binding.table_index &&
|
32
|
-
replace_bindings[i].old_binding.column_index == DConstants::INVALID_INDEX) {
|
33
|
-
bound_column_ref.binding = replace_bindings[i].new_binding;
|
29
|
+
break;
|
34
30
|
}
|
35
31
|
}
|
36
32
|
}
|
@@ -49,6 +45,7 @@ unique_ptr<LogicalOperator> UnnestRewriter::Optimize(unique_ptr<LogicalOperator>
|
|
49
45
|
|
50
46
|
// rearrange the logical operators
|
51
47
|
if (RewriteCandidate(candidate)) {
|
48
|
+
updater.overwritten_tbl_idx = overwritten_tbl_idx;
|
52
49
|
// update the bindings of the BOUND_UNNEST expression
|
53
50
|
UpdateBoundUnnestBindings(updater, candidate);
|
54
51
|
// update the sequence of LOGICAL_PROJECTION(s)
|
@@ -106,7 +103,6 @@ void UnnestRewriter::FindCandidates(unique_ptr<LogicalOperator> *op_ptr,
|
|
106
103
|
if (curr_op->get()->type == LogicalOperatorType::LOGICAL_UNNEST) {
|
107
104
|
candidates.push_back(op_ptr);
|
108
105
|
}
|
109
|
-
return;
|
110
106
|
}
|
111
107
|
|
112
108
|
bool UnnestRewriter::RewriteCandidate(unique_ptr<LogicalOperator> *candidate) {
|
@@ -147,6 +143,11 @@ bool UnnestRewriter::RewriteCandidate(unique_ptr<LogicalOperator> *candidate) {
|
|
147
143
|
auto &unnest = curr_op->get()->Cast<LogicalUnnest>();
|
148
144
|
D_ASSERT(unnest.children[0]->type == LogicalOperatorType::LOGICAL_DELIM_GET);
|
149
145
|
overwritten_tbl_idx = unnest.children[0]->Cast<LogicalDelimGet>().table_index;
|
146
|
+
|
147
|
+
D_ASSERT(!unnest.children.empty());
|
148
|
+
auto &delim_get = unnest.children[0]->Cast<LogicalDelimGet>();
|
149
|
+
D_ASSERT(delim_get.chunk_types.size() > 1);
|
150
|
+
distinct_unnest_count = delim_get.chunk_types.size();
|
150
151
|
unnest.children[0] = std::move(lhs_op);
|
151
152
|
|
152
153
|
// replace the LOGICAL_DELIM_JOIN with its RHS child operator
|
@@ -168,10 +169,11 @@ void UnnestRewriter::UpdateRHSBindings(unique_ptr<LogicalOperator> *plan_ptr, un
|
|
168
169
|
D_ASSERT(curr_op->get()->type == LogicalOperatorType::LOGICAL_PROJECTION);
|
169
170
|
auto &proj = curr_op->get()->Cast<LogicalProjection>();
|
170
171
|
|
171
|
-
// pop the
|
172
|
-
D_ASSERT(proj.expressions.size() >
|
173
|
-
|
174
|
-
|
172
|
+
// pop the unnest columns and the delim index
|
173
|
+
D_ASSERT(proj.expressions.size() > distinct_unnest_count);
|
174
|
+
for (idx_t i = 0; i < distinct_unnest_count; i++) {
|
175
|
+
proj.expressions.pop_back();
|
176
|
+
}
|
175
177
|
|
176
178
|
// store all shifted current bindings
|
177
179
|
idx_t tbl_idx = proj.table_index;
|
@@ -263,14 +265,23 @@ void UnnestRewriter::UpdateBoundUnnestBindings(UnnestRewriterPlanUpdater &update
|
|
263
265
|
auto &unnest = curr_op->get()->Cast<LogicalUnnest>();
|
264
266
|
|
265
267
|
D_ASSERT(unnest.children.size() == 1);
|
266
|
-
auto
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
268
|
+
auto unnest_cols = unnest.children[0]->GetColumnBindings();
|
269
|
+
|
270
|
+
for (idx_t i = 0; i < delim_columns.size(); i++) {
|
271
|
+
auto delim_binding = delim_columns[i];
|
272
|
+
|
273
|
+
auto unnest_it = unnest_cols.begin();
|
274
|
+
while (unnest_it != unnest_cols.end()) {
|
275
|
+
auto unnest_binding = *unnest_it;
|
276
|
+
|
277
|
+
if (delim_binding.table_index == unnest_binding.table_index) {
|
278
|
+
unnest_binding.table_index = overwritten_tbl_idx;
|
279
|
+
unnest_binding.column_index++;
|
280
|
+
updater.replace_bindings.emplace_back(unnest_binding, delim_binding);
|
281
|
+
unnest_cols.erase(unnest_it);
|
272
282
|
break;
|
273
283
|
}
|
284
|
+
unnest_it++;
|
274
285
|
}
|
275
286
|
}
|
276
287
|
|
@@ -95,26 +95,50 @@ void Executor::SchedulePipeline(const shared_ptr<MetaPipeline> &meta_pipeline, S
|
|
95
95
|
|
96
96
|
// create events/stack for this pipeline
|
97
97
|
auto pipeline_event = make_shared<PipelineEvent>(pipeline);
|
98
|
-
|
99
|
-
|
98
|
+
|
99
|
+
auto finish_group = meta_pipeline->GetFinishGroup(pipeline.get());
|
100
|
+
if (finish_group) {
|
101
|
+
// this pipeline is part of a finish group
|
102
|
+
const auto group_entry = event_map.find(*finish_group.get());
|
103
|
+
D_ASSERT(group_entry != event_map.end());
|
104
|
+
auto &group_stack = group_entry->second;
|
105
|
+
PipelineEventStack pipeline_stack(base_stack.pipeline_initialize_event, *pipeline_event,
|
106
|
+
group_stack.pipeline_finish_event, base_stack.pipeline_complete_event);
|
107
|
+
|
108
|
+
// dependencies: base_finish -> pipeline_event -> group_finish
|
109
|
+
pipeline_stack.pipeline_event.AddDependency(base_stack.pipeline_event);
|
110
|
+
group_stack.pipeline_finish_event.AddDependency(pipeline_stack.pipeline_event);
|
111
|
+
|
112
|
+
// add pipeline stack to event map
|
113
|
+
event_map.insert(make_pair(reference<Pipeline>(*pipeline), pipeline_stack));
|
114
|
+
} else if (meta_pipeline->HasFinishEvent(pipeline.get())) {
|
100
115
|
// this pipeline has its own finish event (despite going into the same sink - Finalize twice!)
|
101
116
|
auto pipeline_finish_event = make_shared<PipelineFinishEvent>(pipeline);
|
102
|
-
|
117
|
+
PipelineEventStack pipeline_stack(base_stack.pipeline_initialize_event, *pipeline_event,
|
118
|
+
*pipeline_finish_event, base_stack.pipeline_complete_event);
|
103
119
|
events.push_back(std::move(pipeline_finish_event));
|
104
|
-
|
120
|
+
|
121
|
+
// dependencies: base_finish -> pipeline_event -> pipeline_finish -> base_complete
|
122
|
+
pipeline_stack.pipeline_event.AddDependency(base_stack.pipeline_finish_event);
|
123
|
+
pipeline_stack.pipeline_finish_event.AddDependency(pipeline_stack.pipeline_event);
|
124
|
+
base_stack.pipeline_complete_event.AddDependency(pipeline_stack.pipeline_finish_event);
|
125
|
+
|
126
|
+
// add pipeline stack to event map
|
127
|
+
event_map.insert(make_pair(reference<Pipeline>(*pipeline), pipeline_stack));
|
128
|
+
|
105
129
|
} else {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
*pipeline_finish_event_ptr, base_stack.pipeline_complete_event);
|
110
|
-
events.push_back(std::move(pipeline_event));
|
130
|
+
// no additional finish event
|
131
|
+
PipelineEventStack pipeline_stack(base_stack.pipeline_initialize_event, *pipeline_event,
|
132
|
+
base_stack.pipeline_finish_event, base_stack.pipeline_complete_event);
|
111
133
|
|
112
|
-
|
113
|
-
|
114
|
-
|
134
|
+
// dependencies: base_initialize -> pipeline_event -> base_finish
|
135
|
+
pipeline_stack.pipeline_event.AddDependency(base_stack.pipeline_initialize_event);
|
136
|
+
base_stack.pipeline_finish_event.AddDependency(pipeline_stack.pipeline_event);
|
115
137
|
|
116
|
-
|
117
|
-
|
138
|
+
// add pipeline stack to event map
|
139
|
+
event_map.insert(make_pair(reference<Pipeline>(*pipeline), pipeline_stack));
|
140
|
+
}
|
141
|
+
events.push_back(std::move(pipeline_event));
|
118
142
|
}
|
119
143
|
|
120
144
|
// add base stack to the event data too
|
@@ -70,7 +70,6 @@ void MetaPipeline::AssignNextBatchIndex(Pipeline *pipeline) {
|
|
70
70
|
void MetaPipeline::Build(PhysicalOperator &op) {
|
71
71
|
D_ASSERT(pipelines.size() == 1);
|
72
72
|
D_ASSERT(children.empty());
|
73
|
-
D_ASSERT(final_pipelines.empty());
|
74
73
|
op.BuildPipelines(*pipelines.back(), *this);
|
75
74
|
}
|
76
75
|
|
@@ -125,13 +124,28 @@ void MetaPipeline::AddDependenciesFrom(Pipeline *dependant, Pipeline *start, boo
|
|
125
124
|
}
|
126
125
|
|
127
126
|
void MetaPipeline::AddFinishEvent(Pipeline *pipeline) {
|
127
|
+
D_ASSERT(finish_pipelines.find(pipeline) == finish_pipelines.end());
|
128
128
|
finish_pipelines.insert(pipeline);
|
129
|
+
|
130
|
+
// add all pipelines that were added since 'pipeline' was added (including 'pipeline') to the finish group
|
131
|
+
auto it = pipelines.begin();
|
132
|
+
for (; it->get() != pipeline; it++) {
|
133
|
+
}
|
134
|
+
it++;
|
135
|
+
for (; it != pipelines.end(); it++) {
|
136
|
+
finish_map.emplace(it->get(), pipeline);
|
137
|
+
}
|
129
138
|
}
|
130
139
|
|
131
|
-
bool MetaPipeline::HasFinishEvent(Pipeline *pipeline) {
|
140
|
+
bool MetaPipeline::HasFinishEvent(Pipeline *pipeline) const {
|
132
141
|
return finish_pipelines.find(pipeline) != finish_pipelines.end();
|
133
142
|
}
|
134
143
|
|
144
|
+
optional_ptr<Pipeline> MetaPipeline::GetFinishGroup(Pipeline *pipeline) const {
|
145
|
+
auto it = finish_map.find(pipeline);
|
146
|
+
return it == finish_map.end() ? nullptr : it->second;
|
147
|
+
}
|
148
|
+
|
135
149
|
Pipeline *MetaPipeline::CreateUnionPipeline(Pipeline ¤t, bool order_matters) {
|
136
150
|
// create the union pipeline (batch index 0, should be set correctly afterwards)
|
137
151
|
auto union_pipeline = CreatePipeline();
|
@@ -162,7 +176,7 @@ void MetaPipeline::CreateChildPipeline(Pipeline ¤t, PhysicalOperator &op,
|
|
162
176
|
auto child_pipeline = pipelines.back().get();
|
163
177
|
child_pipeline->base_batch_index = current.base_batch_index;
|
164
178
|
|
165
|
-
// child pipeline has a
|
179
|
+
// child pipeline has a dependency (within this MetaPipeline on all pipelines that were scheduled
|
166
180
|
// between 'current' and now (including 'current') - set them up
|
167
181
|
dependencies[child_pipeline].push_back(¤t);
|
168
182
|
AddDependenciesFrom(child_pipeline, last_pipeline, false);
|
@@ -50,6 +50,7 @@ void ColumnDefinition::Serialize(Serializer &serializer) const {
|
|
50
50
|
writer.WriteOptional(default_value);
|
51
51
|
}
|
52
52
|
writer.WriteField<TableColumnType>(category);
|
53
|
+
writer.WriteField<duckdb::CompressionType>(compression_type);
|
53
54
|
writer.Finalize();
|
54
55
|
}
|
55
56
|
|
@@ -59,16 +60,12 @@ ColumnDefinition ColumnDefinition::Deserialize(Deserializer &source) {
|
|
59
60
|
auto column_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
|
60
61
|
auto expression = reader.ReadOptional<ParsedExpression>(nullptr);
|
61
62
|
auto category = reader.ReadField<TableColumnType>(TableColumnType::STANDARD);
|
63
|
+
auto compression_type = reader.ReadField<duckdb::CompressionType>(duckdb::CompressionType::COMPRESSION_AUTO);
|
62
64
|
reader.Finalize();
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
case TableColumnType::GENERATED:
|
68
|
-
return ColumnDefinition(column_name, column_type, std::move(expression), TableColumnType::GENERATED);
|
69
|
-
default:
|
70
|
-
throw NotImplementedException("Type not implemented for TableColumnType");
|
71
|
-
}
|
66
|
+
ColumnDefinition result(column_name, column_type, std::move(expression), category);
|
67
|
+
result.compression_type = compression_type;
|
68
|
+
return result;
|
72
69
|
}
|
73
70
|
|
74
71
|
const unique_ptr<ParsedExpression> &ColumnDefinition::DefaultValue() const {
|
@@ -5,7 +5,6 @@
|
|
5
5
|
#include "duckdb/parser/parsed_data/create_table_info.hpp"
|
6
6
|
#include "duckdb/parser/parsed_data/create_view_info.hpp"
|
7
7
|
#include "duckdb/parser/parsed_data/create_sequence_info.hpp"
|
8
|
-
#include "duckdb/parser/parsed_data/create_database_info.hpp"
|
9
8
|
#include "duckdb/parser/parsed_data/create_type_info.hpp"
|
10
9
|
#include "duckdb/parser/parsed_data/alter_info.hpp"
|
11
10
|
#include "duckdb/parser/parsed_data/create_macro_info.hpp"
|
@@ -43,8 +42,6 @@ unique_ptr<CreateInfo> CreateInfo::Deserialize(Deserializer &deserializer) {
|
|
43
42
|
return CreateSchemaInfo::Deserialize(deserializer);
|
44
43
|
case CatalogType::VIEW_ENTRY:
|
45
44
|
return CreateViewInfo::Deserialize(deserializer);
|
46
|
-
case CatalogType::DATABASE_ENTRY:
|
47
|
-
return CreateDatabaseInfo::Deserialize(deserializer);
|
48
45
|
case CatalogType::TYPE_ENTRY:
|
49
46
|
return CreateTypeInfo::Deserialize(deserializer);
|
50
47
|
case CatalogType::MACRO_ENTRY:
|
@@ -1,18 +1,17 @@
|
|
1
1
|
#include "duckdb/parser/parser.hpp"
|
2
2
|
|
3
|
-
#include "duckdb/parser/transformer.hpp"
|
4
3
|
#include "duckdb/parser/parsed_data/create_table_info.hpp"
|
4
|
+
#include "duckdb/parser/parser_extension.hpp"
|
5
|
+
#include "duckdb/parser/query_error_context.hpp"
|
6
|
+
#include "duckdb/parser/query_node/select_node.hpp"
|
5
7
|
#include "duckdb/parser/statement/create_statement.hpp"
|
6
8
|
#include "duckdb/parser/statement/extension_statement.hpp"
|
7
9
|
#include "duckdb/parser/statement/select_statement.hpp"
|
8
10
|
#include "duckdb/parser/statement/update_statement.hpp"
|
9
|
-
#include "duckdb/parser/query_node/select_node.hpp"
|
10
11
|
#include "duckdb/parser/tableref/expressionlistref.hpp"
|
11
|
-
#include "
|
12
|
-
#include "duckdb/parser/query_error_context.hpp"
|
13
|
-
#include "duckdb/parser/parser_extension.hpp"
|
14
|
-
|
12
|
+
#include "duckdb/parser/transformer.hpp"
|
15
13
|
#include "parser/parser.hpp"
|
14
|
+
#include "postgres_parser.hpp"
|
16
15
|
|
17
16
|
namespace duckdb {
|
18
17
|
|
@@ -45,7 +44,7 @@ static bool ReplaceUnicodeSpaces(const string &query, string &new_query, vector<
|
|
45
44
|
// This function strips unicode space characters from the query and replaces them with regular spaces
|
46
45
|
// It returns true if any unicode space characters were found and stripped
|
47
46
|
// See here for a list of unicode space characters - https://jkorpela.fi/chars/spaces.html
|
48
|
-
|
47
|
+
bool Parser::StripUnicodeSpaces(const string &query_str, string &new_query) {
|
49
48
|
const idx_t NBSP_LEN = 2;
|
50
49
|
const idx_t USP_LEN = 3;
|
51
50
|
idx_t pos = 0;
|
@@ -124,6 +123,29 @@ end:
|
|
124
123
|
return ReplaceUnicodeSpaces(query_str, new_query, unicode_spaces);
|
125
124
|
}
|
126
125
|
|
126
|
+
vector<string> SplitQueryStringIntoStatements(const string &query) {
|
127
|
+
// Break sql string down into sql statements using the tokenizer
|
128
|
+
vector<string> query_statements;
|
129
|
+
auto tokens = Parser::Tokenize(query);
|
130
|
+
auto next_statement_start = 0;
|
131
|
+
for (idx_t i = 1; i < tokens.size(); ++i) {
|
132
|
+
auto &t_prev = tokens[i - 1];
|
133
|
+
auto &t = tokens[i];
|
134
|
+
if (t_prev.type == SimplifiedTokenType::SIMPLIFIED_TOKEN_OPERATOR) {
|
135
|
+
// LCOV_EXCL_START
|
136
|
+
for (idx_t c = t_prev.start; c <= t.start; ++c) {
|
137
|
+
if (query.c_str()[c] == ';') {
|
138
|
+
query_statements.emplace_back(query.substr(next_statement_start, t.start - next_statement_start));
|
139
|
+
next_statement_start = tokens[i].start;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
// LCOV_EXCL_STOP
|
143
|
+
}
|
144
|
+
}
|
145
|
+
query_statements.emplace_back(query.substr(next_statement_start, query.size() - next_statement_start));
|
146
|
+
return query_statements;
|
147
|
+
}
|
148
|
+
|
127
149
|
void Parser::ParseQuery(const string &query) {
|
128
150
|
Transformer transformer(options);
|
129
151
|
string parser_error;
|
@@ -138,39 +160,77 @@ void Parser::ParseQuery(const string &query) {
|
|
138
160
|
}
|
139
161
|
{
|
140
162
|
PostgresParser::SetPreserveIdentifierCase(options.preserve_identifier_case);
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
// SQLStatements
|
151
|
-
transformer.TransformParseTree(parser.parse_tree, statements);
|
152
|
-
} else {
|
153
|
-
parser_error = QueryErrorContext::Format(query, parser.error_message, parser.error_location - 1);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
if (!parser_error.empty()) {
|
157
|
-
if (options.extensions) {
|
158
|
-
for (auto &ext : *options.extensions) {
|
159
|
-
D_ASSERT(ext.parse_function);
|
160
|
-
auto result = ext.parse_function(ext.parser_info.get(), query);
|
161
|
-
if (result.type == ParserExtensionResultType::PARSE_SUCCESSFUL) {
|
162
|
-
auto statement = make_uniq<ExtensionStatement>(ext, std::move(result.parse_data));
|
163
|
-
statement->stmt_length = query.size();
|
164
|
-
statement->stmt_location = 0;
|
165
|
-
statements.push_back(std::move(statement));
|
163
|
+
bool parsing_succeed = false;
|
164
|
+
// Creating a new scope to prevent multiple PostgresParser destructors being called
|
165
|
+
// which led to some memory issues
|
166
|
+
{
|
167
|
+
PostgresParser parser;
|
168
|
+
parser.Parse(query);
|
169
|
+
if (parser.success) {
|
170
|
+
if (!parser.parse_tree) {
|
171
|
+
// empty statement
|
166
172
|
return;
|
167
173
|
}
|
168
|
-
|
169
|
-
|
174
|
+
|
175
|
+
// if it succeeded, we transform the Postgres parse tree into a list of
|
176
|
+
// SQLStatements
|
177
|
+
transformer.TransformParseTree(parser.parse_tree, statements);
|
178
|
+
parsing_succeed = true;
|
179
|
+
} else {
|
180
|
+
parser_error = QueryErrorContext::Format(query, parser.error_message, parser.error_location - 1);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
// If DuckDB fails to parse the entire sql string, break the string down into individual statements
|
184
|
+
// using ';' as the delimiter so that parser extensions can parse the statement
|
185
|
+
if (parsing_succeed) {
|
186
|
+
// no-op
|
187
|
+
// return here would require refactoring into another function. o.w. will just no-op in order to run wrap up
|
188
|
+
// code at the end of this function
|
189
|
+
} else if (!options.extensions || options.extensions->empty()) {
|
190
|
+
throw ParserException(parser_error);
|
191
|
+
} else {
|
192
|
+
// split sql string into statements and re-parse using extension
|
193
|
+
auto query_statements = SplitQueryStringIntoStatements(query);
|
194
|
+
for (auto const &query_statement : query_statements) {
|
195
|
+
PostgresParser another_parser;
|
196
|
+
another_parser.Parse(query_statement);
|
197
|
+
// LCOV_EXCL_START
|
198
|
+
// first see if DuckDB can parse this individual query statement
|
199
|
+
if (another_parser.success) {
|
200
|
+
if (!another_parser.parse_tree) {
|
201
|
+
// empty statement
|
202
|
+
continue;
|
203
|
+
}
|
204
|
+
transformer.TransformParseTree(another_parser.parse_tree, statements);
|
205
|
+
} else {
|
206
|
+
// let extensions parse the statement which DuckDB failed to parse
|
207
|
+
bool parsed_single_statement = false;
|
208
|
+
for (auto &ext : *options.extensions) {
|
209
|
+
D_ASSERT(!parsed_single_statement);
|
210
|
+
D_ASSERT(ext.parse_function);
|
211
|
+
auto result = ext.parse_function(ext.parser_info.get(), query_statement);
|
212
|
+
if (result.type == ParserExtensionResultType::PARSE_SUCCESSFUL) {
|
213
|
+
auto statement = make_uniq<ExtensionStatement>(ext, std::move(result.parse_data));
|
214
|
+
statement->stmt_length = query_statement.size();
|
215
|
+
statement->stmt_location = 0;
|
216
|
+
statements.push_back(std::move(statement));
|
217
|
+
parsed_single_statement = true;
|
218
|
+
break;
|
219
|
+
} else if (result.type == ParserExtensionResultType::DISPLAY_EXTENSION_ERROR) {
|
220
|
+
throw ParserException(result.error);
|
221
|
+
} else {
|
222
|
+
// We move to the next one!
|
223
|
+
}
|
224
|
+
}
|
225
|
+
if (!parsed_single_statement) {
|
226
|
+
parser_error = QueryErrorContext::Format(query, another_parser.error_message,
|
227
|
+
another_parser.error_location - 1);
|
228
|
+
throw ParserException(parser_error);
|
229
|
+
}
|
170
230
|
}
|
231
|
+
// LCOV_EXCL_STOP
|
171
232
|
}
|
172
233
|
}
|
173
|
-
throw ParserException(parser_error);
|
174
234
|
}
|
175
235
|
if (!statements.empty()) {
|
176
236
|
auto &last_statement = statements.back();
|
@@ -309,6 +309,7 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
309
309
|
order_bys.reset(); // NOLINT
|
310
310
|
filter_expr.reset(); // NOLINT
|
311
311
|
children.clear(); // NOLINT
|
312
|
+
root.agg_distinct = false;
|
312
313
|
children.emplace_back(std::move(unordered));
|
313
314
|
children.emplace_back(std::move(sense));
|
314
315
|
children.emplace_back(std::move(nulls));
|
@@ -82,6 +82,9 @@ unique_ptr<ParsedExpression> Transformer::TransformAExprInternal(duckdb_libpgque
|
|
82
82
|
subquery_expr->child = std::move(left_expr);
|
83
83
|
subquery_expr->comparison_type = OperatorToExpressionType(name);
|
84
84
|
subquery_expr->query_location = root.location;
|
85
|
+
if (subquery_expr->comparison_type == ExpressionType::INVALID) {
|
86
|
+
throw ParserException("Unsupported comparison \"%s\" for ANY/ALL subquery", name);
|
87
|
+
}
|
85
88
|
|
86
89
|
if (root.kind == duckdb_libpgquery::PG_AEXPR_OP_ALL) {
|
87
90
|
// ALL sublink is equivalent to NOT(ANY) with inverted comparison
|
@@ -816,8 +816,6 @@ std::string Transformer::NodetypeToString(duckdb_libpgquery::PGNodeTag type) { /
|
|
816
816
|
return "T_PGAttachStmt";
|
817
817
|
case duckdb_libpgquery::T_PGUseStmt:
|
818
818
|
return "T_PGUseStmt";
|
819
|
-
case duckdb_libpgquery::T_PGCreateDatabaseStmt:
|
820
|
-
return "T_PGCreateDatabaseStmt";
|
821
819
|
default:
|
822
820
|
return "(UNKNOWN)";
|
823
821
|
}
|
@@ -34,9 +34,6 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGDropStm
|
|
34
34
|
case duckdb_libpgquery::PG_OBJECT_TYPE:
|
35
35
|
info.type = CatalogType::TYPE_ENTRY;
|
36
36
|
break;
|
37
|
-
case duckdb_libpgquery::PG_OBJECT_DATABASE:
|
38
|
-
info.type = CatalogType::DATABASE_ENTRY;
|
39
|
-
break;
|
40
37
|
default:
|
41
38
|
throw NotImplementedException("Cannot drop this type yet");
|
42
39
|
}
|