PATCH: Add uri percent-encoding for binary data

From: Anders Åstrand <anders(at)449(dot)se>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PATCH: Add uri percent-encoding for binary data
Date: 2019-10-07 07:14:38
Message-ID: CAPwPebtwJnjjt=eUUsmL1zZ6w3jVnA1cVjEzhBoucCYTJc9D2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

Attached is a patch for adding uri as an encoding option for
encode/decode. It uses what's called "percent-encoding" in rfc3986
(https://tools.ietf.org/html/rfc3986#section-2.1).

The background for this patch is that I could easily build urls in
plpgsql, but doing the actual encoding of the url parts is painfully
slow. The list of available encodings for encode/decode looks quite
arbitrary to me, so I can't see any reason this one couldn't be in
there.

In modern web scenarios one would probably most likely want to encode
the utf8 representation of a text string for inclusion in a url, in
which case correct invocation would be ENCODE(CONVERT_TO('some text in
database encoding goes here', 'UTF8'), 'uri'), but uri
percent-encoding can of course also be used for other text encodings
and arbitrary binary data.

Regards,
Anders

Attachment Content-Type Size
uri-encoding-v1.patch text/x-patch 4.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-10-07 07:38:21 Re: refactoring - share str2*int64 functions
Previous Message Ashutosh Sharma 2019-10-07 07:05:19 Re: Change atoi to strtol in same place