interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / AGENTS.md

152 lines · 6220 bytes Raw Blame History Source

AGENTS.md

Guidance for AI coding agents working in this repository.

Project nature

SQLite is a self-contained, serverless SQL database engine written in C. The source is public domain.

SQLite does not accept pull requests without prior agreement and/or accompanying legal paperwork that places the pull request in the public domain. However, the human SQLite developers will review a concise and well-written pull request as a proof-of-concept prior to reimplementing the changes themselves.

Agentic code is acceptable as long as nobody can tell that the code is agentic. The code must looks as if was written by the original human authors of SQLite, with the same coding style, variable naming style, commenting style, and so forth.

SQLite uses the Fossil for version control, not Git. The GitHub repository for SQLite is a mirror and is not canonical. The canonical repository is at https://sqlite.org/src.

To send patches to the SQLite developers, the ideal format is a Fossil patch created using the "fossil patch create" command. The second best approach is an ordinary context diff.

Reporting Bugs

Send bug reports to https://sqlite.org/bugs, not the SQLite user forum.

Bug reports should include a reproducible test case, written according to the rules outlined at doc/writing-test-cases.md.

Include suggested fixes and/or patches with bug reports, if possible.

Build

The configure script uses autosetup, not GNU Autoconf.

apt install gcc make tcl-dev   # prerequisites (Debian/Ubuntu)

./configure --dev              # debug build
make sqlite3                   # CLI shell
make sqlite3d                  # Debugging variant of the CLI shell
make sqlite3.c                 # amalgamation (single-file distribution form)
make testfixture               # test runner binary (requires tcl-dev)
make tclextension-install      # install TCL extension before running tests

Testing

Test cases in the SQLite source tree are written as SQL scripts, TCL scripts, or separate C programs. There are many thousands of tests in the canonical source tree.

Run individual SQL tests using the CLI. Run individual TCL test scripts using the "testfixture" program. Use the test/testrunner.tcl script to run collections of tests, including SQL tests, TCL scripts, and C test programs, in parallel across multiple cores.

# From the build directory:
./sqlite3 test/misc01.sql      # single SQL test script
./testfixture test/main.test   # single TCL test script
test/testrunner.tcl            # quick suite
test/testrunner.tcl full       # full suite
test/testrunner.tcl fts5%      # pattern match

Check for failures from testrunner.tcl using:

"make test" is an easy way to run a reasonably complete subset of tests.

Architecture

SQL text → tokenizer (tokenize.c) → parser (parse.y / Lemon) → code generator (build.c, select.c, insert.c, update.c, delete.c, expr.c) → optimizer (where*.c) → VDBE (vdbe.c) → B-Tree (btree.c) → Pager (pager.c) → WAL (wal.c) → VFS (os_unix.c, os_win.c).

The master internal header is src/sqliteInt.h. Major subsystems have private headers: vdbeInt.h, btreeInt.h, whereInt.h. The public API is defined in src/sqlite.h.in (template) which generates sqlite3.h.

Do not edit generated files

These files are produced by scripts and must not be edited by hand:

FileRegenerate with
sqlite3.htool/mksqlite3h.tcl
parse.c, parse.hbuild lemon (tool/lemon.c) then run on src/parse.y
opcodes.htool/mkopcodeh.tcl (reads src/vdbe.c)
opcodes.ctool/mkopcodec.tcl (reads opcodes.h)
keywordhash.htool/mkkeywordhash.c
pragma.htool/mkpragmatab.tcl
sqlite3.ctool/mksqlite3c.tcl (the amalgamation)

Editing rules:

Coding conventions

Extensions (ext/)

Extensions are compiled separately from the core and are not part of the amalgamation by default (except where explicitly included). Major subsystems:

Useful references