Commodore 64 Basic for PostgreSQL
6 hours ago
- #Commodore 64
- #Nostalgia
- #PostgreSQL
- PL/CBMBASIC allows PostgreSQL to run functions written in Commodore 64 BASIC V2, using the actual 1982 interpreter compiled into C.
- It features line numbers starting at 10, mandatory for code, with function arguments injected as BASIC variables in lines 0-9.
- Includes a validator that enforces C64 BASIC naming rules, preventing variables with embedded keywords (e.g., 'TOTAL' contains 'TO').
- OUT parameters are handled by reading BASIC's variable table from emulated RAM after program execution.
- Device 8 is mapped to the database, allowing use of OPEN, INPUT#, PRINT#, etc., to execute SQL statements and read results.
- Errors are trapped through the interpreter's ERROR vector, providing PostgreSQL errors with original BASIC error codes.
- Performance benchmarks show it's slower than PL/Python but faster than the original hardware, with a 15-microsecond reset per call.
- Limitations include uppercase-only strings, 255-character string limits, no NULL support, and superuser-only untrusted language status.