3 ms·
SQLite's VM is register-based, not stack-based.
by Scaevolus 2y ago
SQLite's VM is register-based, not stack-based.
- ojosilva 2y agoDoes SQLite's VM have an API? I mean, one where I can build and issue opcodes into directly.
- OskarS 2y agoNot a public one, because they want to have the freedom to change how it works. But if you type in `EXPLAIN CREATE TABLE x(y);` or `EXPLAIN SELECT 3;` or whatever into `sqlite3`, you can see it. And it's reasonably straightforward to dig into the source code (SQLite is very well-written C) to hook that up yourself if you really wanted to.
- bch 2y agoIt’s been both - was stack, converted to register[0][1]. [0] https://www.sqlite.org/vdbe.html https://www.sqlite.org/vdbe.html [1] https://www.sqlite.org/src/info/051ec01f2799e095 https://www.sqlite.org/src/info/051ec01f2799e095
- notpeter 2y agoThis was the question I was going to ask! I've recently been diving into Lua 5.x internals and have been extremely impressed with Lua's register-based bytecode implementation. Lua has a stable byte code interface between patch releases (5.4.0 -> 5.4.1, etc) but not between major/minor revisions (5.3 -> 5.4). SQLite on the other hand does not consider this a public interface at all! > "Remember: The VDBE opcodes are not part of the interface definition for SQLite. The number of opcodes and their names and meanings change from one release of SQLite to the next." https://www.sqlite.org/opcode.html#the_opcodes https://www.sqlite.org/opcode.html#the_opcodes For anyone interested in understanding how a register-based VM operates I highly recommend: A No-Frills Introduction to Lua 5.1 VM Instructions by Kein-Hong Man. https://www.mcours.net/cours/pdf/hasclic3/hasssclic818.pdf https://www.mcours.net/cours/pdf/hasclic3/hasssclic818.pdf