vsql_cube when several numeric columns belong together and you want to
query them as a single value. A chain of AND conditions can test whether a row
falls inside a range, but it cannot rank rows by distance. The cube type does
both. It is a port of PostgreSQL’s cube extension. Where PostgreSQL has a
named function the name matches, and PostgreSQL’s operators and array
constructors become the named functions below.
Install
vsql_cube.veb is already in the server’s lib/veb/ directory if you installed
VillageSQL with the install script, the Docker image, or a release tarball.
Install it into the server with one statement:
What it adds
The cube type
Declare the column as`cube`(N), where N is the number of dimensions.
cube is a MySQL reserved word, so it needs backticks, and the dimension count
is required.
Functions
Example
Find the two sensors nearest a target reading, then the sensors inside a region:A
cube argument gets its dimension count from the column it came from, so
every call above passes a column value. Feeding one function’s result
straight into another, as in cube_dim(cube_point_nd('1,2')), fails with
ERROR 3219 (HY000): Cannot initialize function 'cube_dim': cannot determine type parameters for vsql_cube.cube in argument 1. For the same reason, insert
a plain coordinate string rather than wrapping it in cube_point_nd().See also
- Multi-dimensional range queries in MySQL — a longer walkthrough of containment, distance, and nearest-neighbor queries
- Install extensions — how
INSTALL EXTENSIONworks and where the server looks for a bundle - Available extensions — the full catalog
- villagesql/vsql-cube — source, build instructions, and the complete function reference

