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
IF(CONNECT_WITH_MYSQL)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} myconn.cpp tabmysql.cpp)
# For static linking
SET(MYSQL_LIBRARY mysqlclient)
#SET(MYSQL_LIBRARY mysqlclient)
# For dynamic linking
#SET(MYSQL_LIBRARY libmysql)
SET(MYSQL_LIBRARY libmysql)
add_definitions(-DMYSQL_SUPPORT)
IF(!UNIX)
#
......
/************ 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. */
/* Second family is VALBLK, representing simple suballocated arrays */
......
......@@ -274,7 +274,7 @@ class DATBLK : public LNGBLK {
}; // 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 {
public:
......
......@@ -19,8 +19,8 @@
/* to avoid too complicated classes and unuseful duplication of many */
/* functions used on one family only. The drawback is that for new */
/* types of objects, we shall have more classes to update. */
/* Currently the only implemented types are STRING, int, DOUBLE and */
/* DATE. Shortly we should add at least int VARCHAR and LONGLONG. */
/* Currently the only implemented types are STRING, INT, DOUBLE, DATE */
/* and LONGLONG. Shortly we should add at least TINY and VARCHAR. */
/***********************************************************************/
#ifndef __VALUE_H
......@@ -195,7 +195,6 @@ int GetDBType(int type)
return tp;
} // end of GetPLGType
/***********************************************************************/
/* GetFormatType: returns the FORMAT character(s) according to type. */
/***********************************************************************/
......@@ -293,7 +292,7 @@ int ConvertType(int target, int type, CONV kind, bool match)
: (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT
: TYPE_SHORT;
default:
if (!target || target == type)
if (target == TYPE_ERROR || target == type)
return type;
if (match && ((IsTypeChar(target) && !IsTypeChar(type)) ||
......@@ -711,11 +710,11 @@ char *STRING::GetIntString(char *p, int n)
} // 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)
{
sprintf(p, "%*lld", n, atol(Strp));
sprintf(p, "%*lld", n, atoll(Strp));
return p;
} // end of GetBigintString
......@@ -1237,7 +1236,7 @@ void STRING::SetMax(PVAL vp)
} // 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)
{
......@@ -1246,10 +1245,10 @@ void STRING::SetMax(PVBLK vbp, int i)
if (((Ci) ? stricmp(val, Strp) : strcmp(val, Strp)) > 0)
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)
{
......@@ -1263,10 +1262,10 @@ void STRING::SetMax(PVBLK vbp, int j, int k)
} // 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)
{
......@@ -1280,7 +1279,7 @@ void STRING::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMin
} // end of SetMax
/***********************************************************************/
/* STRING SetFormat function (used to set SELECT output format). */
......@@ -1757,12 +1756,13 @@ bool SHVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true;
} // endswitch op
if (trace)
if (trace) {
if (np = 1)
htrc(" result=%hd val=%hd op=%d\n", Sval, val[0], op);
else
htrc(" result=%hd val=%hd,%hd op=%d\n",
Sval, val[0], val[1], op);
} // endif trace
} // endif op
......@@ -2506,12 +2506,13 @@ bool INTVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true;
} // endswitch op
if (trace)
if (trace) {
if (np = 1)
htrc(" result=%d val=%d op=%d\n", Ival, val[0], op);
else
htrc(" result=%d val=%d,%d op=%d\n",
Ival, val[0], val[1], op);
} // endif trace
} // endif op
......@@ -4181,6 +4182,16 @@ DFVAL::DFVAL(int n, int prec) : VALUE(TYPE_FLOAT)
Clen = sizeof(double);
} // 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. */
/***********************************************************************/
......@@ -4513,12 +4524,13 @@ bool DFVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return true;
} // endswitch op
if (trace)
if (trace) {
if (np == 1)
htrc("Compute result=%lf val=%lf op=%d\n", Fval, val[0], op);
else
htrc("Compute result=%lf val=%lf,%lf op=%d\n",
Fval, val[0], val[1], op);
} // endif trace
return false;
} // end of Compute
......
......@@ -169,7 +169,7 @@ class STRING : public VALUE {
virtual PSZ GetCharValue(void) {return Strp;}
virtual short GetShortValue(void) {return (short)atoi(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 void *GetTo_Val(void) {return Strp;}
......@@ -449,8 +449,8 @@ class DllExport BIGVAL : public VALUE {
// Implementation
virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return Lval == 0;}
virtual void Reset(void) {Lval = 0;}
virtual bool IsZero(void) {return Lval == 0LL;}
virtual void Reset(void) {Lval = 0LL;}
virtual int GetValLen(void);
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(longlong);}
......@@ -465,7 +465,7 @@ class DllExport BIGVAL : public VALUE {
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n);
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(int n) {Lval = (longlong)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