Commit 1c5c2c6d authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix a few test in TYPVAL<PSZ> that cause Valgrind warnings

modified:
  storage/connect/value.cpp

- Ignore column comment field in TabColumns because its pointer is flagged
  as invalid by Valgrind (this is a bypass but not a real fix)

modified:
  storage/connect/tabutil.cpp
  storage/connect/value.cpp
parent 31941439
...@@ -226,8 +226,12 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, ...@@ -226,8 +226,12 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
crp->Kdata->SetValue((fp->null_ptr != 0) ? 1 : 0, i); crp->Kdata->SetValue((fp->null_ptr != 0) ? 1 : 0, i);
crp = crp->Next; // Remark crp = crp->Next; // Remark
fld = fp->comment.str;
crp->Kdata->SetValue(fld, fp->comment.length, i); // For Valgrind until bug on comment storage is fixed
// if (fp->comment.length > 0 && (fld = fp->comment.str))
// crp->Kdata->SetValue(fld, fp->comment.length, i);
// else
crp->Kdata->Reset(i);
crp = crp->Next; // New crp = crp->Next; // New
crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i); crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i);
......
...@@ -871,12 +871,16 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING) ...@@ -871,12 +871,16 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING)
TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c) TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c)
: VALUE(TYPE_STRING) : VALUE(TYPE_STRING)
{ {
assert(Type == TYPE_STRING && (g || s)); assert(Type == TYPE_STRING);
Len = (g) ? n : strlen(s); Len = (g) ? n : strlen(s);
if (g && !s) { if (!s) {
if (g) {
Strp = (char *)PlugSubAlloc(g, NULL, Len + 1); Strp = (char *)PlugSubAlloc(g, NULL, Len + 1);
Strp[Len] = '\0'; Strp[Len] = '\0';
} else
assert(false);
} else } else
Strp = s; Strp = s;
...@@ -908,16 +912,22 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) ...@@ -908,16 +912,22 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
void TYPVAL<PSZ>::SetValue_char(char *p, int n) void TYPVAL<PSZ>::SetValue_char(char *p, int n)
{ {
if (p) { if (p) {
n = min(n, Len); if ((n = min(n, Len))) {
strncpy(Strp, p, n); strncpy(Strp, p, n);
for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ; // for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
for (p = Strp + n - 1; p >= Strp; p--)
if (*p && *p != ' ')
break;
*(++p) = '\0'; *(++p) = '\0';
if (trace > 1) if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp); htrc(" Setting string to: '%s'\n", Strp);
} else
Reset();
Null = false; Null = false;
} else { } else {
Reset(); Reset();
......
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