duckdb 1.1.4-dev9.0 → 1.2.1-dev4.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.
Files changed (221) hide show
  1. package/LICENSE +1 -1
  2. package/binding.gyp +1 -0
  3. package/package.json +2 -2
  4. package/src/connection.cpp +42 -15
  5. package/src/duckdb/extension/core_functions/function_list.cpp +1 -0
  6. package/src/duckdb/extension/core_functions/include/core_functions/scalar/map_functions.hpp +9 -0
  7. package/src/duckdb/extension/core_functions/scalar/date/current.cpp +1 -0
  8. package/src/duckdb/extension/core_functions/scalar/generic/can_implicitly_cast.cpp +2 -2
  9. package/src/duckdb/extension/core_functions/scalar/generic/typeof.cpp +1 -1
  10. package/src/duckdb/extension/core_functions/scalar/list/flatten.cpp +91 -61
  11. package/src/duckdb/extension/core_functions/scalar/map/map_extract.cpp +89 -8
  12. package/src/duckdb/extension/icu/icu-current.cpp +63 -0
  13. package/src/duckdb/extension/icu/icu-makedate.cpp +43 -39
  14. package/src/duckdb/extension/icu/icu-timezone.cpp +63 -63
  15. package/src/duckdb/extension/icu/icu_extension.cpp +2 -0
  16. package/src/duckdb/extension/icu/include/icu-casts.hpp +39 -0
  17. package/src/duckdb/extension/icu/include/icu-current.hpp +17 -0
  18. package/src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp +1 -1
  19. package/src/duckdb/extension/json/json_functions/json_structure.cpp +3 -1
  20. package/src/duckdb/extension/parquet/column_writer.cpp +26 -18
  21. package/src/duckdb/extension/parquet/include/parquet_reader.hpp +0 -6
  22. package/src/duckdb/extension/parquet/include/parquet_writer.hpp +15 -1
  23. package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +1 -0
  24. package/src/duckdb/extension/parquet/parquet_extension.cpp +67 -15
  25. package/src/duckdb/extension/parquet/parquet_reader.cpp +5 -3
  26. package/src/duckdb/extension/parquet/parquet_writer.cpp +5 -6
  27. package/src/duckdb/src/catalog/catalog.cpp +21 -8
  28. package/src/duckdb/src/catalog/catalog_search_path.cpp +17 -1
  29. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  30. package/src/duckdb/src/catalog/default/default_functions.cpp +0 -3
  31. package/src/duckdb/src/catalog/dependency_list.cpp +7 -0
  32. package/src/duckdb/src/common/adbc/adbc.cpp +1 -56
  33. package/src/duckdb/src/common/arrow/arrow_converter.cpp +3 -2
  34. package/src/duckdb/src/common/arrow/arrow_type_extension.cpp +58 -28
  35. package/src/duckdb/src/common/arrow/schema_metadata.cpp +1 -1
  36. package/src/duckdb/src/common/compressed_file_system.cpp +6 -2
  37. package/src/duckdb/src/common/enum_util.cpp +26 -22
  38. package/src/duckdb/src/common/error_data.cpp +3 -2
  39. package/src/duckdb/src/common/gzip_file_system.cpp +8 -8
  40. package/src/duckdb/src/common/local_file_system.cpp +2 -2
  41. package/src/duckdb/src/common/multi_file_reader.cpp +1 -1
  42. package/src/duckdb/src/common/random_engine.cpp +4 -1
  43. package/src/duckdb/src/common/serializer/memory_stream.cpp +23 -19
  44. package/src/duckdb/src/common/serializer/serializer.cpp +1 -1
  45. package/src/duckdb/src/common/types/bit.cpp +1 -1
  46. package/src/duckdb/src/common/types/column/column_data_allocator.cpp +0 -5
  47. package/src/duckdb/src/common/types/column/column_data_collection.cpp +4 -1
  48. package/src/duckdb/src/common/types/data_chunk.cpp +2 -1
  49. package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +0 -4
  50. package/src/duckdb/src/common/types.cpp +1 -1
  51. package/src/duckdb/src/execution/index/art/art.cpp +52 -42
  52. package/src/duckdb/src/execution/index/art/leaf.cpp +4 -9
  53. package/src/duckdb/src/execution/index/art/node.cpp +13 -13
  54. package/src/duckdb/src/execution/index/art/prefix.cpp +21 -16
  55. package/src/duckdb/src/execution/index/bound_index.cpp +6 -8
  56. package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +39 -34
  57. package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +2 -1
  58. package/src/duckdb/src/execution/index/unbound_index.cpp +10 -0
  59. package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +62 -44
  60. package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +26 -0
  61. package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +69 -40
  62. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +3 -7
  63. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +11 -5
  64. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +4 -0
  65. package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +8 -8
  66. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +36 -12
  67. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +12 -9
  68. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +0 -1
  69. package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +29 -1
  70. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +58 -10
  71. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +58 -35
  72. package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +2 -1
  73. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +9 -4
  74. package/src/duckdb/src/execution/sample/reservoir_sample.cpp +7 -6
  75. package/src/duckdb/src/function/compression_config.cpp +4 -0
  76. package/src/duckdb/src/function/function_binder.cpp +1 -1
  77. package/src/duckdb/src/function/scalar/system/write_log.cpp +2 -2
  78. package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +15 -2
  79. package/src/duckdb/src/function/table/arrow_conversion.cpp +10 -10
  80. package/src/duckdb/src/function/table/copy_csv.cpp +8 -5
  81. package/src/duckdb/src/function/table/read_csv.cpp +21 -4
  82. package/src/duckdb/src/function/table/sniff_csv.cpp +7 -0
  83. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +4 -0
  84. package/src/duckdb/src/function/table/system/duckdb_secret_types.cpp +71 -0
  85. package/src/duckdb/src/function/table/system_functions.cpp +1 -0
  86. package/src/duckdb/src/function/table/table_scan.cpp +120 -36
  87. package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -4
  88. package/src/duckdb/src/function/window/window_aggregate_function.cpp +6 -1
  89. package/src/duckdb/src/function/window/window_boundaries_state.cpp +135 -11
  90. package/src/duckdb/src/function/window/window_segment_tree.cpp +50 -22
  91. package/src/duckdb/src/function/window/window_token_tree.cpp +4 -3
  92. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +4 -0
  93. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +2 -0
  94. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +1 -0
  95. package/src/duckdb/src/include/duckdb/common/arrow/arrow_type_extension.hpp +4 -2
  96. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +8 -8
  97. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +0 -2
  98. package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +8 -3
  99. package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +6 -1
  100. package/src/duckdb/src/include/duckdb/common/serializer/serialization_data.hpp +25 -0
  101. package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +9 -3
  102. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  103. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +11 -14
  104. package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +5 -4
  105. package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +21 -10
  106. package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +6 -5
  107. package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +37 -32
  108. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +36 -1
  109. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +3 -0
  110. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/csv_sniffer.hpp +2 -0
  111. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +5 -5
  112. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +5 -30
  113. package/src/duckdb/src/include/duckdb/execution/reservoir_sample.hpp +7 -1
  114. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -3
  115. package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +1 -0
  116. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
  117. package/src/duckdb/src/include/duckdb/function/window/window_boundaries_state.hpp +2 -2
  118. package/src/duckdb/src/include/duckdb/logging/logger.hpp +40 -119
  119. package/src/duckdb/src/include/duckdb/logging/logging.hpp +0 -2
  120. package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
  121. package/src/duckdb/src/include/duckdb/main/connection.hpp +0 -8
  122. package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -1
  123. package/src/duckdb/src/include/duckdb/main/extension.hpp +1 -0
  124. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +11 -7
  125. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +1 -0
  126. package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +2 -0
  127. package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +3 -0
  128. package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
  129. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +9 -0
  130. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +36 -9
  131. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +2 -1
  132. package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +8 -2
  133. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
  134. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +9 -1
  135. package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +1 -0
  136. package/src/duckdb/src/include/duckdb/planner/filter/in_filter.hpp +0 -2
  137. package/src/duckdb/src/include/duckdb/planner/filter/optional_filter.hpp +4 -4
  138. package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +1 -1
  139. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +14 -10
  140. package/src/duckdb/src/include/duckdb/storage/index_storage_info.hpp +4 -0
  141. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +6 -1
  142. package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +7 -2
  143. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -0
  144. package/src/duckdb/src/include/duckdb/storage/storage_options.hpp +2 -0
  145. package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +4 -3
  146. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +2 -0
  147. package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +6 -4
  148. package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +1 -1
  149. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +2 -0
  150. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +2 -0
  151. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +1 -1
  152. package/src/duckdb/src/logging/logger.cpp +8 -66
  153. package/src/duckdb/src/main/attached_database.cpp +3 -1
  154. package/src/duckdb/src/main/client_context.cpp +4 -2
  155. package/src/duckdb/src/main/config.cpp +20 -2
  156. package/src/duckdb/src/main/connection.cpp +2 -29
  157. package/src/duckdb/src/main/connection_manager.cpp +5 -3
  158. package/src/duckdb/src/main/database.cpp +2 -2
  159. package/src/duckdb/src/main/extension/extension_helper.cpp +4 -5
  160. package/src/duckdb/src/main/extension/extension_install.cpp +23 -10
  161. package/src/duckdb/src/main/extension/extension_load.cpp +6 -7
  162. package/src/duckdb/src/main/extension.cpp +27 -9
  163. package/src/duckdb/src/main/secret/secret_manager.cpp +11 -0
  164. package/src/duckdb/src/main/settings/custom_settings.cpp +44 -0
  165. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +6 -0
  166. package/src/duckdb/src/optimizer/filter_combiner.cpp +13 -3
  167. package/src/duckdb/src/optimizer/filter_pushdown.cpp +33 -6
  168. package/src/duckdb/src/optimizer/late_materialization.cpp +14 -3
  169. package/src/duckdb/src/optimizer/remove_unused_columns.cpp +0 -3
  170. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +5 -1
  171. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +6 -3
  172. package/src/duckdb/src/parser/query_node/set_operation_node.cpp +49 -0
  173. package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +1 -0
  174. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +50 -12
  175. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +7 -5
  176. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -0
  177. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +2 -2
  178. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +12 -2
  179. package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +0 -1
  180. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +55 -39
  181. package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +2 -1
  182. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +15 -7
  183. package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +13 -8
  184. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +8 -3
  185. package/src/duckdb/src/planner/expression/bound_function_expression.cpp +17 -1
  186. package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -0
  187. package/src/duckdb/src/planner/filter/conjunction_filter.cpp +1 -0
  188. package/src/duckdb/src/planner/filter/constant_filter.cpp +21 -0
  189. package/src/duckdb/src/planner/filter/in_filter.cpp +4 -7
  190. package/src/duckdb/src/planner/logical_operator.cpp +5 -3
  191. package/src/duckdb/src/planner/planner.cpp +1 -1
  192. package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +2 -0
  193. package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +3 -4
  194. package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -5
  195. package/src/duckdb/src/storage/compression/dictionary/decompression.cpp +4 -4
  196. package/src/duckdb/src/storage/compression/fsst.cpp +2 -2
  197. package/src/duckdb/src/storage/compression/roaring/common.cpp +10 -1
  198. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +11 -6
  199. package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +4 -0
  200. package/src/duckdb/src/storage/compression/zstd.cpp +6 -0
  201. package/src/duckdb/src/storage/data_table.cpp +104 -109
  202. package/src/duckdb/src/storage/local_storage.cpp +8 -6
  203. package/src/duckdb/src/storage/magic_bytes.cpp +1 -1
  204. package/src/duckdb/src/storage/serialization/serialize_dependency.cpp +3 -3
  205. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +3 -3
  206. package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +7 -5
  207. package/src/duckdb/src/storage/single_file_block_manager.cpp +95 -28
  208. package/src/duckdb/src/storage/storage_info.cpp +38 -0
  209. package/src/duckdb/src/storage/storage_manager.cpp +11 -0
  210. package/src/duckdb/src/storage/table/column_data.cpp +4 -0
  211. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +3 -3
  212. package/src/duckdb/src/storage/table/row_group_collection.cpp +67 -68
  213. package/src/duckdb/src/storage/table/table_statistics.cpp +4 -4
  214. package/src/duckdb/src/storage/table_index_list.cpp +41 -15
  215. package/src/duckdb/src/storage/wal_replay.cpp +3 -1
  216. package/src/duckdb/src/storage/write_ahead_log.cpp +11 -4
  217. package/src/duckdb/src/transaction/meta_transaction.cpp +1 -1
  218. package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -1
  219. package/src/duckdb/third_party/httplib/httplib.hpp +0 -1
  220. package/src/duckdb/third_party/re2/util/logging.h +10 -10
  221. package/src/duckdb/ub_src_function_table_system.cpp +2 -0
@@ -9,6 +9,14 @@
9
9
 
10
10
  namespace duckdb {
11
11
 
12
+ void Logger::WriteLog(const char *log_type, LogLevel log_level, const string &message) {
13
+ WriteLog(log_type, log_level, message.c_str());
14
+ }
15
+ void Logger::WriteLog(const char *log_type, LogLevel log_level, const string_t &message) {
16
+ string copied_string = message.GetString();
17
+ WriteLog(log_type, log_level, copied_string.c_str());
18
+ }
19
+
12
20
  Logger &Logger::Get(const DatabaseInstance &db) {
13
21
  return db.GetLogManager().GlobalLogger();
14
22
  }
@@ -29,46 +37,6 @@ Logger &Logger::Get(const FileOpener &opener) {
29
37
  return opener.GetLogger();
30
38
  }
31
39
 
32
- void Logger::Log(const char *log_type, LogLevel log_level, const char *log_message) {
33
- if (ShouldLog(log_type, log_level)) {
34
- WriteLog(log_type, log_level, log_message);
35
- }
36
- }
37
-
38
- void Logger::Log(LogLevel log_level, const char *log_message) {
39
- if (ShouldLog(log_level)) {
40
- WriteLog(log_level, log_message);
41
- }
42
- }
43
-
44
- void Logger::Log(const char *log_type, LogLevel log_level, const string_t &log_message) {
45
- if (ShouldLog(log_type, log_level)) {
46
- auto string_copy = log_message.GetString();
47
- WriteLog(log_type, log_level, string_copy.c_str());
48
- }
49
- }
50
-
51
- void Logger::Log(LogLevel log_level, const string_t &log_message) {
52
- if (ShouldLog(log_level)) {
53
- auto string_copy = log_message.GetString();
54
- WriteLog(log_level, string_copy.c_str());
55
- }
56
- }
57
-
58
- void Logger::Log(const char *log_type, LogLevel log_level, std::function<string()> callback) { // NOLINT
59
- if (ShouldLog(log_type, log_level)) {
60
- auto string = callback();
61
- WriteLog(log_type, log_level, string.c_str());
62
- }
63
- }
64
-
65
- void Logger::Log(LogLevel log_level, std::function<string()> callback) { // NOLINT
66
- if (ShouldLog(log_level)) {
67
- auto string = callback();
68
- WriteLog(log_level, string.c_str());
69
- }
70
- }
71
-
72
40
  ThreadSafeLogger::ThreadSafeLogger(LogConfig &config_p, LoggingContext &context_p, LogManager &manager)
73
41
  : ThreadSafeLogger(config_p, manager.RegisterLoggingContext(context_p), manager) {
74
42
  }
@@ -95,19 +63,10 @@ bool ThreadSafeLogger::ShouldLog(const char *log_type, LogLevel log_level) {
95
63
  return true;
96
64
  }
97
65
 
98
- bool ThreadSafeLogger::ShouldLog(LogLevel log_level) {
99
- return ShouldLog(context.context.default_log_type, log_level);
100
- }
101
-
102
66
  void ThreadSafeLogger::WriteLog(const char *log_type, LogLevel log_level, const char *log_message) {
103
67
  manager.WriteLogEntry(Timestamp::GetCurrentTimestamp(), log_type, log_level, log_message, context);
104
68
  }
105
69
 
106
- void ThreadSafeLogger::WriteLog(LogLevel log_level, const char *log_message) {
107
- manager.WriteLogEntry(Timestamp::GetCurrentTimestamp(), context.context.default_log_type, log_level, log_message,
108
- context);
109
- }
110
-
111
70
  void ThreadSafeLogger::Flush() {
112
71
  manager.Flush();
113
72
  // NOP
@@ -127,18 +86,10 @@ bool ThreadLocalLogger::ShouldLog(const char *log_type, LogLevel log_level) {
127
86
  throw NotImplementedException("ThreadLocalLogger::ShouldLog");
128
87
  }
129
88
 
130
- bool ThreadLocalLogger::ShouldLog(LogLevel log_level) {
131
- throw NotImplementedException("ThreadLocalLogger::ShouldLog");
132
- }
133
-
134
89
  void ThreadLocalLogger::WriteLog(const char *log_type, LogLevel log_level, const char *log_message) {
135
90
  throw NotImplementedException("ThreadLocalLogger::WriteLog");
136
91
  }
137
92
 
138
- void ThreadLocalLogger::WriteLog(LogLevel log_level, const char *log_message) {
139
- throw NotImplementedException("ThreadLocalLogger::WriteLog");
140
- }
141
-
142
93
  void ThreadLocalLogger::Flush() {
143
94
  manager.Flush();
144
95
  }
@@ -168,11 +119,6 @@ void MutableLogger::WriteLog(const char *log_type, LogLevel log_level, const cha
168
119
  manager.WriteLogEntry(Timestamp::GetCurrentTimestamp(), log_type, log_level, log_message, context);
169
120
  }
170
121
 
171
- void MutableLogger::WriteLog(LogLevel log_level, const char *log_message) {
172
- manager.WriteLogEntry(Timestamp::GetCurrentTimestamp(), context.context.default_log_type, log_level, log_message,
173
- context);
174
- }
175
-
176
122
  bool MutableLogger::ShouldLog(const char *log_type, LogLevel log_level) {
177
123
  if (!enabled) {
178
124
  return false;
@@ -200,10 +146,6 @@ bool MutableLogger::ShouldLog(const char *log_type, LogLevel log_level) {
200
146
  throw InternalException("Should be unreachable (MutableLogger::ShouldLog)");
201
147
  }
202
148
 
203
- bool MutableLogger::ShouldLog(LogLevel log_level) {
204
- return ShouldLog(context.context.default_log_type, log_level);
205
- }
206
-
207
149
  void MutableLogger::Flush() {
208
150
  manager.Flush();
209
151
  }
@@ -99,9 +99,11 @@ AttachedDatabase::AttachedDatabase(DatabaseInstance &db, Catalog &catalog_p, str
99
99
  if (StringUtil::CIEquals(entry.first, "row_group_size")) {
100
100
  continue;
101
101
  }
102
+ if (StringUtil::CIEquals(entry.first, "storage_version")) {
103
+ continue;
104
+ }
102
105
  throw BinderException("Unrecognized option for attach \"%s\"", entry.first);
103
106
  }
104
-
105
107
  // We create the storage after the catalog to guarantee we allow extensions to instantiate the DuckCatalog.
106
108
  catalog = make_uniq<DuckCatalog>(*this);
107
109
  auto read_only = options.access_mode == AccessMode::READ_ONLY;
@@ -218,7 +218,7 @@ void ClientContext::BeginQueryInternal(ClientContextLock &lock, const string &qu
218
218
  context.client_context = reinterpret_cast<idx_t>(this);
219
219
  context.transaction_id = transaction.GetActiveQuery();
220
220
  logger = db->GetLogManager().CreateLogger(context, true);
221
- Logger::Info("duckdb.ClientContext.BeginQuery", *this, query);
221
+ DUCKDB_LOG_INFO(*this, "duckdb.ClientContext.BeginQuery", query);
222
222
  }
223
223
 
224
224
  ErrorData ClientContext::EndQueryInternal(ClientContextLock &lock, bool success, bool invalidate_transaction,
@@ -1049,7 +1049,9 @@ unique_ptr<PendingQueryResult> ClientContext::PendingQuery(const string &query,
1049
1049
 
1050
1050
  return PendingQueryInternal(*lock, std::move(statements[0]), params, true);
1051
1051
  } catch (std::exception &ex) {
1052
- return make_uniq<PendingQueryResult>(ErrorData(ex));
1052
+ ErrorData error(ex);
1053
+ ProcessError(error, query);
1054
+ return make_uniq<PendingQueryResult>(std::move(error));
1053
1055
  }
1054
1056
  }
1055
1057
 
@@ -7,6 +7,7 @@
7
7
  #include "duckdb/common/string_util.hpp"
8
8
  #include "duckdb/main/settings.hpp"
9
9
  #include "duckdb/storage/storage_extension.hpp"
10
+ #include "duckdb/common/serializer/serializer.hpp"
10
11
 
11
12
  #ifndef DUCKDB_NO_THREADS
12
13
  #include "duckdb/common/thread.hpp"
@@ -92,6 +93,7 @@ static const ConfigurationOption internal_options[] = {
92
93
  DUCKDB_GLOBAL_ALIAS("null_order", DefaultNullOrderSetting),
93
94
  DUCKDB_GLOBAL(DefaultOrderSetting),
94
95
  DUCKDB_GLOBAL(DefaultSecretStorageSetting),
96
+ DUCKDB_GLOBAL(DisabledCompressionMethodsSetting),
95
97
  DUCKDB_GLOBAL(DisabledFilesystemsSetting),
96
98
  DUCKDB_GLOBAL(DisabledLogTypes),
97
99
  DUCKDB_GLOBAL(DisabledOptimizersSetting),
@@ -460,7 +462,7 @@ idx_t DBConfig::GetSystemMaxThreads(FileSystem &fs) {
460
462
  }
461
463
  return MaxValue<idx_t>(CGroups::GetCPULimit(fs, physical_cores), 1);
462
464
  #else
463
- return physical_cores;
465
+ return MaxValue<idx_t>(physical_cores, 1);
464
466
  #endif
465
467
  #endif
466
468
  }
@@ -740,6 +742,22 @@ bool DBConfig::CanAccessFile(const string &input_path, FileType type) {
740
742
  return true;
741
743
  }
742
744
 
745
+ SerializationOptions::SerializationOptions(AttachedDatabase &db) {
746
+ serialization_compatibility = SerializationCompatibility::FromDatabase(db);
747
+ }
748
+
749
+ SerializationCompatibility SerializationCompatibility::FromDatabase(AttachedDatabase &db) {
750
+ return FromIndex(db.GetStorageManager().GetStorageVersion());
751
+ }
752
+
753
+ SerializationCompatibility SerializationCompatibility::FromIndex(const idx_t version) {
754
+ SerializationCompatibility result;
755
+ result.duckdb_version = "";
756
+ result.serialization_version = version;
757
+ result.manually_set = false;
758
+ return result;
759
+ }
760
+
743
761
  SerializationCompatibility SerializationCompatibility::FromString(const string &input) {
744
762
  if (input.empty()) {
745
763
  throw InvalidInputException("Version string can not be empty");
@@ -748,7 +766,7 @@ SerializationCompatibility SerializationCompatibility::FromString(const string &
748
766
  auto serialization_version = GetSerializationVersion(input.c_str());
749
767
  if (!serialization_version.IsValid()) {
750
768
  auto candidates = GetSerializationCandidates();
751
- throw InvalidInputException("The version string '%s' is not a valid DuckDB version, valid options are: %s",
769
+ throw InvalidInputException("The version string '%s' is not a known DuckDB version, valid options are: %s",
752
770
  input, StringUtil::Join(candidates, ", "));
753
771
  }
754
772
  SerializationCompatibility result;
@@ -28,9 +28,10 @@ Connection::Connection(DatabaseInstance &database)
28
28
  }
29
29
 
30
30
  Connection::Connection(DuckDB &database) : Connection(*database.instance) {
31
+ // Initialization of warning_cb happens in the other constructor
31
32
  }
32
33
 
33
- Connection::Connection(Connection &&other) noexcept {
34
+ Connection::Connection(Connection &&other) noexcept : warning_cb(nullptr) {
34
35
  std::swap(context, other.context);
35
36
  std::swap(warning_cb, other.warning_cb);
36
37
  }
@@ -98,34 +99,6 @@ unique_ptr<MaterializedQueryResult> Connection::Query(const string &query) {
98
99
  return unique_ptr_cast<QueryResult, MaterializedQueryResult>(std::move(result));
99
100
  }
100
101
 
101
- DUCKDB_API string Connection::GetSubstrait(const string &query) {
102
- vector<Value> params;
103
- params.emplace_back(query);
104
- auto result = TableFunction("get_substrait", params)->Execute();
105
- auto protobuf = result->FetchRaw()->GetValue(0, 0);
106
- return protobuf.GetValueUnsafe<string_t>().GetString();
107
- }
108
-
109
- DUCKDB_API unique_ptr<QueryResult> Connection::FromSubstrait(const string &proto) {
110
- vector<Value> params;
111
- params.emplace_back(Value::BLOB_RAW(proto));
112
- return TableFunction("from_substrait", params)->Execute();
113
- }
114
-
115
- DUCKDB_API string Connection::GetSubstraitJSON(const string &query) {
116
- vector<Value> params;
117
- params.emplace_back(query);
118
- auto result = TableFunction("get_substrait_json", params)->Execute();
119
- auto protobuf = result->FetchRaw()->GetValue(0, 0);
120
- return protobuf.GetValueUnsafe<string_t>().GetString();
121
- }
122
-
123
- DUCKDB_API unique_ptr<QueryResult> Connection::FromSubstraitJSON(const string &json) {
124
- vector<Value> params;
125
- params.emplace_back(json);
126
- return TableFunction("from_substrait_json", params)->Execute();
127
- }
128
-
129
102
  unique_ptr<MaterializedQueryResult> Connection::Query(unique_ptr<SQLStatement> statement) {
130
103
  auto result = context->Query(std::move(statement), false);
131
104
  D_ASSERT(result->type == QueryResultType::MATERIALIZED_RESULT);
@@ -5,7 +5,7 @@
5
5
 
6
6
  namespace duckdb {
7
7
 
8
- ConnectionManager::ConnectionManager() {
8
+ ConnectionManager::ConnectionManager() : connection_count(0) {
9
9
  }
10
10
 
11
11
  void ConnectionManager::AddConnection(ClientContext &context) {
@@ -14,6 +14,7 @@ void ConnectionManager::AddConnection(ClientContext &context) {
14
14
  callback->OnConnectionOpened(context);
15
15
  }
16
16
  connections[context] = weak_ptr<ClientContext>(context.shared_from_this());
17
+ connection_count = connections.size();
17
18
  }
18
19
 
19
20
  void ConnectionManager::RemoveConnection(ClientContext &context) {
@@ -22,11 +23,11 @@ void ConnectionManager::RemoveConnection(ClientContext &context) {
22
23
  callback->OnConnectionClosed(context);
23
24
  }
24
25
  connections.erase(context);
26
+ connection_count = connections.size();
25
27
  }
26
28
 
27
29
  idx_t ConnectionManager::GetConnectionCount() const {
28
- lock_guard<mutex> lock(connections_lock);
29
- return connections.size();
30
+ return connection_count;
30
31
  }
31
32
 
32
33
  vector<shared_ptr<ClientContext>> ConnectionManager::GetConnectionList() {
@@ -36,6 +37,7 @@ vector<shared_ptr<ClientContext>> ConnectionManager::GetConnectionList() {
36
37
  auto connection = it.second.lock();
37
38
  if (!connection) {
38
39
  connections.erase(it.first);
40
+ connection_count = connections.size();
39
41
  continue;
40
42
  } else {
41
43
  result.push_back(std::move(connection));
@@ -462,7 +462,7 @@ void DatabaseInstance::Configure(DBConfig &new_config, const char *database_path
462
462
  config.options.buffer_manager_track_eviction_timestamps,
463
463
  config.options.allocator_bulk_deallocation_flush_threshold);
464
464
  }
465
- config.db_cache_entry = new_config.db_cache_entry;
465
+ config.db_cache_entry = std::move(new_config.db_cache_entry);
466
466
  }
467
467
 
468
468
  DBConfig &DBConfig::GetConfig(ClientContext &context) {
@@ -508,7 +508,7 @@ void DatabaseInstance::SetExtensionLoaded(const string &name, ExtensionInstallIn
508
508
  for (auto &callback : callbacks) {
509
509
  callback->OnExtensionLoaded(*this, name);
510
510
  }
511
- Logger::Info("duckdb.Extensions.ExtensionLoaded", *this, name);
511
+ DUCKDB_LOG_INFO(*this, "duckdb.Extensions.ExtensionLoaded", name);
512
512
  }
513
513
 
514
514
  SettingLookupResult DatabaseInstance::TryGetCurrentSetting(const std::string &key, Value &result) const {
@@ -114,7 +114,6 @@ static const DefaultExtension internal_extensions[] = {
114
114
  {"postgres_scanner", "Adds support for connecting to a Postgres database", false},
115
115
  {"inet", "Adds support for IP-related data types and functions", false},
116
116
  {"spatial", "Geospatial extension that adds support for working with spatial data and functions", false},
117
- {"substrait", "Adds support for the Substrait integration", false},
118
117
  {"aws", "Provides features that depend on the AWS SDK", false},
119
118
  {"arrow", "A zero-copy data integration between Apache Arrow and DuckDB", false},
120
119
  {"azure", "Adds a filesystem abstraction for Azure blob storage to DuckDB", false},
@@ -140,13 +139,13 @@ DefaultExtension ExtensionHelper::GetDefaultExtension(idx_t index) {
140
139
  // Allow Auto-Install Extensions
141
140
  //===--------------------------------------------------------------------===//
142
141
  static const char *const auto_install[] = {"motherduck", "postgres_scanner", "mysql_scanner", "sqlite_scanner",
143
- nullptr};
142
+ "delta", "iceberg", "uc_catalog", nullptr};
144
143
 
145
144
  // TODO: unify with new autoload mechanism
146
145
  bool ExtensionHelper::AllowAutoInstall(const string &extension) {
147
- auto lcase = StringUtil::Lower(extension);
146
+ auto extension_name = ApplyExtensionAlias(extension);
148
147
  for (idx_t i = 0; auto_install[i]; i++) {
149
- if (lcase == auto_install[i]) {
148
+ if (extension_name == auto_install[i]) {
150
149
  return true;
151
150
  }
152
151
  }
@@ -389,7 +388,7 @@ void ExtensionHelper::AutoLoadExtension(DatabaseInstance &db, const string &exte
389
388
  }
390
389
  #endif
391
390
  ExtensionHelper::LoadExternalExtension(db, *fs, extension_name);
392
- Logger::Info("duckdb.Extensions.ExtensionAutoloaded", db, extension_name);
391
+ DUCKDB_LOG_INFO(db, "duckdb.Extensions.ExtensionAutoloaded", extension_name);
393
392
 
394
393
  } catch (std::exception &e) {
395
394
  ErrorData error(e);
@@ -56,6 +56,18 @@ const vector<string> ExtensionHelper::PathComponents() {
56
56
  return vector<string> {GetVersionDirectoryName(), DuckDB::Platform()};
57
57
  }
58
58
 
59
+ string ExtensionHelper::ExtensionInstallDocumentationLink(const string &extension_name) {
60
+ auto components = PathComponents();
61
+
62
+ string link = "https://duckdb.org/docs/extensions/troubleshooting";
63
+
64
+ if (components.size() >= 2) {
65
+ link += "/?version=" + components[0] + "&platform=" + components[1] + "&extension=" + extension_name;
66
+ }
67
+
68
+ return link;
69
+ }
70
+
59
71
  duckdb::string ExtensionHelper::DefaultExtensionFolder(FileSystem &fs) {
60
72
  string home_directory = fs.GetHomeDirectory();
61
73
  // exception if the home directory does not exist, don't create whatever we think is home
@@ -90,6 +102,12 @@ string ExtensionHelper::GetExtensionDirectoryPath(DatabaseInstance &db, FileSyst
90
102
  extension_directory = fs.ConvertSeparators(extension_directory);
91
103
  // expand ~ in extension directory
92
104
  extension_directory = fs.ExpandPath(extension_directory);
105
+
106
+ auto path_components = PathComponents();
107
+ for (auto &path_ele : path_components) {
108
+ extension_directory = fs.JoinPath(extension_directory, path_ele);
109
+ }
110
+
93
111
  return extension_directory;
94
112
  }
95
113
 
@@ -117,13 +135,6 @@ string ExtensionHelper::ExtensionDirectory(DatabaseInstance &db, FileSystem &fs)
117
135
  }
118
136
  D_ASSERT(fs.DirectoryExists(extension_directory));
119
137
 
120
- auto path_components = PathComponents();
121
- for (auto &path_ele : path_components) {
122
- extension_directory = fs.JoinPath(extension_directory, path_ele);
123
- if (!fs.DirectoryExists(extension_directory)) {
124
- fs.CreateDirectory(extension_directory);
125
- }
126
- }
127
138
  return extension_directory;
128
139
  }
129
140
 
@@ -445,9 +456,11 @@ static unique_ptr<ExtensionInstallInfo> InstallFromHttpUrl(DatabaseInstance &db,
445
456
  if (!should_retry || retry_count >= MAX_RETRY_COUNT) {
446
457
  // if we should not retry or exceeded the number of retries - bubble up the error
447
458
  string message;
448
- auto exact_match = ExtensionHelper::CreateSuggestions(extension_name, message);
449
- if (exact_match && !ExtensionHelper::IsRelease(DuckDB::LibraryVersion())) {
450
- message += "\nAre you using a development build? In this case, extensions might not (yet) be uploaded.";
459
+ ExtensionHelper::CreateSuggestions(extension_name, message);
460
+
461
+ auto documentation_link = ExtensionHelper::ExtensionInstallDocumentationLink(extension_name);
462
+ if (!documentation_link.empty()) {
463
+ message += "\nFor more info, visit " + documentation_link;
451
464
  }
452
465
  if (res.error() == duckdb_httplib::Error::Success) {
453
466
  throw HTTPException(res.value(), "Failed to download extension \"%s\" at URL \"%s%s\" (HTTP %n)\n%s",
@@ -399,15 +399,13 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
399
399
  signature_valid = false;
400
400
  }
401
401
 
402
- if (!signature_valid) {
403
- throw IOException(db.config.error_manager->FormatException(ErrorType::UNSIGNED_EXTENSION, filename) +
404
- metadata_mismatch_error);
405
- }
406
-
407
402
  if (!metadata_mismatch_error.empty()) {
408
- // Signed extensions perform the full check
409
403
  throw InvalidInputException(metadata_mismatch_error);
410
404
  }
405
+
406
+ if (!signature_valid) {
407
+ throw IOException(db.config.error_manager->FormatException(ErrorType::UNSIGNED_EXTENSION, filename));
408
+ }
411
409
  } else if (!db.config.options.allow_extensions_metadata_mismatch) {
412
410
  if (!metadata_mismatch_error.empty()) {
413
411
  // Unsigned extensions AND configuration allowing n, loading allowed, mainly for
@@ -483,7 +481,8 @@ ExtensionInitResult ExtensionHelper::InitialLoad(DatabaseInstance &db, FileSyste
483
481
  string error;
484
482
  ExtensionInitResult result;
485
483
  if (!TryInitialLoad(db, fs, extension, result, error)) {
486
- if (!ExtensionHelper::AllowAutoInstall(extension)) {
484
+ auto &config = DBConfig::GetConfig(db);
485
+ if (!config.options.autoinstall_known_extensions || !ExtensionHelper::AllowAutoInstall(extension)) {
487
486
  throw IOException(error);
488
487
  }
489
488
  // the extension load failed - try installing the extension
@@ -50,18 +50,29 @@ string ParsedExtensionMetaData::GetInvalidMetadataError() {
50
50
  const string engine_version = string(ExtensionHelper::GetVersionDirectoryName());
51
51
 
52
52
  if (engine_version != duckdb_version) {
53
- result += StringUtil::Format("The file was built for DuckDB version '%s', but we can only load extensions "
54
- "built for DuckDB version '%s'.",
53
+ result += StringUtil::Format("The file was built specifically for DuckDB version '%s' and can only be "
54
+ "loaded with that version of DuckDB. (this version of DuckDB is '%s')",
55
55
  PrettyPrintString(duckdb_version), engine_version);
56
56
  }
57
- // C_STRUCT ABI versioning works when current duckdb version >= required version
57
+ // C_STRUCT ABI versioning
58
58
  } else if (abi_type == ExtensionABIType::C_STRUCT) {
59
-
60
- if (!VersioningUtils::IsSupportedCAPIVersion(duckdb_capi_version)) {
61
- result += StringUtil::Format("The file was built for DuckDB version '%s', but we can only load extensions "
62
- "built for DuckDB C API 'v%lld.%lld.%lld' and lower.",
63
- duckdb_capi_version, DUCKDB_EXTENSION_API_VERSION_MAJOR,
64
- DUCKDB_EXTENSION_API_VERSION_MINOR, DUCKDB_EXTENSION_API_VERSION_PATCH);
59
+ idx_t major, minor, patch;
60
+ if (!VersioningUtils::ParseSemver(duckdb_capi_version, major, minor, patch)) {
61
+ result += StringUtil::Format("The file was built for DuckDB C API version '%s', which failed to parse as a "
62
+ "recognized version string",
63
+ duckdb_capi_version, DUCKDB_EXTENSION_API_VERSION_MAJOR);
64
+ } else if (major != DUCKDB_EXTENSION_API_VERSION_MAJOR) {
65
+ // Special case where the extension is built for a completely unsupported API
66
+ result +=
67
+ StringUtil::Format("The file was built for DuckDB C API version '%s', but we can only load extensions "
68
+ "built for DuckDB C API 'v%lld.x.y'.",
69
+ duckdb_capi_version, DUCKDB_EXTENSION_API_VERSION_MAJOR);
70
+ } else if (!VersioningUtils::IsSupportedCAPIVersion(major, minor, patch)) {
71
+ result +=
72
+ StringUtil::Format("The file was built for DuckDB C API version '%s', but we can only load extensions "
73
+ "built for DuckDB C API 'v%lld.%lld.%lld' and lower.",
74
+ duckdb_capi_version, DUCKDB_EXTENSION_API_VERSION_MAJOR,
75
+ DUCKDB_EXTENSION_API_VERSION_MINOR, DUCKDB_EXTENSION_API_VERSION_PATCH);
65
76
  }
66
77
  } else {
67
78
  throw InternalException("Unknown ABI type for extension: " + extension_abi_metadata);
@@ -137,4 +148,11 @@ bool VersioningUtils::ParseSemver(string &semver, idx_t &major_out, idx_t &minor
137
148
  return true;
138
149
  }
139
150
 
151
+ const char *Extension::DefaultVersion() {
152
+ if (ExtensionHelper::IsRelease(DuckDB::LibraryVersion())) {
153
+ return DuckDB::LibraryVersion();
154
+ }
155
+ return DuckDB::SourceID();
156
+ }
157
+
140
158
  } // namespace duckdb
@@ -489,6 +489,17 @@ vector<SecretEntry> SecretManager::AllSecrets(CatalogTransaction transaction) {
489
489
  return result;
490
490
  }
491
491
 
492
+ vector<SecretType> SecretManager::AllSecretTypes() {
493
+ unique_lock<mutex> lck(manager_lock);
494
+ vector<SecretType> result;
495
+
496
+ for (const auto &secret : secret_types) {
497
+ result.push_back(secret.second);
498
+ }
499
+
500
+ return result;
501
+ }
502
+
492
503
  void SecretManager::ThrowOnSettingChangeIfInitialized() {
493
504
  if (initialized) {
494
505
  throw InvalidInputException(
@@ -499,6 +499,50 @@ Value DefaultSecretStorageSetting::GetSetting(const ClientContext &context) {
499
499
  return config.secret_manager->DefaultStorage();
500
500
  }
501
501
 
502
+ //===----------------------------------------------------------------------===//
503
+ // Disabled Compression Methods
504
+ //===----------------------------------------------------------------------===//
505
+ void DisabledCompressionMethodsSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
506
+ auto list = StringUtil::Split(input.ToString(), ",");
507
+ set<CompressionType> disabled_compression_methods;
508
+ for (auto &entry : list) {
509
+ auto param = StringUtil::Lower(entry);
510
+ StringUtil::Trim(param);
511
+ if (param.empty()) {
512
+ continue;
513
+ }
514
+ if (param == "none") {
515
+ disabled_compression_methods.clear();
516
+ break;
517
+ }
518
+ auto compression_type = CompressionTypeFromString(param);
519
+ if (compression_type == CompressionType::COMPRESSION_UNCOMPRESSED) {
520
+ throw InvalidInputException("Uncompressed compression cannot be disabled");
521
+ }
522
+ if (compression_type == CompressionType::COMPRESSION_AUTO) {
523
+ throw InvalidInputException("Unrecognized compression method \"%s\"", entry);
524
+ }
525
+ disabled_compression_methods.insert(compression_type);
526
+ }
527
+ config.options.disabled_compression_methods = std::move(disabled_compression_methods);
528
+ }
529
+
530
+ void DisabledCompressionMethodsSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
531
+ config.options.disabled_compression_methods = DBConfig().options.disabled_compression_methods;
532
+ }
533
+
534
+ Value DisabledCompressionMethodsSetting::GetSetting(const ClientContext &context) {
535
+ auto &config = DBConfig::GetConfig(context);
536
+ string result;
537
+ for (auto &optimizer : config.options.disabled_compression_methods) {
538
+ if (!result.empty()) {
539
+ result += ",";
540
+ }
541
+ result += CompressionTypeToString(optimizer);
542
+ }
543
+ return Value(result);
544
+ }
545
+
502
546
  //===----------------------------------------------------------------------===//
503
547
  // Disabled Filesystems
504
548
  //===----------------------------------------------------------------------===//
@@ -102,6 +102,12 @@ void ColumnLifetimeAnalyzer::VisitOperator(LogicalOperator &op) {
102
102
  GenerateProjectionMap(op.children[1]->GetColumnBindings(), rhs_unused, comp_join.right_projection_map);
103
103
  return;
104
104
  }
105
+ case LogicalOperatorType::LOGICAL_INSERT:
106
+ case LogicalOperatorType::LOGICAL_UPDATE:
107
+ case LogicalOperatorType::LOGICAL_DELETE:
108
+ //! When RETURNING is used, a PROJECTION is the top level operator for INSERTS, UPDATES, and DELETES
109
+ //! We still need to project all values from these operators so the projection
110
+ //! on top of them can select from only the table values being inserted.
105
111
  case LogicalOperatorType::LOGICAL_UNION:
106
112
  case LogicalOperatorType::LOGICAL_EXCEPT:
107
113
  case LogicalOperatorType::LOGICAL_INTERSECT:
@@ -78,6 +78,7 @@ FilterResult FilterCombiner::AddConstantComparison(vector<ExpressionValueInforma
78
78
  return FilterResult::SUCCESS;
79
79
  case ValueComparisonResult::UNSATISFIABLE_CONDITION:
80
80
  // combination of filters is unsatisfiable: prune the entire branch
81
+ info_list.push_back(info);
81
82
  return FilterResult::UNSATISFIABLE;
82
83
  default:
83
84
  // prune nothing, move to the next condition
@@ -792,11 +793,15 @@ FilterResult FilterCombiner::AddBoundComparisonFilter(Expression &expr) {
792
793
  auto transitive_filter = FindTransitiveFilter(non_scalar);
793
794
  if (transitive_filter != nullptr) {
794
795
  // try to add transitive filters
795
- if (AddTransitiveFilters(transitive_filter->Cast<BoundComparisonExpression>()) ==
796
- FilterResult::UNSUPPORTED) {
796
+ auto transitive_result = AddTransitiveFilters(transitive_filter->Cast<BoundComparisonExpression>());
797
+ if (transitive_result == FilterResult::UNSUPPORTED) {
797
798
  // in case of unsuccessful re-add filter into remaining ones
798
799
  remaining_filters.push_back(std::move(transitive_filter));
799
800
  }
801
+ if (transitive_result == FilterResult::UNSATISFIABLE) {
802
+ // in case transitive filter is unsatisfiable - abort filter pushdown
803
+ return FilterResult::UNSATISFIABLE;
804
+ }
800
805
  }
801
806
  return ret;
802
807
  } else {
@@ -1067,10 +1072,15 @@ FilterResult FilterCombiner::AddTransitiveFilters(BoundComparisonExpression &com
1067
1072
  if (transitive_filter != nullptr) {
1068
1073
  // try to add transitive filters
1069
1074
  auto &transitive_cast = transitive_filter->Cast<BoundComparisonExpression>();
1070
- if (AddTransitiveFilters(transitive_cast, false) == FilterResult::UNSUPPORTED) {
1075
+ auto transitive_result = AddTransitiveFilters(transitive_cast, false);
1076
+ if (transitive_result == FilterResult::UNSUPPORTED) {
1071
1077
  // in case of unsuccessful re-add filter into remaining ones
1072
1078
  remaining_filters.push_back(std::move(transitive_filter));
1073
1079
  }
1080
+ if (transitive_result == FilterResult::UNSATISFIABLE) {
1081
+ // while adding transitive filters we discovered the filter is unsatisfisable - we can prune
1082
+ return FilterResult::UNSATISFIABLE;
1083
+ }
1074
1084
  }
1075
1085
  }
1076
1086
  return FilterResult::SUCCESS;