Skip to content

Commit

Permalink
- Temporary fix for MDEV-7304.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Buggynours committed Dec 14, 2014
1 parent 75c461d commit 8761f22
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
22 changes: 18 additions & 4 deletions storage/connect/odbconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,8 @@ ODBConn::ODBConn(PGLOBAL g, TDBODBC *tdbp)
m_Updatable = true;
m_Transact = false;
m_Scrollable = (tdbp) ? tdbp->Scrollable : false;
m_First = true;
m_Full = false;
m_IDQuoteChar[0] = '"';
m_IDQuoteChar[1] = 0;
//*m_ErrMsg = '\0';
Expand Down Expand Up @@ -1509,6 +1511,16 @@ int ODBConn::Fetch()

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)
m_Rows += irc;

Expand Down Expand Up @@ -2441,12 +2453,13 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g)
/***********************************************************************/
int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
{
int rc, rbuf = -1;
int rc, rbuf;

if (!m_hstmt)
return rbuf;

if (m_Scrollable) {
rbuf = -1;
else if (m_Full)
rbuf = m_Rows; // No need to "rewind"
else if (m_Scrollable) {
SQLULEN crow;

try {
Expand All @@ -2458,6 +2471,7 @@ int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
rbuf = (int)crow;
} catch(DBX *x) {
strcpy(m_G->Message, x->GetErrorMessage(0));
rbuf = -1;
} // end try/catch

} else if (ExecDirectSQL(sql, tocols) >= 0)
Expand Down
3 changes: 2 additions & 1 deletion storage/connect/odbconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,6 @@ class ODBConn : public BLOCK {
bool m_Updatable;
bool m_Transact;
bool m_Scrollable;
bool m_Memory;
bool m_First;
bool m_Full;
}; // end of ODBConn class definition
3 changes: 3 additions & 0 deletions storage/connect/rcmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ char *GetMsgid(int id)
{
char *p = NULL;

// This conditional until a real fix is found for MDEV-7304
#if defined(FRENCH)
if (!stricmp(msglang(), "french"))
switch (id) {
#include "frids.h"
Expand All @@ -40,6 +42,7 @@ char *GetMsgid(int id)
} // endswitch(id)

else // English
#endif // FRENCH
switch (id) {
#include "enids.h"
#if defined(NEWMSG)
Expand Down
6 changes: 3 additions & 3 deletions storage/connect/tabodbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ODBCDEF::ODBCDEF(void)
{
Connect= Tabname= Tabschema= Tabcat= Srcdef= Qchar= Qrystr= Sep= NULL;
Catver = Options = Quoted = Maxerr = Maxres = 0;
Scrollable = Xsrc = false;
Scrollable = Memory = Xsrc = false;
} // end of ODBCDEF constructor

/***********************************************************************/
Expand Down Expand Up @@ -880,7 +880,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
if (To_Kindex) {
// Direct access of ODBC tables is not implemented yet
strcpy(g->Message, MSG(NO_ODBC_DIRECT));
longjmp(g->jumper[g->jump_level], GetAmType());
return RC_FX;
} // endif To_Kindex

/*********************************************************************/
Expand Down Expand Up @@ -1152,7 +1152,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
} // endif Trace

put:
put:
if (tdbp->Memory != 2)
return;

Expand Down
4 changes: 2 additions & 2 deletions storage/connect/tabodbc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*************** 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. */
/***********************************************************************/
Expand Down

0 comments on commit 8761f22

Please sign in to comment.