Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory consumption reduced, database encoding fix #9

Merged
merged 3 commits into from Dec 6, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion mysql_fdw.c
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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));
Expand All @@ -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 */
Expand Down Expand Up @@ -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),
Expand Down