Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

memory consumption reduced, database encoding fix #9

Merged
merged 3 commits into from

3 participants

@nikicat

No description provided.

@dpage dpage merged commit df035c0 into from
@Vladicon

Hello, Nikicat!

After applying this commit previously working connection between PostgreSQL 9.3 database (ENCODING = 'WIN1251' LC_COLLATE = 'ru_RU.CP1251' LC_CTYPE = 'ru_RU.CP1251') and MySQL 4 database in 'cp1251' became unusable because of the error: "failed to connect to MySQL: Can't initialize character set WIN1251 (path: /usr/share/mysql/charsets/)". There are character set files in the path /usr/share/mysql/charsets/. The connections are possible from PostgreSQL 9.3 database in UTF-8, but only with tables without char or varchar columns. Tried to copy section in Index.xml about 'cp1251' changing charset name="cp1251" to charset name="WIN1251". It did not help. What else should I try (besides downgrading to the previous state)?

I think the problem is that charset naming is different for postgresql and mysql.
Does changing strings to
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "cp1251");
help?
If so, we need a function that will map postgresql charset names to mysql names. Patches are welcome ;)

Yes, it did help. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 3, 2013
  1. @nikicat

    fixed database encoding

    nikicat authored
  2. @nikicat
Commits on Nov 15, 2013
  1. @nikicat

    set time_zone to UTC

    nikicat authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 mysql_fdw.c
View
6 mysql_fdw.c
@@ -422,6 +422,7 @@ mysqlPlanForeignScan(Oid foreigntableid, PlannerInfo *root, RelOptInfo *baserel)
errmsg("failed to initialise the MySQL connection object")
));
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, GetDatabaseEncodingName());
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),
@@ -535,6 +536,7 @@ mysqlBeginForeignScan(ForeignScanState *node, int eflags)
errmsg("failed to initialise the MySQL connection object")
));
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, GetDatabaseEncodingName());
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),
@@ -578,6 +580,7 @@ mysqlIterateForeignScan(ForeignScanState *node)
/* Execute the query, if required */
if (!festate->result)
{
+ mysql_query(festate->conn, "SET time_zone = '+00:00'");
if (mysql_query(festate->conn, festate->query) != 0)
{
char *err = pstrdup(mysql_error(festate->conn));
@@ -589,7 +592,7 @@ mysqlIterateForeignScan(ForeignScanState *node)
}
/* Guess the query succeeded then */
- festate->result = mysql_store_result(festate->conn);
+ festate->result = mysql_use_result(festate->conn);
}
/* Cleanup */
@@ -690,6 +693,7 @@ mysqlGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntablei
errmsg("failed to initialise the MySQL connection object")
));
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, GetDatabaseEncodingName());
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),
Something went wrong with that request. Please try again.