Functions and operators
The built-in functions of Raft DB by category, an alphabetical index of every function, and how the MySQL and MariaDB dialects differ.
This page lists every built-in function Raft DB runs, by category, with the dialect each belongs to. A function is documented only if the code implements it; functions of MySQL or MariaDB that are missing are on Functions that are not supported yet. The operators are on Operators.
How to read the function pages#
- Each function has a syntax, a short description and one example with its result. A result written as a value was taken from a verified script or a unit test of the crate; a result written in words (
a date such as ...) depends on the time or the session. - MySQL and MariaDB means the function exists in both servers and Raft DB runs it in both dialects. A function marked MariaDB only is unknown to the MySQL dialect (error 1305,
FUNCTION name is unknown); MySQL only is the same the other way round. A function marked MariaDB function; Raft DB also accepts it when it runs as MySQL exists in MariaDB and Raft DB does not hide it from the MySQL dialect. - Where the servers return different results for the same call, the page says how (regular expressions,
JSON_VALUE,JSON_ARRAYAGG, the standard deviation family,FROM_DAYS). - A function called with the wrong number of arguments is error 1582 (
Wrong number of arguments for native function 'NAME'); an unknown function is error 1305. - Functions that are not deterministic (
NOW,RAND,UUID,USER,LAST_INSERT_IDand the like) cannot be used in a generated column, a functional index or aCHECKconstraint. - Names are not case-sensitive. A function name followed by a space and
(is read as a function.
Categories#
| Page | Contents | Functions |
|---|---|---|
| String functions | text: length, case, search, padding, replace, conversion of bases | 48 |
| Numeric functions | rounding, powers, logarithms, trigonometry, number bases, GREATEST and LEAST | 32 |
| Date and time functions | current time, parts of dates, intervals, formatting and parsing | 54 |
| Control flow functions | CASE, IF, IFNULL, NULLIF, COALESCE, ISNULL | 6 |
| Cast and conversion functions | CAST, CONVERT, BINARY | 3 |
| Aggregate functions | COUNT, SUM, AVG, MIN, MAX, GROUP_CONCAT, STD and VAR family, BIT_ functions, JSON_ARRAYAGG, WITH ROLLUP | 17 |
| Window functions | ROW_NUMBER, RANK, LAG, LEAD, FIRST_VALUE and the aggregates with OVER | 12 |
| JSON functions | every JSON_ function | 33 |
| Regular expression functions | REGEXP, RLIKE, REGEXP_INSTR, REGEXP_REPLACE, REGEXP_SUBSTR | 5 |
| Encryption and hash functions | MD5, SHA1, SHA2 | 4 |
| Information functions | VERSION, DATABASE, USER, LAST_INSERT_ID, ROW_COUNT, FOUND_ROWS, CHARSET, COLLATION | 10 |
| Sequence functions | NEXTVAL, LASTVAL, SETVAL | 3 |
| Miscellaneous functions | UUID, INET_ATON, ANY_VALUE, VALUES, SLEEP, GET_LOCK | 10 |
| Stored function calls | calling a function made with CREATE FUNCTION | |
| Functions that are not supported yet | what MySQL and MariaDB have and Raft DB does not |
Not functions but written like them: CASE, CAST, EXTRACT, TRIM(BOTH ... FROM ...), SUBSTRING(... FROM ... FOR ...), INTERVAL expr unit, NEXT VALUE FOR, COUNT(*). They are on the page of their category.
Alphabetical index#
| Function | Page | Dialect |
|---|---|---|
ABS | numeric-functions | MySQL and MariaDB |
ACOS | numeric-functions | MySQL and MariaDB |
ADDDATE | date-time-functions | MySQL and MariaDB |
ADDTIME | date-time-functions | MySQL and MariaDB |
ADD_MONTHS | date-time-functions | MariaDB function |
ANY_VALUE | miscellaneous-functions | MySQL and MariaDB |
ASCII | string-functions | MySQL and MariaDB |
ASIN | numeric-functions | MySQL and MariaDB |
ATAN | numeric-functions | MySQL and MariaDB |
ATAN2 | numeric-functions | MySQL and MariaDB |
AVG | aggregate-functions | MySQL and MariaDB |
AVG | window-functions | MySQL and MariaDB |
BIN | string-functions | MySQL and MariaDB |
BINARY | cast-functions | MySQL and MariaDB |
BIT_AND | aggregate-functions | MySQL and MariaDB |
BIT_COUNT | numeric-functions | MySQL and MariaDB |
BIT_LENGTH | string-functions | MySQL and MariaDB |
BIT_OR | aggregate-functions | MySQL and MariaDB |
BIT_XOR | aggregate-functions | MySQL and MariaDB |
BTRIM | string-functions | MariaDB function |
CASE | control-flow-functions | MySQL and MariaDB |
CAST | cast-functions | MySQL and MariaDB |
CEIL | numeric-functions | MySQL and MariaDB |
CEILING | numeric-functions | MySQL and MariaDB |
CHAR | string-functions | MySQL and MariaDB |
CHARACTER_LENGTH | string-functions | MySQL and MariaDB |
CHARSET | information-functions | MySQL and MariaDB |
CHAR_LENGTH | string-functions | MySQL and MariaDB |
CHR | string-functions | MariaDB function |
COALESCE | control-flow-functions | MySQL and MariaDB |
COLLATION | information-functions | MySQL and MariaDB |
CONCAT | string-functions | MySQL and MariaDB |
CONCAT_WS | string-functions | MySQL and MariaDB |
CONNECTION_ID | information-functions | MySQL and MariaDB |
CONV | numeric-functions | MySQL and MariaDB |
CONVERT | cast-functions | MySQL and MariaDB |
CONVERT_TZ | date-time-functions | MySQL and MariaDB |
COS | numeric-functions | MySQL and MariaDB |
COT | numeric-functions | MySQL and MariaDB |
COUNT | aggregate-functions | MySQL and MariaDB |
COUNT | window-functions | MySQL and MariaDB |
CRC32 | numeric-functions | MySQL and MariaDB |
CUME_DIST | window-functions | MySQL and MariaDB |
CURDATE | date-time-functions | MySQL and MariaDB |
CURRENT_DATE | date-time-functions | MySQL and MariaDB |
CURRENT_TIME | date-time-functions | MySQL and MariaDB |
CURRENT_TIMESTAMP | date-time-functions | MySQL and MariaDB |
CURRENT_USER | information-functions | MySQL and MariaDB |
CURTIME | date-time-functions | MySQL and MariaDB |
DATABASE | information-functions | MySQL and MariaDB |
DATE | date-time-functions | MySQL and MariaDB |
DATEDIFF | date-time-functions | MySQL and MariaDB |
DATE_ADD | date-time-functions | MySQL and MariaDB |
DATE_FORMAT | date-time-functions | MySQL and MariaDB |
DATE_SUB | date-time-functions | MySQL and MariaDB |
DAY | date-time-functions | MySQL and MariaDB |
DAYNAME | date-time-functions | MySQL and MariaDB |
DAYOFMONTH | date-time-functions | MySQL and MariaDB |
DAYOFWEEK | date-time-functions | MySQL and MariaDB |
DAYOFYEAR | date-time-functions | MySQL and MariaDB |
DEGREES | numeric-functions | MySQL and MariaDB |
DENSE_RANK | window-functions | MySQL and MariaDB |
ELT | string-functions | MySQL and MariaDB |
EXP | numeric-functions | MySQL and MariaDB |
EXPORT_SET | string-functions | MySQL and MariaDB |
EXTRACT | date-time-functions | MySQL and MariaDB |
FIELD | string-functions | MySQL and MariaDB |
FIND_IN_SET | string-functions | MySQL and MariaDB |
FIRST_VALUE | window-functions | MySQL and MariaDB |
FLOOR | numeric-functions | MySQL and MariaDB |
FORMAT | string-functions | MySQL and MariaDB |
FOUND_ROWS | information-functions | MySQL and MariaDB |
FROM_BASE64 | string-functions | MySQL and MariaDB |
FROM_DAYS | date-time-functions | MySQL and MariaDB |
FROM_UNIXTIME | date-time-functions | MySQL and MariaDB |
GET_LOCK | miscellaneous-functions | MySQL and MariaDB |
GREATEST | numeric-functions | MySQL and MariaDB |
GROUP_CONCAT | aggregate-functions | MySQL and MariaDB |
HEX | string-functions | MySQL and MariaDB |
HOUR | date-time-functions | MySQL and MariaDB |
IF | control-flow-functions | MySQL and MariaDB |
IFNULL | control-flow-functions | MySQL and MariaDB |
INET_ATON | miscellaneous-functions | MySQL and MariaDB |
INET_NTOA | miscellaneous-functions | MySQL and MariaDB |
INSERT | string-functions | MySQL and MariaDB |
INSTR | string-functions | MySQL and MariaDB |
INTERVAL | numeric-functions | MySQL and MariaDB |
ISNULL | control-flow-functions | MySQL and MariaDB |
IS_IPV4 | miscellaneous-functions | MySQL and MariaDB |
IS_IPV6 | miscellaneous-functions | MySQL and MariaDB |
JSON_ARRAY | json-functions | MySQL and MariaDB |
JSON_ARRAYAGG | aggregate-functions | MySQL and MariaDB |
JSON_ARRAY_APPEND | json-functions | MySQL and MariaDB |
JSON_ARRAY_INSERT | json-functions | MySQL and MariaDB |
JSON_ARRAY_INTERSECT | json-functions | MariaDB only |
JSON_COMPACT | json-functions | MariaDB only |
JSON_CONTAINS | json-functions | MySQL and MariaDB |
JSON_CONTAINS_PATH | json-functions | MySQL and MariaDB |
JSON_DEPTH | json-functions | MySQL and MariaDB |
JSON_EQUALS | json-functions | MariaDB only |
JSON_EXISTS | json-functions | MariaDB only |
JSON_EXTRACT | json-functions | MySQL and MariaDB |
JSON_INSERT | json-functions | MySQL and MariaDB |
JSON_KEYS | json-functions | MySQL and MariaDB |
JSON_KEY_VALUE | json-functions | MariaDB only |
JSON_LENGTH | json-functions | MySQL and MariaDB |
JSON_LOOSE | json-functions | MariaDB only |
JSON_MERGE | json-functions | MySQL and MariaDB |
JSON_MERGE_PATCH | json-functions | MySQL and MariaDB |
JSON_MERGE_PRESERVE | json-functions | MySQL and MariaDB |
JSON_NORMALIZE | json-functions | MariaDB only |
JSON_OBJECT | json-functions | MySQL and MariaDB |
JSON_OBJECT_TO_ARRAY | json-functions | MariaDB only |
JSON_OVERLAPS | json-functions | MySQL and MariaDB |
JSON_QUERY | json-functions | MariaDB only |
JSON_QUOTE | json-functions | MySQL and MariaDB |
JSON_REMOVE | json-functions | MySQL and MariaDB |
JSON_REPLACE | json-functions | MySQL and MariaDB |
JSON_SEARCH | json-functions | MySQL and MariaDB |
JSON_SET | json-functions | MySQL and MariaDB |
JSON_TYPE | json-functions | MySQL and MariaDB |
JSON_UNQUOTE | json-functions | MySQL and MariaDB |
JSON_VALID | json-functions | MySQL and MariaDB |
JSON_VALUE | json-functions | MySQL and MariaDB |
LAG | window-functions | MySQL and MariaDB |
LASTVAL | sequence-functions | MySQL and MariaDB |
LAST_DAY | date-time-functions | MySQL and MariaDB |
LAST_INSERT_ID | information-functions | MySQL and MariaDB |
LAST_VALUE | window-functions | MySQL and MariaDB |
LCASE | string-functions | MySQL and MariaDB |
LEAD | window-functions | MySQL and MariaDB |
LEAST | numeric-functions | MySQL and MariaDB |
LEFT | string-functions | MySQL and MariaDB |
LENGTH | string-functions | MySQL and MariaDB |
LENGTHB | string-functions | MariaDB function |
LN | numeric-functions | MySQL and MariaDB |
LOCALTIME | date-time-functions | MySQL and MariaDB |
LOCALTIMESTAMP | date-time-functions | MySQL and MariaDB |
LOCATE | string-functions | MySQL and MariaDB |
LOG | numeric-functions | MySQL and MariaDB |
LOG10 | numeric-functions | MySQL and MariaDB |
LOG2 | numeric-functions | MySQL and MariaDB |
LOWER | string-functions | MySQL and MariaDB |
LPAD | string-functions | MySQL and MariaDB |
LTRIM | string-functions | MySQL and MariaDB |
MAKEDATE | date-time-functions | MySQL and MariaDB |
MAKETIME | date-time-functions | MySQL and MariaDB |
MAKE_SET | string-functions | MySQL and MariaDB |
MAX | aggregate-functions | MySQL and MariaDB |
MAX | window-functions | MySQL and MariaDB |
MD5 | encryption-hash-functions | MySQL and MariaDB |
MICROSECOND | date-time-functions | MySQL and MariaDB |
MID | string-functions | MySQL and MariaDB |
MIN | aggregate-functions | MySQL and MariaDB |
MIN | window-functions | MySQL and MariaDB |
MINUTE | date-time-functions | MySQL and MariaDB |
MOD | numeric-functions | MySQL and MariaDB |
MONTH | date-time-functions | MySQL and MariaDB |
MONTHNAME | date-time-functions | MySQL and MariaDB |
NEXTVAL | sequence-functions | MySQL and MariaDB |
NOW | date-time-functions | MySQL and MariaDB |
NTH_VALUE | window-functions | MySQL and MariaDB |
NTILE | window-functions | MySQL and MariaDB |
NULLIF | control-flow-functions | MySQL and MariaDB |
OCT | string-functions | MySQL and MariaDB |
OCTET_LENGTH | string-functions | MySQL and MariaDB |
ORD | string-functions | MariaDB function |
PERCENT_RANK | window-functions | MySQL and MariaDB |
PERIOD_ADD | date-time-functions | MySQL and MariaDB |
PERIOD_DIFF | date-time-functions | MySQL and MariaDB |
PI | numeric-functions | MySQL and MariaDB |
POW | numeric-functions | MySQL and MariaDB |
POWER | numeric-functions | MySQL and MariaDB |
QUARTER | date-time-functions | MySQL and MariaDB |
QUOTE | string-functions | MySQL and MariaDB |
RADIANS | numeric-functions | MySQL and MariaDB |
RAND | numeric-functions | MySQL and MariaDB |
RANK | window-functions | MySQL and MariaDB |
REGEXP | regexp-functions | MySQL and MariaDB |
REGEXP_INSTR | regexp-functions | MySQL and MariaDB |
REGEXP_LIKE | regexp-functions | MySQL and MariaDB |
REGEXP_REPLACE | regexp-functions | MySQL and MariaDB |
REGEXP_SUBSTR | regexp-functions | MySQL and MariaDB |
RELEASE_LOCK | miscellaneous-functions | MySQL and MariaDB |
REPEAT | string-functions | MySQL and MariaDB |
REPLACE | string-functions | MySQL and MariaDB |
REVERSE | string-functions | MySQL and MariaDB |
RIGHT | string-functions | MySQL and MariaDB |
ROUND | numeric-functions | MySQL and MariaDB |
ROW_COUNT | information-functions | MySQL and MariaDB |
ROW_NUMBER | window-functions | MySQL and MariaDB |
RPAD | string-functions | MySQL and MariaDB |
RTRIM | string-functions | MySQL and MariaDB |
SCHEMA | information-functions | MySQL and MariaDB |
SECOND | date-time-functions | MySQL and MariaDB |
SEC_TO_TIME | date-time-functions | MySQL and MariaDB |
SESSION_USER | information-functions | MySQL and MariaDB |
SETVAL | sequence-functions | MySQL and MariaDB |
SHA | encryption-hash-functions | MySQL and MariaDB |
SHA1 | encryption-hash-functions | MySQL and MariaDB |
SHA2 | encryption-hash-functions | MySQL and MariaDB |
SIGN | numeric-functions | MySQL and MariaDB |
SIN | numeric-functions | MySQL and MariaDB |
SLEEP | miscellaneous-functions | MySQL and MariaDB |
SOUNDEX | string-functions | MySQL and MariaDB |
SPACE | string-functions | MySQL and MariaDB |
SQRT | numeric-functions | MySQL and MariaDB |
STD | aggregate-functions | MySQL and MariaDB |
STDDEV | aggregate-functions | MySQL and MariaDB |
STDDEV_POP | aggregate-functions | MySQL and MariaDB |
STDDEV_SAMP | aggregate-functions | MySQL and MariaDB |
STRCMP | string-functions | MySQL and MariaDB |
STR_TO_DATE | date-time-functions | MySQL and MariaDB |
SUBDATE | date-time-functions | MySQL and MariaDB |
SUBSTR | string-functions | MySQL and MariaDB |
SUBSTRING | string-functions | MySQL and MariaDB |
SUBSTRING_INDEX | string-functions | MySQL and MariaDB |
SUBTIME | date-time-functions | MySQL and MariaDB |
SUM | aggregate-functions | MySQL and MariaDB |
SUM | window-functions | MySQL and MariaDB |
SYSDATE | date-time-functions | MySQL and MariaDB |
SYSTEM_USER | information-functions | MySQL and MariaDB |
TAN | numeric-functions | MySQL and MariaDB |
TIME | date-time-functions | MySQL and MariaDB |
TIMEDIFF | date-time-functions | MySQL and MariaDB |
TIMESTAMP | date-time-functions | MySQL and MariaDB |
TIMESTAMPADD | date-time-functions | MySQL and MariaDB |
TIMESTAMPDIFF | date-time-functions | MySQL and MariaDB |
TIME_FORMAT | date-time-functions | MySQL and MariaDB |
TIME_TO_SEC | date-time-functions | MySQL and MariaDB |
TO_BASE64 | string-functions | MySQL and MariaDB |
TO_DAYS | date-time-functions | MySQL and MariaDB |
TO_SECONDS | date-time-functions | MySQL and MariaDB |
TRIM | string-functions | MySQL and MariaDB |
TRUNCATE | numeric-functions | MySQL and MariaDB |
UCASE | string-functions | MySQL and MariaDB |
UNHEX | string-functions | MySQL and MariaDB |
UNIX_TIMESTAMP | date-time-functions | MySQL and MariaDB |
UPPER | string-functions | MySQL and MariaDB |
USER | information-functions | MySQL and MariaDB |
UTC_DATE | date-time-functions | MySQL and MariaDB |
UTC_TIME | date-time-functions | MySQL and MariaDB |
UTC_TIMESTAMP | date-time-functions | MySQL and MariaDB |
UUID | miscellaneous-functions | MySQL and MariaDB |
UUID_SHORT | miscellaneous-functions | MySQL and MariaDB |
VALUES | miscellaneous-functions | MySQL and MariaDB |
VARIANCE | aggregate-functions | MySQL and MariaDB |
VAR_POP | aggregate-functions | MySQL and MariaDB |
VAR_SAMP | aggregate-functions | MySQL and MariaDB |
VERSION | information-functions | MySQL and MariaDB |
WEEK | date-time-functions | MySQL and MariaDB |
WEEKDAY | date-time-functions | MySQL and MariaDB |
WEEKOFYEAR | date-time-functions | MySQL and MariaDB |
YEAR | date-time-functions | MySQL and MariaDB |
YEARWEEK | date-time-functions | MySQL and MariaDB |