extra_misc is a MariaDB plugin that adds small utility SQL functions:
unaccent(str)slugify(str)age(date_or_datetime)human_number(number)parse_duration(str)
SELECT plugin_name, plugin_type, plugin_library,
plugin_description, plugin_author
FROM information_schema.PLUGINS
WHERE plugin_type = 'FUNCTION' AND plugin_library = 'extra_misc.so'
ORDER BY plugin_name;Result:
+----------------+-------------+----------------+---------------------------+---------------+
| plugin_name | plugin_type | plugin_library | plugin_description | plugin_author |
+----------------+-------------+----------------+---------------------------+---------------+
| age | FUNCTION | extra_misc.so | Function AGE() | lefred |
| human_number | FUNCTION | extra_misc.so | Function HUMAN_NUMBER() | lefred |
| parse_duration | FUNCTION | extra_misc.so | Function PARSE_DURATION() | lefred |
| slugify | FUNCTION | extra_misc.so | Function SLUGIFY() | lefred |
| unaccent | FUNCTION | extra_misc.so | Function UNACCENT() | lefred |
+----------------+-------------+----------------+---------------------------+---------------+
Link or copy this directory into the MariaDB plugin directory as
extra_misc, then configure MariaDB with the plugin enabled:
cmake -S /path/to/MariaDB-server \
-B /path/to/build \
-DPLUGIN_EXTRA_MISC=DYNAMIC
cmake --build /path/to/build --target extra_miscINSTALL SONAME 'extra_misc';Returns str with common Latin accents removed.
SELECT unaccent('Crème brûlée déjà vu');
-- Creme brulee deja vuRemoves accents, lowercases ASCII letters, replaces separator runs with -,
and trims leading/trailing separators.
SELECT slugify('Crème brûlée déjà vu!');
-- creme-brulee-deja-vuReturns the calendar-aware elapsed duration between date_or_datetime and the
current statement timestamp.
SELECT age('1976-03-14 06:50:00');
-- 50y 3mo 4d 8h 36m 46sFormats large numbers using SI-style suffixes.
SELECT human_number(1234567);
-- 1.23MParses a human duration and returns seconds. Supported forms include unit
groups, HH:MM:SS, and a simple ISO-8601 duration subset.
SELECT parse_duration('1h 30m 10.5s');
-- 5410.5
SELECT parse_duration('01:02:03');
-- 3723
SELECT parse_duration('P1DT2H');
-- 93600Supported unit names are seconds, minutes, hours, days, and weeks. ISO month values are treated as 30 days.
cd /path/to/build/mysql-test
./mtr extra_misc