SLOPDB / DOCUMENTATION / MYSQL-STYLE FUNCTIONS

MySQL-style functions

Function inventory verified against the supplied SlopDB source checkout e5e2eb2. Entries document implemented behavior, including compatibility placeholders and restrictions.

← Search all SQL functions · 179 documented names/forms in this family.

This reference covers MySQL-style scalar functions and special call syntax implemented by SlopDB. Many also work in native expressions; connection identity, advisory locks, and connection result state require the relevant session context. MySQL protocol sessions enable MySQL-specific coercion and overrides. See the compatibility guide and server setup.

Shared functions and overrides

Core conditional, string, date, aggregate, and JSON functions remain available. In MySQL mode, LENGTH counts bytes, HEX keeps native textual-byte conversion for numeric inputs, ROUND supports negative positions and exact/approximate tie rules, and ABS uses MySQL numeric coercion. Explicit CONVERT_TZ calls also convert between supported fixed offsets and available host IANA zones. See core functions, shared JSON, and aggregates.

Coercion and bounds

MySQL numeric helpers generally accept a leading numeric prefix in strings. TEXT positions count Unicode code points; BLOB operations count bytes. Expanded strings, padding, formatting, and decompression are checked against the query memory budget. Wrong argument counts fail even on empty input. NULL handling and domain errors are function-specific.

Temporal values use TEXT and the session timezone is UTC. The implementation includes month-end clamping, leap years, all eight WEEK modes, and signed durations up to the MySQL 838-hour range. Date names are English. It does not implement every MySQL sql_mode, warning, collation, timezone conversion, or temporal coercion.

Regex flags and boundaries

Supported match flags include i (case-insensitive), c (case-sensitive), m (multiline), n (dot matches newline), and u (supported Unix-line behavior). The u flag is accepted while RE2 retains its line-ending semantics. The engine uses RE2 rather than ICU; unsupported pattern constructs fail. Check the compatibility guide before relying on upstream-specific regex behavior.

Conditional and scalar values

GREATEST(value, value, ...)

Returns selected value

Returns the greatest or least argument. Any NULL returns NULL. All-numeric inputs use numeric comparison; mixed inputs use their string forms.

SELECT GREATEST(3, 1, 2);
Source: sql/mysql_functions.go · e5e2eb2

IF(condition, when_true, when_false)

Returns selected value

Evaluates only the chosen branch. NULL or a false condition selects when_false.

SELECT IF(1, 'yes', 'no');
Source: sql/mysql_functions.go · e5e2eb2

ISNULL(value)

Returns INTEGER

Returns 1 for SQL NULL and 0 otherwise.

SELECT ISNULL(NULL);
Source: sql/mysql_function_utility.go:303 · e5e2eb2

LEAST(value, value, ...)

Returns selected value

Returns the greatest or least argument. Any NULL returns NULL. All-numeric inputs use numeric comparison; mixed inputs use their string forms.

SELECT LEAST(3, 1, 2);
Source: sql/mysql_functions.go · e5e2eb2

Strings and bytes

ASCII(value)

Returns INTEGER

Returns the first byte value or zero for empty input. NULL stays NULL.

SELECT ASCII('A');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

BIT_LENGTH(value)

Returns INTEGER

Returns eight times the input byte length.

SELECT BIT_LENGTH('Go');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

CHAR(code [, code, ...] [USING utf8mb4])

Returns BLOB or TEXT

Builds bytes from integer codes, skipping NULL codes. The USING UTF-8 form returns validated TEXT instead of the default binary result.

SELECT CHAR(71, 111);
Source: sql/mysql_function_strings.go:671 · e5e2eb2

CHAR_LENGTH(value)

Returns INTEGER

Counts Unicode code points in TEXT or bytes in BLOB. These names are aliases.

SELECT CHAR_LENGTH('slime');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

CHARACTER_LENGTH(value)

Returns INTEGER

Counts Unicode code points in TEXT or bytes in BLOB. These names are aliases.

SELECT CHARACTER_LENGTH('slime');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

CHARSET(value)

Returns TEXT

Reports the expression charset or collation label. Text defaults to utf8mb4/utf8mb4_bin; binary and nontext values report binary.

SELECT CHARSET('slime');
Source: sql/mysql_function_utility.go:313 · e5e2eb2

COLLATION(value)

Returns TEXT

Reports the expression charset or collation label. Text defaults to utf8mb4/utf8mb4_bin; binary and nontext values report binary.

SELECT COLLATION('slime');
Source: sql/mysql_function_utility.go:313 · e5e2eb2

CONCAT(value [, value, ...])

Returns TEXT or BLOB

Concatenates values; any NULL argument returns NULL. A BLOB argument makes the result binary.

PostgreSQL CONCAT skips NULL arguments instead.

SELECT CONCAT('slop', 'db');
Source: sql/mysql_functions.go · e5e2eb2

CONCAT_WS(separator, value [, value, ...])

Returns TEXT or BLOB

Concatenates non-NULL values with a separator. A NULL separator returns NULL; NULL values are skipped.

SELECT CONCAT_WS('-', 'slop', NULL, 'db');
Source: sql/mysql_function_strings.go:549 · e5e2eb2

ELT(index, value [, value, ...])

Returns TEXT or BLOB

Returns the one-based selected value or NULL for an invalid index.

SELECT ELT(2, 'a', 'b');
Source: sql/mysql_function_strings.go:133 · e5e2eb2

EXPORT_SET(bits, on, off [, separator [, number_of_bits]])

Returns TEXT or BLOB

Formats each selected bit as on or off, low bit first. Separator defaults to comma; bit count defaults to 64 and is capped at 64.

SELECT EXPORT_SET(5, 'Y', 'N', ',', 3);
Source: sql/mysql_function_strings.go:770 · e5e2eb2

FIELD(value, candidate [, candidate, ...])

Returns INTEGER

Returns the one-based index of the first matching candidate, or zero. NULL search values do not match NULL candidates.

SELECT FIELD('b', 'a', 'b');
Source: sql/mysql_function_strings.go:640 · e5e2eb2

FIND_IN_SET(value, comma_list)

Returns INTEGER

Returns the one-based position in a comma-separated list, or zero if absent. NULL propagates.

SELECT FIND_IN_SET('b', 'a,b,c');
Source: sql/mysql_function_strings.go:108 · e5e2eb2

FROM_BASE64(text)

Returns BLOB

Decodes Base64, ignoring supported whitespace; invalid encoded data returns NULL.

SELECT FROM_BASE64('R28=');
Source: sql/mysql_function_strings.go:211 · e5e2eb2

INSERT(value, position, length, replacement)

Returns TEXT or BLOB

Replaces a span at a one-based position. An invalid position leaves the original unchanged; a negative length replaces through the end.

SELECT INSERT('slopdb', 1, 4, 'go');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

LCASE(text)

Returns TEXT or BLOB

Aliases for lowercasing and uppercasing Unicode text, respectively; binary input retains binary result metadata.

BLOB input is returned unchanged with binary result metadata.

SELECT LCASE('Slime');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

LEFT(value, count)

Returns TEXT or BLOB

Returns the requested number of characters from the left or right. TEXT counts code points and BLOB counts bytes; a nonpositive count returns an empty value.

SELECT LEFT('slopdb', 2);
Source: sql/mysql_function_strings.go:32 · e5e2eb2

LOCATE(needle, haystack [, start])

Returns INTEGER

Returns a one-based match position from optional start, or zero if absent. Text positions count characters; binary positions count bytes.

SELECT LOCATE('db', 'slopdb');
Source: sql/mysql_function_strings.go:572 · e5e2eb2

LPAD(value, length, padding)

Returns TEXT or BLOB

Pads to a character/byte length or truncates longer input. Zero returns empty; negative length returns NULL. An empty pad returns empty when extension would be needed.

SELECT LPAD('go', 5, '.');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

MAKE_SET(bits, value [, value, ...])

Returns TEXT or BLOB

Builds a comma-separated list of non-NULL values selected by bits, beginning with the low bit.

SELECT MAKE_SET(5, 'a', 'b', 'c');
Source: sql/mysql_function_strings.go:744 · e5e2eb2

MID(value, start [, length])

Returns TEXT or BLOB

Returns a one-based slice; negative positions count from the end. Zero, out-of-range positions, or nonpositive lengths produce an empty value.

Also supports SUBSTRING(value FROM start FOR length). Unlike native SUBSTR, negative length does not select preceding characters.

SELECT MID('slopdb', 2, 3);
Source: sql/mysql_function_strings.go:32 · e5e2eb2

OCTET_LENGTH(value)

Returns INTEGER

Counts bytes, including the UTF-8 bytes of TEXT.

SELECT OCTET_LENGTH('é');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

ORD(value)

Returns INTEGER

Combines the first character’s UTF-8 bytes into an integer; BLOB input uses its first byte. Empty input returns zero.

SELECT ORD('A');
Source: sql/mysql_function_strings.go:48 · e5e2eb2

POSITION(needle IN haystack)

Returns INTEGER

SQL POSITION syntax for a first-match location, or zero when absent.

SELECT POSITION('db' IN 'slopdb');
Source: sql/mysql_function_strings.go:572 · e5e2eb2

REPEAT(value, count)

Returns TEXT or BLOB

Repeats a value; nonpositive count returns empty. Expanded results are checked against the query memory budget.

SELECT REPEAT('go', 3);
Source: sql/mysql_function_strings.go:32 · e5e2eb2

REVERSE(value)

Returns TEXT or BLOB

Reverses Unicode code points for TEXT or bytes for BLOB.

SELECT REVERSE('slime');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

RIGHT(value, count)

Returns TEXT or BLOB

Returns the requested number of characters from the left or right. TEXT counts code points and BLOB counts bytes; a nonpositive count returns an empty value.

SELECT RIGHT('slopdb', 2);
Source: sql/mysql_function_strings.go:32 · e5e2eb2

RPAD(value, length, padding)

Returns TEXT or BLOB

Pads to a character/byte length or truncates longer input. Zero returns empty; negative length returns NULL. An empty pad returns empty when extension would be needed.

SELECT RPAD('go', 5, '.');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

SOUNDEX(value)

Returns TEXT or BLOB

Returns the implemented Soundex phonetic code; this is not a locale-aware fuzzy matching engine.

SELECT SOUNDEX('Robert');
Source: sql/mysql_function_strings.go:805 · e5e2eb2

SPACE(count)

Returns TEXT

Returns count spaces; a nonpositive count returns an empty string.

SELECT SPACE(3);
Source: sql/mysql_function_strings.go:79 · e5e2eb2

STRCMP(a, b)

Returns INTEGER

Returns -1, 0, or 1 from active collation-aware string comparison. NULL propagates.

SELECT STRCMP('a', 'b');
Source: sql/mysql_function_strings.go:94 · e5e2eb2

SUBSTRING(value, start [, length])

Returns TEXT or BLOB

Returns a one-based slice; negative positions count from the end. Zero, out-of-range positions, or nonpositive lengths produce an empty value.

Also supports SUBSTRING(value FROM start FOR length). Unlike native SUBSTR, negative length does not select preceding characters.

SELECT SUBSTRING('slopdb', 2, 3);
Source: sql/mysql_functions.go · e5e2eb2

SUBSTRING_INDEX(value, delimiter, count)

Returns TEXT or BLOB

Returns the portion before count delimiter occurrences for positive count, or after that many occurrences from the right for negative count. Matching is literal.

SELECT SUBSTRING_INDEX('a.b.c', '.', 2);
Source: sql/mysql_function_strings.go:32 · e5e2eb2

TO_BASE64(value)

Returns TEXT

Encodes bytes as Base64, inserting a line break after each 76 output characters.

SELECT TO_BASE64('Go');
Source: sql/mysql_function_strings.go:185 · e5e2eb2

UCASE(text)

Returns TEXT or BLOB

Aliases for lowercasing and uppercasing Unicode text, respectively; binary input retains binary result metadata.

BLOB input is returned unchanged with binary result metadata.

SELECT UCASE('Slime');
Source: sql/mysql_function_strings.go:32 · e5e2eb2

UNHEX(text)

Returns BLOB

Decodes hexadecimal text to bytes. Odd-length strings are left-padded with zero; invalid hex returns NULL.

SELECT UNHEX('476F');
Source: sql/mysql_function_strings.go:168 · e5e2eb2

Regular expressions

REGEXP_INSTR(value, pattern [, position [, occurrence [, return_option [, match_type]]]])

Returns INTEGER

Returns a one-based match start (return_option 0) or position after the match (1), or zero if no match. Positions count Unicode characters.

SELECT REGEXP_INSTR('slime', 'im');
Source: sql/mysql_function_regexp.go:32 · e5e2eb2

REGEXP_LIKE(value, pattern [, match_type])

Returns INTEGER

Returns 1 when a RE2 pattern matches, 0 otherwise. Match flags include case and multiline controls; NULL propagates.

SELECT REGEXP_LIKE('slime', '^s');
Source: sql/mysql_function_regexp.go:32 · e5e2eb2

REGEXP_REPLACE(value, pattern, replacement [, position [, occurrence [, match_type]]])

Returns TEXT

Replaces matching substrings. Occurrence zero replaces all; positive occurrence replaces only that match. Capture references in replacement are supported.

Regex uses RE2, not ICU: lookarounds and pattern backreferences are rejected. Some noninitial-position anchored matches are also rejected.

SELECT REGEXP_REPLACE('slime', 'im', 'op');
Source: sql/mysql_function_regexp.go:32 · e5e2eb2

REGEXP_SUBSTR(value, pattern [, position [, occurrence [, match_type]]])

Returns TEXT

Returns the selected match or NULL when absent.

SELECT REGEXP_SUBSTR('slime', 'im');
Source: sql/mysql_function_regexp.go:32 · e5e2eb2

Numeric and mathematical functions

ABS(number)

Returns numeric

Returns absolute value using MySQL numeric-prefix coercion and exact-number handling. Signed minimum BIGINT overflow fails.

SELECT ABS(-12);
Source: sql/mysql_function_numeric.go:101 · e5e2eb2

ACOS(number)

Returns REAL

Inverse cosine in radians. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT ACOS(1);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

ASIN(number)

Returns REAL

Inverse sine in radians. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT ASIN(0);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

ATAN(value) or ATAN(y, x)

Returns REAL

Returns inverse tangent in radians, with optional two-argument quadrant selection.

SELECT ATAN(1);
Source: sql/mysql_function_numeric.go:48 · e5e2eb2

ATAN2(y, x)

Returns REAL

Returns the quadrant-aware inverse tangent in radians.

SELECT ATAN2(1, 1);
Source: sql/mysql_function_numeric.go:48 · e5e2eb2

BIN(number)

Returns TEXT

Returns unsigned integer digits in base 2 (BIN) or base 8 (OCT).

SELECT BIN(10);
Source: sql/mysql_function_numeric.go:143 · e5e2eb2

BIT_COUNT(value)

Returns INTEGER

Counts set bits in an integer or all bytes of a BLOB.

SELECT BIT_COUNT(7);
Source: sql/mysql_function_numeric.go:156 · e5e2eb2

CEIL(number)

Returns numeric

Rounds toward positive infinity for CEIL/CEILING, or negative infinity for FLOOR. Exact integer/DECIMAL inputs retain exact computation.

SELECT CEIL(12.3);
Source: sql/mysql_function_numeric.go:81 · e5e2eb2

CEILING(number)

Returns numeric

Rounds toward positive infinity for CEIL/CEILING, or negative infinity for FLOOR. Exact integer/DECIMAL inputs retain exact computation.

SELECT CEILING(12.3);
Source: sql/mysql_function_numeric.go:81 · e5e2eb2

CONV(number, from_base, to_base)

Returns TEXT

Converts a numeric string between bases 2 through 36; signed destination bases select signed interpretation.

SELECT CONV('FF', 16, 10);
Source: sql/mysql_function_numeric.go:132 · e5e2eb2

COS(number)

Returns REAL

Cosine of a radian angle. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT COS(0);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

COT(number)

Returns REAL

Cotangent of a radian angle. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT COT(1);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

CRC32(value)

Returns unsigned INTEGER

Returns the unsigned IEEE CRC-32 checksum of the input bytes.

SELECT CRC32('Go');
Source: sql/mysql_function_numeric.go:150 · e5e2eb2

DEGREES(number)

Returns REAL

Converts radians to degrees. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT DEGREES(1);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

EXP(number)

Returns REAL

Base-e exponential. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT EXP(1);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

FLOOR(number)

Returns numeric

Rounds toward positive infinity for CEIL/CEILING, or negative infinity for FLOOR. Exact integer/DECIMAL inputs retain exact computation.

SELECT FLOOR(12.3);
Source: sql/mysql_function_numeric.go:81 · e5e2eb2

FORMAT(number, decimal_places [, locale])

Returns TEXT

Returns a rounded, grouped numeric string using the supported locale’s punctuation. Default locale is en_US.

This is numeric formatting; PostgreSQL FORMAT interprets a formatting template instead.

SELECT FORMAT(1234.5, 2, 'en_US');
Source: sql/mysql_function_numeric.go:513 · e5e2eb2

LN(number)

Returns REAL

Natural logarithm. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT LN(2);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

LOG(value) or LOG(base, value)

Returns REAL

One argument computes the natural logarithm; two arguments choose the base. Invalid bases or domains return NULL.

PostgreSQL LOG(value) uses base 10.

SELECT LOG(2, 8);
Source: sql/mysql_function_numeric.go:33 · e5e2eb2

LOG10(number)

Returns REAL

Base-10 logarithm. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT LOG10(100);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

LOG2(number)

Returns REAL

Base-2 logarithm. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT LOG2(8);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

MOD(a, b)

Returns numeric

Returns the remainder using exact arithmetic when possible. A zero divisor returns NULL; floating inputs use real arithmetic.

SELECT MOD(7, 3);
Source: sql/mysql_function_numeric.go:381 · e5e2eb2

OCT(number)

Returns TEXT

Returns unsigned integer digits in base 2 (BIN) or base 8 (OCT).

SELECT OCT(10);
Source: sql/mysql_function_numeric.go:143 · e5e2eb2

PI()

Returns REAL

Returns the double-precision value of pi.

SELECT PI();
Source: sql/mysql_function_numeric.go:32 · e5e2eb2

POW(base, exponent)

Returns REAL

Raises base to exponent with double-precision math. Invalid real domains return NULL; overflowing results fail.

SELECT POW(2, 3);
Source: sql/mysql_function_numeric.go:62 · e5e2eb2

POWER(base, exponent)

Returns REAL

Raises base to exponent with double-precision math. Invalid real domains return NULL; overflowing results fail.

SELECT POWER(2, 3);
Source: sql/mysql_function_numeric.go:62 · e5e2eb2

RADIANS(number)

Returns REAL

Converts degrees to radians. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT RADIANS(180);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

RAND([seed])

Returns REAL

Returns a pseudo-random REAL. A constant seed initializes statement-local sequences; column-dependent seeds reseed per row. Prepared executions start a fresh seeded sequence.

RAND is volatile even with a seed. It is not a cryptographic random generator.

SELECT RAND(7);
Source: sql/mysql_function_numeric.go:175 · e5e2eb2

ROUND(number [, digits])

Returns numeric

Rounds at a decimal position, including negative positions. Exact integer/DECIMAL ties round away from zero; approximate DOUBLE ties use nearest-even.

SELECT ROUND(125, -1);
Source: sql/mysql_function_numeric.go:91 · e5e2eb2

SIGN(number)

Returns INTEGER

Returns -1, 0, or 1 according to the numeric sign. NULL propagates.

SELECT SIGN(-12);
Source: sql/mysql_function_numeric.go:69 · e5e2eb2

SIN(number)

Returns REAL

Sine of a radian angle. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT SIN(0);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

SQRT(number)

Returns REAL

Square root. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT SQRT(9);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

TAN(number)

Returns REAL

Tangent of a radian angle. Uses double precision; NULL propagates, invalid real domains return NULL, and nonfinite overflow fails.

SELECT TAN(0);
Source: sql/mysql_function_numeric.go:16 · e5e2eb2

TRUNCATE(number, digits)

Returns numeric

Truncates decimal places toward zero. Negative digits remove integer digits to the left of the decimal point.

SELECT TRUNCATE(12.345, 2);
Source: sql/mysql_function_numeric.go:85 · e5e2eb2

Dates, times, and calendars

ADDDATE(date, INTERVAL amount unit)

Returns TEXT

Adds or subtracts a calendar/time interval, clamping month-end dates. ADDDATE/SUBDATE also accept a two-argument day count.

Supported simple and compound interval units are parsed by the engine. This does not provide unrestricted interval SQL semantics.

SELECT ADDDATE('2026-01-31', INTERVAL 1 MONTH);
Source: sql/mysql_function_temporal.go:310 · e5e2eb2

ADDTIME(value, duration)

Returns TEXT

Adds or subtracts a time duration; date-time input retains a date-time result.

SELECT ADDTIME('12:00:00', '01:30:00');
Source: sql/mysql_function_temporal.go:120 · e5e2eb2

CONVERT_TZ(datetime, from_timezone, to_timezone)

Returns TEXT

Converts a civil date-time between UTC/GMT, supported fixed offsets, or available IANA time zones, including daylight-saving changes. Unknown zones and invalid inputs return NULL.

Named zones use the host time-zone database. Values outside the supported Unix conversion range retain their original civil value.

SELECT CONVERT_TZ('2026-01-02 12:00:00', '+00:00', '+02:00');
Source: sql/mysql_function_extra.go:42 · e5e2eb2

DATE_ADD(date, INTERVAL amount unit)

Returns TEXT

Adds or subtracts a calendar/time interval, clamping month-end dates. ADDDATE/SUBDATE also accept a two-argument day count.

Supported simple and compound interval units are parsed by the engine. This does not provide unrestricted interval SQL semantics.

SELECT DATE_ADD('2026-01-31', INTERVAL 1 MONTH);
Source: sql/mysql_function_temporal.go:310 · e5e2eb2

DATE_FORMAT(value, format)

Returns TEXT

Formats a date/time using the supported MySQL percent templates. Calendar names are English and the session timezone is UTC.

SELECT DATE_FORMAT('2026-01-02 12:34:56', '%H:%i:%s');
Source: sql/mysql_function_temporal.go:280 · e5e2eb2

DATE_SUB(date, INTERVAL amount unit)

Returns TEXT

Adds or subtracts a calendar/time interval, clamping month-end dates. ADDDATE/SUBDATE also accept a two-argument day count.

Supported simple and compound interval units are parsed by the engine. This does not provide unrestricted interval SQL semantics.

SELECT DATE_SUB('2026-01-31', INTERVAL 1 MONTH);
Source: sql/mysql_function_temporal.go:310 · e5e2eb2

DATEDIFF(a, b)

Returns INTEGER

Returns the calendar-day difference a minus b, ignoring clock parts.

SELECT DATEDIFF('2026-01-03', '2026-01-01');
Source: sql/mysql_function_temporal.go:108 · e5e2eb2

DAY(date)

Returns INTEGER

Day of month. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT DAY('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

DAYNAME(date)

Returns TEXT

English weekday name. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT DAYNAME('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

DAYOFMONTH(date)

Returns INTEGER

Day of month. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT DAYOFMONTH('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

DAYOFWEEK(date)

Returns INTEGER

Weekday with Sunday=1 through Saturday=7. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT DAYOFWEEK('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

DAYOFYEAR(date)

Returns INTEGER

One-based day of year. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT DAYOFYEAR('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

EXTRACT(unit FROM value)

Returns INTEGER

Extracts a component or supported compound component such as YEAR_MONTH.

SELECT EXTRACT(YEAR_MONTH FROM '2026-01-02');
Source: sql/mysql_function_temporal.go:333 · e5e2eb2

FROM_DAYS(day_number)

Returns TEXT

Converts a MySQL day number to a date. Values outside the implemented calendar range return the zero-date text 0000-00-00.

SELECT FROM_DAYS(739983);
Source: sql/mysql_function_temporal.go:187 · e5e2eb2

FROM_UNIXTIME(seconds [, format])

Returns TEXT

Converts supported nonnegative Unix seconds to UTC date-time TEXT, or formats the result with a MySQL template.

SELECT FROM_UNIXTIME(0);
Source: sql/mysql_function_temporal.go:264 · e5e2eb2

GET_FORMAT(type, format_family)

Returns TEXT

Returns a MySQL date/time format template for DATE, TIME, DATETIME, or TIMESTAMP. Format families are USA, JIS, ISO, EUR, and INTERNAL. Unknown families return NULL; an invalid temporal type fails.

SELECT GET_FORMAT(DATE, 'ISO');
Source: sql/mysql_function_extra.go:15 · e5e2eb2

HOUR(time)

Returns INTEGER

Returns the absolute hour component, including supported multi-day durations; the sign is not included in the HOUR result.

SELECT HOUR('12:34:56.123456');
Source: sql/mysql_function_temporal.go:71 · e5e2eb2

LAST_DAY(date)

Returns TEXT

Last calendar date of the input month. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT LAST_DAY('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

MAKEDATE(year, day_of_year)

Returns TEXT

Builds a date from a year and one-based day count. Nonpositive day counts return NULL.

SELECT MAKEDATE(2026, 32);
Source: sql/mysql_function_temporal.go:149 · e5e2eb2

MAKETIME(hour, minute, second)

Returns TEXT

Builds a signed time value, including fractional seconds, subject to duration limits.

SELECT MAKETIME(12, 34, 56);
Source: sql/mysql_function_temporal.go:122 · e5e2eb2

MICROSECOND(time)

Returns numeric

Fractional microseconds. The implementation supports signed MySQL time durations up to 838 hours.

SELECT MICROSECOND('12:34:56.123456');
Source: sql/mysql_function_temporal.go:71 · e5e2eb2

MINUTE(time)

Returns numeric

Minute component. The implementation supports signed MySQL time durations up to 838 hours.

SELECT MINUTE('12:34:56.123456');
Source: sql/mysql_function_temporal.go:71 · e5e2eb2

MONTH(date)

Returns INTEGER

Month number 1 through 12. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT MONTH('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

MONTHNAME(date)

Returns TEXT

English month name. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT MONTHNAME('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

PERIOD_ADD(period, months)

Returns INTEGER

Adds months to a YYMM or YYYYMM period and returns a YYYYMM integer.

SELECT PERIOD_ADD(202601, 2);
Source: sql/mysql_function_temporal.go:200 · e5e2eb2

PERIOD_DIFF(a, b)

Returns INTEGER

Returns the month difference between YYMM or YYYYMM periods.

SELECT PERIOD_DIFF(202603, 202601);
Source: sql/mysql_function_temporal.go:200 · e5e2eb2

QUARTER(date)

Returns INTEGER

Quarter number 1 through 4. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT QUARTER('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

SEC_TO_TIME(seconds)

Returns TEXT

Converts signed seconds to a time string within the supported MySQL duration range.

SELECT SEC_TO_TIME(3661);
Source: sql/mysql_function_temporal.go:97 · e5e2eb2

SECOND(time)

Returns numeric

Second component. The implementation supports signed MySQL time durations up to 838 hours.

SELECT SECOND('12:34:56.123456');
Source: sql/mysql_function_temporal.go:71 · e5e2eb2

STR_TO_DATE(text, format)

Returns TEXT

Parses the implemented MySQL percent-template subset into temporal TEXT; invalid combinations return NULL.

SELECT STR_TO_DATE('2026-01-02', '%Y-%m-%d');
Source: sql/mysql_function_temporal.go:298 · e5e2eb2

SUBDATE(date, INTERVAL amount unit)

Returns TEXT

Adds or subtracts a calendar/time interval, clamping month-end dates. ADDDATE/SUBDATE also accept a two-argument day count.

Supported simple and compound interval units are parsed by the engine. This does not provide unrestricted interval SQL semantics.

SELECT SUBDATE('2026-01-31', INTERVAL 1 MONTH);
Source: sql/mysql_function_temporal.go:310 · e5e2eb2

SUBTIME(value, duration)

Returns TEXT

Adds or subtracts a time duration; date-time input retains a date-time result.

SELECT SUBTIME('12:00:00', '01:30:00');
Source: sql/mysql_function_temporal.go:120 · e5e2eb2

TIME_FORMAT(value, format)

Returns TEXT

Formats a date/time using the supported MySQL percent templates. Calendar names are English and the session timezone is UTC.

SELECT TIME_FORMAT('2026-01-02 12:34:56', '%H:%i:%s');
Source: sql/mysql_function_temporal.go:280 · e5e2eb2

TIME_TO_SEC(time)

Returns INTEGER

Returns signed elapsed whole seconds. Fractional microseconds are truncated toward zero by the current implementation.

SELECT TIME_TO_SEC('12:34:56.123456');
Source: sql/mysql_function_temporal.go:71 · e5e2eb2

TIMEDIFF(a, b)

Returns TEXT

Returns the signed time difference a minus b for compatible time/date-time inputs.

SELECT TIMEDIFF('12:00:00', '10:30:00');
Source: sql/mysql_function_temporal.go:120 · e5e2eb2

TIMESTAMPADD(unit, amount, datetime)

Returns TEXT

Adds a specified interval unit to a date-time.

SELECT TIMESTAMPADD(DAY, 2, '2026-01-01');
Source: sql/mysql_function_temporal.go:321 · e5e2eb2

TIMESTAMPDIFF(unit, start, end)

Returns INTEGER

Returns end minus start as an integer count of whole requested units.

SELECT TIMESTAMPDIFF(DAY, '2026-01-01', '2026-01-03');
Source: sql/mysql_function_temporal.go:327 · e5e2eb2

TO_DAYS(date)

Returns INTEGER

Returns the MySQL calendar day number or the corresponding seconds count, not Unix epoch time.

SELECT TO_DAYS('2026-01-02');
Source: sql/mysql_function_temporal.go:172 · e5e2eb2

TO_SECONDS(date)

Returns INTEGER

Returns the MySQL calendar day number or the corresponding seconds count, not Unix epoch time.

SELECT TO_SECONDS('2026-01-02');
Source: sql/mysql_function_temporal.go:172 · e5e2eb2

UNIX_TIMESTAMP([datetime])

Returns INTEGER or REAL

Without input returns current Unix seconds. A parsed UTC input returns epoch seconds; fractional input can produce a REAL. Invalid date text returns zero.

SELECT UNIX_TIMESTAMP('1970-01-01 00:00:00');
Source: sql/mysql_functions.go · e5e2eb2

WEEK(date [, mode])

Returns INTEGER

Returns a week number or combined year/week number under one of the eight MySQL week modes. WEEK defaults to mode 0; YEARWEEK also defaults to mode 0.

SELECT WEEK('2026-01-02', 3);
Source: sql/mysql_function_temporal.go:46 · e5e2eb2

WEEKDAY(date)

Returns INTEGER

Weekday with Monday=0 through Sunday=6. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT WEEKDAY('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

WEEKOFYEAR(date)

Returns INTEGER

Returns the ISO-style week number, equivalent to WEEK(date, 3).

SELECT WEEKOFYEAR('2026-01-02');
Source: sql/mysql_function_temporal.go:46 · e5e2eb2

YEAR(date)

Returns INTEGER

Year number. Uses the MySQL-style civil-date parser; invalid inputs can return NULL.

SELECT YEAR('2026-01-02');
Source: sql/mysql_function_temporal.go:38 · e5e2eb2

YEARWEEK(date [, mode])

Returns INTEGER

Returns a week number or combined year/week number under one of the eight MySQL week modes. WEEK defaults to mode 0; YEARWEEK also defaults to mode 0.

SELECT YEARWEEK('2026-01-02', 3);
Source: sql/mysql_function_temporal.go:46 · e5e2eb2

Clocks

CURDATE()

Returns TEXT

Returns the statement’s current UTC date. These date forms accept no precision argument.

SELECT CURDATE();
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

CURRENT_DATE()

Returns TEXT

Returns the statement’s current UTC date. These date forms accept no precision argument.

SELECT CURRENT_DATE();
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

CURRENT_TIME([precision])

Returns TEXT

Returns the statement’s current UTC time. Optional fractional precision is 0 through 6.

SELECT CURRENT_TIME(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

CURRENT_TIMESTAMP([precision])

Returns TEXT

Returns the statement’s UTC date and time; optional fractional precision is 0 through 6. Statement-time values are stable within one statement.

PostgreSQL NOW and CURRENT_TIMESTAMP have transaction-clock semantics instead.

SELECT CURRENT_TIMESTAMP(3);
Source: sql/mysql_functions.go · e5e2eb2

CURTIME([precision])

Returns TEXT

Returns the statement’s current UTC time. Optional fractional precision is 0 through 6.

SELECT CURTIME(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

LOCALTIME([precision])

Returns TEXT

Returns the statement’s UTC date and time; optional fractional precision is 0 through 6. Statement-time values are stable within one statement.

PostgreSQL NOW and CURRENT_TIMESTAMP have transaction-clock semantics instead.

SELECT LOCALTIME(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

LOCALTIMESTAMP([precision])

Returns TEXT

Returns the statement’s UTC date and time; optional fractional precision is 0 through 6. Statement-time values are stable within one statement.

PostgreSQL NOW and CURRENT_TIMESTAMP have transaction-clock semantics instead.

SELECT LOCALTIMESTAMP(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

NOW([precision])

Returns TEXT

Returns the statement’s UTC date and time; optional fractional precision is 0 through 6. Statement-time values are stable within one statement.

PostgreSQL NOW and CURRENT_TIMESTAMP have transaction-clock semantics instead.

SELECT NOW(3);
Source: sql/mysql_functions.go · e5e2eb2

SYSDATE([precision])

Returns TEXT

Reads the wall clock at evaluation time rather than the statement’s initial timestamp. Precision is 0 through 6.

SELECT SYSDATE(3);
Source: sql/mysql_functions.go · e5e2eb2

UTC_DATE()

Returns TEXT

Returns the statement’s current UTC date. These date forms accept no precision argument.

SELECT UTC_DATE();
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

UTC_TIME([precision])

Returns TEXT

Returns the statement’s current UTC time. Optional fractional precision is 0 through 6.

SELECT UTC_TIME(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

UTC_TIMESTAMP([precision])

Returns TEXT

Returns the statement’s UTC date and time; optional fractional precision is 0 through 6. Statement-time values are stable within one statement.

PostgreSQL NOW and CURRENT_TIMESTAMP have transaction-clock semantics instead.

SELECT UTC_TIMESTAMP(3);
Source: sql/mysql_function_temporal.go:239 · e5e2eb2

Digests, encryption, compression

AES_DECRYPT(value, key [, iv])

Returns BLOB

Encrypts/decrypts with the implemented default aes-128-ecb key folding and block padding. The optional IV does not change ECB operation.

Other block modes and KDF parameters are not implemented; malformed ciphertext or padding returns NULL.

SELECT AES_DECRYPT(AES_ENCRYPT('slime', 'key'), 'key');
Source: sql/mysql_function_utility.go:62 · e5e2eb2

AES_ENCRYPT(value, key [, iv])

Returns BLOB

Encrypts/decrypts with the implemented default aes-128-ecb key folding and block padding. The optional IV does not change ECB operation.

Other block modes and KDF parameters are not implemented; malformed ciphertext or padding returns NULL.

SELECT AES_DECRYPT(AES_ENCRYPT('slime', 'key'), 'key');
Source: sql/mysql_function_utility.go:62 · e5e2eb2

COMPRESS(value)

Returns BLOB

Returns the MySQL-compatible length-prefix/zlib representation of the input bytes.

SELECT COMPRESS('slime');
Source: sql/mysql_function_utility.go:431 · e5e2eb2

MD5(value)

Returns TEXT

Returns a lowercase hexadecimal digest. MD5 is MD5; SHA and SHA1 are SHA-1 aliases. NULL propagates.

SELECT MD5('slime');
Source: sql/mysql_function_utility.go:33 · e5e2eb2

RANDOM_BYTES(length)

Returns BLOB

Returns cryptographically random bytes. Length must be from 1 through 1024.

SELECT RANDOM_BYTES(16);
Source: sql/mysql_function_utility.go:113 · e5e2eb2

SHA(value)

Returns TEXT

Returns a lowercase hexadecimal digest. MD5 is MD5; SHA and SHA1 are SHA-1 aliases. NULL propagates.

SELECT SHA('slime');
Source: sql/mysql_function_utility.go:33 · e5e2eb2

SHA1(value)

Returns TEXT

Returns a lowercase hexadecimal digest. MD5 is MD5; SHA and SHA1 are SHA-1 aliases. NULL propagates.

SELECT SHA1('slime');
Source: sql/mysql_function_utility.go:33 · e5e2eb2

SHA2(value, bits)

Returns TEXT

Returns SHA-224, SHA-256, SHA-384, or SHA-512 as lowercase hex. Bits zero selects 256; unsupported sizes return NULL.

SELECT SHA2('slime', 256);
Source: sql/mysql_function_utility.go:33 · e5e2eb2

UNCOMPRESS(value)

Returns BLOB

Decodes a supported MySQL compressed value. Expansion is bounded by the query memory budget.

SELECT UNCOMPRESS(COMPRESS('slime'));
Source: sql/mysql_function_utility.go:456 · e5e2eb2

UNCOMPRESSED_LENGTH(value)

Returns INTEGER

Reads the declared uncompressed byte length from a compressed value’s prefix; a too-short input returns zero.

SELECT UNCOMPRESSED_LENGTH(COMPRESS('slime'));
Source: sql/mysql_function_utility.go:293 · e5e2eb2

UUIDs and network addresses

BIN_TO_UUID(bytes [, swap_flag])

Returns TEXT

Converts exactly 16 bytes to UUID text, optionally reversing time-field swapping. Invalid binary length fails.

SELECT BIN_TO_UUID(UUID_TO_BIN('00112233-4455-6677-8899-aabbccddeeff'));
Source: sql/mysql_function_utility.go:162 · e5e2eb2

INET_ATON(ipv4)

Returns unsigned INTEGER

Converts accepted dotted IPv4 text, including supported short forms, to an unsigned integer. Invalid addresses return NULL.

SELECT INET_ATON('127.0.0.1');
Source: sql/mysql_function_utility.go:175 · e5e2eb2

INET_NTOA(number)

Returns TEXT

Converts an in-range IPv4 integer to dotted text; invalid values return NULL.

SELECT INET_NTOA(2130706433);
Source: sql/mysql_function_utility.go:209 · e5e2eb2

INET6_ATON(address)

Returns BLOB

Parses IPv4/IPv6 into 4 or 16 bytes; invalid addresses or zone suffixes return NULL.

SELECT INET6_ATON('::1');
Source: sql/mysql_function_utility.go:226 · e5e2eb2

INET6_NTOA(bytes)

Returns TEXT

Formats a valid 4- or 16-byte network address; invalid lengths return NULL.

SELECT INET6_NTOA(INET6_ATON('::1'));
Source: sql/mysql_function_utility.go:236 · e5e2eb2

IS_IPV4(text)

Returns INTEGER

Returns 1 for a valid address of the named family and 0 otherwise, including SQL NULL.

SELECT IS_IPV4('127.0.0.1');
Source: sql/mysql_function_utility.go:256 · e5e2eb2

IS_IPV4_COMPAT(bytes)

Returns INTEGER

Tests a 16-byte address for the IPv4-compatible or IPv4-mapped binary layout. Non-16-byte inputs and NULL return zero.

SELECT IS_IPV4_COMPAT(INET6_ATON('::ffff:127.0.0.1'));
Source: sql/mysql_function_utility.go:272 · e5e2eb2

IS_IPV4_MAPPED(bytes)

Returns INTEGER

Tests a 16-byte address for the IPv4-compatible or IPv4-mapped binary layout. Non-16-byte inputs and NULL return zero.

SELECT IS_IPV4_MAPPED(INET6_ATON('::ffff:127.0.0.1'));
Source: sql/mysql_function_utility.go:272 · e5e2eb2

IS_IPV6(text)

Returns INTEGER

Returns 1 for a valid address of the named family and 0 otherwise, including SQL NULL.

SELECT IS_IPV6('127.0.0.1');
Source: sql/mysql_function_utility.go:256 · e5e2eb2

IS_UUID(value)

Returns INTEGER

Returns 1 for an accepted UUID string and 0 for invalid text; SQL NULL remains NULL.

SELECT IS_UUID('00112233-4455-6677-8899-aabbccddeeff');
Source: sql/mysql_function_utility.go:139 · e5e2eb2

UUID()

Returns TEXT

Generates a version-1-layout UUID with random node/clock-sequence components and returns its textual form.

SELECT UUID();
Source: sql/mysql_function_utility.go:125 · e5e2eb2

UUID_TO_BIN(uuid [, swap_flag])

Returns BLOB

Converts a UUID string to 16 bytes. A nonzero swap flag rearranges time fields; invalid UUID text fails.

SELECT UUID_TO_BIN('00112233-4455-6677-8899-aabbccddeeff');
Source: sql/mysql_function_utility.go:149 · e5e2eb2

Session state and named locks

BENCHMARK(count, expression)

Returns INTEGER

Evaluates an expression repeatedly and returns zero after completion. NULL/negative counts return NULL; cancellation and deadlines are checked.

SELECT BENCHMARK(2, 1 + 1);
Source: sql/mysql_function_session.go · e5e2eb2

CONNECTION_ID()

Returns INTEGER · requires session or schema setup

Returns the current MySQL protocol connection ID.

SELECT CONNECTION_ID();
Source: sql/mysql_functions.go · e5e2eb2

CURRENT_USER()

Returns TEXT · requires session or schema setup

Returns the authenticated MySQL connection identity. A MySQL connection is required.

SELECT CURRENT_USER();
Source: sql/mysql_functions.go · e5e2eb2

DATABASE()

Returns TEXT · requires session or schema setup

Returns the current database/schema name. SCHEMA is an alias through the database session state.

SELECT DATABASE();
Source: sql/mysql_functions.go · e5e2eb2

FOUND_ROWS()

Returns unsigned INTEGER

Returns the preceding SELECT row count. With SQL_CALC_FOUND_ROWS, it reports qualifying rows before LIMIT/OFFSET, counted once at the statement snapshot; otherwise it reports returned rows.

Connection-local state is updated after execution; use the same pinned connection when reading it.

SELECT FOUND_ROWS();
Source: sql/mysql_function_session.go:70 · e5e2eb2

GET_LOCK(name, timeout_seconds)

Returns INTEGER or NULL · requires session or schema setup

Acquires a connection-scoped named lock. Returns 1 on success or 0 on timeout. Reacquisition by the same connection increments an acquisition count; cancellation interrupts waits.

SELECT GET_LOCK('site-demo', 0);
Source: sql/mysql_functions.go · e5e2eb2

IS_FREE_LOCK(name)

Returns INTEGER or NULL · requires session or schema setup

Returns 1 when the named lock is unheld and 0 when it is held.

SELECT IS_FREE_LOCK('site-demo');
Source: sql/mysql_functions.go · e5e2eb2

IS_USED_LOCK(name)

Returns INTEGER or NULL · requires session or schema setup

Returns the owning connection ID, or NULL when the named lock is free.

SELECT IS_USED_LOCK('site-demo');
Source: sql/mysql_function_session.go:79 · e5e2eb2

LAST_INSERT_ID([value])

Returns unsigned INTEGER

Returns the first generated ID from the connection’s preceding insert, or explicitly sets the connection value. Explicitly supplied row IDs do not replace it; state survives rollback.

SELECT LAST_INSERT_ID();
Source: sql/mysql_function_session.go:60 · e5e2eb2

NAME_CONST(name, value)

Returns value type

Returns a literal value with its value type. Arguments must be literals or signed literal forms, and the name must not be NULL. Expressions, subqueries, and column references fail.

Available in MySQL dialect; this does not substitute SQL or create a persistent variable.

SELECT NAME_CONST('label', 42);
Source: sql/mysql_function_extra.go:76 · e5e2eb2

RELEASE_ALL_LOCKS()

Returns unsigned INTEGER · requires session or schema setup

Releases the connection’s named locks and returns the released acquisition count.

SELECT RELEASE_ALL_LOCKS();
Source: sql/mysql_function_session.go:79 · e5e2eb2

RELEASE_LOCK(name)

Returns INTEGER or NULL · requires session or schema setup

Releases one acquisition of a named lock. Returns 1 when released, 0 when held by another connection, or NULL when the lock does not exist.

SELECT RELEASE_LOCK('site-demo');
Source: sql/mysql_functions.go · e5e2eb2

ROW_COUNT()

Returns INTEGER

Reports affected rows for the preceding statement, or -1 after a result-producing statement.

SELECT ROW_COUNT();
Source: sql/mysql_function_session.go:69 · e5e2eb2

SCHEMA()

Returns TEXT · requires session or schema setup

Returns the current database/schema name. SCHEMA is an alias through the database session state.

SELECT SCHEMA();
Source: sql/mysql_function_utility.go:335 · e5e2eb2

SESSION_USER()

Returns TEXT · requires session or schema setup

Returns the MySQL connection user identity. These names use the same connection callback; native calls without that context fail.

SELECT SESSION_USER();
Source: sql/mysql_function_utility.go:335 · e5e2eb2

SLEEP(seconds)

Returns INTEGER

Waits for a nonnegative duration and returns zero on normal completion. NULL/invalid duration fails; cancellation/deadlines interrupt the wait.

SELECT SLEEP(0);
Source: sql/mysql_function_utility.go:346 · e5e2eb2

SYSTEM_USER()

Returns TEXT · requires session or schema setup

Returns the MySQL connection user identity. These names use the same connection callback; native calls without that context fail.

SELECT SYSTEM_USER();
Source: sql/mysql_function_utility.go:335 · e5e2eb2

USER()

Returns TEXT · requires session or schema setup

Returns the MySQL connection user identity. These names use the same connection callback; native calls without that context fail.

SELECT USER();
Source: sql/mysql_function_utility.go:335 · e5e2eb2

VERSION()

Returns TEXT · requires session or schema setup

Returns the MySQL protocol server’s advertised compatibility version, not a claim that the underlying engine is MySQL.

SELECT VERSION();
Source: sql/mysql_functions.go · e5e2eb2

Conversion and full-text syntax

CONVERT(value USING charset) or CONVERT(value, type)

Returns target type

Converts to supported UTF-8 charset aliases or binary bytes, or uses the supported CAST target syntax. Invalid UTF-8 and unsupported character sets fail.

SELECT CONVERT('slime' USING utf8mb4);
Source: sql/mysql_functions.go · e5e2eb2

MATCH(column [, column, ...]) AGAINST(search [mode])

Returns REAL · requires session or schema setup

Evaluates the implemented MySQL-style FULLTEXT match and relevance score. Requires the appropriate FULLTEXT index and matching column set.

Create the articles table and its FULLTEXT index before running this example. See the MySQL server guide for supported search modes.

SELECT MATCH(body) AGAINST('slime') FROM articles;
Source: sql/mysql_fulltext.go · e5e2eb2

JSON_SEARCH(document, one_or_all, pattern [, escape [, path, ...]])

Returns JSON

Searches JSON string values with LIKE-style percent/underscore wildcards. Returns one matching path, a JSON array of paths, or SQL NULL when no value matches. Optional paths restrict the search roots.

Modes are one and all. Escape defaults to backslash and must be empty or one character when supplied; a NULL escape retains the default. The document, mode, and search pattern propagate SQL NULL.

SELECT JSON_SEARCH('{"a":"slime"}', 'one', 'sl%');
Source: sql/mysql_function_extra.go:150 · e5e2eb2
Function reference checked against engine source · e5e2eb2Edit the function reference ↗