summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2015-03-30 19:03:57 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2015-03-30 19:03:57 +0200
commit8721d20fb1360b4fe6a415f64b22769f750984de (patch)
treeda852c4d6fc9ce96f31c823478160283cd4ea7b1
parentdaa8b6b5bac5d0237724bb17d55d804134a8cb35 (diff)
downloadmariadb-git-8721d20fb1360b4fe6a415f64b22769f750984de.tar.gz
- Fix MDEV-7879 by adding a test in all SetValue_pval function to return when valp == this.
- Fix MDEV-7840 by making proper datetime constant in ha_connect::CheckCond on a second place.
-rw-r--r--storage/connect/ha_connect.cc7
-rw-r--r--storage/connect/value.cpp80
2 files changed, 52 insertions, 35 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index c6c3703f54e..74f89fa2abe 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -2714,7 +2714,12 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
case MYSQL_TYPE_DATETIME:
if (tty == TYPE_AM_ODBC) {
strcat(body, "{ts '");
- strcat(strncat(body, res->ptr(), res->length()), "'}");
+ strncat(body, res->ptr(), res->length());
+
+ if (res->length() < 19)
+ strcat(body, "1970-01-01 00:00:00" + res->length());
+
+ strcat(body, "'}");
break;
} // endif ODBC
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index e012e12d00b..7d3d5463129 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -627,13 +627,16 @@ int TYPVAL<double>::GetValLen(void)
template <class TYPE>
bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype)
{
- if (chktype && Type != valp->GetType())
- return true;
+ if (valp != this) {
+ if (chktype && Type != valp->GetType())
+ return true;
- if (!(Null = valp->IsNull() && Nullable))
- Tval = GetTypedValue(valp);
- else
- Reset();
+ if (!(Null = valp->IsNull() && Nullable))
+ Tval = GetTypedValue(valp);
+ else
+ Reset();
+
+ } // endif valp
return false;
} // end of SetValue
@@ -1319,15 +1322,18 @@ ulonglong TYPVAL<PSZ>::GetUBigintValue(void)
/***********************************************************************/
bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
{
- if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
- return true;
+ if (valp != this) {
+ if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
+ return true;
- char buf[64];
+ char buf[64];
- if (!(Null = valp->IsNull() && Nullable))
- strncpy(Strp, valp->GetCharString(buf), Len);
- else
- Reset();
+ if (!(Null = valp->IsNull() && Nullable))
+ strncpy(Strp, valp->GetCharString(buf), Len);
+ else
+ Reset();
+
+ } // endif valp
return false;
} // end of SetValue_pval
@@ -2063,18 +2069,21 @@ double BINVAL::GetFloatValue(void)
/***********************************************************************/
bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
{
- if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen))
- return true;
-
bool rc = false;
-
- if (!(Null = valp->IsNull() && Nullable)) {
- if ((rc = (Len = valp->GetSize()) > Clen))
- Len = Clen;
+
+ if (valp != this) {
+ if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen))
+ return true;
- memcpy(Binp, valp->GetTo_Val(), Len);
- } else
- Reset();
+ if (!(Null = valp->IsNull() && Nullable)) {
+ if ((rc = (Len = valp->GetSize()) > Clen))
+ Len = Clen;
+
+ memcpy(Binp, valp->GetTo_Val(), Len);
+ } else
+ Reset();
+
+ } // endif valp
return rc;
} // end of SetValue_pval
@@ -2629,21 +2638,24 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval)
/***********************************************************************/
bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
{
- if (chktype && Type != valp->GetType())
- return true;
+ if (valp != this) {
+ if (chktype && Type != valp->GetType())
+ return true;
- if (!(Null = valp->IsNull() && Nullable)) {
- if (Pdtp && !valp->IsTypeNum()) {
- int ndv;
- int dval[6];
+ if (!(Null = valp->IsNull() && Nullable)) {
+ if (Pdtp && !valp->IsTypeNum()) {
+ int ndv;
+ int dval[6];
+
+ ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
+ MakeDate(NULL, dval, ndv);
+ } else
+ Tval = valp->GetIntValue();
- ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
- MakeDate(NULL, dval, ndv);
} else
- Tval = valp->GetIntValue();
+ Reset();
- } else
- Reset();
+ } // endif valp
return false;
} // end of SetValue