From a6772ddc22d80ede3020c1847bd517b163ecced7 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Mar 2026 20:44:40 +0000 Subject: [PATCH] Add SQLite Bytecode Explorer - interactive VDBE instruction viewer A web UI that uses SQLite compiled to WASM (via sql.js) to let users explore the bytecode that sqlite3_prepare_v2() generates for any SQL query. Features include: - EXPLAIN and EXPLAIN QUERY PLAN modes - Color-coded opcode categories (cursor, movement, comparison, etc.) - Clickable jump targets for navigating control flow - Detailed human-readable explanations for 100+ VDBE opcodes - Program overview with automatic feature detection - Optional schema setup for realistic query plans - 10 built-in examples (SELECT, JOIN, aggregate, subquery, DML) https://claude.ai/code/session_01HmnRs8ZKJVP1U4LXGvVe75 --- sqlite-bytecode-explorer.docs.md | 1 + sqlite-bytecode-explorer.html | 972 +++++++++++++++++++++++++++++++ 2 files changed, 973 insertions(+) create mode 100644 sqlite-bytecode-explorer.docs.md create mode 100644 sqlite-bytecode-explorer.html diff --git a/sqlite-bytecode-explorer.docs.md b/sqlite-bytecode-explorer.docs.md new file mode 100644 index 0000000..9890fc5 --- /dev/null +++ b/sqlite-bytecode-explorer.docs.md @@ -0,0 +1 @@ +Visualize and understand the virtual machine instructions SQLite generates for your SQL queries. Enter any SQL statement to see its compiled VDBE (Virtual Database Engine) bytecode with color-coded opcodes, clickable jump targets, and detailed explanations for each instruction. Includes optional schema setup for realistic query plans, an EXPLAIN QUERY PLAN mode, and ten built-in examples covering SELECTs, JOINs, aggregates, subqueries, and DML statements. Powered by SQLite compiled to WebAssembly running entirely in your browser. diff --git a/sqlite-bytecode-explorer.html b/sqlite-bytecode-explorer.html new file mode 100644 index 0000000..effca1e --- /dev/null +++ b/sqlite-bytecode-explorer.html @@ -0,0 +1,972 @@ + + + + + + SQLite Bytecode Explorer + + + + +
+

SQLite Bytecode Explorer

+

Visualize and understand the virtual machine instructions SQLite generates for your SQL queries

+ +
+

How SQLite Executes Queries

+

+ SQLite compiles every SQL statement into a program for its built-in Virtual Database Engine (VDBE). + The VDBE is a register-based virtual machine — each instruction (opcode) operates on numbered registers (like r[2]) + rather than a stack. When you call sqlite3_prepare_v2(), SQLite parses your SQL and generates this bytecode program. + Then sqlite3_step() executes it one instruction at a time. +

+

+ Use EXPLAIN before any SQL statement to see its bytecode. This tool runs EXPLAIN for you + and annotates each opcode with a human-readable explanation. +

+
+ +
+
+ Schema Setup (optional — define tables/indexes so EXPLAIN can reference them) + +
These CREATE TABLE / CREATE INDEX statements set up the database schema so that EXPLAIN output reflects real query plans.
+
+ + + + +
+ + +
+ +
+
+ +
+ +
Loading SQLite WASM...
+ +
+ + + +