Commit 8761f22a authored by Olivier Bertrand's avatar Olivier Bertrand

- Temporary fix for MDEV-7304.

modified:
  storage/connect/rcmsg.c

- Avoid Memory copying when reading an ODBC table when the entire table
  is already in the result set.
modified:
  storage/connect/odbconn.cpp
  storage/connect/odbconn.h
  storage/connect/tabodbc.cpp
  storage/connect/tabodbc.h
parent 75c461d5
...@@ -922,6 +922,8 @@ ODBConn::ODBConn(PGLOBAL g, TDBODBC *tdbp) ...@@ -922,6 +922,8 @@ ODBConn::ODBConn(PGLOBAL g, TDBODBC *tdbp)
m_Updatable = true; m_Updatable = true;
m_Transact = false; m_Transact = false;
m_Scrollable = (tdbp) ? tdbp->Scrollable : false; m_Scrollable = (tdbp) ? tdbp->Scrollable : false;
m_First = true;
m_Full = false;
m_IDQuoteChar[0] = '"'; m_IDQuoteChar[0] = '"';
m_IDQuoteChar[1] = 0; m_IDQuoteChar[1] = 0;
//*m_ErrMsg = '\0'; //*m_ErrMsg = '\0';
...@@ -1509,6 +1511,16 @@ int ODBConn::Fetch() ...@@ -1509,6 +1511,16 @@ int ODBConn::Fetch()
irc = (rc == SQL_NO_DATA_FOUND) ? 0 : (int)crow; irc = (rc == SQL_NO_DATA_FOUND) ? 0 : (int)crow;
if (m_First) {
// First fetch. Check whether the full table was read
if ((m_Full = irc < (signed)m_RowsetSize)) {
m_Tdb->Memory = 0; // Not needed anymore
m_Rows = irc; // Table size
} // endif m_Full
m_First = false;
} // endif m_First
if (m_Tdb->Memory == 1) if (m_Tdb->Memory == 1)
m_Rows += irc; m_Rows += irc;
...@@ -2441,12 +2453,13 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g) ...@@ -2441,12 +2453,13 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int ODBConn::Rewind(char *sql, ODBCCOL *tocols) int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
{ {
int rc, rbuf = -1; int rc, rbuf;
if (!m_hstmt) if (!m_hstmt)
return rbuf; rbuf = -1;
else if (m_Full)
if (m_Scrollable) { rbuf = m_Rows; // No need to "rewind"
else if (m_Scrollable) {
SQLULEN crow; SQLULEN crow;
try { try {
...@@ -2458,6 +2471,7 @@ int ODBConn::Rewind(char *sql, ODBCCOL *tocols) ...@@ -2458,6 +2471,7 @@ int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
rbuf = (int)crow; rbuf = (int)crow;
} catch(DBX *x) { } catch(DBX *x) {
strcpy(m_G->Message, x->GetErrorMessage(0)); strcpy(m_G->Message, x->GetErrorMessage(0));
rbuf = -1;
} // end try/catch } // end try/catch
} else if (ExecDirectSQL(sql, tocols) >= 0) } else if (ExecDirectSQL(sql, tocols) >= 0)
......
...@@ -194,5 +194,6 @@ class ODBConn : public BLOCK { ...@@ -194,5 +194,6 @@ class ODBConn : public BLOCK {
bool m_Updatable; bool m_Updatable;
bool m_Transact; bool m_Transact;
bool m_Scrollable; bool m_Scrollable;
bool m_Memory; bool m_First;
bool m_Full;
}; // end of ODBConn class definition }; // end of ODBConn class definition
...@@ -31,6 +31,8 @@ char *GetMsgid(int id) ...@@ -31,6 +31,8 @@ char *GetMsgid(int id)
{ {
char *p = NULL; char *p = NULL;
// This conditional until a real fix is found for MDEV-7304
#if defined(FRENCH)
if (!stricmp(msglang(), "french")) if (!stricmp(msglang(), "french"))
switch (id) { switch (id) {
#include "frids.h" #include "frids.h"
...@@ -40,6 +42,7 @@ char *GetMsgid(int id) ...@@ -40,6 +42,7 @@ char *GetMsgid(int id)
} // endswitch(id) } // endswitch(id)
else // English else // English
#endif // FRENCH
switch (id) { switch (id) {
#include "enids.h" #include "enids.h"
#if defined(NEWMSG) #if defined(NEWMSG)
......
...@@ -95,7 +95,7 @@ ODBCDEF::ODBCDEF(void) ...@@ -95,7 +95,7 @@ ODBCDEF::ODBCDEF(void)
{ {
Connect= Tabname= Tabschema= Tabcat= Srcdef= Qchar= Qrystr= Sep= NULL; Connect= Tabname= Tabschema= Tabcat= Srcdef= Qchar= Qrystr= Sep= NULL;
Catver = Options = Quoted = Maxerr = Maxres = 0; Catver = Options = Quoted = Maxerr = Maxres = 0;
Scrollable = Xsrc = false; Scrollable = Memory = Xsrc = false;
} // end of ODBCDEF constructor } // end of ODBCDEF constructor
/***********************************************************************/ /***********************************************************************/
...@@ -880,7 +880,7 @@ int TDBODBC::ReadDB(PGLOBAL g) ...@@ -880,7 +880,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
if (To_Kindex) { if (To_Kindex) {
// Direct access of ODBC tables is not implemented yet // Direct access of ODBC tables is not implemented yet
strcpy(g->Message, MSG(NO_ODBC_DIRECT)); strcpy(g->Message, MSG(NO_ODBC_DIRECT));
longjmp(g->jumper[g->jump_level], GetAmType()); return RC_FX;
} // endif To_Kindex } // endif To_Kindex
/*********************************************************************/ /*********************************************************************/
...@@ -1152,7 +1152,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) ...@@ -1152,7 +1152,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf)); Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
} // endif Trace } // endif Trace
put: put:
if (tdbp->Memory != 2) if (tdbp->Memory != 2)
return; return;
......
/*************** Tabodbc H Declares Source Code File (.H) **************/ /*************** Tabodbc H Declares Source Code File (.H) **************/
/* Name: TABODBC.H Version 1.6 */ /* Name: TABODBC.H Version 1.7 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2014 */
/* */ /* */
/* This file contains the TDBODBC classes declares. */ /* This file contains the TDBODBC classes declares. */
/***********************************************************************/ /***********************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment