duckdb 0.10.1 → 0.10.2-dev3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (699) hide show
  1. package/binding.gyp +22 -18
  2. package/binding.gyp.in +3 -0
  3. package/package.json +1 -1
  4. package/src/duckdb/extension/icu/icu-timezone.cpp +3 -1
  5. package/src/duckdb/extension/icu/icu_extension.cpp +6 -2
  6. package/src/duckdb/extension/json/buffered_json_reader.cpp +10 -3
  7. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +2 -0
  8. package/src/duckdb/extension/json/include/json_scan.hpp +13 -7
  9. package/src/duckdb/extension/json/include/json_serializer.hpp +5 -4
  10. package/src/duckdb/extension/json/include/json_structure.hpp +3 -3
  11. package/src/duckdb/extension/json/json_functions/json_serialize_plan.cpp +15 -5
  12. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +15 -6
  13. package/src/duckdb/extension/json/json_functions/json_structure.cpp +21 -20
  14. package/src/duckdb/extension/json/json_functions/read_json.cpp +37 -3
  15. package/src/duckdb/extension/json/json_functions.cpp +7 -2
  16. package/src/duckdb/extension/json/json_scan.cpp +57 -33
  17. package/src/duckdb/extension/parquet/column_reader.cpp +12 -3
  18. package/src/duckdb/extension/parquet/column_writer.cpp +44 -7
  19. package/src/duckdb/extension/parquet/include/parquet_writer.hpp +5 -1
  20. package/src/duckdb/extension/parquet/parquet_extension.cpp +30 -3
  21. package/src/duckdb/extension/parquet/parquet_metadata.cpp +1 -1
  22. package/src/duckdb/extension/parquet/parquet_writer.cpp +4 -2
  23. package/src/duckdb/extension/parquet/zstd_file_system.cpp +1 -1
  24. package/src/duckdb/src/catalog/catalog.cpp +5 -1
  25. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +21 -5
  26. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +8 -9
  27. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -7
  28. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +1 -1
  29. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +6 -7
  30. package/src/duckdb/src/catalog/catalog_entry.cpp +8 -0
  31. package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -0
  32. package/src/duckdb/src/catalog/catalog_set.cpp +2 -2
  33. package/src/duckdb/src/catalog/default/default_functions.cpp +6 -6
  34. package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
  35. package/src/duckdb/src/catalog/default/default_views.cpp +7 -7
  36. package/src/duckdb/src/catalog/dependency_catalog_set.cpp +2 -1
  37. package/src/duckdb/src/catalog/dependency_list.cpp +92 -8
  38. package/src/duckdb/src/catalog/dependency_manager.cpp +53 -68
  39. package/src/duckdb/src/catalog/duck_catalog.cpp +1 -1
  40. package/src/duckdb/src/common/adbc/adbc.cpp +287 -45
  41. package/src/duckdb/src/common/arrow/appender/union_data.cpp +2 -2
  42. package/src/duckdb/src/common/box_renderer.cpp +12 -12
  43. package/src/duckdb/src/common/crypto/md5.cpp +2 -1
  44. package/src/duckdb/src/common/enum_util.cpp +307 -1
  45. package/src/duckdb/src/common/enums/expression_type.cpp +4 -0
  46. package/src/duckdb/src/common/enums/optimizer_type.cpp +1 -1
  47. package/src/duckdb/src/common/file_system.cpp +60 -13
  48. package/src/duckdb/src/common/filename_pattern.cpp +13 -13
  49. package/src/duckdb/src/common/gzip_file_system.cpp +1 -1
  50. package/src/duckdb/src/common/http_state.cpp +1 -1
  51. package/src/duckdb/src/common/local_file_system.cpp +72 -71
  52. package/src/duckdb/src/common/multi_file_reader.cpp +48 -28
  53. package/src/duckdb/src/common/row_operations/row_matcher.cpp +2 -2
  54. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +13 -1
  55. package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +32 -13
  56. package/src/duckdb/src/common/string_util.cpp +2 -3
  57. package/src/duckdb/src/common/tree_renderer.cpp +32 -67
  58. package/src/duckdb/src/common/types/bit.cpp +6 -6
  59. package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
  60. package/src/duckdb/src/common/types/hash.cpp +6 -6
  61. package/src/duckdb/src/common/types/hyperloglog.cpp +2 -0
  62. package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +13 -0
  63. package/src/duckdb/src/common/types/row/tuple_data_layout.cpp +5 -7
  64. package/src/duckdb/src/common/types/uuid.cpp +1 -1
  65. package/src/duckdb/src/common/types/vector.cpp +22 -14
  66. package/src/duckdb/src/common/types.cpp +8 -1
  67. package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +20 -18
  68. package/src/duckdb/src/common/vector_operations/generators.cpp +1 -1
  69. package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +267 -110
  70. package/src/duckdb/src/common/vector_operations/vector_hash.cpp +52 -23
  71. package/src/duckdb/src/common/virtual_file_system.cpp +33 -20
  72. package/src/duckdb/src/core_functions/aggregate/algebraic/avg.cpp +2 -2
  73. package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +3 -3
  74. package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +31 -16
  75. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +3 -0
  76. package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +2 -0
  77. package/src/duckdb/src/core_functions/core_functions.cpp +1 -1
  78. package/src/duckdb/src/core_functions/function_list.cpp +2 -2
  79. package/src/duckdb/src/core_functions/scalar/date/time_bucket.cpp +1 -1
  80. package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +46 -17
  81. package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +1 -1
  82. package/src/duckdb/src/core_functions/scalar/list/flatten.cpp +82 -45
  83. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -2
  84. package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +3 -0
  85. package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +3 -2
  86. package/src/duckdb/src/core_functions/scalar/string/hex.cpp +2 -4
  87. package/src/duckdb/src/core_functions/scalar/string/repeat.cpp +12 -21
  88. package/src/duckdb/src/execution/column_binding_resolver.cpp +2 -10
  89. package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +133 -66
  90. package/src/duckdb/src/execution/expression_executor/execute_function.cpp +0 -2
  91. package/src/duckdb/src/execution/expression_executor.cpp +0 -4
  92. package/src/duckdb/src/execution/expression_executor_state.cpp +1 -1
  93. package/src/duckdb/src/execution/index/art/art.cpp +2 -2
  94. package/src/duckdb/src/execution/index/unknown_index.cpp +13 -13
  95. package/src/duckdb/src/execution/join_hashtable.cpp +1 -1
  96. package/src/duckdb/src/execution/nested_loop_join/nested_loop_join_mark.cpp +0 -1
  97. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer.cpp +10 -7
  98. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.cpp +32 -1
  99. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_file_handle.cpp +16 -2
  100. package/src/duckdb/src/execution/operator/csv_scanner/scanner/scanner_boundary.cpp +7 -7
  101. package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +354 -159
  102. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +11 -2
  103. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +22 -7
  104. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +1 -1
  105. package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +10 -10
  106. package/src/duckdb/src/execution/operator/csv_scanner/table_function/csv_file_scanner.cpp +9 -18
  107. package/src/duckdb/src/execution/operator/csv_scanner/table_function/global_csv_state.cpp +180 -47
  108. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +100 -58
  109. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +88 -21
  110. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +12 -13
  111. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +2 -0
  112. package/src/duckdb/src/execution/operator/persistent/csv_rejects_table.cpp +118 -23
  113. package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +2 -2
  114. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +14 -5
  115. package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +1 -1
  116. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +5 -5
  117. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +1 -1
  118. package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +0 -9
  119. package/src/duckdb/src/execution/physical_plan/plan_vacuum.cpp +18 -0
  120. package/src/duckdb/src/execution/physical_plan_generator.cpp +5 -3
  121. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +81 -106
  122. package/src/duckdb/src/execution/reservoir_sample.cpp +1 -1
  123. package/src/duckdb/src/execution/window_executor.cpp +48 -28
  124. package/src/duckdb/src/execution/window_segment_tree.cpp +20 -23
  125. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +1 -1
  126. package/src/duckdb/src/function/cast/enum_casts.cpp +20 -55
  127. package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +10 -9
  128. package/src/duckdb/src/function/cast_rules.cpp +9 -1
  129. package/src/duckdb/src/function/compression_config.cpp +1 -1
  130. package/src/duckdb/src/function/function_binder.cpp +45 -44
  131. package/src/duckdb/src/function/function_set.cpp +9 -9
  132. package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -2
  133. package/src/duckdb/src/function/scalar/compressed_materialization/compress_integral.cpp +21 -5
  134. package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +2 -2
  135. package/src/duckdb/src/function/scalar/list/list_select.cpp +5 -2
  136. package/src/duckdb/src/function/scalar/list/list_zip.cpp +5 -4
  137. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +60 -32
  138. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +1 -1
  139. package/src/duckdb/src/function/scalar/strftime_format.cpp +31 -25
  140. package/src/duckdb/src/function/scalar/string/caseconvert.cpp +6 -6
  141. package/src/duckdb/src/function/scalar/string/length.cpp +23 -2
  142. package/src/duckdb/src/function/scalar/string/like.cpp +1 -1
  143. package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +1 -1
  144. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +3 -3
  145. package/src/duckdb/src/function/table/arrow/arrow_array_scan_state.cpp +1 -1
  146. package/src/duckdb/src/function/table/arrow.cpp +7 -1
  147. package/src/duckdb/src/function/table/copy_csv.cpp +17 -13
  148. package/src/duckdb/src/function/table/read_csv.cpp +52 -39
  149. package/src/duckdb/src/function/table/sniff_csv.cpp +7 -13
  150. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +1 -1
  151. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +7 -1
  152. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +12 -2
  153. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +1 -2
  154. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +2 -2
  155. package/src/duckdb/src/function/table/system/pragma_metadata_info.cpp +9 -2
  156. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +10 -6
  157. package/src/duckdb/src/function/table/table_scan.cpp +1 -4
  158. package/src/duckdb/src/function/table/version/pragma_version.cpp +3 -3
  159. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +6 -2
  160. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
  161. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +1 -1
  162. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
  163. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +6 -1
  164. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +3 -3
  165. package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +3 -3
  166. package/src/duckdb/src/include/duckdb/catalog/dependency.hpp +26 -4
  167. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +39 -6
  168. package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +19 -14
  169. package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +1 -1
  170. package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +4 -0
  171. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -3
  172. package/src/duckdb/src/include/duckdb/common/arrow/arrow_wrapper.hpp +1 -1
  173. package/src/duckdb/src/include/duckdb/common/bit_utils.hpp +1 -1
  174. package/src/duckdb/src/include/duckdb/common/box_renderer.hpp +16 -16
  175. package/src/duckdb/src/include/duckdb/common/crypto/md5.hpp +0 -1
  176. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +32 -0
  177. package/src/duckdb/src/include/duckdb/common/enums/expression_type.hpp +4 -2
  178. package/src/duckdb/src/include/duckdb/common/exception/binder_exception.hpp +14 -10
  179. package/src/duckdb/src/include/duckdb/common/exception/catalog_exception.hpp +4 -4
  180. package/src/duckdb/src/include/duckdb/common/exception/conversion_exception.hpp +6 -6
  181. package/src/duckdb/src/include/duckdb/common/exception/http_exception.hpp +3 -3
  182. package/src/duckdb/src/include/duckdb/common/exception/parser_exception.hpp +4 -4
  183. package/src/duckdb/src/include/duckdb/common/exception/transaction_exception.hpp +2 -2
  184. package/src/duckdb/src/include/duckdb/common/exception.hpp +57 -58
  185. package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +2 -2
  186. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +2 -2
  187. package/src/duckdb/src/include/duckdb/common/file_open_flags.hpp +134 -0
  188. package/src/duckdb/src/include/duckdb/common/file_opener.hpp +9 -6
  189. package/src/duckdb/src/include/duckdb/common/file_system.hpp +35 -36
  190. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +4 -6
  191. package/src/duckdb/src/include/duckdb/common/fixed_size_map.hpp +13 -13
  192. package/src/duckdb/src/include/duckdb/common/helper.hpp +42 -47
  193. package/src/duckdb/src/include/duckdb/common/http_state.hpp +1 -1
  194. package/src/duckdb/src/include/duckdb/common/hugeint.hpp +2 -2
  195. package/src/duckdb/src/include/duckdb/common/index_vector.hpp +10 -10
  196. package/src/duckdb/src/include/duckdb/common/local_file_system.hpp +13 -10
  197. package/src/duckdb/src/include/duckdb/common/memory_safety.hpp +3 -3
  198. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +1 -1
  199. package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +50 -24
  200. package/src/duckdb/src/include/duckdb/common/operator/abs.hpp +12 -4
  201. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +5 -5
  202. package/src/duckdb/src/include/duckdb/common/pipe_file_system.hpp +1 -1
  203. package/src/duckdb/src/include/duckdb/common/platform.h +1 -1
  204. package/src/duckdb/src/include/duckdb/common/printer.hpp +5 -5
  205. package/src/duckdb/src/include/duckdb/common/profiler.hpp +2 -2
  206. package/src/duckdb/src/include/duckdb/common/progress_bar/display/terminal_progress_bar_display.hpp +5 -5
  207. package/src/duckdb/src/include/duckdb/common/random_engine.hpp +1 -1
  208. package/src/duckdb/src/include/duckdb/common/re2_regex.hpp +7 -7
  209. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +3 -0
  210. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +2 -2
  211. package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +17 -6
  212. package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +12 -0
  213. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +14 -0
  214. package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +16 -0
  215. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +3 -0
  216. package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +2 -0
  217. package/src/duckdb/src/include/duckdb/common/string_util.hpp +4 -4
  218. package/src/duckdb/src/include/duckdb/common/tree_renderer.hpp +24 -25
  219. package/src/duckdb/src/include/duckdb/common/typedefs.hpp +5 -5
  220. package/src/duckdb/src/include/duckdb/common/types/cast_helpers.hpp +1 -2
  221. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +10 -10
  222. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_iterators.hpp +5 -5
  223. package/src/duckdb/src/include/duckdb/common/types/column/partitioned_column_data.hpp +1 -1
  224. package/src/duckdb/src/include/duckdb/common/types/constraint_conflict_info.hpp +1 -2
  225. package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -2
  226. package/src/duckdb/src/include/duckdb/common/types/date.hpp +1 -1
  227. package/src/duckdb/src/include/duckdb/common/types/hash.hpp +5 -5
  228. package/src/duckdb/src/include/duckdb/common/types/hyperloglog.hpp +1 -1
  229. package/src/duckdb/src/include/duckdb/common/types/interval.hpp +4 -4
  230. package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +1 -1
  231. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_layout.hpp +10 -3
  232. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +1 -1
  233. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +12 -12
  234. package/src/duckdb/src/include/duckdb/common/types/string_heap.hpp +1 -1
  235. package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +21 -20
  236. package/src/duckdb/src/include/duckdb/common/types/time.hpp +2 -2
  237. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +3 -3
  238. package/src/duckdb/src/include/duckdb/common/types/uuid.hpp +2 -2
  239. package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -2
  240. package/src/duckdb/src/include/duckdb/common/types/vector.hpp +15 -7
  241. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +1 -1
  242. package/src/duckdb/src/include/duckdb/common/types.hpp +14 -10
  243. package/src/duckdb/src/include/duckdb/common/uhugeint.hpp +2 -2
  244. package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +1 -1
  245. package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +15 -14
  246. package/src/duckdb/src/include/duckdb/common/vector.hpp +21 -21
  247. package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +2 -0
  248. package/src/duckdb/src/include/duckdb/common/vector_operations/general_cast.hpp +2 -1
  249. package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +2 -3
  250. package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +3 -2
  251. package/src/duckdb/src/include/duckdb/common/vector_operations/vector_operations.hpp +50 -32
  252. package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +10 -11
  253. package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +1 -1
  254. package/src/duckdb/src/include/duckdb/core_functions/aggregate/sum_helpers.hpp +13 -1
  255. package/src/duckdb/src/include/duckdb/core_functions/function_list.hpp +1 -1
  256. package/src/duckdb/src/include/duckdb/core_functions/lambda_functions.hpp +2 -1
  257. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
  258. package/src/duckdb/src/include/duckdb/execution/column_binding_resolver.hpp +1 -1
  259. package/src/duckdb/src/include/duckdb/execution/expression_executor.hpp +1 -1
  260. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +2 -5
  261. package/src/duckdb/src/include/duckdb/execution/merge_sort_tree.hpp +3 -3
  262. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/aggregate_object.hpp +2 -2
  263. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/distinct_aggregate_data.hpp +1 -1
  264. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +1 -1
  265. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +0 -3
  266. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer.hpp +9 -6
  267. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer_manager.hpp +3 -0
  268. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_error.hpp +40 -22
  269. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_handle.hpp +5 -0
  270. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_scanner.hpp +1 -0
  271. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_option.hpp +6 -4
  272. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_reader_options.hpp +24 -10
  273. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp +4 -0
  274. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/global_csv_state.hpp +3 -1
  275. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/skip_scanner.hpp +0 -3
  276. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +58 -17
  277. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -1
  278. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +1 -1
  279. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +3 -3
  280. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -1
  281. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +4 -1
  282. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_rejects_table.hpp +16 -5
  283. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +6 -6
  284. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
  285. package/src/duckdb/src/include/duckdb/execution/window_executor.hpp +1 -1
  286. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  287. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +1 -1
  288. package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +5 -5
  289. package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +4 -4
  290. package/src/duckdb/src/include/duckdb/function/cast/vector_cast_helpers.hpp +6 -6
  291. package/src/duckdb/src/include/duckdb/function/compression_function.hpp +4 -4
  292. package/src/duckdb/src/include/duckdb/function/copy_function.hpp +10 -13
  293. package/src/duckdb/src/include/duckdb/function/function.hpp +3 -3
  294. package/src/duckdb/src/include/duckdb/function/function_binder.hpp +24 -23
  295. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -1
  296. package/src/duckdb/src/include/duckdb/function/function_set.hpp +1 -1
  297. package/src/duckdb/src/include/duckdb/function/pragma_function.hpp +1 -1
  298. package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +3 -3
  299. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +7 -7
  300. package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +3 -3
  301. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +6 -6
  302. package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +4 -4
  303. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +2 -2
  304. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -3
  305. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -1
  306. package/src/duckdb/src/include/duckdb/function/table_function.hpp +12 -11
  307. package/src/duckdb/src/include/duckdb/function/udf_function.hpp +66 -60
  308. package/src/duckdb/src/include/duckdb/main/appender.hpp +6 -6
  309. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +3 -1
  310. package/src/duckdb/src/include/duckdb/main/buffered_data/buffered_data.hpp +2 -2
  311. package/src/duckdb/src/include/duckdb/main/buffered_data/simple_buffered_data.hpp +1 -1
  312. package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +2 -2
  313. package/src/duckdb/src/include/duckdb/main/chunk_scan_state/query_result.hpp +2 -2
  314. package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
  315. package/src/duckdb/src/include/duckdb/main/client_context_file_opener.hpp +3 -2
  316. package/src/duckdb/src/include/duckdb/main/client_data.hpp +1 -0
  317. package/src/duckdb/src/include/duckdb/main/client_properties.hpp +2 -1
  318. package/src/duckdb/src/include/duckdb/main/config.hpp +14 -5
  319. package/src/duckdb/src/include/duckdb/main/connection.hpp +27 -26
  320. package/src/duckdb/src/include/duckdb/main/database.hpp +19 -3
  321. package/src/duckdb/src/include/duckdb/main/database_file_opener.hpp +58 -0
  322. package/src/duckdb/src/include/duckdb/main/database_path_and_type.hpp +2 -2
  323. package/src/duckdb/src/include/duckdb/main/error_manager.hpp +6 -6
  324. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +8 -0
  325. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +1 -0
  326. package/src/duckdb/src/include/duckdb/main/external_dependencies.hpp +2 -1
  327. package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +8 -8
  328. package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +2 -59
  329. package/src/duckdb/src/include/duckdb/main/query_result.hpp +3 -3
  330. package/src/duckdb/src/include/duckdb/main/relation/query_relation.hpp +1 -1
  331. package/src/duckdb/src/include/duckdb/main/relation.hpp +1 -1
  332. package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +11 -7
  333. package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +2 -2
  334. package/src/duckdb/src/include/duckdb/main/secret/secret_storage.hpp +4 -4
  335. package/src/duckdb/src/include/duckdb/main/settings.hpp +78 -70
  336. package/src/duckdb/src/include/duckdb/optimizer/column_lifetime_analyzer.hpp +45 -0
  337. package/src/duckdb/src/include/duckdb/optimizer/compressed_materialization.hpp +11 -13
  338. package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +2 -2
  339. package/src/duckdb/src/include/duckdb/optimizer/join_order/cost_model.hpp +1 -1
  340. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_node.hpp +1 -1
  341. package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +1 -1
  342. package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph_manager.hpp +1 -1
  343. package/src/duckdb/src/include/duckdb/optimizer/join_order/relation_manager.hpp +1 -1
  344. package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +7 -7
  345. package/src/duckdb/src/include/duckdb/optimizer/matcher/function_matcher.hpp +7 -7
  346. package/src/duckdb/src/include/duckdb/optimizer/matcher/type_matcher.hpp +1 -1
  347. package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +3 -0
  348. package/src/duckdb/src/include/duckdb/optimizer/statistics_propagator.hpp +32 -30
  349. package/src/duckdb/src/include/duckdb/optimizer/unnest_rewriter.hpp +1 -1
  350. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  351. package/src/duckdb/src/include/duckdb/parallel/executor_task.hpp +1 -1
  352. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +2 -2
  353. package/src/duckdb/src/include/duckdb/parallel/pipeline_event.hpp +1 -1
  354. package/src/duckdb/src/include/duckdb/parser/column_list.hpp +4 -4
  355. package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +49 -8
  356. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +1 -1
  357. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  358. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  359. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_scalar_function_info.hpp +1 -1
  360. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_function_info.hpp +1 -1
  361. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
  362. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_database_info.hpp +40 -0
  363. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_function_info.hpp +2 -1
  364. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -0
  365. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +2 -1
  366. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +1 -1
  367. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +1 -1
  368. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_secret_info.hpp +2 -2
  369. package/src/duckdb/src/include/duckdb/parser/parsed_data/extra_drop_info.hpp +3 -3
  370. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +3 -2
  371. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +2 -5
  372. package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -1
  373. package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +3 -3
  374. package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +1 -1
  375. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +3 -5
  376. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -2
  377. package/src/duckdb/src/include/duckdb/planner/binder.hpp +16 -9
  378. package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +1 -1
  379. package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +1 -1
  380. package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +1 -1
  381. package/src/duckdb/src/include/duckdb/planner/expression/bound_expanded_expression.hpp +34 -0
  382. package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +1 -1
  383. package/src/duckdb/src/include/duckdb/planner/expression.hpp +1 -1
  384. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +5 -8
  385. package/src/duckdb/src/include/duckdb/planner/expression_binder/column_alias_binder.hpp +3 -4
  386. package/src/duckdb/src/include/duckdb/planner/expression_binder/group_binder.hpp +3 -2
  387. package/src/duckdb/src/include/duckdb/planner/expression_binder/having_binder.hpp +3 -5
  388. package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +6 -14
  389. package/src/duckdb/src/include/duckdb/planner/expression_binder/qualify_binder.hpp +3 -6
  390. package/src/duckdb/src/include/duckdb/planner/expression_binder/select_bind_state.hpp +52 -0
  391. package/src/duckdb/src/include/duckdb/planner/expression_binder/select_binder.hpp +4 -10
  392. package/src/duckdb/src/include/duckdb/planner/expression_binder/table_function_binder.hpp +5 -2
  393. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +1 -0
  394. package/src/duckdb/src/include/duckdb/planner/expression_iterator.hpp +2 -0
  395. package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +3 -6
  396. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +2 -0
  397. package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +1 -0
  398. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -0
  399. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_database.hpp +4 -12
  400. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_secret.hpp +1 -1
  401. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +2 -2
  402. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -1
  403. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -1
  404. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +1 -1
  405. package/src/duckdb/src/include/duckdb/planner/operator/logical_export.hpp +2 -2
  406. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +2 -2
  407. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +2 -2
  408. package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +2 -2
  409. package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +1 -1
  410. package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +3 -2
  411. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +3 -3
  412. package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +1 -1
  413. package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +2 -1
  414. package/src/duckdb/src/include/duckdb/planner/operator/logical_vacuum.hpp +52 -0
  415. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +1 -1
  416. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -2
  417. package/src/duckdb/src/include/duckdb/planner/query_node/bound_select_node.hpp +5 -4
  418. package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -2
  419. package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +4 -1
  420. package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +1 -1
  421. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +3 -3
  422. package/src/duckdb/src/include/duckdb/storage/checkpoint/row_group_writer.hpp +2 -3
  423. package/src/duckdb/src/include/duckdb/storage/checkpoint/string_checkpoint_state.hpp +1 -1
  424. package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +3 -3
  425. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +5 -5
  426. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_analyze.hpp +1 -1
  427. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_compress.hpp +1 -1
  428. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_fetch.hpp +1 -1
  429. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_scan.hpp +1 -1
  430. package/src/duckdb/src/include/duckdb/storage/compression/alprd/algorithm/alprd.hpp +3 -3
  431. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_analyze.hpp +2 -2
  432. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_compress.hpp +1 -1
  433. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_fetch.hpp +1 -1
  434. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_scan.hpp +3 -3
  435. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/flag_buffer.hpp +1 -1
  436. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/leading_zero_buffer.hpp +3 -3
  437. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp.hpp +3 -3
  438. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_analyze.hpp +0 -1
  439. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_fetch.hpp +1 -1
  440. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +4 -4
  441. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas.hpp +4 -4
  442. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_analyze.hpp +0 -1
  443. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_fetch.hpp +1 -1
  444. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +3 -3
  445. package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +1 -1
  446. package/src/duckdb/src/include/duckdb/storage/index.hpp +1 -1
  447. package/src/duckdb/src/include/duckdb/storage/magic_bytes.hpp +1 -1
  448. package/src/duckdb/src/include/duckdb/storage/object_cache.hpp +3 -3
  449. package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +1 -1
  450. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +1 -1
  451. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +4 -1
  452. package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +24 -24
  453. package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +3 -3
  454. package/src/duckdb/src/include/duckdb/storage/statistics/segment_statistics.hpp +2 -2
  455. package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +2 -2
  456. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +4 -4
  457. package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +9 -6
  458. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
  459. package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +2 -2
  460. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +1 -1
  461. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +10 -1
  462. package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -2
  463. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +1 -1
  464. package/src/duckdb/src/include/duckdb/storage/table/row_group_segment_tree.hpp +1 -1
  465. package/src/duckdb/src/include/duckdb/storage/table/row_version_manager.hpp +2 -1
  466. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +3 -3
  467. package/src/duckdb/src/include/duckdb/storage/table/segment_lock.hpp +1 -1
  468. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +4 -4
  469. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +2 -0
  470. package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +3 -2
  471. package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +1 -1
  472. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +1 -1
  473. package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +2 -1
  474. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +1 -1
  475. package/src/duckdb/src/include/duckdb/transaction/delete_info.hpp +20 -1
  476. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +1 -1
  477. package/src/duckdb/src/include/duckdb/transaction/transaction_data.hpp +1 -1
  478. package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
  479. package/src/duckdb/src/include/duckdb/transaction/update_info.hpp +1 -1
  480. package/src/duckdb/src/main/appender.cpp +1 -1
  481. package/src/duckdb/src/main/attached_database.cpp +11 -3
  482. package/src/duckdb/src/main/capi/arrow-c.cpp +6 -2
  483. package/src/duckdb/src/main/capi/cast/utils-c.cpp +1 -1
  484. package/src/duckdb/src/main/capi/duckdb-c.cpp +1 -1
  485. package/src/duckdb/src/main/capi/pending-c.cpp +1 -1
  486. package/src/duckdb/src/main/capi/prepared-c.cpp +2 -2
  487. package/src/duckdb/src/main/capi/result-c.cpp +4 -4
  488. package/src/duckdb/src/main/client_context.cpp +4 -12
  489. package/src/duckdb/src/main/client_context_file_opener.cpp +15 -3
  490. package/src/duckdb/src/main/client_data.cpp +5 -0
  491. package/src/duckdb/src/main/config.cpp +82 -82
  492. package/src/duckdb/src/main/database.cpp +31 -7
  493. package/src/duckdb/src/main/database_manager.cpp +3 -2
  494. package/src/duckdb/src/main/database_path_and_type.cpp +4 -4
  495. package/src/duckdb/src/main/error_manager.cpp +1 -1
  496. package/src/duckdb/src/main/extension/extension_alias.cpp +9 -9
  497. package/src/duckdb/src/main/extension/extension_helper.cpp +10 -5
  498. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  499. package/src/duckdb/src/main/extension/extension_load.cpp +111 -37
  500. package/src/duckdb/src/main/query_profiler.cpp +1 -118
  501. package/src/duckdb/src/main/secret/secret_manager.cpp +1 -2
  502. package/src/duckdb/src/main/secret/secret_storage.cpp +1 -1
  503. package/src/duckdb/src/main/settings/settings.cpp +81 -65
  504. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +8 -1
  505. package/src/duckdb/src/optimizer/compressed_materialization/compress_aggregate.cpp +3 -0
  506. package/src/duckdb/src/optimizer/compressed_materialization.cpp +26 -28
  507. package/src/duckdb/src/optimizer/cse_optimizer.cpp +5 -5
  508. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +10 -6
  509. package/src/duckdb/src/optimizer/optimizer.cpp +14 -17
  510. package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +16 -5
  511. package/src/duckdb/src/optimizer/pushdown/pushdown_inner_join.cpp +7 -4
  512. package/src/duckdb/src/optimizer/pushdown/pushdown_set_operation.cpp +2 -2
  513. package/src/duckdb/src/optimizer/remove_unused_columns.cpp +3 -3
  514. package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +2 -2
  515. package/src/duckdb/src/optimizer/statistics/expression/propagate_aggregate.cpp +1 -1
  516. package/src/duckdb/src/optimizer/statistics/expression/propagate_between.cpp +8 -8
  517. package/src/duckdb/src/optimizer/statistics/expression/propagate_case.cpp +1 -1
  518. package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +1 -1
  519. package/src/duckdb/src/optimizer/statistics/expression/propagate_columnref.cpp +1 -1
  520. package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +7 -7
  521. package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +6 -6
  522. package/src/duckdb/src/optimizer/statistics/expression/propagate_constant.cpp +1 -1
  523. package/src/duckdb/src/optimizer/statistics/expression/propagate_function.cpp +2 -2
  524. package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +10 -10
  525. package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +1 -1
  526. package/src/duckdb/src/optimizer/statistics/operator/propagate_cross_product.cpp +1 -1
  527. package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +14 -7
  528. package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +2 -2
  529. package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +9 -9
  530. package/src/duckdb/src/optimizer/statistics/operator/propagate_limit.cpp +1 -1
  531. package/src/duckdb/src/optimizer/statistics/operator/propagate_order.cpp +1 -1
  532. package/src/duckdb/src/optimizer/statistics/operator/propagate_projection.cpp +2 -2
  533. package/src/duckdb/src/optimizer/statistics/operator/propagate_set_operation.cpp +1 -1
  534. package/src/duckdb/src/optimizer/statistics/operator/propagate_window.cpp +1 -1
  535. package/src/duckdb/src/optimizer/statistics_propagator.cpp +39 -18
  536. package/src/duckdb/src/parallel/pipeline_finish_event.cpp +1 -1
  537. package/src/duckdb/src/parallel/task_scheduler.cpp +8 -1
  538. package/src/duckdb/src/parser/constraints/unique_constraint.cpp +4 -2
  539. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +64 -0
  540. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +1 -0
  541. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +13 -5
  542. package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +24 -0
  543. package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +1 -8
  544. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +2 -1
  545. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +3 -0
  546. package/src/duckdb/src/parser/transform/statement/transform_delete.cpp +2 -6
  547. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +2 -6
  548. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +2 -6
  549. package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +1 -1
  550. package/src/duckdb/src/parser/transform/statement/transform_select.cpp +5 -2
  551. package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +2 -8
  552. package/src/duckdb/src/parser/transform/statement/transform_update.cpp +1 -6
  553. package/src/duckdb/src/parser/transform/statement/transform_use.cpp +3 -2
  554. package/src/duckdb/src/parser/transformer.cpp +14 -2
  555. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +40 -17
  556. package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +8 -3
  557. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +32 -30
  558. package/src/duckdb/src/planner/binder/query_node/bind_cte_node.cpp +28 -17
  559. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +146 -101
  560. package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +28 -26
  561. package/src/duckdb/src/planner/binder/query_node/plan_cte_node.cpp +29 -0
  562. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +10 -10
  563. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +3 -2
  564. package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +23 -28
  565. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +11 -12
  566. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +9 -11
  567. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +10 -13
  568. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +3 -3
  569. package/src/duckdb/src/planner/binder/statement/bind_set.cpp +3 -0
  570. package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +66 -65
  571. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +54 -46
  572. package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +3 -0
  573. package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +1 -1
  574. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +5 -5
  575. package/src/duckdb/src/planner/binder.cpp +78 -6
  576. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +11 -3
  577. package/src/duckdb/src/planner/expression/bound_expanded_expression.cpp +22 -0
  578. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +11 -58
  579. package/src/duckdb/src/planner/expression_binder/column_alias_binder.cpp +5 -8
  580. package/src/duckdb/src/planner/expression_binder/group_binder.cpp +5 -4
  581. package/src/duckdb/src/planner/expression_binder/having_binder.cpp +5 -19
  582. package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +8 -8
  583. package/src/duckdb/src/planner/expression_binder/order_binder.cpp +42 -26
  584. package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +3 -22
  585. package/src/duckdb/src/planner/expression_binder/select_bind_state.cpp +52 -0
  586. package/src/duckdb/src/planner/expression_binder/select_binder.cpp +43 -5
  587. package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +19 -7
  588. package/src/duckdb/src/planner/logical_operator.cpp +20 -3
  589. package/src/duckdb/src/planner/operator/logical_copy_database.cpp +4 -14
  590. package/src/duckdb/src/planner/operator/logical_delete.cpp +1 -1
  591. package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
  592. package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
  593. package/src/duckdb/src/planner/operator/logical_update.cpp +1 -1
  594. package/src/duckdb/src/planner/operator/logical_vacuum.cpp +65 -0
  595. package/src/duckdb/src/planner/planner.cpp +4 -4
  596. package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +26 -27
  597. package/src/duckdb/src/storage/arena_allocator.cpp +9 -0
  598. package/src/duckdb/src/storage/buffer/buffer_pool_reservation.cpp +1 -1
  599. package/src/duckdb/src/storage/buffer_manager.cpp +2 -10
  600. package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +2 -3
  601. package/src/duckdb/src/storage/checkpoint_manager.cpp +15 -8
  602. package/src/duckdb/src/storage/compression/bitpacking.cpp +6 -1
  603. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +1 -1
  604. package/src/duckdb/src/storage/data_pointer.cpp +1 -1
  605. package/src/duckdb/src/storage/data_table.cpp +18 -7
  606. package/src/duckdb/src/storage/local_storage.cpp +8 -5
  607. package/src/duckdb/src/storage/magic_bytes.cpp +6 -5
  608. package/src/duckdb/src/storage/partial_block_manager.cpp +1 -1
  609. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +20 -9
  610. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +12 -10
  611. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +23 -0
  612. package/src/duckdb/src/storage/single_file_block_manager.cpp +46 -19
  613. package/src/duckdb/src/storage/standard_buffer_manager.cpp +21 -5
  614. package/src/duckdb/src/storage/statistics/array_stats.cpp +1 -1
  615. package/src/duckdb/src/storage/statistics/base_statistics.cpp +2 -3
  616. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  617. package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
  618. package/src/duckdb/src/storage/storage_info.cpp +19 -19
  619. package/src/duckdb/src/storage/storage_manager.cpp +18 -13
  620. package/src/duckdb/src/storage/table/chunk_info.cpp +11 -3
  621. package/src/duckdb/src/storage/table/column_data.cpp +88 -66
  622. package/src/duckdb/src/storage/table/row_group.cpp +7 -7
  623. package/src/duckdb/src/storage/table/row_version_manager.cpp +2 -2
  624. package/src/duckdb/src/storage/table/standard_column_data.cpp +4 -0
  625. package/src/duckdb/src/storage/table/update_segment.cpp +3 -1
  626. package/src/duckdb/src/storage/table_index_list.cpp +6 -1
  627. package/src/duckdb/src/storage/temporary_file_manager.cpp +1 -1
  628. package/src/duckdb/src/storage/wal_replay.cpp +8 -7
  629. package/src/duckdb/src/storage/write_ahead_log.cpp +3 -4
  630. package/src/duckdb/src/transaction/cleanup_state.cpp +10 -3
  631. package/src/duckdb/src/transaction/commit_state.cpp +11 -4
  632. package/src/duckdb/src/transaction/duck_transaction.cpp +23 -3
  633. package/src/duckdb/src/transaction/rollback_state.cpp +1 -1
  634. package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
  635. package/src/duckdb/src/transaction/undo_buffer.cpp +3 -1
  636. package/src/duckdb/third_party/fmt/include/fmt/core.h +0 -5
  637. package/src/duckdb/third_party/fsst/fsst.h +1 -1
  638. package/src/duckdb/third_party/fsst/libfsst.cpp +1 -140
  639. package/src/duckdb/third_party/fsst/libfsst.hpp +0 -13
  640. package/src/duckdb/third_party/hyperloglog/hyperloglog.hpp +4 -0
  641. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +8 -1
  642. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
  643. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +15401 -15354
  644. package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +299 -538
  645. package/src/duckdb/third_party/lz4/lz4.cpp +2605 -0
  646. package/src/duckdb/third_party/lz4/lz4.hpp +843 -0
  647. package/src/duckdb/third_party/parquet/parquet_types.cpp +3 -0
  648. package/src/duckdb/third_party/parquet/parquet_types.h +2 -1
  649. package/src/duckdb/third_party/re2/re2/bitmap256.cc +44 -0
  650. package/src/duckdb/third_party/re2/re2/bitmap256.h +3 -35
  651. package/src/duckdb/third_party/re2/re2/bitstate.cc +31 -24
  652. package/src/duckdb/third_party/re2/re2/compile.cc +146 -164
  653. package/src/duckdb/third_party/re2/re2/dfa.cc +174 -181
  654. package/src/duckdb/third_party/re2/re2/filtered_re2.cc +19 -3
  655. package/src/duckdb/third_party/re2/re2/filtered_re2.h +27 -23
  656. package/src/duckdb/third_party/re2/re2/mimics_pcre.cc +21 -11
  657. package/src/duckdb/third_party/re2/re2/nfa.cc +91 -131
  658. package/src/duckdb/third_party/re2/re2/onepass.cc +11 -10
  659. package/src/duckdb/third_party/re2/re2/parse.cc +171 -154
  660. package/src/duckdb/third_party/re2/re2/perl_groups.cc +35 -35
  661. package/src/duckdb/third_party/re2/re2/pod_array.h +55 -0
  662. package/src/duckdb/third_party/re2/re2/prefilter.cc +40 -40
  663. package/src/duckdb/third_party/re2/re2/prefilter.h +24 -2
  664. package/src/duckdb/third_party/re2/re2/prefilter_tree.cc +70 -84
  665. package/src/duckdb/third_party/re2/re2/prefilter_tree.h +5 -4
  666. package/src/duckdb/third_party/re2/re2/prog.cc +315 -58
  667. package/src/duckdb/third_party/re2/re2/prog.h +77 -44
  668. package/src/duckdb/third_party/re2/re2/re2.cc +333 -221
  669. package/src/duckdb/third_party/re2/re2/re2.h +277 -201
  670. package/src/duckdb/third_party/re2/re2/regexp.cc +137 -105
  671. package/src/duckdb/third_party/re2/re2/regexp.h +45 -40
  672. package/src/duckdb/third_party/re2/re2/set.cc +40 -17
  673. package/src/duckdb/third_party/re2/re2/set.h +11 -6
  674. package/src/duckdb/third_party/re2/re2/simplify.cc +50 -41
  675. package/src/duckdb/third_party/re2/re2/sparse_array.h +392 -0
  676. package/src/duckdb/third_party/re2/re2/sparse_set.h +264 -0
  677. package/src/duckdb/third_party/re2/re2/stringpiece.cc +1 -1
  678. package/src/duckdb/third_party/re2/re2/stringpiece.h +11 -8
  679. package/src/duckdb/third_party/re2/re2/tostring.cc +8 -6
  680. package/src/duckdb/third_party/re2/re2/unicode_casefold.cc +39 -10
  681. package/src/duckdb/third_party/re2/re2/unicode_casefold.h +1 -1
  682. package/src/duckdb/third_party/re2/re2/unicode_groups.cc +5019 -4566
  683. package/src/duckdb/third_party/re2/re2/unicode_groups.h +1 -1
  684. package/src/duckdb/third_party/re2/re2/walker-inl.h +21 -20
  685. package/src/duckdb/third_party/re2/util/logging.h +14 -18
  686. package/src/duckdb/third_party/re2/util/mix.h +4 -4
  687. package/src/duckdb/third_party/re2/util/mutex.h +48 -15
  688. package/src/duckdb/third_party/re2/util/rune.cc +5 -5
  689. package/src/duckdb/third_party/re2/util/strutil.cc +1 -16
  690. package/src/duckdb/third_party/re2/util/strutil.h +1 -3
  691. package/src/duckdb/third_party/re2/util/utf.h +1 -1
  692. package/src/duckdb/third_party/re2/util/util.h +9 -1
  693. package/src/duckdb/third_party/utf8proc/include/utf8proc_wrapper.hpp +2 -0
  694. package/src/duckdb/third_party/utf8proc/utf8proc_wrapper.cpp +36 -1
  695. package/src/duckdb/ub_src_common.cpp +0 -2
  696. package/src/duckdb/ub_src_execution_physical_plan.cpp +2 -0
  697. package/src/duckdb/ub_src_planner_expression.cpp +2 -0
  698. package/src/duckdb/ub_src_planner_expression_binder.cpp +2 -0
  699. package/src/duckdb/ub_src_planner_operator.cpp +2 -0
@@ -0,0 +1,843 @@
1
+ /*
2
+ * LZ4 - Fast LZ compression algorithm
3
+ * Header File
4
+ * Copyright (C) 2011-2020, Yann Collet.
5
+
6
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are
10
+ met:
11
+
12
+ * Redistributions of source code must retain the above copyright
13
+ notice, this list of conditions and the following disclaimer.
14
+ * Redistributions in binary form must reproduce the above
15
+ copyright notice, this list of conditions and the following disclaimer
16
+ in the documentation and/or other materials provided with the
17
+ distribution.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ You can contact the author at :
32
+ - LZ4 homepage : http://www.lz4.org
33
+ - LZ4 source repository : https://github.com/lz4/lz4
34
+ */
35
+ //#if defined (__cplusplus)
36
+ //extern "C" {
37
+ //#endif
38
+
39
+ #ifndef LZ4_H_2983827168210
40
+ #define LZ4_H_2983827168210
41
+
42
+ /* --- Dependency --- */
43
+ #include <stddef.h> /* size_t */
44
+
45
+ namespace duckdb_lz4 {
46
+
47
+ /**
48
+ Introduction
49
+
50
+ LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
51
+ scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
52
+ multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
53
+
54
+ The LZ4 compression library provides in-memory compression and decompression functions.
55
+ It gives full buffer control to user.
56
+ Compression can be done in:
57
+ - a single step (described as Simple Functions)
58
+ - a single step, reusing a context (described in Advanced Functions)
59
+ - unbounded multiple steps (described as Streaming compression)
60
+
61
+ lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
62
+ Decompressing such a compressed block requires additional metadata.
63
+ Exact metadata depends on exact decompression function.
64
+ For the typical case of LZ4_decompress_safe(),
65
+ metadata includes block's compressed size, and maximum bound of decompressed size.
66
+ Each application is free to encode and pass such metadata in whichever way it wants.
67
+
68
+ lz4.h only handle blocks, it can not generate Frames.
69
+
70
+ Blocks are different from Frames (doc/lz4_Frame_format.md).
71
+ Frames bundle both blocks and metadata in a specified manner.
72
+ Embedding metadata is required for compressed data to be self-contained and portable.
73
+ Frame format is delivered through a companion API, declared in lz4frame.h.
74
+ The `lz4` CLI can only manage frames.
75
+ */
76
+
77
+ /*^***************************************************************
78
+ * Export parameters
79
+ *****************************************************************/
80
+ /*
81
+ * LZ4_DLL_EXPORT :
82
+ * Enable exporting of functions when building a Windows DLL
83
+ * LZ4LIB_VISIBILITY :
84
+ * Control library symbols visibility.
85
+ */
86
+ #ifndef LZ4LIB_VISIBILITY
87
+ # if defined(__GNUC__) && (__GNUC__ >= 4)
88
+ # define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
89
+ # else
90
+ # define LZ4LIB_VISIBILITY
91
+ # endif
92
+ #endif
93
+ #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
94
+ # define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
95
+ #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
96
+ # define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
97
+ #else
98
+ # define LZ4LIB_API LZ4LIB_VISIBILITY
99
+ #endif
100
+
101
+ /*! LZ4_FREESTANDING :
102
+ * When this macro is set to 1, it enables "freestanding mode" that is
103
+ * suitable for typical freestanding environment which doesn't support
104
+ * standard C library.
105
+ *
106
+ * - LZ4_FREESTANDING is a compile-time switch.
107
+ * - It requires the following macros to be defined:
108
+ * LZ4_memcpy, LZ4_memmove, LZ4_memset.
109
+ * - It only enables LZ4/HC functions which don't use heap.
110
+ * All LZ4F_* functions are not supported.
111
+ * - See tests/freestanding.c to check its basic setup.
112
+ */
113
+ #if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
114
+ # define LZ4_HEAPMODE 0
115
+ # define LZ4HC_HEAPMODE 0
116
+ # define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
117
+ # if !defined(LZ4_memcpy)
118
+ # error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
119
+ # endif
120
+ # if !defined(LZ4_memset)
121
+ # error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
122
+ # endif
123
+ # if !defined(LZ4_memmove)
124
+ # error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
125
+ # endif
126
+ #elif ! defined(LZ4_FREESTANDING)
127
+ # define LZ4_FREESTANDING 0
128
+ #endif
129
+
130
+
131
+ /*------ Version ------*/
132
+ #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
133
+ #define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
134
+ #define LZ4_VERSION_RELEASE 4 /* for tweaks, bug-fixes, or development */
135
+
136
+ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
137
+
138
+ #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
139
+ #define LZ4_QUOTE(str) #str
140
+ #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
141
+ #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */
142
+
143
+ LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version; requires v1.3.0+ */
144
+ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version; requires v1.7.5+ */
145
+
146
+
147
+ /*-************************************
148
+ * Tuning parameter
149
+ **************************************/
150
+ #define LZ4_MEMORY_USAGE_MIN 10
151
+ #define LZ4_MEMORY_USAGE_DEFAULT 14
152
+ #define LZ4_MEMORY_USAGE_MAX 20
153
+
154
+ /*!
155
+ * LZ4_MEMORY_USAGE :
156
+ * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
157
+ * Increasing memory usage improves compression ratio, at the cost of speed.
158
+ * Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
159
+ * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
160
+ */
161
+ #ifndef LZ4_MEMORY_USAGE
162
+ # define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
163
+ #endif
164
+
165
+ #if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
166
+ # error "LZ4_MEMORY_USAGE is too small !"
167
+ #endif
168
+
169
+ #if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX)
170
+ # error "LZ4_MEMORY_USAGE is too large !"
171
+ #endif
172
+
173
+ /*-************************************
174
+ * Simple Functions
175
+ **************************************/
176
+ /*! LZ4_compress_default() :
177
+ * Compresses 'srcSize' bytes from buffer 'src'
178
+ * into already allocated 'dst' buffer of size 'dstCapacity'.
179
+ * Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
180
+ * It also runs faster, so it's a recommended setting.
181
+ * If the function cannot compress 'src' into a more limited 'dst' budget,
182
+ * compression stops *immediately*, and the function result is zero.
183
+ * In which case, 'dst' content is undefined (invalid).
184
+ * srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
185
+ * dstCapacity : size of buffer 'dst' (which must be already allocated)
186
+ * @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
187
+ * or 0 if compression fails
188
+ * Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
189
+ */
190
+ LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
191
+
192
+ /*! LZ4_decompress_safe() :
193
+ * compressedSize : is the exact complete size of the compressed block.
194
+ * dstCapacity : is the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size.
195
+ * @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
196
+ * If destination buffer is not large enough, decoding will stop and output an error code (negative value).
197
+ * If the source stream is detected malformed, the function will stop decoding and return a negative result.
198
+ * Note 1 : This function is protected against malicious data packets :
199
+ * it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
200
+ * even if the compressed block is maliciously modified to order the decoder to do these actions.
201
+ * In such case, the decoder stops immediately, and considers the compressed block malformed.
202
+ * Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
203
+ * The implementation is free to send / store / derive this information in whichever way is most beneficial.
204
+ * If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
205
+ */
206
+ LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
207
+
208
+
209
+ /*-************************************
210
+ * Advanced Functions
211
+ **************************************/
212
+ #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
213
+ #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
214
+
215
+ /*! LZ4_compressBound() :
216
+ Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
217
+ This function is primarily useful for memory allocation purposes (destination buffer size).
218
+ Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
219
+ Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize)
220
+ inputSize : max supported value is LZ4_MAX_INPUT_SIZE
221
+ return : maximum output size in a "worst case" scenario
222
+ or 0, if input size is incorrect (too large or negative)
223
+ */
224
+ LZ4LIB_API int LZ4_compressBound(int inputSize);
225
+
226
+ /*! LZ4_compress_fast() :
227
+ Same as LZ4_compress_default(), but allows selection of "acceleration" factor.
228
+ The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
229
+ It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
230
+ An acceleration value of "1" is the same as regular LZ4_compress_default()
231
+ Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).
232
+ Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).
233
+ */
234
+ LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
235
+
236
+
237
+ /*! LZ4_compress_fast_extState() :
238
+ * Same as LZ4_compress_fast(), using an externally allocated memory space for its state.
239
+ * Use LZ4_sizeofState() to know how much memory must be allocated,
240
+ * and allocate it on 8-bytes boundaries (using `malloc()` typically).
241
+ * Then, provide this buffer as `void* state` to compression function.
242
+ */
243
+ LZ4LIB_API int LZ4_sizeofState(void);
244
+ LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
245
+
246
+
247
+ /*! LZ4_compress_destSize() :
248
+ * Reverse the logic : compresses as much data as possible from 'src' buffer
249
+ * into already allocated buffer 'dst', of size >= 'targetDestSize'.
250
+ * This function either compresses the entire 'src' content into 'dst' if it's large enough,
251
+ * or fill 'dst' buffer completely with as much data as possible from 'src'.
252
+ * note: acceleration parameter is fixed to "default".
253
+ *
254
+ * *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
255
+ * New value is necessarily <= input value.
256
+ * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
257
+ * or 0 if compression fails.
258
+ *
259
+ * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+):
260
+ * the produced compressed content could, in specific circumstances,
261
+ * require to be decompressed into a destination buffer larger
262
+ * by at least 1 byte than the content to decompress.
263
+ * If an application uses `LZ4_compress_destSize()`,
264
+ * it's highly recommended to update liblz4 to v1.9.2 or better.
265
+ * If this can't be done or ensured,
266
+ * the receiving decompression function should provide
267
+ * a dstCapacity which is > decompressedSize, by at least 1 byte.
268
+ * See https://github.com/lz4/lz4/issues/859 for details
269
+ */
270
+ LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
271
+
272
+
273
+ /*! LZ4_decompress_safe_partial() :
274
+ * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
275
+ * into destination buffer 'dst' of size 'dstCapacity'.
276
+ * Up to 'targetOutputSize' bytes will be decoded.
277
+ * The function stops decoding on reaching this objective.
278
+ * This can be useful to boost performance
279
+ * whenever only the beginning of a block is required.
280
+ *
281
+ * @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize)
282
+ * If source stream is detected malformed, function returns a negative result.
283
+ *
284
+ * Note 1 : @return can be < targetOutputSize, if compressed block contains less data.
285
+ *
286
+ * Note 2 : targetOutputSize must be <= dstCapacity
287
+ *
288
+ * Note 3 : this function effectively stops decoding on reaching targetOutputSize,
289
+ * so dstCapacity is kind of redundant.
290
+ * This is because in older versions of this function,
291
+ * decoding operation would still write complete sequences.
292
+ * Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize,
293
+ * it could write more bytes, though only up to dstCapacity.
294
+ * Some "margin" used to be required for this operation to work properly.
295
+ * Thankfully, this is no longer necessary.
296
+ * The function nonetheless keeps the same signature, in an effort to preserve API compatibility.
297
+ *
298
+ * Note 4 : If srcSize is the exact size of the block,
299
+ * then targetOutputSize can be any value,
300
+ * including larger than the block's decompressed size.
301
+ * The function will, at most, generate block's decompressed size.
302
+ *
303
+ * Note 5 : If srcSize is _larger_ than block's compressed size,
304
+ * then targetOutputSize **MUST** be <= block's decompressed size.
305
+ * Otherwise, *silent corruption will occur*.
306
+ */
307
+ LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
308
+
309
+
310
+ /*-*********************************************
311
+ * Streaming Compression Functions
312
+ ***********************************************/
313
+ typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
314
+
315
+ /**
316
+ Note about RC_INVOKED
317
+
318
+ - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
319
+ https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
320
+
321
+ - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
322
+ and reports warning "RC4011: identifier truncated".
323
+
324
+ - To eliminate the warning, we surround long preprocessor symbol with
325
+ "#if !defined(RC_INVOKED) ... #endif" block that means
326
+ "skip this block when rc.exe is trying to read it".
327
+ */
328
+ #if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
329
+ #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
330
+ LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
331
+ LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
332
+ #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
333
+ #endif
334
+
335
+ /*! LZ4_resetStream_fast() : v1.9.0+
336
+ * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
337
+ * (e.g., LZ4_compress_fast_continue()).
338
+ *
339
+ * An LZ4_stream_t must be initialized once before usage.
340
+ * This is automatically done when created by LZ4_createStream().
341
+ * However, should the LZ4_stream_t be simply declared on stack (for example),
342
+ * it's necessary to initialize it first, using LZ4_initStream().
343
+ *
344
+ * After init, start any new stream with LZ4_resetStream_fast().
345
+ * A same LZ4_stream_t can be re-used multiple times consecutively
346
+ * and compress multiple streams,
347
+ * provided that it starts each new stream with LZ4_resetStream_fast().
348
+ *
349
+ * LZ4_resetStream_fast() is much faster than LZ4_initStream(),
350
+ * but is not compatible with memory regions containing garbage data.
351
+ *
352
+ * Note: it's only useful to call LZ4_resetStream_fast()
353
+ * in the context of streaming compression.
354
+ * The *extState* functions perform their own resets.
355
+ * Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
356
+ */
357
+ LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
358
+
359
+ /*! LZ4_loadDict() :
360
+ * Use this function to reference a static dictionary into LZ4_stream_t.
361
+ * The dictionary must remain available during compression.
362
+ * LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
363
+ * The same dictionary will have to be loaded on decompression side for successful decoding.
364
+ * Dictionary are useful for better compression of small data (KB range).
365
+ * While LZ4 accept any input as dictionary,
366
+ * results are generally better when using Zstandard's Dictionary Builder.
367
+ * Loading a size of 0 is allowed, and is the same as reset.
368
+ * @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
369
+ */
370
+ LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
371
+
372
+ /*! LZ4_compress_fast_continue() :
373
+ * Compress 'src' content using data from previously compressed blocks, for better compression ratio.
374
+ * 'dst' buffer must be already allocated.
375
+ * If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
376
+ *
377
+ * @return : size of compressed block
378
+ * or 0 if there is an error (typically, cannot fit into 'dst').
379
+ *
380
+ * Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block.
381
+ * Each block has precise boundaries.
382
+ * Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata.
383
+ * It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together.
384
+ *
385
+ * Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory !
386
+ *
387
+ * Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB.
388
+ * Make sure that buffers are separated, by at least one byte.
389
+ * This construction ensures that each block only depends on previous block.
390
+ *
391
+ * Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
392
+ *
393
+ * Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
394
+ */
395
+ LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
396
+
397
+ /*! LZ4_saveDict() :
398
+ * If last 64KB data cannot be guaranteed to remain available at its current memory location,
399
+ * save it into a safer place (char* safeBuffer).
400
+ * This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
401
+ * but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
402
+ * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
403
+ */
404
+ LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
405
+
406
+
407
+ /*-**********************************************
408
+ * Streaming Decompression Functions
409
+ * Bufferless synchronous API
410
+ ************************************************/
411
+ typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
412
+
413
+ /*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
414
+ * creation / destruction of streaming decompression tracking context.
415
+ * A tracking context can be re-used multiple times.
416
+ */
417
+ #if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
418
+ #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
419
+ LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
420
+ LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
421
+ #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
422
+ #endif
423
+
424
+ /*! LZ4_setStreamDecode() :
425
+ * An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
426
+ * Use this function to start decompression of a new stream of blocks.
427
+ * A dictionary can optionally be set. Use NULL or size 0 for a reset order.
428
+ * Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
429
+ * @return : 1 if OK, 0 if error
430
+ */
431
+ LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
432
+
433
+ /*! LZ4_decoderRingBufferSize() : v1.8.2+
434
+ * Note : in a ring buffer scenario (optional),
435
+ * blocks are presumed decompressed next to each other
436
+ * up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize),
437
+ * at which stage it resumes from beginning of ring buffer.
438
+ * When setting such a ring buffer for streaming decompression,
439
+ * provides the minimum size of this ring buffer
440
+ * to be compatible with any source respecting maxBlockSize condition.
441
+ * @return : minimum ring buffer size,
442
+ * or 0 if there is an error (invalid maxBlockSize).
443
+ */
444
+ LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
445
+ #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
446
+
447
+ /*! LZ4_decompress_*_continue() :
448
+ * These decoding functions allow decompression of consecutive blocks in "streaming" mode.
449
+ * A block is an unsplittable entity, it must be presented entirely to a decompression function.
450
+ * Decompression functions only accepts one block at a time.
451
+ * The last 64KB of previously decoded data *must* remain available and unmodified at the memory position where they were decoded.
452
+ * If less than 64KB of data has been decoded, all the data must be present.
453
+ *
454
+ * Special : if decompression side sets a ring buffer, it must respect one of the following conditions :
455
+ * - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize).
456
+ * maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes.
457
+ * In which case, encoding and decoding buffers do not need to be synchronized.
458
+ * Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize.
459
+ * - Synchronized mode :
460
+ * Decompression buffer size is _exactly_ the same as compression buffer size,
461
+ * and follows exactly same update rule (block boundaries at same positions),
462
+ * and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
463
+ * _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
464
+ * - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
465
+ * In which case, encoding and decoding buffers do not need to be synchronized,
466
+ * and encoding ring buffer can have any size, including small ones ( < 64 KB).
467
+ *
468
+ * Whenever these conditions are not possible,
469
+ * save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
470
+ * then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
471
+ */
472
+ LZ4LIB_API int
473
+ LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode,
474
+ const char* src, char* dst,
475
+ int srcSize, int dstCapacity);
476
+
477
+
478
+ /*! LZ4_decompress_*_usingDict() :
479
+ * These decoding functions work the same as
480
+ * a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
481
+ * They are stand-alone, and don't need an LZ4_streamDecode_t structure.
482
+ * Dictionary is presumed stable : it must remain accessible and unmodified during decompression.
483
+ * Performance tip : Decompression speed can be substantially increased
484
+ * when dst == dictStart + dictSize.
485
+ */
486
+ LZ4LIB_API int
487
+ LZ4_decompress_safe_usingDict(const char* src, char* dst,
488
+ int srcSize, int dstCapacity,
489
+ const char* dictStart, int dictSize);
490
+
491
+ LZ4LIB_API int
492
+ LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
493
+ int compressedSize,
494
+ int targetOutputSize, int maxOutputSize,
495
+ const char* dictStart, int dictSize);
496
+
497
+ #endif /* LZ4_H_2983827168210 */
498
+
499
+
500
+ /*^*************************************
501
+ * !!!!!! STATIC LINKING ONLY !!!!!!
502
+ ***************************************/
503
+
504
+ /*-****************************************************************************
505
+ * Experimental section
506
+ *
507
+ * Symbols declared in this section must be considered unstable. Their
508
+ * signatures or semantics may change, or they may be removed altogether in the
509
+ * future. They are therefore only safe to depend on when the caller is
510
+ * statically linked against the library.
511
+ *
512
+ * To protect against unsafe usage, not only are the declarations guarded,
513
+ * the definitions are hidden by default
514
+ * when building LZ4 as a shared/dynamic library.
515
+ *
516
+ * In order to access these declarations,
517
+ * define LZ4_STATIC_LINKING_ONLY in your application
518
+ * before including LZ4's headers.
519
+ *
520
+ * In order to make their implementations accessible dynamically, you must
521
+ * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
522
+ ******************************************************************************/
523
+
524
+ #ifdef LZ4_STATIC_LINKING_ONLY
525
+
526
+ #ifndef LZ4_STATIC_3504398509
527
+ #define LZ4_STATIC_3504398509
528
+
529
+ #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
530
+ #define LZ4LIB_STATIC_API LZ4LIB_API
531
+ #else
532
+ #define LZ4LIB_STATIC_API
533
+ #endif
534
+
535
+
536
+ /*! LZ4_compress_fast_extState_fastReset() :
537
+ * A variant of LZ4_compress_fast_extState().
538
+ *
539
+ * Using this variant avoids an expensive initialization step.
540
+ * It is only safe to call if the state buffer is known to be correctly initialized already
541
+ * (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized").
542
+ * From a high level, the difference is that
543
+ * this function initializes the provided state with a call to something like LZ4_resetStream_fast()
544
+ * while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
545
+ */
546
+ LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
547
+
548
+ /*! LZ4_attach_dictionary() :
549
+ * This is an experimental API that allows
550
+ * efficient use of a static dictionary many times.
551
+ *
552
+ * Rather than re-loading the dictionary buffer into a working context before
553
+ * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
554
+ * working LZ4_stream_t, this function introduces a no-copy setup mechanism,
555
+ * in which the working stream references the dictionary stream in-place.
556
+ *
557
+ * Several assumptions are made about the state of the dictionary stream.
558
+ * Currently, only streams which have been prepared by LZ4_loadDict() should
559
+ * be expected to work.
560
+ *
561
+ * Alternatively, the provided dictionaryStream may be NULL,
562
+ * in which case any existing dictionary stream is unset.
563
+ *
564
+ * If a dictionary is provided, it replaces any pre-existing stream history.
565
+ * The dictionary contents are the only history that can be referenced and
566
+ * logically immediately precede the data compressed in the first subsequent
567
+ * compression call.
568
+ *
569
+ * The dictionary will only remain attached to the working stream through the
570
+ * first compression call, at the end of which it is cleared. The dictionary
571
+ * stream (and source buffer) must remain in-place / accessible / unchanged
572
+ * through the completion of the first compression call on the stream.
573
+ */
574
+ LZ4LIB_STATIC_API void
575
+ LZ4_attach_dictionary(LZ4_stream_t* workingStream,
576
+ const LZ4_stream_t* dictionaryStream);
577
+
578
+
579
+ /*! In-place compression and decompression
580
+ *
581
+ * It's possible to have input and output sharing the same buffer,
582
+ * for highly constrained memory environments.
583
+ * In both cases, it requires input to lay at the end of the buffer,
584
+ * and decompression to start at beginning of the buffer.
585
+ * Buffer size must feature some margin, hence be larger than final size.
586
+ *
587
+ * |<------------------------buffer--------------------------------->|
588
+ * |<-----------compressed data--------->|
589
+ * |<-----------decompressed size------------------>|
590
+ * |<----margin---->|
591
+ *
592
+ * This technique is more useful for decompression,
593
+ * since decompressed size is typically larger,
594
+ * and margin is short.
595
+ *
596
+ * In-place decompression will work inside any buffer
597
+ * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
598
+ * This presumes that decompressedSize > compressedSize.
599
+ * Otherwise, it means compression actually expanded data,
600
+ * and it would be more efficient to store such data with a flag indicating it's not compressed.
601
+ * This can happen when data is not compressible (already compressed, or encrypted).
602
+ *
603
+ * For in-place compression, margin is larger, as it must be able to cope with both
604
+ * history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX,
605
+ * and data expansion, which can happen when input is not compressible.
606
+ * As a consequence, buffer size requirements are much higher,
607
+ * and memory savings offered by in-place compression are more limited.
608
+ *
609
+ * There are ways to limit this cost for compression :
610
+ * - Reduce history size, by modifying LZ4_DISTANCE_MAX.
611
+ * Note that it is a compile-time constant, so all compressions will apply this limit.
612
+ * Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX,
613
+ * so it's a reasonable trick when inputs are known to be small.
614
+ * - Require the compressor to deliver a "maximum compressed size".
615
+ * This is the `dstCapacity` parameter in `LZ4_compress*()`.
616
+ * When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail,
617
+ * in which case, the return code will be 0 (zero).
618
+ * The caller must be ready for these cases to happen,
619
+ * and typically design a backup scheme to send data uncompressed.
620
+ * The combination of both techniques can significantly reduce
621
+ * the amount of margin required for in-place compression.
622
+ *
623
+ * In-place compression can work in any buffer
624
+ * which size is >= (maxCompressedSize)
625
+ * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success.
626
+ * LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX,
627
+ * so it's possible to reduce memory requirements by playing with them.
628
+ */
629
+
630
+ #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
631
+ #define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize)) /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */
632
+
633
+ #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
634
+ # define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
635
+ #endif
636
+
637
+ #define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
638
+ #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */
639
+
640
+ #endif /* LZ4_STATIC_3504398509 */
641
+ #endif /* LZ4_STATIC_LINKING_ONLY */
642
+
643
+
644
+
645
+ #ifndef LZ4_H_98237428734687
646
+ #define LZ4_H_98237428734687
647
+
648
+ /*-************************************************************
649
+ * Private Definitions
650
+ **************************************************************
651
+ * Do not use these definitions directly.
652
+ * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
653
+ * Accessing members will expose user code to API and/or ABI break in future versions of the library.
654
+ **************************************************************/
655
+ #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
656
+ #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
657
+ #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
658
+
659
+ #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
660
+ # include <stdint.h>
661
+ typedef int8_t LZ4_i8;
662
+ typedef uint8_t LZ4_byte;
663
+ typedef uint16_t LZ4_u16;
664
+ typedef uint32_t LZ4_u32;
665
+ #else
666
+ typedef signed char LZ4_i8;
667
+ typedef unsigned char LZ4_byte;
668
+ typedef unsigned short LZ4_u16;
669
+ typedef unsigned int LZ4_u32;
670
+ #endif
671
+
672
+ /*! LZ4_stream_t :
673
+ * Never ever use below internal definitions directly !
674
+ * These definitions are not API/ABI safe, and may change in future versions.
675
+ * If you need static allocation, declare or allocate an LZ4_stream_t object.
676
+ **/
677
+
678
+ typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
679
+ struct LZ4_stream_t_internal {
680
+ LZ4_u32 hashTable[LZ4_HASH_SIZE_U32];
681
+ const LZ4_byte* dictionary;
682
+ const LZ4_stream_t_internal* dictCtx;
683
+ LZ4_u32 currentOffset;
684
+ LZ4_u32 tableType;
685
+ LZ4_u32 dictSize;
686
+ /* Implicit padding to ensure structure is aligned */
687
+ };
688
+
689
+ #define LZ4_STREAM_MINSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
690
+ union LZ4_stream_u {
691
+ char minStateSize[LZ4_STREAM_MINSIZE];
692
+ LZ4_stream_t_internal internal_donotuse;
693
+ }; /* previously typedef'd to LZ4_stream_t */
694
+
695
+
696
+ /*! LZ4_initStream() : v1.9.0+
697
+ * An LZ4_stream_t structure must be initialized at least once.
698
+ * This is automatically done when invoking LZ4_createStream(),
699
+ * but it's not when the structure is simply declared on stack (for example).
700
+ *
701
+ * Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
702
+ * It can also initialize any arbitrary buffer of sufficient size,
703
+ * and will @return a pointer of proper type upon initialization.
704
+ *
705
+ * Note : initialization fails if size and alignment conditions are not respected.
706
+ * In which case, the function will @return NULL.
707
+ * Note2: An LZ4_stream_t structure guarantees correct alignment and size.
708
+ * Note3: Before v1.9.0, use LZ4_resetStream() instead
709
+ **/
710
+ LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
711
+
712
+
713
+ /*! LZ4_streamDecode_t :
714
+ * Never ever use below internal definitions directly !
715
+ * These definitions are not API/ABI safe, and may change in future versions.
716
+ * If you need static allocation, declare or allocate an LZ4_streamDecode_t object.
717
+ **/
718
+ typedef struct {
719
+ const LZ4_byte* externalDict;
720
+ const LZ4_byte* prefixEnd;
721
+ size_t extDictSize;
722
+ size_t prefixSize;
723
+ } LZ4_streamDecode_t_internal;
724
+
725
+ #define LZ4_STREAMDECODE_MINSIZE 32
726
+ union LZ4_streamDecode_u {
727
+ char minStateSize[LZ4_STREAMDECODE_MINSIZE];
728
+ LZ4_streamDecode_t_internal internal_donotuse;
729
+ } ; /* previously typedef'd to LZ4_streamDecode_t */
730
+
731
+
732
+
733
+ /*-************************************
734
+ * Obsolete Functions
735
+ **************************************/
736
+
737
+ /*! Deprecation warnings
738
+ *
739
+ * Deprecated functions make the compiler generate a warning when invoked.
740
+ * This is meant to invite users to update their source code.
741
+ * Should deprecation warnings be a problem, it is generally possible to disable them,
742
+ * typically with -Wno-deprecated-declarations for gcc
743
+ * or _CRT_SECURE_NO_WARNINGS in Visual.
744
+ *
745
+ * Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
746
+ * before including the header file.
747
+ */
748
+ #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
749
+ # define LZ4_DEPRECATED(message) /* disable deprecation warnings */
750
+ #else
751
+ # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
752
+ # define LZ4_DEPRECATED(message) [[deprecated(message)]]
753
+ # elif defined(_MSC_VER)
754
+ # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
755
+ # elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
756
+ # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
757
+ # elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
758
+ # define LZ4_DEPRECATED(message) __attribute__((deprecated))
759
+ # else
760
+ # pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
761
+ # define LZ4_DEPRECATED(message) /* disabled */
762
+ # endif
763
+ #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
764
+
765
+ /*! Obsolete compression functions (since v1.7.3) */
766
+ LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize);
767
+ LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize);
768
+ LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
769
+ LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
770
+ LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
771
+ LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
772
+
773
+ /*! Obsolete decompression functions (since v1.8.0) */
774
+ LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
775
+ LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
776
+
777
+ /* Obsolete streaming functions (since v1.7.0)
778
+ * degraded functionality; do not use!
779
+ *
780
+ * In order to perform streaming compression, these functions depended on data
781
+ * that is no longer tracked in the state. They have been preserved as well as
782
+ * possible: using them will still produce a correct output. However, they don't
783
+ * actually retain any history between compression calls. The compression ratio
784
+ * achieved will therefore be no better than compressing each chunk
785
+ * independently.
786
+ */
787
+ LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
788
+ LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
789
+ LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
790
+ LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
791
+
792
+ /*! Obsolete streaming decoding functions (since v1.7.0) */
793
+ LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
794
+ LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
795
+
796
+ /*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
797
+ * These functions used to be faster than LZ4_decompress_safe(),
798
+ * but this is no longer the case. They are now slower.
799
+ * This is because LZ4_decompress_fast() doesn't know the input size,
800
+ * and therefore must progress more cautiously into the input buffer to not read beyond the end of block.
801
+ * On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability.
802
+ * As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.
803
+ *
804
+ * The last remaining LZ4_decompress_fast() specificity is that
805
+ * it can decompress a block without knowing its compressed size.
806
+ * Such functionality can be achieved in a more secure manner
807
+ * by employing LZ4_decompress_safe_partial().
808
+ *
809
+ * Parameters:
810
+ * originalSize : is the uncompressed size to regenerate.
811
+ * `dst` must be already allocated, its size must be >= 'originalSize' bytes.
812
+ * @return : number of bytes read from source buffer (== compressed size).
813
+ * The function expects to finish at block's end exactly.
814
+ * If the source stream is detected malformed, the function stops decoding and returns a negative result.
815
+ * note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer.
816
+ * However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds.
817
+ * Also, since match offsets are not validated, match reads from 'src' may underflow too.
818
+ * These issues never happen if input (compressed) data is correct.
819
+ * But they may happen if input data is invalid (error or intentional tampering).
820
+ * As a consequence, use these functions in trusted environments with trusted data **only**.
821
+ */
822
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
823
+ LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
824
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
825
+ LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
826
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
827
+ LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
828
+
829
+ /*! LZ4_resetStream() :
830
+ * An LZ4_stream_t structure must be initialized at least once.
831
+ * This is done with LZ4_initStream(), or LZ4_resetStream().
832
+ * Consider switching to LZ4_initStream(),
833
+ * invoking LZ4_resetStream() will trigger deprecation warnings in the future.
834
+ */
835
+ LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
836
+
837
+
838
+ #endif /* LZ4_H_98237428734687 */
839
+
840
+
841
+ #if defined (__cplusplus)
842
+ }
843
+ #endif