EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
521 stars 160 forks source link

Error decode utf-8 after upgrade #255

Closed guenlm closed 2 years ago

guenlm commented 2 years ago

Hi

I did an update on my ubuntu 20.04.4 yestarday with the latest version of mysql-fdw (postgresql-14-mysql-fdw_2.8.0-1.pgdg20.04+1) and now, I have this error on all my wrapper : 'utf-8' codec can't decode byte 0xe9 in position 61: invalid continuation byte Can you help me please (the server is in prod...) thank's

guen

surajkharage19 commented 2 years ago

Hi @guenlm,

Thanks for reporting an issue. Can you please share the complete reproducible test case with all details as I am not able to understand your concern fully?

guenlm commented 2 years ago

ok. Ubuntu Linux 20.04.4 pgAdmin 6.9 postgresql-14-mysql-fdw:amd64 2.8.0-1.pgdg20.04+1 (since yesterday...since the problem....)

I have a test mysql_fdw like this

CREATE FOREIGN TABLE IF NOT EXISTS mysql_master.tabtest(
    id integer NOT NULL,
    text character varying(255) NULL COLLATE pg_catalog."default"
)
    SERVER mysql_server
    OPTIONS (dbname 'trace_master', table_name 'tabtest');

The table tabtest on Mysql'server is in utf-8. When I put a special character in text (like 'guenaël' for example), I have an error on pgadmin like this : 'utf-8' codec can't decode byte 0xe9 in position 61: invalid continuation byte I have too an error of character inrecognize in qgis which use this fdw (so it's not only a problem with pgadmin) All was good before the last update (and restart of the server) yesterday evening. Thank's

surajkharage19 commented 2 years ago

Thanks.

On a high level, it looks like character_set issue. As a part of commit ca6adc16ca7632ffa1eb9fabcc3b3336d4749ff3, we have added server level character_set option and its default value is auto which means autodetect based on the operating system setting. Before the introduction of the character_set option, the character set was set similar to the PostgreSQL database encoding. To get this older behaviour set the character_set to special value PGDatabaseEncoding.

Please let us know if you still face this issue after setting character_set value to 'PGDatabaseEncoding'.

guenlm commented 2 years ago

sorry but how can I do that (a persistant way...) ? thank's

guenlm commented 2 years ago

ok I found and it work's. I add an option on my mysql_fdw with character_set=PGDatabaseEncoding thank's a lot !

surajkharage19 commented 2 years ago

Glad to know that your issue is resolved.

Regarding the character_set option - We have added this parameter which allows users to set the correct character_set as per their requirement. One must set the correct character_set by using that option.

Since this has been resolved, can you please close this issue?