summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/connect/colblk.cpp6
-rw-r--r--storage/connect/colblk.h7
-rw-r--r--storage/connect/connect.cc9
-rw-r--r--storage/connect/ha_connect.cc98
-rw-r--r--storage/connect/tabmysql.cpp11
-rw-r--r--storage/connect/tabodbc.cpp6
-rw-r--r--storage/connect/valblk.cpp272
-rw-r--r--storage/connect/valblk.h71
-rw-r--r--storage/connect/value.cpp248
-rw-r--r--storage/connect/value.h84
-rw-r--r--storage/connect/xindex.cpp8
11 files changed, 571 insertions, 249 deletions
diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp
index ceb7dcf92a0..027ac5710ab 100644
--- a/storage/connect/colblk.cpp
+++ b/storage/connect/colblk.cpp
@@ -1,7 +1,7 @@
/************* Colblk C++ Functions Source Code File (.CPP) ************/
-/* Name: COLBLK.CPP Version 1.9 */
+/* Name: COLBLK.CPP Version 2.0 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
@@ -49,6 +49,7 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
} // endif cdp
To_Tdb = tdbp;
+ Nullable = false;
Status = BUF_NO;
//Value = NULL; done in XOBJECT constructor
To_Kcol = NULL;
@@ -190,6 +191,7 @@ bool COLBLK::InitValue(PGLOBAL g)
return true;
Status = BUF_READY;
+ Value->SetNullable(Nullable);
#ifdef DEBTRACE
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h
index 3e6b9f3ee05..cf6fb443308 100644
--- a/storage/connect/colblk.h
+++ b/storage/connect/colblk.h
@@ -1,7 +1,7 @@
/*************** Colblk H Declares Source Code File (.H) ***************/
-/* Name: COLBLK.H Version 1.5 */
+/* Name: COLBLK.H Version 1.6 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */
/* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/
@@ -53,6 +53,8 @@ class DllExport COLBLK : public XOBJECT {
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
+ bool IsNullable(void) {return Nullable;}
+ void SetNullable(bool b) {Nullable = b;}
// Methods
virtual void Reset(void);
@@ -81,6 +83,7 @@ class DllExport COLBLK : public XOBJECT {
PCOLDEF Cdp; // To column definition block
PTDB To_Tdb; // Points to Table Descriptor Block
PXCOL To_Kcol; // Points to Xindex matching column
+ bool Nullable; // True if nullable
int Index; // Column number in table
int Opt; // Cluster/sort information
int Buf_Type; // Data type
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 15345ff47e7..3fee989907d 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -273,8 +273,10 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
cp= new(g) COLUMN(p + 1);
cp->SetTo_Table(tdbp->GetTable());
colp= ((PTDBASE)tdbp)->InsertSpcBlk(g, cp);
- } else
- colp= tdbp->ColDB(g, p, 0);
+ } else {
+ colp= tdbp->ColDB(g, p + 1, 0);
+ colp->SetNullable(*p == '1');
+ } // endif p
if (!colp) {
sprintf(g->Message, "Column %s not found in %s", p, tdbp->GetName());
@@ -338,7 +340,8 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
utp->ColDB(g, NULL, 0);
else for (p= c2; *p; p+= n) {
// Allocate only used column blocks
- utp->ColDB(g, p, 0);
+ colp= utp->ColDB(g, p + 1, 0);
+ colp->SetNullable(*p == '1');
n= strlen(p) + 1;
} // endfor p
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 5154bb83cbb..5e23b3746d5 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1211,7 +1211,7 @@ int ha_connect::GetColNameLen(Field *fp)
if (fop && fop->special)
n= strlen(fop->special) + 1;
else
- n= strlen(fp->field_name);
+ n= strlen(fp->field_name) + 1;
return n;
} // end of GetColNameLen
@@ -1238,7 +1238,7 @@ void ha_connect::AddColName(char *cp, Field *fp)
// The prefix * mark the column as "special"
strcat(strcpy(cp, "*"), strupr(fop->special));
else
- strcpy(cp, (char*)fp->field_name);
+ strcat(strcpy(cp, fp->maybe_null() ? "1" : "0"), (char*)fp->field_name);
} // end of AddColName
@@ -1456,49 +1456,54 @@ int ha_connect::MakeRecord(char *buf)
value= colp->GetValue();
// All this could be better optimized
- switch (value->GetType()) {
- case TYPE_DATE:
- if (!sdval)
- sdval= AllocateValue(xp->g, TYPE_STRING, 20);
-
- switch (fp->type()) {
- case MYSQL_TYPE_DATE:
- fmt= "%Y-%m-%d";
- break;
- case MYSQL_TYPE_TIME:
- fmt= "%H:%M:%S";
- break;
- default:
- fmt= "%Y-%m-%d %H:%M:%S";
- } // endswitch type
-
- // Get date in the format required by MySQL fields
- value->FormatValue(sdval, fmt);
- p= sdval->GetCharValue();
- break;
- case TYPE_FLOAT:
- p= NULL;
- break;
- case TYPE_STRING:
- // Passthru
- default:
- p= value->GetCharString(val);
- } // endswitch Type
-
- if (p) {
- if (fp->store(p, strlen(p), charset, CHECK_FIELD_WARN)) {
- // Avoid "error" on null fields
- if (value->GetIntValue())
+ if (!value->IsNull()) {
+ switch (value->GetType()) {
+ case TYPE_DATE:
+ if (!sdval)
+ sdval= AllocateValue(xp->g, TYPE_STRING, 20);
+
+ switch (fp->type()) {
+ case MYSQL_TYPE_DATE:
+ fmt= "%Y-%m-%d";
+ break;
+ case MYSQL_TYPE_TIME:
+ fmt= "%H:%M:%S";
+ break;
+ default:
+ fmt= "%Y-%m-%d %H:%M:%S";
+ } // endswitch type
+
+ // Get date in the format required by MySQL fields
+ value->FormatValue(sdval, fmt);
+ p= sdval->GetCharValue();
+ break;
+ case TYPE_FLOAT:
+ p= NULL;
+ break;
+ case TYPE_STRING:
+ // Passthru
+ default:
+ p= value->GetCharString(val);
+ } // endswitch Type
+
+ if (p) {
+ if (fp->store(p, strlen(p), charset, CHECK_FIELD_WARN)) {
+ // Avoid "error" on null fields
+ if (value->GetIntValue())
+ rc= HA_ERR_WRONG_IN_RECORD;
+
+ DBUG_PRINT("MakeRecord", (p));
+ } // endif store
+
+ } else
+ if (fp->store(value->GetFloatValue())) {
rc= HA_ERR_WRONG_IN_RECORD;
+ DBUG_PRINT("MakeRecord", (value->GetCharString(val)));
+ } // endif store
- DBUG_PRINT("MakeRecord", (p));
- } // endif store
-
+ fp->set_notnull();
} else
- if (fp->store(value->GetFloatValue())) {
- rc= HA_ERR_WRONG_IN_RECORD;
- DBUG_PRINT("MakeRecord", (value->GetCharString(val)));
- } // endif store
+ fp->set_null();
} // endif bitmap
@@ -1552,7 +1557,12 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
// This is a used field, fill the value from the row buffer
// All this could be better optimized
- switch (value->GetType()) {
+ if (fp->is_null()) {
+ if (colp->IsNullable())
+ value->SetNull(true);
+
+ value->Reset();
+ } else switch (value->GetType()) {
case TYPE_FLOAT:
value->SetValue(fp->val_real());
break;
@@ -3306,7 +3316,7 @@ bool ha_connect::add_fields(THD *thd, void *alt_info,
alter_info->create_list.push_back(new_field);
//lex->last_field=new_field;
DBUG_RETURN(0);
-}
+} // end of add_fields
/**
@brief
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index 8111bc95265..fafa5caf6d8 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -109,14 +109,15 @@ MYSQLDEF::MYSQLDEF(void)
/* An Example: */
/* */
/* CREATE TABLE t1 (id int(32)) */
-/* ENGINE="FEDERATEDX" */
+/* ENGINE="CONNECT" TABLE_TYPE="MYSQL" */
/* CONNECTION="mysql://joe:pwd@192.168.1.111:9308/dbname/tabname"; */
/* */
/* CREATE TABLE t2 ( */
/* id int(4) NOT NULL auto_increment, */
/* name varchar(32) NOT NULL, */
/* PRIMARY KEY(id) */
-/* ) ENGINE="FEDERATEDX" CONNECTION="my_conn"; (NIY) */
+/* ) ENGINE="CONNECT" TABLE_TYPE="MYSQL" */
+/* CONNECTION="my_conn"; (NIY) */
/* */
/* 'password' and 'port' are both optional. */
/* */
@@ -1040,8 +1041,12 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank)))
Value->SetValue_char(buf, Long);
- else
+ else {
+ if (Nullable)
+ Value->SetNull(true);
+
Value->Reset(); // Null value
+ } // endelse
} // end of ReadColumn
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index dba3ba1ae15..3ea608a171a 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -796,9 +796,13 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
if (StrLen[n] == SQL_NULL_DATA) {
// Null value
+ if (Nullable)
+ Value->SetNull(true);
+
Value->Reset();
return;
- } // endif StrLen
+ } else
+ Value->SetNull(false);
if (Bufp && tdbp->Rows)
if (Buf_Type == TYPE_DATE)
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index 2ae564f2e62..595421a38d4 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -14,12 +14,12 @@
/* 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 and DOUBLE. */
-/* Shortly we should add at least int VARCHAR and DATE. */
+/* Currently the only implemented types are STRING, int and DOUBLE. */
+/* Shortly we should add at least int VARCHAR and DATE. */
/***********************************************************************/
/***********************************************************************/
-/* Include relevant MariaDB header file. */
+/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
@@ -131,6 +131,19 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
/* -------------------------- Class VALBLK --------------------------- */
/***********************************************************************/
+/* Constructor. */
+/***********************************************************************/
+VALBLK::VALBLK(void *mp, int type, int nval)
+ {
+ Blkp = mp;
+ To_Nulls = NULL;
+ Type = type;
+ Nval = nval;
+ Check = true;
+ Nullable = false;
+ } // end of VALBLK constructor
+
+/***********************************************************************/
/* Raise error for numeric types. */
/***********************************************************************/
PSZ VALBLK::GetCharValue(int n)
@@ -170,6 +183,18 @@ bool VALBLK::Locate(PVAL vp, int& i)
return (!n);
} // end of Locate
+/***********************************************************************/
+/* Set Nullable and allocate the Null array. */
+/***********************************************************************/
+void VALBLK::SetNullable(bool b)
+{
+ if ((Nullable = b)) {
+ To_Nulls = (char*)PlugSubAlloc(Global, NULL, Nval);
+ memset(To_Nulls, 0, Nval);
+ } else
+ To_Nulls = NULL;
+
+} // end of SetNullable
/* -------------------------- Class CHRBLK --------------------------- */
@@ -229,7 +254,7 @@ short CHRBLK::GetShortValue(int n)
} // end of GetIntValue
/***********************************************************************/
-/* Return the value of the nth element converted to int. */
+/* Return the value of the nth element converted to int. */
/***********************************************************************/
int CHRBLK::GetIntValue(int n)
{
@@ -258,8 +283,14 @@ double CHRBLK::GetFloatValue(int n)
void CHRBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
+ bool b;
- SetValue((PSZ)valp->GetCharValue(), n);
+ if (!(b = valp->IsNull() && Nullable))
+ SetValue((PSZ)valp->GetCharValue(), n);
+ else
+ Reset(n);
+
+ SetNull(n, b);
} // end of SetValue
/***********************************************************************/
@@ -288,6 +319,7 @@ void CHRBLK::SetValue(PSZ sp, int n)
for (register int i = len; i < Long; i++)
p[i] = ' ';
+ SetNull(n, false);
} // end of SetValue
/***********************************************************************/
@@ -302,10 +334,17 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
longjmp(g->jumper[g->jump_level], Type);
} // endif Type
#endif
+ bool b;
+
+ if (!(b = pv->IsNull(n2) && Nullable))
+ memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
+ else
+ Reset(n1);
- memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
+ SetNull(n1, b);
} // end of SetValue
+#if 0
/***********************************************************************/
/* Set many values in a block from values in another block. */
/***********************************************************************/
@@ -356,6 +395,7 @@ void CHRBLK::SetMax(PVAL valp, int n)
memcpy(bp, vp, Long);
} // end of SetMax
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -363,6 +403,7 @@ void CHRBLK::SetMax(PVAL valp, int n)
void CHRBLK::Move(int i, int j)
{
memcpy(Chrp + j * Long, Chrp + i * Long, Long);
+ MoveNull(i, j);
} // end of Move
/***********************************************************************/
@@ -404,6 +445,9 @@ void *CHRBLK::GetValPtrEx(int n)
CheckIndex(n)
memcpy(Valp, Chrp + n * Long, Long);
+ if (IsNull(n))
+ return "";
+
if (Blanks) {
// The (fast) way this is done works only for blocks such
// as Min and Max where strings are stored with the ending 0
@@ -429,7 +473,13 @@ int CHRBLK::Find(PVAL vp)
bool ci = Ci || vp->IsCi();
PSZ s = vp->GetCharValue();
+ if (vp->IsNull())
+ return -1;
+
for (i = 0; i < Nval; i++) {
+ if (IsNull(i))
+ continue;
+
GetValPtrEx(i); // Get a zero ended string in Valp
if (!((ci) ? strnicmp(s, Valp, Long) : strncmp(s, Valp, Long)))
@@ -438,7 +488,7 @@ int CHRBLK::Find(PVAL vp)
} // endfor i
return (i < Nval) ? i : (-1);
- } // end of GetValPtr
+ } // end of Find
/***********************************************************************/
/* Returns the length of the longest string in the block. */
@@ -447,10 +497,11 @@ int CHRBLK::GetMaxLength(void)
{
int i, n;
- for (i = n = 0; i < Nval; i++) {
- GetValPtrEx(i);
- n = max(n, (signed)strlen(Valp));
- } // endfor i
+ for (i = n = 0; i < Nval; i++)
+ if (!IsNull(i)) {
+ GetValPtrEx(i);
+ n = max(n, (signed)strlen(Valp));
+ } // endif null
return n;
} // end of GetMaxLength
@@ -465,6 +516,7 @@ STRBLK::STRBLK(PGLOBAL g, void *mp, int nval)
: VALBLK(mp, TYPE_STRING, nval), Strp((PSZ*&)Blkp)
{
Global = g;
+ Nullable = true;
} // end of STRBLK constructor
/***********************************************************************/
@@ -486,9 +538,10 @@ void STRBLK::SetValue(PVBLK pv, int n1, int n2)
{
CheckType(pv)
- Strp[n1] = ((STRBLK*)pv)->Strp[n2];
+ Strp[n1] = (!pv->IsNull(n2)) ? ((STRBLK*)pv)->Strp[n2] : NULL;
} // end of SetValue
+#if 0
/***********************************************************************/
/* Set many values in a block from values in another block. */
/***********************************************************************/
@@ -498,9 +551,10 @@ void STRBLK::SetValues(PVBLK pv, int k, int n)
PSZ *sp = ((STRBLK*)pv)->Strp;
for (register int i = k; i < n; i++)
- Strp[i] = sp[i];
+ Strp[i] = (!pv->IsNull(i)) ? sp[i] : NULL;
} // end of SetValues
+#endif // 0
/***********************************************************************/
/* Set one value in a block. */
@@ -508,7 +562,12 @@ void STRBLK::SetValues(PVBLK pv, int k, int n)
void STRBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
- SetValue((PSZ)valp->GetCharValue(), n);
+
+ if (!valp->IsNull())
+ SetValue((PSZ)valp->GetCharValue(), n);
+ else
+ Strp[n] = NULL;
+
} // end of SetValue
/***********************************************************************/
@@ -520,6 +579,7 @@ void STRBLK::SetValue(PSZ p, int n)
strcpy(Strp[n], p);
} // end of SetValue
+#if 0
/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
@@ -547,6 +607,7 @@ void STRBLK::SetMax(PVAL valp, int n)
SetValue(valp, n);
} // end of SetMax
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -562,6 +623,10 @@ void STRBLK::Move(int i, int j)
int STRBLK::CompVal(PVAL vp, int n)
{
CheckParms(vp, n)
+
+ if (vp->IsNull() || !Strp[n])
+ DBUG_ASSERT(false);
+
return strcmp(vp->GetCharValue(), Strp[n]);
} // end of CompVal
@@ -570,6 +635,9 @@ int STRBLK::CompVal(PVAL vp, int n)
/***********************************************************************/
int STRBLK::CompVal(int i1, int i2)
{
+ if (!Strp[i1] || Strp[i2])
+ DBUG_ASSERT(false);
+
return (strcmp(Strp[i1], Strp[i2]));
} // end of CompVal
@@ -588,7 +656,7 @@ void *STRBLK::GetValPtr(int n)
void *STRBLK::GetValPtrEx(int n)
{
CheckIndex(n)
- return Strp[n];
+ return (Strp[n]) ? Strp[n] : "";
} // end of GetValPtrEx
/***********************************************************************/
@@ -598,10 +666,15 @@ int STRBLK::Find(PVAL vp)
{
CheckType(vp)
int i;
- PSZ s = vp->GetCharValue();
+ PSZ s;
+
+ if (vp->IsNull())
+ return -1;
+ else
+ s = vp->GetCharValue();
for (i = 0; i < Nval; i++)
- if (!strcmp(s, Strp[i]))
+ if (Strp[i] && !strcmp(s, Strp[i]))
break;
return (i < Nval) ? i : (-1);
@@ -615,7 +688,8 @@ int STRBLK::GetMaxLength(void)
int i, n;
for (i = n = 0; i < Nval; i++)
- n = max(n, (signed)strlen(Strp[i]));
+ if (Strp[i])
+ n = max(n, (signed)strlen(Strp[i]));
return n;
} // end of GetMaxLength
@@ -649,7 +723,14 @@ void SHRBLK::Init(PGLOBAL g, bool check)
void SHRBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
- Shrp[n] = valp->GetShortValue();
+ bool b;
+
+ if (!(b = valp->IsNull() && Nullable))
+ Shrp[n] = valp->GetShortValue();
+ else
+ Reset(n);
+
+ SetNull(n, b);
} // end of SetValue
/***********************************************************************/
@@ -664,11 +745,28 @@ void SHRBLK::SetValue(PSZ p, int n)
longjmp(g->jumper[g->jump_level], Type);
} // endif Check
#endif
-
Shrp[n] = (short)atoi(p);
+ SetNull(n, false);
} // end of SetValue
/***********************************************************************/
+/* Set one value in a block from a value in another block. */
+/***********************************************************************/
+void SHRBLK::SetValue(PVBLK pv, int n1, int n2)
+ {
+ CheckType(pv)
+ bool b;
+
+ if (!(b = pv->IsNull(n2) && Nullable))
+ Shrp[n1] = ((SHRBLK*)pv)->Shrp[n2];
+ else
+ Reset(n1);
+
+ SetNull(n1, b);
+ } // end of SetValue
+
+#if 0
+/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
void SHRBLK::SetMin(PVAL valp, int n)
@@ -697,16 +795,6 @@ void SHRBLK::SetMax(PVAL valp, int n)
} // end of SetMax
/***********************************************************************/
-/* Set one value in a block from a value in another block. */
-/***********************************************************************/
-void SHRBLK::SetValue(PVBLK pv, int n1, int n2)
- {
- CheckType(pv)
-
- Shrp[n1] = ((SHRBLK*)pv)->Shrp[n2];
- } // end of SetValue
-
-/***********************************************************************/
/* Set many values in a block from values in another block. */
/***********************************************************************/
void SHRBLK::SetValues(PVBLK pv, int k, int n)
@@ -727,6 +815,7 @@ void SHRBLK::AddMinus1(PVBLK pv, int n1, int n2)
assert(Type == pv->GetType());
Shrp[n1] += (((SHRBLK*)pv)->Shrp[n2] - 1);
} // end of AddMinus1
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -734,6 +823,7 @@ void SHRBLK::AddMinus1(PVBLK pv, int n1, int n2)
void SHRBLK::Move(int i, int j)
{
Shrp[j] = Shrp[i];
+ MoveNull(i, j);
} // end of Move
/***********************************************************************/
@@ -839,7 +929,14 @@ void LNGBLK::Init(PGLOBAL g, bool check)
void LNGBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
- Lngp[n] = valp->GetIntValue();
+ bool b;
+
+ if (!(b = valp->IsNull() && Nullable))
+ Lngp[n] = valp->GetIntValue();
+ else
+ Reset(n);
+
+ SetNull(n, b);
} // end of SetValue
/***********************************************************************/
@@ -859,6 +956,23 @@ void LNGBLK::SetValue(PSZ p, int n)
} // end of SetValue
/***********************************************************************/
+/* Set one value in a block from a value in another block. */
+/***********************************************************************/
+void LNGBLK::SetValue(PVBLK pv, int n1, int n2)
+ {
+ CheckType(pv)
+ bool b;
+
+ if (!(b = pv->IsNull(n2) && Nullable))
+ Lngp[n1] = ((LNGBLK*)pv)->Lngp[n2];
+ else
+ Reset(n1);
+
+ SetNull(n1, b);
+ } // end of SetValue
+
+#if 0
+/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
void LNGBLK::SetMin(PVAL valp, int n)
@@ -887,16 +1001,6 @@ void LNGBLK::SetMax(PVAL valp, int n)
} // end of SetMax
/***********************************************************************/
-/* Set one value in a block from a value in another block. */
-/***********************************************************************/
-void LNGBLK::SetValue(PVBLK pv, int n1, int n2)
- {
- CheckType(pv)
-
- Lngp[n1] = ((LNGBLK*)pv)->Lngp[n2];
- } // end of SetValue
-
-/***********************************************************************/
/* Set many values in a block from values in another block. */
/***********************************************************************/
void LNGBLK::SetValues(PVBLK pv, int k, int n)
@@ -917,6 +1021,7 @@ void LNGBLK::AddMinus1(PVBLK pv, int n1, int n2)
assert(Type == pv->GetType());
Lngp[n1] += (((LNGBLK*)pv)->Lngp[n2] - 1);
} // end of AddMinus1
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -924,6 +1029,7 @@ void LNGBLK::AddMinus1(PVBLK pv, int n1, int n2)
void LNGBLK::Move(int i, int j)
{
Lngp[j] = Lngp[i];
+ MoveNull(i, j);
} // end of Move
/***********************************************************************/
@@ -1066,7 +1172,14 @@ void BIGBLK::Init(PGLOBAL g, bool check)
void BIGBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
- Lngp[n] = valp->GetBigintValue();
+ bool b;
+
+ if (!(b = valp->IsNull() && Nullable))
+ Lngp[n] = valp->GetBigintValue();
+ else
+ Reset(n);
+
+ SetNull(n, b);
} // end of SetValue
/***********************************************************************/
@@ -1086,6 +1199,23 @@ void BIGBLK::SetValue(PSZ p, int n)
} // end of SetValue
/***********************************************************************/
+/* Set one value in a block from a value in another block. */
+/***********************************************************************/
+void BIGBLK::SetValue(PVBLK pv, int n1, int n2)
+ {
+ CheckType(pv)
+ bool b;
+
+ if (!(b = pv->IsNull(n2) && Nullable))
+ Lngp[n1] = ((BIGBLK*)pv)->Lngp[n2];
+ else
+ Reset(n1);
+
+ SetNull(n1, b);
+ } // end of SetValue
+
+#if 0
+/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
void BIGBLK::SetMin(PVAL valp, int n)
@@ -1114,16 +1244,6 @@ void BIGBLK::SetMax(PVAL valp, int n)
} // end of SetMax
/***********************************************************************/
-/* Set one value in a block from a value in another block. */
-/***********************************************************************/
-void BIGBLK::SetValue(PVBLK pv, int n1, int n2)
- {
- CheckType(pv)
-
- Lngp[n1] = ((BIGBLK*)pv)->Lngp[n2];
- } // end of SetValue
-
-/***********************************************************************/
/* Set many values in a block from values in another block. */
/***********************************************************************/
void BIGBLK::SetValues(PVBLK pv, int k, int n)
@@ -1144,6 +1264,7 @@ void BIGBLK::AddMinus1(PVBLK pv, int n1, int n2)
assert(Type == pv->GetType());
Lngp[n1] += (((BIGBLK*)pv)->Lngp[n2] - 1);
} // end of AddMinus1
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -1151,6 +1272,7 @@ void BIGBLK::AddMinus1(PVBLK pv, int n1, int n2)
void BIGBLK::Move(int i, int j)
{
Lngp[j] = Lngp[i];
+ MoveNull(i, j);
} // end of Move
/***********************************************************************/
@@ -1257,22 +1379,15 @@ void DBLBLK::Init(PGLOBAL g, bool check)
void DBLBLK::SetValue(PVBLK pv, int n1, int n2)
{
CheckType(pv)
+ bool b;
- Dblp[n1] = ((DBLBLK*)pv)->Dblp[n2];
- } // end of SetValue
-
-/***********************************************************************/
-/* Set many values in a block from values in another block. */
-/***********************************************************************/
-void DBLBLK::SetValues(PVBLK pv, int k, int n)
- {
- CheckType(pv)
- double *dp = ((DBLBLK*)pv)->Dblp;
-
- for (register int i = k; i < n; i++)
- Dblp[i] = dp[i];
+ if (!(b = pv->IsNull(n2) && Nullable))
+ Dblp[n1] = ((DBLBLK*)pv)->Dblp[n2];
+ else
+ Reset(n1);
- } // end of SetValues
+ SetNull(n1, b);
+ } // end of SetValue
/***********************************************************************/
/* Set one value in a block. */
@@ -1280,7 +1395,14 @@ void DBLBLK::SetValues(PVBLK pv, int k, int n)
void DBLBLK::SetValue(PVAL valp, int n)
{
CheckParms(valp, n)
- Dblp[n] = valp->GetFloatValue();
+ bool b;
+
+ if (!(b = valp->IsNull() && Nullable))
+ Dblp[n] = valp->GetFloatValue();
+ else
+ Reset(n);
+
+ SetNull(n, b);
} // end of SetValue
/***********************************************************************/
@@ -1299,6 +1421,20 @@ void DBLBLK::SetValue(PSZ p, int n)
Dblp[n] = atof(p);
} // end of SetValue
+#if 0
+/***********************************************************************/
+/* Set many values in a block from values in another block. */
+/***********************************************************************/
+void DBLBLK::SetValues(PVBLK pv, int k, int n)
+ {
+ CheckType(pv)
+ double *dp = ((DBLBLK*)pv)->Dblp;
+
+ for (register int i = k; i < n; i++)
+ Dblp[i] = dp[i];
+
+ } // end of SetValues
+
/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
@@ -1326,6 +1462,7 @@ void DBLBLK::SetMax(PVAL valp, int n)
fmax = fval;
} // end of SetMax
+#endif // 0
/***********************************************************************/
/* Move one value from i to j. */
@@ -1333,6 +1470,7 @@ void DBLBLK::SetMax(PVAL valp, int n)
void DBLBLK::Move(int i, int j)
{
Dblp[j] = Dblp[i];
+ MoveNull(i, j);
} // end of Move
/***********************************************************************/
diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h
index 6c04bfdab65..adcc7835dee 100644
--- a/storage/connect/valblk.h
+++ b/storage/connect/valblk.h
@@ -27,8 +27,7 @@ class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp);
public:
// Constructors
- VALBLK(void *mp, int type, int nval)
- {Blkp = mp; Type = type; Nval = nval; Check = true;}
+ VALBLK(void *mp, int type, int nval);
// Implementation
int GetNval(void) {return Nval;}
@@ -37,6 +36,12 @@ class VALBLK : public BLOCK {
void SetValPointer(void *mp) {Blkp = mp;}
int GetType(void) {return Type;}
void SetCheck(bool b) {Check = b;}
+ void MoveNull(int i, int j)
+ {if (To_Nulls) To_Nulls[j] = To_Nulls[j];}
+ virtual void SetNull(int n, bool b)
+ {if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}}
+ virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];}
+ virtual void SetNullable(bool b);
virtual void Init(PGLOBAL g, bool check) = 0;
virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n);
@@ -56,11 +61,13 @@ class VALBLK : public BLOCK {
virtual void SetValue(longlong lval, int n) {assert(false);}
virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
+ virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
+#if 0
virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetMax(PVAL valp, int n) = 0;
- virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetValues(PVBLK pv, int i, int n) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
+#endif // 0
virtual void Move(int i, int j) = 0;
virtual int CompVal(PVAL vp, int n) = 0;
virtual int CompVal(int i1, int i2) = 0;
@@ -80,10 +87,12 @@ class VALBLK : public BLOCK {
// Members
PGLOBAL Global; // Used for messages and allocation
+ char *To_Nulls; // Null values array
void *Blkp; // To value block
int Type; // Type of individual values
int Nval; // Max number of values in block
bool Check; // If true SetValue types must match
+ bool Nullable; // True if values can be null
}; // end of class VALBLK
/***********************************************************************/
@@ -109,10 +118,12 @@ class CHRBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -126,7 +137,7 @@ class CHRBLK : public VALBLK {
char* const &Chrp; // Pointer to char buffer
PSZ Valp; // Used to make a zero ended value
bool Blanks; // True for right filling with blanks
- bool Ci; // True if case insensitive
+ bool Ci; // True if case insensitive
int Long; // Length of each string
}; // end of class CHRBLK
@@ -141,6 +152,9 @@ class STRBLK : public VALBLK {
STRBLK(PGLOBAL g, void *mp, int size);
// Implementation
+ virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}}
+ virtual bool IsNull(int n) {return Strp[n] == NULL;}
+ virtual void SetNullable(bool b) {} // Always nullable
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];}
@@ -153,10 +167,12 @@ class STRBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -190,15 +206,20 @@ class SHRBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
- virtual void SetValue(short sval, int n) {Shrp[n] = sval;}
- virtual void SetValue(int lval, int n) {Shrp[n] = (short)lval;}
- virtual void SetValue(longlong lval, int n) {Shrp[n] = (short)lval;}
+ virtual void SetValue(short sval, int n)
+ {Shrp[n] = sval; SetNull(n, false);}
+ virtual void SetValue(int lval, int n)
+ {Shrp[n] = (short)lval; SetNull(n, false);}
+ virtual void SetValue(longlong lval, int n)
+ {Shrp[n] = (short)lval; SetNull(n, false);}
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -232,15 +253,20 @@ class LNGBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
- virtual void SetValue(short sval, int n) {Lngp[n] = (int)sval;}
- virtual void SetValue(int lval, int n) {Lngp[n] = lval;}
- virtual void SetValue(longlong lval, int n) {Lngp[n] = (int)lval;}
+ virtual void SetValue(short sval, int n)
+ {Lngp[n] = (int)sval; SetNull(n, false);}
+ virtual void SetValue(int lval, int n)
+ {Lngp[n] = lval; SetNull(n, false);}
+ virtual void SetValue(longlong lval, int n)
+ {Lngp[n] = (int)lval; SetNull(n, false);}
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -293,15 +319,20 @@ class BIGBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
- virtual void SetValue(short sval, int n) {Lngp[n] = (longlong)sval;}
- virtual void SetValue(int lval, int n) {Lngp[n] = (longlong)lval;}
- virtual void SetValue(longlong lval, int n) {Lngp[n] = lval;}
+ virtual void SetValue(short sval, int n)
+ {Lngp[n] = (longlong)sval; SetNull(n, false);}
+ virtual void SetValue(int lval, int n)
+ {Lngp[n] = (longlong)lval; SetNull(n, false);}
+ virtual void SetValue(longlong lval, int n)
+ {Lngp[n] = lval; SetNull(n, false);}
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
virtual void AddMinus1(PVBLK pv, int n1, int n2);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -337,10 +368,12 @@ class DBLBLK : public VALBLK {
// Methods
virtual void SetValue(PSZ sp, int n);
virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+#if 0
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
- virtual void SetValue(PVBLK pv, int n1, int n2);
virtual void SetValues(PVBLK pv, int k, int n);
+#endif // 0
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index b67e8a6348e..2ff961494fb 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -27,7 +27,7 @@
#define __VALUE_H
/***********************************************************************/
-/* Include relevant MariaDB header file. */
+/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
@@ -397,6 +397,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
/* -------------------------- Class VALUE ---------------------------- */
+#if 0
/***********************************************************************/
/* ShowTypedValue: send back the value formatted according to parms. */
/* buf: is a pointer to a buffer large enough for big double values. */
@@ -447,6 +448,7 @@ BYTE VALUE::TestValue(PVAL vp)
return (n > 0) ? 0x04 : (n < 0) ? 0x02 : 0x01;
} // end of TestValue
+#endif // 0
/* -------------------------- Class STRING --------------------------- */
@@ -490,7 +492,7 @@ STRING::STRING(PGLOBAL g, short i) : VALUE(TYPE_STRING)
} // end of STRING constructor
/***********************************************************************/
-/* STRING public constructor from int. */
+/* STRING public constructor from int. */
/***********************************************************************/
STRING::STRING(PGLOBAL g, int n) : VALUE(TYPE_STRING)
{
@@ -532,7 +534,11 @@ bool STRING::SetValue_pval(PVAL valp, bool chktype)
char buf[32];
- strncpy(Strp, valp->GetCharString(buf), Len);
+ if (!(Null = valp->IsNull() && Nullable))
+ strncpy(Strp, valp->GetCharString(buf), Len);
+ else
+ Reset();
+
return false;
} // end of SetValue_pval
@@ -551,6 +557,7 @@ void STRING::SetValue_char(char *p, int n)
if (trace)
htrc(" Setting string to: '%s'\n", Strp);
+ Null = false;
} // end of SetValue_char
/***********************************************************************/
@@ -559,6 +566,7 @@ void STRING::SetValue_char(char *p, int n)
void STRING::SetValue_psz(PSZ s)
{
strncpy(Strp, s, Len);
+ Null = false;
} // end of SetValue_psz
/***********************************************************************/
@@ -575,6 +583,7 @@ void STRING::SetValue_pvblk(PVBLK blk, int n)
void STRING::SetValue(short n)
{
SetValue((int)n);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -592,6 +601,7 @@ void STRING::SetValue(int n)
} else
SetValue_psz(buf);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -609,6 +619,7 @@ void STRING::SetValue(longlong n)
} else
SetValue_psz(buf);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -633,6 +644,7 @@ void STRING::SetValue(double f)
} else
SetValue_psz(buf);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -641,6 +653,7 @@ void STRING::SetValue(double f)
void STRING::SetBinValue(void *p)
{
SetValue_char((char *)p, Len);
+ Null = false;
} // end of SetBinValue
/***********************************************************************/
@@ -651,7 +664,7 @@ void STRING::SetBinValue(void *p)
/***********************************************************************/
bool STRING::GetBinValue(void *buf, int buflen, bool go)
{
- int len = strlen(Strp);
+ int len = (Null) ? 0 : strlen(Strp);
if (len > buflen)
return true;
@@ -663,6 +676,7 @@ bool STRING::GetBinValue(void *buf, int buflen, bool go)
return false;
} // end of GetBinValue
+#if 0
/***********************************************************************/
/* GetBinValue: used by SELECT when called from QUERY and KINDEX. */
/* This is a fast implementation that does not do any checking. */
@@ -674,6 +688,7 @@ void STRING::GetBinValue(void *buf, int buflen)
memset(buf, ' ', buflen);
memcpy(buf, Strp, buflen);
} // end of GetBinValue
+#endif // 0
/***********************************************************************/
/* STRING ShowValue: get string representation of a char value. */
@@ -696,7 +711,7 @@ char *STRING::GetCharString(char *p)
/***********************************************************************/
char *STRING::GetShortString(char *p, int n)
{
- sprintf(p, "%*hd", n, (short)atoi(Strp));
+ sprintf(p, "%*hd", n,(short)(Null ? 0 : atoi(Strp)));
return p;
} // end of GetShortString
@@ -705,7 +720,7 @@ char *STRING::GetShortString(char *p, int n)
/***********************************************************************/
char *STRING::GetIntString(char *p, int n)
{
- sprintf(p, "%*ld", n, atol(Strp));
+ sprintf(p, "%*ld", n, (Null) ? 0 : atol(Strp));
return p;
} // end of GetIntString
@@ -714,7 +729,7 @@ char *STRING::GetIntString(char *p, int n)
/***********************************************************************/
char *STRING::GetBigintString(char *p, int n)
{
- sprintf(p, "%*lld", n, atoll(Strp));
+ sprintf(p, "%*lld", n, (Null) ? 0 : atoll(Strp));
return p;
} // end of GetBigintString
@@ -723,7 +738,7 @@ char *STRING::GetBigintString(char *p, int n)
/***********************************************************************/
char *STRING::GetFloatString(char *p, int n, int prec)
{
- sprintf(p, "%*.*lf", n, (prec < 0) ? 2 : prec, atof(Strp));
+ sprintf(p, "%*.*lf", n, (prec < 0) ? 2 : prec, Null ? 0 : atof(Strp));
return p;
} // end of GetFloatString
@@ -736,6 +751,8 @@ bool STRING::IsEqual(PVAL vp, bool chktype)
return true;
else if (chktype && Type != vp->GetType())
return false;
+ else if (Null || vp->IsNull())
+ return false;
else if (Ci || vp->IsCi())
return !stricmp(Strp, vp->GetCharValue());
else // (!Ci)
@@ -743,6 +760,7 @@ bool STRING::IsEqual(PVAL vp, bool chktype)
} // end of IsEqual
+#if 0
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of character filters. */
@@ -1149,19 +1167,6 @@ int STRING::GetTime(PGLOBAL g, PVAL *vp, int np)
} // end of GetTime
/***********************************************************************/
-/* FormatValue: This function set vp (a STRING value) to the string */
-/* constructed from its own value formated using the fmt format. */
-/* This function assumes that the format matches the value type. */
-/***********************************************************************/
-bool STRING::FormatValue(PVAL vp, char *fmt)
- {
- char *buf = (char*)vp->GetTo_Val(); // Should be big enough
- int n = sprintf(buf, fmt, Strp);
-
- return (n > vp->GetValLen());
- } // end of FormatValue
-
-/***********************************************************************/
/* SetMin: used by the aggregate function MIN. */
/***********************************************************************/
void STRING::SetMin(PVAL vp)
@@ -1280,6 +1285,20 @@ void STRING::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMax
+#endif // 0
+
+/***********************************************************************/
+/* FormatValue: This function set vp (a STRING value) to the string */
+/* constructed from its own value formated using the fmt format. */
+/* This function assumes that the format matches the value type. */
+/***********************************************************************/
+bool STRING::FormatValue(PVAL vp, char *fmt)
+ {
+ char *buf = (char*)vp->GetTo_Val(); // Should be big enough
+ int n = sprintf(buf, fmt, Strp);
+
+ return (n > vp->GetValLen());
+ } // end of FormatValue
/***********************************************************************/
/* STRING SetFormat function (used to set SELECT output format). */
@@ -1302,7 +1321,7 @@ void STRING::Print(PGLOBAL g, FILE *f, uint n)
memset(m, ' ', n); /* Make margin string */
m[n] = '\0';
- fprintf(f, "%s%s\n", m, Strp);
+ fprintf(f, "%s%s\n", m, (Null) ? "<null>" : Strp);
} // end of Print
/***********************************************************************/
@@ -1310,7 +1329,7 @@ void STRING::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/
void STRING::Print(PGLOBAL g, char *ps, uint z)
{
- sprintf(ps, "'%.*s'", z-3, Strp);
+ sprintf(ps, "'%.*s'", z-3, (Null) ? "<null>" : Strp);
} // end of Print
/* -------------------------- Class SHVAL ---------------------------- */
@@ -1379,7 +1398,11 @@ bool SHVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && Type != valp->GetType())
return true;
- Sval = valp->GetShortValue();
+ if (!(Null = valp->IsNull() && Nullable))
+ Sval = valp->GetShortValue();
+ else
+ Reset();
+
return false;
} // end of SetValue
@@ -1422,6 +1445,7 @@ void SHVAL::SetValue_char(char *p, int n)
if (trace)
htrc(" setting short to: %hd\n", Sval);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -1430,6 +1454,7 @@ void SHVAL::SetValue_char(char *p, int n)
void SHVAL::SetValue_psz(PSZ s)
{
Sval = atoi(s);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -1438,6 +1463,7 @@ void SHVAL::SetValue_psz(PSZ s)
void SHVAL::SetValue_pvblk(PVBLK blk, int n)
{
Sval = blk->GetShortValue(n);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -1446,6 +1472,7 @@ void SHVAL::SetValue_pvblk(PVBLK blk, int n)
void SHVAL::SetBinValue(void *p)
{
Sval = *(short *)p;
+ Null = false;
} // end of SetBinValue
/***********************************************************************/
@@ -1471,6 +1498,7 @@ bool SHVAL::GetBinValue(void *buf, int buflen, bool go)
return false;
} // end of GetBinValue
+#if 0
/***********************************************************************/
/* GetBinValue: used by SELECT when called from QUERY and KINDEX. */
/* This is a fast implementation that does not do any checking. */
@@ -1481,6 +1509,7 @@ void SHVAL::GetBinValue(void *buf, int buflen)
*(short *)buf = Sval;
} // end of GetBinValue
+#endif // 0
/***********************************************************************/
/* SHVAL ShowValue: get string representation of a short value. */
@@ -1545,11 +1574,14 @@ bool SHVAL::IsEqual(PVAL vp, bool chktype)
return true;
else if (chktype && Type != vp->GetType())
return false;
+ else if (Null || vp->IsNull())
+ return false;
else
return (Sval == vp->GetShortValue());
} // end of IsEqual
+#if 0
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of short integer filters. */
@@ -1876,19 +1908,6 @@ void SHVAL::AddSquare(PVBLK vbp, int j, int k)
} // end of AddSquare
/***********************************************************************/
-/* FormatValue: This function set vp (a STRING value) to the string */
-/* constructed from its own value formated using the fmt format. */
-/* This function assumes that the format matches the value type. */
-/***********************************************************************/
-bool SHVAL::FormatValue(PVAL vp, char *fmt)
- {
- char *buf = (char*)vp->GetTo_Val(); // Should be big enough
- int n = sprintf(buf, fmt, Sval);
-
- return (n > vp->GetValLen());
- } // end of FormatValue
-
-/***********************************************************************/
/* SetMin: used by the aggregate function MIN. */
/***********************************************************************/
void SHVAL::SetMin(PVAL vp)
@@ -2001,6 +2020,20 @@ void SHVAL::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMax
+#endif // 0
+
+/***********************************************************************/
+/* FormatValue: This function set vp (a STRING value) to the string */
+/* constructed from its own value formated using the fmt format. */
+/* This function assumes that the format matches the value type. */
+/***********************************************************************/
+bool SHVAL::FormatValue(PVAL vp, char *fmt)
+ {
+ char *buf = (char*)vp->GetTo_Val(); // Should be big enough
+ int n = sprintf(buf, fmt, Sval);
+
+ return (n > vp->GetValLen());
+ } // end of FormatValue
/***********************************************************************/
/* SHVAL SetFormat function (used to set SELECT output format). */
@@ -2094,7 +2127,7 @@ int INTVAL::GetValLen(void)
} // end of GetValLen
/***********************************************************************/
-/* INTVAL SetValue: copy the value of another Value object. */
+/* INTVAL SetValue: copy the value of another Value object. */
/* This function allows conversion if chktype is false. */
/***********************************************************************/
bool INTVAL::SetValue_pval(PVAL valp, bool chktype)
@@ -2102,7 +2135,11 @@ bool INTVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && Type != valp->GetType())
return true;
- Ival = valp->GetIntValue();
+ if (!(Null = valp->IsNull() && Nullable))
+ Ival = valp->GetIntValue();
+ else
+ Reset();
+
return false;
} // end of SetValue
@@ -2142,6 +2179,7 @@ void INTVAL::SetValue_char(char *p, int n)
if (trace)
htrc(" setting int to: %d\n", Ival);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -2150,6 +2188,7 @@ void INTVAL::SetValue_char(char *p, int n)
void INTVAL::SetValue_psz(PSZ s)
{
Ival = atol(s);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -2158,6 +2197,7 @@ void INTVAL::SetValue_psz(PSZ s)
void INTVAL::SetValue_pvblk(PVBLK blk, int n)
{
Ival = blk->GetIntValue(n);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -2166,6 +2206,7 @@ void INTVAL::SetValue_pvblk(PVBLK blk, int n)
void INTVAL::SetBinValue(void *p)
{
Ival = *(int *)p;
+ Null = false;
} // end of SetBinValue
/***********************************************************************/
@@ -2188,9 +2229,11 @@ bool INTVAL::GetBinValue(void *buf, int buflen, bool go)
if (go)
*(int *)buf = Ival;
+ Null = false;
return false;
} // end of GetBinValue
+#if 0
/***********************************************************************/
/* GetBinValue: used by SELECT when called from QUERY and KINDEX. */
/* This is a fast implementation that does not do any checking. */
@@ -2201,6 +2244,7 @@ void INTVAL::GetBinValue(void *buf, int buflen)
*(int *)buf = Ival;
} // end of GetBinValue
+#endif // 0
/***********************************************************************/
/* INTVAL ShowValue: get string representation of a int value. */
@@ -2265,11 +2309,14 @@ bool INTVAL::IsEqual(PVAL vp, bool chktype)
return true;
else if (chktype && Type != vp->GetType())
return false;
+ else if (Null || vp->IsNull())
+ return false;
else
return (Ival == vp->GetIntValue());
} // end of IsEqual
+#if 0
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of int integer filters. */
@@ -2644,19 +2691,6 @@ void INTVAL::AddSquare(PVBLK vbp, int j, int k)
} // end of AddSquare
/***********************************************************************/
-/* FormatValue: This function set vp (a STRING value) to the string */
-/* constructed from its own value formated using the fmt format. */
-/* This function assumes that the format matches the value type. */
-/***********************************************************************/
-bool INTVAL::FormatValue(PVAL vp, char *fmt)
- {
- char *buf = (char*)vp->GetTo_Val(); // Should be big enough
- int n = sprintf(buf, fmt, Ival);
-
- return (n > vp->GetValLen());
- } // end of FormatValue
-
-/***********************************************************************/
/* SetMin: used by the aggregate function MIN. */
/***********************************************************************/
void INTVAL::SetMin(PVAL vp)
@@ -2769,6 +2803,20 @@ void INTVAL::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMax
+#endif // 0
+
+/***********************************************************************/
+/* FormatValue: This function set vp (a STRING value) to the string */
+/* constructed from its own value formated using the fmt format. */
+/* This function assumes that the format matches the value type. */
+/***********************************************************************/
+bool INTVAL::FormatValue(PVAL vp, char *fmt)
+ {
+ char *buf = (char*)vp->GetTo_Val(); // Should be big enough
+ int n = sprintf(buf, fmt, Ival);
+
+ return (n > vp->GetValLen());
+ } // end of FormatValue
/***********************************************************************/
/* INTVAL SetFormat function (used to set SELECT output format). */
@@ -3083,14 +3131,18 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && Type != valp->GetType())
return true;
- if (Pdtp && !valp->IsTypeNum()) {
- int ndv;
- int dval[6];
+ if (!(Null = valp->IsNull() && Nullable)) {
+ if (Pdtp && !valp->IsTypeNum()) {
+ int ndv;
+ int dval[6];
+
+ ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
+ MakeDate(NULL, dval, ndv);
+ } else
+ Ival = valp->GetIntValue();
- ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
- MakeDate(NULL, dval, ndv);
} else
- Ival = valp->GetIntValue();
+ Reset();
return false;
} // end of SetValue
@@ -3118,6 +3170,7 @@ void DTVAL::SetValue_char(char *p, int n)
if (trace)
htrc(" setting date: '%s' -> %d\n", Sdate, Ival);
+ Null = false;
} else
INTVAL::SetValue_char(p, n);
@@ -3141,6 +3194,7 @@ void DTVAL::SetValue_psz(PSZ p)
if (trace)
htrc(" setting date: '%s' -> %d\n", Sdate, Ival);
+ Null = false;
} else
INTVAL::SetValue_psz(p);
@@ -3183,6 +3237,7 @@ char *DTVAL::GetCharString(char *p)
} else
sprintf(p, "%d", Ival);
+ Null = false;
return p;
} // end of GetCharString
@@ -3218,6 +3273,7 @@ char *DTVAL::ShowValue(char *buf, int len)
} // end of ShowValue
+#if 0
/***********************************************************************/
/* Compute a function on a date time stamp. */
/***********************************************************************/
@@ -3280,6 +3336,7 @@ int DTVAL::GetTime(PGLOBAL g, PVAL *vp, int np)
{
return (Ival % 86400);
} // end of GetTime
+#endif // 0
/***********************************************************************/
/* Returns a member of the struct tm representation of the date. */
@@ -3331,13 +3388,14 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval)
return false;
} // end of WeekNum
+#if 0
/***********************************************************************/
/* This covers days, months and years between two dates. */
/***********************************************************************/
bool DTVAL::DateDiff(DTVAL *dtp, OPVAL op, int& tdif)
{
bool rc = false;
- int lv1, lv2, t1, t2;
+ int lv1, lv2, t1, t2;
int s = CompareValue(dtp);
struct tm dat1, dat2, *ptm = dtp->GetGmTime();
@@ -3406,6 +3464,7 @@ bool DTVAL::DateDiff(DTVAL *dtp, OPVAL op, int& tdif)
return rc;
} // end of DateDiff
+#endif // 0
/***********************************************************************/
/* FormatValue: This function set vp (a STRING value) to the string */
@@ -3498,7 +3557,11 @@ bool BIGVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && Type != valp->GetType())
return true;
- Lval = valp->GetBigintValue();
+ if (!(Null = valp->IsNull() && Nullable))
+ Lval = valp->GetBigintValue();
+ else
+ Reset();
+
return false;
} // end of SetValue
@@ -3538,6 +3601,7 @@ void BIGVAL::SetValue_char(char *p, int n)
if (trace)
htrc(" setting big int to: %lld\n", Lval);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -3546,6 +3610,7 @@ void BIGVAL::SetValue_char(char *p, int n)
void BIGVAL::SetValue_psz(PSZ s)
{
Lval = atoll(s);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -3554,6 +3619,7 @@ void BIGVAL::SetValue_psz(PSZ s)
void BIGVAL::SetValue_pvblk(PVBLK blk, int n)
{
Lval = blk->GetBigintValue(n);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -3562,6 +3628,7 @@ void BIGVAL::SetValue_pvblk(PVBLK blk, int n)
void BIGVAL::SetBinValue(void *p)
{
Lval = *(longlong *)p;
+ Null = false;
} // end of SetBinValue
/***********************************************************************/
@@ -3587,6 +3654,7 @@ bool BIGVAL::GetBinValue(void *buf, int buflen, bool go)
return false;
} // end of GetBinValue
+#if 0
/***********************************************************************/
/* GetBinValue: used by SELECT when called from QUERY and KINDEX. */
/* This is a fast implementation that does not do any checking. */
@@ -3597,6 +3665,7 @@ void BIGVAL::GetBinValue(void *buf, int buflen)
*(longlong *)buf = Lval;
} // end of GetBinValue
+#endif // 0
/***********************************************************************/
/* BIGVAL ShowValue: get string representation of a big int value. */
@@ -3661,11 +3730,14 @@ bool BIGVAL::IsEqual(PVAL vp, bool chktype)
return true;
else if (chktype && Type != vp->GetType())
return false;
+ else if (vp->IsNull() || Null)
+ return false;
else
return (Lval == vp->GetBigintValue());
} // end of IsEqual
+#if 0
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of big int integer filters. */
@@ -3990,19 +4062,6 @@ void BIGVAL::AddSquare(PVBLK vbp, int j, int k)
} // end of AddSquare
/***********************************************************************/
-/* FormatValue: This function set vp (a STRING value) to the string */
-/* constructed from its own value formated using the fmt format. */
-/* This function assumes that the format matches the value type. */
-/***********************************************************************/
-bool BIGVAL::FormatValue(PVAL vp, char *fmt)
- {
- char *buf = (char*)vp->GetTo_Val(); // Should be big enough
- int n = sprintf(buf, fmt, Lval);
-
- return (n > vp->GetValLen());
- } // end of FormatValue
-
-/***********************************************************************/
/* SetMin: used by the aggregate function MIN. */
/***********************************************************************/
void BIGVAL::SetMin(PVAL vp)
@@ -4115,6 +4174,20 @@ void BIGVAL::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMax
+#endif // 0
+
+/***********************************************************************/
+/* FormatValue: This function set vp (a STRING value) to the string */
+/* constructed from its own value formated using the fmt format. */
+/* This function assumes that the format matches the value type. */
+/***********************************************************************/
+bool BIGVAL::FormatValue(PVAL vp, char *fmt)
+ {
+ char *buf = (char*)vp->GetTo_Val(); // Should be big enough
+ int n = sprintf(buf, fmt, Lval);
+
+ return (n > vp->GetValLen());
+ } // end of FormatValue
/***********************************************************************/
/* BIGVAL SetFormat function (used to set SELECT output format). */
@@ -4221,7 +4294,11 @@ bool DFVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && Type != valp->GetType())
return true;
- Fval = valp->GetFloatValue();
+ if (!(Null = valp->IsNull() && Nullable))
+ Fval = valp->GetFloatValue();
+ else
+ Reset();
+
return false;
} // end of SetValue
@@ -4242,6 +4319,7 @@ void DFVAL::SetValue_char(char *p, int n)
if (trace)
htrc(" setting double: '%s' -> %lf\n", buf, Fval);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -4250,6 +4328,7 @@ void DFVAL::SetValue_char(char *p, int n)
void DFVAL::SetValue_psz(PSZ s)
{
Fval = atof(s);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -4258,6 +4337,7 @@ void DFVAL::SetValue_psz(PSZ s)
void DFVAL::SetValue_pvblk(PVBLK blk, int n)
{
Fval = blk->GetFloatValue(n);
+ Null = false;
} // end of SetValue
/***********************************************************************/
@@ -4266,6 +4346,7 @@ void DFVAL::SetValue_pvblk(PVBLK blk, int n)
void DFVAL::SetBinValue(void *p)
{
Fval = *(double *)p;
+ Null = false;
} // end of SetBinValue
/***********************************************************************/
@@ -4291,6 +4372,7 @@ bool DFVAL::GetBinValue(void *buf, int buflen, bool go)
return false;
} // end of GetBinValue
+#if 0
/***********************************************************************/
/* GetBinValue: used by SELECT when called from QUERY and KINDEX. */
/* This is a fast implementation that does not do any checking. */
@@ -4302,6 +4384,7 @@ void DFVAL::GetBinValue(void *buf, int buflen)
*(double *)buf = Fval;
} // end of GetBinValue
+#endif // 0
/***********************************************************************/
/* DFVAL ShowValue: get string representation of a double value. */
@@ -4367,11 +4450,14 @@ bool DFVAL::IsEqual(PVAL vp, bool chktype)
return true;
else if (chktype && Type != vp->GetType())
return false;
+ else if (Null || vp->IsNull())
+ return false;
else
return (Fval == vp->GetFloatValue());
} // end of IsEqual
+#if 0
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of double float filters. */
@@ -4785,6 +4871,20 @@ void DFVAL::SetMax(PVBLK vbp, int *x, int j, int k)
} // endfor i
} // end of SetMax
+#endif // 0
+
+/***********************************************************************/
+/* FormatValue: This function set vp (a STRING value) to the string */
+/* constructed from its own value formated using the fmt format. */
+/* This function assumes that the format matches the value type. */
+/***********************************************************************/
+bool DFVAL::FormatValue(PVAL vp, char *fmt)
+ {
+ char *buf = (char*)vp->GetTo_Val(); // Should be big enough
+ int n = sprintf(buf, fmt, Fval);
+
+ return (n > vp->GetValLen());
+ } // end of FormatValue
/***********************************************************************/
/* DFVAL SetFormat function (used to set SELECT output format). */
diff --git a/storage/connect/value.h b/storage/connect/value.h
index c0502085be5..bbb4aeb19a4 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -81,6 +81,9 @@ class DllExport VALUE : public BLOCK {
virtual longlong GetBigintValue(void) = 0;
virtual double GetFloatValue(void) = 0;
virtual void *GetTo_Val(void) = 0;
+ bool IsNull(void) {return Null;}
+ void SetNull(bool b) {Null = b;}
+ void SetNullable(bool b) {Nullable = b;}
int GetType(void) {return Type;}
int GetClen(void) {return Clen;}
void SetGlobal(PGLOBAL g) {Global = g;}
@@ -97,11 +100,17 @@ class DllExport VALUE : public BLOCK {
virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
virtual void SetBinValue(void *p) = 0;
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
- virtual void GetBinValue(void *buf, int len) = 0;
+//virtual void GetBinValue(void *buf, int len) = 0;
+ virtual char *ShowValue(char *buf, int len = 0) = 0;
+ virtual char *GetCharString(char *p) = 0;
+ virtual char *GetShortString(char *p, int n) {return "#####";}
+ virtual char *GetIntString(char *p, int n) = 0;
+ virtual char *GetBigintString(char *p, int n) = 0;
+ virtual char *GetFloatString(char *p, int n, int prec) = 0;
virtual bool IsEqual(PVAL vp, bool chktype) = 0;
+#if 0
virtual int CompareValue(PVAL vp) = 0;
virtual BYTE TestValue(PVAL vp);
- virtual void Divide(int cnt) {assert(false);}
virtual void StdVar(PVAL vp, int cnt, bool b) {assert(false);}
virtual void Add(int lv) {assert(false);}
virtual void Add(PVAL vp) {assert(false);}
@@ -112,6 +121,7 @@ class DllExport VALUE : public BLOCK {
virtual void AddSquare(PVBLK vbp, int i) {assert(false);}
virtual void AddSquare(PVBLK vbp, int j, int k) {assert(false);}
virtual void Times(PVAL vp) {assert(false);}
+ virtual void Divide(int cnt) {assert(false);}
virtual void SetMin(PVAL vp) = 0;
virtual void SetMin(PVBLK vbp, int i) = 0;
virtual void SetMin(PVBLK vbp, int j, int k) = 0;
@@ -120,25 +130,23 @@ class DllExport VALUE : public BLOCK {
virtual void SetMax(PVBLK vbp, int i) = 0;
virtual void SetMax(PVBLK vbp, int j, int k) = 0;
virtual void SetMax(PVBLK vbp, int *x, int j, int k) = 0;
- virtual char *ShowValue(char *buf, int len = 0) = 0;
- virtual char *GetCharString(char *p) = 0;
- virtual char *GetShortString(char *p, int n) {return "#####";}
- virtual char *GetIntString(char *p, int n) = 0;
- virtual char *GetBigintString(char *p, int n) = 0;
- virtual char *GetFloatString(char *p, int n, int prec) = 0;
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) = 0;
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) = 0;
+#endif // 0
virtual bool FormatValue(PVAL vp, char *fmt) = 0;
- char *ShowTypedValue(PGLOBAL g, char *buf, int typ, int n, int p);
+// char *ShowTypedValue(PGLOBAL g, char *buf, int typ, int n, int p);
+
protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
// Constructor used by derived classes
- VALUE(int type) : Type(type) {}
+ VALUE(int type) : Type(type) {Null=Nullable=false; Clen=0;}
// Members
PGLOBAL Global; // To reduce arglist
//const int Type; // The value type
+ bool Nullable; // True if value can be null
+ bool Null; // True if value is null
int Type; // The value type
int Clen; // Internal value length
}; // end of class VALUE
@@ -184,7 +192,7 @@ class STRING : public VALUE {
virtual void SetValue(double f);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual void GetBinValue(void *buf, int len);
+//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
@@ -192,6 +200,7 @@ class STRING : public VALUE {
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
+#if 0
virtual int CompareValue(PVAL vp);
virtual BYTE TestValue(PVAL vp);
virtual void SetMin(PVAL vp);
@@ -202,9 +211,10 @@ class STRING : public VALUE {
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
+#endif // 0
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
@@ -256,7 +266,7 @@ class SHVAL : public VALUE {
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual void GetBinValue(void *buf, int len);
+//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
@@ -264,8 +274,8 @@ class SHVAL : public VALUE {
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
+#if 0
virtual int CompareValue(PVAL vp);
- virtual void Divide(int cnt);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Sval += (short)lv;}
virtual void Add(PVAL vp);
@@ -276,6 +286,7 @@ class SHVAL : public VALUE {
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
+ virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
@@ -284,16 +295,17 @@ class SHVAL : public VALUE {
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) {return 0;}
+#endif // 0
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
protected:
- short SafeAdd(short n1, short n2);
- short SafeMult(short n1, short n2);
+// short SafeAdd(short n1, short n2);
+// short SafeMult(short n1, short n2);
// Default constructor not to be used
SHVAL(void) : VALUE(TYPE_ERROR) {}
@@ -339,7 +351,7 @@ class DllExport INTVAL : public VALUE {
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual void GetBinValue(void *buf, int len);
+//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
@@ -347,8 +359,8 @@ class DllExport INTVAL : public VALUE {
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
+#if 0
virtual int CompareValue(PVAL vp);
- virtual void Divide(int cnt);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Ival += lv;}
virtual void Add(PVAL vp);
@@ -359,6 +371,7 @@ class DllExport INTVAL : public VALUE {
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
+ virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
@@ -367,16 +380,17 @@ class DllExport INTVAL : public VALUE {
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
+#endif // 0
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
protected:
- int SafeAdd(int n1, int n2);
- int SafeMult(int n1, int n2);
+// int SafeAdd(int n1, int n2);
+// int SafeMult(int n1, int n2);
// Default constructor not to be used
INTVAL(void) : VALUE(TYPE_ERROR) {}
@@ -404,8 +418,8 @@ class DllExport DTVAL : public INTVAL {
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual char *GetCharString(char *p);
virtual char *ShowValue(char *buf, int);
- virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
- virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
+//virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
+//virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
virtual bool FormatValue(PVAL vp, char *fmt);
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
bool SetFormat(PGLOBAL g, PVAL valp);
@@ -473,7 +487,7 @@ class DllExport BIGVAL : public VALUE {
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual void GetBinValue(void *buf, int len);
+//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
@@ -481,8 +495,8 @@ class DllExport BIGVAL : public VALUE {
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
+#if 0
virtual int CompareValue(PVAL vp);
- virtual void Divide(int cnt);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Lval += (longlong)lv;}
virtual void Add(PVAL vp);
@@ -493,6 +507,7 @@ class DllExport BIGVAL : public VALUE {
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
+ virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
@@ -501,16 +516,17 @@ class DllExport BIGVAL : public VALUE {
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) {return 0;}
+#endif // 0
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
protected:
- longlong SafeAdd(longlong n1, longlong n2);
- longlong SafeMult(longlong n1, longlong n2);
+// longlong SafeAdd(longlong n1, longlong n2);
+// longlong SafeMult(longlong n1, longlong n2);
// Default constructor not to be used
BIGVAL(void) : VALUE(TYPE_ERROR) {}
@@ -556,7 +572,7 @@ class DFVAL : public VALUE {
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual void GetBinValue(void *buf, int len);
+//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
@@ -564,8 +580,8 @@ class DFVAL : public VALUE {
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
+#if 0
virtual int CompareValue(PVAL vp);
- virtual void Divide(int cnt);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(PVAL vp);
virtual void Add(PVBLK vbp, int i);
@@ -575,6 +591,7 @@ class DFVAL : public VALUE {
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
+ virtual void Divide(int cnt)
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
@@ -583,15 +600,16 @@ class DFVAL : public VALUE {
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
+#endif // 0
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
// Specific function
- void Divide(double div) {Fval /= div;}
+ void Divide(double d) {Fval /= d;}
protected:
// Default constructor not to be used
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 073767752d3..5971f578113 100644
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -279,7 +279,7 @@ int XINDEX::Qcompare(int *i1, int *i2)
bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
{
/*********************************************************************/
- /* Table can be accessed through an index. */
+ /* Table can be accessed through an index. */
/*********************************************************************/
int k, rc = RC_OK;
int *bof, i, j, n, ndf, nkey;
@@ -2861,6 +2861,12 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
{
int len = colp->GetLength(), prec = colp->GetPrecision();
+ // Currently no indexing on NULL columns
+ if (colp->IsNullable()) {
+ sprintf(g->Message, "Cannot index nullable column %s", colp->GetName());
+ return true;
+ } // endif nullable
+
if (kln && len > kln && colp->GetResultType() == TYPE_STRING) {
len = kln;
Prefix = true;