Commit 2b60525d authored by Olivier Bertrand's avatar Olivier Bertrand

- Add support to NULL values. This concern the MYSQL

  and ODBC table types. Not supported yet for indexes.

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