Elyra
Elyra The coding agent eTerm The terminal that knows where each command ends Huskarl AI colleagues on your own Mac Starf An activity monitor for Apple silicon that never invents a number etrans An SSH and SFTP client for macOS Elyra VM Virtual machines for macOS, Linux and Windows on your Mac Litr A small, native web browser for macOS Notr A notebook for macOS e The native code editor Elyra Grove Native local development environment Askr The real server for Laravel & PHP Elyra Framework Rust + Svelte 5 framework for desktop apps Elyra Conductor Local project conductor Refr Local-first PDF workspace for macOS Elyra Workspace A desktop workspace for coding agents eDock A container runtime for the Mac Elyra SQL Server MySQL-compatible SQL server in Rust Elyra Félagi Agents as teammates on one board Elyra SQL Client Native desktop SQL workbench Elyra SQL Anywhere Replication-ready SQL engine Elyra Sjá SEO & GEO workspace for macOS Elyra DataGrid Server-driven data grid for Laravel
Release notes
Changelog
Elyra

Functions

ElyraSQL supports a broad set of MySQL-compatible scalar functions in expressions (SELECT list, WHERE, DEFAULT, generated columns, etc.).

Date & time

Function Result
NOW(), CURRENT_TIMESTAMP, SYSDATE(), LOCALTIME current DATETIME
CURDATE(), CURRENT_DATE current DATE
CURTIME(), CURRENT_TIME current TIME
UNIX_TIMESTAMP([dt]) seconds since the epoch

The niladic forms work with or without parentheses.

Extracting and formatting

Function Result
YEAR, MONTH, DAY/DAYOFMONTH, HOUR, MINUTE, SECOND component
QUARTER, DAYOFWEEK, WEEKDAY, DAYOFYEAR component
EXTRACT(unit FROM d) component
DATE(dt), TIME(dt) date / time part
DATEDIFF(a, b) whole days between
TIMESTAMPDIFF(unit, a, b) difference in the given unit
WEEK(d[, mode]), YEARWEEK(d[, mode]) week number (MySQL modes)
LAST_DAY(d) last day of the month
DATE_FORMAT(d, fmt) formatted string (%Y %m %d %H %i %s %M %b %W %a %j %p ...)
STR_TO_DATE(s, fmt) parse a string with a format pattern

Date arithmetic

DATE_ADD('2024-01-31', INTERVAL 1 MONTH)   -- 2024-02-29 (day clamped)
DATE_SUB('2024-03-15', INTERVAL 10 DAY)
ADDDATE(d, 7)                              -- numeric day form
TIMESTAMPADD(HOUR, 5, dt)

-- INTERVAL also works as an operator
SELECT * FROM events WHERE ts > NOW() - INTERVAL 7 DAY;
SELECT DATE '2024-01-31' + INTERVAL 1 MONTH;

Units: MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR. INTERVAL is supported both inside DATE_ADD/DATE_SUB/ TIMESTAMPADD and as a bare d + INTERVAL n UNIT / d - INTERVAL n UNIT operator.

Time zones

Function Result
UTC_TIMESTAMP(), UTC_DATE(), UTC_TIME() the current UTC instant
CONVERT_TZ(dt, from, to) dt shifted by the offset difference
FROM_UNIXTIME(n[, fmt]) epoch seconds as a session-zone DATETIME (or formatted string)

The server's system zone is UTC. The session zone is set with SET time_zone = '<value>', which accepts UTC (+00:00, SYSTEM, UTC) and any numeric offset in [+-]HH:MM form within ±14:00:

SET time_zone = '+02:00';
SELECT NOW();                              -- UTC + 2 hours
SELECT UTC_TIMESTAMP();                    -- still UTC
SELECT FROM_UNIXTIME(0);                   -- 1970-01-01 02:00:00
SELECT UNIX_TIMESTAMP('1970-01-01 02:00:00');  -- 0
SELECT UNIX_TIMESTAMP();                   -- absolute epoch, offset-independent

The local now-family (NOW, CURRENT_TIMESTAMP, LOCALTIME/LOCALTIMESTAMP, CURDATE, CURTIME) and the interpreting forms FROM_UNIXTIME(n) and UNIX_TIMESTAMP(dt) read in the session zone; the UTC_* forms and a niladic UNIX_TIMESTAMP() stay in UTC. CONVERT_TZ takes fixed offsets (+HH:MM, SYSTEM, UTC); a named zone (Europe/Oslo) returns NULL and, when set as the session zone, is refused -- resolving one needs a zone table with DST rules a fixed offset cannot express.

String

CONCAT, CONCAT_WS, UPPER/UCASE, LOWER/LCASE, LENGTH/CHAR_LENGTH, OCTET_LENGTH, SUBSTRING/SUBSTR/MID, SUBSTRING_INDEX, LEFT, RIGHT, TRIM/LTRIM/RTRIM (incl. TRIM(LEADING/TRAILING 'x' FROM s)), REPLACE, REVERSE, REPEAT, SPACE, LPAD, RPAD, INSTR, LOCATE/POSITION, ASCII, ORD, FIELD, ELT, FIND_IN_SET, CHAR, INSERT, STRCMP, BIN, OCT, CONV, HEX, CRC32.

LENGTH returns the byte length and CHAR_LENGTH the character count; SUBSTRING positions are 1-based (position 0 yields the empty string).

REPEAT, SPACE, LPAD and RPAD return NULL when the result would exceed ELYRASQL_MAX_ALLOWED_PACKET (default 64 MiB) — the same behaviour as MySQL past max_allowed_packet, so SPACE(10000000000) is NULL rather than a 10 GB allocation.

Pattern matching: str LIKE pattern, and str REGEXP pattern / str RLIKE pattern (POSIX-style regular expressions, with NOT REGEXP). Compiled patterns are cached, so a constant pattern is compiled once per server rather than once per row. Case-sensitivity follows the operand's collation, as in MySQL: matching is case-insensitive under the default collation ('Hello' REGEXP 'h' is true) and case-sensitive for a _bin operand, while an inline (?-i) in the pattern overrides it. REGEXP_REPLACE and REGEXP_SUBSTR receive already-evaluated values, so they always use the default (case-insensitive) behaviour.

Math

ABS, CEIL/CEILING, FLOOR, ROUND(x[,d]), TRUNCATE(x,d), SIGN, SQRT, EXP, LN/LOG, LOG10, LOG2, POWER/POW, MOD, PI(), RAND(), GREATEST, LEAST, BIT_COUNT. A math domain error (e.g. SQRT(-1), LN(0)) returns NULL, and out-of-range DOUBLE results are NULL, as in MySQL.

Bitwise operators

a & b (AND), a | b (OR), a ^ b (XOR), a << b, a >> b, and unary ~a operate on 64-bit unsigned integers and return BIGINT UNSIGNED, matching MySQL. a DIV b is integer division (truncating toward zero; DIV 0 is NULL), and !x is the logical-NOT prefix. Example flag mask: WHERE flags & 4 > 0.

Conditional & null

COALESCE, IFNULL/NVL, NULLIF, ISNULL, IF(cond, a, b), and CASE expressions (both simple and searched). NULL propagates through arithmetic and follows three-valued logic in AND/OR/IN/BETWEEN (e.g. NULL AND 1 and 1 IN (NULL, 2) are NULL), as in MySQL.

Other

  • UUID() — a random version-4 UUID string.

  • USER(), SESSION_USER(), SYSTEM_USER() — the connection's own user@client-address, also inside a view, procedure or trigger.

  • CURRENT_USER() / CURRENT_USER — the account, user@%. Inside a view it is the view's definer, or the invoker for a SQL SECURITY INVOKER view (see Views); inside a procedure or trigger it is root@%, the definer information_schema reports for them. To filter rows by who is asking, use USER():

    CREATE VIEW my_docs AS
      SELECT * FROM docs WHERE owner = SUBSTRING_INDEX(USER(), '@', 1);
    GRANT SELECT ON elyra.my_docs TO alice;  -- not on docs itself
    
  • CONNECTION_ID() — the connection's id, as SHOW PROCESSLIST lists it.

  • CAST(x AS <type>) / CONVERT — to CHAR/text, SIGNED/integer, DECIMAL(p,s) (exact, rescaled), BINARY/bytes, DATE, DATETIME, TIME.

Decimal arithmetic (+, -, *) and SUM(DECIMAL) are computed exactly.

JSON

See Data types for JSON_EXTRACT, JSON_SET, JSON_ARRAY, JSON_OBJECT, and the rest of the JSON family.

Vector

See Vector search for VEC_DISTANCE, VEC_COSINE_DISTANCE, and VEC_INNER_PRODUCT.