Re: proposal: unescape_text function - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: unescape_text function
Date
Msg-id CAFj8pRBwrnotQzzVmG8s1i+cZ=h0FNv08Q=OcG+9NPMy7jkZ6g@mail.gmail.com
Whole thread Raw
In response to proposal: unescape_text function  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: unescape_text function
List pgsql-hackers


po 22. 6. 2020 v 5:48 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:
Hi

There is one user request for unescape function in core.


This request is about possibility that we do with string literal via functional interface instead string literals only

I wrote plpgsql function, but built in function can be simpler:

CREATE OR REPLACE FUNCTION public.unescape(text, text) RETURNS textLANGUAGE plpgsqlAS $function$DECLARE result text;BEGIN  EXECUTE format('SELECT U&%s UESCAPE %s',                         quote_literal(replace($1, '\u','^')),                        quote_literal($2)) INTO result;  RETURN result;END;$function$
postgres=# select unescape('Odpov\u011Bdn\u00E1 osoba','^');   unescape     
-----------------Odpovědná osoba
(1 row)
What do you think about this?

I changed the name to more accurately "unicode_unescape". Patch is assigned

Regards

Pavel


Regards

Pavel
Attachment

pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: Assertion failure in pg_copy_logical_replication_slot()
Next
From: Amit Kapila
Date:
Subject: Re: EXPLAIN: Non-parallel ancestor plan nodes exclude parallel worker instrumentation