Add prefix for UNACCENT in getsafexmlpath (#233)

* Add prefix for UNACCENT in getsafexmlpath

The restore of a backup won't work with UNACCENT without schema prefix.

* Bugfix

* Bugfix

* Remove accidentally left over file
This commit is contained in:
Rikard Bartholf
2021-10-15 13:48:20 +02:00
committed by GitHub
parent 4650107b75
commit 9d41ec3b53
+25
View File
@@ -0,0 +1,25 @@
-- Prefix UNACCENT with "public"
CREATE OR REPLACE FUNCTION public.getsafexmlpath(val character varying, with_root integer DEFAULT 0)
RETURNS character varying
LANGUAGE plpgsql
AS $function$
BEGIN
IF with_root = 1 THEN
val = regexp_replace(val, '^\w+', 'root');
ELSIF with_root = 2 THEN
val = regexp_replace(val, '^\w+/', '');
END IF;
val = public.UNACCENT(val);
val = REGEXP_REPLACE(val, '[\., _]', '-', 'g');
val = REPLACE(val, '&', '-'); /* ampersand should always be blank but it gets fixed in below */
val = lower(val);
val = REGEXP_REPLACE(val, '-+', '-', 'g');
val = REGEXP_REPLACE(val, '[^\/\w\-]', '', 'g');
RETURN val;
END;
$function$
;