diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-07-16 19:09:54 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-07-16 19:09:54 +0200 |
commit | 005c7e54214546584c8dc67a746e215f8dbe4b58 (patch) | |
tree | dea50cd7b32808413e058d43d20cf230d1cc7477 /sql/sql_table.cc | |
parent | b9f220b45afaae9b61af29129a8c8ec5f9a7759b (diff) | |
parent | 4f5c10e6b565bc2761b9d083e25c6a36141552a0 (diff) | |
download | mariadb-git-005c7e54214546584c8dc67a746e215f8dbe4b58.tar.gz |
mysql-5.5.32 merge
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 47b1627f8e4..9d0b7b709c9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -198,7 +198,6 @@ uint explain_filename(THD* thd, uint to_length, enum_explain_filename_mode explain_mode) { - uint res= 0; char *to_p= to; char *end_p= to_p + to_length; const char *db_name= NULL; @@ -209,7 +208,8 @@ uint explain_filename(THD* thd, int part_name_len= 0; const char *subpart_name= NULL; int subpart_name_len= 0; - uint name_variant= NORMAL_PART_NAME; + uint part_type= NORMAL_PART_NAME; + const char *tmp_p; DBUG_ENTER("explain_filename"); DBUG_PRINT("enter", ("from '%s'", from)); @@ -228,17 +228,18 @@ uint explain_filename(THD* thd, table_name= tmp_p; } tmp_p= table_name; - while (!res && (tmp_p= strchr(tmp_p, '#'))) + /* Look if there are partition tokens in the table name. */ + while ((tmp_p= strchr(tmp_p, '#'))) { tmp_p++; switch (tmp_p[0]) { case 'P': case 'p': if (tmp_p[1] == '#') + { part_name= tmp_p + 2; - else - res= 1; - tmp_p+= 2; + tmp_p+= 2; + } break; case 'S': case 's': @@ -248,48 +249,32 @@ uint explain_filename(THD* thd, subpart_name= tmp_p + 3; tmp_p+= 3; } - else if ((tmp_p[1] == 'Q' || tmp_p[1] == 'q') && - (tmp_p[2] == 'L' || tmp_p[2] == 'l') && - tmp_p[3] == '-') - { - tmp_p+= 4; /* sql- prefix found */ - } - else - res= 2; break; case 'T': case 't': if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') && (tmp_p[2] == 'P' || tmp_p[2] == 'p') && tmp_p[3] == '#' && !tmp_p[4]) - name_variant= TEMP_PART_NAME; - else - res= 3; - tmp_p+= 4; + { + part_type= TEMP_PART_NAME; + tmp_p+= 4; + } break; case 'R': case 'r': if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') && (tmp_p[2] == 'N' || tmp_p[2] == 'n') && tmp_p[3] == '#' && !tmp_p[4]) - name_variant= RENAMED_PART_NAME; - else - res= 4; - tmp_p+= 4; + { + part_type= RENAMED_PART_NAME; + tmp_p+= 4; + } break; default: - res= 5; + /* Not partition name part. */ + ; } } - if (res) - { - /* Better to give something back if we fail parsing, than nothing at all */ - DBUG_PRINT("info", ("Error in explain_filename: %u", res)); - sql_print_warning("Invalid (old?) table or database name '%s'", from); - DBUG_RETURN(my_snprintf(to, to_length, - "<result %u when explaining filename '%s'>", - res, from)); - } if (part_name) { table_name_len= part_name - table_name - 3; @@ -297,7 +282,7 @@ uint explain_filename(THD* thd, subpart_name_len= strlen(subpart_name); else part_name_len= strlen(part_name); - if (name_variant != NORMAL_PART_NAME) + if (part_type != NORMAL_PART_NAME) { if (subpart_name) subpart_name_len-= 5; @@ -339,9 +324,9 @@ uint explain_filename(THD* thd, to_p= strnmov(to_p, " ", end_p - to_p); else to_p= strnmov(to_p, ", ", end_p - to_p); - if (name_variant != NORMAL_PART_NAME) + if (part_type != NORMAL_PART_NAME) { - if (name_variant == TEMP_PART_NAME) + if (part_type == TEMP_PART_NAME) to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME), end_p - to_p); else |