summaryrefslogtreecommitdiff
path: root/storage/connect/valblk.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2014-04-19 11:11:30 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2014-04-19 11:11:30 +0200
commit812520315318e358d2d9daf9ca709578af1efe40 (patch)
treed5dff4f4c06aa4554707a6ad717dc73a576313d0 /storage/connect/valblk.cpp
parentcc7a08c9410335237e6c19f84d9c5d08938b8e8a (diff)
parentb43e82dce63c07abe8de740b3bf18a33600ccac0 (diff)
downloadmariadb-git-812520315318e358d2d9daf9ca709578af1efe40.tar.gz
- Commit merged files
modified: storage/connect/CMakeLists.txt storage/connect/connect.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/myconn.cpp storage/connect/myconn.h storage/connect/mysql-test/connect/r/pivot.result storage/connect/mysql-test/connect/suite.pm storage/connect/mysql-test/connect/t/pivot.test storage/connect/myutil.cpp storage/connect/osutil.c storage/connect/plgdbsem.h storage/connect/plugutil.c storage/connect/tabmysql.cpp storage/connect/tabpivot.cpp storage/connect/tabutil.cpp storage/connect/user_connect.cc storage/connect/valblk.cpp storage/connect/valblk.h storage/connect/value.cpp storage/connect/value.h storage/connect/xindex.cpp storage/connect/xindex.h
Diffstat (limited to 'storage/connect/valblk.cpp')
-rw-r--r--storage/connect/valblk.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index 893e8b1de81..c0fa37aab6e 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -44,6 +44,7 @@
#define CheckParms(V, N) ChkIndx(N); ChkTyp(V);
extern "C" int trace;
+extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/***********************************************************************/
/* AllocValBlock: allocate a VALBLK according to type. */
@@ -105,8 +106,7 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
return NULL;
} // endswitch Type
- blkp->Init(g, check);
- return blkp;
+ return (blkp->Init(g, check)) ? NULL : blkp;
} // end of AllocValBlock
/* -------------------------- Class VALBLK --------------------------- */
@@ -116,6 +116,7 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
/***********************************************************************/
VALBLK::VALBLK(void *mp, int type, int nval, bool un)
{
+ Mblk = Nmblk;
Blkp = mp;
To_Nulls = NULL;
Check = true;
@@ -180,6 +181,22 @@ void VALBLK::SetNullable(bool b)
} // end of SetNullable
/***********************************************************************/
+/* Buffer allocation routine. */
+/***********************************************************************/
+bool VALBLK::AllocBuff(PGLOBAL g, size_t size)
+ {
+ Mblk.Size = size;
+
+ if (!(Blkp = PlgDBalloc(g, NULL, Mblk))) {
+ sprintf(g->Message, MSG(MEM_ALLOC_ERR), "Blkp", Mblk.Size);
+ fprintf(stderr, "%s\n", g->Message);
+ return true;
+ } // endif Blkp
+
+ return false;
+ } // end of AllocBuff
+
+/***********************************************************************/
/* Check functions. */
/***********************************************************************/
void VALBLK::ChkIndx(int n)
@@ -229,13 +246,15 @@ TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type, int prec, bool un)
/* Initialization routine. */
/***********************************************************************/
template <class TYPE>
-void TYPBLK<TYPE>::Init(PGLOBAL g, bool check)
+bool TYPBLK<TYPE>::Init(PGLOBAL g, bool check)
{
if (!Blkp)
- Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(TYPE));
+ if (AllocBuff(g, Nval * sizeof(TYPE)))
+ return true;
Check = check;
Global = g;
+ return false;
} // end of Init
/***********************************************************************/
@@ -606,16 +625,18 @@ CHRBLK::CHRBLK(void *mp, int nval, int len, int prec, bool blank)
/***********************************************************************/
/* Initialization routine. */
/***********************************************************************/
-void CHRBLK::Init(PGLOBAL g, bool check)
+bool CHRBLK::Init(PGLOBAL g, bool check)
{
Valp = (char*)PlugSubAlloc(g, NULL, Long + 1);
Valp[Long] = '\0';
if (!Blkp)
- Blkp = PlugSubAlloc(g, NULL, Nval * Long);
+ if (AllocBuff(g, Nval * Long))
+ return true;
Check = check;
Global = g;
+ return false;
} // end of Init
/***********************************************************************/
@@ -996,13 +1017,15 @@ STRBLK::STRBLK(PGLOBAL g, void *mp, int nval)
/***********************************************************************/
/* Initialization routine. */
/***********************************************************************/
-void STRBLK::Init(PGLOBAL g, bool check)
+bool STRBLK::Init(PGLOBAL g, bool check)
{
if (!Blkp)
- Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(PSZ));
+ if (AllocBuff(g, Nval * sizeof(PSZ)))
+ return true;
Check = check;
Global = g;
+ return false;
} // end of Init
/***********************************************************************/