Expand description
Function catalog — static table of built-in scalar / aggregate
function signatures used by the Fase 3 expression typer to
resolve Expr::FunctionCall nodes to a concrete return type.
Mirrors PostgreSQL’s pg_proc catalog with a deliberately
narrow row shape: a single (name, arg_types, return_type, kind)
entry per overload. Multiple entries may share the same name —
the resolver picks the one whose argument types match (after
implicit coercion) using the func_select_candidate heuristic
described in the roadmap (parte 4 of the plan file).
The table is const &[FunctionEntry] so it lives in the
read-only segment and lookups stay cache-friendly. Linear
scan is fine for the ~30 entries the catalog covers today.
Future weeks can switch to a HashMap<&'static str, &[…]>
grouped by name when the table grows past ~500 entries.
§Coverage today
Aggregates: COUNT, SUM, AVG, MIN, MAX (the five SQL-standard ones). Each has multiple overloads for the numeric category.
Scalars covered:
- String: UPPER, LOWER, LENGTH, COALESCE
- Math: ABS, ROUND, FLOOR, CEIL
- Time: NOW, CURRENT_TIMESTAMP, CURRENT_DATE, TIME_BUCKET
- Geo: GEO_DISTANCE, GEO_BEARING, HAVERSINE
- Misc: VERIFY_PASSWORD
Variadic functions (COALESCE, GREATEST, LEAST, CONCAT) are
marked with variadic: true and the resolver treats their
arg_types slice as a description of the uniform element
type — the catalog can’t enumerate every arity, so the typer
checks each call-site argument against arg_types[0] instead.
§What’s NOT in this catalog
- User-defined functions (CREATE FUNCTION) — separate runtime table, queried after the static catalog yields no match.
- Polymorphic signatures (anyelement, anyarray) — Fase 3 W4.
- Operator functions backing
+,-,*— those go inpg_operatorequivalent which we haven’t built yet.
Structs§
- Function
Entry - One signature in the static function catalog.
Enums§
- Function
Kind - Function classification — affects resolver behavior and downstream planner cost estimation.
Constants§
- FUNCTION_
CATALOG - The static function catalog. Append-only; removing a row is a breaking change that may invalidate cached plans referencing the function. Each block is grouped by category for readability.
Functions§
- lookup
- Look up a function by name, returning the slice of overloads (possibly empty). The resolver walks this slice and picks the best match using its own coercion logic.
- resolve
- Resolve a function call to the best-matching overload. Returns
Nonewhen no overload matches the call-site argument types (after implicit coercion).