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
//! # Per-destination SQL dialect abstraction
//!
//! External destinations registered via [`crate::config::ConfigBuilder::custom_destination`]
//! (or `use_destination`) can supply their own SQL
//! dialect by overriding
//! [`crate::destinations::destination_factory::DestinationHandler::dialect`].
//!
//! Three integration patterns:
//!
//! 1. **Reuse a built-in dialect** — return a reference to a static instance
//! of one of the five built-ins ([`crate::destinations::dialects::MySqlDialect`],
//! [`crate::destinations::dialects::SqlServerDialect`],
//! [`crate::destinations::dialects::SqliteDialect`],
//! [`crate::destinations::dialects::KafkaDialect`], or
//! [`crate::destinations::dialects::AnsiDialect`]):
//!
//! ```ignore
//! fn dialect(&self) -> &'static dyn SqlDialect {
//! use pg2any_lib::MySqlDialect;
//! static D: MySqlDialect = MySqlDialect;
//! &D
//! }
//! ```
//!
//! 2. **Accept the [`crate::destinations::dialects::AnsiDialect`] default** —
//! do nothing. `DestinationHandler::dialect`'s default impl returns
//! `&AnsiDialect`, which matches the historical `DestinationType::Custom(_)`
//! fallback (double-quoted identifiers, `X'…'` hex, `TRUNCATE TABLE`).
//!
//! 3. **Provide a fully custom dialect** — implement [`SqlDialect`] yourself
//! for your destination's quoting/value/truncate rules. See
//! `examples/src/bin/custom_destination.rs` for a worked example.
//!
//! See docs/superpowers/specs/2026-06-05-destination-dialect-extraction-design.md
//! for design rationale.
use ColumnValue;
/// SQL dialect rules for a destination database.
///
/// Implementations encapsulate quoting, value rendering, and DDL emission
/// differences across destination engines. All methods write into a caller-
/// supplied `String` buffer to avoid per-call allocation.
///
/// The four built-in implementations (`MySqlDialect`, `SqlServerDialect`,
/// `SqliteDialect`, `KafkaDialect`) plus the generic `AnsiDialect` cover the
/// pre-refactor branches that lived inside `TransactionManager`. External
/// destinations registered via `Config::custom_destination` may either reuse
/// one of these or supply their own.
/// Append `bytes` to `out` as ASCII hex digits (no prefix/suffix).
///
/// Shared helper for dialect impls that emit hex literals.
pub