Permalink
Browse files

Merge pull request #9 from nikicat/master

memory consumption reduced, database encoding fix
  • Loading branch information...
2 parents 47b5bed + a2a78f3 commit df035c02083d6271423f80d56eef56be88e0b141 @dpage dpage committed Dec 6, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 mysql_fdw.c
View
@@ -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),

0 comments on commit df035c0

Please sign in to comment.