Documentation
¶
Overview ¶
Package sqlstmt holds a statement compiled on first use and reused thereafter (mache-3063fb).
It is its own package because two readers need it and neither may import the other: graph's NodesTableReader, and lloschema's projection-v6 path addressing, which graph imports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lazy ¶
type Lazy struct {
// contains filtered or unexported fields
}
Lazy is a statement compiled on first use and reused thereafter.
The direct read path used to hand database/sql a query STRING on every call, so modernc compiled the same SQL from scratch and discarded it each time — about half of a warm point read once page I/O was out of the way. TestNodesTableReader_CompilesEachStatementOnce pins the fix as a count.
LAZY, deliberately. A reader is constructed against dbs that do not carry every table it can query — a standalone mache projection has no node_refs — and preparing eagerly would fail the constructor where today's code only errors when GetCallers is actually called. Preparing on first use keeps that behaviour exactly: the same call fails, at the same moment, with the same error.
A FAILED prepare is not cached. sync.Once would make one transient failure permanent for the life of the reader; here the next call simply tries again. The fast path is a single atomic load, so the lock is only ever taken by callers racing to compile the statement the first time.