Open huiflyy opened 13 years ago
I am using version 1.0.1 of mysql_fdw and have run on the same problem with Greek I have solved the problem by editing the source file mysql_fdw.c and adding right before each
mysql_real_connect()
the following commands mysql_options(conn, MYSQL_SET_CHARSET_NAME, "utf8"); mysql_options(conn, MYSQL_INIT_COMMAND, "SET NAMES utf8");
It is a simple solution that works fine if all of your databases, that you are going to connect to, are UTF8.
--- mysql_fdw.c.orig 2013-02-03 16:34:32.000000000 +0200 +++ mysql_fdw.c 2013-03-07 16:23:33.000000000 +0200 @@ -422,6 +422,9 @@ errmsg("failed to initialise the MySQL connection object") ));
if (!mysql_real_connect(conn, svr_address, svr_username, svr_password, svr_database, svr_port, NULL, 0)) ereport(ERROR, (errcode(ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION),
In case anyone cannot get Chinese supported, the working settings for us is character_set 'utf8'
but not character_set 'utf8mb4'
etc.
CREATE SERVER mysql_rds FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host 'my-rds.us-west-2.rds.amazonaws.com', port '3306', character_set 'utf8');
query the foreign table contains Chinese content, shows '????'
mysql 5.0.77 utf8 postgresql 9.1 utf8