Commit 8721d20f authored by Olivier Bertrand's avatar Olivier Bertrand

- 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.
parent daa8b6b5
...@@ -2714,7 +2714,12 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond) ...@@ -2714,7 +2714,12 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
if (tty == TYPE_AM_ODBC) { if (tty == TYPE_AM_ODBC) {
strcat(body, "{ts '"); 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; break;
} // endif ODBC } // endif ODBC
......
...@@ -627,13 +627,16 @@ int TYPVAL<double>::GetValLen(void) ...@@ -627,13 +627,16 @@ int TYPVAL<double>::GetValLen(void)
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype) bool TYPVAL<TYPE>::SetValue_pval(PVAL valp, bool chktype)
{ {
if (chktype && Type != valp->GetType()) if (valp != this) {
return true; if (chktype && Type != valp->GetType())
return true;
if (!(Null = valp->IsNull() && Nullable)) if (!(Null = valp->IsNull() && Nullable))
Tval = GetTypedValue(valp); Tval = GetTypedValue(valp);
else else
Reset(); Reset();
} // endif valp
return false; return false;
} // end of SetValue } // end of SetValue
...@@ -1319,15 +1322,18 @@ ulonglong TYPVAL<PSZ>::GetUBigintValue(void) ...@@ -1319,15 +1322,18 @@ ulonglong TYPVAL<PSZ>::GetUBigintValue(void)
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
{ {
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len)) if (valp != this) {
return true; if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
char buf[64]; char buf[64];
if (!(Null = valp->IsNull() && Nullable)) if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len); strncpy(Strp, valp->GetCharString(buf), Len);
else else
Reset(); Reset();
} // endif valp
return false; return false;
} // end of SetValue_pval } // end of SetValue_pval
...@@ -2063,18 +2069,21 @@ double BINVAL::GetFloatValue(void) ...@@ -2063,18 +2069,21 @@ double BINVAL::GetFloatValue(void)
/***********************************************************************/ /***********************************************************************/
bool BINVAL::SetValue_pval(PVAL valp, bool chktype) bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
{ {
if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen))
return true;
bool rc = false; bool rc = false;
if (!(Null = valp->IsNull() && Nullable)) { if (valp != this) {
if ((rc = (Len = valp->GetSize()) > Clen)) if (chktype && (valp->GetType() != Type || valp->GetSize() > Clen))
Len = Clen; return true;
memcpy(Binp, valp->GetTo_Val(), Len); if (!(Null = valp->IsNull() && Nullable)) {
} else if ((rc = (Len = valp->GetSize()) > Clen))
Reset(); Len = Clen;
memcpy(Binp, valp->GetTo_Val(), Len);
} else
Reset();
} // endif valp
return rc; return rc;
} // end of SetValue_pval } // end of SetValue_pval
...@@ -2629,21 +2638,24 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) ...@@ -2629,21 +2638,24 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval)
/***********************************************************************/ /***********************************************************************/
bool DTVAL::SetValue_pval(PVAL valp, bool chktype) bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
{ {
if (chktype && Type != valp->GetType()) if (valp != this) {
return true; if (chktype && Type != valp->GetType())
return true;
if (!(Null = valp->IsNull() && Nullable)) { if (!(Null = valp->IsNull() && Nullable)) {
if (Pdtp && !valp->IsTypeNum()) { if (Pdtp && !valp->IsTypeNum()) {
int ndv; int ndv;
int dval[6]; 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 } else
Tval = valp->GetIntValue(); Reset();
} else } // endif valp
Reset();
return false; return false;
} // end of SetValue } // end of SetValue
......
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