1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Which engine this build carries.
//!
//! Three accessors, each reporting exactly one versioning scheme. Nothing here
//! falls back to another scheme when its own source is unavailable: a chdb-core
//! release number and a ClickHouse version number cannot be compared, so
//! answering one question with the other number is worse than answering with an
//! error.
//!
//! | | scheme | resolved | example |
//! | --- | --- | --- | --- |
//! | [`EXPECTED_ENGINE_VERSION`] | chdb-core | at compile time | `26.7.0` |
//! | [`engine_version`] | chdb-core | by the linked library | `26.7.0` |
//! | [`clickhouse_version`] | ClickHouse | by a query | `26.5.1.1` |
//!
//! A chdb-core release number is not a ClickHouse one: `X.Y` is the ClickHouse
//! minor line the release sits on and `Z` is chdb-core's own counter, so the two
//! agree on the first two fields at most.
use crate;
/// The chdb-core release this build fetched, without the leading `v`.
///
/// `None` when the build linked a library it did not fetch — a `CHDB_LIB_DIR`
/// build, a copy already installed on the machine, a docs.rs build. The pinned
/// version says nothing about an artifact that came from somewhere else, so this
/// reports nothing rather than reporting the pin. [`ENGINE_SOURCE`] says where
/// the library came from, and [`engine_version`] asks the library itself.
///
/// ```no_run
/// use chdb_rust::version::{engine_version, EXPECTED_ENGINE_VERSION};
///
/// // A build that fetched its own engine can check the two agree.
/// if let Some(expected) = EXPECTED_ENGINE_VERSION {
/// assert_eq!(expected, engine_version()?);
/// }
/// # Ok::<(), chdb_rust::error::Error>(())
/// ```
pub const EXPECTED_ENGINE_VERSION: = ;
/// Where the linked library came from, as the build script resolved it.
///
/// One of `download: chdb-core <tag>`, `CHDB_LIB_DIR: <path>`,
/// `local: <path>`, or `none: docs.rs build`. Diagnostic only — the shape is not
/// part of the API.
pub const ENGINE_SOURCE: &str = env!;
/// The chdb-core release the linked library reports, without the leading `v`.
///
/// This is the only accessor that describes the artifact actually loaded, which
/// is what makes it the way to tell which engine a binary carries when the build
/// did not fetch it.
///
/// # Errors
///
/// Returns [`Error::EngineVersionUnavailable`] when the library predates
/// `chdb_version()`, which arrived in chdb-core v26.7.0.
/// The ClickHouse version the linked engine reports, as `SELECT version()` gives
/// it.
///
/// Opens a temporary in-memory connection, the same as [`crate::execute`]. Use
/// `SELECT version()` on a connection you already hold if you have one.