Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.

SQL

HolaDB implements a deliberately defined SQL subset. Everything outside it is refused with a clear unsupported: … message that names the construct; nothing is silently ignored or approximated.

Statements

CREATE TABLE [IF NOT EXISTS] t (col TYPE [NOT NULL] [DEFAULT literal] [PRIMARY KEY], …, [PRIMARY KEY (a, b)])
DROP TABLE [IF EXISTS] t
ALTER TABLE t ADD COLUMN col TYPE [NOT NULL] [DEFAULT literal]
ALTER TABLE t DROP COLUMN col
ALTER TABLE t RENAME COLUMN a TO b
ALTER TABLE t RENAME TO t2
CREATE [UNIQUE] INDEX [IF NOT EXISTS] i ON t (a, b)
DROP INDEX [IF EXISTS] i

INSERT INTO t [(cols)] VALUES (…), (…)
UPDATE t SET a = expr, … [WHERE cond]
DELETE FROM t [WHERE cond]
SELECT items FROM t [AS alias] [WHERE cond] [ORDER BY expr [ASC|DESC], …] [LIMIT n] [OFFSET n]
SELECT count(*), sum(x), min(x), max(x), avg(x) FROM t [WHERE cond]     -- whole-table aggregates
EXPLAIN <statement>

BEGIN | COMMIT | ROLLBACK
SHOW TABLES | SHOW COLUMNS FROM t (also DESCRIBE t) | SHOW INDEXES FROM t
CREATE USER / ALTER USER / DROP USER / CREATE ROLE / DROP ROLE / GRANT / REVOKE / SHOW USERS / SHOW ROLES / SHOW GRANTS   -- see Security

Parameters are $1, $2, … (or ?, numbered in order). Their types are inferred from the columns they are compared with or assigned to.

Types

SQL name(s) Stored as Notes
BOOLEAN, BOOL boolean
TINYINT, SMALLINT, INTEGER/INT, BIGINT 8/16/32/64-bit signed range-checked on write
UTINYINT, USMALLINT, UINTEGER, UBIGINT unsigned
REAL/FLOAT4, DOUBLE PRECISION/FLOAT8/DOUBLE 32/64-bit float
TEXT, VARCHAR, CHAR, STRING UTF-8 text length limits are not enforced
BYTEA, BLOB, BYTES bytes literals as '\x0a0b'
TIMESTAMP, TIMESTAMPTZ, DATETIME microseconds since the Unix epoch, UTC literals '2026-01-02T03:04:05.5Z' or '2026-01-02 03:04:05'
JSON, JSONB canonical JSON text literals are JSON text

Not available: NUMERIC/DECIMAL (use DOUBLE PRECISION or scaled integers), UUID (use TEXT), DATE/TIME/INTERVAL (use TIMESTAMP or BIGINT), SERIAL (assign keys explicitly, or omit the primary key and let HolaDB assign a row id), arrays (use JSON).

Every table has exactly one key: a declared PRIMARY KEY (one or more columns of any supported type) or, without one, a hidden row id.

Values on write: a number is converted between the numeric types when it fits exactly (42 into a DOUBLE PRECISION, 7 into a BIGINT); a text literal is read as a TIMESTAMP or JSON where the column is one. Nothing else is converted: a text literal into a number column ('42' into an INT), a number into TEXT, 3.0 into an INT and TRUE into an INT are errors — use CAST. A value that does not fit is an error, never truncated: an integer outside the column’s range, and a finite number too large for a REAL. A REAL column stores the nearest 32-bit value of what is written, and a literal compared with a REAL column is rounded the same way, so WHERE r = 0.1 finds the row that 0.1 was written to. -0.0 is stored as 0.0; NaN equals NaN and sorts above every number.

Arithmetic on integers is done in 64 bits whatever the columns’ widths (tinyint_col + 1 is a BIGINT); on two unsigned values in unsigned 64 bits; mixed signed and unsigned exactly, with an integer overflow error only when the result fits neither. A sum is a 64-bit value (or a DOUBLE PRECISION). timestamp ± integer is a TIMESTAMP (microseconds); timestamp − timestamp is a BIGINT. BETWEEN reads its bounds like >= and <=.

Parameters ($1, $2, …): a statement must be given exactly as many values as it has placeholders; more or fewer is an error. A parameter takes its type from the other side of a comparison or of an arithmetic operator, which is how text values sent by a PostgreSQL driver are read (SET a = a + $1 with '5').

Expressions

  • Literals: numbers, 'strings' ('' to escape a quote), TRUE/FALSE, NULL.
  • Operators: + - * / % (checked; overflow and division by zero are errors), = <> != < <= > >=, AND OR NOT, IS [NOT] NULL, [NOT] LIKE (% and _), [NOT] IN (list), BETWEEN, CAST(x AS TYPE).
  • Functions: lower, upper, length, abs, coalesce; aggregates count, sum, min, max, avg (count(*) and count(col)).
  • Three-valued logic: comparisons with NULL yield NULL, and WHERE keeps only rows whose condition is TRUE.

What is not supported (yet)

JOIN, subqueries, GROUP BY / HAVING, DISTINCT, UNION / INTERSECT / EXCEPT, INSERT … SELECT, INSERT … ON CONFLICT, RETURNING, UPDATE … FROM, WITH (common table expressions), window functions, NULLS FIRST/LAST, SELECT … FOR UPDATE, TRUNCATE, COPY, schema-qualified names, CASCADE, table constraints other than PRIMARY KEY (unique constraints are CREATE UNIQUE INDEX), foreign keys, CHECK, sequences, views, triggers, stored procedures.

Reading a query plan

holadb> EXPLAIN SELECT * FROM users WHERE id = 5;
 QUERY PLAN
------------
 PointLookup users (id = 5)

Plans are TableScan, PointLookup (primary key equality), RangeScan (primary key range), IndexLookup (secondary index equality), with Filter, Project, Sort, Limit and Aggregate on top. A sort on the primary key in ascending order is eliminated.

Errors

A syntax error carries a position: syntax error at line 1, column 14: expected a statement. A construct outside the subset is refused with unsupported: <the construct>.

Errors come in classes that every client exposes, so that a program can react to them:

Class Examples Native code SQLSTATE (PostgreSQL protocol)
syntax and binding unknown column, misspelt keyword Sql (16) 42601, 42703, 42P01
unsupported GROUP BY, joins, RETURNING Sql (16) 0A000
constraint duplicate primary key, unique index, NULL into a NOT NULL column Constraint (17) 23505, 23502
value out of range, wrong type, division by zero, overflow InvalidArgument (8) 22003, 42804, 22012
transaction serialization failure (retry), statement in an aborted transaction, no transaction open Transaction (18) 40001, 25P02, 25P01
statement timeout the statement ran longer than --statement-timeout-ms and was cancelled Timeout (25) 57014
limit statement too long, expression too deep, too many prepared statements InvalidArgument (8) / TooLarge (3) 54000
permission the user lacks the privilege Forbidden (21) 42501
uncertain outcome a commit whose result is unknown; see Recovery UncertainOutcome (24) 08007

A statement that fails inside a transaction aborts the transaction (Transactions).

Limits on a statement

  • A statement may be at most 1 MiB of text.
  • An expression may be nested at most 200 operators deep. a + b + c is 3 deep (operators group to the left), NOT NOT x is 3 deep. A deeper expression is refused with expression too deeply nested. A long list of alternatives belongs in an IN (…) list, which is not deep however long it is.
  • Parentheses, function arguments and IN lists may be nested 64 levels.
  • EXPLAIN cannot be nested.
  • An integer literal must lie between −9223372036854775808 and 18446744073709551615; anything outside is refused, never wrapped.
  • An index is used when the filter gives a value for every column of the index. A filter on only the leading columns of a multi-column index is answered by scanning the table.