-- 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$); qs_eval --------- -1 (1 row) SELECT qs_eval($js$'b'.localeCompare('a')$js$); qs_eval --------- 1 (1 row) SELECT qs_eval($js$'é'.normalize('NFD').length$js$); qs_eval --------- 2 (1 row) SELECT qs_eval($js$'e\u0301'.normalize('NFC') === 'é'$js$); qs_eval --------- true (1 row) SELECT qs_eval($js$'fi'.normalize('NFKD')$js$); qs_eval --------- fi (1 row) SELECT qs_eval($js$['b', 'é', 'a'].sort((x, y) => x.localeCompare(y)).join()$js$); qs_eval --------- a,b,é (1 row) -- The rest of QuickJS's Unicode tables: case conversion and regular -- expressions. SELECT qs_eval($js$'Dž'.toLowerCase() + 'ß'.toUpperCase()$js$); qs_eval --------- džSS (1 row) SELECT qs_eval($js$/\p{L}+/u.test('héllo')$js$); qs_eval --------- true (1 row) SELECT qs_eval($js$/ÉCOLE/i.test('école')$js$); qs_eval --------- true (1 row) DROP FUNCTION qs_eval(text);