diff --git a/ci/jobs/scripts/check_style/check_cpp.sh b/ci/jobs/scripts/check_style/check_cpp.sh
index d8bfce5d2b5a..d07e285cb70b 100755
--- a/ci/jobs/scripts/check_style/check_cpp.sh
+++ b/ci/jobs/scripts/check_style/check_cpp.sh
@@ -94,6 +94,8 @@ EXTERN_TYPES_EXCLUDES=(
ProfileEvents::ValueType
ProfileEvents::dumpToMapColumn
ProfileEvents::getProfileEvents
+ ProfileEvents::getSampleBlock
+ ProfileEvents::checkBlockStructure
ProfileEvents::ThreadIdToCountersSnapshot
ProfileEvents::LOCAL_NAME
ProfileEvents::keeper_profile_events
diff --git a/ci/jobs/scripts/integration_tests_configs.py b/ci/jobs/scripts/integration_tests_configs.py
index 32f4629997b1..32d34436e35b 100644
--- a/ci/jobs/scripts/integration_tests_configs.py
+++ b/ci/jobs/scripts/integration_tests_configs.py
@@ -435,7 +435,6 @@ def force_heavy_modules_sequential(
test_jbod_ha/test.py 79681
test_remote_blobs_naming/test_backward_compatibility.py 79599
test_replicated_merge_tree_compatibility/test.py 79514
-test_store_cleanup/test.py 79320
test_paimon_incremental_read/test.py 79095
test_storage_iceberg_with_spark/test_metadata_file_format_with_uuid.py 78918
test_system_flush_logs/test.py 78482
diff --git a/ci/tests/data/integration_test_durations_sample.tsv b/ci/tests/data/integration_test_durations_sample.tsv
index 55fbf44d0ff0..6d85307a7032 100644
--- a/ci/tests/data/integration_test_durations_sample.tsv
+++ b/ci/tests/data/integration_test_durations_sample.tsv
@@ -317,7 +317,6 @@ test_keeper_opentelemetry_tracing/test.py 82072
test_refreshable_mv_watch_fault/test.py 81637
test_always_fetch_merged/test.py 80848
test_system_flush_logs/test.py 80564
-test_store_cleanup/test.py 80458
test_rmv_access_denied_on_rename_race/test.py 80328
test_replicated_merge_tree_compatibility/test.py 79758
test_clickhouse_server_wait_server_pool/test.py 79623
diff --git a/cmake/autogenerated_versions.txt b/cmake/autogenerated_versions.txt
index 54176be7b1d4..db49181a9d49 100644
--- a/cmake/autogenerated_versions.txt
+++ b/cmake/autogenerated_versions.txt
@@ -2,13 +2,13 @@
# NOTE: VERSION_REVISION has nothing common with DBMS_TCP_PROTOCOL_VERSION,
# only DBMS_TCP_PROTOCOL_VERSION should be incremented on protocol changes.
-SET(VERSION_REVISION 54551)
+SET(VERSION_REVISION 54566)
SET(VERSION_MAJOR 26)
SET(VERSION_MINOR 8)
-SET(VERSION_PATCH 39)
-SET(VERSION_GITHASH 71391c9b2bbc4d2c104996451586a396138a4785)
-SET(VERSION_DESCRIBE v26.8.39.20001.altinityantalya)
-SET(VERSION_STRING 26.8.39.20001.altinityantalya)
+SET(VERSION_PATCH 54)
+SET(VERSION_GITHASH cb5e492e954c7689d2eb953a3a8665c160d8ac37)
+SET(VERSION_DESCRIBE v26.8.54.20001.altinityantalya)
+SET(VERSION_STRING 26.8.54.20001.altinityantalya)
# end of autochange
SET(VERSION_TWEAK 20001)
diff --git a/contrib/chdig b/contrib/chdig
index a28e1072f6e2..af4005a0dba2 160000
--- a/contrib/chdig
+++ b/contrib/chdig
@@ -1 +1 @@
-Subproject commit a28e1072f6e2aeb98116ae6f6ecda06d57e877ff
+Subproject commit af4005a0dba22924bb295c0986d481f037e0d802
diff --git a/contrib/chdig-cmake/CMakeLists.txt b/contrib/chdig-cmake/CMakeLists.txt
index 9dfb54411ba3..d5d45c612ab2 100644
--- a/contrib/chdig-cmake/CMakeLists.txt
+++ b/contrib/chdig-cmake/CMakeLists.txt
@@ -17,10 +17,10 @@ if (NOT ENABLE_CHDIG OR NOT ENABLE_RUST)
return()
endif()
-clickhouse_import_crate(MANIFEST_PATH ../chdig/Cargo.toml FEATURES tls)
-clickhouse_config_crate_flags(chdig)
-add_library(ch_rust::chdig ALIAS chdig)
+clickhouse_import_crate(MANIFEST_PATH Cargo.toml)
+clickhouse_config_crate_flags(_ch_rust_chdig)
+add_library(ch_rust::chdig ALIAS _ch_rust_chdig)
if (OS_DARWIN)
- target_link_libraries(chdig INTERFACE "-framework AppKit")
+ target_link_libraries(_ch_rust_chdig INTERFACE "-framework AppKit")
endif()
diff --git a/contrib/chdig-cmake/Cargo.lock b/contrib/chdig-cmake/Cargo.lock
new file mode 100644
index 000000000000..26ec2ffdc050
--- /dev/null
+++ b/contrib/chdig-cmake/Cargo.lock
@@ -0,0 +1,2658 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "_ch_rust_chdig"
+version = "0.1.0"
+dependencies = [
+ "chdig",
+]
+
+[[package]]
+name = "adler2"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+
+[[package]]
+name = "aead"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
+dependencies = [
+ "crypto-common",
+ "generic-array",
+]
+
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
+ "subtle",
+]
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "allocator-api2"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "anstream"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
+
+[[package]]
+name = "anstyle-parse"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
+
+[[package]]
+name = "approx"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "ascii"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
+
+[[package]]
+name = "by_address"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"
+
+[[package]]
+name = "byteorder"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+[[package]]
+name = "bytes"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
+
+[[package]]
+name = "castaway"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
+dependencies = [
+ "rustversion",
+]
+
+[[package]]
+name = "cc"
+version = "1.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+
+[[package]]
+name = "chdig"
+version = "26.11.1"
+dependencies = [
+ "aes-gcm",
+ "anyhow",
+ "base64",
+ "chrono",
+ "chrono-tz",
+ "clap",
+ "clap_complete",
+ "clickhouse-rs",
+ "crossbeam-channel",
+ "crossterm",
+ "flamelens",
+ "flate2",
+ "flexi_logger",
+ "futures",
+ "futures-util",
+ "fuzzy-matcher",
+ "getrandom 0.2.17",
+ "humantime",
+ "libc",
+ "log",
+ "percent-encoding",
+ "perfetto_protos",
+ "protobuf",
+ "quick-xml",
+ "ratatui",
+ "regex",
+ "semver",
+ "serde",
+ "serde_json",
+ "serde_norway",
+ "signal-hook",
+ "size",
+ "strfmt",
+ "tempfile",
+ "tiny_http",
+ "tokio",
+ "unicode-width",
+ "url",
+ "uuid",
+]
+
+[[package]]
+name = "chrono"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
+dependencies = [
+ "iana-time-zone",
+ "num-traits",
+ "windows-link",
+]
+
+[[package]]
+name = "chrono-tz"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e"
+dependencies = [
+ "chrono",
+ "chrono-tz-build",
+ "phf",
+]
+
+[[package]]
+name = "chrono-tz-build"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f"
+dependencies = [
+ "parse-zoneinfo",
+ "phf",
+ "phf_codegen",
+]
+
+[[package]]
+name = "chunked_transfer"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901"
+
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common",
+ "inout",
+]
+
+[[package]]
+name = "clap"
+version = "4.6.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.6.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_complete"
+version = "4.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "037e2a1a92236d0aff7e845093f64661d6df4c02c9fcc61a60e9e1d736fa392f"
+dependencies = [
+ "clap",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.6.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "clap_lex"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
+
+[[package]]
+name = "clickhouse-rs"
+version = "1.1.0-alpha.1"
+source = "git+https://github.com/azat-rust/clickhouse-rs?branch=next#50f683f0ae358d784c34eb0545c056fa3939c502"
+dependencies = [
+ "byteorder",
+ "cfg-if",
+ "chrono",
+ "chrono-tz",
+ "clickhouse-rs-cityhash-sys",
+ "combine",
+ "crossbeam-queue",
+ "either",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "hostname",
+ "lazy_static",
+ "log",
+ "lz4",
+ "percent-encoding",
+ "pin-project",
+ "rustls",
+ "thiserror 2.0.21",
+ "tokio",
+ "tokio-rustls",
+ "url",
+ "uuid",
+ "webpki-roots",
+]
+
+[[package]]
+name = "clickhouse-rs-cityhash-sys"
+version = "0.1.2"
+source = "git+https://github.com/azat-rust/clickhouse-rs?branch=next#50f683f0ae358d784c34eb0545c056fa3939c502"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "colorchoice"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
+
+[[package]]
+name = "combine"
+version = "4.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92"
+dependencies = [
+ "bytes",
+ "memchr",
+]
+
+[[package]]
+name = "compact_str"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab"
+dependencies = [
+ "castaway",
+ "cfg-if",
+ "itoa",
+ "rustversion",
+ "ryu",
+ "static_assertions",
+]
+
+[[package]]
+name = "convert_case"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crc32fast"
+version = "1.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "critical-section"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-queue"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
+
+[[package]]
+name = "crossterm"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
+dependencies = [
+ "bitflags",
+ "crossterm_winapi",
+ "derive_more",
+ "document-features",
+ "filedescriptor",
+ "mio",
+ "parking_lot",
+ "rustix 1.1.6",
+ "signal-hook",
+ "signal-hook-mio",
+ "winapi",
+]
+
+[[package]]
+name = "crossterm_winapi"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
+[[package]]
+name = "ctr"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
+dependencies = [
+ "cipher",
+]
+
+[[package]]
+name = "darling"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
+dependencies = [
+ "darling_core",
+ "darling_macro",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
+dependencies = [
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
+dependencies = [
+ "darling_core",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "deranged"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
+
+[[package]]
+name = "derive_more"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"
+dependencies = [
+ "derive_more-impl",
+]
+
+[[package]]
+name = "derive_more-impl"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
+dependencies = [
+ "convert_case",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "document-features"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
+dependencies = [
+ "litrs",
+]
+
+[[package]]
+name = "either"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
+
+[[package]]
+name = "equivalent"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
+
+[[package]]
+name = "errno"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "filedescriptor"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d"
+dependencies = [
+ "libc",
+ "thiserror 1.0.69",
+ "winapi",
+]
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
+
+[[package]]
+name = "flamelens"
+version = "0.4.0"
+source = "git+https://github.com/azat-rust/flamelens?branch=chdig#40706414c879da3359acd432547c05938c47bad0"
+dependencies = [
+ "anyhow",
+ "cfg-if",
+ "clap",
+ "crossterm",
+ "ratatui",
+ "regex",
+ "serde",
+ "serde_json",
+ "tui-input",
+]
+
+[[package]]
+name = "flate2"
+version = "1.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
+[[package]]
+name = "flexi_logger"
+version = "0.27.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "469e584c031833564840fb0cdbce99bdfe946fd45480a188545e73a76f45461c"
+dependencies = [
+ "chrono",
+ "glob",
+ "lazy_static",
+ "log",
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "foldhash"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "futures"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-io"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
+
+[[package]]
+name = "futures-macro"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "futures-sink"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-macro",
+ "futures-sink",
+ "futures-task",
+ "memchr",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "fuzzy-matcher"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94"
+dependencies = [
+ "thread_local",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+]
+
+[[package]]
+name = "ghash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
+dependencies = [
+ "opaque-debug",
+ "polyval",
+]
+
+[[package]]
+name = "glob"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
+
+[[package]]
+name = "hashbrown"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
+dependencies = [
+ "allocator-api2",
+ "equivalent",
+ "foldhash",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "home"
+version = "0.5.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "hostname"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
+dependencies = [
+ "libc",
+ "match_cfg",
+ "winapi",
+]
+
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "humantime"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15"
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "icu_collections"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd"
+dependencies = [
+ "displaydoc",
+ "potential_utf",
+ "utf8_iter",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599"
+dependencies = [
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc"
+
+[[package]]
+name = "icu_properties"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf"
+
+[[package]]
+name = "icu_provider"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514"
+dependencies = [
+ "displaydoc",
+ "icu_locale_core",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "ident_case"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
+
+[[package]]
+name = "idna"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "indoc"
+version = "2.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
+dependencies = [
+ "rustversion",
+]
+
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "instability"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20"
+dependencies = [
+ "darling",
+ "indoc",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
+
+[[package]]
+name = "itertools"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
+
+[[package]]
+name = "js-sys"
+version = "0.3.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "kasuari"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f14c90e40a6133f4805b83542a7ed7364f56070b447f56e7f4e90297122209"
+dependencies = [
+ "hashbrown",
+ "portable-atomic",
+ "thiserror 2.0.21",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
+
+[[package]]
+name = "libc"
+version = "0.2.191"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+
+[[package]]
+name = "libm"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
+
+[[package]]
+name = "line-clipping"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e752191d037c44ad111a8caa762921926658402f01cc1253f7bef2020ece4f5e"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "litemap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
+
+[[package]]
+name = "litrs"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70"
+
+[[package]]
+name = "lock_api"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+dependencies = [
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "lru"
+version = "0.18.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5"
+dependencies = [
+ "hashbrown",
+]
+
+[[package]]
+name = "lz4"
+version = "1.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4"
+dependencies = [
+ "lz4-sys",
+]
+
+[[package]]
+name = "lz4-sys"
+version = "1.11.1+lz4-1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
+name = "match_cfg"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
+dependencies = [
+ "adler2",
+ "simd-adler32",
+]
+
+[[package]]
+name = "mio"
+version = "1.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "num-conv"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "num_threads"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
+
+[[package]]
+name = "opaque-debug"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
+
+[[package]]
+name = "palette"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ddeed8580d347d2abf3dcf06a5f0b3dc020258338526b277847cd4248a70fc64"
+dependencies = [
+ "approx",
+ "libm",
+ "palette_derive",
+ "palette_math",
+]
+
+[[package]]
+name = "palette_derive"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "88537020289b719d81be994ccf1bbf4990f477e2f69ee52fe3e45f43a02e56be"
+dependencies = [
+ "by_address",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "palette_math"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e6eb142958d64335fb0e345c5b9ead2ecd6fc438c307e9d7d3c4fd428dbaf12"
+dependencies = [
+ "libm",
+]
+
+[[package]]
+name = "parking_lot"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-link",
+]
+
+[[package]]
+name = "parse-zoneinfo"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24"
+dependencies = [
+ "regex",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+
+[[package]]
+name = "perfetto_protos"
+version = "0.51.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "634f88ebef917643d9e470dbf99637fbfa8295f54525954d156641f06823f9ac"
+dependencies = [
+ "protobuf",
+ "protobuf-codegen",
+ "protoc-bin-vendored",
+]
+
+[[package]]
+name = "phf"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
+dependencies = [
+ "phf_shared",
+]
+
+[[package]]
+name = "phf_codegen"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
+dependencies = [
+ "phf_generator",
+ "phf_shared",
+]
+
+[[package]]
+name = "phf_generator"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
+dependencies = [
+ "phf_shared",
+ "rand",
+]
+
+[[package]]
+name = "phf_shared"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
+dependencies = [
+ "siphasher",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "polyval"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "opaque-debug",
+ "universal-hash",
+]
+
+[[package]]
+name = "portable-atomic"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
+
+[[package]]
+name = "potential_utf"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "powerfmt"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "protobuf"
+version = "3.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d65a1d4ddae7d8b5de68153b48f6aa3bba8cb002b243dbdbc55a5afbc98f99f4"
+dependencies = [
+ "once_cell",
+ "protobuf-support",
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "protobuf-codegen"
+version = "3.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d3976825c0014bbd2f3b34f0001876604fe87e0c86cd8fa54251530f1544ace"
+dependencies = [
+ "anyhow",
+ "once_cell",
+ "protobuf",
+ "protobuf-parse",
+ "regex",
+ "tempfile",
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "protobuf-parse"
+version = "3.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4aeaa1f2460f1d348eeaeed86aea999ce98c1bded6f089ff8514c9d9dbdc973"
+dependencies = [
+ "anyhow",
+ "indexmap",
+ "log",
+ "protobuf",
+ "protobuf-support",
+ "tempfile",
+ "thiserror 1.0.69",
+ "which",
+]
+
+[[package]]
+name = "protobuf-support"
+version = "3.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e36c2f31e0a47f9280fb347ef5e461ffcd2c52dd520d8e216b52f93b0b0d7d6"
+dependencies = [
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "protoc-bin-vendored"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8760a25b6ff9c620324822737e468478fa092234190d2e449760344354896ed9"
+dependencies = [
+ "protoc-bin-vendored-linux-aarch_64",
+ "protoc-bin-vendored-linux-ppcle_64",
+ "protoc-bin-vendored-linux-s390_64",
+ "protoc-bin-vendored-linux-x86_32",
+ "protoc-bin-vendored-linux-x86_64",
+ "protoc-bin-vendored-macos-aarch_64",
+ "protoc-bin-vendored-macos-x86_64",
+ "protoc-bin-vendored-win32",
+]
+
+[[package]]
+name = "protoc-bin-vendored-linux-aarch_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73fa2624782ca04cd44f51554566717377acd240e4c0016d757dd74fccc9324f"
+
+[[package]]
+name = "protoc-bin-vendored-linux-ppcle_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2417e9817fa237dab803ad4dda7357a111656e242959cc6b8f9a1a583367d42"
+
+[[package]]
+name = "protoc-bin-vendored-linux-s390_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4d189c34636356a46a7ed3188233dc8a88c431278cc54d4a19b096a2d270e985"
+
+[[package]]
+name = "protoc-bin-vendored-linux-x86_32"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "171e39f1e846e5f322ced1ac3b8d4cd3a3833ca24b6e5d58b3632574fe6204fa"
+
+[[package]]
+name = "protoc-bin-vendored-linux-x86_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "873cdcc097593432086661aa432b8078f1cd87bfb02847c332e98ae2c119e966"
+
+[[package]]
+name = "protoc-bin-vendored-macos-aarch_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eeb72df001783b8297847fe8f5f874ee400fd742c843d60583e8c23d96977c7f"
+
+[[package]]
+name = "protoc-bin-vendored-macos-x86_64"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b04652167eca899dda05f32f5481adeaf25c623a98ce2fc146a001cc59a2add7"
+
+[[package]]
+name = "protoc-bin-vendored-win32"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "263a3f48f01e7309e857138bd47f785585b4a005e8e56c6d2824ce91195999c3"
+
+[[package]]
+name = "quick-xml"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b"
+dependencies = [
+ "memchr",
+ "serde",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "rand"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
+dependencies = [
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+
+[[package]]
+name = "ratatui"
+version = "0.30.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3274ba0a2c5e1bcad2a2005d20f4dc59dad26b2eb0940fb094500dba4099d57d"
+dependencies = [
+ "instability",
+ "ratatui-core",
+ "ratatui-crossterm",
+ "ratatui-widgets",
+ "serde",
+]
+
+[[package]]
+name = "ratatui-core"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c"
+dependencies = [
+ "bitflags",
+ "compact_str",
+ "critical-section",
+ "hashbrown",
+ "itertools",
+ "kasuari",
+ "lru",
+ "palette",
+ "serde",
+ "strum",
+ "thiserror 2.0.21",
+ "unicode-segmentation",
+ "unicode-truncate",
+ "unicode-width",
+]
+
+[[package]]
+name = "ratatui-crossterm"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567584a3b0e6a8203c23de40b4861497266725eb5363dbfd18a1edd603cca9f0"
+dependencies = [
+ "cfg-if",
+ "crossterm",
+ "instability",
+ "ratatui-core",
+]
+
+[[package]]
+name = "ratatui-widgets"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1"
+dependencies = [
+ "bitflags",
+ "hashbrown",
+ "indoc",
+ "instability",
+ "itertools",
+ "line-clipping",
+ "ratatui-core",
+ "serde",
+ "strum",
+ "time",
+ "unicode-segmentation",
+ "unicode-width",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "regex"
+version = "1.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
+
+[[package]]
+name = "ring"
+version = "0.17.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom 0.2.17",
+ "libc",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustix"
+version = "0.38.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.4.15",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "rustix"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.12.1",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
+dependencies = [
+ "log",
+ "once_cell",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
+dependencies = [
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "ryu"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "semver"
+version = "1.0.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "serde_norway"
+version = "0.9.42"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e408f29489b5fd500fab51ff1484fc859bb655f32c671f307dcd733b72e8168c"
+dependencies = [
+ "indexmap",
+ "itoa",
+ "ryu",
+ "serde",
+ "unsafe-libyaml-norway",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "signal-hook"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
+dependencies = [
+ "libc",
+ "signal-hook-registry",
+]
+
+[[package]]
+name = "signal-hook-mio"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
+dependencies = [
+ "libc",
+ "mio",
+ "signal-hook",
+]
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
+dependencies = [
+ "errno",
+ "libc",
+]
+
+[[package]]
+name = "simd-adler32"
+version = "0.3.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
+
+[[package]]
+name = "siphasher"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
+
+[[package]]
+name = "size"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c48f464f8e2766494cb2223d1683ff6801dd56f0d07298500f9c970de2571cf0"
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "smallvec"
+version = "1.16.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
+
+[[package]]
+name = "socket2"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "strfmt"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "046d549b88a663d317cd04d39696fca5f77db4db44e1db65bfb9dee7f9e680bd"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "strum"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
+dependencies = [
+ "strum_macros",
+]
+
+[[package]]
+name = "strum_macros"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom 0.4.3",
+ "once_cell",
+ "rustix 1.1.6",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl 1.0.69",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl 2.0.21",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "time"
+version = "0.3.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
+dependencies = [
+ "deranged",
+ "libc",
+ "num-conv",
+ "num_threads",
+ "powerfmt",
+ "serde_core",
+ "time-core",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
+
+[[package]]
+name = "tiny_http"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82"
+dependencies = [
+ "ascii",
+ "chunked_transfer",
+ "httpdate",
+ "log",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a"
+dependencies = [
+ "displaydoc",
+ "zerovec",
+]
+
+[[package]]
+name = "tokio"
+version = "1.54.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
+dependencies = [
+ "bytes",
+ "libc",
+ "mio",
+ "pin-project-lite",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.26.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"
+dependencies = [
+ "rustls",
+ "tokio",
+]
+
+[[package]]
+name = "tui-input"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4fa0cb7933d19f91eb3109781bf7297d5e4cba57e857d97a29b9465d3383f56"
+dependencies = [
+ "crossterm",
+ "unicode-segmentation",
+ "unicode-width",
+]
+
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+
+[[package]]
+name = "unicode-truncate"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5"
+dependencies = [
+ "itertools",
+ "unicode-segmentation",
+ "unicode-width",
+]
+
+[[package]]
+name = "unicode-width"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557"
+
+[[package]]
+name = "universal-hash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
+dependencies = [
+ "crypto-common",
+ "subtle",
+]
+
+[[package]]
+name = "unsafe-libyaml-norway"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b39abd59bf32521c7f2301b52d05a6a2c975b6003521cbd0c6dc1582f0a22104"
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "url"
+version = "2.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+ "serde",
+]
+
+[[package]]
+name = "utf8_iter"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0"
+dependencies = [
+ "utf_types",
+]
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "utf_types"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6"
+
+[[package]]
+name = "uuid"
+version = "1.29.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bed99139f7dac9b5cfe5f17be4d66dc7079a34dee1d74bcc77217119240e267c"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c"
+dependencies = [
+ "cfg-if",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297"
+dependencies = [
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "which"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
+dependencies = [
+ "either",
+ "home",
+ "once_cell",
+ "rustix 0.38.44",
+]
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows-core"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.59.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-result"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "writeable"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
+
+[[package]]
+name = "yoke"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3"
+dependencies = [
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "synstructure",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "synstructure",
+]
+
+[[package]]
+name = "zeroize"
+version = "1.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879"
+
+[[package]]
+name = "zerotrie"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.11.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.11.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
diff --git a/contrib/chdig-cmake/Cargo.toml b/contrib/chdig-cmake/Cargo.toml
new file mode 100644
index 000000000000..d36786053af7
--- /dev/null
+++ b/contrib/chdig-cmake/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "_ch_rust_chdig"
+version = "0.1.0"
+edition = "2021"
+
+[lib]
+crate-type = ["staticlib"]
+
+[dependencies]
+chdig = { path = "../chdig", default-features = false, features = ["tls"] }
+
+# Standalone, so that the lock in this directory is used instead of the one in `chdig`
+[workspace]
diff --git a/contrib/chdig-cmake/src/lib.rs b/contrib/chdig-cmake/src/lib.rs
new file mode 100644
index 000000000000..4a18a6b2ef29
--- /dev/null
+++ b/contrib/chdig-cmake/src/lib.rs
@@ -0,0 +1 @@
+pub use chdig;
diff --git a/contrib/krb5 b/contrib/krb5
index 857c2d1edd7a..17f660ca561d 160000
--- a/contrib/krb5
+++ b/contrib/krb5
@@ -1 +1 @@
-Subproject commit 857c2d1edd7a4218b84594768587aa53fd63da9e
+Subproject commit 17f660ca561db6716125041396ce2cdd8ebd594a
diff --git a/contrib/krb5-cmake/autoconf_darwin.h b/contrib/krb5-cmake/autoconf_darwin.h
index 64c28f90b41b..7c7ee22fa1ff 100644
--- a/contrib/krb5-cmake/autoconf_darwin.h
+++ b/contrib/krb5-cmake/autoconf_darwin.h
@@ -635,7 +635,7 @@
#define PACKAGE_NAME "Kerberos 5"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Kerberos 5 1.22.1"
+#define PACKAGE_STRING "Kerberos 5 1.22.3"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "krb5"
@@ -644,7 +644,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.22.1"
+#define PACKAGE_VERSION "1.22.3"
/* Define if setjmp indicates POSIX interface */
#define POSIX_SETJMP 1
diff --git a/contrib/krb5-cmake/autoconf_linux.h b/contrib/krb5-cmake/autoconf_linux.h
index ec8e867eec38..efa76cd145fc 100644
--- a/contrib/krb5-cmake/autoconf_linux.h
+++ b/contrib/krb5-cmake/autoconf_linux.h
@@ -637,7 +637,7 @@
#define PACKAGE_NAME "Kerberos 5"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Kerberos 5 1.22.1"
+#define PACKAGE_STRING "Kerberos 5 1.22.3"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "krb5"
@@ -646,7 +646,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.22.1"
+#define PACKAGE_VERSION "1.22.3"
/* Define if setjmp indicates POSIX interface */
/* #undef POSIX_SETJMP */
diff --git a/contrib/lz4 b/contrib/lz4
index ebb370ca83af..aa4647fad575 160000
--- a/contrib/lz4
+++ b/contrib/lz4
@@ -1 +1 @@
-Subproject commit ebb370ca83af193212df4dcbadcc5d87bc0de2f0
+Subproject commit aa4647fad575d01a874aaaadcdbe8e6a40e072f5
diff --git a/contrib/mongo-c-driver b/contrib/mongo-c-driver
index 58b4e1f39c6f..bc3a26beeb18 160000
--- a/contrib/mongo-c-driver
+++ b/contrib/mongo-c-driver
@@ -1 +1 @@
-Subproject commit 58b4e1f39c6f8bcf4da4204deb84f9b3527388d4
+Subproject commit bc3a26beeb18da7d0f8e1704618ac09ce74531c1
diff --git a/contrib/mongo-c-driver-cmake/CMakeLists.txt b/contrib/mongo-c-driver-cmake/CMakeLists.txt
index 6d013bc450fa..815aa4451ea2 100644
--- a/contrib/mongo-c-driver-cmake/CMakeLists.txt
+++ b/contrib/mongo-c-driver-cmake/CMakeLists.txt
@@ -6,12 +6,12 @@ endif()
set(libbson_VERSION_MAJOR 2)
set(libbson_VERSION_MINOR 5)
-set(libbson_VERSION_PATCH 8)
-set(libbson_VERSION 2.5.8)
+set(libbson_VERSION_PATCH 10)
+set(libbson_VERSION 2.5.10)
set(libmongoc_VERSION_MAJOR 2)
set(libmongoc_VERSION_MINOR 5)
-set(libmongoc_VERSION_PATCH 8)
-set(libmongoc_VERSION 2.5.8)
+set(libmongoc_VERSION_PATCH 10)
+set(libmongoc_VERSION 2.5.10)
set(LIBBSON_SOURCES_ROOT "${ClickHouse_SOURCE_DIR}/contrib/mongo-c-driver/src")
set(LIBBSON_SOURCE_DIR "${LIBBSON_SOURCES_ROOT}/libbson/src")
diff --git a/contrib/postgres b/contrib/postgres
index ab6952af3ac8..c7649becd213 160000
--- a/contrib/postgres
+++ b/contrib/postgres
@@ -1 +1 @@
-Subproject commit ab6952af3ac8cdede654be4dc68f990b0352c213
+Subproject commit c7649becd213231466df7e679154e8ac0f744788
diff --git a/contrib/postgres-cmake/pg_config.h b/contrib/postgres-cmake/pg_config.h
index 84e435838d41..9df1b95a3b33 100644
--- a/contrib/postgres-cmake/pg_config.h
+++ b/contrib/postgres-cmake/pg_config.h
@@ -593,7 +593,7 @@
#define PACKAGE_NAME "PostgreSQL"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "PostgreSQL 18.3"
+#define PACKAGE_STRING "PostgreSQL 18.6"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "postgresql"
@@ -602,7 +602,7 @@
#define PACKAGE_URL "https://www.postgresql.org/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "18.3"
+#define PACKAGE_VERSION "18.6"
/* Define to the name of a signed 128-bit integer type. */
#define PG_INT128_TYPE __int128
@@ -618,7 +618,7 @@
#define PG_MAJORVERSION_NUM 18
/* PostgreSQL minor version number */
-#define PG_MINORVERSION_NUM 4
+#define PG_MINORVERSION_NUM 6
/* Define to best C++ printf format archetype, usually gnu_printf if
available. */
@@ -629,13 +629,13 @@
#define PG_C_PRINTF_ATTRIBUTE gnu_printf
/* PostgreSQL version as a string */
-#define PG_VERSION "18.4"
+#define PG_VERSION "18.6"
/* PostgreSQL version as a number */
-#define PG_VERSION_NUM 180004
+#define PG_VERSION_NUM 180006
/* A string containing the version number, platform, and C compiler */
-#define PG_VERSION_STR "PostgreSQL 18.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 15.2.1 20250813, 64-bit"
+#define PG_VERSION_STR "PostgreSQL 18.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 15.2.1 20250813, 64-bit"
/* Define to 1 to allow profiling output to be saved separately for each
process. */
diff --git a/contrib/rust_vendor b/contrib/rust_vendor
index c4fd435abe86..11cea4f35a9a 160000
--- a/contrib/rust_vendor
+++ b/contrib/rust_vendor
@@ -1 +1 @@
-Subproject commit c4fd435abe8696742d992306a2c6f48a2e57e3ae
+Subproject commit 11cea4f35a9a6184e391d76333aea8662c6e3c1d
diff --git a/contrib/wasmtime b/contrib/wasmtime
index 561b224fd058..1c05b58b727c 160000
--- a/contrib/wasmtime
+++ b/contrib/wasmtime
@@ -1 +1 @@
-Subproject commit 561b224fd0589a02fc9e7bcef1aeb70d886d33c0
+Subproject commit 1c05b58b727cdb87dfdc8f076feef2b1666e6a53
diff --git a/contrib/zlib-ng b/contrib/zlib-ng
index a2fbeffdc30a..a7943f5947a9 160000
--- a/contrib/zlib-ng
+++ b/contrib/zlib-ng
@@ -1 +1 @@
-Subproject commit a2fbeffdc30a8b0ce6d54ee31208e2688eac4c9f
+Subproject commit a7943f5947a9533b4efbbf48915764ac73211431
diff --git a/contrib/zstd b/contrib/zstd
index 5b3e9e8fd277..1663170820f4 160000
--- a/contrib/zstd
+++ b/contrib/zstd
@@ -1 +1 @@
-Subproject commit 5b3e9e8fd2779260101a07e6cc7b34fd8764617f
+Subproject commit 1663170820f4825123ddfc4976223ad2c78b21cc
diff --git a/docker/keeper/Dockerfile b/docker/keeper/Dockerfile
index 85b7712ef4ac..2f044c8864cb 100644
--- a/docker/keeper/Dockerfile
+++ b/docker/keeper/Dockerfile
@@ -61,6 +61,10 @@ RUN addgroup -S -g "${DEFAULT_GID}" clickhouse && \
ARG WGET_RETRIES=5
ARG WGET_RETRY_DELAY=1
+# `apk upgrade` runs first because `apk add` never bumps packages already in the base
+# image, so without it the image keeps whatever (possibly vulnerable) libssl3 the
+# `alpine` snapshot had at build time.
+#
# `apk` has no retry option, and it does not treat a failed repository index fetch
# as fatal: it proceeds with an empty index, so every requested package is then
# reported as `no such package`.
@@ -83,7 +87,7 @@ RUN arch=${TARGETARCH:-amd64} \
&& apk_add_with_retry() { \
local attempt=1; \
while [ "$attempt" -le "${APK_RETRIES}" ]; do \
- if apk add --no-cache "$@"; then return 0; fi; \
+ if apk upgrade --no-cache && apk add --no-cache "$@"; then return 0; fi; \
echo "Attempt $attempt/${APK_RETRIES} failed for apk add $*, retrying in ${APK_RETRY_DELAY}s..."; \
sleep "${APK_RETRY_DELAY}"; \
attempt=$((attempt + 1)); \
diff --git a/docker/server/Dockerfile.alpine b/docker/server/Dockerfile.alpine
index 3aaf63a034b4..4de58ea346fd 100644
--- a/docker/server/Dockerfile.alpine
+++ b/docker/server/Dockerfile.alpine
@@ -55,6 +55,10 @@ RUN addgroup -S -g "${DEFAULT_GID}" clickhouse && \
ARG WGET_RETRIES=5
ARG WGET_RETRY_DELAY=1
+# `apk upgrade` runs first because `apk add` never bumps packages already in the base
+# image, so without it the image keeps whatever (possibly vulnerable) libssl3 the
+# `alpine` snapshot had at build time.
+#
# `apk` has no retry option, and it does not treat a failed repository index fetch
# as fatal: it proceeds with an empty index, so every requested package is then
# reported as `no such package`.
@@ -76,7 +80,7 @@ RUN arch=${TARGETARCH:-amd64} \
&& apk_add_with_retry() { \
local attempt=1; \
while [ "$attempt" -le "${APK_RETRIES}" ]; do \
- if apk add --no-cache "$@"; then return 0; fi; \
+ if apk upgrade --no-cache && apk add --no-cache "$@"; then return 0; fi; \
echo "Attempt $attempt/${APK_RETRIES} failed for apk add $*, retrying in ${APK_RETRY_DELAY}s..."; \
sleep "${APK_RETRY_DELAY}"; \
attempt=$((attempt + 1)); \
diff --git a/docs/concepts/features/interfaces/http.mdx b/docs/concepts/features/interfaces/http.mdx
index ee87cf7216b6..0aad852e197a 100644
--- a/docs/concepts/features/interfaces/http.mdx
+++ b/docs/concepts/features/interfaces/http.mdx
@@ -644,7 +644,7 @@ curl -sS "http://localhost:8123?role=my_role&role=my_other_role" --data-binary "
In this case, `?role=my_role&role=my_other_role` works similarly to executing `SET ROLE my_role, my_other_role` before the statement.
-The `role` query parameter is not affected by the `access_control_improvements.readonly_restricts_set_role` server setting, which refuses only the `SET ROLE` statement.
+The `role` query parameter is not affected by the `access_control_improvements.readonly_restricts_set_role` server setting, which refuses only the `SET ROLE` and `SET DEFAULT ROLE` statements.
## HTTP response codes caveats {#http_response_codes_caveats}
diff --git a/docs/en/sql-reference/statements/create/handler.md b/docs/en/sql-reference/statements/create/handler.md
index 5b1a2ebfc1fb..4707ae70eef7 100644
--- a/docs/en/sql-reference/statements/create/handler.md
+++ b/docs/en/sql-reference/statements/create/handler.md
@@ -48,7 +48,7 @@ The functions [`currentHandler`](/sql-reference/functions/other-functions#curren
## Access control {#access-control}
-`CREATE HANDLER`, `DROP HANDLER` and `ALTER HANDLER` require the `CREATE HANDLER`, `DROP HANDLER` and `ALTER HANDLER` grants respectively.
+`CREATE HANDLER`, `DROP HANDLER` and `ALTER HANDLER` require the `CREATE HANDLER`, `DROP HANDLER` and `ALTER HANDLER` grants respectively. These privileges and `SHOW HANDLERS` form the `HANDLER ADMIN` privilege group; they are not part of the `CREATE`, `ALTER` and `DROP` privilege groups.
Reading the [`system.handlers`](/operations/system-tables/handlers) table requires the `SHOW HANDLERS` grant. Secrets that may be embedded in a handler's query are masked there unless the user is additionally allowed to see secrets (see [`system.handlers`](/operations/system-tables/handlers)).
diff --git a/docs/reference/functions/regular-functions/ai-functions.mdx b/docs/reference/functions/regular-functions/ai-functions.mdx
index 2cb7851fbf60..bb6ec61986ad 100644
--- a/docs/reference/functions/regular-functions/ai-functions.mdx
+++ b/docs/reference/functions/regular-functions/ai-functions.mdx
@@ -229,24 +229,49 @@ AI function activity is tracked through ClickHouse [ProfileEvents](/reference/sy
| ProfileEvent | Description |
|-------|-------------|
| `AIAPICalls` | Number of HTTP requests made to the AI provider. |
-| `AIInputTokens` | Total input tokens consumed. |
+| `AIInputTokens` | Total input tokens consumed, including cache reads and writes. |
| `AIOutputTokens` | Total output tokens consumed. |
+| `AICacheReadTokens` | Input tokens read from the provider's prompt cache. |
+| `AICacheWriteTokens` | Input tokens written to the provider's prompt cache. |
+| `AIRequestMicroseconds` | Total time spent in AI provider calls (request serialization, HTTP round trip, response parsing), including failed attempts, excluding retry backoff. |
+| `AIRetryBackoffMicroseconds` | Total time spent waiting before retries of failed AI provider calls. |
| `AIRowsProcessed` | Number of rows that received a result. |
| `AIRowsSkipped` | Number of rows skipped (quota exceeded, or error with `ai_function_throw_on_error = 0`). |
+Times are summed across executions and threads, so they can exceed query wall-clock time.
+Divide `AIRequestMicroseconds` by `AIAPICalls` to get mean request latency, including failed attempts.
+These counters are per-query, they do not provide per-request latency information.
+If a query calls multiple AI functions, their counts are added together.
+
+Cache counters are subsets of `AIInputTokens`, not additional tokens. They report provider-emitted cache reads/writes, not any internal ClickHouse caching. A provider that omits cache usage contributes
+zero cache tokens.
+
Query these events:
```sql
+SYSTEM FLUSH LOGS;
+
SELECT
+ query_duration_ms,
ProfileEvents['AIAPICalls'] AS api_calls,
+ ProfileEvents['AIRequestMicroseconds'] / 1000 AS request_ms,
+ request_ms / nullIf(api_calls, 0) AS mean_request_ms,
+ ProfileEvents['AIRetryBackoffMicroseconds'] / 1000 AS retry_backoff_ms,
+ ProfileEvents['AIRowsProcessed'] AS rows_processed,
+ ProfileEvents['AIRowsSkipped'] AS rows_skipped,
ProfileEvents['AIInputTokens'] AS input_tokens,
- ProfileEvents['AIOutputTokens'] AS output_tokens
+ ProfileEvents['AIOutputTokens'] AS output_tokens,
+ ProfileEvents['AICacheReadTokens'] AS cache_read_tokens,
+ ProfileEvents['AICacheWriteTokens'] AS cache_write_tokens
FROM system.query_log
WHERE query_id = 'query_id'
-AND type = 'QueryFinish'
+AND type IN ('QueryFinish', 'ExceptionWhileProcessing')
ORDER BY event_time DESC;
```
+`log_queries` and `log_profile_events` are enabled by default to record these events in `system.query_log`.
+Server-wide totals are also available in `system.events`.
+
{/*
The inner content of the tags below are replaced at doc framework build time with
docs generated from system.functions. Please do not modify or remove the tags.
diff --git a/docs/reference/interfaces/specs/NativeFormat.mdx b/docs/reference/interfaces/specs/NativeFormat.mdx
index 301aaa82b489..6f24fb27d908 100644
--- a/docs/reference/interfaces/specs/NativeFormat.mdx
+++ b/docs/reference/interfaces/specs/NativeFormat.mdx
@@ -203,7 +203,8 @@ The `count` is the full stack length **including the leading `DEFAULT` entry** t
Note that this order is not the order of the kind byte values above. Any other stack describes a column layout no writer builds and that no materialization step unwraps back to a full column of the declared type — a `ColumnSparse` whose values column is itself sparse or replicated, for instance, stays wrapped.
-**Recursive `kind_stack` for `Tuple` columns.** The `kind_stack` payload above is the byte (or `COMBINATION` sequence) for one column's own serialization info. A `Tuple` carries a `SerializationInfoTuple`, which first writes the tuple's *own* kind-stack payload and then writes one full kind-stack payload for *each* element, in order; a decoder reads back the same recursive structure. So for `Tuple(A, B, C)` the field-4 bytes are `[tuple_kind][A_kind][B_kind][C_kind]`, and each element payload is itself recursive if that element is again a composite. The `has_custom_serialization` byte (field 3) is set whenever the tuple's own info *or any element's* info is non-default, so a `Tuple` whose only special element is sparse or replicated still triggers the kind-stack payload. A decoder that reads only the single leading enum byte for a `Tuple` will stop too early and misread the remaining element-kind bytes as column data.
+**Recursive `kind_stack` for `Tuple` columns.** The `kind_stack` payload above is the byte (or `COMBINATION` sequence) for one column's own serialization info. A `Tuple` carries a `SerializationInfoTuple`, which first writes the tuple's *own* kind-stack payload and then writes one full kind-stack payload for *each* element, in order; a decoder reads back the same recursive structure. So for `Tuple(A, B, C)` the field-4 bytes are `[tuple_kind][A_kind][B_kind][C_kind]`, and each element payload is itself recursive if that element is again a composite. The `has_custom_serialization` byte (field 3) is set whenever the tuple's own info *or any element's* info is non-default, so a `Tuple` whose only special element is sparse still triggers the kind-stack payload. A decoder that reads only the single leading enum byte for a `Tuple` will stop too early and misread the remaining element-kind bytes as column data.
+An element's stack never contains `REPLICATED` or `DETACHED`: both wrap a whole top-level column only, and a decoder rejects either of them in an element stack with `INCORRECT_DATA`.
**Sparse wire format.** When `kind_stack = 0x01`, the column `data` is two streams written back-to-back in the single shared TCP stream:
@@ -237,7 +238,10 @@ A decoder reconstructs a dense column by selecting `elements[indexes[i]]` for ea
If the wrapped column was sparse, its stack is `{DEFAULT, SPARSE, DETACHED}`, which serializes as `DETACHED_OVER_SPARSE`. A client decoding such a column reads the blob length and bytes, then decompresses the blob to recover the inner column payload (see the [`ColumnBLOB` note](#compression-negotiation) under compression).
-`DETACHED` is directional: it may appear only in result blocks sent by a server, and only for a whole top-level column — never as one of the element kinds of a `Tuple`. Unlike the other kinds, it makes the runtime column a `ColumnBLOB` instead of the column of the declared type, so a receiver accepts it only when its own pipeline converts the blob back. A server therefore rejects `DETACHED` in any block a client sends — external table data, scalars and insert data alike — with `INCORRECT_DATA`.
+`DETACHED` is directional: it may appear only in result blocks sent by a server, and only for a whole top-level column — never as one of the element kinds of a `Tuple`. Unlike the other kinds, it makes the runtime column a `ColumnBLOB` instead of the column of the declared type, so a receiver accepts it only when its own pipeline converts the blob back.
+
+**Kinds in blocks sent to a server.** Every non-default kind is directional: it appears only in result blocks sent by a server.
+A block sent to a server — insert data, the data of the `input` table function, external table data and scalars, whether it comes from a client or from another server — carries only `DEFAULT` stacks: senders convert the columns to full ones before sending, and a server rejects any other kind in such a block with `INCORRECT_DATA`.
### Block variants {#block-variants}
diff --git a/docs/reference/interfaces/specs/NativeProtocol.mdx b/docs/reference/interfaces/specs/NativeProtocol.mdx
index 872448036117..a00f32a0aacf 100644
--- a/docs/reference/interfaces/specs/NativeProtocol.mdx
+++ b/docs/reference/interfaces/specs/NativeProtocol.mdx
@@ -779,6 +779,10 @@ The 8 columns, in this exact order:
| 7 | source | String | Logger name |
| 8 | text | String | Log message text |
+
+A server that receives the packet from another server of a distributed query forwards the rows to its own client only if the block has exactly this schema: the same number, order, names and types of the columns, each in the default [serialization kind](/reference/interfaces/specs/NativeFormat#kind-stack-and-sparse-encoding). It drops a block of any other structure and logs a warning.
+
+
### ProfileEvents (packet type 14) {#profileevents}
Server → Client. Carries per-query performance counters.
@@ -798,12 +802,14 @@ The 6 columns:
| 1 | host_name | String | Server hostname |
| 2 | current_time | DateTime | Event timestamp |
| 3 | thread_id | UInt64 | Thread ID |
-| 4 | type | Enum8 | Event type: 1 = Increment (counter), 2 = Gauge. The underlying storage is one signed byte. |
+| 4 | type | Enum8 | Event type: 1 = Increment (counter), 2 = Gauge. The underlying storage is one signed byte. The full type is `Enum8('increment' = 1, 'gauge' = 2)`. |
| 5 | name | String | Event name (e.g., `"Query"`, `"NetworkReceiveBytes"`) |
| 6 | value | Int64 | Counter value or gauge reading |
-The `value` column's element type is not fixed across packets — older servers emit `UInt64`, newer ones `Int64`. Read the column's type string from the block header rather than assuming one width.
+A server at revision 54450 emits the `value` column as `UInt64` and fills it with the total values of the counters instead of their increments. ClickHouse reads such a packet and discards its contents.
+
+From revision 54451 the schema is exact. ClickHouse, both as a client and as a server that receives the packet from another server of a distributed query, refuses a block that differs from it in the number, the order, the names or the types of the columns, or that carries a column in a non-default [serialization kind](/reference/interfaces/specs/NativeFormat#kind-stack-and-sparse-encoding), with the `UNEXPECTED_PACKET_FROM_SERVER` error.
### TableColumns (packet type 11) {#tablecolumns}
diff --git a/docs/reference/settings/server-settings/_server_settings_outside_source.mdx b/docs/reference/settings/server-settings/_server_settings_outside_source.mdx
index f72dee549231..a8acfb984546 100644
--- a/docs/reference/settings/server-settings/_server_settings_outside_source.mdx
+++ b/docs/reference/settings/server-settings/_server_settings_outside_source.mdx
@@ -1820,7 +1820,7 @@ Settings for optional improvements in the access control system.
| Setting | Description | Default |
|-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `on_cluster_queries_require_cluster_grant` | Sets whether `ON CLUSTER` queries require the `CLUSTER` grant. | `true` |
-| `readonly_restricts_set_role` | Sets whether the `SET ROLE` statement is refused when the session or the query is readonly. When `false`, `readonly` does not restrict `SET ROLE`. The `role` HTTP query parameter is not affected. | `false` |
+| `readonly_restricts_set_role` | Sets whether the `SET ROLE` and `SET DEFAULT ROLE` statements are refused when the session or the query is readonly. When `false`, `readonly` does not restrict `SET ROLE`, nor `SET DEFAULT ROLE ... TO CURRENT_USER`. The `role` HTTP query parameter is not affected. | `false` |
| `role_cache_expiration_time_seconds` | Sets the number of seconds since last access, that a role is stored in the Role Cache. | `600` |
| `select_from_information_schema_requires_grant` | Sets whether `SELECT * FROM information_schema.
` requires any grants and can be executed by any user. If set to true, then this query requires `GRANT SELECT ON information_schema.`, just as for ordinary tables. | `true` |
| `select_from_system_db_requires_grant` | Sets whether `SELECT * FROM system.` requires any grants and can be executed by any user. If set to true then this query requires `GRANT SELECT ON system.` just as for non-system tables. Exceptions: a few system tables (`tables`, `columns`, `databases`, and some constant tables like `one`, `contributors`) are still accessible for everyone; and if there is a `SHOW` privilege (e.g. `SHOW USERS`) granted then the corresponding system table (i.e. `system.users`) will be accessible. | `true` |
diff --git a/programs/client/FuzzLoop.cpp b/programs/client/FuzzLoop.cpp
index 58788361397d..583de7730397 100644
--- a/programs/client/FuzzLoop.cpp
+++ b/programs/client/FuzzLoop.cpp
@@ -358,7 +358,7 @@ bool Client::processWithASTFuzzer(std::string_view full_query)
{
/// Print insert data
String bytes;
- auto read_buf = getReadBufferFromASTInsertQuery(ast_to_process);
+ auto read_buf = getReadBufferFromASTInsertQuery(ast_to_process, client_context);
WriteBufferFromString write_buf(bytes);
copyData(*read_buf, write_buf);
fmt::print(stdout, "{}\n", bytes);
@@ -476,7 +476,7 @@ bool Client::processWithASTFuzzer(std::string_view full_query)
{
String bytes;
{
- auto read_buf = getReadBufferFromASTInsertQuery(query);
+ auto read_buf = getReadBufferFromASTInsertQuery(query, client_context);
WriteBufferFromString write_buf(bytes);
copyData(*read_buf, write_buf);
}
diff --git a/programs/format/Format.cpp b/programs/format/Format.cpp
index 62bd0a43a3ff..e1d61418dbe6 100644
--- a/programs/format/Format.cpp
+++ b/programs/format/Format.cpp
@@ -286,7 +286,7 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
const char * this_query_end = find_first_symbols<'\n'>(insert_query->data, end);
insert_query->end = this_query_end;
pos = this_query_end;
- insert_query_payload = getReadBufferFromASTInsertQuery(res);
+ insert_query_payload = getReadBufferFromASTInsertQuery(res, context);
}
if (!quiet)
diff --git a/programs/server/binary.html b/programs/server/binary.html
index 49330aa82b1c..7160582baeb6 100644
--- a/programs/server/binary.html
+++ b/programs/server/binary.html
@@ -267,15 +267,22 @@
`${url}&default_format=JSON`,
{
method: 'POST',
- body: `SELECT encodeXMLComponent(demangle(addressToSymbol(${addr_int}::UInt64))) AS name,
- encodeXMLComponent(addressToLine(${addr_int}::UInt64)) AS line`
+ body: `SELECT demangle(addressToSymbol(${addr_int}::UInt64)) AS name,
+ addressToLine(${addr_int}::UInt64) AS line`
}).then(response => response.json().then(o => {
let name = o.rows ? o.data[0].name : 'nothing';
let line = o.rows ? o.data[0].line : '';
if (addr_int == current_requested_addr) {
- popup.setContent(`${addr_hex}
${name}
${line}
`);
+ /// The response is untrusted (the server can be specified by the `host` parameter),
+ /// so it is inserted as text, never as HTML.
+ const content = document.createElement('div');
+ const addr_elem = content.appendChild(document.createElement('p')).appendChild(document.createElement('b'));
+ addr_elem.textContent = addr_hex;
+ content.appendChild(document.createElement('p')).textContent = name;
+ content.appendChild(document.createElement('p')).textContent = line;
+ popup.setContent(content);
}
}));
diff --git a/programs/server/config.xml b/programs/server/config.xml
index 4aecbf96394d..4d86b1b4eeb5 100644
--- a/programs/server/config.xml
+++ b/programs/server/config.xml
@@ -905,7 +905,7 @@
however you can change this behaviour by setting this to true -->
false
-
false
diff --git a/rust/vendor.sh b/rust/vendor.sh
index ca7ca26457e6..e31032eb560a 100755
--- a/rust/vendor.sh
+++ b/rust/vendor.sh
@@ -37,7 +37,7 @@ cd "$CH_TOP_DIR"/contrib/delta-kernel-rs || exit 1
cargo vendor --no-delete --locked --versioned-dirs --manifest-path Cargo.toml "$CH_TOP_DIR"/contrib/rust_vendor
# chdig
-cd "$CH_TOP_DIR"/contrib/chdig || exit 1
+cd "$CH_TOP_DIR"/contrib/chdig-cmake || exit 1
cargo vendor --no-delete --locked --versioned-dirs --manifest-path Cargo.toml "$CH_TOP_DIR"/contrib/rust_vendor
# wasmtime
diff --git a/rust/workspace/Cargo.lock b/rust/workspace/Cargo.lock
index 7b87c76d377d..2c297f7e81dd 100644
--- a/rust/workspace/Cargo.lock
+++ b/rust/workspace/Cargo.lock
@@ -179,7 +179,7 @@ checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -228,18 +228,18 @@ dependencies = [
[[package]]
name = "bumpalo"
-version = "3.20.3"
+version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
dependencies = [
"allocator-api2",
]
[[package]]
name = "cc"
-version = "1.11.0"
+version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "375989decec1a0fa424442bed520fa12ede43a48475ce8c7417d2c69b32b5f6b"
+checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
dependencies = [
"find-msvc-tools",
"shlex 2.0.1",
@@ -325,7 +325,7 @@ dependencies = [
"proc-macro2",
"pulldown-cmark",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -368,9 +368,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpp_demangle"
-version = "0.4.5"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2bb79cb74d735044c972aae58ed0aaa9a837e85b01106a54c39e42e97f62253"
+checksum = "0667304c32ea56cb4cd6d2d7c0cfe9a2f8041229db8c033af7f8d69492429def"
dependencies = [
"cfg-if",
]
@@ -386,21 +386,21 @@ dependencies = [
[[package]]
name = "cranelift-assembler-x64"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-assembler-x64-meta",
]
[[package]]
name = "cranelift-assembler-x64-meta"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-srcgen",
]
[[package]]
name = "cranelift-bforest"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-entity",
"wasmtime-internal-core",
@@ -408,7 +408,7 @@ dependencies = [
[[package]]
name = "cranelift-bitset"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"serde",
"serde_derive",
@@ -417,7 +417,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"bumpalo",
"cranelift-assembler-x64",
@@ -432,10 +432,13 @@ dependencies = [
"hashbrown 0.17.1",
"libm",
"log",
+ "postcard",
"pulley-interpreter",
"regalloc2",
"rustc-hash",
"serde",
+ "serde_derive",
+ "sha2",
"smallvec",
"target-lexicon",
"wasmtime-internal-core",
@@ -443,7 +446,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-assembler-x64-meta",
"cranelift-codegen-shared",
@@ -454,18 +457,18 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
-version = "0.132.1"
+version = "0.137.1"
[[package]]
name = "cranelift-control"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"arbitrary",
]
[[package]]
name = "cranelift-entity"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-bitset",
"serde",
@@ -475,9 +478,10 @@ dependencies = [
[[package]]
name = "cranelift-frontend"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-codegen",
+ "hashbrown 0.17.1",
"log",
"smallvec",
"target-lexicon",
@@ -485,26 +489,27 @@ dependencies = [
[[package]]
name = "cranelift-isle"
-version = "0.132.1"
+version = "0.137.1"
[[package]]
name = "cranelift-native"
-version = "0.132.1"
+version = "0.137.1"
dependencies = [
"cranelift-codegen",
"libc",
+ "mach2",
"target-lexicon",
]
[[package]]
name = "cranelift-srcgen"
-version = "0.132.1"
+version = "0.137.1"
[[package]]
name = "crc32fast"
-version = "1.5.4"
+version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04"
+checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64"
dependencies = [
"cfg-if",
]
@@ -623,7 +628,7 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -637,7 +642,7 @@ dependencies = [
"indexmap",
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -655,7 +660,7 @@ dependencies = [
"indexmap",
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -703,37 +708,6 @@ dependencies = [
"once_cell",
]
-[[package]]
-name = "defmt"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1"
-dependencies = [
- "bitflags 1.3.2",
- "defmt-macros",
-]
-
-[[package]]
-name = "defmt-macros"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366"
-dependencies = [
- "defmt-parser",
- "proc-macro2",
- "quote",
- "syn 3.0.9",
-]
-
-[[package]]
-name = "defmt-parser"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0"
-dependencies = [
- "thiserror 2.0.21",
-]
-
[[package]]
name = "deranged"
version = "0.5.9"
@@ -875,9 +849,9 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
[[package]]
name = "errno"
-version = "0.3.14"
+version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
dependencies = [
"libc",
"windows-sys",
@@ -907,12 +881,48 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
+[[package]]
+name = "futures"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+]
+
[[package]]
name = "futures-core"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+[[package]]
+name = "futures-io"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
+
[[package]]
name = "futures-task"
version = "0.3.34"
@@ -925,8 +935,12 @@ version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
dependencies = [
+ "futures-channel",
"futures-core",
+ "futures-io",
+ "futures-sink",
"futures-task",
+ "memchr",
"pin-project-lite",
"slab",
]
@@ -1087,17 +1101,16 @@ dependencies = [
[[package]]
name = "itoa"
-version = "1.0.18"
+version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "jiff"
-version = "0.2.39"
+version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ac703058abac89e5c39b0b879dce2b6b14a4ba36600c7e7e3d0c60a6883ef3c"
+checksum = "175dc66334db3b9ab9985bf8b61cfed50dc16d20964bb47f9e479adcae984a7f"
dependencies = [
- "defmt",
"jiff-core",
"jiff-static",
"log",
@@ -1108,19 +1121,18 @@ dependencies = [
[[package]]
name = "jiff-core"
-version = "0.1.2"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aee43309eb53bafb8c36d35d6e444769c8f8e6206a9fbf7546f5db9d7d4a0e93"
+checksum = "e599b80292e597019b8b3e392de3f4bea2959ddfb8c7dff60e035e9e311a2c1b"
dependencies = [
- "defmt",
"log",
]
[[package]]
name = "jiff-static"
-version = "0.2.39"
+version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6dc32470c67eb7d0e9ccb74303fa925313dc04cecb1aa048beaa6f391e36a93d"
+checksum = "c7b1af7547d47354bc438d797e3854601bde8f8d185780c5ba4ab27afa54f1ba"
dependencies = [
"jiff-core",
"proc-macro2",
@@ -1195,12 +1207,9 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
[[package]]
name = "mach2"
-version = "0.4.3"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44"
-dependencies = [
- "libc",
-]
+checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b"
[[package]]
name = "memchr"
@@ -1255,9 +1264,9 @@ dependencies = [
[[package]]
name = "object"
-version = "0.39.1"
+version = "0.40.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"
+checksum = "dd229a0361b9d0d4396176e02d65897f487eebeab7caa6d443855ee152ca0b9c"
dependencies = [
"crc32fast",
"hashbrown 0.17.1",
@@ -1401,7 +1410,7 @@ dependencies = [
[[package]]
name = "pulley-interpreter"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"cranelift-bitset",
"log",
@@ -1411,11 +1420,11 @@ dependencies = [
[[package]]
name = "pulley-macros"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.119",
+ "syn 3.0.10",
]
[[package]]
@@ -1510,7 +1519,7 @@ checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -1524,6 +1533,7 @@ dependencies = [
"hashbrown 0.17.1",
"log",
"rustc-hash",
+ "serde",
"smallvec",
]
@@ -1615,7 +1625,7 @@ dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -1661,7 +1671,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -1672,7 +1682,7 @@ checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -1782,9 +1792,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "smallvec"
-version = "1.16.4"
+version = "1.16.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8"
+checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
dependencies = [
"serde",
]
@@ -1855,9 +1865,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "3.0.9"
+version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
"proc-macro2",
"quote",
@@ -1866,9 +1876,9 @@ dependencies = [
[[package]]
name = "target-lexicon"
-version = "0.13.5"
+version = "0.13.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
+checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
[[package]]
name = "term"
@@ -1936,7 +1946,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
]
[[package]]
@@ -2164,7 +2174,7 @@ dependencies = [
"bumpalo",
"proc-macro2",
"quote",
- "syn 3.0.9",
+ "syn 3.0.10",
"wasm-bindgen-shared",
]
@@ -2179,12 +2189,12 @@ dependencies = [
[[package]]
name = "wasm-encoder"
-version = "0.248.0"
+version = "0.261.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac92cf547bc18d27ecc521015c08c353b4f18b84ab388bb6d1b6b682c620d9b6"
+checksum = "2608e8bb6d67fd68f5a8d0eb1363d6e7bcbc1f8ded5a0bd3a1e382462b876b22"
dependencies = [
"leb128fmt",
- "wasmparser 0.248.0",
+ "wasmparser 0.261.0",
]
[[package]]
@@ -2199,9 +2209,9 @@ dependencies = [
[[package]]
name = "wasmparser"
-version = "0.248.0"
+version = "0.261.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4439c5eee9df71ee0c6efb37f63b1fcb1fec38f85f5142c54e7ed05d33091a"
+checksum = "4f20f20e44f7e8aeb6744823ea9d869ede51e51be4fdaedede2852282e54d2d8"
dependencies = [
"bitflags 2.13.2",
"hashbrown 0.17.1",
@@ -2223,25 +2233,25 @@ dependencies = [
[[package]]
name = "wasmprinter"
-version = "0.248.0"
+version = "0.261.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30b264a5410b008d4d199a92bf536eae703cbd614482fc1ec53831cf19e1c183"
+checksum = "86a21c9e3325655ba02de3e645bc8357a8b3651a2e3ada25b6dbc37560deb9b7"
dependencies = [
"anyhow",
"termcolor",
- "wasmparser 0.248.0",
+ "wasmparser 0.261.0",
]
[[package]]
name = "wasmtime"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"addr2line",
"async-trait",
"bitflags 2.13.2",
"bumpalo",
"cc",
- "cfg-if",
+ "futures",
"gimli",
"libc",
"log",
@@ -2256,8 +2266,8 @@ dependencies = [
"serde_derive",
"smallvec",
"target-lexicon",
- "wasm-encoder 0.248.0",
- "wasmparser 0.248.0",
+ "wasm-encoder 0.261.0",
+ "wasmparser 0.261.0",
"wasmtime-environ",
"wasmtime-internal-core",
"wasmtime-internal-cranelift",
@@ -2266,14 +2276,13 @@ dependencies = [
"wasmtime-internal-jit-icache-coherence",
"wasmtime-internal-unwinder",
"wasmtime-internal-versioned-export-macros",
- "wasmtime-internal-winch",
"wat",
"windows-sys",
]
[[package]]
name = "wasmtime-c-api-impl"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"log",
"tracing",
@@ -2284,7 +2293,7 @@ dependencies = [
[[package]]
name = "wasmtime-environ"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"anyhow",
"cpp_demangle",
@@ -2298,28 +2307,33 @@ dependencies = [
"object",
"postcard",
"rustc-demangle",
+ "semver",
"serde",
"serde_derive",
- "sha2",
"smallvec",
"target-lexicon",
- "wasm-encoder 0.248.0",
- "wasmparser 0.248.0",
+ "wasm-encoder 0.261.0",
+ "wasmparser 0.261.0",
"wasmprinter",
+ "wasmtime-internal-component-util",
"wasmtime-internal-core",
]
[[package]]
name = "wasmtime-internal-c-api-macros"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"proc-macro2",
"quote",
]
+[[package]]
+name = "wasmtime-internal-component-util"
+version = "50.0.1"
+
[[package]]
name = "wasmtime-internal-core"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"hashbrown 0.17.1",
"libm",
@@ -2328,9 +2342,8 @@ dependencies = [
[[package]]
name = "wasmtime-internal-cranelift"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
- "cfg-if",
"cranelift-codegen",
"cranelift-control",
"cranelift-entity",
@@ -2344,7 +2357,7 @@ dependencies = [
"smallvec",
"target-lexicon",
"thiserror 2.0.21",
- "wasmparser 0.248.0",
+ "wasmparser 0.261.0",
"wasmtime-environ",
"wasmtime-internal-core",
"wasmtime-internal-unwinder",
@@ -2353,10 +2366,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-fiber"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"cc",
- "cfg-if",
"libc",
"rustix",
"wasmtime-environ",
@@ -2366,7 +2378,7 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-debug"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"cc",
"wasmtime-internal-versioned-export-macros",
@@ -2374,9 +2386,8 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-icache-coherence"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
- "cfg-if",
"libc",
"wasmtime-internal-core",
"windows-sys",
@@ -2384,9 +2395,8 @@ dependencies = [
[[package]]
name = "wasmtime-internal-unwinder"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
- "cfg-if",
"cranelift-codegen",
"log",
"object",
@@ -2395,26 +2405,11 @@ dependencies = [
[[package]]
name = "wasmtime-internal-versioned-export-macros"
-version = "45.0.1"
+version = "50.0.1"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.119",
-]
-
-[[package]]
-name = "wasmtime-internal-winch"
-version = "45.0.1"
-dependencies = [
- "cranelift-codegen",
- "gimli",
- "log",
- "object",
- "target-lexicon",
- "wasmparser 0.248.0",
- "wasmtime-environ",
- "wasmtime-internal-cranelift",
- "winch-codegen",
+ "syn 3.0.10",
]
[[package]]
@@ -2482,23 +2477,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-[[package]]
-name = "winch-codegen"
-version = "45.0.1"
-dependencies = [
- "cranelift-assembler-x64",
- "cranelift-codegen",
- "gimli",
- "regalloc2",
- "smallvec",
- "target-lexicon",
- "thiserror 2.0.21",
- "wasmparser 0.248.0",
- "wasmtime-environ",
- "wasmtime-internal-core",
- "wasmtime-internal-cranelift",
-]
-
[[package]]
name = "windows-core"
version = "0.62.2"
diff --git a/src/Access/AccessBackup.cpp b/src/Access/AccessBackup.cpp
index 8f81ddd0bc20..2af79fb0d493 100644
--- a/src/Access/AccessBackup.cpp
+++ b/src/Access/AccessBackup.cpp
@@ -264,6 +264,22 @@ AccessRestorerFromBackup::AccessRestorerFromBackup(
{
}
+AccessRestorerFromBackup::AccessRestorerFromBackup(
+ const AccessRestorerFromBackup & src, RestoreAccessCreationMode creation_mode_, bool skip_unresolved_dependencies_)
+ : backup(src.backup)
+ , creation_mode(creation_mode_)
+ , skip_unresolved_dependencies(skip_unresolved_dependencies_)
+ , update_dependents(src.update_dependents)
+ , restore_with_current_grants(src.restore_with_current_grants)
+ , log(src.log)
+ , loaded(src.loaded)
+ , ids_assigned(src.ids_assigned)
+ , data_paths_in_backup(src.data_paths_in_backup)
+ , data_path_with_entities_to_restore(src.data_path_with_entities_to_restore)
+ , entity_infos(src.entity_infos)
+{
+}
+
AccessRestorerFromBackup::~AccessRestorerFromBackup() = default;
@@ -470,6 +486,7 @@ void AccessRestorerFromBackup::generateRandomIDsAndResolveDependencies(const Acc
bool was_going_to_restore = entity_info.restore;
entity_info.new_id = *existing_id;
entity_info.restore = false;
+ entity_info.exists = was_going_to_restore;
LOG_TRACE(log, "{}: Found with UUID {}{}", AccessEntityTypeInfo::get(type).formatEntityNameWithType(name), *existing_id,
(was_going_to_restore ? ", will not restore" : ""));
}
@@ -521,7 +538,7 @@ void AccessRestorerFromBackup::generateRandomIDsAndResolveDependencies(const Acc
/// Remap the UUIDs of dependencies in the access entities we're going to restore.
for (auto & [id, entity_info] : entity_infos)
{
- if (entity_info.restore || entity_info.is_dependent)
+ if (entity_info.restore || entity_info.is_dependent || entity_info.exists)
{
auto new_entity = entity_info.entity->clone();
new_entity->replaceDependencies(old_to_new_ids);
@@ -562,6 +579,31 @@ AccessEntitiesToRestore AccessRestorerFromBackup::getEntitiesToRestore(const Str
}
+std::vector> AccessRestorerFromBackup::getEntitiesFromBackup() const
+{
+ if (!ids_assigned)
+ throw Exception(ErrorCodes::LOGICAL_ERROR, "IDs not assigned");
+
+ std::vector> res;
+ for (const auto & [id, entity_info] : entity_infos)
+ {
+ if (entity_info.restore || entity_info.exists)
+ res.emplace_back(*entity_info.new_id, entity_info.entity);
+ }
+ return res;
+}
+
+
+AccessRestorerFromBackup AccessRestorerFromBackup::makeCopyForChecking() const
+{
+ if (!loaded || ids_assigned)
+ throw Exception(ErrorCodes::LOGICAL_ERROR, "Access entities must be loaded and not resolved to make a copy for checking");
+
+ auto mode = (creation_mode == RestoreAccessCreationMode::kCreate) ? RestoreAccessCreationMode::kCreateIfNotExists : creation_mode;
+ return AccessRestorerFromBackup(*this, mode, /* skip_unresolved_dependencies_= */ true);
+}
+
+
void restoreAccessEntitiesFromBackup(
IAccessStorage & destination_access_storage,
const AccessEntitiesToRestore & entities_to_restore,
diff --git a/src/Access/AccessBackup.h b/src/Access/AccessBackup.h
index da0f3088a033..e4724c881be5 100644
--- a/src/Access/AccessBackup.h
+++ b/src/Access/AccessBackup.h
@@ -81,7 +81,17 @@ class AccessRestorerFromBackup
/// Both functions loadFromBackup() and generateRandomIDsAndResolveDependencies() must be called before that.
AccessEntitiesToRestore getEntitiesToRestore(const String & data_path_in_backup) const;
+ /// Returns every access entity selected from the backup, including the ones not restored because they exist,
+ /// with dependencies resolved. generateRandomIDsAndResolveDependencies() must be called before that.
+ [[nodiscard]] std::vector> getEntitiesFromBackup() const;
+
+ /// Returns a copy which resolves without throwing on existing or missing entities. Call after loadFromBackup(), before resolving.
+ [[nodiscard]] AccessRestorerFromBackup makeCopyForChecking() const;
+
private:
+ AccessRestorerFromBackup(
+ const AccessRestorerFromBackup & src, RestoreAccessCreationMode creation_mode_, bool skip_unresolved_dependencies_);
+
const BackupPtr backup;
const RestoreAccessCreationMode creation_mode;
const bool skip_unresolved_dependencies;
@@ -128,6 +138,10 @@ class AccessRestorerFromBackup
/// This flags is set by generateRandomIDsAndResolveDependencies().
bool is_dependent = false;
+ /// Whether this entity was loaded to be restored but is not restored because it exists already.
+ /// This flag is set by generateRandomIDsAndResolveDependencies().
+ bool exists = false;
+
/// New UUID for this entity - either randomly generated or copied from an existing entity.
/// This UUID is assigned by generateRandomIDsAndResolveDependencies().
std::optional new_id = std::nullopt;
diff --git a/src/Access/AccessRights.cpp b/src/Access/AccessRights.cpp
index b664efc88321..472ea47bdb89 100644
--- a/src/Access/AccessRights.cpp
+++ b/src/Access/AccessRights.cpp
@@ -38,6 +38,10 @@ namespace
if (left.full_name.size() != right.full_name.size())
return left.full_name.size() < right.full_name.size();
+ /// Wildcards before exact names: `db*` covers `db`, so its element must be applied first.
+ if (left.wildcard != right.wildcard)
+ return left.wildcard;
+
/// Grants before partial revokes.
if (left.is_partial_revoke != right.is_partial_revoke)
return right.is_partial_revoke; /// if left is grant, right is partial revoke, we assume left < right
@@ -976,7 +980,9 @@ struct AccessRights::Node
auto grants = flags - parent_fl - grants_go;
/// Inserts into result only meaningful nodes (e.g. wildcards or leafs).
- if (target_node && (target_node->isLeaf() || target_node->wildcard_grant))
+ const bool node_meaningful = node && (node->isLeaf() || node->wildcard_grant);
+ const bool node_go_meaningful = node_go && (node_go->isLeaf() || node_go->wildcard_grant);
+ if (node_meaningful || node_go_meaningful)
{
boost::container::small_vector new_full_name = full_name;
@@ -992,19 +998,27 @@ struct AccessRights::Node
}
}
- if (node && revokes)
+ if (node_meaningful && revokes)
res.push_back(ProtoElement{revokes, new_full_name, false, true, node->wildcard_grant});
- if (node_go && revokes_go)
+ if (node_go_meaningful && revokes_go)
res.push_back(ProtoElement{revokes_go, new_full_name, true, true, node_go->wildcard_grant});
- if (node && grants)
+ if (node_meaningful && grants)
res.push_back(ProtoElement{grants, new_full_name, false, false, node->wildcard_grant});
- if (node_go && grants_go)
+ if (node_go_meaningful && grants_go)
res.push_back(ProtoElement{grants_go, new_full_name, true, false, node_go->wildcard_grant});
}
+ /// The two tries compress child names independently: a child of one can be a strict name
+ /// prefix of a child of the other, and only exactly-named pairs can be walked together.
+ if (node && node_go && node_go->children)
+ {
+ for (auto & child_go : *node_go->children)
+ node->getLeaf(child_go.node_name, child_go.level, !child_go.isLeaf());
+ }
+
if (node && node->children)
{
for (auto & child : *node->children)
@@ -1024,19 +1038,8 @@ struct AccessRights::Node
{
for (auto & child : *node_go->children)
{
- if (node && node->children)
- {
- auto starts_with = [&child](const Node & n)
- {
- if (child.isLeaf())
- return n.isLeaf();
-
- return !n.isLeaf() && child.node_name[0] == n.node_name[0];
- };
-
- if (auto it = std::find_if(node->children->begin(), node->children->end(), starts_with); it != node->children->end())
- continue; /// already processed
- }
+ if (node && node->tryGetChildNode(child.node_name))
+ continue; /// already processed
String new_path = path;
new_path.append(child.node_name);
@@ -1564,7 +1567,11 @@ AccessRights AccessRights::getGrantableRights() const
continue;
if (element.is_partial_revoke)
+ {
+ /// A right with a revoked grant option is not grantable, so remove the right itself.
+ element.grant_option = false;
result.revoke(element);
+ }
else
result.grant(element);
}
diff --git a/src/Access/Common/AccessType.h b/src/Access/Common/AccessType.h
index 60d9b69c74d2..aa87fb56ed59 100644
--- a/src/Access/Common/AccessType.h
+++ b/src/Access/Common/AccessType.h
@@ -229,7 +229,7 @@ enum class AccessType : uint16_t
\
M(ALTER_DATABASE_SETTINGS, "ALTER DATABASE SETTING, ALTER MODIFY DATABASE SETTING, MODIFY DATABASE SETTING", DATABASE, ALTER_DATABASE) /* allows to execute ALTER MODIFY SETTING */\
M(ALTER_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute ALTER NAMED COLLECTION */\
- M(ALTER_HANDLER, "", GLOBAL, ALTER) /* allows to execute ALTER HANDLER */\
+ M(ALTER_HANDLER, "", GLOBAL, HANDLER_ADMIN) /* allows to execute ALTER HANDLER */\
\
M(ALTER_TABLE, "", GROUP, ALTER) \
M(ALTER_DATABASE, "", GROUP, ALTER) \
@@ -257,7 +257,7 @@ enum class AccessType : uint16_t
M(CREATE_WORKLOAD, "", GLOBAL, CREATE) /* allows to execute CREATE WORKLOAD */ \
M(CREATE_RESOURCE, "", GLOBAL, CREATE) /* allows to execute CREATE RESOURCE */ \
M(CREATE_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute CREATE NAMED COLLECTION */ \
- M(CREATE_HANDLER, "", GLOBAL, CREATE) /* allows to execute CREATE HANDLER */ \
+ M(CREATE_HANDLER, "", GLOBAL, HANDLER_ADMIN) /* allows to execute CREATE HANDLER */ \
M(CREATE, "", GROUP, ALL) /* allows to execute {CREATE|ATTACH} */ \
\
M(DROP_DATABASE, "", DATABASE, DROP) /* allows to execute {DROP|DETACH|TRUNCATE} DATABASE */\
@@ -269,7 +269,7 @@ enum class AccessType : uint16_t
M(DROP_WORKLOAD, "", GLOBAL, DROP) /* allows to execute DROP WORKLOAD */\
M(DROP_RESOURCE, "", GLOBAL, DROP) /* allows to execute DROP RESOURCE */\
M(DROP_NAMED_COLLECTION, "", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) /* allows to execute DROP NAMED COLLECTION */\
- M(DROP_HANDLER, "", GLOBAL, DROP) /* allows to execute DROP HANDLER */\
+ M(DROP_HANDLER, "", GLOBAL, HANDLER_ADMIN) /* allows to execute DROP HANDLER */\
M(DROP, "", GROUP, ALL) /* allows to execute {DROP|DETACH} */\
\
M(UNDROP_TABLE, "", TABLE, ALL) /* allows to execute {UNDROP} TABLE */\
@@ -318,7 +318,8 @@ enum class AccessType : uint16_t
M(SHOW_NAMED_COLLECTIONS_SECRETS, "SHOW NAMED COLLECTIONS SECRETS", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) \
M(NAMED_COLLECTION, "NAMED COLLECTION USAGE, USE NAMED COLLECTION", NAMED_COLLECTION, NAMED_COLLECTION_ADMIN) \
M(NAMED_COLLECTION_ADMIN, "NAMED COLLECTION CONTROL", NAMED_COLLECTION, ALL) \
- M(SHOW_HANDLERS, "SHOW HANDLER", GLOBAL, ALL) /* allows to see SQL-defined HTTP handlers in system.handlers */\
+ M(SHOW_HANDLERS, "SHOW HANDLER", GLOBAL, HANDLER_ADMIN) /* allows to see SQL-defined HTTP handlers in system.handlers */\
+ M(HANDLER_ADMIN, "", GROUP, ALL) /* allows to create, alter, drop and see SQL-defined HTTP handlers */\
M(SET_DEFINER, "", DEFINER, ALL) \
\
M(TABLE_ENGINE, "TABLE ENGINE", TABLE_ENGINE, ALL) \
diff --git a/src/Access/ContextAccess.cpp b/src/Access/ContextAccess.cpp
index adb60e147045..18a4589665df 100644
--- a/src/Access/ContextAccess.cpp
+++ b/src/Access/ContextAccess.cpp
@@ -18,9 +18,7 @@
#include
#include
#include
-#include
#include
-#include
#include
#include
#include
@@ -43,23 +41,6 @@ namespace ErrorCodes
namespace
{
- String normalizeAccessURI(std::string_view uri)
- {
- if (uri.empty())
- return {};
-
- try
- {
- Poco::URI parsed{String{uri}};
- parsed.normalize();
- return parsed.toString();
- }
- catch (const Poco::Exception &)
- {
- return {};
- }
- }
-
AccessRights mixAccessRightsFromUserAndRoles(const User & user, const EnabledRolesInfo & roles_info)
{
AccessRights res = user.access;
@@ -1202,9 +1183,12 @@ bool ContextAccess::isGrantedWithFilter(const ContextPtr & context, const Access
if (isGranted(context, flags, parameter))
return true;
+ /// Callers pass the exact location to match: a URI is normalized (or deliberately left as written,
+ /// e.g. an Azure blob name, which is not a URI) at the call site, see `ITableFunction::checkSourceAccessForURI`.
+ /// Re-parsing it as a URI here would decode `%2F` and lowercase a scheme-like prefix of a blob name.
const String normalized_filter_target = parameter == AccessTypeObjects::toStringSource(AccessTypeObjects::Source::FILE)
? std::filesystem::path{String{to_check_by_filter}}.lexically_normal().string()
- : normalizeAccessURI(to_check_by_filter);
+ : String{to_check_by_filter};
if (!normalized_filter_target.empty())
{
auto access_rights = getAccessRights();
diff --git a/src/Access/ContextAccess.h b/src/Access/ContextAccess.h
index a6c66a3dbf50..4c9f2cbe820e 100644
--- a/src/Access/ContextAccess.h
+++ b/src/Access/ContextAccess.h
@@ -133,7 +133,7 @@ class ContextAccess : public std::enable_shared_from_this
void checkGranteesAreAllowed(const std::vector & grantee_ids) const;
/// Checks access of grants with parameter where a filter can be applied.
- /// The URI checked against the filter is normalized first; an invalid URI cannot match a filter.
+ /// The caller passes the location to match already in its canonical form (a local path is normalized here).
/// For example, for `GRANT READ ON S3('s3://foo.*') TO user` calling `checkAccess(READ, "S3")` will throw an error
/// because we are checking for `READ` permissions for all possible URLs.
///
@@ -342,7 +342,7 @@ class ContextAccessWrapper : public std::enable_shared_from_this & grantee_ids) const { access->checkGranteesAreAllowed(grantee_ids); }
/// Checks access of grants with parameter where a filter can be applied.
- /// The URI checked against the filter is normalized first; an invalid URI cannot match a filter.
+ /// The caller passes the location to match already in its canonical form (a local path is normalized here).
ALWAYS_INLINE void checkAccessWithFilter(const AccessFlags & flags, std::string_view parameter, std::string_view filter) const { access->checkAccessWithFilter(context, flags, parameter, filter); }
/// Checks access of grants with parameter where a filter can be applied, without throwing.
diff --git a/src/Access/LDAPAccessStorage.cpp b/src/Access/LDAPAccessStorage.cpp
index e464d5818b55..6f75afac42d3 100644
--- a/src/Access/LDAPAccessStorage.cpp
+++ b/src/Access/LDAPAccessStorage.cpp
@@ -401,37 +401,36 @@ String LDAPAccessStorage::getStorageParamsJSON() const
}
+/// The read-only methods below don't lock `mutex`: `memory_storage` is synchronized by itself,
+/// and `mutex` is held by `authenticateImpl` during the network communication with the LDAP server.
+/// Waiting for it here would make lookups (e.g. the check for a name collision in `MultipleAccessStorage`)
+/// wait for unrelated LDAP authentications.
std::optional LDAPAccessStorage::findImpl(AccessEntityType type, const String & name) const
{
- std::lock_guard lock(mutex);
return memory_storage.find(type, name);
}
std::vector LDAPAccessStorage::findAllImpl(AccessEntityType type) const
{
- std::lock_guard lock(mutex);
return memory_storage.findAll(type);
}
bool LDAPAccessStorage::exists(const UUID & id) const
{
- std::lock_guard lock(mutex);
return memory_storage.exists(id);
}
AccessEntityPtr LDAPAccessStorage::readImpl(const UUID & id, bool throw_if_not_exists) const
{
- std::lock_guard lock(mutex);
return memory_storage.read(id, throw_if_not_exists);
}
std::optional> LDAPAccessStorage::readNameWithTypeImpl(const UUID & id, bool throw_if_not_exists) const
{
- std::lock_guard lock(mutex);
return memory_storage.readNameWithType(id, throw_if_not_exists);
}
diff --git a/src/Access/MultipleAccessStorage.cpp b/src/Access/MultipleAccessStorage.cpp
index c7247900b1c2..40158681c287 100644
--- a/src/Access/MultipleAccessStorage.cpp
+++ b/src/Access/MultipleAccessStorage.cpp
@@ -17,6 +17,7 @@ namespace ErrorCodes
extern const int ACCESS_ENTITY_ALREADY_EXISTS;
extern const int ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND;
extern const int ACCESS_ENTITY_NOT_FOUND;
+ extern const int AUTHENTICATION_FAILED;
}
using Storage = IAccessStorage;
@@ -256,6 +257,24 @@ void MultipleAccessStorage::moveAccessEntities(const std::vector & ids, co
auto destination_storage = getStorageByName(destination_storage_name);
auto to_move = source_storage->read(ids);
+
+ /// The same name must not refer to entities in different storages, so a move is refused if any storage
+ /// other than the source one already holds the name (e.g. a user of the config with the same name).
+ /// This is checked before anything is removed from the source storage.
+ auto storages = getStoragesInternal();
+ for (const auto & entity : to_move)
+ {
+ for (const auto & other_storage : *storages)
+ {
+ if (other_storage == source_storage)
+ continue;
+ if (other_storage->find(entity->getType(), entity->getName()))
+ throw Exception(ErrorCodes::ACCESS_ENTITY_ALREADY_EXISTS, "{}: cannot move to {} because {} already exists in {}",
+ entity->formatTypeWithName(), backQuote(destination_storage_name), entity->formatTypeWithName(),
+ backQuote(other_storage->getStorageName()));
+ }
+ }
+
bool need_rollback = false;
try
@@ -397,6 +416,22 @@ bool MultipleAccessStorage::insertImpl(const UUID & id, const AccessEntityPtr &
getStorageName());
}
+ /// The same name must not refer to entities in different storages.
+ /// A replacement replaces only an entity of the destination storage, so it is refused too if another storage holds the name.
+ for (const auto & other_storage : *storages)
+ {
+ if (other_storage == storage_for_insertion)
+ continue;
+ if (auto existing_id = other_storage->find(entity->getType(), entity->getName()))
+ {
+ if (conflicting_id)
+ *conflicting_id = *existing_id;
+ if (throw_if_exists || replace_if_exists)
+ throwNameCollisionCannotInsert(entity->getType(), entity->getName(), other_storage->getStorageName());
+ return false;
+ }
+ }
+
if (storage_for_insertion->insert(id, entity, replace_if_exists, throw_if_exists, conflicting_id))
{
std::lock_guard lock{mutex};
@@ -431,9 +466,10 @@ bool MultipleAccessStorage::updateImpl(const UUID & id, const UpdateFunc & updat
return false;
}
- /// If the updating involves renaming check that the renamed entity will be accessible by name.
+ /// If the updating involves renaming check that the new name is not used in another storage:
+ /// the same name must not refer to entities in different storages.
auto storages = getStoragesInternal();
- if ((storages->size() > 1) && (storages->front() != storage_for_updating))
+ if (storages->size() > 1)
{
if (auto old_entity = storage_for_updating->tryRead(id))
{
@@ -443,7 +479,7 @@ bool MultipleAccessStorage::updateImpl(const UUID & id, const UpdateFunc & updat
for (const auto & storage : *storages)
{
if (storage == storage_for_updating)
- break;
+ continue;
if (storage->find(new_entity->getType(), new_entity->getName()))
{
throw Exception(ErrorCodes::ACCESS_ENTITY_ALREADY_EXISTS, "{}: cannot rename to {} because {} already exists in {}",
@@ -466,15 +502,62 @@ MultipleAccessStorage::authenticateImpl(const Credentials & credentials, const P
bool allow_no_password, bool allow_plaintext_password) const
{
auto storages = getStoragesInternal();
- for (size_t i = 0; i != storages->size(); ++i)
+
+ /// Users from different user directories are distinct entities, but some code identifies users by name,
+ /// so the same name must not refer to more than one user.
+ auto throw_name_collision = [&](const String & user_name, const StoragePtr & storage, const StoragePtr & other_storage) -> void
+ {
+ throw Exception(ErrorCodes::AUTHENTICATION_FAILED,
+ "User {} exists in {}, but a user with the same name also exists in {}",
+ backQuote(user_name), storage->getStorageName(), other_storage->getStorageName());
+ };
+
+ /// If a user with this name already exists, only its storage may authenticate it. Otherwise an external directory
+ /// (e.g. LDAP) could introduce a second user with the same name on login, in particular with `AlwaysAllowCredentials`,
+ /// which LDAP accepts without contacting the LDAP server.
+ ///
+ /// The same name with the same ID in several storages is one identity, not a collision: external directories
+ /// which derive both the name and the ID of a user from the verified identity (e.g. several token-based directories,
+ /// one per signing key or identity provider) each keep their own copy of the same user, and any of them may authenticate it.
+ std::vector existing_user_storages;
+ if (storages->size() > 1 && credentials.isReady())
+ {
+ std::optional existing_user_id;
+ for (const auto & storage : *storages)
+ {
+ auto user_id = storage->find(AccessEntityType::USER, credentials.getUserName());
+ if (!user_id)
+ continue;
+ if (existing_user_id && *existing_user_id != *user_id)
+ throw_name_collision(credentials.getUserName(), existing_user_storages.front(), storage);
+ existing_user_id = user_id;
+ existing_user_storages.push_back(storage);
+ }
+ }
+
+ /// The storages which may authenticate these credentials.
+ std::vector candidate_storages = existing_user_storages.empty() ? *storages : existing_user_storages;
+
+ for (size_t i = 0; i != candidate_storages.size(); ++i)
{
- const auto & storage = (*storages)[i];
- bool is_last_storage = (i == storages->size() - 1);
+ const auto & storage = candidate_storages[i];
+ bool is_last_storage = (i == candidate_storages.size() - 1);
auto auth_result = storage->authenticate(credentials, address, external_authenticators, client_info,
(throw_if_user_not_exists && is_last_storage),
allow_no_password, allow_plaintext_password);
if (auth_result)
{
+ /// Check again: a user with the same name could have appeared in another storage concurrently,
+ /// or the storage could have just introduced the user.
+ for (const auto & other_storage : *storages)
+ {
+ if (other_storage == storage)
+ continue;
+ auto other_user_id = other_storage->find(AccessEntityType::USER, auth_result->user_name);
+ if (other_user_id && *other_user_id != auth_result->user_id)
+ throw_name_collision(auth_result->user_name, storage, other_storage);
+ }
+
std::lock_guard lock{mutex};
ids_cache.set(auth_result->user_id, storage);
return auth_result;
diff --git a/src/Access/tests/gtest_access_rights_ops.cpp b/src/Access/tests/gtest_access_rights_ops.cpp
index ec4b2993ea5a..eed332d02a98 100644
--- a/src/Access/tests/gtest_access_rights_ops.cpp
+++ b/src/Access/tests/gtest_access_rights_ops.cpp
@@ -96,13 +96,13 @@ TEST(AccessRights, GrantWildcard)
root.grantWildcard(AccessType::INSERT, "default", "t");
ASSERT_EQ(root.isGranted(AccessType::SELECT, "default", "t"), true);
ASSERT_EQ(root.isGranted(AccessType::INSERT, "default", "t"), true);
- ASSERT_EQ(root.toString(), "GRANT SELECT ON default.t, GRANT INSERT ON default.t*");
+ ASSERT_EQ(root.toString(), "GRANT INSERT ON default.t*, GRANT SELECT ON default.t");
root.revoke(AccessType::INSERT, "default", "t");
ASSERT_EQ(root.isGranted(AccessType::SELECT, "default", "t"), true);
ASSERT_EQ(root.isGranted(AccessType::INSERT, "default", "t"), false);
ASSERT_EQ(root.isGranted(AccessType::INSERT, "default", "test"), true);
- ASSERT_EQ(root.toString(), "GRANT SELECT ON default.t, GRANT INSERT ON default.t*, REVOKE INSERT ON default.t");
+ ASSERT_EQ(root.toString(), "GRANT INSERT ON default.t*, GRANT SELECT ON default.t, REVOKE INSERT ON default.t");
root = {};
root.grant(AccessType::SELECT, "default", "t");
@@ -235,6 +235,51 @@ TEST(AccessRights, GrantWildcard)
ASSERT_EQ(root.toString(), "GRANT SELECT ON db*.* WITH GRANT OPTION, GRANT INSERT ON db.`table`");
}
+TEST(AccessRights, WildcardBeforeExactNameInElements)
+{
+ /// The elements are applied in the order of `getElements`, so `REVOKE ... ON dbx*.*` must precede `GRANT ... ON dbx.*`.
+ AccessRights root;
+ root.grantWildcard(AccessType::SELECT, "db");
+ root.revokeWildcard(AccessType::SELECT, "dbx");
+ root.grant(AccessType::SELECT, "dbx");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON db*.*, REVOKE SELECT ON dbx*.*, GRANT SELECT ON dbx.*");
+ AccessRights restored{root.getElements()};
+ ASSERT_TRUE(restored.isGranted(AccessType::SELECT, "dbx"));
+ ASSERT_FALSE(restored.isGranted(AccessType::SELECT, "dbx1"));
+ ASSERT_EQ(restored, root);
+
+ root = {};
+ root.grant(AccessType::SELECT, "db");
+ root.revokeWildcard(AccessType::SELECT, "db", "t");
+ root.grant(AccessType::SELECT, "db", "t");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON db.*, REVOKE SELECT ON db.t*, GRANT SELECT ON db.t");
+ restored = AccessRights{root.getElements()};
+ ASSERT_TRUE(restored.isGranted(AccessType::SELECT, "db", "t"));
+ ASSERT_FALSE(restored.isGranted(AccessType::SELECT, "db", "t1"));
+ ASSERT_EQ(restored, root);
+
+ root = {};
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revokeWildcardGrantOption(AccessType::SELECT, "db");
+ root.grantWithGrantOption(AccessType::SELECT, "db");
+ ASSERT_EQ(root.toString(),
+ "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE GRANT OPTION SELECT ON db*.*, GRANT SELECT ON db.* WITH GRANT OPTION");
+ restored = AccessRights{root.getElements()};
+ ASSERT_TRUE(restored.hasGrantOption(AccessType::SELECT, "db"));
+ ASSERT_FALSE(restored.hasGrantOption(AccessType::SELECT, "db1"));
+ ASSERT_EQ(restored, root);
+
+ /// The same after a union, like the rights of two roles.
+ AccessRights lhs;
+ AccessRights rhs;
+ lhs.grant(AccessType::SELECT);
+ lhs.revokeWildcard(AccessType::SELECT, "db");
+ rhs.grant(AccessType::SELECT, "db");
+ lhs.makeUnion(rhs);
+ ASSERT_EQ(lhs.toString(), "GRANT SELECT ON *.*, REVOKE SELECT ON db*.*, GRANT SELECT ON db.*");
+ ASSERT_TRUE(AccessRights{lhs.getElements()}.isGranted(AccessType::SELECT, "db"));
+}
+
TEST(AccessRights, Union)
{
AccessRights lhs;
@@ -638,6 +683,55 @@ TEST(AccessRights, ParialRevokeWithGrantOption)
ASSERT_TRUE(root.isGranted(AccessType::SELECT, "default", "zoo"));
}
+TEST(AccessRights, PartialRevokeGrantOptionWithSharedPrefix)
+{
+ /// Each arm pairs a grant-option-only revoke whose name shares a prefix with a plain revoke
+ /// (the shape that used to be dropped) with a control name that shares nothing.
+
+ /// Database level.
+ AccessRights root;
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revoke(AccessType::SELECT, "db1");
+ root.revokeGrantOption(AccessType::SELECT, "db2");
+ root.revokeGrantOption(AccessType::SELECT, "zdb2");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE SELECT ON db1.*, "
+ "REVOKE GRANT OPTION SELECT ON db2.*, REVOKE GRANT OPTION SELECT ON zdb2.*");
+
+ /// Database level, grant-option name is a strict prefix of the plain one.
+ root = {};
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revoke(AccessType::SELECT, "dbx");
+ root.revokeGrantOption(AccessType::SELECT, "db");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE GRANT OPTION SELECT ON db.*, "
+ "REVOKE SELECT ON dbx.*");
+
+ /// Table level.
+ root = {};
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revoke(AccessType::SELECT, "d", "t1");
+ root.revokeGrantOption(AccessType::SELECT, "d", "t2");
+ root.revokeGrantOption(AccessType::SELECT, "d", "zt2");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE SELECT ON d.t1, "
+ "REVOKE GRANT OPTION SELECT ON d.t2, REVOKE GRANT OPTION SELECT ON d.zt2");
+
+ /// Column level.
+ root = {};
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revoke(AccessType::SELECT, "d", "t", "c1");
+ root.revokeGrantOption(AccessType::SELECT, "d", "t", "c2");
+ root.revokeGrantOption(AccessType::SELECT, "d", "t", "zc2");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE SELECT(c1) ON d.t, "
+ "REVOKE GRANT OPTION SELECT(c2, zc2) ON d.t");
+
+ /// Wildcard grant-option revoke whose name is a strict prefix of the plain one.
+ root = {};
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revoke(AccessType::SELECT, "dbx1");
+ root.revokeWildcardGrantOption(AccessType::SELECT, "db");
+ ASSERT_EQ(root.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE GRANT OPTION SELECT ON db*.*, "
+ "REVOKE SELECT ON dbx1.*");
+}
+
TEST(AccessRights, WildcardGrantEdgeCases)
{
AccessRights root;
@@ -751,6 +845,46 @@ TEST(AccessRights, PartialRevokeWithWildcard)
ASSERT_EQ(root.toString(), "GRANT SELECT ON *.*, REVOKE SELECT ON internal*.*, GRANT SELECT ON internal_public.*");
}
+TEST(AccessRights, GrantableRightsWithoutRevokedGrantOption)
+{
+ /// `getGrantableRights` is what GRANT CURRENT GRANTS and RESTORE may hand out.
+ AccessRights root;
+ root.grantWithGrantOption(AccessType::SELECT);
+ root.revokeGrantOption(AccessType::SELECT, "db", "secret");
+ ASSERT_TRUE(root.isGranted(AccessType::SELECT, "db", "secret"));
+ ASSERT_FALSE(root.hasGrantOption(AccessType::SELECT, "db", "secret"));
+
+ AccessRights grantable = root.getGrantableRights();
+ ASSERT_FALSE(grantable.isGranted(AccessType::SELECT, "db", "secret"));
+ ASSERT_FALSE(grantable.hasGrantOption(AccessType::SELECT, "db", "secret"));
+ ASSERT_TRUE(grantable.hasGrantOption(AccessType::SELECT, "db", "other"));
+ ASSERT_EQ(grantable.toString(), "GRANT SELECT ON *.* WITH GRANT OPTION, REVOKE SELECT ON db.secret");
+
+ /// GRANT CURRENT GRANTS(SELECT ON *.*)
+ AccessRights rights;
+ rights.grant(AccessType::SELECT);
+ rights.makeIntersection(grantable);
+ ASSERT_FALSE(rights.isGranted(AccessType::SELECT, "db", "secret"));
+ ASSERT_TRUE(rights.isGranted(AccessType::SELECT, "db", "other"));
+
+ root = {};
+ root.grantWildcardWithGrantOption(AccessType::SELECT, "db");
+ root.revokeWildcardGrantOption(AccessType::SELECT, "dbx");
+ grantable = root.getGrantableRights();
+ ASSERT_FALSE(grantable.isGranted(AccessType::SELECT, "dbx1"));
+ ASSERT_TRUE(grantable.hasGrantOption(AccessType::SELECT, "db1"));
+
+ /// A right granted again without the grant option is not grantable either.
+ root = {};
+ root.grantWithGrantOption(AccessType::INSERT);
+ root.revoke(AccessType::INSERT, "db", "t");
+ root.grant(AccessType::INSERT, "db");
+ grantable = root.getGrantableRights();
+ ASSERT_TRUE(root.isGranted(AccessType::INSERT, "db", "t"));
+ ASSERT_FALSE(grantable.isGranted(AccessType::INSERT, "db", "t"));
+ ASSERT_TRUE(grantable.hasGrantOption(AccessType::INSERT, "db", "other"));
+}
+
TEST(AccessRights, WildcardGrantOptionInteractions)
{
AccessRights root;
diff --git a/src/AggregateFunctions/AggregateFunctionGroupFormat.cpp b/src/AggregateFunctions/AggregateFunctionGroupFormat.cpp
index 8cfc7d9ad6ab..6350d8afdf7d 100644
--- a/src/AggregateFunctions/AggregateFunctionGroupFormat.cpp
+++ b/src/AggregateFunctions/AggregateFunctionGroupFormat.cpp
@@ -96,11 +96,12 @@ class AggregateFunctionGroupFormat final : public IAggregateFunctionDataHelpercreateColumn());
+ columns.emplace_back(type->createColumn());
+ new (place) GroupFormatData{std::move(columns)};
}
void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena *) const override
diff --git a/src/AggregateFunctions/Combinators/AggregateFunctionCombinatorsArgMinArgMax.cpp b/src/AggregateFunctions/Combinators/AggregateFunctionCombinatorsArgMinArgMax.cpp
index f73eed07a9ab..2008623631da 100644
--- a/src/AggregateFunctions/Combinators/AggregateFunctionCombinatorsArgMinArgMax.cpp
+++ b/src/AggregateFunctions/Combinators/AggregateFunctionCombinatorsArgMinArgMax.cpp
@@ -33,6 +33,10 @@ struct AggregateFunctionCombinatorArgMinArgMaxData
SingleValueDataBase & data() { return v_data.get(); }
const SingleValueDataBase & data() const { return v_data.get(); }
+
+ /// False after the nested state is destroyed until it is created again, so a throwing nested `create` does not lead
+ /// to a second nested `destroy`.
+ bool nested_created = true;
};
template
@@ -57,6 +61,19 @@ class AggregateFunctionCombinatorArgMinArgMax final : public IAggregateFunctionH
return *reinterpret_cast(place + key_offset);
}
+ /// Replaces the nested state with an empty one.
+ void resetNested(AggregateDataPtr __restrict place) const
+ {
+ auto & key = data(place);
+ if (key.nested_created)
+ {
+ nested_function->destroy(place);
+ key.nested_created = false;
+ }
+ nested_function->create(place);
+ key.nested_created = true;
+ }
+
public:
AggregateFunctionCombinatorArgMinArgMax(AggregateFunctionPtr nested_function_, const DataTypes & arguments, const Array & params)
: IAggregateFunctionHelper>{arguments, params, nested_function_->getResultType()}
@@ -120,8 +137,7 @@ class AggregateFunctionCombinatorArgMinArgMax final : public IAggregateFunctionH
if ((isMin && data(place).data().setIfSmaller(rhs_key.data(), arena))
|| (!isMin && data(place).data().setIfGreater(rhs_key.data(), arena)))
{
- nested_function->destroy(place);
- nested_function->create(place);
+ resetNested(place);
nested_function->mergeStateFromDifferentVariant(place, *rhs_nested, rhs_place, arena);
}
else if (data(place).data().isEqualTo(rhs_key.data()))
@@ -155,19 +171,31 @@ class AggregateFunctionCombinatorArgMinArgMax final : public IAggregateFunctionH
void create(AggregateDataPtr __restrict place) const override
{
nested_function->create(place);
- new (place + key_offset) Key(key_type);
+ try
+ {
+ new (place + key_offset) Key(key_type);
+ }
+ catch (...)
+ {
+ nested_function->destroy(place);
+ throw;
+ }
}
void destroy(AggregateDataPtr __restrict place) const noexcept override
{
+ const bool nested_created = data(place).nested_created;
data(place).~Key();
- nested_function->destroy(place);
+ if (nested_created)
+ nested_function->destroy(place);
}
void destroyUpToState(AggregateDataPtr __restrict place) const noexcept override
{
+ const bool nested_created = data(place).nested_created;
data(place).~Key();
- nested_function->destroyUpToState(place);
+ if (nested_created)
+ nested_function->destroyUpToState(place);
}
void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override
@@ -175,8 +203,7 @@ class AggregateFunctionCombinatorArgMinArgMax final : public IAggregateFunctionH
if ((isMin && data(place).data().setIfSmaller(*columns[key_col], row_num, arena))
|| (!isMin && data(place).data().setIfGreater(*columns[key_col], row_num, arena)))
{
- nested_function->destroy(place);
- nested_function->create(place);
+ resetNested(place);
nested_function->add(place, columns, row_num, arena);
}
else if (data(place).data().isEqualTo(*columns[key_col], row_num))
@@ -190,8 +217,7 @@ class AggregateFunctionCombinatorArgMinArgMax final : public IAggregateFunctionH
if ((isMin && data(place).data().setIfSmaller(data(rhs).data(), arena))
|| (!isMin && data(place).data().setIfGreater(data(rhs).data(), arena)))
{
- nested_function->destroy(place);
- nested_function->create(place);
+ resetNested(place);
nested_function->merge(place, rhs, arena);
}
else if (data(place).data().isEqualTo(data(rhs).data()))
diff --git a/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h b/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h
index 036884376681..c8f56845a9c4 100644
--- a/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h
+++ b/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h
@@ -309,7 +309,15 @@ class AggregateFunctionDistinct final : public IAggregateFunctionDataHelpercreate(getNestedPlace(place));
+ try
+ {
+ nested_func->create(getNestedPlace(place));
+ }
+ catch (...)
+ {
+ this->data(place).~Data();
+ throw;
+ }
}
void destroy(AggregateDataPtr __restrict place) const noexcept override
diff --git a/src/AggregateFunctions/WindowFunction.h b/src/AggregateFunctions/WindowFunction.h
index efa447f8f20e..e1dece457011 100644
--- a/src/AggregateFunctions/WindowFunction.h
+++ b/src/AggregateFunctions/WindowFunction.h
@@ -53,6 +53,10 @@ struct WindowFunctionWorkspace
// Will not be initialized for a pure window function.
mutable AlignedBuffer aggregate_function_state;
+ /// False after the state is destroyed until it is created again, so a throwing `create` does not lead to a second
+ /// `destroy`.
+ bool aggregate_function_state_created = false;
+
// Argument columns. Be careful, this is a per-block cache.
VectorWithMemoryTracking argument_columns;
UInt64 cached_block_number = std::numeric_limits::max();
diff --git a/src/Analyzer/FunctionNode.h b/src/Analyzer/FunctionNode.h
index f72f285480cc..303468c94a53 100644
--- a/src/Analyzer/FunctionNode.h
+++ b/src/Analyzer/FunctionNode.h
@@ -204,6 +204,9 @@ class FunctionNode final : public IQueryTreeNode
wrap_with_nullable = true;
}
+ /// Whether `convertToNullable` was called, also when the result type cannot be `Nullable` and did not change.
+ bool isConvertedToNullable() const { return wrap_with_nullable; }
+
/// Get settings changes passed to table function
const SettingsChanges & getSettingsChanges() const
{
diff --git a/src/Analyzer/Passes/IfChainToMultiIfPass.cpp b/src/Analyzer/Passes/IfChainToMultiIfPass.cpp
index 83ae67a64919..31388d1e2f42 100644
--- a/src/Analyzer/Passes/IfChainToMultiIfPass.cpp
+++ b/src/Analyzer/Passes/IfChainToMultiIfPass.cpp
@@ -3,9 +3,13 @@
#include
#include
+#include
+#include
#include
#include
+#include
+
namespace DB
{
namespace Setting
@@ -19,6 +23,39 @@ namespace Setting
namespace
{
+/// The `if` nodes of the query, outside of its subqueries, that are `GROUP BY` keys, collected before any of them is rewritten.
+std::unordered_set collectGroupByKeyIfNodes(const QueryNode & query_node)
+{
+ auto is_if = [](const QueryTreeNodePtr & node)
+ {
+ const auto * function_node = node->as();
+ return function_node && function_node->getFunctionName() == "if" && function_node->getArguments().getNodes().size() == 3;
+ };
+
+ auto if_keys = getGroupByKeys(query_node);
+ std::erase_if(if_keys, [&](const auto & key) { return !is_if(key); });
+
+ std::unordered_set result;
+ if (if_keys.empty())
+ return result;
+
+ std::vector nodes{&query_node};
+ while (!nodes.empty())
+ {
+ const auto * node = nodes.back();
+ nodes.pop_back();
+ for (const auto & child : node->getChildren())
+ {
+ if (!child || child->getNodeType() == QueryTreeNodeType::QUERY || child->getNodeType() == QueryTreeNodeType::UNION)
+ continue;
+ if (is_if(child) && isGroupByKeyAfterAggregation(child, if_keys))
+ result.insert(child);
+ nodes.push_back(child.get());
+ }
+ }
+ return result;
+}
+
class IfChainToMultiIfPassVisitor : public InDepthQueryTreeVisitorWithContext
{
public:
@@ -28,10 +65,19 @@ class IfChainToMultiIfPassVisitor : public InDepthQueryTreeVisitorWithContextas())
+ {
+ group_by_key_if_nodes_stack.push_back(
+ getSettings()[Setting::optimize_if_chain_to_multiif] ? collectGroupByKeyIfNodes(*query_node) : std::unordered_set{});
+ return;
+ }
+
if (!getSettings()[Setting::optimize_if_chain_to_multiif])
return;
@@ -53,6 +99,10 @@ class IfChainToMultiIfPassVisitor : public InDepthQueryTreeVisitorWithContextgetFunctionName() != "if" || if_chain_function_node->getArguments().getNodes().size() != 3)
break;
+ /// A `GROUP BY` key is read from the aggregation result, so it is not spliced into the chain.
+ if (if_chain_function_node->isConvertedToNullable() || group_by_key_if_nodes_stack.back().contains(if_chain_node))
+ break;
+
/// Replace last `multiIf` argument with `if` function arguments
multi_if_arguments.pop_back();
@@ -74,14 +124,27 @@ class IfChainToMultiIfPassVisitor : public InDepthQueryTreeVisitorWithContextgetResultType()->equals(*function_node->getResultType()))
+ if (!multi_if_function->getResultType()->equals(*function_node->getFunctionOrThrow()->getResultType()))
return;
+ /// A `group_by_use_nulls` copy of a GROUP BY key is the key made Nullable: rewrite it like the key and keep it Nullable.
+ if (function_node->isConvertedToNullable())
+ multi_if_function->convertToNullable();
+
node = std::move(multi_if_function);
}
+ void leaveImpl(QueryTreeNodePtr & node)
+ {
+ if (node->getNodeType() == QueryTreeNodeType::QUERY)
+ group_by_key_if_nodes_stack.pop_back();
+ }
+
private:
FunctionOverloadResolverPtr multi_if_function_ptr;
+
+ /// For each enclosing query, its `if` nodes that are `GROUP BY` keys; the first set is for an expression outside of any query.
+ std::vector> group_by_key_if_nodes_stack;
};
}
diff --git a/src/Analyzer/Passes/IfConstantConditionPass.cpp b/src/Analyzer/Passes/IfConstantConditionPass.cpp
index 6b24eb1d5391..dd1f7366c79f 100644
--- a/src/Analyzer/Passes/IfConstantConditionPass.cpp
+++ b/src/Analyzer/Passes/IfConstantConditionPass.cpp
@@ -3,8 +3,11 @@
#include
#include
+#include
#include
#include
+#include
+#include
#include
namespace DB
@@ -13,6 +16,41 @@ namespace DB
namespace
{
+/// The planner tells GROUP BY keys apart by expression and by column source, not by the aliases in the expression.
+/// A column is named after the unique alias of its source instead, so that comparing keys does not compare sources.
+QueryTreeNodePtr cloneForComparison(const QueryTreeNodePtr & node)
+{
+ auto name_after_source = [](QueryTreeNodePtr & current)
+ {
+ const auto * column_node = current->as();
+ if (!column_node)
+ return;
+ auto source = column_node->getColumnSourceOrNull();
+ if (source && source->hasAlias())
+ current = std::make_shared(
+ NameAndTypePair{source->getAlias() + "." + column_node->getColumnName(), column_node->getColumnType()},
+ TableExpressionNodeWeakPtr{});
+ };
+
+ auto result = node->clone();
+ name_after_source(result);
+ std::vector nodes{result.get()};
+ while (!nodes.empty())
+ {
+ auto * current = nodes.back();
+ nodes.pop_back();
+ current->removeAlias();
+ for (auto & child : current->getChildren())
+ {
+ if (!child || child->getNodeType() == QueryTreeNodeType::QUERY || child->getNodeType() == QueryTreeNodeType::UNION)
+ continue;
+ name_after_source(child);
+ nodes.push_back(child.get());
+ }
+ }
+ return result;
+}
+
class IfConstantConditionVisitor : public InDepthQueryTreeVisitorWithContext
{
public:
@@ -21,6 +59,22 @@ class IfConstantConditionVisitor : public InDepthQueryTreeVisitorWithContextas())
+ skip_query_folding.push_back(ifConstantConditionFoldingMergesGroupingKeys(*query_node, getContext()));
+ }
+
+ /// After the arguments, so that a chain collapses in one visit and visiting a shared node again is a no-op.
+ void leaveImpl(QueryTreeNodePtr & node)
+ {
+ if (node->getNodeType() == QueryTreeNodeType::QUERY)
+ {
+ skip_query_folding.pop_back();
+ return;
+ }
+
+ if (!skip_query_folding.empty() && skip_query_folding.back())
+ return;
+
auto * function_node = node->as();
if (!function_node || (function_node->getFunctionName() != "if" && function_node->getFunctionName() != "multiIf"))
return;
@@ -51,12 +105,72 @@ class IfConstantConditionVisitor : public InDepthQueryTreeVisitorWithContextgetArguments().getNodes()[2];
if (node->getResultType()->equals(*argument_node->getResultType()))
+ {
node = argument_node;
+ return;
+ }
+
+ /// A `group_by_use_nulls` copy of a GROUP BY key is the key made Nullable: fold it like the key and keep it Nullable.
+ const auto argument_node_type = argument_node->getNodeType();
+ const bool argument_can_be_nullable = argument_node_type == QueryTreeNodeType::COLUMN
+ || (argument_node_type == QueryTreeNodeType::FUNCTION && argument_node->as().isOrdinaryFunction());
+ if (argument_can_be_nullable && function_node->getFunctionOrThrow()->getResultType()->equals(*argument_node->getResultType()))
+ {
+ auto nullable_argument_node = argument_node->clone();
+ nullable_argument_node->convertToNullable();
+ node = std::move(nullable_argument_node);
+ }
}
+
+private:
+ /// Whether folding is skipped in the expressions of each enclosing query; nested queries decide for themselves.
+ std::vector skip_query_folding;
};
}
+/// ROLLUP, CUBE and GROUPING SETS take their grouping sets from the distinct keys, so folding may make two keys
+/// equal only if they are in the same grouping sets; a ROLLUP or CUBE key is told apart by its position.
+bool ifConstantConditionFoldingMergesGroupingKeys(const QueryNode & query_node, const ContextPtr & context)
+{
+ if (!query_node.isGroupByWithRollup() && !query_node.isGroupByWithCube() && !query_node.isGroupByWithGroupingSets())
+ return false;
+
+ QueryTreeNodePtrWithHashMap> key_grouping_sets;
+ auto add_key = [&](const QueryTreeNodePtr & key, size_t grouping_set)
+ {
+ auto & grouping_sets = key_grouping_sets[cloneForComparison(key)];
+ if (grouping_sets.empty() || grouping_sets.back() != grouping_set)
+ grouping_sets.push_back(grouping_set);
+ };
+
+ const auto & group_by_nodes = query_node.getGroupBy().getNodes();
+ for (size_t i = 0; i < group_by_nodes.size(); ++i)
+ {
+ if (query_node.isGroupByWithGroupingSets())
+ {
+ for (const auto & key : group_by_nodes[i]->as().getNodes())
+ add_key(key, i);
+ }
+ else
+ {
+ add_key(group_by_nodes[i], i);
+ }
+ }
+
+ QueryTreeNodePtrWithHashMap *> folded_key_grouping_sets;
+ for (const auto & [key, grouping_sets] : key_grouping_sets)
+ {
+ auto folded_key = key.node->clone();
+ IfConstantConditionVisitor(context).visit(folded_key);
+ auto [it, inserted] = folded_key_grouping_sets.emplace(std::move(folded_key), &grouping_sets);
+ if (!inserted && *it->second != grouping_sets)
+ return true;
+ }
+
+ return false;
+}
+
void IfConstantConditionPass::run(QueryTreeNodePtr & query_tree_node, ContextPtr context)
{
IfConstantConditionVisitor visitor(std::move(context));
diff --git a/src/Analyzer/Passes/IfConstantConditionPass.h b/src/Analyzer/Passes/IfConstantConditionPass.h
index 7548fc702bc6..e880c0284520 100644
--- a/src/Analyzer/Passes/IfConstantConditionPass.h
+++ b/src/Analyzer/Passes/IfConstantConditionPass.h
@@ -5,6 +5,8 @@
namespace DB
{
+class QueryNode;
+
/** Convert `if` with constant condition or `multiIf` with single constant condition into true condition argument value
* or false condition argument value.
*
@@ -25,4 +27,8 @@ class IfConstantConditionPass final : public IQueryTreePass
};
+/// Whether `IfConstantConditionPass` leaves the expressions of `query_node` unfolded, because folding them would merge
+/// ROLLUP, CUBE or GROUPING SETS keys of different grouping sets.
+bool ifConstantConditionFoldingMergesGroupingKeys(const QueryNode & query_node, const ContextPtr & context);
+
}
diff --git a/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.cpp b/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.cpp
index 2eebf5cc6be0..7a997118f8bf 100644
--- a/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.cpp
+++ b/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.cpp
@@ -1,9 +1,13 @@
#include
+#include
#include
#include
#include
+#include
+#include
+#include
#include
#include
#include
@@ -181,4 +185,32 @@ QueryTreeNodes unwrapInjectiveFunctionsInKeys(const QueryTreeNodes & keys, bool
return new_keys;
}
+QueryTreeNodes getGroupByKeys(const QueryNode & query_node)
+{
+ QueryTreeNodes keys;
+ if (!query_node.hasGroupBy())
+ return keys;
+
+ for (const auto & node : query_node.getGroupBy().getNodes())
+ {
+ if (query_node.isGroupByWithGroupingSets())
+ {
+ const auto & grouping_set_keys = node->as().getNodes();
+ keys.insert(keys.end(), grouping_set_keys.begin(), grouping_set_keys.end());
+ }
+ else
+ {
+ keys.push_back(node);
+ }
+ }
+ return keys;
+}
+
+bool isGroupByKeyAfterAggregation(const QueryTreeNodePtr & node, const QueryTreeNodes & group_by_keys)
+{
+ if (const auto * function_node = node->as(); function_node && function_node->isConvertedToNullable())
+ return true;
+ return std::ranges::any_of(group_by_keys, [&](const auto & key) { return compareGroupByKeys(node, key); });
+}
+
}
diff --git a/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.h b/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.h
index 63b59f76fc97..a429af960a71 100644
--- a/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.h
+++ b/src/Analyzer/Passes/OptimizeKeyExpressionsUtils.h
@@ -6,6 +6,8 @@
namespace DB
{
+class QueryNode;
+
/** Shared helpers for cleaning up the key list of `GROUP BY` and `LIMIT BY`. Both group rows by
* the distinct combinations of their key values. A key is dropped or rewritten only when this
* grouping stays the same and the old value can still be computed from the keys that remain, so
@@ -26,4 +28,11 @@ void removeKeysThatAreFunctionsOfOtherKeys(QueryTreeNodes & keys);
/// `Dynamic` or `Variant` argument into a key.
QueryTreeNodes unwrapInjectiveFunctionsInKeys(const QueryTreeNodes & keys, bool allow_suspicious_types);
+/// The `GROUP BY` keys of `query_node`, of all grouping sets.
+QueryTreeNodes getGroupByKeys(const QueryNode & query_node);
+
+/// Returns true if `node`, in an expression computed after `GROUP BY`, is a key, read from the aggregation result.
+/// Under `group_by_use_nulls` the analyzer replaces a key there with a copy converted to `Nullable`, not equal to the key.
+bool isGroupByKeyAfterAggregation(const QueryTreeNodePtr & node, const QueryTreeNodes & group_by_keys);
+
}
diff --git a/src/Analyzer/Passes/OrderByTupleEliminationPass.cpp b/src/Analyzer/Passes/OrderByTupleEliminationPass.cpp
index 7c1060821240..e346bbea180d 100644
--- a/src/Analyzer/Passes/OrderByTupleEliminationPass.cpp
+++ b/src/Analyzer/Passes/OrderByTupleEliminationPass.cpp
@@ -2,6 +2,7 @@
#include
#include
+#include
#include
#include
#include
@@ -21,13 +22,17 @@ class OrderByTupleEliminationVisitor : public InDepthQueryTreeVisitorhasOrderBy())
return;
+ const auto group_by_keys = getGroupByKeys(*query_node);
+
QueryTreeNodes result_nodes;
for (auto & sort_node : query_node->getOrderBy().getNodes())
{
auto & sort_node_typed = sort_node->as();
auto * function_expression = sort_node_typed.getExpression()->as();
- if (sort_node_typed.withFill() || !function_expression || function_expression->getFunctionName() != "tuple")
+ /// Splitting a key would read its arguments, which do not exist after aggregation.
+ if (sort_node_typed.withFill() || !function_expression || function_expression->getFunctionName() != "tuple"
+ || isGroupByKeyAfterAggregation(sort_node_typed.getExpression(), group_by_keys))
{
result_nodes.push_back(sort_node);
continue;
diff --git a/src/Analyzer/Resolve/IdentifierResolveScope.h b/src/Analyzer/Resolve/IdentifierResolveScope.h
index 33609d26a3ae..82dbf5b4dcbe 100644
--- a/src/Analyzer/Resolve/IdentifierResolveScope.h
+++ b/src/Analyzer/Resolve/IdentifierResolveScope.h
@@ -185,6 +185,9 @@ struct IdentifierResolveScope
*/
QueryTreeNodePtrWithHashIgnoreAliasesMap nullable_group_by_keys;
+ /// With `group_by_use_nulls`, the columns that `if`/`multiIf` GROUP BY keys may collapse to; used only for correlated references.
+ QueryTreeNodePtrWithHashIgnoreAliasesSet nullable_collapsed_group_by_key_columns;
+
/** It's possible that after a JOIN, a column in the projection has a type different from the column in the source table.
* (For example, after join_use_nulls or USING column cast to supertype)
* However, the column in the projection still refers to the table as its source.
diff --git a/src/Analyzer/Resolve/QueryAnalyzer.cpp b/src/Analyzer/Resolve/QueryAnalyzer.cpp
index 0a4836283852..04f3bc983089 100644
--- a/src/Analyzer/Resolve/QueryAnalyzer.cpp
+++ b/src/Analyzer/Resolve/QueryAnalyzer.cpp
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -3777,6 +3778,12 @@ ProjectionNames QueryAnalyzer::resolveExpressionNode(
}
break;
}
+
+ if (is_correlated_column_node && scope_ptr->nullable_collapsed_group_by_key_columns.contains(node))
+ {
+ node->convertToNullable();
+ break;
+ }
}
/// For local references stop at the first surrounding QUERY scope.
@@ -4146,6 +4153,32 @@ void registerNullableGroupByKeys(const QueryTreeNodes & group_by_keys, Identifie
}
}
+/// The columns `IfConstantConditionPass` may collapse `node` to: the branches of nested `if`/`multiIf`, whatever their conditions.
+void registerConstantConditionBranchColumns(const QueryTreeNodePtr & node, IdentifierResolveScope & scope)
+{
+ const auto * function_node = node->as();
+ if (!function_node || (function_node->getFunctionName() != "if" && function_node->getFunctionName() != "multiIf"))
+ return;
+
+ const auto & arguments = function_node->getArguments().getNodes();
+ if (arguments.size() != 3)
+ return;
+
+ for (size_t i = 1; i < 3; ++i)
+ {
+ if (arguments[i]->getNodeType() == QueryTreeNodeType::COLUMN)
+ scope.nullable_collapsed_group_by_key_columns.insert(arguments[i]->clone());
+ else
+ registerConstantConditionBranchColumns(arguments[i], scope);
+ }
+}
+
+void registerCollapsedGroupByKeyColumns(const QueryTreeNodes & group_by_keys, IdentifierResolveScope & scope)
+{
+ for (const auto & key : group_by_keys)
+ registerConstantConditionBranchColumns(key, scope);
+}
+
}
/** Resolve GROUP BY clause.
@@ -4203,7 +4236,12 @@ void QueryAnalyzer::resolveGroupByNode(QueryNode & query_node_typed, IdentifierR
}
if (!nullable_group_by_keys.empty())
+ {
registerNullableGroupByKeys(nullable_group_by_keys, scope);
+ /// Only if `IfConstantConditionPass` folds the keys of this query, so that the collapsed columns exist after aggregation.
+ if (!ifConstantConditionFoldingMergesGroupingKeys(query_node_typed, scope.context))
+ registerCollapsedGroupByKeyColumns(nullable_group_by_keys, scope);
+ }
/// With group_by_use_nulls the projection (and the other clauses) are re-resolved after GROUP BY
/// so that expressions equal to a key become Nullable via the scope.nullable_group_by_keys
diff --git a/src/Analyzer/Resolve/resolveFunction.cpp b/src/Analyzer/Resolve/resolveFunction.cpp
index 53b0dfc3a24f..0c8861373d26 100644
--- a/src/Analyzer/Resolve/resolveFunction.cpp
+++ b/src/Analyzer/Resolve/resolveFunction.cpp
@@ -1298,7 +1298,10 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
if (is_special_function_dict_get)
{
- scope.context->getExternalDictionariesLoader().assertDictionaryStructureExists(identifier.getFullName(), scope.context);
+ /// Check access before reading the dictionary definition, so that a user without access learns nothing
+ /// about the dictionary.
+ const auto & external_loader = scope.context->getExternalDictionariesLoader();
+ (void)external_loader.getDictionaryStructure(external_loader.resolveDictionaryCheckingAccess(identifier.getFullName(), scope.context));
}
else
{
diff --git a/src/Backups/BackupFactory.cpp b/src/Backups/BackupFactory.cpp
index ba18a6183e2d..8fb65ebb537e 100644
--- a/src/Backups/BackupFactory.cpp
+++ b/src/Backups/BackupFactory.cpp
@@ -1,6 +1,6 @@
-#include
#include
#include
+#include
#include
#include
@@ -61,8 +61,7 @@ void BackupFactory::checkSourceAccess(const BackupInfo & backup_info, ContextPtr
return;
if (auto target = it->second.source_access(backup_info, context, open_mode))
- context->getAccess()->checkAccessWithFilter(
- target->flags, AccessTypeObjects::toStringSource(target->source), target->uri);
+ ITableFunction::checkSourceAccessForURI(context, target->flags, target->source, target->uri);
}
BackupMutablePtr BackupFactory::createBackup(const CreateParams & params) const
diff --git a/src/Backups/RestorerFromBackup.cpp b/src/Backups/RestorerFromBackup.cpp
index a047b66a4ff5..8972133d7200 100644
--- a/src/Backups/RestorerFromBackup.cpp
+++ b/src/Backups/RestorerFromBackup.cpp
@@ -1,8 +1,11 @@
#include
+#include
#include
#include
#include
#include
+#include
+#include
#include
#include
#include
@@ -149,6 +152,7 @@ void RestorerFromBackup::run(Mode mode_)
setStage(Stage::CHECKING_ACCESS_RIGHTS);
loadSystemAccessTables();
checkAccessForObjectsFoundInBackup();
+ checkSettingsOfAccessEntitiesToRestore();
if (mode == Mode::CHECK_ACCESS_ONLY)
return;
@@ -436,6 +440,31 @@ AccessEntitiesToRestore RestorerFromBackup::getAccessEntitiesToRestore(const Str
return entities;
}
+void RestorerFromBackup::checkSettingsOfAccessEntitiesToRestore() const
+{
+ std::lock_guard lock{mutex};
+ if (!access_restorer)
+ return;
+
+ auto & access_control = context->getAccessControl();
+
+ /// References must be resolved by name first: the backup's UUIDs are unknown here, and a profile the check cannot read is skipped.
+ auto restorer_copy = access_restorer->makeCopyForChecking();
+ restorer_copy.generateRandomIDsAndResolveDependencies(access_control);
+
+ /// An entity existing here may not exist on another host of `RESTORE ON CLUSTER`, so it is checked too.
+ auto entities = restorer_copy.getEntitiesFromBackup();
+ for (const auto & [id, entity] : entities)
+ {
+ if (const auto * user = typeid_cast(entity.get()))
+ context->checkSettingsConstraints(AlterSettingsProfileElements{user->settings}, SettingSource::USER);
+ else if (const auto * role = typeid_cast(entity.get()))
+ context->checkSettingsConstraints(AlterSettingsProfileElements{role->settings}, SettingSource::ROLE);
+ else if (const auto * profile = typeid_cast(entity.get()))
+ context->checkSettingsConstraints(AlterSettingsProfileElements{profile->elements}, SettingSource::PROFILE);
+ }
+}
+
void RestorerFromBackup::createAndCheckDatabases()
{
Strings database_names;
diff --git a/src/Backups/RestorerFromBackup.h b/src/Backups/RestorerFromBackup.h
index aad3d2eb4232..4ee0bc1530af 100644
--- a/src/Backups/RestorerFromBackup.h
+++ b/src/Backups/RestorerFromBackup.h
@@ -86,6 +86,9 @@ class RestorerFromBackup : public BackupMetadataFinder
void loadSystemAccessTables();
void checkAccessForObjectsFoundInBackup() const;
+ /// Applies the settings constraints check of `CREATE [OR REPLACE] USER/ROLE/SETTINGS PROFILE` to the entities to restore.
+ void checkSettingsOfAccessEntitiesToRestore() const;
+
void createAndCheckDatabases();
void createAndCheckDatabase(const String & database_name);
void createAndCheckDatabaseImpl(const String & database_name);
diff --git a/src/Backups/registerBackupEngineAzureBlobStorage.cpp b/src/Backups/registerBackupEngineAzureBlobStorage.cpp
index d3d4afa57d65..5d9753324c20 100644
--- a/src/Backups/registerBackupEngineAzureBlobStorage.cpp
+++ b/src/Backups/registerBackupEngineAzureBlobStorage.cpp
@@ -18,6 +18,8 @@
#include
+#include
+
#endif
@@ -44,8 +46,6 @@ namespace
AzureBlobStorage::ConnectionParams connection_params;
String blob_path;
String archive_name;
- /// `blob_path` before a trailing archive filename is stripped off it.
- String blob_path_with_archive;
};
String removeFileNameFromURL(String & url)
@@ -178,7 +178,6 @@ namespace
"(storage account URL, container, path, account name, account key)");
}
- location.blob_path_with_archive = location.blob_path;
if (hasRegisteredArchiveFileExtension(location.blob_path))
location.archive_name = removeFileNameFromURL(location.blob_path);
return location;
@@ -198,7 +197,11 @@ namespace
return target;
}
- target.uri = resolveAzureBackupLocation(backup_info, context).blob_path_with_archive;
+ /// The key that is accessed: an archive is opened under the split-off `blob_path`.
+ const auto location = resolveAzureBackupLocation(backup_info, context);
+ target.uri = location.archive_name.empty()
+ ? location.blob_path
+ : String(std::filesystem::path(location.blob_path) / location.archive_name);
return target;
}
diff --git a/src/Client/Connection.cpp b/src/Client/Connection.cpp
index 7535a1d95856..fa4cc828ae1c 100644
--- a/src/Client/Connection.cpp
+++ b/src/Client/Connection.cpp
@@ -37,6 +37,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -90,6 +91,7 @@ namespace FailPoints
namespace ErrorCodes
{
+ extern const int AUTHENTICATION_FAILED;
extern const int NETWORK_ERROR;
extern const int SOCKET_TIMEOUT;
extern const int UNEXPECTED_PACKET_FROM_SERVER;
@@ -754,7 +756,8 @@ void Connection::receiveHello()
if (server_revision >= DBMS_MIN_REVISION_WITH_SERVER_SETTINGS)
{
Settings settings;
- settings.read(*in, SettingsWriteFormat::STRINGS_WITH_FLAGS);
+ /// A server of another version may send values that this version rejects.
+ settings.read(*in, SettingsWriteFormat::STRINGS_WITH_FLAGS, /* skip_invalid_values= */ true);
settings_from_server = settings.changes();
}
@@ -1137,6 +1140,20 @@ void Connection::sendQuery(
disconnect();
});
+ /// Over the cluster secret a shard authenticates as `initial_user` without a password, so forward
+ /// only an `initial_user` equal to the authenticated `current_user`. Skip the check when
+ /// `current_user` is empty -- server-internal paths (async `Distributed` insert, buffer flush) have none.
+ if (!cluster_secret.empty() && client_info && !client_info->current_user.empty()
+ && client_info->initial_user != client_info->current_user)
+ {
+ /// A mismatch means a forged SECONDARY_QUERY impersonating another user -- including an empty
+ /// initial_user, which the shard would otherwise run with full access -- so refuse it.
+ throw Exception(ErrorCodes::AUTHENTICATION_FAILED,
+ "Refusing to forward a query over the cluster secret: its initial_user '{}' differs "
+ "from the authenticated user '{}'.",
+ client_info->initial_user, client_info->current_user);
+ }
+
writeVarUInt(Protocol::Client::Query, *out);
writeStringBinary(query_id, *out);
@@ -1749,7 +1766,16 @@ Block Connection::receiveDataImpl(NativeReader & reader)
Block Connection::receiveProfileEvents()
{
initBlockProfileEventsInput();
- return receiveDataImpl(*block_profile_events_in);
+ Block block = receiveDataImpl(*block_profile_events_in);
+
+ /// The servers before this revision report the counters in another form (total values instead of
+ /// increments, in a block of another structure), which nothing reads: what they have sent is skipped.
+ if (server_revision < DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS)
+ return ProfileEvents::getSampleBlock();
+
+ /// The structure of the block is chosen by the server, and the consumers of the packet rely on it.
+ ProfileEvents::checkBlockStructure(block);
+ return block;
}
diff --git a/src/Columns/ColumnObject.cpp b/src/Columns/ColumnObject.cpp
index af2242c747b2..be42aee89024 100644
--- a/src/Columns/ColumnObject.cpp
+++ b/src/Columns/ColumnObject.cpp
@@ -20,6 +20,7 @@ namespace DB
namespace ErrorCodes
{
extern const int ATTEMPT_TO_READ_AFTER_EOF;
+ extern const int INCORRECT_DATA;
extern const int NOT_IMPLEMENTED;
extern const int LOGICAL_ERROR;
extern const int PARAMETER_OUT_OF_BOUND;
@@ -431,6 +432,11 @@ UInt64 ColumnObject::getNumberOfDefaultRows() const
if (num_non_default == num_rows)
return;
+ /// The indices of the non-default rows of a subcolumn index the bitmap of `num_rows` entries.
+ if (column.size() != num_rows)
+ throw Exception(ErrorCodes::LOGICAL_ERROR,
+ "Subcolumn of a JSON column has {} rows, but the column has {} rows", column.size(), num_rows);
+
const size_t num_defaults_in_column = column.getNumberOfDefaultRows();
if (num_defaults_in_column == num_rows)
return;
@@ -1188,6 +1194,7 @@ void ColumnObject::deserializeDynamicPathsAndSharedDataFromArena(ReadBuffer & in
readBinaryLittleEndian(num_paths, in);
const auto [shared_data_paths, shared_data_values] = getSharedDataPathsAndValues();
+ const size_t shared_data_row_start = shared_data_paths->size();
for (size_t i = 0; i != num_paths; ++i)
{
size_t path_size = 0;
@@ -1206,9 +1213,17 @@ void ColumnObject::deserializeDynamicPathsAndSharedDataFromArena(ReadBuffer & in
size_t value_size = 0;
readBinaryLittleEndian(value_size, in);
+ /// `serializeDynamicPathsAndSharedDataIntoArena` writes every path of a row once. A path repeated
+ /// in the row would get several values in a column of a dynamic path, or break the order of shared data.
+ /// Typed paths are deserialized before, so a typed path here would be a second value of it.
+ if (typed_paths.contains(path))
+ throw Exception(ErrorCodes::INCORRECT_DATA, "Typed path '{}' in dynamic paths of a serialized value of JSON column", path);
+
/// Check if we have this path in dynamic paths.
if (auto dynamic_it = dynamic_paths.find(path); dynamic_it != dynamic_paths.end())
{
+ if (dynamic_it->second->size() != current_size)
+ throw Exception(ErrorCodes::INCORRECT_DATA, "Duplicate path '{}' in a serialized value of JSON column", path);
getDynamicSerialization()->deserializeBinary(*dynamic_it->second, in, getFormatSettings());
}
/// Try to add a new dynamic path.
@@ -1226,6 +1241,9 @@ void ColumnObject::deserializeDynamicPathsAndSharedDataFromArena(ReadBuffer & in
"Attempt to read {} bytes for the value size, but only {} bytes are available",
value_size,
in.available());
+ if (shared_data_paths->size() > shared_data_row_start && shared_data_paths->getDataAt(shared_data_paths->size() - 1) >= path)
+ throw Exception(ErrorCodes::INCORRECT_DATA,
+ "Paths of a serialized value of JSON column are not sorted or have duplicates (at path '{}')", path);
std::string_view value(in.position(), value_size);
in.ignore(value_size);
shared_data_paths->insertData(path.data(), path.size());
diff --git a/src/Columns/ColumnUnique.h b/src/Columns/ColumnUnique.h
index 447a52cdbe0c..7aa83411a6f1 100644
--- a/src/Columns/ColumnUnique.h
+++ b/src/Columns/ColumnUnique.h
@@ -28,6 +28,7 @@ namespace DB
namespace ErrorCodes
{
extern const int ATTEMPT_TO_READ_AFTER_EOF;
+ extern const int INCORRECT_DATA;
extern const int LOGICAL_ERROR;
extern const int ILLEGAL_COLUMN;
extern const int NOT_IMPLEMENTED;
@@ -616,6 +617,9 @@ size_t ColumnUnique::uniqueDeserializeAndInsertFromArena(ReadBuffer
if (in.available() < string_size)
throw Exception(ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF, "Not enough data to deserialize string value in ColumnUnique.");
+ if (unlikely(string_size < serialize_string_with_zero_byte))
+ throw Exception(ErrorCodes::INCORRECT_DATA, "String size is smaller than its zero-byte terminator");
+
size_t ret = uniqueInsertData(in.position(), string_size - serialize_string_with_zero_byte);
in.ignore(string_size);
return ret;
@@ -624,39 +628,8 @@ size_t ColumnUnique::uniqueDeserializeAndInsertFromArena(ReadBuffer
template
size_t ColumnUnique::uniqueDeserializeAndInsertAggregationStateValueFromArena(ReadBuffer & in)
{
- if (is_nullable)
- {
- UInt8 val = 0;
- readBinaryLittleEndian(val, in);
-
- if (val)
- return getNullValueIndex();
-
- }
-
- /// Numbers, FixedString
- if (size_of_value_if_fixed)
- {
- if (in.available() < size_of_value_if_fixed)
- throw Exception(ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF, "Not enough data to deserialize fixed size value in ColumnUnique.");
-
- size_t ret = uniqueInsertData(in.position(), size_of_value_if_fixed);
- in.ignore(size_of_value_if_fixed);
- return ret;
-
- }
-
- /// String
- /// For compatibility, serialized string value contains zero byte at the end, we just ignore this byte.
- size_t string_size_with_zero_byte = 0;
- readBinaryLittleEndian(string_size_with_zero_byte, in);
- if (in.available() < string_size_with_zero_byte)
- throw Exception(ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF, "Not enough data to deserialize string value in ColumnUnique.");
-
- size_t ret = uniqueInsertData(in.position(), string_size_with_zero_byte - 1);
- in.ignore(string_size_with_zero_byte);
-
- return ret;
+ const auto settings = IColumn::SerializationSettings::createForAggregationState();
+ return uniqueDeserializeAndInsertFromArena(in, &settings);
}
template
diff --git a/src/Common/AsynchronousMetrics.cpp b/src/Common/AsynchronousMetrics.cpp
index db8f1d6f6fca..0e92766461b3 100644
--- a/src/Common/AsynchronousMetrics.cpp
+++ b/src/Common/AsynchronousMetrics.cpp
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -28,6 +29,7 @@
#include
#include
+#include
#include "config.h"
@@ -153,6 +155,7 @@ AsynchronousMetrics::AsynchronousMetrics(
/// CGroups v2
openCgroupv2MetricFile("memory.max", cgroupmem_limit_in_bytes);
openCgroupv2MetricFile("cpu.max", cgroupcpu_max);
+ openCgroupv2MetricFile("cpuset.cpus.effective", cgroupcpuset);
openCgroupv2MetricFile("cpu.stat", cgroupcpu_stat);
/// CGroups v1
@@ -165,6 +168,8 @@ AsynchronousMetrics::AsynchronousMetrics(
}
if (!cgroupcpu_stat)
openFileIfExists("/sys/fs/cgroup/cpuacct/cpuacct.stat", cgroupcpuacct_stat);
+ if (!cgroupcpuset)
+ openFileIfExists("/sys/fs/cgroup/cpuset/cpuset.effective_cpus", cgroupcpuset);
try
{
@@ -1683,9 +1688,37 @@ void AsynchronousMetrics::update(TimePoint update_time, bool force_update)
}
}
+ /// With exclusive CPUs (e.g. the static CPU manager of Kubernetes) there is no CFS quota (`cpu.max` is `max`),
+ /// and the limit is only visible in the cpuset.
+ if (cgroupcpuset)
+ {
+ try
+ {
+ cgroupcpuset->rewind();
+
+ String cpu_list;
+ readString(cpu_list, *cgroupcpuset);
+ if (auto cpuset_cpus = countCPUsInList(cpu_list))
+ {
+ const auto cpuset_cores = static_cast(*cpuset_cpus);
+ if (max_cpu_cgroups > 0)
+ max_cpu_cgroups = std::min(max_cpu_cgroups, cpuset_cores);
+ /// Without a quota, a cpuset with all online CPUs is not a limit.
+ else if (*cpuset_cpus < std::thread::hardware_concurrency())
+ max_cpu_cgroups = cpuset_cores;
+ }
+ }
+ catch (...)
+ {
+ tryLogCurrentException(__PRETTY_FUNCTION__);
+ }
+ }
+
if (max_cpu_cgroups > 0)
{
- new_values["CGroupMaxCPU"] = { max_cpu_cgroups, "The maximum number of CPU cores according to CGroups."};
+ new_values["CGroupMaxCPU"] = { max_cpu_cgroups,
+ "The maximum number of CPU cores according to CGroups: the minimum of the CPU quota divided by its period "
+ "and the number of CPUs in the effective cpuset."};
}
if (cgroupcpu_stat || cgroupcpuacct_stat)
diff --git a/src/Common/AsynchronousMetrics.h b/src/Common/AsynchronousMetrics.h
index cd7c9b6706a2..01124fb45e8b 100644
--- a/src/Common/AsynchronousMetrics.h
+++ b/src/Common/AsynchronousMetrics.h
@@ -190,6 +190,7 @@ class AsynchronousMetrics
std::optional cgroupcpu_cfs_period TSA_GUARDED_BY(data_mutex);
std::optional cgroupcpu_cfs_quota TSA_GUARDED_BY(data_mutex);
std::optional cgroupcpu_max TSA_GUARDED_BY(data_mutex);
+ std::optional cgroupcpuset TSA_GUARDED_BY(data_mutex);
std::optional cgroupcpu_stat TSA_GUARDED_BY(data_mutex);
std::optional cgroupcpuacct_stat TSA_GUARDED_BY(data_mutex);
diff --git a/src/Common/DateLUTImpl.cpp b/src/Common/DateLUTImpl.cpp
index 305e2b1f277a..6688f0ccc7f6 100644
--- a/src/Common/DateLUTImpl.cpp
+++ b/src/Common/DateLUTImpl.cpp
@@ -324,6 +324,14 @@ DateLUTImpl::Time DateLUTImpl::timezoneOffsetOutOfRange(Time t) const
return cctz_time_zone->lookup(std::chrono::system_clock::from_time_t(t)).offset;
}
+DateLUTImpl::Time DateLUTImpl::timezoneOffsetAtLocalTimeOutOfRange(Time t) const
+{
+ t = std::clamp(t, min_representable_time, max_representable_time);
+ const auto local = cctz::civil_second{1970, 1, 1} + t;
+ return t - std::chrono::system_clock::to_time_t(
+ cctz_time_zone->lookup(local).post);
+}
+
DateLUTImpl::Time DateLUTImpl::addDaysOutOfRange(Time t, Int64 delta) const
{
/// Keep the same wall-clock time of day, but on the day that is `delta` days away.
diff --git a/src/Common/DateLUTImpl.h b/src/Common/DateLUTImpl.h
index 26cf5f97e2df..465b469ca03a 100644
--- a/src/Common/DateLUTImpl.h
+++ b/src/Common/DateLUTImpl.h
@@ -872,11 +872,7 @@ class DateLUTImpl
return res <= 23 ? res : 23;
}
- /** Calculating offset from UTC in seconds.
- * which means Using the same literal time of "t" to get the corresponding timestamp in UTC,
- * then subtract the former from the latter to get the offset result.
- * The boundaries when meets DST(daylight saving time) change should be handled very carefully.
- */
+ /// The offset from UTC at the instant `t`.
Time timezoneOffset(Time t) const
{
if (unlikely(isOutOfLUTRange(t)))
@@ -895,6 +891,29 @@ class DateLUTImpl
return res;
}
+ /// The offset from UTC at the local time `t`, which is a wall clock read as seconds since the epoch, so that
+ /// `t - timezoneOffsetAtLocalTime(t)` is its UTC time. A repeated or skipped local time is resolved as in `makeDateTime`.
+ Time timezoneOffsetAtLocalTime(Time t) const
+ {
+ Int64 day = t / 86400;
+ Time time_of_day = t % 86400;
+ if (time_of_day < 0)
+ {
+ --day;
+ time_of_day += 86400;
+ }
+
+ const Int64 index = day + daynum_offset_epoch;
+ if (unlikely(static_cast(index) >= DATE_LUT_SIZE))
+ return timezoneOffsetAtLocalTimeOutOfRange(t);
+
+ const Values & values = lut[index];
+ Time res = day * 86400 - values.date;
+ if (values.amount_of_offset_change() != 0 && time_of_day >= values.time_at_offset_change())
+ res += values.amount_of_offset_change();
+ return res;
+ }
+
unsigned toSecond(Time t) const
{
@@ -1914,6 +1933,7 @@ class DateLUTImpl
DateTimeComponents toDateTimeComponentsOutOfRange(Time t) const;
Time toTimeOutOfRange(Time t) const;
Time timezoneOffsetOutOfRange(Time t) const;
+ Time timezoneOffsetAtLocalTimeOutOfRange(Time t) const;
Time addDaysOutOfRange(Time t, Int64 delta) const;
Time addMonthsOutOfRange(Time t, Int64 delta) const;
Time addYearsOutOfRange(Time t, Int64 delta) const;
diff --git a/src/Common/FailPoint.cpp b/src/Common/FailPoint.cpp
index 25b9a3f00bd5..5e051f6e43f6 100644
--- a/src/Common/FailPoint.cpp
+++ b/src/Common/FailPoint.cpp
@@ -326,6 +326,8 @@ static struct InitFiu
REGULAR(rmt_merge_selecting_task_max_part_size) \
REGULAR(merge_tree_load_statistics_throw) \
REGULAR(merge_tree_load_outdated_parts_retryable_error) \
+ REGULAR(merge_tree_load_outdated_parts_schedule_error) \
+ PAUSEABLE_ONCE(mt_pause_before_loading_outdated_part) \
PAUSEABLE(merge_tree_load_outdated_parts_pause) \
PAUSEABLE(smt_mutate_task_pause_in_prepare) \
PAUSEABLE(smt_merge_selecting_task_pause_when_scheduled) \
diff --git a/src/Common/HTTPHeaderFilter.cpp b/src/Common/HTTPHeaderFilter.cpp
index 2285f8f6ab02..59e0e5948e0d 100644
--- a/src/Common/HTTPHeaderFilter.cpp
+++ b/src/Common/HTTPHeaderFilter.cpp
@@ -3,7 +3,9 @@
#include
#include
#include
+#include
#include
+#include
#include
#include
@@ -53,6 +55,37 @@ void HTTPHeaderFilter::checkAndNormalizeHeaders(HTTPHeaderEntries & entries) con
}
}
+void HTTPHeaderFilter::checkBasicCredentials(const Poco::Net::HTTPBasicCredentials & credentials) const
+{
+ if (credentials.getUsername().empty())
+ return;
+
+ checkAuthorizationHeader("Basic authentication credentials, for example the userinfo of a URL, are sent in this header");
+}
+
+void HTTPHeaderFilter::checkURIUserInfo(const Poco::URI & uri) const
+{
+ if (uri.getUserInfo().empty())
+ return;
+
+ checkAuthorizationHeader("The userinfo of the URL is sent in this header as Basic authentication credentials");
+}
+
+void HTTPHeaderFilter::checkAuthorizationHeader(const std::string & reason) const
+{
+ /// A forbidden header is matched by name, and a Base64 value has no CR or LF, so a placeholder value suffices.
+ HTTPHeaderEntries entries{{"Authorization", "Basic"}};
+ try
+ {
+ checkAndNormalizeHeaders(entries);
+ }
+ catch (Exception & e)
+ {
+ e.addMessage(reason);
+ throw;
+ }
+}
+
void HTTPHeaderFilter::setValuesFromConfig(const Poco::Util::AbstractConfiguration & config)
{
std::lock_guard guard(mutex);
diff --git a/src/Common/HTTPHeaderFilter.h b/src/Common/HTTPHeaderFilter.h
index b6232b40b932..4d3a034320fc 100644
--- a/src/Common/HTTPHeaderFilter.h
+++ b/src/Common/HTTPHeaderFilter.h
@@ -8,6 +8,8 @@
#include
namespace re2 { class RE2; }
+namespace Poco { class URI; }
+namespace Poco::Net { class HTTPBasicCredentials; }
namespace DB
{
@@ -19,7 +21,14 @@ class HTTPHeaderFilter
void setValuesFromConfig(const Poco::Util::AbstractConfiguration & config);
void checkAndNormalizeHeaders(HTTPHeaderEntries & entries) const;
+ /// Throws if the `Authorization` header that sends these credentials is forbidden. An empty username sends no header.
+ void checkBasicCredentials(const Poco::Net::HTTPBasicCredentials & credentials) const;
+ /// The same for a sender that sends any non-empty userinfo of `uri` as Basic credentials, even without a username.
+ void checkURIUserInfo(const Poco::URI & uri) const;
+
private:
+ void checkAuthorizationHeader(const std::string & reason) const;
+
/// Header names are case-insensitive (RFC 7230 3.2): entries are stored
/// lower-cased and the incoming name is lower-cased before lookup.
std::unordered_set forbidden_headers;
diff --git a/src/Common/MemoryWorker.cpp b/src/Common/MemoryWorker.cpp
index 4fa59e326579..d7b7f1950ee3 100644
--- a/src/Common/MemoryWorker.cpp
+++ b/src/Common/MemoryWorker.cpp
@@ -1000,14 +1000,28 @@ void MemoryWorker::updateResidentMemoryThread()
}
}
- /// update MemoryTracker with resident memory information (cgroup or jemalloc) when:
+ /// update MemoryTracker with `allocated` (the maximum of resident memory (cgroup or jemalloc) and jemalloc `stats.allocated`) when:
/// - it's a first run of MemoryWorker (MemoryTracker could've missed some allocation before its initialization)
/// - MemoryTracker stores a negative value
/// - `correct_tracker` is set to true
- if (first_run || total_memory_tracker.get() < 0) [[unlikely]]
- MemoryTracker::updateAllocated(memory_usage.allocated, /*log_change=*/true);
- else if (correct_tracker)
- MemoryTracker::updateAllocated(memory_usage.allocated, /*log_change=*/false);
+ if (first_run || total_memory_tracker.get() < 0 || correct_tracker)
+ {
+ /// Every allocation of `Allocator` goes through jemalloc, and `stats.allocated` counts the bytes
+ /// handed out to the application even if their pages are not touched yet, while the resident
+ /// memory does not include such pages. Correcting the tracker down to the resident memory alone
+ /// would forget memory that is allocated but not yet used and admit allocations past
+ /// `max_server_memory_usage` until the process is killed by the OOM killer. Correcting it down to
+ /// `stats.allocated` still removes the drift: bytes counted in the tracker without any allocation
+ /// behind them.
+ if (source != MemoryUsageSource::Jemalloc)
+ epoch_mib.setValue(0);
+ const Int64 allocated = std::max(memory_usage.allocated, allocated_mib.getValue());
+
+ if (first_run || total_memory_tracker.get() < 0) [[unlikely]]
+ MemoryTracker::updateAllocated(allocated, /*log_change=*/true);
+ else
+ MemoryTracker::updateAllocated(allocated, /*log_change=*/false);
+ }
#else
/// we don't update in the first run if we don't have jemalloc
/// because without a sanitizer we can only use resident memory information
diff --git a/src/Common/MemoryWorker.h b/src/Common/MemoryWorker.h
index 9eb2fc7107eb..66496f213d64 100644
--- a/src/Common/MemoryWorker.h
+++ b/src/Common/MemoryWorker.h
@@ -273,6 +273,7 @@ class MemoryWorker
Jemalloc::MibCache epoch_mib{"epoch"};
Jemalloc::MibCache resident_mib{"stats.resident"};
+ Jemalloc::MibCache allocated_mib{"stats.allocated"};
Jemalloc::MibCache pagesize_mib{"arenas.page"};
Jemalloc::MibCache dirty_decay_ms_mib{"arenas.dirty_decay_ms"};
diff --git a/src/Common/ProfileEvents.cpp b/src/Common/ProfileEvents.cpp
index e3f0c10d8c13..006702d79696 100644
--- a/src/Common/ProfileEvents.cpp
+++ b/src/Common/ProfileEvents.cpp
@@ -1908,12 +1908,16 @@ The server successfully detected this situation and will download merged part fr
\
M(JoinBuildPostProcessingMicroseconds, "Elapsed time of post-processing steps after building the right JOIN side.", ValueType::Microseconds) \
\
- M(AIInputTokens, "Total prompt tokens consumed across all AI function calls in the query.", ValueType::Number) \
+ M(AIInputTokens, "Total prompt tokens consumed across all AI function calls in the query, including cache reads and writes.", ValueType::Number) \
M(AIOutputTokens, "Total completion tokens consumed across all AI function calls in the query.", ValueType::Number) \
+ M(AICacheReadTokens, "Prompt tokens read from the provider cache, as reported by AI chat providers. Included in AIInputTokens.", ValueType::Number) \
+ M(AICacheWriteTokens, "Prompt tokens written to the provider cache, as reported by AI chat providers. Included in AIInputTokens.", ValueType::Number) \
M(AIAPICalls, "Number of HTTP requests dispatched to AI providers.", ValueType::Number) \
M(AIAPICallsRetried, "Number of AI provider requests retried after a transient failure.", ValueType::Number) \
M(AIAPICallsFailed, "Number of AI provider requests that failed after all retries.", ValueType::Number) \
M(AIAPICallsThrottled, "Number of AI provider requests rejected with HTTP 429 (Too Many Requests).", ValueType::Number) \
+ M(AIRequestMicroseconds, "Total time spent in AI provider requests, including failed attempts and response parsing, excluding retry backoff. Summed across threads.", ValueType::Microseconds) \
+ M(AIRetryBackoffMicroseconds, "Total time spent waiting before retries of failed AI provider requests. Summed across threads.", ValueType::Microseconds) \
M(AIRowsProcessed, "Number of rows that received an AI result.", ValueType::Number) \
M(AIRowsSkipped, "Number of rows that received a default value due to quota or error.", ValueType::Number) \
\
diff --git a/src/Common/RemoteHostFilter.cpp b/src/Common/RemoteHostFilter.cpp
index 5b5da5ec7c6b..a5f8b81e1220 100644
--- a/src/Common/RemoteHostFilter.cpp
+++ b/src/Common/RemoteHostFilter.cpp
@@ -17,13 +17,15 @@ namespace ErrorCodes
bool RemoteHostFilter::checkURL(const Poco::URI & uri, bool throw_on_error) const
{
- if (checkForDirectEntry(uri.getHost()) || checkForDirectEntry(uri.getHost() + ":" + toString(uri.getPort())))
+ const std::string host_and_port = uri.getHost() + ":" + toString(uri.getPort());
+ if (checkForDirectEntry(uri.getHost()) || checkForDirectEntry(host_and_port))
return true;
if (!throw_on_error)
return false;
+ /// Only the host and port are checked. The rest of the URL can carry secrets and is not printed.
throw Exception(ErrorCodes::UNACCEPTABLE_URL, "URL \"{}\" is not allowed in configuration file, "
- "see ", uri.toString());
+ "see ", host_and_port);
}
void RemoteHostFilter::checkHostAndPort(const std::string & host, const std::string & port) const
diff --git a/src/Common/Scheduler/Workload/WorkloadEntityKeeperStorage.cpp b/src/Common/Scheduler/Workload/WorkloadEntityKeeperStorage.cpp
index aff81eaa2faa..a97080a7d961 100644
--- a/src/Common/Scheduler/Workload/WorkloadEntityKeeperStorage.cpp
+++ b/src/Common/Scheduler/Workload/WorkloadEntityKeeperStorage.cpp
@@ -184,8 +184,12 @@ WorkloadEntityStorageBase::OperationResult WorkloadEntityKeeperStorage::storeEnt
auto component_guard = Coordination::setCurrentComponent("WorkloadEntityKeeperStorage::storeEntityImpl");
LOG_DEBUG(log, "Storing workload entity {}", backQuote(entity_name));
- String new_data = serializeLocalEntities(Event{entity_type, entity_name, create_entity_query});
+ Int32 validated_version = current_version;
auto zookeeper = getZooKeeper();
+ if (current_version != validated_version)
+ return OperationResult::Retry; /// A new session has refreshed the entities, so the caller's validation is stale
+
+ String new_data = serializeLocalEntities(Event{entity_type, entity_name, create_entity_query});
Coordination::Stat stat;
auto code = zookeeper->trySet(zookeeper_path, new_data, current_version, &stat);
@@ -212,8 +216,12 @@ WorkloadEntityStorageBase::OperationResult WorkloadEntityKeeperStorage::removeEn
auto component_guard = Coordination::setCurrentComponent("WorkloadEntityKeeperStorage::removeEntityImpl");
LOG_DEBUG(log, "Removing workload entity {}", backQuote(entity_name));
- String new_data = serializeLocalEntities(Event{entity_type, entity_name, {}});
+ Int32 validated_version = current_version;
auto zookeeper = getZooKeeper();
+ if (current_version != validated_version)
+ return OperationResult::Retry; /// A new session has refreshed the entities, so the caller's validation is stale
+
+ String new_data = serializeLocalEntities(Event{entity_type, entity_name, {}});
Coordination::Stat stat;
auto code = zookeeper->trySet(zookeeper_path, new_data, current_version, &stat);
diff --git a/src/Common/ThreadPool.cpp b/src/Common/ThreadPool.cpp
index 37d3a0ea3431..8f3c65e78d54 100644
--- a/src/Common/ThreadPool.cpp
+++ b/src/Common/ThreadPool.cpp
@@ -338,6 +338,7 @@ void ThreadPoolImpl::setMaxThreads(size_t value)
/// We have to also adjust queue size, because it limits the number of scheduled and already running jobs in total.
queue_size = queue_size ? std::max(queue_size, max_threads) : 0;
jobs.reserve(std::min(queue_size, MAX_JOBS_TO_RESERVE));
+ slot_freed.notify_all();
if (need_start_threads)
{
@@ -401,6 +402,8 @@ void ThreadPoolImpl::setQueueSize(size_t value)
queue_size = value ? std::max(value, max_threads) : 0;
/// Reserve memory to get rid of allocations
jobs.reserve(std::min(queue_size, MAX_JOBS_TO_RESERVE));
+ /// A larger queue can admit the schedulers waiting for a slot.
+ slot_freed.notify_all();
}
template
@@ -431,6 +434,7 @@ ReturnType ThreadPoolImpl::scheduleImpl(Job job, Priority priority, std:
ScopedDecrement available_threads_decrement(available_threads);
std::unique_ptr new_thread;
+ std::shared_ptr idle_thread_cv;
// Load the current capacity
int64_t capacity = remaining_pool_capacity.load(std::memory_order_relaxed);
int64_t currently_available_threads = available_threads.load(std::memory_order_relaxed);
@@ -471,11 +475,18 @@ ReturnType ThreadPoolImpl::scheduleImpl(Job job, Priority priority, std:
/// Wait for available threads or timeout
if (wait_microseconds) /// Check for optional. Condition is true if the optional is set. Even if the value is zero.
{
- if (!job_finished.wait_for(lock, std::chrono::microseconds(*wait_microseconds), pred))
+ if (!slot_freed.wait_for(lock, std::chrono::microseconds(*wait_microseconds), pred))
return on_error(fmt::format("no free thread (timeout={})", *wait_microseconds));
}
else
- job_finished.wait(lock, pred);
+ slot_freed.wait(lock, pred);
+
+ /// A freed slot wakes only one scheduler, so pass the wakeup on while slots remain free.
+ /// This covers a scheduler that fails without taking the slot.
+ SCOPE_EXIT(
+ if (queue_size && scheduled_jobs < queue_size)
+ slot_freed.notify_one();
+ );
if (finished)
return on_error("finished");
@@ -573,14 +584,19 @@ ReturnType ThreadPoolImpl::scheduleImpl(Job job, Priority priority, std:
/// avoids a thundering herd where every idle thread wakes, contends for the
/// mutex, and goes back to sleep on every job schedule.
///
- /// Notify while still holding `mutex`: once `idle_wakeup_flag` is set, a
- /// spurious wakeup is enough for the worker to run and remove itself from
- /// the pool, so the raw `ThreadFromThreadPool` pointer must not be used
- /// after the lock is released.
+ /// Notify after releasing `mutex`, otherwise the woken thread blocks on it right away.
+ /// Once `idle_wakeup_flag` is set, a spurious wakeup is enough for the thread to run
+ /// and remove itself from the pool, so only its CV, not the thread, is used after unlock.
if (ThreadFromThreadPool * thread_to_wake = popNewestIdleThreadNoLock())
- wakeIdleThreadNoLock(thread_to_wake);
+ {
+ thread_to_wake->idle_wakeup_flag = true;
+ idle_thread_cv = thread_to_wake->cv;
+ }
}
+ if (idle_thread_cv)
+ idle_thread_cv->notify_one();
+
ProfileEvents::increment(std::is_same_v ? ProfileEvents::GlobalThreadPoolJobs : ProfileEvents::LocalThreadPoolJobs);
return static_cast(true);
@@ -675,7 +691,7 @@ void ThreadPoolImpl::wait()
/// first worker-loop iteration, or a busy thread that will see the queued
/// job when it finishes its current one). Waking all idle threads would
/// destroy LIFO ordering — the whole point of this pool design.
- job_finished.wait(lock, [this] { return scheduled_jobs == 0; });
+ all_jobs_finished.wait(lock, [this] { return scheduled_jobs == 0; });
if (first_exception)
{
@@ -693,7 +709,7 @@ bool ThreadPoolImpl::waitUntil(std::chrono::steady_clock::time_point dea
ProfileEvents::increment(
std::is_same_v ? ProfileEvents::GlobalThreadPoolLockWaitMicroseconds : ProfileEvents::LocalThreadPoolLockWaitMicroseconds,
watch.elapsedMicroseconds());
- return job_finished.wait_until(lock, deadline, [this] { return scheduled_jobs == 0; });
+ return all_jobs_finished.wait_until(lock, deadline, [this] { return scheduled_jobs == 0; });
}
template
@@ -720,7 +736,7 @@ void ThreadPoolImpl::finishNoLock(const std::lock_guard &)
/// Wake up all idle threads so they can see it and exit gracefully.
wakeUpAllIdleThreadsNoLock();
- job_finished.notify_all();
+ slot_freed.notify_all();
}
template
@@ -837,7 +853,7 @@ template
void ThreadPoolImpl::wakeIdleThreadNoLock(ThreadFromThreadPool * thread)
{
thread->idle_wakeup_flag = true;
- thread->cv.notify_one();
+ thread->cv->notify_one();
}
template
@@ -1031,9 +1047,15 @@ void ThreadPoolImpl::ThreadFromThreadPool::worker()
--parent_pool.scheduled_jobs;
- parent_pool.job_finished.notify_all();
+ if (parent_pool.scheduled_jobs == 0)
+ parent_pool.all_jobs_finished.notify_all();
if (parent_pool.finished)
+ {
+ parent_pool.slot_freed.notify_all();
parent_pool.wakeUpAllIdleThreadsNoLock(); /// `finished` was set, wake up other threads so they can finish themselves.
+ }
+ else
+ parent_pool.slot_freed.notify_one();
}
/// LIFO idle thread scheduling: link this thread into the intrusive
@@ -1064,7 +1086,7 @@ void ThreadPoolImpl::ThreadFromThreadPool::worker()
{
idle_wakeup_flag = false;
parent_pool.pushIdleThreadNoLock(this);
- cv.wait(lock, [this]
+ cv->wait(lock, [this]
{
return idle_wakeup_flag
|| !parent_pool.jobs.empty()
diff --git a/src/Common/ThreadPool.h b/src/Common/ThreadPool.h
index 502f2430fc66..fb8bb9340efd 100644
--- a/src/Common/ThreadPool.h
+++ b/src/Common/ThreadPool.h
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -92,7 +93,9 @@ class ThreadPoolImpl
/// Each idle thread waits on its own CV, so the scheduler can wake the
/// LIFO-selected thread directly without disturbing other idle threads.
/// This avoids the thundering herd that a shared CV with `notify_all` creates.
- std::condition_variable cv;
+ /// Shared, so that `scheduleImpl` can notify it after releasing the pool mutex,
+ /// when the thread may already have left the pool.
+ std::shared_ptr cv = std::make_shared();
/// LIFO idle thread scheduling flag.
/// When a new job is scheduled, the most recently idle thread is popped
@@ -201,7 +204,9 @@ class ThreadPoolImpl
friend class GlobalThreadPool;
mutable std::mutex mutex;
- std::condition_variable job_finished;
+ /// A finished job frees one slot, so it wakes only one scheduler waiting for a slot.
+ std::condition_variable slot_freed;
+ std::condition_variable all_jobs_finished;
Metric metric_threads;
Metric metric_active_threads;
diff --git a/src/Common/getNumberOfCPUCoresToUse.cpp b/src/Common/getNumberOfCPUCoresToUse.cpp
index cd87fca568ba..9092b995c8a2 100644
--- a/src/Common/getNumberOfCPUCoresToUse.cpp
+++ b/src/Common/getNumberOfCPUCoresToUse.cpp
@@ -13,8 +13,42 @@
#include
#include
#include
+#include
+#include
#include
+#if defined(OS_LINUX)
+std::optional countCPUsInList(const std::string & cpu_list)
+{
+ if (cpu_list.empty())
+ return std::nullopt;
+
+ auto parse = [](const std::string & text, int & value)
+ {
+ return std::from_chars(text.data(), text.data() + text.size(), value).ec == std::errc{};
+ };
+
+ std::vector cpu_ranges;
+ boost::split(cpu_ranges, cpu_list, boost::is_any_of(","));
+ uint32_t cpus_count = 0;
+ for (const std::string & cpu_number_or_range : cpu_ranges)
+ {
+ std::vector cpu_range;
+ boost::split(cpu_range, cpu_number_or_range, boost::is_any_of("-"));
+
+ int start = 0;
+ int end = 0;
+ if (cpu_range.size() == 1 && parse(cpu_range[0], start))
+ end = start;
+ else if (cpu_range.size() != 2 || !parse(cpu_range[0], start) || !parse(cpu_range[1], end) || end < start)
+ return std::nullopt;
+
+ cpus_count += static_cast(end - start) + 1;
+ }
+ return cpus_count;
+}
+#endif
+
namespace
{
diff --git a/src/Common/getNumberOfCPUCoresToUse.h b/src/Common/getNumberOfCPUCoresToUse.h
index e17400328583..08a5635c279b 100644
--- a/src/Common/getNumberOfCPUCoresToUse.h
+++ b/src/Common/getNumberOfCPUCoresToUse.h
@@ -1,6 +1,14 @@
#pragma once
+#include
+#include
+#include
+
/// Get the number of CPU cores to use. Depending on the machine size we choose
/// between the number of physical and logical cores.
/// Also under cgroups we respect possible cgroups limits.
unsigned getNumberOfCPUCoresToUse();
+
+/// Parse a kernel cpu-list such as "0-15" or "0,2-4,7" (the format of /sys/devices/system/cpu/* and
+/// cgroup cpuset files) and return the number of CPUs in it, or nullopt if the text is not a cpu-list.
+std::optional countCPUsInList(const std::string & cpu_list);
diff --git a/src/Common/maskURIPassword.h b/src/Common/maskURIPassword.h
index 81559987db59..bb12e94c48c2 100644
--- a/src/Common/maskURIPassword.h
+++ b/src/Common/maskURIPassword.h
@@ -159,10 +159,11 @@ inline bool maskURIUserinfo(std::string & url)
}
/** Mask the values of the query parameters that carry credentials in a presigned URL, so that
- * `...?X-Amz-Signature=abc&foo=1` becomes `...?X-Amz-Signature=[HIDDEN]&foo=1`. Every occurrence
- * is masked. Returns whether anything was masked.
+ * `...?X-Amz-Signature=abc&foo=1` becomes `...?X-Amz-Signature=[HIDDEN]&foo=1`, and of the
+ * `connection_string` parameter of an ODBC/JDBC bridge request. Every occurrence is masked.
+ * Returns whether anything was masked.
*
- * This used to be the regular expression
+ * Apart from `connection_string`, this used to be the regular expression
* `([?&](?:AWSAccessKeyId|Signature|Expires|GoogleAccessId|X-Amz-[A-Za-z0-9\-]*|X-Goog-[A-Za-z0-9\-]*)=)[^]*`
* rewritten to `\1[HIDDEN]` globally. The parameter set mirrors
* `BackupInfo::removeCredentialsFromS3URL`. Matching is case-sensitive, as in the expression, and
@@ -175,6 +176,9 @@ inline bool maskPresignedURLParameters(std::string & url)
auto is_secret_parameter = [](std::string_view name)
{
+ if (name == "connection_string")
+ return true;
+
for (auto exact : exact_names)
if (name == exact)
return true;
diff --git a/src/Common/mysqlxx/Connection.cpp b/src/Common/mysqlxx/Connection.cpp
index 281f8f33c9be..e54f286ab7b1 100644
--- a/src/Common/mysqlxx/Connection.cpp
+++ b/src/Common/mysqlxx/Connection.cpp
@@ -112,6 +112,12 @@ void Connection::connect(const char* db,
if (mysql_options(driver.get(), MYSQL_OPT_RECONNECT, reinterpret_cast(&opt_reconnect)))
throw ConnectionFailed(errorMessage(driver.get()), mysql_errno(driver.get()));
+ /// Generated queries escape string literals with backslashes, so `NO_BACKSLASH_ESCAPES` must be off: with it, a quote
+ /// escaped as `\'` ends the literal. The library runs this command on every connect, including automatic reconnects.
+ if (mysql_options(driver.get(), MYSQL_INIT_COMMAND,
+ "SET sql_mode = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', @@sql_mode, ','), ',NO_BACKSLASH_ESCAPES,', ','))"))
+ throw ConnectionFailed(errorMessage(driver.get()), mysql_errno(driver.get()));
+
/// Enable classic MySQL protocol compression if requested.
if (enable_compression && mysql_options(driver.get(), MYSQL_OPT_COMPRESS, nullptr))
throw ConnectionFailed(errorMessage(driver.get()), mysql_errno(driver.get()));
@@ -120,6 +126,15 @@ void Connection::connect(const char* db,
if (mysql_ssl_set(driver.get(), ifNotEmpty(ssl_key), ifNotEmpty(ssl_cert), ifNotEmpty(ssl_ca), nullptr, nullptr))
throw ConnectionFailed(errorMessage(driver.get()), mysql_errno(driver.get()));
+ /// With a CA the server certificate is verified anyway. This also makes the library refuse a server that does not
+ /// offer TLS before it sends the credentials, instead of going on without TLS.
+ if (ifNotEmpty(ssl_ca))
+ {
+ my_bool verify_server_cert = 1;
+ if (mysql_options(driver.get(), MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify_server_cert))
+ throw ConnectionFailed(errorMessage(driver.get()), mysql_errno(driver.get()));
+ }
+
/// Without an explicit socket, use TCP to the given port: otherwise `localhost` goes to the library's default socket.
if (!ifNotEmpty(socket))
{
diff --git a/src/Common/mysqlxx/Query.cpp b/src/Common/mysqlxx/Query.cpp
index babfc8c7c41d..1079c9c7789c 100644
--- a/src/Common/mysqlxx/Query.cpp
+++ b/src/Common/mysqlxx/Query.cpp
@@ -52,6 +52,10 @@ void Query::executeImpl()
{
MYSQL* mysql_driver = conn->getDriver();
+ /// See `Connection::connect`: the session reports `NO_BACKSLASH_ESCAPES` if something turned it on again.
+ if (mysql_driver->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
+ throw Exception("The MySQL session has NO_BACKSLASH_ESCAPES in sql_mode, which is not supported");
+
LOG_TRACE(getLogger("mysqlxx::Query"), "Running MySQL query using connection {}", mysql_thread_id(mysql_driver));
if (mysql_real_query(mysql_driver, query.data(), query.size()))
{
diff --git a/src/Common/tests/gtest_thread_pool_lifo.cpp b/src/Common/tests/gtest_thread_pool_lifo.cpp
index 268ed6df1da2..5a66d136a1cb 100644
--- a/src/Common/tests/gtest_thread_pool_lifo.cpp
+++ b/src/Common/tests/gtest_thread_pool_lifo.cpp
@@ -160,7 +160,7 @@ TEST(ThreadPool, LIFOSchedulesOnMostRecentlyIdleThread)
/// `pool.wait` returns only after the worker that completed the last job
/// has pushed itself onto the idle stack: the worker holds `pool.mutex`
- /// continuously from notifying `job_finished` through the idle push, and
+ /// continuously from notifying `all_jobs_finished` through the idle push, and
/// `pool.wait` reacquires that mutex before returning. So once `pool.wait`
/// returns, both workers are parked in the idle stack.
pool.wait();
diff --git a/src/Common/tests/gtest_thread_pool_many_schedulers.cpp b/src/Common/tests/gtest_thread_pool_many_schedulers.cpp
new file mode 100644
index 000000000000..0cc3fbcc2e3d
--- /dev/null
+++ b/src/Common/tests/gtest_thread_pool_many_schedulers.cpp
@@ -0,0 +1,46 @@
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+namespace CurrentMetrics
+{
+ extern const Metric LocalThread;
+ extern const Metric LocalThreadActive;
+ extern const Metric LocalThreadScheduled;
+}
+
+/// Many threads wait in `scheduleImpl` for a slot of a full pool, and a finished job wakes only one of them.
+/// Every job must still be scheduled and run.
+TEST(ThreadPool, ManySchedulersOnFullPool)
+{
+ constexpr size_t num_schedulers = 32;
+ constexpr size_t jobs_per_scheduler = 1000;
+
+ ThreadPool pool(CurrentMetrics::LocalThread, CurrentMetrics::LocalThreadActive, CurrentMetrics::LocalThreadScheduled,
+ /* max_threads */ 2, /* max_free_threads */ 0, /* queue_size */ 2);
+
+ /// The global pool is created lazily without synchronization, so create it before the schedulers start threads in it.
+ GlobalThreadPool::instance();
+
+ std::atomic counter = 0;
+ std::vector schedulers;
+ for (size_t i = 0; i < num_schedulers; ++i)
+ {
+ schedulers.emplace_back([&]
+ {
+ for (size_t j = 0; j < jobs_per_scheduler; ++j)
+ pool.scheduleOrThrowOnError([&] { ++counter; });
+ });
+ }
+
+ for (auto & scheduler : schedulers)
+ scheduler.join();
+ pool.wait();
+
+ EXPECT_EQ(counter, num_schedulers * jobs_per_scheduler);
+}
diff --git a/src/Compression/CachedCompressedReadBuffer.cpp b/src/Compression/CachedCompressedReadBuffer.cpp
index e2f6b87b43f8..7b15fd9117eb 100644
--- a/src/Compression/CachedCompressedReadBuffer.cpp
+++ b/src/Compression/CachedCompressedReadBuffer.cpp
@@ -30,6 +30,10 @@ void CachedCompressedReadBuffer::initInput()
void CachedCompressedReadBuffer::prefetch(Priority priority)
{
+ /// The next block is served from the cache without touching the file, see `nextImpl`.
+ if (cache->contains(UncompressedCache::hash(path, file_pos)))
+ return;
+
initInput();
file_in->prefetch(priority);
}
diff --git a/src/Core/BaseSettings.cpp b/src/Core/BaseSettings.cpp
index 01c77b06e63d..cf09441e91a7 100644
--- a/src/Core/BaseSettings.cpp
+++ b/src/Core/BaseSettings.cpp
@@ -1,4 +1,5 @@
#include
+#include
#include
#include
#include
@@ -127,6 +128,15 @@ void BaseSettingsHelpers::warningSettingNotFound(std::string_view name)
}
}
+bool BaseSettingsHelpers::skipInvalidSettingValue(std::string_view name, const Exception & e)
+{
+ if (e.code() != ErrorCodes::BAD_ARGUMENTS && !isParseError(e.code()))
+ return false;
+
+ LOG_WARNING(getLogger("Settings"), "Cannot parse the value of setting `{}`, skipping it: {}", name, e.message());
+ return true;
+}
+
void BaseSettingsHelpers::flushWarnings()
{
unknown_settings.clear();
diff --git a/src/Core/BaseSettings.h b/src/Core/BaseSettings.h
index c3028b8eb6d1..929d1bdccb3b 100644
--- a/src/Core/BaseSettings.h
+++ b/src/Core/BaseSettings.h
@@ -60,6 +60,8 @@ struct BaseSettingsHelpers
[[noreturn]] static void throwValuelessSettingIsNotBool(std::string_view name);
[[noreturn]] static void throwValuelessSettingHasValue(std::string_view name);
static void warningSettingNotFound(std::string_view name);
+ /// Returns true (and logs a warning) if `e` is `BAD_ARGUMENTS` or a parse error (`isParseError`); other errors are not skipped.
+ static bool skipInvalidSettingValue(std::string_view name, const Exception & e);
static void flushWarnings();
/// Serialization helpers
@@ -306,8 +308,9 @@ class BaseSettings : public TTraits::Data
/// Write all settings (or only changed ones depending on format)
void write(WriteBuffer & out, SettingsWriteFormat format = SettingsWriteFormat::DEFAULT) const;
- /// Read settings from a buffer
- void read(ReadBuffer & in, SettingsWriteFormat format = SettingsWriteFormat::DEFAULT);
+ /// Read settings from a buffer.
+ /// With `skip_invalid_values`, a non-important setting whose value is rejected keeps its default instead of failing the read.
+ void read(ReadBuffer & in, SettingsWriteFormat format = SettingsWriteFormat::DEFAULT, bool skip_invalid_values = false);
/// Write only changed settings in binary format
void writeChangedBinary(WriteBuffer & out) const;
@@ -773,7 +776,7 @@ void BaseSettings::readBinary(ReadBuffer & in)
}
template
-void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format)
+void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format, bool skip_invalid_values)
{
resetToDefault();
const auto & accessor = Traits::Accessor::instance();
@@ -810,7 +813,20 @@ void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format)
accessor.setValue(*this, index, static_cast(temp));
}
else if (format >= SettingsWriteFormat::STRINGS_WITH_FLAGS)
- accessor.setValueString(*this, index, BaseSettingsHelpers::readString(in));
+ {
+ String value = BaseSettingsHelpers::readString(in);
+ try
+ {
+ accessor.setValueString(*this, index, value);
+ }
+ catch (const Exception & e)
+ {
+ if (!skip_invalid_values || is_important || !BaseSettingsHelpers::skipInvalidSettingValue(name, e))
+ throw;
+ /// A failed parse may have assigned the field already.
+ accessor.resetValueToDefault(*this, index);
+ }
+ }
else
accessor.readBinary(*this, index, in);
}
diff --git a/src/Core/Block.cpp b/src/Core/Block.cpp
index 78ca84e6bb16..ac629ef763f4 100644
--- a/src/Core/Block.cpp
+++ b/src/Core/Block.cpp
@@ -993,6 +993,27 @@ bool blocksHaveEqualStructure(const Block & lhs, const Block & rhs)
}
+bool blocksHaveIdenticalStructure(const Block & lhs, const Block & rhs)
+{
+ size_t columns = lhs.columns();
+ if (rhs.columns() != columns)
+ return false;
+
+ for (size_t i = 0; i < columns; ++i)
+ {
+ const auto & left = lhs.getByPosition(i);
+ const auto & right = rhs.getByPosition(i);
+
+ if (left.name != right.name
+ || !left.type || !right.type || !left.type->equals(*right.type)
+ || !left.column || !right.column || !left.column->structureEquals(*right.column))
+ return false;
+ }
+
+ return true;
+}
+
+
void assertBlocksHaveEqualStructure(const Block & lhs, const Block & rhs, std::string_view context_description)
{
checkBlockStructure(lhs, rhs, context_description, false);
diff --git a/src/Core/Block.h b/src/Core/Block.h
index 8c98ef05694d..e34d34924bcd 100644
--- a/src/Core/Block.h
+++ b/src/Core/Block.h
@@ -205,6 +205,13 @@ void assertBlocksHaveEqualStructure(const Block & lhs, const Block & rhs, std::s
void assertBlocksHaveEqualStructureAllowReplicated(const Block & lhs, const Block & rhs, std::string_view context_description);
+/// Compare the number, the names and the types of the columns, and the columns themselves with `IColumn::structureEquals`,
+/// so, unlike for `blocksHaveEqualStructure`, a column in a special representation (e.g. sparse) differs from an
+/// ordinary column of the same type. It is the check for a block from an untrusted source (e.g. another server)
+/// before its columns are appended to the columns of another block or cast to their classes.
+/// Both blocks must have the columns.
+bool blocksHaveIdenticalStructure(const Block & lhs, const Block & rhs);
+
/// Actual header is compatible to desired if block have equal structure except constants.
/// It is allowed when column from actual header is constant, but in desired is not.
/// If both columns are constant, it is checked that they have the same value.
diff --git a/src/Core/Field.cpp b/src/Core/Field.cpp
index 6e3de2b8dbe5..bdb48c55848b 100644
--- a/src/Core/Field.cpp
+++ b/src/Core/Field.cpp
@@ -632,29 +632,40 @@ void writeText(const CustomType & x, WriteBuffer & buf)
template
void readQuoted(DecimalField & x, ReadBuffer & buf)
{
- assertChar('\'', buf);
+ String text;
+ readQuotedString(text, buf);
+ ReadBufferFromString in(text);
T value{};
- UInt32 scale = 0;
int32_t exponent = 0;
uint32_t max_digits = static_cast(-1);
- readDigits(buf, value, max_digits, exponent, true);
- if (exponent > 0)
+ bool has_digits = false;
+ if (!text.empty())
+ readDigits(in, value, max_digits, exponent, true, &has_digits);
+ if (!has_digits || !in.eof())
+ throw Exception(ErrorCodes::CANNOT_PARSE_NUMBER, "Cannot parse decimal dump '{}'", text);
+
+ /// `readDigits` drops trailing fractional zeroes, but the dump writes them to keep the scale.
+ size_t mantissa_end = std::min(text.find_first_of("eE"), text.size());
+ uint32_t trailing_zeroes = 0;
+ if (text.find('.') < mantissa_end)
+ while (text[mantissa_end - 1 - trailing_zeroes] == '0')
+ ++trailing_zeroes;
+ if (!mulPow10AddChecked(value.value, trailing_zeroes, typename T::NativeType(0)))
+ throw Exception(ErrorCodes::DECIMAL_OVERFLOW, "Decimal math overflow");
+
+ /// An out-of-range scale overruns the decimal text writer.
+ Int64 total_exponent = static_cast(exponent) - trailing_zeroes;
+ UInt32 scale = 0;
+ if (total_exponent > 0)
{
- scale = 0;
- if (common::mulOverflow(value.value, DecimalUtils::scaleMultiplier(exponent), value.value))
+ if (!mulPow10AddChecked(value.value, static_cast(std::min