@@ -21,22 +21,33 @@ nullability propagation. Database-specific common-type algorithms belong to
2121the engine: SQL Server's precedence, length and decimal rules live in
2222` internal/engine/mssql/typepolicy ` , independent of its parser.
2323
24- ` set_operations.strategy ` in a dialect's ` dialect.json ` explicitly selects an
25- implemented policy (currently only ` "mssql" ` ). The remaining fields configure
26- that SQL Server policy; they are not a universal coercion language. Seeds
27- reject missing or unsupported strategies rather than accidentally applying
28- SQL Server's formula to another engine. The selector is serialized in the
29- catalog, so cache restores use the same policy as freshly seeded catalogs.
30- Omitting ` set_operations ` preserves the old inference fallback.
31-
32- To support another dialect, add its engine-owned policy and explicit
33- dispatch/seed validation, then opt in its dialect settings and add end-to-end
34- cases. Do not copy SQL Server's settings into other seeds. Some engines need
35- the entire candidate list, cast context, domain information or recursive
36- structured types; extend the policy inputs/orchestration for those semantics
37- rather than forcing them through pairwise precedence. Set operations and
38- ` CASE ` -like expressions need not share one algorithm. The current cross-engine
39- gaps and database references are in
24+ ` core.TypeCombiner ` receives an operation context and the entire ordered list
25+ of candidate types, retaining nil entries for untyped values. It returns a
26+ type and an explicit ` Handled ` flag; declining a context preserves the old
27+ inference fallback, while an error is propagated. Engines without a combiner
28+ keep their existing behavior. ` Prepare ` accepts the combiner through an
29+ optional analyzer option, inherited by nested queries.
30+
31+ The compiler's existing engine assembly selects an optional combiner factory.
32+ It calls that factory after ` core.NewCached ` returns, on both fresh and
33+ restored catalogs, and passes the instance to analysis. No engine names,
34+ imports or strategy registry are needed in shared core analysis or seeding.
35+ Combiners must allow concurrent analysis and must not mutate candidate types.
36+
37+ ` set_operations ` in ` dialect.json ` is opaque JSON to shared seeding. Its schema
38+ and validation belong to the engine implementation; SQL Server's precedence
39+ and decimal settings are not a universal coercion language. Only the data is
40+ cached; runtime behavior is constructed afresh. Malformed configuration fails
41+ in the engine factory, and configuration without a provider is a setup error.
42+
43+ To support another dialect, implement its combiner and wire its factory at
44+ the compiler's engine assembly, without editing shared policy dispatch or
45+ validation. Add end-to-end cases rather than copying SQL Server's settings.
46+ Some engines additionally need literal/domain metadata or recursive structured
47+ types; extend the inputs for actual implementations rather than forcing those
48+ semantics through pairwise precedence. Set operations and ` CASE ` -like
49+ expressions need not share an algorithm. The current cross-engine gaps and
50+ database references are in
4051[ ` analyze ` ] ( ../howto/analyze.md#common-type-inference ) .
4152
4253SQL Server's converter also performs syntax/semantic lowering before seeded
0 commit comments