Bug #34646 "replace" utility: "found" members in st_replace and st_replace_found unused
Submitted: 18 Feb 2008 20:38 Modified: 13 Jan 2017 13:31
Reporter: Guilhem Bichot Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1-bk OS:Any
Assigned to: CPU Architecture:Any

[18 Feb 2008 20:38] Guilhem Bichot
Description:
In source file extra/replace.c, those two members seem to only be set, or never be set but tested. It looks mysterious. We should investigate if there is not some hidden magic behind them, and if there is not, remove them

How to repeat:
code review
[19 Feb 2008 12:40] Sveta Smirnova
Thank you for the report.

Please indicate version which you use.

In version 5.1:

typedef struct st_replace {
  my_bool   found;
  struct st_replace *next[256];
} REPLACE;

typedef struct st_replace_found {
  bool found;
  char *replace_string;
  uint to_offset;
  int from_offset;
} REPLACE_STRING;

REPLACE and REPLACE_STRING are used in many places.

Or do you mind these structures are not anonymous?
[19 Feb 2008 12:53] Guilhem Bichot
Tree mysql-5.1 for example. Yes the structs are used but their "found" members seem to not be really used (look at places where they are used: for that, comment out their definitions and see all lines where the compiler complains).
REPLACE_STRING::found is used at
    rep_str[0].found=1;
and
      rep_str[i].found= (my_bool) (!bcmp(pos,"\\^",3) ? 2 : 1);
(so, only written, never read?)
REPLACE::found is used at
    while (!rep_pos->found)
and
    if (!*(from-=rep_str->from_offset) && rep_pos->found != 2)
(so, only read, never written?).
There may be a trick, some memcpy() somewhere, so "=" between structs somewhere,  anything, that's why I asked for investigation and didn't just remove the "found" members.
[13 Jan 2017 13:31] Erlend Dahl
The replace utility has been deprecated in 5.7 and removed in 8.0.