summaryrefslogtreecommitdiff
path: root/storage/connect/tabmysql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect/tabmysql.cpp')
-rw-r--r--storage/connect/tabmysql.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index 54627ba43fd..19a5dfd758f 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -5,7 +5,7 @@
/* */
/* AUTHOR: */
/* ------- */
-/* Olivier BERTRAND 2007-2014 */
+/* Olivier BERTRAND 2007-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -35,9 +35,9 @@
#include "my_global.h"
#include "sql_class.h"
#include "sql_servers.h"
-#if defined(WIN32)
+#if defined(__WIN__)
//#include <windows.h>
-#else // !WIN32
+#else // !__WIN__
//#include <fnmatch.h>
//#include <errno.h>
#include <stdlib.h>
@@ -46,7 +46,7 @@
#include "osutil.h"
//#include <io.h>
//#include <fcntl.h>
-#endif // !WIN32
+#endif // !__WIN__
/***********************************************************************/
/* Include application header files: */
@@ -56,7 +56,6 @@
#include "xtable.h"
#include "tabcol.h"
#include "colblk.h"
-#include "mycat.h"
#include "reldef.h"
#include "tabmysql.h"
#include "valblk.h"
@@ -308,7 +307,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
/***********************************************************************/
/* DefineAM: define specific AM block values from XCV file. */
/***********************************************************************/
-bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
{
char *url;
@@ -381,7 +380,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
-PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE m)
+PTDB MYSQLDEF::GetTable(PGLOBAL g, MODE)
{
if (Xsrc)
return new(g) TDBMYEXC(this);
@@ -439,7 +438,7 @@ TDBMYSQL::TDBMYSQL(PMYDEF tdp) : TDBASE(tdp)
Nparm = 0;
} // end of TDBMYSQL constructor
-TDBMYSQL::TDBMYSQL(PGLOBAL g, PTDBMY tdbp) : TDBASE(tdbp)
+TDBMYSQL::TDBMYSQL(PTDBMY tdbp) : TDBASE(tdbp)
{
Host = tdbp->Host;
Database = tdbp->Database;
@@ -469,7 +468,7 @@ PTDB TDBMYSQL::CopyOne(PTABS t)
PCOL cp1, cp2;
PGLOBAL g = t->G;
- tp = new(g) TDBMYSQL(g, this);
+ tp = new(g) TDBMYSQL(this);
for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) {
cp2 = new(g) MYSQLCOL((PMYCOL)cp1, tp);
@@ -817,7 +816,7 @@ int TDBMYSQL::GetMaxSize(PGLOBAL g)
/***********************************************************************/
/* This a fake routine as ROWID does not exist in MySQL. */
/***********************************************************************/
-int TDBMYSQL::RowNumber(PGLOBAL g, bool b)
+int TDBMYSQL::RowNumber(PGLOBAL, bool)
{
return N + 1;
} // end of RowNumber
@@ -833,7 +832,7 @@ int TDBMYSQL::GetProgMax(PGLOBAL g)
/***********************************************************************/
/* MySQL Bind Parameter function. */
/***********************************************************************/
-int TDBMYSQL::BindColumns(PGLOBAL g)
+int TDBMYSQL::BindColumns(PGLOBAL g __attribute__((unused)))
{
#if defined(MYSQL_PREPARED_STATEMENTS)
if (Prep) {
@@ -1061,9 +1060,16 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
int oldlen = Query->GetLength();
if (!key || op == OP_NEXT ||
- Mode == MODE_UPDATE || Mode == MODE_DELETE)
+ Mode == MODE_UPDATE || Mode == MODE_DELETE) {
+ if (!key && Mode == MODE_READX) {
+ // This is a false indexed read
+ m_Rc = Myc.ExecSQL(g, Query->GetStr());
+ Mode = MODE_READ;
+ return (m_Rc == RC_FX) ? true : false;
+ } // endif key
+
return false;
- else if (op == OP_FIRST) {
+ } else if (op == OP_FIRST) {
if (To_CondFil) {
oom = Query->Append(" WHERE ");
@@ -1078,8 +1084,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
if (Myc.m_Res)
Myc.FreeResult();
- To_Def->GetHandler()->MakeKeyWhere(g, Query->GetStr(),
- op, "`", key, len);
+ To_Def->GetHandler()->MakeKeyWhere(g, Query, op, '`', key, len);
if (To_CondFil) {
oom = Query->Append(" AND (");
@@ -1141,19 +1146,16 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
int rc;
uint len = Query->GetLength();
char buf[64];
- bool b, oom = false;
+ bool oom = false;
// Make the Insert command value list
for (PCOL colp = Columns; colp; colp = colp->GetNext()) {
if (!colp->GetValue()->IsNull()) {
- if ((b = colp->GetResultType() == TYPE_STRING ||
- colp->GetResultType() == TYPE_DATE))
- oom |= Query->Append('\'');
-
- oom |= Query->Append(colp->GetValue()->GetCharString(buf));
-
- if (b)
- oom |= Query->Append('\'');
+ if (colp->GetResultType() == TYPE_STRING ||
+ colp->GetResultType() == TYPE_DATE)
+ oom |= Query->Append_quoted(colp->GetValue()->GetCharString(buf));
+ else
+ oom |= Query->Append(colp->GetValue()->GetCharString(buf));
} else
oom |= Query->Append("NULL");
@@ -1423,7 +1425,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
/* WriteColumn: make sure the bind buffer is updated. */
/***********************************************************************/
-void MYSQLCOL::WriteColumn(PGLOBAL g)
+void MYSQLCOL::WriteColumn(PGLOBAL)
{
/*********************************************************************/
/* Do convert the column value if necessary. */
@@ -1461,7 +1463,7 @@ TDBMYEXC::TDBMYEXC(PMYDEF tdp) : TDBMYSQL(tdp)
Nerr = 0;
} // end of TDBMYEXC constructor
-TDBMYEXC::TDBMYEXC(PGLOBAL g, PTDBMYX tdbp) : TDBMYSQL(g, tdbp)
+TDBMYEXC::TDBMYEXC(PTDBMYX tdbp) : TDBMYSQL(tdbp)
{
Cmdlist = tdbp->Cmdlist;
Cmdcol = tdbp->Cmdcol;
@@ -1479,7 +1481,7 @@ PTDB TDBMYEXC::CopyOne(PTABS t)
PCOL cp1, cp2;
PGLOBAL g = t->G;
- tp = new(g) TDBMYEXC(g, this);
+ tp = new(g) TDBMYEXC(this);
for (cp1 = Columns; cp1; cp1 = cp1->GetNext()) {
cp2 = new(g) MYXCOL((PMYXCOL)cp1, tp);
@@ -1532,7 +1534,7 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g)
/***********************************************************************/
/* EXC GetMaxSize: returns the maximum number of rows in the table. */
/***********************************************************************/
-int TDBMYEXC::GetMaxSize(PGLOBAL g)
+int TDBMYEXC::GetMaxSize(PGLOBAL)
{
if (MaxSize < 0) {
MaxSize = 10; // a guess
@@ -1709,7 +1711,7 @@ void MYXCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
/* WriteColumn: should never be called. */
/***********************************************************************/
-void MYXCOL::WriteColumn(PGLOBAL g)
+void MYXCOL::WriteColumn(PGLOBAL)
{
assert(false);
} // end of WriteColumn