Commit 26b00be3 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix problems with ODBC raised by Adding the type TYPE_BIGINT (longlong).

parent a9d06e10
...@@ -130,9 +130,9 @@ OPTION(CONNECT_WITH_MYSQL ...@@ -130,9 +130,9 @@ OPTION(CONNECT_WITH_MYSQL
IF(CONNECT_WITH_MYSQL) IF(CONNECT_WITH_MYSQL)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} myconn.cpp tabmysql.cpp) SET(CONNECT_SOURCES ${CONNECT_SOURCES} myconn.cpp tabmysql.cpp)
# For static linking # For static linking
SET(MYSQL_LIBRARY mysqlclient) #SET(MYSQL_LIBRARY mysqlclient)
# For dynamic linking # For dynamic linking
#SET(MYSQL_LIBRARY libmysql) SET(MYSQL_LIBRARY libmysql)
add_definitions(-DMYSQL_SUPPORT) add_definitions(-DMYSQL_SUPPORT)
IF(!UNIX) IF(!UNIX)
# #
......
/************ Valblk C++ Functions Source Code File (.CPP) *************/ /************ Valblk C++ Functions Source Code File (.CPP) *************/
/* Name: VALBLK.CPP Version 1.4 */ /* Name: VALBLK.CPP Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */ /* */
/* This file contains the VALBLK and derived classes functions. */ /* This file contains the VALBLK and derived classes functions. */
/* Second family is VALBLK, representing simple suballocated arrays */ /* Second family is VALBLK, representing simple suballocated arrays */
......
...@@ -274,7 +274,7 @@ class DATBLK : public LNGBLK { ...@@ -274,7 +274,7 @@ class DATBLK : public LNGBLK {
}; // end of class DATBLK }; // end of class DATBLK
/***********************************************************************/ /***********************************************************************/
/* Class LNGBLK: represents a block of int integer values. */ /* Class BIGBLK: represents a block of big integer values. */
/***********************************************************************/ /***********************************************************************/
class BIGBLK : public VALBLK { class BIGBLK : public VALBLK {
public: public:
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
/* to avoid too complicated classes and unuseful duplication of many */ /* to avoid too complicated classes and unuseful duplication of many */
/* functions used on one family only. The drawback is that for new */ /* functions used on one family only. The drawback is that for new */
/* types of objects, we shall have more classes to update. */ /* types of objects, we shall have more classes to update. */
/* Currently the only implemented types are STRING, int, DOUBLE and */ /* Currently the only implemented types are STRING, INT, DOUBLE, DATE */
/* DATE. Shortly we should add at least int VARCHAR and LONGLONG. */ /* and LONGLONG. Shortly we should add at least TINY and VARCHAR. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALUE_H #ifndef __VALUE_H
...@@ -195,7 +195,6 @@ int GetDBType(int type) ...@@ -195,7 +195,6 @@ int GetDBType(int type)
return tp; return tp;
} // end of GetPLGType } // end of GetPLGType
/***********************************************************************/ /***********************************************************************/
/* GetFormatType: returns the FORMAT character(s) according to type. */ /* GetFormatType: returns the FORMAT character(s) according to type. */
/***********************************************************************/ /***********************************************************************/
...@@ -293,7 +292,7 @@ int ConvertType(int target, int type, CONV kind, bool match) ...@@ -293,7 +292,7 @@ int ConvertType(int target, int type, CONV kind, bool match)
: (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT : (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT
: TYPE_SHORT; : TYPE_SHORT;
default: default:
if (!target || target == type) if (target == TYPE_ERROR || target == type)
return type; return type;
if (match && ((IsTypeChar(target) && !IsTypeChar(type)) || if (match && ((IsTypeChar(target) && !IsTypeChar(type)) ||
...@@ -711,11 +710,11 @@ char *STRING::GetIntString(char *p, int n) ...@@ -711,11 +710,11 @@ char *STRING::GetIntString(char *p, int n)
} // end of GetIntString } // end of GetIntString
/***********************************************************************/ /***********************************************************************/
/* STRING GetIntString: get big int representation of a char value. */ /* STRING GetBigintString: get big int representation of a char value.*/
/***********************************************************************/ /***********************************************************************/
char *STRING::GetBigintString(char *p, int n) char *STRING::GetBigintString(char *p, int n)
{ {
sprintf(p, "%*lld", n, atol(Strp)); sprintf(p, "%*lld", n, atoll(Strp));
return p; return p;
} // end of GetBigintString } // end of GetBigintString
...@@ -1237,7 +1236,7 @@ void STRING::SetMax(PVAL vp) ...@@ -1237,7 +1236,7 @@ void STRING::SetMax(PVAL vp)
} // end of SetMax } // end of SetMax
/***********************************************************************/ /***********************************************************************/
/* SetMin: used by QUERY for the aggregate function MIN. */ /* SetMax: used by QUERY for the aggregate function MAX. */
/***********************************************************************/ /***********************************************************************/
void STRING::SetMax(PVBLK vbp, int i) void STRING::SetMax(PVBLK vbp, int i)
{ {
...@@ -1246,10 +1245,10 @@ void STRING::SetMax(PVBLK vbp, int i) ...@@ -1246,10 +1245,10 @@ void STRING::SetMax(PVBLK vbp, int i)
if (((Ci) ? stricmp(val, Strp) : strcmp(val, Strp)) > 0) if (((Ci) ? stricmp(val, Strp) : strcmp(val, Strp)) > 0)
strcpy(Strp, val); strcpy(Strp, val);
} // end of SetMin } // end of SetMax
/***********************************************************************/ /***********************************************************************/
/* SetMin: used by QUERY for the aggregate function MIN. */ /* SetMax: used by QUERY for the aggregate function MAX. */
/***********************************************************************/ /***********************************************************************/
void STRING::SetMax(PVBLK vbp, int j, int k) void STRING::SetMax(PVBLK vbp, int j, int k)
{ {
...@@ -1263,10 +1262,10 @@ void STRING::SetMax(PVBLK vbp, int j, int k) ...@@ -1263,10 +1262,10 @@ void STRING::SetMax(PVBLK vbp, int j, int k)
} // endfor i } // endfor i
} // end of SetMin } // end of SetMax
/***********************************************************************/ /***********************************************************************/
/* SetMin: used by QUERY for the aggregate function MIN. */ /* SetMax: used by QUERY for the aggregate function MAX. */
/***********************************************************************/ /***********************************************************************/
void STRING::SetMax(PVBLK vbp, int *x, int j, int k) void STRING::SetMax(PVBLK vbp, int *x, int j, int k)
{ {
...@@ -1280,7 +1279,7 @@ void STRING::SetMax(PVBLK vbp, int *x, int j, int k) ...@@ -1280,7 +1279,7 @@ void STRING::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i } // endfor i
} // end of SetMin } // end of SetMax
/***********************************************************************/ /***********************************************************************/
/* STRING SetFormat function (used to set SELECT output format). */ /* STRING SetFormat function (used to set SELECT output format). */
...@@ -1757,12 +1756,13 @@ bool SHVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -1757,12 +1756,13 @@ bool SHVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true; return true;
} // endswitch op } // endswitch op
if (trace) if (trace) {
if (np = 1) if (np = 1)
htrc(" result=%hd val=%hd op=%d\n", Sval, val[0], op); htrc(" result=%hd val=%hd op=%d\n", Sval, val[0], op);
else else
htrc(" result=%hd val=%hd,%hd op=%d\n", htrc(" result=%hd val=%hd,%hd op=%d\n",
Sval, val[0], val[1], op); Sval, val[0], val[1], op);
} // endif trace
} // endif op } // endif op
...@@ -2257,7 +2257,7 @@ char *INTVAL::GetFloatString(char *p, int n, int prec) ...@@ -2257,7 +2257,7 @@ char *INTVAL::GetFloatString(char *p, int n, int prec)
} // end of GetFloatString } // end of GetFloatString
/***********************************************************************/ /***********************************************************************/
/* INTVAL compare value with another Value. */ /* INTVAL compare value with another Value. */
/***********************************************************************/ /***********************************************************************/
bool INTVAL::IsEqual(PVAL vp, bool chktype) bool INTVAL::IsEqual(PVAL vp, bool chktype)
{ {
...@@ -2272,7 +2272,7 @@ bool INTVAL::IsEqual(PVAL vp, bool chktype) ...@@ -2272,7 +2272,7 @@ bool INTVAL::IsEqual(PVAL vp, bool chktype)
/***********************************************************************/ /***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */ /* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of int integer filters. */ /* This function is used for evaluation of int integer filters. */
/***********************************************************************/ /***********************************************************************/
int INTVAL::CompareValue(PVAL vp) int INTVAL::CompareValue(PVAL vp)
{ {
...@@ -2506,12 +2506,13 @@ bool INTVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -2506,12 +2506,13 @@ bool INTVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true; return true;
} // endswitch op } // endswitch op
if (trace) if (trace) {
if (np = 1) if (np = 1)
htrc(" result=%d val=%d op=%d\n", Ival, val[0], op); htrc(" result=%d val=%d op=%d\n", Ival, val[0], op);
else else
htrc(" result=%d val=%d,%d op=%d\n", htrc(" result=%d val=%d,%d op=%d\n",
Ival, val[0], val[1], op); Ival, val[0], val[1], op);
} // endif trace
} // endif op } // endif op
...@@ -2783,7 +2784,7 @@ bool INTVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt) ...@@ -2783,7 +2784,7 @@ bool INTVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt)
} // end of SetConstFormat } // end of SetConstFormat
/***********************************************************************/ /***********************************************************************/
/* Make file output of a int object. */ /* Make file output of a int object. */
/***********************************************************************/ /***********************************************************************/
void INTVAL::Print(PGLOBAL g, FILE *f, uint n) void INTVAL::Print(PGLOBAL g, FILE *f, uint n)
{ {
...@@ -2796,7 +2797,7 @@ void INTVAL::Print(PGLOBAL g, FILE *f, uint n) ...@@ -2796,7 +2797,7 @@ void INTVAL::Print(PGLOBAL g, FILE *f, uint n)
} /* end of Print */ } /* end of Print */
/***********************************************************************/ /***********************************************************************/
/* Make string output of a int object. */ /* Make string output of a int object. */
/***********************************************************************/ /***********************************************************************/
void INTVAL::Print(PGLOBAL g, char *ps, uint z) void INTVAL::Print(PGLOBAL g, char *ps, uint z)
{ {
...@@ -4162,7 +4163,7 @@ DFVAL::DFVAL(PSZ s, int prec) : VALUE(TYPE_FLOAT) ...@@ -4162,7 +4163,7 @@ DFVAL::DFVAL(PSZ s, int prec) : VALUE(TYPE_FLOAT)
} // end of DFVAL constructor } // end of DFVAL constructor
/***********************************************************************/ /***********************************************************************/
/* DFVAL public constructor from short. */ /* DFVAL public constructor from short. */
/***********************************************************************/ /***********************************************************************/
DFVAL::DFVAL(short n, int prec) : VALUE(TYPE_FLOAT) DFVAL::DFVAL(short n, int prec) : VALUE(TYPE_FLOAT)
{ {
...@@ -4172,7 +4173,7 @@ DFVAL::DFVAL(short n, int prec) : VALUE(TYPE_FLOAT) ...@@ -4172,7 +4173,7 @@ DFVAL::DFVAL(short n, int prec) : VALUE(TYPE_FLOAT)
} // end of DFVAL constructor } // end of DFVAL constructor
/***********************************************************************/ /***********************************************************************/
/* DFVAL public constructor from int. */ /* DFVAL public constructor from int. */
/***********************************************************************/ /***********************************************************************/
DFVAL::DFVAL(int n, int prec) : VALUE(TYPE_FLOAT) DFVAL::DFVAL(int n, int prec) : VALUE(TYPE_FLOAT)
{ {
...@@ -4181,6 +4182,16 @@ DFVAL::DFVAL(int n, int prec) : VALUE(TYPE_FLOAT) ...@@ -4181,6 +4182,16 @@ DFVAL::DFVAL(int n, int prec) : VALUE(TYPE_FLOAT)
Clen = sizeof(double); Clen = sizeof(double);
} // end of DFVAL constructor } // end of DFVAL constructor
/***********************************************************************/
/* DFVAL public constructor from big int. */
/***********************************************************************/
DFVAL::DFVAL(longlong n, int prec) : VALUE(TYPE_FLOAT)
{
Fval = (double)n;
Prec = prec;
Clen = sizeof(double);
} // end of DFVAL constructor
/***********************************************************************/ /***********************************************************************/
/* DFVAL public constructor from double. */ /* DFVAL public constructor from double. */
/***********************************************************************/ /***********************************************************************/
...@@ -4513,12 +4524,13 @@ bool DFVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -4513,12 +4524,13 @@ bool DFVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true; return true;
} // endswitch op } // endswitch op
if (trace) if (trace) {
if (np == 1) if (np == 1)
htrc("Compute result=%lf val=%lf op=%d\n", Fval, val[0], op); htrc("Compute result=%lf val=%lf op=%d\n", Fval, val[0], op);
else else
htrc("Compute result=%lf val=%lf,%lf op=%d\n", htrc("Compute result=%lf val=%lf,%lf op=%d\n",
Fval, val[0], val[1], op); Fval, val[0], val[1], op);
} // endif trace
return false; return false;
} // end of Compute } // end of Compute
......
...@@ -169,7 +169,7 @@ class STRING : public VALUE { ...@@ -169,7 +169,7 @@ class STRING : public VALUE {
virtual PSZ GetCharValue(void) {return Strp;} virtual PSZ GetCharValue(void) {return Strp;}
virtual short GetShortValue(void) {return (short)atoi(Strp);} virtual short GetShortValue(void) {return (short)atoi(Strp);}
virtual int GetIntValue(void) {return atol(Strp);} virtual int GetIntValue(void) {return atol(Strp);}
virtual longlong GetBigintValue(void) {return strtoll(Strp, NULL, 10);} virtual longlong GetBigintValue(void) {return atoll(Strp);}
virtual double GetFloatValue(void) {return atof(Strp);} virtual double GetFloatValue(void) {return atof(Strp);}
virtual void *GetTo_Val(void) {return Strp;} virtual void *GetTo_Val(void) {return Strp;}
...@@ -449,8 +449,8 @@ class DllExport BIGVAL : public VALUE { ...@@ -449,8 +449,8 @@ class DllExport BIGVAL : public VALUE {
// Implementation // Implementation
virtual bool IsTypeNum(void) {return true;} virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return Lval == 0;} virtual bool IsZero(void) {return Lval == 0LL;}
virtual void Reset(void) {Lval = 0;} virtual void Reset(void) {Lval = 0LL;}
virtual int GetValLen(void); virtual int GetValLen(void);
virtual int GetValPrec() {return 0;} virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(longlong);} virtual int GetSize(void) {return sizeof(longlong);}
...@@ -465,7 +465,7 @@ class DllExport BIGVAL : public VALUE { ...@@ -465,7 +465,7 @@ class DllExport BIGVAL : public VALUE {
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n); virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PSZ s);
virtual void SetValue_bool(bool b) {Lval = (b) ? 1 : 0;} virtual void SetValue_bool(bool b) {Lval = (b) ? 1LL : 0LL;}
virtual void SetValue(short i) {Lval = (longlong)i;} virtual void SetValue(short i) {Lval = (longlong)i;}
virtual void SetValue(int n) {Lval = (longlong)n;} virtual void SetValue(int n) {Lval = (longlong)n;}
virtual void SetValue(longlong n) {Lval = n;} virtual void SetValue(longlong n) {Lval = n;}
......
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