summaryrefslogtreecommitdiff
path: root/storage/connect/valblk.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-11-26 11:47:48 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2013-11-26 11:47:48 +0100
commit385dbaeae01b0ebb22a271263f96d9ff778c85ec (patch)
treefc8bb67dee170a4d315bd40344a28a41a282a801 /storage/connect/valblk.cpp
parentaaa982e7908b4d8464e9ac799336c5d890f72fad (diff)
downloadmariadb-git-385dbaeae01b0ebb22a271263f96d9ff778c85ec.tar.gz
- Fix gcc compilation warnings
modified: storage/connect/odbconn.cpp - Prepare Value and Valblk to support unsigned data types (not operational yet) modified: storage/connect/colblk.cpp storage/connect/filamvct.cpp storage/connect/myconn.cpp storage/connect/plgdbutl.cpp storage/connect/tabdos.cpp storage/connect/tabodbc.cpp storage/connect/tabvct.cpp storage/connect/valblk.cpp storage/connect/valblk.h storage/connect/value.cpp storage/connect/value.h storage/connect/xindex.cpp
Diffstat (limited to 'storage/connect/valblk.cpp')
-rw-r--r--storage/connect/valblk.cpp122
1 files changed, 101 insertions, 21 deletions
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index 06c7776d2f5..128e7e924c7 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -1,5 +1,5 @@
/************ Valblk C++ Functions Source Code File (.CPP) *************/
-/* Name: VALBLK.CPP Version 1.7 */
+/* Name: VALBLK.CPP Version 2.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */
@@ -16,7 +16,7 @@
/* types of objects, we shall have more classes to update. */
/* This is why we are now using a template class for many types. */
/* Currently the only implemented types are PSZ, chars, int, short, */
-/* DATE, longlong, and double. Shortly we should add more types. */
+/* DATE, longlong, double and tiny. Fix numeric ones can be unsigned. */
/***********************************************************************/
/***********************************************************************/
@@ -46,7 +46,7 @@
/* AllocValBlock: allocate a VALBLK according to type. */
/***********************************************************************/
PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
- int prec, bool check, bool blank)
+ int prec, bool check, bool blank, bool un)
{
PVBLK blkp;
@@ -64,22 +64,38 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
break;
case TYPE_SHORT:
- blkp = new(g) TYPBLK<short>(mp, nval, type);
+ if (un)
+ blkp = new(g) TYPBLK<ushort>(mp, nval, type, 0, true);
+ else
+ blkp = new(g) TYPBLK<short>(mp, nval, type);
+
break;
case TYPE_INT:
- blkp = new(g) TYPBLK<int>(mp, nval, type);
+ if (un)
+ blkp = new(g) TYPBLK<uint>(mp, nval, type, 0, true);
+ else
+ blkp = new(g) TYPBLK<int>(mp, nval, type);
+
break;
case TYPE_DATE: // ?????
blkp = new(g) DATBLK(mp, nval);
break;
case TYPE_BIGINT:
- blkp = new(g) TYPBLK<longlong>(mp, nval, type);
+ if (un)
+ blkp = new(g) TYPBLK<ulonglong>(mp, nval, type, 0, true);
+ else
+ blkp = new(g) TYPBLK<longlong>(mp, nval, type);
+
break;
case TYPE_FLOAT:
- blkp = new(g) TYPBLK<double>(mp, nval, prec, type);
+ blkp = new(g) TYPBLK<double>(mp, nval, type, prec);
break;
case TYPE_TINY:
- blkp = new(g) TYPBLK<char>(mp, nval, type);
+ if (un)
+ blkp = new(g) TYPBLK<uchar>(mp, nval, type, 0, true);
+ else
+ blkp = new(g) TYPBLK<char>(mp, nval, type);
+
break;
default:
sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type);
@@ -95,12 +111,13 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
/***********************************************************************/
/* Constructor. */
/***********************************************************************/
-VALBLK::VALBLK(void *mp, int type, int nval)
+VALBLK::VALBLK(void *mp, int type, int nval, bool un)
{
Blkp = mp;
To_Nulls = NULL;
Check = true;
Nullable = false;
+ Unsigned = un;
Type = type;
Nval = nval;
Prec = 0;
@@ -195,23 +212,15 @@ void VALBLK::ChkTyp(PVBLK vb)
/* -------------------------- Class TYPBLK --------------------------- */
/***********************************************************************/
-/* Constructors. */
+/* Constructor. */
/***********************************************************************/
template <class TYPE>
-TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type)
- : VALBLK(mp, type, nval), Typp((TYPE*&)Blkp)
- {
- Fmt = GetFmt(Type);
- } // end of TYPBLK constructor
-
-template <class TYPE>
-TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int prec, int type)
- : VALBLK(mp, type, nval), Typp((TYPE*&)Blkp)
+TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type, int prec, bool un)
+ : VALBLK(mp, type, nval, un), Typp((TYPE*&)Blkp)
{
- DBUG_ASSERT(Type == TYPE_FLOAT);
Prec = prec;
Fmt = GetFmt(Type);
- } // end of DBLBLK constructor
+ } // end of TYPBLK constructor
/***********************************************************************/
/* Initialization routine. */
@@ -249,15 +258,26 @@ template <>
int TYPBLK<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();}
+uint TYPBLK<uint>::GetTypedValue(PVAL valp)
+ {return valp->GetUIntValue();}
+
template <>
short TYPBLK<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();}
template <>
+ushort TYPBLK<ushort>::GetTypedValue(PVAL valp)
+ {return valp->GetUShortValue();}
+
+template <>
longlong TYPBLK<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();}
template <>
+ulonglong TYPBLK<ulonglong>::GetTypedValue(PVAL valp)
+ {return valp->GetUBigintValue();}
+
+template <>
double TYPBLK<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();}
@@ -265,6 +285,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();}
+template <>
+uchar TYPBLK<uchar>::GetTypedValue(PVAL valp)
+ {return valp->GetUTinyValue();}
+
/***********************************************************************/
/* Set one value in a block from a zero terminated string. */
/***********************************************************************/
@@ -286,13 +310,21 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
template <>
int TYPBLK<int>::GetTypedValue(PSZ p) {return atol(p);}
template <>
+uint TYPBLK<uint>::GetTypedValue(PSZ p) {return (unsigned)atol(p);}
+template <>
short TYPBLK<short>::GetTypedValue(PSZ p) {return (short)atoi(p);}
template <>
+ushort TYPBLK<ushort>::GetTypedValue(PSZ p) {return (ushort)atoi(p);}
+template <>
longlong TYPBLK<longlong>::GetTypedValue(PSZ p) {return atoll(p);}
template <>
+ulonglong TYPBLK<ulonglong>::GetTypedValue(PSZ p) {return (unsigned)atoll(p);}
+template <>
double TYPBLK<double>::GetTypedValue(PSZ p) {return atof(p);}
template <>
char TYPBLK<char>::GetTypedValue(PSZ p) {return (char)atoi(p);}
+template <>
+uchar TYPBLK<uchar>::GetTypedValue(PSZ p) {return (uchar)atoi(p);}
/***********************************************************************/
/* Set one value in a block from an array of characters. */
@@ -334,14 +366,26 @@ int TYPBLK<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);}
template <>
+uint TYPBLK<uint>::GetTypedValue(PVBLK blk, int n)
+ {return blk->GetUIntValue(n);}
+
+template <>
short TYPBLK<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);}
template <>
+ushort TYPBLK<ushort>::GetTypedValue(PVBLK blk, int n)
+ {return blk->GetUShortValue(n);}
+
+template <>
longlong TYPBLK<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);}
template <>
+ulonglong TYPBLK<ulonglong>::GetTypedValue(PVBLK blk, int n)
+ {return blk->GetUBigintValue(n);}
+
+template <>
double TYPBLK<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);}
@@ -349,6 +393,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVBLK blk, int n)
{return blk->GetTinyValue(n);}
+template <>
+uchar TYPBLK<uchar>::GetTypedValue(PVBLK blk, int n)
+ {return blk->GetUTinyValue(n);}
+
#if 0
/***********************************************************************/
/* Set many values in a block from values in another block. */
@@ -517,6 +565,14 @@ short CHRBLK::GetShortValue(int n)
} // end of GetShortValue
/***********************************************************************/
+/* Return the value of the nth element converted to ushort. */
+/***********************************************************************/
+ushort CHRBLK::GetUShortValue(int n)
+ {
+ return (ushort)atoi((char *)GetValPtrEx(n));
+ } // end of GetShortValue
+
+/***********************************************************************/
/* Return the value of the nth element converted to int. */
/***********************************************************************/
int CHRBLK::GetIntValue(int n)
@@ -525,6 +581,14 @@ int CHRBLK::GetIntValue(int n)
} // end of GetIntValue
/***********************************************************************/
+/* Return the value of the nth element converted to uint. */
+/***********************************************************************/
+uint CHRBLK::GetUIntValue(int n)
+ {
+ return (unsigned)atol((char *)GetValPtrEx(n));
+ } // end of GetIntValue
+
+/***********************************************************************/
/* Return the value of the nth element converted to big int. */
/***********************************************************************/
longlong CHRBLK::GetBigintValue(int n)
@@ -533,6 +597,14 @@ longlong CHRBLK::GetBigintValue(int n)
} // end of GetBigintValue
/***********************************************************************/
+/* Return the value of the nth element converted to unsigned big int. */
+/***********************************************************************/
+ulonglong CHRBLK::GetUBigintValue(int n)
+ {
+ return (unsigned)atoll((char *)GetValPtrEx(n));
+ } // end of GetBigintValue
+
+/***********************************************************************/
/* Return the value of the nth element converted to double. */
/***********************************************************************/
double CHRBLK::GetFloatValue(int n)
@@ -549,6 +621,14 @@ char CHRBLK::GetTinyValue(int n)
} // end of GetTinyValue
/***********************************************************************/
+/* Return the value of the nth element converted to unsigned tiny int.*/
+/***********************************************************************/
+uchar CHRBLK::GetUTinyValue(int n)
+ {
+ return (uchar)atoi((char *)GetValPtrEx(n));
+ } // end of GetTinyValue
+
+/***********************************************************************/
/* Set one value in a block. */
/***********************************************************************/
void CHRBLK::SetValue(PVAL valp, int n)