1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Rewrite some VALBLK classes as templates

- Correct typo initializing datm in DTVAL::MakeDate as {0,0,0,2,0,70,0,0,0}
  instead of {0,0,0,1,0,70,0,0,0}

modified:
  storage/connect/valblk.cpp
  storage/connect/valblk.h
  storage/connect/value.cpp
  storage/connect/value.h
This commit is contained in:
Olivier Bertrand
2013-03-01 22:23:40 +01:00
parent cdf3606b38
commit 63798ef4a5
4 changed files with 416 additions and 346 deletions

View File

@@ -262,6 +262,23 @@ bool IsTypeNum(int type)
return false;
} // end of IsTypeNum
/***********************************************************************/
/* GetFmt: returns the format to use with a typed value. */
/***********************************************************************/
const char *GetFmt(int type)
{
const char *fmt = "%d";;
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;
} // endswitch Type
return fmt;
} // end of GetFmt
/***********************************************************************/
/* ConvertType: what this function does is to determine the type to */
/* which should be converted a value so no precision would be lost. */
@@ -430,7 +447,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
/***********************************************************************/
VALUE::VALUE(int type) : Type(type)
{
Fmt = GetFmt();
Fmt = GetFmt(Type);
Xfmt = GetXfmt();
Null = false;
Nullable = false;
@@ -438,23 +455,6 @@ VALUE::VALUE(int type) : Type(type)
Prec = 0;
} // end of VALUE constructor
/***********************************************************************/
/* VALUE GetFmt: returns the format to use with typed value. */
/***********************************************************************/
const char *VALUE::GetFmt(void)
{
const char *fmt = "%d";;
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;
} // endswitch Type
return fmt;
} // end of GetFmt
/***********************************************************************/
/* VALUE GetXfmt: returns the extended format to use with typed value. */
/***********************************************************************/
@@ -1278,9 +1278,9 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval)
int n;
bool rc = false;
#if defined(WIN32)
struct tm datm = {0,0,0,2,0,70,0,0,0};
struct tm datm = {0,0,0,1,0,70,0,0,0};
#else // !WIN32
struct tm datm = {0,0,0,2,0,70,0,0,0,0,0};
struct tm datm = {0,0,0,1,0,70,0,0,0,0,0};
#endif // !WIN32
if (trace)