Miscellaneous functions
ANY_VALUE, UUID, UUID_SHORT, INET_ATON and its relatives, VALUES, and the lock and sleep functions that Raft DB accepts without acting.
These functions do not fit another category. GET_LOCK, RELEASE_LOCK and SLEEP exist so that application code and dumps run; they do not lock and do not wait. There are no user-level locks in Raft DB yet.
DEFAULT(col) gives the default of the column (NULL, error 1364 for a NOT NULL column without one, 3773 for an expression default in MySQL; 0 for an AUTO_INCREMENT column) in SELECT, WHERE, UPDATE SET, INSERT ... VALUES and ON DUPLICATE KEY UPDATE.
Not supported yet: UUID_TO_BIN, BIN_TO_UUID, IS_UUID, INET6_ATON, INET6_NTOA, IS_FREE_LOCK, IS_USED_LOCK, RELEASE_ALL_LOCKS, NAME_CONST, LOAD_FILE, . See Functions that are not supported yet.
Summary of functions#
| Function | What it does | Dialect |
|---|---|---|
ANY_VALUE | Returns expr. | MySQL and MariaDB |
GET_LOCK | Accepted so that applications run: GET_LOCK and RELEASE_LOCK return 1 and lock nothing. | MySQL and MariaDB |
INET_ATON | Returns the number for an IPv4 address written a.b.c.d (and the short forms a.b, a.b.c); NULL if it is not an address. | MySQL and MariaDB |
INET_NTOA | Returns the dotted IPv4 address for a number; NULL outside 0 to 4294967295. | MySQL and MariaDB |
IS_IPV4 | Returns 1 if the argument is a dotted IPv4 address, 0 if not. | MySQL and MariaDB |
IS_IPV6 | Returns 1 if the argument is an IPv6 address, 0 if not. | MySQL and MariaDB |
SLEEP | Accepted so that applications run; it returns 0 at once and does not wait. | MySQL and MariaDB |
UUID | Returns a version 4 UUID as 36 characters (8-4-4-4-12 hexadecimal digits, lower case). | MySQL and MariaDB |
UUID_SHORT | Returns a 64-bit number that is different for each call within a server run. | MySQL and MariaDB |
VALUES | In the UPDATE part of `INSERT ... | MySQL and MariaDB |
ANY_VALUE#
ANY_VALUE(expr)Returns expr. It is for a select list that has a column not in the GROUP BY while ONLY_FULL_GROUP_BY is on; Raft DB returns the value of the argument unchanged.
Example:
SELECT ANY_VALUE(1);Result: 1
GET_LOCK#
GET_LOCK(str, timeout)
RELEASE_LOCK(str)Accepted so that applications run: GET_LOCK and RELEASE_LOCK return 1 and lock nothing.
Example:
SELECT GET_LOCK('job', 5), RELEASE_LOCK('job');Result: 1, 1
INET_ATON#
INET_ATON(expr)Returns the number for an IPv4 address written a.b.c.d (and the short forms a.b, a.b.c); NULL if it is not an address.
Example:
SELECT INET_ATON('192.168.1.1');Result: 3232235777
INET_NTOA#
INET_NTOA(expr)Returns the dotted IPv4 address for a number; NULL outside 0 to 4294967295.
Example:
SELECT INET_NTOA(3232235777);Result: 192.168.1.1
IS_IPV4#
IS_IPV4(expr)Returns 1 if the argument is a dotted IPv4 address, 0 if not.
Example:
SELECT IS_IPV4('1.2.3.4'), IS_IPV4('1.2.3');Result: 1, 0
IS_IPV6#
IS_IPV6(expr)Returns 1 if the argument is an IPv6 address, 0 if not.
Example:
SELECT IS_IPV6('::1'), IS_IPV6('x');Result: 1, 0
SLEEP#
SLEEP(duration)Accepted so that applications run; it returns 0 at once and does not wait.
Example:
SELECT SLEEP(1);Result: 0
UUID#
UUID()Returns a version 4 UUID as 36 characters (8-4-4-4-12 hexadecimal digits, lower case). Can be a column default (DEFAULT UUID()).
Example:
SELECT LENGTH(UUID());Result: 36
UUID_SHORT#
UUID_SHORT()Returns a 64-bit number that is different for each call within a server run.
Example:
SELECT UUID_SHORT() > 0;Result: 1
VALUES#
VALUES(col_name)In the UPDATE part of INSERT ... ON DUPLICATE KEY UPDATE, the value that the row would have been inserted with.
Example:
INSERT INTO t (id, n) VALUES (1, 5) ON DUPLICATE KEY UPDATE n = n + VALUES(n);Result: an upsert