diff options
-rw-r--r-- | storage/connect/global.h | 1 | ||||
-rw-r--r-- | storage/connect/ha_connect.cc | 5 | ||||
-rw-r--r-- | storage/connect/myutil.cpp | 13 | ||||
-rw-r--r-- | storage/connect/plgdbutl.cpp | 4 | ||||
-rw-r--r-- | storage/connect/tabdos.cpp | 13 | ||||
-rw-r--r-- | storage/connect/tabwmi.cpp | 12 | ||||
-rw-r--r-- | storage/connect/valblk.cpp | 706 | ||||
-rw-r--r-- | storage/connect/valblk.h | 176 | ||||
-rw-r--r-- | storage/connect/value.cpp | 70 | ||||
-rw-r--r-- | storage/connect/value.h | 11 | ||||
-rw-r--r-- | storage/connect/xobject.cpp | 6 |
11 files changed, 150 insertions, 867 deletions
diff --git a/storage/connect/global.h b/storage/connect/global.h index 963b5047e1a..778f5cab2e9 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -79,6 +79,7 @@ #define TYPE_STRING 1 #define TYPE_FLOAT 2 #define TYPE_SHORT 3 +#define TYPE_TINY 4 #define TYPE_BIGINT 5 #define TYPE_LIST 6 #define TYPE_INT 7 diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 5a2cbcbe01c..61d2f6271a9 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1097,6 +1097,9 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) case MYSQL_TYPE_SHORT: pcf->Type= TYPE_SHORT; break; + case MYSQL_TYPE_TINY: + pcf->Type= TYPE_TINY; + break; case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_FLOAT: pcf->Type= TYPE_FLOAT; @@ -3797,6 +3800,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_LONGLONG: + case MYSQL_TYPE_TINY: break; // Ok case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: @@ -3804,7 +3808,6 @@ int ha_connect::create(const char *name, TABLE *table_arg, case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_INT24: break; // To be checked - case MYSQL_TYPE_TINY: case MYSQL_TYPE_BIT: case MYSQL_TYPE_NULL: case MYSQL_TYPE_ENUM: diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index 44a4ed8a165..0b97e8aa5a0 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -1,7 +1,7 @@ /************** MyUtil C++ Program Source Code File (.CPP) **************/ /* PROGRAM NAME: MYUTIL */ /* ------------- */ -/* Version 1.0 */ +/* Version 1.1 */ /* */ /* Author Olivier BERTRAND 2013 */ /* */ @@ -35,7 +35,7 @@ int MYSQLtoPLG(char *typname) if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") || !stricmp(typname, "integer")) type = TYPE_INT; - else if (!stricmp(typname, "tinyint") || !stricmp(typname, "smallint")) + else if (!stricmp(typname, "smallint")) type = TYPE_SHORT; else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") || !stricmp(typname, "text") || !stricmp(typname, "blob")) @@ -50,6 +50,8 @@ int MYSQLtoPLG(char *typname) type = TYPE_DATE; else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong")) type = TYPE_BIGINT; + else if (!stricmp(typname, "tinyint")) + type = TYPE_TINY; else type = TYPE_ERROR; @@ -82,6 +84,9 @@ enum enum_field_types PLGtoMYSQL(int type, bool dbf) case TYPE_BIGINT: mytype = MYSQL_TYPE_LONGLONG; break; + case TYPE_TINY: + mytype = MYSQL_TYPE_TINY; + break; default: mytype = MYSQL_TYPE_NULL; } // endswitch mytype @@ -97,7 +102,6 @@ int MYSQLtoPLG(int mytype) int type; switch (mytype) { - case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: type = TYPE_SHORT; break; @@ -109,6 +113,9 @@ int MYSQLtoPLG(int mytype) case MYSQL_TYPE_LONGLONG: type = TYPE_BIGINT; break; + case MYSQL_TYPE_TINY: + type = TYPE_TINY; + break; case MYSQL_TYPE_DECIMAL: #if !defined(ALPHA) case MYSQL_TYPE_NEWDECIMAL: diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 511ccf54863..ef6e3d5f6c6 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -1529,6 +1529,10 @@ void PlugPutOut(PGLOBAL g, FILE *f, short t, void *v, uint n) fprintf(f, "%s%hd\n", m, *(short *)v); break; + case TYPE_TINY: + fprintf(f, "%s%d\n", m, (int)*(char *)v); + break; + case TYPE_VOID: break; diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 4140f94ff37..c3ac9d08911 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -1086,6 +1086,7 @@ void DOSCOL::ReadColumn(PGLOBAL g) if (Nod) switch (Buf_Type) { case TYPE_INT: case TYPE_SHORT: + case TYPE_TINY: case TYPE_BIGINT: Value->SetValue_char(p, field - Dcm); break; @@ -1175,7 +1176,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) len = sprintf(Buf, fmt, field - i, Value->GetShortValue()); break; case TYPE_INT: - strcpy(fmt, (Ldz) ? "%0*ld" : "%*.ld"); + strcpy(fmt, (Ldz) ? "%0*d" : "%*.d"); i = 0; if (Nod) @@ -1184,6 +1185,16 @@ void DOSCOL::WriteColumn(PGLOBAL g) len = sprintf(Buf, fmt, field - i, Value->GetIntValue()); break; + case TYPE_TINY: + strcpy(fmt, (Ldz) ? "%0*d" : "%*.d"); + i = 0; + + if (Nod) + for (; i < Dcm; i++) + strcat(fmt, "0"); + + len = sprintf(Buf, fmt, field - i, Value->GetTinyValue()); + break; case TYPE_FLOAT: strcpy(fmt, (Ldz) ? "%0*.*lf" : "%*.*lf"); sprintf(Buf, fmt, field + ((Nod && Dcm) ? 1 : 0), diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index e4e5dde7be5..789994ad8f7 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -256,10 +256,13 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) case CIM_UINT32: case CIM_BOOLEAN: typ = TYPE_INT; - lng = 9; + lng = 11; break; case CIM_SINT8: case CIM_UINT8: + typ = TYPE_TINY; + lng = 4; + break; case CIM_SINT16: case CIM_UINT16: typ = TYPE_SHORT; @@ -268,11 +271,14 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info) case CIM_REAL64: case CIM_REAL32: prec = 2; - case CIM_SINT64: - case CIM_UINT64: typ = TYPE_FLOAT; lng = 15; break; + case CIM_SINT64: + case CIM_UINT64: + typ = TYPE_BIGINT; + lng = 20; + break; case CIM_DATETIME: typ = TYPE_DATE; lng = 19; diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index c7427381b76..4fbee8ba3df 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -1,5 +1,5 @@ /************ Valblk C++ Functions Source Code File (.CPP) *************/ -/* Name: VALBLK.CPP Version 1.6 */ +/* Name: VALBLK.CPP Version 1.7 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* */ @@ -78,6 +78,9 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, case TYPE_FLOAT: blkp = new(g) TYPBLK<double>(mp, nval, prec, type); break; + case TYPE_TINY: + blkp = new(g) TYPBLK<char>(mp, nval, type); + break; default: sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type); return NULL; @@ -258,6 +261,10 @@ template <> double TYPBLK<double>::GetTypedValue(PVAL valp) {return valp->GetFloatValue();} +template <> +char TYPBLK<char>::GetTypedValue(PVAL valp) + {return valp->GetTinyValue();} + /***********************************************************************/ /* Set one value in a block. */ /***********************************************************************/ @@ -284,6 +291,8 @@ template <> longlong TYPBLK<longlong>::GetTypedValue(PSZ p) {return atoll(p);} template <> double TYPBLK<double>::GetTypedValue(PSZ p) {return atof(p);} +template <> +char TYPBLK<char>::GetTypedValue(PSZ p) {return (char)atoi(p);} /***********************************************************************/ /* Set one value in a block from a value in another block. */ @@ -320,6 +329,10 @@ template <> double TYPBLK<double>::GetTypedValue(PVBLK blk, int n) {return blk->GetFloatValue(n);} +template <> +char TYPBLK<char>::GetTypedValue(PVBLK blk, int n) + {return blk->GetTinyValue(n);} + #if 0 /***********************************************************************/ /* Set many values in a block from values in another block. */ @@ -486,7 +499,7 @@ char *CHRBLK::GetCharValue(int n) short CHRBLK::GetShortValue(int n) { return (short)atoi((char *)GetValPtrEx(n)); - } // end of GetIntValue + } // end of GetShortValue /***********************************************************************/ /* Return the value of the nth element converted to int. */ @@ -502,7 +515,7 @@ int CHRBLK::GetIntValue(int n) longlong CHRBLK::GetBigintValue(int n) { return atoll((char *)GetValPtrEx(n)); - } // end of GetIntValue + } // end of GetBigintValue /***********************************************************************/ /* Return the value of the nth element converted to double. */ @@ -513,6 +526,14 @@ double CHRBLK::GetFloatValue(int n) } // end of GetFloatValue /***********************************************************************/ +/* Return the value of the nth element converted to tiny int. */ +/***********************************************************************/ +char CHRBLK::GetTinyValue(int n) + { + return (char)atoi((char *)GetValPtrEx(n)); + } // end of GetTinyValue + +/***********************************************************************/ /* Set one value in a block. */ /***********************************************************************/ void CHRBLK::SetValue(PVAL valp, int n) @@ -875,345 +896,6 @@ int STRBLK::GetMaxLength(void) return n; } // end of GetMaxLength -#if 0 -/* -------------------------- Class SHRBLK --------------------------- */ - -/***********************************************************************/ -/* Constructor. */ -/***********************************************************************/ -SHRBLK::SHRBLK(void *mp, int nval) - : VALBLK(mp, TYPE_SHORT, nval), Shrp((short*&)Blkp) - { - } // end of SHRBLK constructor - -/***********************************************************************/ -/* Initialization routine. */ -/***********************************************************************/ -void SHRBLK::Init(PGLOBAL g, bool check) - { - if (!Blkp) - Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(short)); - - Check = check; - Global = g; - } // end of Init - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void SHRBLK::SetValue(PVAL valp, int n) - { - CheckParms(valp, n) - bool b; - - if (!(b = valp->IsNull() && Nullable)) - Shrp[n] = valp->GetShortValue(); - else - Reset(n); - - SetNull(n, b); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void SHRBLK::SetValue(PSZ p, int n) - { -#if defined(_DEBUG) || defined(DEBTRACE) - if (Check) { - PGLOBAL& g = Global; - strcpy(g->Message, MSG(BAD_SET_STRING)); - longjmp(g->jumper[g->jump_level], Type); - } // endif Check -#endif - Shrp[n] = (short)atoi(p); - SetNull(n, false); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block from a value in another block. */ -/***********************************************************************/ -void SHRBLK::SetValue(PVBLK pv, int n1, int n2) - { - CheckType(pv) - bool b; - - if (!(b = pv->IsNull(n2) && Nullable)) - Shrp[n1] = ((SHRBLK*)pv)->Shrp[n2]; - else - Reset(n1); - - SetNull(n1, b); - } // end of SetValue - -#if 0 -/***********************************************************************/ -/* Set many values in a block from values in another block. */ -/***********************************************************************/ -void SHRBLK::SetValues(PVBLK pv, int k, int n) - { - CheckType(pv) - short *sp = ((SHRBLK*)pv)->Shrp; - - for (register int i = k; i < n; i++) - Shrp[i] = sp[i]; - - } // end of SetValues -#endif // 0 - -/***********************************************************************/ -/* Move one value from i to j. */ -/***********************************************************************/ -void SHRBLK::Move(int i, int j) - { - Shrp[j] = Shrp[i]; - MoveNull(i, j); - } // end of Move - -/***********************************************************************/ -/* Compare a Value object with the nth value of the block. */ -/***********************************************************************/ -int SHRBLK::CompVal(PVAL vp, int n) - { - CheckParms(vp, n) - short msv = Shrp[n]; - short vsv = vp->GetShortValue(); - - return (vsv > msv) ? 1 : (vsv < msv) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Compare two values of the block. */ -/***********************************************************************/ -int SHRBLK::CompVal(int i1, int i2) - { - short sv1 = Shrp[i1]; - short sv2 = Shrp[i2]; - - return (sv1 > sv2) ? 1 : (sv1 < sv2) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *SHRBLK::GetValPtr(int n) - { - ChkIndx(n); - return Shrp + n; - } // end of GetValPtr - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *SHRBLK::GetValPtrEx(int n) - { - ChkIndx(n); - return Shrp + n; - } // end of GetValPtrEx - -/***********************************************************************/ -/* Returns index of matching value in block or -1. */ -/***********************************************************************/ -int SHRBLK::Find(PVAL vp) - { - CheckType(vp) - int i; - short n = vp->GetShortValue(); - - for (i = 0; i < Nval; i++) - if (n == Shrp[i]) - break; - - return (i < Nval) ? i : (-1); - } // end of Find - -/***********************************************************************/ -/* Returns the length of the longest string in the block. */ -/***********************************************************************/ -int SHRBLK::GetMaxLength(void) - { - char buf[12]; - int i, n; - - for (i = n = 0; i < Nval; i++) { - sprintf(buf, "%hd", Shrp[i]); - - n = max(n, (signed)strlen(buf)); - } // endfor i - - return n; - } // end of GetMaxLength - - -/* -------------------------- Class LNGBLK --------------------------- */ - -/***********************************************************************/ -/* Constructor. */ -/***********************************************************************/ -LNGBLK::LNGBLK(void *mp, int nval) - : VALBLK(mp, TYPE_INT, nval), Lngp((int*&)Blkp) - { - } // end of LNGBLK constructor - -/***********************************************************************/ -/* Initialization routine. */ -/***********************************************************************/ -void LNGBLK::Init(PGLOBAL g, bool check) - { - if (!Blkp) - Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(int)); - - Check = check; - Global = g; - } // end of Init - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void LNGBLK::SetValue(PVAL valp, int n) - { - CheckParms(valp, n) - bool b; - - if (!(b = valp->IsNull() && Nullable)) - Lngp[n] = valp->GetIntValue(); - else - Reset(n); - - SetNull(n, b); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void LNGBLK::SetValue(PSZ p, int n) - { -#if defined(_DEBUG) || defined(DEBTRACE) - if (Check) { - PGLOBAL& g = Global; - strcpy(g->Message, MSG(BAD_SET_STRING)); - longjmp(g->jumper[g->jump_level], Type); - } // endif Check -#endif - - Lngp[n] = atol(p); - } // 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 many values in a block from values in another block. */ -/***********************************************************************/ -void LNGBLK::SetValues(PVBLK pv, int k, int n) - { - CheckType(pv) - int *lp = ((LNGBLK*)pv)->Lngp; - - for (register int i = k; i < n; i++) - Lngp[i] = lp[i]; - - } // end of SetValues -#endif // 0 - -/***********************************************************************/ -/* Move one value from i to j. */ -/***********************************************************************/ -void LNGBLK::Move(int i, int j) - { - Lngp[j] = Lngp[i]; - MoveNull(i, j); - } // end of Move - -/***********************************************************************/ -/* Compare a Value object with the nth value of the block. */ -/***********************************************************************/ -int LNGBLK::CompVal(PVAL vp, int n) - { - CheckParms(vp, n) - register int mlv = Lngp[n]; - register int vlv = vp->GetIntValue(); - - return (vlv > mlv) ? 1 : (vlv < mlv) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Compare two values of the block. */ -/***********************************************************************/ -int LNGBLK::CompVal(int i1, int i2) - { - register int lv1 = Lngp[i1]; - register int lv2 = Lngp[i2]; - - return (lv1 > lv2) ? 1 : (lv1 < lv2) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *LNGBLK::GetValPtr(int n) - { - ChkIndx(n); - return Lngp + n; - } // end of GetValPtr - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *LNGBLK::GetValPtrEx(int n) - { - ChkIndx(n); - return Lngp + n; - } // end of GetValPtrEx - -/***********************************************************************/ -/* Returns index of matching value in block or -1. */ -/***********************************************************************/ -int LNGBLK::Find(PVAL vp) - { - CheckType(vp) - int i; - int n = vp->GetIntValue(); - - for (i = 0; i < Nval; i++) - if (n == Lngp[i]) - break; - - return (i < Nval) ? i : (-1); - } // end of Find - -/***********************************************************************/ -/* Returns the length of the longest string in the block. */ -/***********************************************************************/ -int LNGBLK::GetMaxLength(void) - { - char buf[12]; - int i, n; - - for (i = n = 0; i < Nval; i++) { - sprintf(buf, "%d", Lngp[i]); - - n = max(n, (signed)strlen(buf)); - } // endfor i - - return n; - } // end of GetMaxLength -#endif // 0 - /* -------------------------- Class DATBLK --------------------------- */ /***********************************************************************/ @@ -1250,345 +932,5 @@ void DATBLK::SetValue(PSZ p, int n) } // end of SetValue -#if 0 -/* -------------------------- Class BIGBLK --------------------------- */ - -/***********************************************************************/ -/* Constructor. */ -/***********************************************************************/ -BIGBLK::BIGBLK(void *mp, int nval) - : VALBLK(mp, TYPE_BIGINT, nval), Lngp((longlong*&)Blkp) - { - } // end of BIGBLK constructor - -/***********************************************************************/ -/* Initialization routine. */ -/***********************************************************************/ -void BIGBLK::Init(PGLOBAL g, bool check) - { - if (!Blkp) - Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(longlong)); - - Check = check; - Global = g; - } // end of Init - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void BIGBLK::SetValue(PVAL valp, int n) - { - CheckParms(valp, n) - bool b; - - if (!(b = valp->IsNull() && Nullable)) - Lngp[n] = valp->GetBigintValue(); - else - Reset(n); - - SetNull(n, b); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void BIGBLK::SetValue(PSZ p, int n) - { -#if defined(_DEBUG) || defined(DEBTRACE) - if (Check) { - PGLOBAL& g = Global; - strcpy(g->Message, MSG(BAD_SET_STRING)); - longjmp(g->jumper[g->jump_level], Type); - } // endif Check -#endif - - Lngp[n] = atoll(p); - } // 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 many values in a block from values in another block. */ -/***********************************************************************/ -void BIGBLK::SetValues(PVBLK pv, int k, int n) - { - CheckType(pv) - longlong *lp = ((BIGBLK*)pv)->Lngp; - - for (register int i = k; i < n; i++) - Lngp[i] = lp[i]; - - } // end of SetValues -#endif // 0 - -/***********************************************************************/ -/* Move one value from i to j. */ -/***********************************************************************/ -void BIGBLK::Move(int i, int j) - { - Lngp[j] = Lngp[i]; - MoveNull(i, j); - } // end of Move - -/***********************************************************************/ -/* Compare a Value object with the nth value of the block. */ -/***********************************************************************/ -int BIGBLK::CompVal(PVAL vp, int n) - { - CheckParms(vp, n) - longlong mlv = Lngp[n]; - longlong vlv = vp->GetBigintValue(); - - return (vlv > mlv) ? 1 : (vlv < mlv) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Compare two values of the block. */ -/***********************************************************************/ -int BIGBLK::CompVal(int i1, int i2) - { - longlong lv1 = Lngp[i1]; - longlong lv2 = Lngp[i2]; - - return (lv1 > lv2) ? 1 : (lv1 < lv2) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *BIGBLK::GetValPtr(int n) - { - ChkIndx(n); - return Lngp + n; - } // end of GetValPtr - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *BIGBLK::GetValPtrEx(int n) - { - ChkIndx(n); - return Lngp + n; - } // end of GetValPtrEx - -/***********************************************************************/ -/* Returns index of matching value in block or -1. */ -/***********************************************************************/ -int BIGBLK::Find(PVAL vp) - { - CheckType(vp) - int i; - longlong n = vp->GetBigintValue(); - - for (i = 0; i < Nval; i++) - if (n == Lngp[i]) - break; - - return (i < Nval) ? i : (-1); - } // end of Find - -/***********************************************************************/ -/* Returns the length of the longest string in the block. */ -/***********************************************************************/ -int BIGBLK::GetMaxLength(void) - { - char buf[24]; - int i, n; - - for (i = n = 0; i < Nval; i++) { - sprintf(buf, "%lld", Lngp[i]); - - n = max(n, (signed)strlen(buf)); - } // endfor i - - return n; - } // end of GetMaxLength - - -/* -------------------------- Class DBLBLK --------------------------- */ - -/***********************************************************************/ -/* Constructor. */ -/***********************************************************************/ -DBLBLK::DBLBLK(void *mp, int nval, int prec) - : VALBLK(mp, TYPE_FLOAT, nval), Dblp((double*&)Blkp) - { - Prec = prec; - } // end of DBLBLK constructor - -/***********************************************************************/ -/* Initialization routine. */ -/***********************************************************************/ -void DBLBLK::Init(PGLOBAL g, bool check) - { - if (!Blkp) - Blkp = PlugSubAlloc(g, NULL, Nval * sizeof(double)); - - Check = check; - Global = g; - } // end of Init - -/***********************************************************************/ -/* Set one value in a block from a value in another block. */ -/***********************************************************************/ -void DBLBLK::SetValue(PVBLK pv, int n1, int n2) - { - CheckType(pv) - bool b; - - if (!(b = pv->IsNull(n2) && Nullable)) - Dblp[n1] = ((DBLBLK*)pv)->Dblp[n2]; - else - Reset(n1); - - SetNull(n1, b); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void DBLBLK::SetValue(PVAL valp, int n) - { - CheckParms(valp, n) - bool b; - - if (!(b = valp->IsNull() && Nullable)) - Dblp[n] = valp->GetFloatValue(); - else - Reset(n); - - SetNull(n, b); - } // end of SetValue - -/***********************************************************************/ -/* Set one value in a block. */ -/***********************************************************************/ -void DBLBLK::SetValue(PSZ p, int n) - { -#if defined(_DEBUG) || defined(DEBTRACE) - if (Check) { - PGLOBAL& g = Global; - strcpy(g->Message, MSG(BAD_SET_STRING)); - longjmp(g->jumper[g->jump_level], Type); - } // endif Check -#endif - - Dblp[n] = atof(p); - } // end of SetValue - -#if 0 -/***********************************************************************/ -/* Set many values in a block from values in another block. */ -/***********************************************************************/ -void DBLBLK::SetValues(PVBLK pv, int k, int n) - { - CheckType(pv) - double *dp = ((DBLBLK*)pv)->Dblp; - - for (register int i = k; i < n; i++) - Dblp[i] = dp[i]; - - } // end of SetValues -#endif // 0 - -/***********************************************************************/ -/* Move one value from i to j. */ -/***********************************************************************/ -void DBLBLK::Move(int i, int j) - { - Dblp[j] = Dblp[i]; - MoveNull(i, j); - } // end of Move - -/***********************************************************************/ -/* Compare a Value object with the nth value of the block. */ -/***********************************************************************/ -int DBLBLK::CompVal(PVAL vp, int n) - { - CheckParms(vp, n) - double mfv = Dblp[n]; - double vfv = vp->GetFloatValue(); - - return (vfv > mfv) ? 1 : (vfv < mfv) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Compare two values of the block. */ -/***********************************************************************/ -int DBLBLK::CompVal(int i1, int i2) - { - register double dv1 = Dblp[i1]; - register double dv2 = Dblp[i2]; - - return (dv1 > dv2) ? 1 : (dv1 < dv2) ? (-1) : 0; - } // end of CompVal - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *DBLBLK::GetValPtr(int n) - { - ChkIndx(n); - return Dblp + n; - } // end of GetValPtr - -/***********************************************************************/ -/* Get a pointer on the nth value of the block. */ -/***********************************************************************/ -void *DBLBLK::GetValPtrEx(int n) - { - ChkIndx(n); - return Dblp + n; - } // end of GetValPtrEx - -/***********************************************************************/ -/* Returns index of matching value in block or -1. */ -/***********************************************************************/ -int DBLBLK::Find(PVAL vp) - { - CheckType(vp) - int i; - double d = vp->GetFloatValue(); - - for (i = 0; i < Nval; i++) - if (d == Dblp[i]) - break; - - return (i < Nval) ? i : (-1); - } // end of Find - -/***********************************************************************/ -/* Returns the length of the longest string in the block. */ -/***********************************************************************/ -int DBLBLK::GetMaxLength(void) - { - char buf[32]; - int i, n; - - for (i = n = 0; i < Nval; i++) { - sprintf(buf, "%lf", Dblp[i]); - - n = max(n, (signed)strlen(buf)); - } // endfor i - - return n; - } // end of GetMaxLength -#endif // 0 - /* ------------------------- End of Valblk --------------------------- */ diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index 32bc2135935..9a85577a104 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -1,5 +1,5 @@ /*************** Valblk H Declares Source Code File (.H) ***************/ -/* Name: VALBLK.H Version 1.8 */ +/* Name: VALBLK.H Version 1.9 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* */ @@ -50,6 +50,7 @@ class VALBLK : public BLOCK { virtual int GetIntValue(int n) = 0; virtual longlong GetBigintValue(int n) = 0; virtual double GetFloatValue(int n) = 0; + virtual char GetTinyValue(int n) = 0; virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} virtual void Reset(int n) = 0; virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); @@ -61,6 +62,7 @@ class VALBLK : public BLOCK { virtual void SetValue(int lval, int n) {assert(false);} virtual void SetValue(longlong lval, int n) {assert(false);} virtual void SetValue(double fval, int n) {assert(false);} + virtual void SetValue(char cval, int n) {assert(false);} virtual void SetValue(PSZ sp, int n) {assert(false);} virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVBLK pv, int n1, int n2) = 0; @@ -113,6 +115,7 @@ class TYPBLK : public VALBLK { virtual int GetIntValue(int n) {return (int)Typp[n];} virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];} virtual double GetFloatValue(int n) {return (double)Typp[n];} + virtual char GetTinyValue(int n) {return (char)Typp[n];} virtual void Reset(int n) {Typp[n] = 0;} // Methods @@ -125,6 +128,8 @@ class TYPBLK : public VALBLK { {Typp[n] = (TYPE)lval; SetNull(n, false);} virtual void SetValue(double fval, int n) {Typp[n] = (TYPE)fval; SetNull(n, false);} + virtual void SetValue(char cval, int n) + {Typp[n] = (TYPE)cval; SetNull(n, false);} virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVBLK pv, int n1, int n2); //virtual void SetValues(PVBLK pv, int k, int n); @@ -163,6 +168,7 @@ class CHRBLK : public VALBLK { virtual int GetIntValue(int n); virtual longlong GetBigintValue(int n); virtual double GetFloatValue(int n); + virtual char GetTinyValue(int n); virtual void Reset(int n); virtual void SetPrec(int p) {Ci = (p != 0);} virtual bool IsCi(void) {return Ci;} @@ -210,6 +216,7 @@ class STRBLK : public VALBLK { virtual int GetIntValue(int n) {return atol(Strp[n]);} virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);} virtual double GetFloatValue(int n) {return atof(Strp[n]);} + virtual char GetTinyValue(int n) {return (char)atoi(Strp[n]);} virtual void Reset(int n) {Strp[n] = NULL;} // Methods @@ -230,92 +237,6 @@ class STRBLK : public VALBLK { PSZ* const &Strp; // Pointer to PSZ buffer }; // end of class STRBLK -#if 0 -/***********************************************************************/ -/* Class SHRBLK: represents a block of short integer values. */ -/***********************************************************************/ -class SHRBLK : public VALBLK { - public: - // Constructors - SHRBLK(void *mp, int size); - - // Implementation - virtual void Init(PGLOBAL g, bool check); - virtual int GetVlen(void) {return sizeof(short);} -//virtual PSZ GetCharValue(int n); - virtual short GetShortValue(int n) {return Shrp[n];} - virtual int GetIntValue(int n) {return (int)Shrp[n];} - virtual longlong GetBigintValue(int n) {return (longlong)Shrp[n];} - virtual double GetFloatValue(int n) {return (double)Shrp[n];} - virtual void Reset(int n) {Shrp[n] = 0;} - - // Methods - virtual void SetValue(PSZ sp, int n); - virtual void SetValue(short sval, int n) - {Shrp[n] = sval; SetNull(n, false);} - virtual void SetValue(int lval, int n) - {Shrp[n] = (short)lval; SetNull(n, false);} - virtual void SetValue(longlong lval, int n) - {Shrp[n] = (short)lval; SetNull(n, false);} - virtual void SetValue(PVAL valp, int n); - virtual void SetValue(PVBLK pv, int n1, int n2); -//virtual void SetValues(PVBLK pv, int k, int n); - virtual void Move(int i, int j); - virtual int CompVal(PVAL vp, int n); - virtual int CompVal(int i1, int i2); - virtual void *GetValPtr(int n); - virtual void *GetValPtrEx(int n); - virtual int Find(PVAL vp); - virtual int GetMaxLength(void); - - protected: - // Members - short* const &Shrp; - }; // end of class SHRBLK - -/***********************************************************************/ -/* Class LNGBLK: represents a block of int integer values. */ -/***********************************************************************/ -class LNGBLK : public VALBLK { - public: - // Constructors - LNGBLK(void *mp, int size); - - // Implementation - virtual void Init(PGLOBAL g, bool check); - virtual int GetVlen(void) {return sizeof(int);} -//virtual PSZ GetCharValue(int n); - virtual short GetShortValue(int n) {return (short)Lngp[n];} - virtual int GetIntValue(int n) {return Lngp[n];} - virtual longlong GetBigintValue(int n) {return (longlong)Lngp[n];} - virtual double GetFloatValue(int n) {return (double)Lngp[n];} - virtual void Reset(int n) {Lngp[n] = 0;} - - // Methods - virtual void SetValue(PSZ sp, int n); - virtual void SetValue(short sval, int n) - {Lngp[n] = (int)sval; SetNull(n, false);} - virtual void SetValue(int lval, int n) - {Lngp[n] = lval; SetNull(n, false);} - virtual void SetValue(longlong lval, int n) - {Lngp[n] = (int)lval; SetNull(n, false);} - virtual void SetValue(PVAL valp, int n); - virtual void SetValue(PVBLK pv, int n1, int n2); -//virtual void SetValues(PVBLK pv, int k, int n); - virtual void Move(int i, int j); - virtual int CompVal(PVAL vp, int n); - virtual int CompVal(int i1, int i2); - virtual void *GetValPtr(int n); - virtual void *GetValPtrEx(int n); - virtual int Find(PVAL vp); - virtual int GetMaxLength(void); - - protected: - // Members - int* const &Lngp; - }; // end of class LNGBLK -#endif // 0 - /***********************************************************************/ /* Class DATBLK: represents a block of time stamp values. */ /***********************************************************************/ @@ -335,86 +256,5 @@ class DATBLK : public TYPBLK<int> { PVAL Dvalp; // Date value used to convert string }; // end of class DATBLK -#if 0 -/***********************************************************************/ -/* Class BIGBLK: represents a block of big integer values. */ -/***********************************************************************/ -class BIGBLK : public VALBLK { - public: - // Constructors - BIGBLK(void *mp, int size); - - // Implementation - virtual void Init(PGLOBAL g, bool check); - virtual int GetVlen(void) {return sizeof(longlong);} -//virtual PSZ GetCharValue(int n); - virtual short GetShortValue(int n) {return (short)Lngp[n];} - virtual int GetIntValue(int n) {return (int)Lngp[n];} - virtual longlong GetBigintValue(int n) {return Lngp[n];} - virtual double GetFloatValue(int n) {return (double)Lngp[n];} - virtual void Reset(int n) {Lngp[n] = 0LL;} - - // Methods - virtual void SetValue(PSZ sp, int n); - virtual void SetValue(short sval, int n) - {Lngp[n] = (longlong)sval; SetNull(n, false);} - virtual void SetValue(int lval, int n) - {Lngp[n] = (longlong)lval; SetNull(n, false);} - virtual void SetValue(longlong lval, int n) - {Lngp[n] = lval; SetNull(n, false);} - virtual void SetValue(PVAL valp, int n); - virtual void SetValue(PVBLK pv, int n1, int n2); -//virtual void SetValues(PVBLK pv, int k, int n); - virtual void Move(int i, int j); - virtual int CompVal(PVAL vp, int n); - virtual int CompVal(int i1, int i2); - virtual void *GetValPtr(int n); - virtual void *GetValPtrEx(int n); - virtual int Find(PVAL vp); - virtual int GetMaxLength(void); - - protected: - // Members - longlong* const &Lngp; - }; // end of class BIGBLK - -/***********************************************************************/ -/* Class DBLBLK: represents a block of double float values. */ -/***********************************************************************/ -class DBLBLK : public VALBLK { - public: - // Constructors - DBLBLK(void *mp, int size, int prec); - - // Implementation - virtual void Init(PGLOBAL g, bool check); - virtual int GetVlen(void) {return sizeof(double);} -//virtual PSZ GetCharValue(int n); - virtual short GetShortValue(int n) {return (short)Dblp[n];} - virtual int GetIntValue(int n) {return (int)Dblp[n];} - virtual longlong GetBigintValue(int n) {return (longlong)Dblp[n];} - virtual double GetFloatValue(int n) {return Dblp[n];} - virtual void Reset(int n) {Dblp[n] = 0.0;} - virtual void SetPrec(int p) {Prec = p;} - - // Methods - virtual void SetValue(PSZ sp, int n); - virtual void SetValue(PVAL valp, int n); - virtual void SetValue(PVBLK pv, int n1, int n2); -//virtual void SetValues(PVBLK pv, int k, int n); - virtual void Move(int i, int j); - virtual int CompVal(PVAL vp, int n); - virtual int CompVal(int i1, int i2); - virtual void *GetValPtr(int n); - virtual void *GetValPtrEx(int n); - virtual int Find(PVAL vp); - virtual int GetMaxLength(void); - - protected: - // Members - double* const &Dblp; - }; // end of class DBLBLK -#endif // 0 - #endif // __VALBLK__H__ diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 4e29cffb1d2..7412b2197de 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1,5 +1,5 @@ /************* Value C++ Functions Source Code File (.CPP) *************/ -/* Name: VALUE.CPP Version 2.1 */ +/* Name: VALUE.CPP Version 2.2 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* */ @@ -19,8 +19,8 @@ /* to avoid too complicated classes and unuseful duplication of many */ /* functions used on one family only. The drawback is that for new */ /* types of objects, we shall have more classes to update. */ -/* Currently the only implemented types are STRING, INT, DOUBLE, DATE */ -/* and LONGLONG. Shortly we should add at least TINY and VARCHAR. */ +/* Currently the only implemented types are STRING, INT, SHORT, TINY, */ +/* DATE and LONGLONG. Shortly we should add at least UNSIGNED types. */ /***********************************************************************/ /***********************************************************************/ @@ -128,6 +128,7 @@ PSZ GetTypeName(int type) case TYPE_BIGINT: name = "BIGINT"; break; case TYPE_DATE: name = "DATE"; break; case TYPE_FLOAT: name = "FLOAT"; break; + case TYPE_TINY: name = "TINY"; break; } // endswitch type return name; @@ -145,6 +146,7 @@ int GetTypeSize(int type, int len) case TYPE_BIGINT: len = sizeof(longlong); break; case TYPE_DATE: len = sizeof(int); break; case TYPE_FLOAT: len = sizeof(double); break; + case TYPE_TINY: len = sizeof(char); break; break; default: len = 0; } // endswitch type @@ -206,6 +208,7 @@ char *GetFormatType(int type) case TYPE_BIGINT: c = "L"; break; case TYPE_FLOAT: c = "F"; break; case TYPE_DATE: c = "D"; break; + case TYPE_TINY: c = "T"; break; } // endswitch type return c; @@ -225,6 +228,7 @@ int GetFormatType(char c) case 'L': type = TYPE_BIGINT; break; case 'F': type = TYPE_FLOAT; break; case 'D': type = TYPE_DATE; break; + case 'T': type = TYPE_TINY; break; } // endswitch type return type; @@ -256,6 +260,7 @@ bool IsTypeNum(int type) case TYPE_FLOAT: case TYPE_SHORT: case TYPE_NUM: + case TYPE_TINY: return true; } // endswitch type @@ -267,13 +272,14 @@ bool IsTypeNum(int type) /***********************************************************************/ const char *GetFmt(int type) { - const char *fmt = "%d";; + const char *fmt; switch (type) { case TYPE_STRING: fmt = "%s"; break; case TYPE_SHORT: fmt = "%hd"; break; case TYPE_BIGINT: fmt = "%lld"; break; case TYPE_FLOAT: fmt = "%.*lf"; break; + default: fmt = "%d"; break; } // endswitch Type return fmt; @@ -304,7 +310,8 @@ int ConvertType(int target, int type, CONV kind, bool match) : (target == TYPE_DATE || type == TYPE_DATE) ? TYPE_DATE : (target == TYPE_BIGINT || type == TYPE_BIGINT) ? TYPE_BIGINT : (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT - : TYPE_SHORT; + : (target == TYPE_SHORT || type == TYPE_SHORT) ? TYPE_SHORT + : TYPE_TINY; default: if (target == TYPE_ERROR || target == type) return type; @@ -319,6 +326,7 @@ int ConvertType(int target, int type, CONV kind, bool match) : (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT : (target == TYPE_SHORT || type == TYPE_SHORT) ? TYPE_SHORT : (target == TYPE_STRING || type == TYPE_STRING) ? TYPE_STRING + : (target == TYPE_TINY || type == TYPE_TINY) ? TYPE_TINY : TYPE_ERROR; } // endswitch kind @@ -350,6 +358,9 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type) case TYPE_FLOAT: valp = new(g) TYPVAL<double>(*(double *)value, TYPE_FLOAT); break; + case TYPE_TINY: + valp = new(g) TYPVAL<char>(*(char *)value, TYPE_TINY); + break; default: sprintf(g->Message, MSG(BAD_VALUE_TYPE), type); return NULL; @@ -386,6 +397,9 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, case TYPE_FLOAT: valp = new(g) TYPVAL<double>(0.0, prec, TYPE_FLOAT); break; + case TYPE_TINY: + valp = new(g) TYPVAL<char>((char)0, TYPE_SHORT); + break; default: sprintf(g->Message, MSG(BAD_VALUE_TYPE), type); return NULL; @@ -430,6 +444,9 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype) case TYPE_FLOAT: valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_FLOAT); break; + case TYPE_TINY: + valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY); + break; default: sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype); return NULL; @@ -460,13 +477,14 @@ VALUE::VALUE(int type) : Type(type) /***********************************************************************/ const char *VALUE::GetXfmt(void) { - const char *fmt = "%*d";; + const char *fmt; switch (Type) { case TYPE_STRING: fmt = "%*s"; break; case TYPE_SHORT: fmt = "%*hd"; break; case TYPE_BIGINT: fmt = "%*lld"; break; case TYPE_FLOAT: fmt = "%*.*lf"; break; + default: fmt = "%*d"; break; } // endswitch Type return fmt; @@ -527,7 +545,6 @@ bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype) return true; if (!(Null = valp->IsNull() && Nullable)) -// Tval = (TYPE)valp->GetBigintValue(); Tval = GetTypedValue(valp); else Reset(); @@ -551,6 +568,10 @@ template <> double TYPVAL<double>::GetTypedValue(PVAL valp) {return valp->GetFloatValue();} +template <> +char TYPVAL<char>::GetTypedValue(PVAL valp) + {return valp->GetTinyValue();} + /***********************************************************************/ /* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/ /***********************************************************************/ @@ -628,7 +649,8 @@ template <> longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);} template <> double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);} - +template <> +char TYPVAL<char>::GetTypedValue(PSZ s) {return (char)atoi(s);} /***********************************************************************/ /* TYPVAL SetValue: set value with a TYPE extracted from a block. */ @@ -656,6 +678,10 @@ template <> double TYPVAL<double>::GetTypedValue(PVBLK blk, int n) {return blk->GetFloatValue(n);} +template <> +char TYPVAL<char>::GetTypedValue(PVBLK blk, int n) + {return blk->GetTinyValue(n);} + /***********************************************************************/ /* TYPVAL SetBinValue: with bytes extracted from a line. */ /***********************************************************************/ @@ -767,6 +793,16 @@ char *TYPVAL<TYPE>::GetFloatString(char *p, int n, int prec) } // end of GetFloatString /***********************************************************************/ +/* TYPVAL GetTinyString: get char representation of a typed value. */ +/***********************************************************************/ +template <class TYPE> +char *TYPVAL<TYPE>::GetTinyString(char *p, int n) + { + sprintf(p, "%*d", n, (int)(char)Tval); + return p; + } // end of GetIntString + +/***********************************************************************/ /* TYPVAL compare value with another Value. */ /***********************************************************************/ template <class TYPE> @@ -998,6 +1034,15 @@ void TYPVAL<PSZ>::SetValue(double f) } // end of SetValue /***********************************************************************/ +/* STRING SetValue: get the character representation of a tiny int. */ +/***********************************************************************/ +void TYPVAL<PSZ>::SetValue(char c) + { + SetValue((int)c); + Null = false; + } // end of SetValue + +/***********************************************************************/ /* STRING SetBinValue: fill string with chars extracted from a line. */ /***********************************************************************/ void TYPVAL<PSZ>::SetBinValue(void *p) @@ -1079,6 +1124,15 @@ char *TYPVAL<PSZ>::GetFloatString(char *p, int n, int prec) } // end of GetFloatString /***********************************************************************/ +/* STRING GetTinyString: get tiny int representation of a char value. */ +/***********************************************************************/ +char *TYPVAL<PSZ>::GetTinyString(char *p, int n) + { + sprintf(p, "%*d", n, (Null) ? 0 : (char)atoi(Strp)); + return p; + } // end of GetIntString + +/***********************************************************************/ /* STRING compare value with another Value. */ /***********************************************************************/ bool TYPVAL<PSZ>::IsEqual(PVAL vp, bool chktype) diff --git a/storage/connect/value.h b/storage/connect/value.h index 99e71b5d699..0f7b795c252 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -1,5 +1,5 @@ /**************** Value H Declares Source Code File (.H) ***************/ -/* Name: VALUE.H Version 1.8 */ +/* Name: VALUE.H Version 1.9 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* */ @@ -76,6 +76,7 @@ class DllExport VALUE : public BLOCK { virtual int GetValPrec(void) = 0; virtual int GetLength(void) {return 1;} virtual PSZ GetCharValue(void) {assert(false); return NULL;} + virtual char GetTinyValue(void) {assert(false); return 0;} virtual short GetShortValue(void) {assert(false); return 0;} virtual int GetIntValue(void) = 0; virtual longlong GetBigintValue(void) = 0; @@ -93,6 +94,7 @@ class DllExport VALUE : public BLOCK { virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual void SetValue_char(char *p, int n) = 0; virtual void SetValue_psz(PSZ s) = 0; + virtual void SetValue(char c) {assert(false);} virtual void SetValue(short i) {assert(false);} virtual void SetValue(int n) {assert(false);} virtual void SetValue(longlong n) {assert(false);} @@ -106,6 +108,7 @@ class DllExport VALUE : public BLOCK { 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 char *GetTinyString(char *p, int n) {return "?";} virtual bool IsEqual(PVAL vp, bool chktype) = 0; virtual bool FormatValue(PVAL vp, char *fmt) = 0; @@ -145,6 +148,7 @@ class DllExport TYPVAL : public VALUE { virtual int GetValPrec() {return 0;} virtual int GetSize(void) {return sizeof(TYPE);} virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();} + virtual char GetTinyValue(void) {return (char)Tval;} virtual short GetShortValue(void) {return (short)Tval;} virtual int GetIntValue(void) {return (int)Tval;} virtual longlong GetBigintValue(void) {return (longlong)Tval;} @@ -155,6 +159,7 @@ class DllExport TYPVAL : public VALUE { virtual bool SetValue_pval(PVAL valp, bool chktype); virtual void SetValue_char(char *p, int n); virtual void SetValue_psz(PSZ s); + virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;} virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;} virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;} @@ -168,6 +173,7 @@ class DllExport TYPVAL : public VALUE { virtual char *GetIntString(char *p, int n); virtual char *GetBigintString(char *p, int n); virtual char *GetFloatString(char *p, int n, int prec = -1); + virtual char *GetTinyString(char *p, int n); virtual bool IsEqual(PVAL vp, bool chktype); virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool FormatValue(PVAL vp, char *fmt); @@ -205,6 +211,7 @@ class DllExport TYPVAL<PSZ>: public VALUE { virtual int GetValPrec() {return (Ci) ? 1 : 0;} virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} virtual PSZ GetCharValue(void) {return Strp;} + virtual char GetTinyValue(void) {return (char)atoi(Strp);} virtual short GetShortValue(void) {return (short)atoi(Strp);} virtual int GetIntValue(void) {return atol(Strp);} virtual longlong GetBigintValue(void) {return atoll(Strp);} @@ -216,6 +223,7 @@ class DllExport TYPVAL<PSZ>: public VALUE { virtual void SetValue_char(char *p, int n); virtual void SetValue_psz(PSZ s); virtual void SetValue_pvblk(PVBLK blk, int n); + virtual void SetValue(char c); virtual void SetValue(short i); virtual void SetValue(int n); virtual void SetValue(longlong n); @@ -228,6 +236,7 @@ class DllExport TYPVAL<PSZ>: public VALUE { virtual char *GetIntString(char *p, int n); virtual char *GetBigintString(char *p, int n); virtual char *GetFloatString(char *p, int n, int prec = -1); + virtual char *GetTinyString(char *p, int n); virtual bool IsEqual(PVAL vp, bool chktype); virtual bool FormatValue(PVAL vp, char *fmt); virtual bool SetConstFormat(PGLOBAL, FORMAT&); diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp index 093fe8cb103..cd8af248005 100644 --- a/storage/connect/xobject.cpp +++ b/storage/connect/xobject.cpp @@ -153,6 +153,12 @@ bool CONSTANT::Rephrase(PGLOBAL g, PSZ work) case TYPE_FLOAT: sprintf(work + strlen(work), "%lf", Value->GetFloatValue()); break; + case TYPE_BIGINT: + sprintf(work + strlen(work), "%lld", Value->GetBigintValue()); + break; + case TYPE_TINY: + sprintf(work + strlen(work), "%d", Value->GetTinyValue()); + break; default: sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType()); return false; |