Documentation
¶
Overview ¶
Package sqlval holds the small, self-contained value-semantics helpers that both the SQL engine and its retrieval subpackage need.
It exists to break an import cycle. internal/engine imports internal/engine/search for the FTS/vector/RAG algorithms, so search must not import engine back — yet the algorithms need a handful of leaf helpers (stringify a scalar, compare two raw values, coerce to int, check context cancellation, bound a cache map) that engine also uses in hundreds of places. Duplicating them into search would risk the two copies drifting apart, and valueText in particular has behaviour pinned by a test (TestValueTextMatchesSprintfFloatSweep), so a silent divergence there would change query results rather than fail loudly.
Every function here is a leaf: it depends only on the standard library, never on engine types or state. Anything that fans out into engine's coercion, planning, or evaluation machinery deliberately does NOT belong here.
engine keeps unexported forwarders (valueText, rawEqual, toInt, checkCtx, evictOverCap) so its existing call sites are unchanged and this package stays an implementation detail rather than a new vocabulary every caller must learn.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCtx ¶
CheckCtx returns ctx's error if it has been cancelled, and nil otherwise. A nil context is treated as never cancelled, so callers with no context to thread need no special case.
func EvictOverCap ¶
func EvictOverCap[K comparable, V any](m map[K]V, maxEntries int)
EvictOverCap removes arbitrary entries until the map is below the cap, making room for one more. Go's random map iteration order makes this a cheap pseudo-random eviction policy — deliberately not LRU, since every cache using it re-derives an evicted entry lazily on the next miss.
func RawEqual ¶
RawEqual reports whether two raw storage values are equal, treating the numeric kinds as mutually comparable (int/int64/float64) so a value read back as one kind still matches a literal written as another.
func ValueText ¶
ValueText renders a scalar exactly like fmt.Sprintf("%v", v) but without entering fmt for the types SQL values actually take. Scalar functions coerce arguments to text with this on every call of every row; fmt's reflection walk — and, for strings, its needless copy — dominated their profiles. Types without a fast case (e.g. []byte, whose %v form is the decimal byte list) fall back to fmt to keep output byte-identical.
Types ¶
This section is empty.