SQL reference (MySQL and MariaDB dialects)

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#

FunctionWhat it doesDialect
ANY_VALUEReturns expr.MySQL and MariaDB
GET_LOCKAccepted so that applications run: GET_LOCK and RELEASE_LOCK return 1 and lock nothing.MySQL and MariaDB
INET_ATONReturns 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_NTOAReturns the dotted IPv4 address for a number; NULL outside 0 to 4294967295.MySQL and MariaDB
IS_IPV4Returns 1 if the argument is a dotted IPv4 address, 0 if not.MySQL and MariaDB
IS_IPV6Returns 1 if the argument is an IPv6 address, 0 if not.MySQL and MariaDB
SLEEPAccepted so that applications run; it returns 0 at once and does not wait.MySQL and MariaDB
UUIDReturns a version 4 UUID as 36 characters (8-4-4-4-12 hexadecimal digits, lower case).MySQL and MariaDB
UUID_SHORTReturns a 64-bit number that is different for each call within a server run.MySQL and MariaDB
VALUESIn the UPDATE part of `INSERT ...MySQL and MariaDB

ANY_VALUE#

SQL
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:

SQL
SELECT ANY_VALUE(1);

Result: 1

GET_LOCK#

SQL
GET_LOCK(str, timeout)
RELEASE_LOCK(str)

Accepted so that applications run: GET_LOCK and RELEASE_LOCK return 1 and lock nothing.

Example:

SQL
SELECT GET_LOCK('job', 5), RELEASE_LOCK('job');

Result: 1, 1

INET_ATON#

SQL
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:

SQL
SELECT INET_ATON('192.168.1.1');

Result: 3232235777

INET_NTOA#

SQL
INET_NTOA(expr)

Returns the dotted IPv4 address for a number; NULL outside 0 to 4294967295.

Example:

SQL
SELECT INET_NTOA(3232235777);

Result: 192.168.1.1

IS_IPV4#

SQL
IS_IPV4(expr)

Returns 1 if the argument is a dotted IPv4 address, 0 if not.

Example:

SQL
SELECT IS_IPV4('1.2.3.4'), IS_IPV4('1.2.3');

Result: 1, 0

IS_IPV6#

SQL
IS_IPV6(expr)

Returns 1 if the argument is an IPv6 address, 0 if not.

Example:

SQL
SELECT IS_IPV6('::1'), IS_IPV6('x');

Result: 1, 0

SLEEP#

SQL
SLEEP(duration)

Accepted so that applications run; it returns 0 at once and does not wait.

Example:

SQL
SELECT SLEEP(1);

Result: 0

UUID#

SQL
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:

SQL
SELECT LENGTH(UUID());

Result: 36

UUID_SHORT#

SQL
UUID_SHORT()

Returns a 64-bit number that is different for each call within a server run.

Example:

SQL
SELECT UUID_SHORT() > 0;

Result: 1

VALUES#

SQL
VALUES(col_name)

In the UPDATE part of INSERT ... ON DUPLICATE KEY UPDATE, the value that the row would have been inserted with.

Example:

SQL
INSERT INTO t (id, n) VALUES (1, 5) ON DUPLICATE KEY UPDATE n = n + VALUES(n);

Result: an upsert

See also#