1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Fix compile errors and warnings of LINUX G++

added:
  storage/connect/json.cpp
  storage/connect/json.h
  storage/connect/mysql-test/connect/r/json.result
  storage/connect/mysql-test/connect/std_data/biblio.jsn
  storage/connect/mysql-test/connect/std_data/expense.jsn
  storage/connect/mysql-test/connect/std_data/mulexp3.jsn
  storage/connect/mysql-test/connect/std_data/mulexp4.jsn
  storage/connect/mysql-test/connect/std_data/mulexp5.jsn
  storage/connect/mysql-test/connect/t/json.test
  storage/connect/tabjson.cpp
  storage/connect/tabjson.h
modified:
  storage/connect/CMakeLists.txt
  storage/connect/engmsg.h
  storage/connect/filamtxt.h
  storage/connect/ha_connect.cc
  storage/connect/msgid.h
  storage/connect/mycat.cc
  storage/connect/plgdbsem.h
  storage/connect/tabdos.cpp
  storage/connect/value.cpp
  storage/connect/value.h
This commit is contained in:
Olivier Bertrand
2015-01-20 01:21:56 +01:00
21 changed files with 3958 additions and 61 deletions

View File

@@ -434,6 +434,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
{
PSZ p, sp;
bool un = (uns < 0) ? false : (uns > 0) ? true : valp->IsUnsigned();
PVAL vp;
if (newtype == TYPE_VOID) // Means allocate a value of the same type
newtype = valp->GetType();
@@ -445,53 +446,55 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
if ((sp = valp->GetCharString(p)) != p)
strcpy (p, sp);
valp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
vp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
break;
case TYPE_SHORT:
if (un)
valp = new(g) TYPVAL<ushort>(valp->GetUShortValue(),
TYPE_SHORT, 0, true);
vp = new(g) TYPVAL<ushort>(valp->GetUShortValue(),
TYPE_SHORT, 0, true);
else
valp = new(g) TYPVAL<short>(valp->GetShortValue(), TYPE_SHORT);
vp = new(g) TYPVAL<short>(valp->GetShortValue(), TYPE_SHORT);
break;
case TYPE_INT:
if (un)
valp = new(g) TYPVAL<uint>(valp->GetUIntValue(), TYPE_INT, 0, true);
vp = new(g) TYPVAL<uint>(valp->GetUIntValue(), TYPE_INT, 0, true);
else
valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
vp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
break;
case TYPE_BIGINT:
if (un)
valp = new(g) TYPVAL<ulonglong>(valp->GetUBigintValue(),
TYPE_BIGINT, 0, true);
vp = new(g) TYPVAL<ulonglong>(valp->GetUBigintValue(),
TYPE_BIGINT, 0, true);
else
valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
vp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
break;
case TYPE_DATE:
valp = new(g) DTVAL(g, valp->GetIntValue());
vp = new(g) DTVAL(g, valp->GetIntValue());
break;
case TYPE_DOUBLE:
valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE,
(uns) ? uns : valp->GetValPrec());
vp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE,
(uns) ? uns : valp->GetValPrec());
break;
case TYPE_TINY:
if (un)
valp = new(g) TYPVAL<uchar>(valp->GetUTinyValue(),
vp = new(g) TYPVAL<uchar>(valp->GetUTinyValue(),
TYPE_TINY, 0, true);
else
valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
vp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
break;
default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype);
return NULL;
} // endswitch type
valp->SetGlobal(g);
return valp;
vp->SetNullable(valp->GetNullable());
vp->SetNull(valp->IsNull());
vp->SetGlobal(g);
return vp;
} // end of AllocateValue
/* -------------------------- Class VALUE ---------------------------- */
@@ -939,33 +942,32 @@ int TYPVAL<TYPE>::CompareValue(PVAL vp)
return (Tval > n) ? 1 : (Tval < n) ? (-1) : 0;
} // end of CompareValue
#if 0
/***********************************************************************/
/* Return max type value if b is true, else min type value. */
/***********************************************************************/
template <>
short TYPVAL<short>::MinMaxVal(bool b)
{return (b) ? MAXINT16 : MININT16;}
{return (b) ? INT_MAX16 : INT_MIN16;}
template <>
USHORT TYPVAL<USHORT>::MinMaxVal(bool b)
{return (b) ? MAXUINT16 : 0;}
ushort TYPVAL<ushort>::MinMaxVal(bool b)
{return (b) ? UINT_MAX16 : 0;}
template <>
int TYPVAL<int>::MinMaxVal(bool b)
{return (b) ? MAXINT32 : MININT32;}
{return (b) ? INT_MAX32 : INT_MIN32;}
template <>
UINT TYPVAL<UINT>::MinMaxVal(bool b)
{return (b) ? MAXUINT32 : 0;}
uint TYPVAL<uint>::MinMaxVal(bool b)
{return (b) ? UINT_MAX32 : 0;}
template <>
longlong TYPVAL<longlong>::MinMaxVal(bool b)
{return (b) ? MAXINT64 : MININT64;}
{return (b) ? INT_MAX64 : INT_MIN64;}
template <>
ulonglong TYPVAL<ulonglong>::MinMaxVal(bool b)
{return (b) ? MAXUINT64 : 0;}
{return (b) ? 0xFFFFFFFFFFFFFFFFLL : 0;}
template <>
double TYPVAL<double>::MinMaxVal(bool b)
@@ -973,11 +975,11 @@ double TYPVAL<double>::MinMaxVal(bool b)
template <>
char TYPVAL<char>::MinMaxVal(bool b)
{return (b) ? MAXINT8 : MININT8;}
{return (b) ? INT_MAX8 : INT_MIN8;}
template <>
UCHAR TYPVAL<UCHAR>::MinMaxVal(bool b)
{return (b) ? MAXUINT8 : 0;}
uchar TYPVAL<uchar>::MinMaxVal(bool b)
{return (b) ? UINT_MAX8 : 0;}
/***********************************************************************/
/* SafeAdd: adds a value and test whether overflow/underflow occured. */
@@ -1004,7 +1006,7 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
template <>
inline double TYPVAL<double>::SafeAdd(double n1, double n2)
{
assert(false); return 0;
return n1 + n2;
} // end of SafeAdd
/***********************************************************************/
@@ -1032,9 +1034,8 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
template <>
inline double TYPVAL<double>::SafeMult(double n1, double n2)
{
assert(false); return 0;
return n1 * n2;
} // end of SafeMult
#endif // 0
/***********************************************************************/
/* Compute defined functions for the type. */
@@ -1052,12 +1053,18 @@ bool TYPVAL<TYPE>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
switch (op) {
case OP_ADD:
// Tval = SafeAdd(val[0], val[1]);
Tval = val[0] + val[1];
Tval = SafeAdd(val[0], val[1]);
break;
case OP_MULT:
// Tval = SafeMult(val[0], val[1]);
Tval = val[0] * val[1];
Tval = SafeMult(val[0], val[1]);
break;
case OP_DIV:
if (!val[1]) {
strcpy(g->Message, MSG(ZERO_DIVIDE));
return true;
} // endif
Tval = val[0] / val[1];
break;
default:
rc = Compall(g, vp, np, op);
@@ -1067,7 +1074,6 @@ bool TYPVAL<TYPE>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return rc;
} // end of Compute
#if 0
template <>
bool TYPVAL<double>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
{
@@ -1092,7 +1098,6 @@ bool TYPVAL<double>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
return rc;
} // end of Compute
#endif // 0
/***********************************************************************/
/* Compute a function for all types. */
@@ -1106,6 +1111,18 @@ bool TYPVAL<TYPE>::Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op)
val[i] = GetTypedValue(vp[i]);
switch (op) {
case OP_DIV:
if (val[0]) {
if (!val[1]) {
strcpy(g->Message, MSG(ZERO_DIVIDE));
return true;
} // endif
Tval = val[0] / val[1];
} else
Tval = 0;
break;
case OP_MIN:
Tval = MY_MIN(val[0], val[1]);
break;