summaryrefslogtreecommitdiff
path: root/storage/connect/tabodbc.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-11-06 18:22:09 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2013-11-06 18:22:09 +0100
commit056f35d0c136af4437344d4fbce80172e6d96817 (patch)
tree954befda500a4f7b1fb3b6d5b1e814a7077c3d96 /storage/connect/tabodbc.cpp
parentf1325549e9eca1311435255854da0a93923eff9b (diff)
downloadmariadb-git-056f35d0c136af4437344d4fbce80172e6d96817.tar.gz
- Move all enum AMT definitions in one place (plgdbsem.h)
modified: storage/connect/filamtxt.h storage/connect/filamzip.h storage/connect/myconn.h storage/connect/plgdbsem.h storage/connect/taboccur.h storage/connect/tabutil.h storage/connect/tabxcl.h - Add the possibility to execute several commands in one query of an EXECSRC tables (using ...where command in (cmd list);) modified: storage/connect/ha_connect.cc storage/connect/odbconn.cpp storage/connect/odbconn.h storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabtbl.cpp storage/connect/tabwmi.cpp storage/connect/xtable.h - Enhance retrieving column definitions in discovery: From SRCDEF adding LIMIT 0 to the executed query Testing if type, length, and precision are compatible Making the distinction between CHAR and VARCHAR modified: storage/connect/ha_connect.cc storage/connect/myconn.cpp storage/connect/mysql-test/connect/r/mysql.result storage/connect/mysql-test/connect/r/odbc_sqlite3.result storage/connect/mysql-test/connect/r/odbc_sqlite3_grant.result storage/connect/myutil.h storage/connect/myutil.h storage/connect/odbconn.cpp storage/connect/value.h
Diffstat (limited to 'storage/connect/tabodbc.cpp')
-rw-r--r--storage/connect/tabodbc.cpp72
1 files changed, 37 insertions, 35 deletions
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index d9d794ef4e4..bf0216d52eb 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -110,6 +110,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Qchar = Cat->GetStringCatInfo(g, "Qchar", "");
Catver = Cat->GetIntCatInfo("Catver", 2);
Xsrc = Cat->GetBoolCatInfo("Execsrc", FALSE);
+ Mxr = Cat->GetIntCatInfo("Maxerr", 0);
Options = ODBConn::noOdbcDialog;
Pseudo = 2; // FILID is Ok but not ROWID
return false;
@@ -395,7 +396,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
// Below 14 is length of 'select ' + length of ' from ' + 1
len = (strlen(colist) + strlen(buf) + 14);
- len += (To_Filter ? strlen(To_Filter) + 7 : 0);
+ len += (To_Filter ? strlen(To_Filter->Body) + 7 : 0);
// if (tablep->GetQualifier()) This is used when using a table
// qualp = tablep->GetQualifier(); from anotherPlugDB database but
@@ -432,7 +433,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
strcat(sql, tabname);
if (To_Filter)
- strcat(strcat(sql, " WHERE "), To_Filter);
+ strcat(strcat(sql, " WHERE "), To_Filter->Body);
return sql;
} // end of MakeSQL
@@ -720,7 +721,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
/***********************************************************************/
int TDBODBC::WriteDB(PGLOBAL g)
{
- int n = Ocp->ExecuteSQL(false);
+ int n = Ocp->ExecuteSQL();
if (n < 0) {
AftRows = n;
@@ -1004,6 +1005,22 @@ void ODBCCOL::WriteColumn(PGLOBAL g)
/***********************************************************************/
/* Implementation of the TDBODBC class. */
/***********************************************************************/
+TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp)
+{
+ Cmdlist = NULL;
+ Cmdcol = NULL;
+ Mxr = tdp->Mxr;
+ Nerr = 0;
+} // end of TDBXDBC constructor
+
+TDBXDBC::TDBXDBC(PTDBXDBC tdbp) : TDBODBC(tdbp)
+{
+ Cmdlist = tdbp->Cmdlist;
+ Cmdcol = tdbp->Cmdcol;
+ Mxr = tdbp->Mxr;
+ Nerr = tdbp->Nerr;
+} // end of TDBXDBC copy constructor
+
PTDB TDBXDBC::CopyOne(PTABS t)
{
PTDB tp;
@@ -1036,23 +1053,15 @@ PCOL TDBXDBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
/* MakeCMD: make the SQL statement to send to ODBC connection. */
/***********************************************************************/
-char *TDBXDBC::MakeCMD(PGLOBAL g)
+PCMD TDBXDBC::MakeCMD(PGLOBAL g)
{
- char *xcmd = NULL;
+ PCMD xcmd = NULL;
if (To_Filter) {
if (Cmdcol) {
- char col[128], cmd[1024];
- int n;
-
- memset(cmd, 0, sizeof(cmd));
- n = sscanf(To_Filter, "%s = '%1023c", col, cmd);
-
- if (n == 2 && !stricmp(col, Cmdcol)) {
- xcmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1);
-
- strcpy(xcmd, cmd);
- xcmd[strlen(xcmd) - 1] = 0;
+ if (!stricmp(Cmdcol, To_Filter->Body) &&
+ (To_Filter->Op == OP_EQ || To_Filter->Op == OP_IN)) {
+ xcmd = To_Filter->Cmds;
} else
strcpy(g->Message, "Invalid command specification filter");
@@ -1062,7 +1071,7 @@ char *TDBXDBC::MakeCMD(PGLOBAL g)
} else if (!Srcdef)
strcpy(g->Message, "No Srcdef default command");
else
- xcmd = Srcdef;
+ xcmd = new(g) CMD(g, Srcdef);
return xcmd;
} // end of MakeCMD
@@ -1088,12 +1097,12 @@ bool TDBXDBC::BindParameters(PGLOBAL g)
#endif // 0
/***********************************************************************/
-/* XDBC GetMaxSize: returns table size (always one row). */
+/* XDBC GetMaxSize: returns table size (not always one row). */
/***********************************************************************/
int TDBXDBC::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0)
- MaxSize = 1;
+ MaxSize = 10; // Just a guess
return MaxSize;
} // end of GetMaxSize
@@ -1142,19 +1151,12 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
/*********************************************************************/
/* Get the command to execute. */
/*********************************************************************/
- if (!(Query = MakeCMD(g))) {
+ if (!(Cmdlist = MakeCMD(g))) {
Ocp->Close();
return true;
} // endif Query
Rows = 1;
-
- if (Ocp->PrepareSQL(Query)) {
- strcpy(g->Message, "Parameters not supported");
- AftRows = -1;
- } else
- AftRows = 0;
-
return false;
} // end of OpenDB
@@ -1163,18 +1165,18 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
/***********************************************************************/
int TDBXDBC::ReadDB(PGLOBAL g)
{
- if (trace)
- htrc("XDBC ReadDB: query=%s\n", SVP(Query));
+ if (Cmdlist) {
+ Query = Cmdlist->Cmd;
- if (Rows--) {
- if (!AftRows)
- AftRows = Ocp->ExecuteSQL(true);
+ if (Ocp->ExecSQLcommand(Query))
+ Nerr++;
- } else
+ Fpos++; // Used for progress info
+ Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
+ return RC_OK;
+ } else
return RC_EF;
- Fpos++; // Used for progress info
- return RC_OK;
} // end of ReadDB
/***********************************************************************/