-- QuickJS's own functions are called, not the postgres binary's of the same -- name. QuickJS was linked into pljs with its symbols visible, and on Linux, -- where postgres exports its own symbols, a call to QuickJS's -- unicode_normalize() went to PostgreSQL's, with QuickJS's arguments: the -- backend crashed, or the call threw "[unsupported type]" (issue #45). -- QuickJS is now built with hidden visibility. CREATE FUNCTION qs_eval(src text) RETURNS text LANGUAGE pljs AS $$ return String((0, eval)(src)); $$; -- unicode_normalize(), through normalize() and localeCompare(). SELECT qs_eval($js$'a'.localeCompare('b')$js$); SELECT qs_eval($js$'b'.localeCompare('a')$js$); SELECT qs_eval($js$'é'.normalize('NFD').length$js$); SELECT qs_eval($js$'e\u0301'.normalize('NFC') === 'é'$js$); SELECT qs_eval($js$'fi'.normalize('NFKD')$js$); SELECT qs_eval($js$['b', 'é', 'a'].sort((x, y) => x.localeCompare(y)).join()$js$); -- The rest of QuickJS's Unicode tables: case conversion and regular -- expressions. SELECT qs_eval($js$'Dž'.toLowerCase() + 'ß'.toUpperCase()$js$); SELECT qs_eval($js$/\p{L}+/u.test('héllo')$js$); SELECT qs_eval($js$/ÉCOLE/i.test('école')$js$); DROP FUNCTION qs_eval(text);