Repository navigation
Commit 1c22d51
committed
goldeneye: read SQLite function signatures from the amalgamation
SQLite records nothing about what its functions return or take, but its
source does, in its way: every function is registered with the C
functions that implement it, and those set their result through
sqlite3_result_* and read their arguments through sqlite3_value_*. So
instead of a hand-written table of signatures, the generator now reads
the amalgamation the shells are built from. It indexes every function
definition, reads the FuncDef macro tables, the sqlite3_create_function
calls and the struct tables extensions walk, follows each implementation
and the helpers it calls for result calls, and reads each argument's
position for value calls. One kind of result is that type; a function
that returns one of its arguments is "any"; integer and real together
widen to real, text and blob together to text; a JSON function's
registration says whether it returns text or JSONB; a function the VDBE
implements in bytecode passes an argument through. A function the shell
reports that the source does not register, or whose implementation sets
no result, fails the run.
Whether an aggregate returns NULL over no rows is found by running each
over none, in one shell process per build. Which scalar functions return
NULL for arguments that are not is what neither the shell nor the source
can say — a SQLite function returns NULL as often by setting no result
as by saying so — so that remains a short list, with the functions the
dialect omits and the one inline function that does not pass an argument
through.
The regenerated dialect differs where the source knows better: ceil,
floor and trunc return real for real input; unixepoch can; format,
printf, instr and length are not nullable for arguments that are not,
and neither are coalesce, iif and their kin; round's second argument
and the math functions' arguments are typed; hex takes a blob.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RYkxvtwH6GgysuWYP87vyj1 parent ea6e341 commit 1c22d51
11 files changed
Lines changed: 812 additions & 369 deletions
File tree
- internal
- endtoend/testdata/builtins/sqlite/go
- engine/sqlite/dialect
- extensions
- enable_fts3
- enable_fts5
- enable_geopoly
- enable_percentile
- goldeneye
- sqlite
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments