Virtual machine features

Operand stack
The operand stack is of unlimited depth. Many of the opcodes use operands from the stack. For details, see the individual opcode descriptions.
Cursors
Cursors are the only means for the virtual machine to interact with a database file. The virtual machine can have zero or more cursors. Each cursor points to a single table or index in the database. All cursors operate independently, even those pointing to the same object.
There are instructions to create a new cursor (Open), read data from a cursor (Column), advance the cursor to the next entry in the table (Next) or index (NextIdx), and more. All cursors are automatically closed when the virtual machine terminates.
Memory locations
The virtual machine contains an arbitrary number of fixed memory locations with addresses beginning at zero and growing upward. Each location can hold a string of any length. Typically, the memory cells hold the result of a scalar SELECT within a larger expression.
Sorter
The virtual machine contains a single sorter, which accumulates records, sorts them, and plays them back in sorted order. The sorter is used by the ORDER BY clause of a SELECT statement.
List
In the virtual machine, there's a single list used to hold the row IDs for the records of a database table that needs to be updated. For the WHERE clause of an UPDATE or DELETE statement, QDB scans through the table and writes the row ID of every record to be modified into the list. Then, QDB plays back the list and modifies the table in a separate step.
Sets
The virtual machine can contain any number of sets. Each set holds any number of strings. Sets are used to implement the IN operator with a constant right-hand side.
Reading external files
A single external file can be opened by the virtual machine for reading. This external file is used when executing the COPY command.
Aggregators
An aggregator is a device used to implement the GROUP BY clause of a SELECT statement. The virtual machine has a single set of aggregators, each of which has one or more slots that hold the values extracted by that statement.
The number of slots is the same for all aggregators and is defined by the AggReset operation. At any time, a single aggregator is current or “has focus”. There are operations to read from or write to the memory slots of the aggregator in focus, to change the focus aggregator, and to scan through all aggregators.