summaryrefslogtreecommitdiff
path: root/storage/connect/myconn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect/myconn.cpp')
-rw-r--r--storage/connect/myconn.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index ada0109a820..644ca019e4a 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */
+/* (C) Copyright to the author Olivier BERTRAND 2007-2016 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -401,8 +401,10 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
MYSQLC::MYSQLC(void)
{
m_DB = NULL;
- m_Stmt = NULL;
- m_Res = NULL;
+#if defined (MYSQL_PREPARED_STATEMENTS)
+ m_Stmt = NULL;
+#endif // MYSQL_PREPARED_STATEMENTS
+ m_Res = NULL;
m_Rows = -1;
m_Row = NULL;
m_Fields = -1;
@@ -444,7 +446,10 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
return RC_FX;
} // endif m_DB
- // Removed to do like FEDERATED do
+ if (trace)
+ htrc("MYSQLC Open: m_DB=%.4X size=%d\n", m_DB, (int)sizeof(*m_DB));
+
+ // Removed to do like FEDERATED do
//mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "client-mariadb");
mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL);
mysql_options(m_DB, MYSQL_OPT_CONNECT_TIMEOUT, &cto);
@@ -701,6 +706,11 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w)
} else {
m_Fields = mysql_num_fields(m_Res);
m_Rows = (!m_Use) ? (int)mysql_num_rows(m_Res) : 0;
+
+ if (trace)
+ htrc("ExecSQL: m_Res=%.4X size=%d m_Fields=%d m_Rows=%d\n",
+ m_Res, sizeof(*m_Res), m_Fields, m_Rows);
+
} // endif m_Res
} else {
@@ -901,8 +911,12 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
if (fld->flags & NOT_NULL_FLAG)
crp->Nulls = NULL;
else {
- crp->Nulls = (char*)PlugSubAlloc(g, NULL, m_Rows);
- memset(crp->Nulls, ' ', m_Rows);
+ if (m_Rows) {
+ crp->Nulls = (char*)PlugSubAlloc(g, NULL, m_Rows);
+ memset(crp->Nulls, ' ', m_Rows);
+ } // endif m_Rows
+
+ crp->Kdata->SetNullable(true);
} // endelse fld->flags
} // endfor fld
@@ -959,11 +973,16 @@ void MYSQLC::FreeResult(void)
/***********************************************************************/
/* Place the cursor at the beginning of the result set. */
/***********************************************************************/
-void MYSQLC::Rewind(void)
+int MYSQLC::Rewind(PGLOBAL g, PSZ sql)
{
- if (m_Res)
- DataSeek(0);
+ int rc = RC_OK;
+
+ if (m_Res)
+ DataSeek(0);
+ else if (sql)
+ rc = ExecSQL(g, sql);
+ return rc;
} // end of Rewind
/***********************************************************************/
@@ -1008,7 +1027,11 @@ int MYSQLC::ExecSQLcmd(PGLOBAL g, const char *query, int *w)
void MYSQLC::Close(void)
{
FreeResult();
- mysql_close(m_DB);
+
+ if (trace)
+ htrc("MYSQLC Close: m_DB=%.4X\n", m_DB);
+
+ mysql_close(m_DB);
m_DB = NULL;
} // end of Close