Commit ecc03af9 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-364 Server crashes in add_identifier on concurrent ALTER TABLE and SHOW ENGINE INNODB STATUS

fix add_identifier() to distinguish between temporary tables (#sql- prefix) and temporary partitions (#TMP# suffix).
change add_identifier() to use the same name variant constants as sql_partition.cc does.
parent 9ed96f5f
...@@ -163,6 +163,13 @@ static char* add_identifier(THD* thd, char *to_p, const char * end_p, ...@@ -163,6 +163,13 @@ static char* add_identifier(THD* thd, char *to_p, const char * end_p,
diagnostic, error etc. when it would be useful to know what a particular diagnostic, error etc. when it would be useful to know what a particular
file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc. file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc.
Examples:
t1#P#p1 table t1 partition p1
t1#P#p1#SP#sp1 table t1 partition p1 subpartition sp1
t1#P#p1#SP#sp1#TMP# table t1 partition p1 subpartition sp1 temporary
t1#P#p1#SP#sp1#REN# table t1 partition p1 subpartition sp1 renamed
@param thd Thread handle @param thd Thread handle
@param from Path name in my_charset_filename @param from Path name in my_charset_filename
Null terminated in my_charset_filename, normalized Null terminated in my_charset_filename, normalized
...@@ -201,7 +208,7 @@ uint explain_filename(THD* thd, ...@@ -201,7 +208,7 @@ uint explain_filename(THD* thd,
int part_name_len= 0; int part_name_len= 0;
const char *subpart_name= NULL; const char *subpart_name= NULL;
int subpart_name_len= 0; int subpart_name_len= 0;
enum enum_file_name_type {NORMAL, TEMP, RENAMED} name_type= NORMAL; uint name_variant= NORMAL_PART_NAME;
const char *tmp_p; const char *tmp_p;
DBUG_ENTER("explain_filename"); DBUG_ENTER("explain_filename");
DBUG_PRINT("enter", ("from '%s'", from)); DBUG_PRINT("enter", ("from '%s'", from));
...@@ -244,7 +251,6 @@ uint explain_filename(THD* thd, ...@@ -244,7 +251,6 @@ uint explain_filename(THD* thd,
(tmp_p[2] == 'L' || tmp_p[2] == 'l') && (tmp_p[2] == 'L' || tmp_p[2] == 'l') &&
tmp_p[3] == '-') tmp_p[3] == '-')
{ {
name_type= TEMP;
tmp_p+= 4; /* sql- prefix found */ tmp_p+= 4; /* sql- prefix found */
} }
else else
...@@ -255,7 +261,7 @@ uint explain_filename(THD* thd, ...@@ -255,7 +261,7 @@ uint explain_filename(THD* thd,
if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') && if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') &&
(tmp_p[2] == 'P' || tmp_p[2] == 'p') && (tmp_p[2] == 'P' || tmp_p[2] == 'p') &&
tmp_p[3] == '#' && !tmp_p[4]) tmp_p[3] == '#' && !tmp_p[4])
name_type= TEMP; name_variant= TEMP_PART_NAME;
else else
res= 3; res= 3;
tmp_p+= 4; tmp_p+= 4;
...@@ -265,7 +271,7 @@ uint explain_filename(THD* thd, ...@@ -265,7 +271,7 @@ uint explain_filename(THD* thd,
if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') && if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') &&
(tmp_p[2] == 'N' || tmp_p[2] == 'n') && (tmp_p[2] == 'N' || tmp_p[2] == 'n') &&
tmp_p[3] == '#' && !tmp_p[4]) tmp_p[3] == '#' && !tmp_p[4])
name_type= RENAMED; name_variant= RENAMED_PART_NAME;
else else
res= 4; res= 4;
tmp_p+= 4; tmp_p+= 4;
...@@ -290,7 +296,7 @@ uint explain_filename(THD* thd, ...@@ -290,7 +296,7 @@ uint explain_filename(THD* thd,
subpart_name_len= strlen(subpart_name); subpart_name_len= strlen(subpart_name);
else else
part_name_len= strlen(part_name); part_name_len= strlen(part_name);
if (name_type != NORMAL) if (name_variant != NORMAL_PART_NAME)
{ {
if (subpart_name) if (subpart_name)
subpart_name_len-= 5; subpart_name_len-= 5;
...@@ -332,9 +338,9 @@ uint explain_filename(THD* thd, ...@@ -332,9 +338,9 @@ uint explain_filename(THD* thd,
to_p= strnmov(to_p, " ", end_p - to_p); to_p= strnmov(to_p, " ", end_p - to_p);
else else
to_p= strnmov(to_p, ", ", end_p - to_p); to_p= strnmov(to_p, ", ", end_p - to_p);
if (name_type != NORMAL) if (name_variant != NORMAL_PART_NAME)
{ {
if (name_type == TEMP) if (name_variant == TEMP_PART_NAME)
to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME), to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME),
end_p - to_p); end_p - to_p);
else else
......
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