Commit c1efc4a4 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix compile error when copying a string on itself.

  modified:   storage/connect/value.cpp

- Fix compile error of MDEV-9603
  modified:   storage/connect/tabmysql.cpp
parent 66890975
...@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int) ...@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Delayed = !!GetIntCatInfo("Delayed", 0); Delayed = !!GetIntCatInfo("Delayed", 0);
} else { } else {
// MYSQL access from a PROXY table // MYSQL access from a PROXY table
Database = GetStringCatInfo(g, "Database", Schema ? Schema : (PSZ)"*"); Database = GetStringCatInfo(g, "Database", Schema ? Schema : PlugDup(g, "*"));
Isview = GetBoolCatInfo("View", false); Isview = GetBoolCatInfo("View", false);
// We must get other connection parms from the calling table // We must get other connection parms from the calling table
......
...@@ -1344,10 +1344,13 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) ...@@ -1344,10 +1344,13 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::SetValue_char(char *p, int n) bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
{ {
bool rc; bool rc = false;
if (p && n > 0) { if (!p || n == 0) {
rc = n > Len; Reset();
Null = Nullable;
} else if (p != Strp) {
rc = n > Len;
if ((n = MY_MIN(n, Len))) { if ((n = MY_MIN(n, Len))) {
strncpy(Strp, p, n); strncpy(Strp, p, n);
...@@ -1366,10 +1369,6 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) ...@@ -1366,10 +1369,6 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
Reset(); Reset();
Null = false; Null = false;
} else {
rc = false;
Reset();
Null = Nullable;
} // endif p } // endif p
return rc; return rc;
...@@ -1380,12 +1379,12 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) ...@@ -1380,12 +1379,12 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
/***********************************************************************/ /***********************************************************************/
void TYPVAL<PSZ>::SetValue_psz(PSZ s) void TYPVAL<PSZ>::SetValue_psz(PSZ s)
{ {
if (s) { if (!s) {
strncpy(Strp, s, Len); Reset();
Null = Nullable;
} else if (s != Strp) {
strncpy(Strp, s, Len);
Null = false; Null = false;
} else {
Reset();
Null = Nullable;
} // endif s } // endif s
} // end of SetValue_psz } // end of SetValue_psz
...@@ -1643,7 +1642,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -1643,7 +1642,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
assert(np == 1 || np == 2); assert(np == 1 || np == 2);
if (np == 2) if (np == 2)
strncpy(Strp, p[0], Len); SetValue_psz(p[0]);
if ((i = Len - (signed)strlen(Strp)) > 0) if ((i = Len - (signed)strlen(Strp)) > 0)
strncat(Strp, p[np - 1], i); strncat(Strp, p[np - 1], i);
...@@ -1651,11 +1650,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -1651,11 +1650,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
break; break;
case OP_MIN: case OP_MIN:
assert(np == 2); assert(np == 2);
strcpy(Strp, (strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
break; break;
case OP_MAX: case OP_MAX:
assert(np == 2); assert(np == 2);
strcpy(Strp, (strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
break; break;
default: default:
// sprintf(g->Message, MSG(BAD_EXP_OPER), op); // sprintf(g->Message, MSG(BAD_EXP_OPER), op);
......
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