By digoal
What can I do if unreadable code appears because the character set of MySQL is different from the character set of PostgreSQL?
Check the mysql_fdw source code. The options for mysql_fdw are listed below:
#define CR_NO_ERROR 0
/*
* Options structure to store the MySQL
* server information
*/
typedef struct mysql_opt
{
int svr_port; /* MySQL port number */
char *svr_address; /* MySQL server ip address */
char *svr_username; /* MySQL user name */
char *svr_password; /* MySQL password */
char *svr_database; /* MySQL database name */
char *svr_table; /* MySQL table name */
bool svr_sa; /* MySQL secure authentication */
char *svr_init_command; /* MySQL SQL statement to execute when connecting to the MySQL server. */
unsigned long max_blob_size; /* Max blob size to read without truncation */
bool use_remote_estimate; /* use remote estimate for rows */
// SSL parameters; unused options may be given as NULL
char *ssl_key; /* MySQL SSL: path to the key file */
char *ssl_cert; /* MySQL SSL: path to the certificate file */
char *ssl_ca; /* MySQL SSL: path to the certificate authority file */
char *ssl_capath; /* MySQL SSL: path to a directory that contains trusted SSL CA certificates in PEM format */
char *ssl_cipher; /* MySQL SSL: list of permissible ciphers to use for SSL encryption */
} mysql_opt;
svr_init_command
indicates that an SQL request (like the set connection variable) can be executed when PostgreSQL connects to MySQL using mysql_fdw
.
You can set the init_command
option to set the character set of the MySQL client to enable automatic transcoding.
https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html
As described above, it is still necessary for applications to configure their connection using SET NAMES or equivalent after they connect? You might be tempted to start the server with the --init_connect="SET NAMES 'utf8'"
option to cause SET NAMES to be executed automatically for each client that connects. However, this may yield inconsistent results because the init_connect value
is not executed for users that have the SUPER privilege.
PostgreSQL Multi-replica Wait Behavior, Transaction Snapshots, and Data Visibility
An Introduction to the Machine Learning Algorithms of the PostgreSQL MADlib Graph
digoal - April 29, 2021
ApsaraDB - July 23, 2024
digoal - April 29, 2021
digoal - February 20, 2020
digoal - October 22, 2018
Alibaba Clouder - January 11, 2018
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.
Learn MoreAn online MPP warehousing service based on the Greenplum Database open source program
Learn MoreAnalyticDB for MySQL is a real-time data warehousing service that can process petabytes of data with high concurrency and low latency.
Learn MoreMore Posts by digoal