Skip to main content

uqa_sql/type_resolution/
mod.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Static SQL type propagation and PostgreSQL-compatible common-type rules.
8
9use crate::ast::{ColumnType, FunctionBinding};
10use crate::{SQLError, SQLParam};
11
12use crate::schema::ScalarTypeSchema;
13use crate::{RowSchema, ScalarExpr};
14use uqa_core::Value;
15
16mod array_transform;
17pub(crate) use array_transform::{
18    resolve_array_transform_call_with_control, ArrayTransformArguments,
19};
20pub(crate) mod between;
21pub(crate) mod boolean;
22pub(crate) use array_transform::resolve_array_transform_call;
23mod call;
24pub use call::{FunctionBindingParts, OwnedBindingCall};
25mod cast_compatibility;
26mod checksum;
27mod common;
28pub(crate) use common::common_context_expression_type_with_control;
29pub(crate) use common::{function_arguments_have_runtime_types_with_control, runtime_input};
30pub(crate) use common::{parameter_type_matches, parameter_type_with_control};
31pub(crate) mod concatenation;
32pub(crate) use common::literal_input_type_with_control;
33pub use common::runtime_value_type_with_control;
34pub(crate) use common::value_type;
35pub(crate) use common::value_type_with_control;
36pub(crate) use common::{array_element_type, base_type};
37pub(crate) use common::{
38    select_common_input_type_in_with_control, select_common_input_type_with_control,
39};
40mod containment;
41pub(crate) mod enums;
42mod equality;
43pub(crate) mod field_selection;
44pub use field_selection::relation_column as relation_field_column;
45pub use field_selection::relation_column_ref as relation_field_column_ref;
46mod fixed_builtin;
47#[cfg(test)]
48pub(crate) use fixed_builtin::overloads as fixed_builtin_overloads;
49pub(crate) use fixed_builtin::overloads_with_control as fixed_builtin_overloads_with_control;
50pub(crate) use fixed_builtin::resolve_fixed_builtin_call_with_control;
51pub(crate) use overload_resolution::builtin_binding_matches_with_control;
52mod function_inputs;
53mod functions;
54pub(crate) use function_inputs::{call_type_from_observations_with_control, CallInputTypes};
55pub(crate) use functions::builtin_function_argument_targets_with_control;
56pub(crate) use functions::builtin_function_type_with_resolver_and_control;
57mod gamma;
58mod inference;
59mod production;
60use inference::scalar_type_inner_with_control;
61mod introspection;
62pub(crate) use introspection::bind_stored_inputs_owned;
63pub(crate) mod json_path;
64mod json_strip;
65mod length;
66mod md5;
67pub(crate) mod membership;
68mod operator_errors;
69pub(crate) mod row_comparison;
70pub(crate) mod row_distinct;
71pub use operator_errors::{
72    ambiguous_binary_operator, ambiguous_prefix_operator, undefined_binary_operator,
73    undefined_binary_operator_named, undefined_prefix_operator,
74};
75mod operators;
76pub(crate) use operators::comparison::ComparisonSupport;
77pub use operators::comparison::{
78    comparison_key_is_constant, equality_types_share_hash_key, type_supports_hashing,
79    type_supports_ordering, ComparisonKeySupport,
80};
81mod overload_resolution;
82pub use overload_resolution::canonical_routine_type_name_with_control;
83pub(crate) use overload_resolution::resolve_local_builtin_call_with_control;
84mod qualified_column;
85mod range;
86mod range_offsets;
87pub use range_offsets::range_frame_offset_type;
88mod reverse;
89mod routine_signature;
90mod scalar_input;
91mod stored_constants;
92pub use scalar_input::{
93    scalar_array_element_oid_with_control, scalar_array_element_type_with_control,
94    scalar_array_input_type_with_control, scalar_cast_source_type_name_with_control,
95    scalar_integer_operation_width, scalar_integer_operation_width_with_control,
96    scalar_operand_type_name, scalar_operand_type_name_with_control,
97    scalar_operand_type_with_engine_and_control, scalar_record_field_type_with_control,
98};
99pub(crate) use stored_constants::store_syntax_operand_coercions;
100pub use stored_constants::{
101    contains_unknown_literal, fold_stored_enum_constants, store_operand_coercions,
102    stored_enum_constant,
103};
104pub(crate) mod pattern;
105mod string_binary;
106
107pub use cast_compatibility::{
108    assignment_type_compatible, assignment_type_compatible_with_control, cast_catalog_entry,
109    cast_volatility, cast_volatility_with_control, explicit_type_compatible, immutable_cast_type,
110    pg_catalog_builtin_type, pg_catalog_builtin_type_with_control, CastCatalogEntry, CastMethod,
111};
112pub(crate) use cast_compatibility::{cast_catalog_entry_with_control, preserves_record_identity};
113#[doc(hidden)]
114pub use checksum::{resolve_checksum_overload, ResolvedChecksumOverload};
115pub(crate) use common::effective_overload_argument_type_ref_with_params;
116pub use common::{
117    common_context_expression_type, common_type, common_type_in, common_type_in_with_control,
118    effective_overload_argument_type, effective_overload_argument_type_with_params,
119    function_call_argument_signature, function_call_argument_signature_with_control,
120    select_common_input_type, values_column_types, CommonTypeContext,
121    FunctionCallArgumentSignature,
122};
123pub use equality::{
124    equality_operand_type, equality_operand_type_with_control, foreign_key_operand_type,
125};
126pub(crate) use fixed_builtin::resolve_syntax_binding_with_control as resolve_fixed_syntax_binding_with_control;
127#[doc(hidden)]
128pub use fixed_builtin::{
129    fixed_builtin_return_type, fixed_builtin_return_type_with_control,
130    is_function as is_fixed_builtin, resolve_fixed_builtin_call, selected_builtin_dispatch,
131    ResolvedFixedBuiltinCall,
132};
133pub use functions::{
134    builtin_function_argument_targets, builtin_function_type, builtin_function_type_with_resolver,
135};
136#[doc(hidden)]
137pub use gamma::{resolve_gamma_overload, ResolvedGammaOverload};
138pub use introspection::{
139    bind_type_introspection, bind_type_introspection_owned, bind_type_introspection_with_control,
140    bind_type_introspection_with_resolver, validate_catalog_literals,
141    validate_catalog_literals_with_control,
142};
143#[doc(hidden)]
144pub use json_strip::{resolve_json_strip_overload, ResolvedJsonStripOverload};
145#[doc(hidden)]
146pub use length::{resolve_length_overload, ResolvedLengthOverload};
147#[doc(hidden)]
148pub use md5::{resolve_md5_overload, ResolvedMd5Overload};
149#[doc(hidden)]
150pub use operators::{
151    binary_operator_by_oid, binary_operator_catalog_entry, binary_operator_types,
152    binary_operator_types_with_control, binary_operator_volatility,
153    binary_operator_volatility_with_control, binary_result_type, binary_result_type_with_control,
154    numeric_operator_types, numeric_operator_types_with_control, require_equality_operator,
155    require_ordering_operator, unary_minus_catalog_entry, unary_operator_by_oid,
156    BinaryOperatorCatalogEntry, NumericOperatorTypes, UnaryOperatorCatalogEntry,
157};
158pub(crate) use operators::{
159    named_binary_operator_catalog_entry, named_binary_operator_types,
160    named_binary_operator_types_with_control,
161};
162#[doc(hidden)]
163pub use overload_resolution::{
164    builtin_binding_matches, builtin_name_matches, canonical_column_type_name,
165    canonical_routine_type_name, function_resolution_error, match_builtin_function_call,
166    match_builtin_function_overload, match_function_signature, parse_enum_type_identity,
167    rank_function_matches, resolve_local_builtin_overload, routine_type_accepts_implicit_cast,
168    routine_type_category, routine_type_is_preferred, FunctionParameterDescriptor,
169    MatchedBuiltinFunction, MatchedFunctionSignature, RankedFunctionMatch,
170};
171pub(crate) use overload_resolution::{
172    match_builtin_with_control, rank_function_matches_with_control, Candidates, RankingCandidates,
173};
174#[doc(hidden)]
175pub use reverse::{resolve_reverse_overload, ResolvedReverseOverload};
176#[doc(hidden)]
177pub(crate) use routine_signature::{
178    match_routine_candidate, match_routine_candidate_with_control,
179    routine_polymorphic_type_with_control, RoutineInvocationParts, RoutineSignatureProductionError,
180};
181pub use routine_signature::{
182    match_routine_signature, routine_polymorphic_type, MatchedRoutineSignature,
183    RoutineCallDescriptor, RoutineCoercionTarget, RoutineParameterDescriptor,
184    RoutinePolymorphicFamily, RoutinePolymorphicType, RoutineSignatureMatchError,
185    RoutineTypeSubstitutions, RoutineVariadicMode, RoutineVariadicPlan,
186};
187#[doc(hidden)]
188pub use string_binary::{ResolvedStringBinaryOverload, ResolvedTextByteaOverload};
189
190pub trait FunctionTypeResolver: Send + Sync {
191    /// Format a selected type using the binding catalog's namespace visibility.
192    fn format_type_name(&self, ty: &ColumnType) -> Result<String, SQLError> {
193        Ok(ty.sql_name())
194    }
195
196    /// Retain a custom resolver's result in the caller's allowance. Native catalogs override this method to admit their own construction rather than copy an external result.
197    fn format_type_name_with_control(
198        &self,
199        ty: &ColumnType,
200        control: &uqa_core::memory::ProductionControl<'_>,
201    ) -> Result<uqa_core::memory::Produced<String>, SQLError> {
202        control.check()?;
203        let name = self.format_type_name(ty)?;
204        if control.budget().is_none() {
205            Ok(control.finish(name, None)?)
206        } else {
207            control.copy_text(&name).map_err(Into::into)
208        }
209    }
210
211    /// The default adapts an external catalog's owned result; project-owned catalogs admit their result in the producing implementation.
212    fn resolve_type_name_with_control(
213        &self,
214        name: &str,
215        control: &uqa_core::memory::ProductionControl<'_>,
216    ) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
217        control.check()?;
218        production::external_type(self.resolve_type_name(name)?, control)
219    }
220
221    /// Return whether an external runtime callback claims this unbound function
222    /// name without exposing a declared SQL return type. Such callbacks must
223    /// retain dispatch precedence instead of being rebound to a same-named
224    /// built-in overload.
225    fn has_untyped_function(&self, _name: &str) -> bool {
226        false
227    }
228
229    /// Observe an external callback's dispatch precedence while retaining invoking cancellation. Native catalogs override this callback to admit any name normalization before allocation.
230    fn has_untyped_function_with_control(
231        &self,
232        name: &str,
233        control: &uqa_core::memory::ProductionControl<'_>,
234    ) -> Result<bool, SQLError> {
235        control.check()?;
236        let untyped = self.has_untyped_function(name);
237        control.check()?;
238        Ok(untyped)
239    }
240
241    /// Resolve a catalog-owned SQL type name that is not represented by the
242    /// built-in [`ColumnType::from_sql_name`] mapping, such as a domain.
243    fn resolve_type_name(&self, _name: &str) -> Result<Option<ColumnType>, SQLError> {
244        Ok(None)
245    }
246
247    /// Resolve an explicit collation name with the binding catalog's namespace visibility and privileges.
248    fn resolve_collation_name(&self, _name: &str) -> Result<Option<u32>, SQLError> {
249        Ok(None)
250    }
251
252    /// Native catalogs admit namespace parsing and lookup scratch in this scope; the default adapts an external resolver's inline result.
253    fn resolve_collation_name_with_control(
254        &self,
255        name: &str,
256        control: &uqa_core::memory::ProductionControl<'_>,
257    ) -> Result<Option<u32>, SQLError> {
258        control.check()?;
259        let selected = self.resolve_collation_name(name)?;
260        control.check()?;
261        Ok(selected)
262    }
263
264    /// Enum labels of the binding catalog. Binding converts `unknown` literals coerced to an enum type with them, as `PostgreSQL` parse analysis calls the type's input function.
265    fn enum_labels(&self) -> Option<&dyn crate::expr::enums::EnumLabelCatalog> {
266        None
267    }
268
269    /// Input functions whose catalog constraints must run when an unknown literal is analyzed. Callers retain the returned constant; metadata-only inference does not invoke this capability.
270    fn catalog_input_functions(&self) -> Option<&dyn crate::expr::CatalogInputFunctions> {
271        None
272    }
273
274    /// Composite type attributes of the binding catalog, which type field selections and row coercions.
275    fn composite_types(&self) -> Option<&dyn crate::expr::composites::CompositeTypeCatalog> {
276        None
277    }
278
279    /// Require the current user's `USAGE` privilege on a type that a relation column, domain or routine declares, as `object_aclcheck(TypeRelationId, ..., ACL_USAGE)` and `aclcheck_error_type` require it; see [`crate::catalog::security::type_inquiry::usage_governing_type`]. A resolver without roles and type privileges has nothing to deny.
280    fn require_type_usage(&self, _ty: &ColumnType) -> Result<(), SQLError> {
281        Ok(())
282    }
283
284    fn resolve_function_type(
285        &self,
286        name: &str,
287        binding: Option<&FunctionBinding>,
288        argument_names: &[Option<String>],
289        argument_types: &[Option<ColumnType>],
290        explicit_variadic: bool,
291    ) -> Result<Option<ColumnType>, SQLError>;
292
293    fn resolve_function_type_with_control(
294        &self,
295        name: &str,
296        binding: Option<&FunctionBinding>,
297        argument_names: &[Option<String>],
298        argument_types: &[Option<ColumnType>],
299        explicit_variadic: bool,
300        control: &uqa_core::memory::ProductionControl<'_>,
301    ) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
302        control.check()?;
303        production::external_type(
304            self.resolve_function_type(
305                name,
306                binding,
307                argument_names,
308                argument_types,
309                explicit_variadic,
310            )?,
311            control,
312        )
313    }
314
315    fn resolve_function_overload_with_control(
316        &self,
317        name: &str,
318        binding: Option<&FunctionBinding>,
319        argument_names: &[Option<String>],
320        argument_types: &[Option<ColumnType>],
321        explicit_variadic: bool,
322        control: &uqa_core::memory::ProductionControl<'_>,
323    ) -> Result<Option<uqa_core::memory::Produced<ResolvedFunctionOverload>>, SQLError> {
324        control.check()?;
325        production::external_overload(
326            self.resolve_function_overload(
327                name,
328                binding,
329                argument_names,
330                argument_types,
331                explicit_variadic,
332            )?,
333            control,
334        )
335    }
336
337    #[expect(
338        clippy::too_many_arguments,
339        reason = "the external resolver keeps its established call fields and adds the invoking production control"
340    )]
341    fn resolve_function_overload_with_builtins_and_control(
342        &self,
343        name: &str,
344        binding: Option<&FunctionBinding>,
345        argument_names: &[Option<String>],
346        argument_types: &[Option<ColumnType>],
347        explicit_variadic: bool,
348        builtins: &[BuiltinFunctionOverload],
349        control: &uqa_core::memory::ProductionControl<'_>,
350    ) -> Result<Option<uqa_core::memory::Produced<ResolvedFunctionOverload>>, SQLError> {
351        control.check()?;
352        production::external_overload(
353            self.resolve_function_overload_with_builtins(
354                name,
355                binding,
356                argument_names,
357                argument_types,
358                explicit_variadic,
359                builtins,
360            )?,
361            control,
362        )
363    }
364
365    /// Resolve a catalog-backed overload together with the stable binding needed to execute it after built-in and user-defined candidates have been ranked.
366    fn resolve_function_overload(
367        &self,
368        _name: &str,
369        _binding: Option<&FunctionBinding>,
370        _argument_names: &[Option<String>],
371        _argument_types: &[Option<ColumnType>],
372        _explicit_variadic: bool,
373    ) -> Result<Option<ResolvedFunctionOverload>, SQLError> {
374        Ok(None)
375    }
376
377    /// Return whether an exact catalog-selected binding can execute in a scalar expression. The conservative default prevents aggregate, procedure, and set-returning routines from being attached to [`ScalarExpr::Func`].
378    fn is_scalar_function_binding(&self, _binding: &FunctionBinding) -> Result<bool, SQLError> {
379        Ok(false)
380    }
381
382    /// Resolve the selected routine's execution category in the caller's production scope. Native catalog producers override this boundary; the default adapts an external resolver's boolean callback.
383    fn is_scalar_function_binding_with_control(
384        &self,
385        binding: &FunctionBinding,
386        control: &uqa_core::memory::ProductionControl<'_>,
387    ) -> Result<bool, SQLError> {
388        control.check()?;
389        let scalar = self.is_scalar_function_binding(binding)?;
390        control.check()?;
391        Ok(scalar)
392    }
393
394    /// Resolve catalog-backed routines and the supplied built-in overloads as
395    /// one `PostgreSQL` candidate set. Implementations with catalog visibility
396    /// should override this so search-path shadowing and unknown-category
397    /// selection happen before a winner is chosen.
398    fn resolve_function_overload_with_builtins(
399        &self,
400        name: &str,
401        binding: Option<&FunctionBinding>,
402        argument_names: &[Option<String>],
403        argument_types: &[Option<ColumnType>],
404        explicit_variadic: bool,
405        _builtins: &[BuiltinFunctionOverload],
406    ) -> Result<Option<ResolvedFunctionOverload>, SQLError> {
407        self.resolve_function_overload(
408            name,
409            binding,
410            argument_names,
411            argument_types,
412            explicit_variadic,
413        )
414    }
415
416    fn resolve_scalar_subquery_type_with_control(
417        &self,
418        subquery: crate::SubqueryId,
419        outer_schema: &RowSchema,
420        params: &[SQLParam],
421        control: &uqa_core::memory::ProductionControl<'_>,
422    ) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
423        control.check()?;
424        production::external_type(
425            self.resolve_scalar_subquery_type(subquery, outer_schema, params)?,
426            control,
427        )
428    }
429
430    /// Resolve the declared first-column type of a physical scalar-subquery slot when the owning execution context carries its plan arena.
431    fn resolve_scalar_subquery_type(
432        &self,
433        _subquery: crate::SubqueryId,
434        _outer_schema: &RowSchema,
435        _params: &[SQLParam],
436    ) -> Result<Option<ColumnType>, SQLError> {
437        Ok(None)
438    }
439}
440
441#[derive(Debug, Clone, PartialEq, Eq)]
442pub struct BuiltinFunctionOverload {
443    /// The final declared array parameter accepts expanded elements or an explicit VARIADIC array.
444    pub variadic: bool,
445    pub name: String,
446    pub argument_names: Vec<Option<String>>,
447    pub argument_types: Vec<ColumnType>,
448    pub default_arguments: usize,
449    pub return_type: ColumnType,
450}
451
452#[derive(Debug, Clone, PartialEq, Eq)]
453pub struct ResolvedFunctionOverload {
454    pub binding: FunctionBinding,
455    pub return_type: ColumnType,
456    pub exact_matches: usize,
457    pub known_arguments: usize,
458    pub preferred_matches: usize,
459    pub precedes_pg_catalog: bool,
460}
461
462impl ResolvedFunctionOverload {
463    #[must_use]
464    pub fn is_exact_for_known_arguments(&self) -> bool {
465        self.known_arguments > 0 && self.exact_matches == self.known_arguments
466    }
467}
468
469pub fn scalar_type(
470    expression: &ScalarExpr,
471    schema: &dyn ScalarTypeSchema,
472    params: &[SQLParam],
473) -> Result<Option<ColumnType>, SQLError> {
474    scalar_type_inner(expression, schema, params, None)
475}
476
477/// Infer a scalar type from borrowed schema and parameter metadata while retaining every constructed type and temporary buffer under the supplied allowance.
478pub fn scalar_type_with_control(
479    expression: &ScalarExpr,
480    schema: &dyn ScalarTypeSchema,
481    params: &[SQLParam],
482    control: &uqa_core::memory::ProductionControl<'_>,
483) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
484    scalar_type_inner_with_control(expression, schema, params, None, control)
485}
486
487/// Infer with the same catalog and observations while synthesized metadata retains its producer's allowance.
488pub fn scalar_type_with_resolver_and_control(
489    expression: &ScalarExpr,
490    schema: &dyn ScalarTypeSchema,
491    params: &[SQLParam],
492    resolver: Option<&dyn FunctionTypeResolver>,
493    control: &uqa_core::memory::ProductionControl<'_>,
494) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
495    scalar_type_inner_with_control(expression, schema, params, resolver, control)
496}
497
498/// Preserve unknown-literal and domain rules when selecting an operator's common type without a catalog callback.
499pub fn common_context_type_with_control(
500    expression: &ScalarExpr,
501    schema: &dyn ScalarTypeSchema,
502    params: &[SQLParam],
503    control: &uqa_core::memory::ProductionControl<'_>,
504) -> Result<Option<uqa_core::memory::Produced<ColumnType>>, SQLError> {
505    common::common_context_expression_type_with_control(expression, schema, params, None, control)
506}
507
508pub fn scalar_type_with_resolver(
509    expression: &ScalarExpr,
510    schema: &dyn ScalarTypeSchema,
511    params: &[SQLParam],
512    resolver: &dyn FunctionTypeResolver,
513) -> Result<Option<ColumnType>, SQLError> {
514    scalar_type_inner(expression, schema, params, Some(resolver))
515}
516
517/// A bare string or NULL literal, which `PostgreSQL` types as `unknown` until its context resolves it.
518pub fn is_unknown_literal(expression: &ScalarExpr) -> bool {
519    matches!(expression, ScalarExpr::Literal(Value::Str(_) | Value::Null))
520}
521
522/// Whether a type's input function consults the catalog: the OID alias types and `aclitem` look names up, and an enum, a composite type, a record or a type known by name is read through its catalog definition. Analysis without the catalog leaves such a literal in the cast form that binding or evaluation reads, and reads every other literal with the type's input function.
523pub fn catalog_input_type(ty: &ColumnType) -> bool {
524    match ty {
525        ColumnType::Regproc
526        | ColumnType::Regprocedure
527        | ColumnType::Regclass
528        | ColumnType::Regcollation
529        | ColumnType::Regnamespace
530        | ColumnType::Regrole
531        | ColumnType::Regtype
532        | ColumnType::AclItem
533        | ColumnType::PgNodeTree
534        | ColumnType::Named(_)
535        | ColumnType::Enum(_)
536        | ColumnType::Composite(_)
537        | ColumnType::Record
538        | ColumnType::AnyArray
539        | ColumnType::Vector(_)
540        | ColumnType::Tensor(_) => true,
541        ColumnType::Array(inner) | ColumnType::Domain { base: inner, .. } => {
542            catalog_input_type(inner)
543        }
544        _ => false,
545    }
546}
547
548/// Whether value operations can require live catalog metadata: enum identities, record fields and their array/domain containers cannot be evaluated by a catalog-free scalar implementation. OID aliases have already decoded their names and operate on ordinary integer values.
549#[must_use]
550pub fn catalog_value_type(ty: &ColumnType) -> bool {
551    match ty {
552        ColumnType::Named(_)
553        | ColumnType::Enum(_)
554        | ColumnType::Composite(_)
555        | ColumnType::Record
556        | ColumnType::AnyArray => true,
557        ColumnType::Array(inner) | ColumnType::Domain { base: inner, .. } => {
558            catalog_value_type(inner)
559        }
560        _ => false,
561    }
562}
563
564/// The type of an assignment's source before coercion to its destination. A bare string or NULL literal has none: `transformAssignedExpr` and `transformAssignmentIndirection` convert it with the destination type's input function instead of checking a source type, so `'7'` assigns to an integer array element and `'abc'` fails as integer input.
565pub fn assignment_source_type(
566    expression: &ScalarExpr,
567    schema: &dyn ScalarTypeSchema,
568    params: &[SQLParam],
569    resolver: &dyn FunctionTypeResolver,
570) -> Result<Option<ColumnType>, SQLError> {
571    if is_unknown_literal(expression) {
572        return Ok(None);
573    }
574    scalar_type_with_resolver(expression, schema, params, resolver)
575}
576
577pub(super) fn scalar_type_inner(
578    expression: &ScalarExpr,
579    schema: &dyn ScalarTypeSchema,
580    params: &[SQLParam],
581    resolver: Option<&dyn FunctionTypeResolver>,
582) -> Result<Option<ColumnType>, SQLError> {
583    scalar_type_inner_with_control(
584        expression,
585        schema,
586        params,
587        resolver,
588        &uqa_core::memory::ProductionControl::uncontrolled(),
589    )
590    .map(|ty| {
591        ty.map(|ty| {
592            ty.into_uncontrolled()
593                .expect("ordinary scalar inference has no reservation")
594        })
595    })
596}
597
598#[cfg(test)]
599mod tests;
600
601mod declaration;
602pub use declaration::{
603    resolve_alter_column_type, resolve_declared_column_type,
604    resolve_declared_column_type_with_control,
605};
606
607mod coercion;
608pub mod composite_rows;
609pub use coercion::coerce_common_context_value;