Please tell me about character code conversion.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Please tell me about character code conversion.

久門 愛
Hi,
Please tell me about character code conversion.
I am currently using Postgres 13.3.
I would like to set my own character code conversion as DEFAULT CONVERSION.
Since there is a CONVERSION provided by Postgres by default, the following
error will occur when executing CREATE CONVERSION.
-----------------------------
postgres=# CREATE DEFAULT CONVERSION pg_catalog.myconv_sjis_to_utf8 FOR
'SJIS' TO 'UTF8' FROM myconv_sjis_to_utf8;
ERROR:  default conversion for SJIS to UTF8 already exists
postgres=#
-----------------------------

As a method to change the conversion provided by default, execute the
following SQL statement and after executing CREATE CONVERSION
I am trying to update the system catalog with an UPDATE statement. Is there
any problem with this method?
-----------------------------
CREATE CONVERSION pg_catalog.myconv_sjis_to_utf8 FOR 'SJIS' TO 'UTF8' FROM
myconv_sjis_to_utf8;
UPDATE pg_conversion SET condefault='f' WHERE conname='sjis_to_utf8';
UPDATE pg_conversion SET condefault='t' WHERE conname='myconv_sjis_to_utf8';
-----------------------------

Thanks
Ai




Reply | Threaded
Open this post in threaded view
|

Re: Please tell me about character code conversion.

Tom Lane-2
=?iso-2022-jp?B?GyRCNVdMZyEhMCYbKEI=?= <[hidden email]> writes:
> I would like to set my own character code conversion as DEFAULT CONVERSION.

That's not an area of functionality that ever got fleshed out completely.
What you're thinking about sounds like it'd work, but I'd strongly
suggest experimenting in a scratch database before doing it with
irreplaceable data.

Keep in mind also that pg_dump/pg_upgrade will absolutely not
reproduce this configuration for you.

                        regards, tom lane