Re: [PGdocs] fix description for handling pf non-ASCII characters - Mailing list pgsql-hackers

From jian he
Subject Re: [PGdocs] fix description for handling pf non-ASCII characters
Date
Msg-id CACJufxFkp8c0ap6YhyXRpVkjsB8pwZjWH9Hqc1tVF0aNWFRzFA@mail.gmail.com
Whole thread Raw
In response to [PGdocs] fix description for handling pf non-ASCII characters  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
Responses RE: [PGdocs] fix description for handling pf non-ASCII characters
List pgsql-hackers
On Fri, Jun 23, 2023 at 10:25 PM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> Dear hackers,
>
> While discussing based on the article[1] with Japanese developers,
> I found inconsistencies between codes and documents.
>
> 45b1a67a[2] changed the behavior when non-ASCII characters was set as application_name,
> cluster_name and postgres_fdw.application_name, but it seemed not to be documented.
> Previously non-ASCII chars were replaed with question makrs '?', but now they are replaced
> with a hex escape instead.
>
> How do you think? Is my understanding correct?
>
> Acknowledgement:
> Sawada-san and Shinoda-san led the developer's discussion.
> Fujii-san was confirmed my points. Thank you for all of their works!
>
> [1]:
https://h50146.www5.hpe.com/products/software/oe/linux/mainstream/support/lcc/pdf/PostgreSQL16Beta1_New_Features_en_20230528_1.pdf
> [2]:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=45b1a67a0fcb3f1588df596431871de4c93cb76f;hp=da5d4ea5aaac4fc02f2e2aec272efe438dd4e171
>
> Best Regards,
> Hayato Kuroda
> FUJITSU LIMITED
>

in your patch:
> printable ASCII characters will be replaced with a hex escape.

My wording is not good. I think the result will be: ASCII characters
will be as is, non-ASCII characters will be replaced with "a hex
escape".

set application_name to 'abc漢字Abc';
SET
test16=# show application_name;
        application_name
--------------------------------
 abc\xe6\xbc\xa2\xe5\xad\x97Abc
(1 row)

I see multi escape, so I am not sure "a hex escape".

to properly render it back to  'abc漢字Abc'
here is how i do it:
select 'abc' || convert_from(decode(' e6bca2e5ad97','hex'), 'UTF8') || 'Abc';

I guess it's still painful if your application_name has non-ASCII chars.



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Assert !bms_overlap(joinrel->relids, required_outer)
Next
From: Richard Guo
Date:
Subject: Trivial revise for the check of parameterized partial paths