Commit 75c461d5 authored by Olivier Bertrand's avatar Olivier Bertrand

- Move mktime in TIME_to_localtime because on Linux the hour can be modified

modified:
  storage/connect/value.cpp
  
- These files were commited even not modified (?)
modified:
  storage/connect/ha_connect.cc
  storage/connect/odbconn.cpp
  storage/connect/odbconn.h
  storage/connect/tabodbc.cpp
parents d592f665 c3b0894f
...@@ -1326,6 +1326,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) ...@@ -1326,6 +1326,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
datm.tm_mday= 12; datm.tm_mday= 12;
datm.tm_mon= 11; datm.tm_mon= 11;
datm.tm_year= 112; datm.tm_year= 112;
mktime(&datm); // set other fields get proper day name
len= strftime(buf, 256, pdtp->OutFmt, &datm); len= strftime(buf, 256, pdtp->OutFmt, &datm);
} else } else
len= 0; len= 0;
......
...@@ -2439,29 +2439,31 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g) ...@@ -2439,29 +2439,31 @@ PQRYRES ODBConn::AllocateResult(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Restart from beginning of result set */ /* Restart from beginning of result set */
/***********************************************************************/ /***********************************************************************/
bool ODBConn::Rewind(char *sql, ODBCCOL *tocols) int ODBConn::Rewind(char *sql, ODBCCOL *tocols)
{ {
RETCODE rc; int rc, rbuf = -1;
if (!m_hstmt) if (!m_hstmt)
return false; return rbuf;
if (m_Scrollable) { if (m_Scrollable) {
SQLULEN crow;
try { try {
rc = SQLFetchScroll(m_hstmt, SQL_FETCH_ABSOLUTE, 0); rc = SQLExtendedFetch(m_hstmt, SQL_FETCH_FIRST, 1, &crow, NULL);
if (rc != SQL_NO_DATA_FOUND) if (!Check(rc))
ThrowDBX(rc, "SQLFetchScroll", m_hstmt); ThrowDBX(rc, "SQLExtendedFetch", m_hstmt);
rbuf = (int)crow;
} catch(DBX *x) { } catch(DBX *x) {
strcpy(m_G->Message, x->GetErrorMessage(0)); strcpy(m_G->Message, x->GetErrorMessage(0));
return true;
} // end try/catch } // end try/catch
} else if (ExecDirectSQL(sql, tocols) < 0) } else if (ExecDirectSQL(sql, tocols) >= 0)
return true; rbuf = 0;
return false; return rbuf;
} // end of Rewind } // end of Rewind
/***********************************************************************/ /***********************************************************************/
......
...@@ -124,7 +124,7 @@ class ODBConn : public BLOCK { ...@@ -124,7 +124,7 @@ class ODBConn : public BLOCK {
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
int Open(PSZ ConnectString, DWORD Options = 0); int Open(PSZ ConnectString, DWORD Options = 0);
bool Rewind(char *sql, ODBCCOL *tocols); int Rewind(char *sql, ODBCCOL *tocols);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
......
...@@ -130,10 +130,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -130,10 +130,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Quoted = GetIntCatInfo("Quoted", 0); Quoted = GetIntCatInfo("Quoted", 0);
Options = ODBConn::noOdbcDialog; Options = ODBConn::noOdbcDialog;
//Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib; //Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib;
Scrollable = GetBoolCatInfo("Scrollable", false);
if ((Scrollable = GetBoolCatInfo("Scrollable", false)))
Elemt = 0; // Not compatible with extended fetch
Memory = GetBoolCatInfo("Memory", false); Memory = GetBoolCatInfo("Memory", false);
Pseudo = 2; // FILID is Ok but not ROWID Pseudo = 2; // FILID is Ok but not ROWID
return false; return false;
...@@ -775,13 +772,14 @@ bool TDBODBC::OpenDB(PGLOBAL g) ...@@ -775,13 +772,14 @@ bool TDBODBC::OpenDB(PGLOBAL g)
if (Memory < 3) { if (Memory < 3) {
// Method will depend on cursor type // Method will depend on cursor type
if (Ocp->Rewind(Query, (PODBCCOL)Columns)) { if ((Rbuf = Ocp->Rewind(Query, (PODBCCOL)Columns)) < 0) {
Ocp->Close(); Ocp->Close();
return true; return true;
} // endif Rewind } // endif Rewind
} // endif Memory } // endif Memory
CurNum = 0;
Fpos = 0; Fpos = 0;
return false; return false;
} // endif use } // endif use
......
...@@ -2187,10 +2187,11 @@ static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime) ...@@ -2187,10 +2187,11 @@ static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime)
tm->tm_year= ltime->year - 1900; tm->tm_year= ltime->year - 1900;
tm->tm_mon= ltime->month - 1; tm->tm_mon= ltime->month - 1;
tm->tm_mday= ltime->day; tm->tm_mday= ltime->day;
mktime(tm); // set tm->tm_wday tm->yday fields to get proper day name (OB)
tm->tm_hour= ltime->hour; tm->tm_hour= ltime->hour;
tm->tm_min= ltime->minute; tm->tm_min= ltime->minute;
tm->tm_sec= ltime->second; tm->tm_sec= ltime->second;
} } // end of TIME_to_localtime
// Added by Alexander Barkov // Added by Alexander Barkov
static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm) static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm)
...@@ -2199,7 +2200,7 @@ static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm) ...@@ -2199,7 +2200,7 @@ static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm)
thd_gmt_sec_to_TIME(current_thd, &ltime, (my_time_t) *timep); thd_gmt_sec_to_TIME(current_thd, &ltime, (my_time_t) *timep);
TIME_to_localtime(tm, &ltime); TIME_to_localtime(tm, &ltime);
return tm; return tm;
} } // end of gmtime_mysql
/***********************************************************************/ /***********************************************************************/
/* GetGmTime: returns a pointer to a static tm structure obtained */ /* GetGmTime: returns a pointer to a static tm structure obtained */
...@@ -2511,6 +2512,8 @@ char *DTVAL::ShowValue(char *buf, int len) ...@@ -2511,6 +2512,8 @@ char *DTVAL::ShowValue(char *buf, int len)
if (!Null) { if (!Null) {
size_t m, n = 0; size_t m, n = 0;
struct tm tm, *ptm = GetGmTime(&tm); struct tm tm, *ptm = GetGmTime(&tm);
if (Len < len) { if (Len < len) {
p = buf; p = buf;
...@@ -2596,7 +2599,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval) ...@@ -2596,7 +2599,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval)
/***********************************************************************/ /***********************************************************************/
bool DTVAL::FormatValue(PVAL vp, char *fmt) bool DTVAL::FormatValue(PVAL vp, char *fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
struct tm tm, *ptm = GetGmTime(&tm); struct tm tm, *ptm = GetGmTime(&tm);
if (trace > 1) if (trace > 1)
......
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