Commit 163478db authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: InnoDB: is_partition()

parent 4aab0588
...@@ -281,6 +281,26 @@ void set_my_errno(int err) ...@@ -281,6 +281,26 @@ void set_my_errno(int err)
errno = err; errno = err;
} }
/** Checks whether the file name belongs to a partition of a table.
@param[in] file_name file name
@return pointer to the end of the table name part of the file name, or NULL */
static
char*
is_partition(
/*=========*/
char* file_name)
{
/* We look for pattern #P# to see if the table is partitioned
MariaDB table. */
#ifdef _WIN32
return strstr(file_name, "#p#");
#else
return strstr(file_name, "#P#");
#endif /* _WIN32 */
}
/** Return the InnoDB ROW_FORMAT enum value /** Return the InnoDB ROW_FORMAT enum value
@param[in] row_format row_format from "innodb_default_row_format" @param[in] row_format row_format from "innodb_default_row_format"
@return InnoDB ROW_FORMAT value from rec_format_t enum. */ @return InnoDB ROW_FORMAT value from rec_format_t enum. */
...@@ -6715,7 +6735,6 @@ ha_innobase::open( ...@@ -6715,7 +6735,6 @@ ha_innobase::open(
dict_table_t* ib_table; dict_table_t* ib_table;
char norm_name[FN_REFLEN]; char norm_name[FN_REFLEN];
THD* thd; THD* thd;
char* is_part = NULL;
dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE; dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE;
DBUG_ENTER("ha_innobase::open"); DBUG_ENTER("ha_innobase::open");
...@@ -6745,13 +6764,7 @@ ha_innobase::open( ...@@ -6745,13 +6764,7 @@ ha_innobase::open(
m_upd_buf = NULL; m_upd_buf = NULL;
m_upd_buf_size = 0; m_upd_buf_size = 0;
/* We look for pattern #P# to see if the table is partitioned char* is_part = is_partition(norm_name);
MySQL table. */
#ifdef _WIN32
is_part = strstr(norm_name, "#p#");
#else
is_part = strstr(norm_name, "#P#");
#endif /* _WIN32 */
/* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table /* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
can be opened even if some FK indexes are missing. If not, the table can be opened even if some FK indexes are missing. If not, the table
...@@ -14546,12 +14559,7 @@ ha_innobase::delete_table( ...@@ -14546,12 +14559,7 @@ ha_innobase::delete_table(
if (err == DB_TABLE_NOT_FOUND if (err == DB_TABLE_NOT_FOUND
&& innobase_get_lower_case_table_names() == 1) { && innobase_get_lower_case_table_names() == 1) {
char* is_part = NULL; char* is_part = is_partition(norm_name);
#ifdef __WIN__
is_part = strstr(norm_name, "#p#");
#else
is_part = strstr(norm_name, "#P#");
#endif /* __WIN__ */
if (is_part) { if (is_part) {
char par_case_name[FN_REFLEN]; char par_case_name[FN_REFLEN];
...@@ -14616,11 +14624,7 @@ ha_innobase::delete_table( ...@@ -14616,11 +14624,7 @@ ha_innobase::delete_table(
native innodb partitioning is completed */ native innodb partitioning is completed */
if (err == DB_TABLE_NOT_FOUND if (err == DB_TABLE_NOT_FOUND
&& innobase_get_lower_case_table_names() == 1) { && innobase_get_lower_case_table_names() == 1) {
#ifdef _WIN32 char* is_part = is_partition(norm_name);
char* is_part = strstr(norm_name, "#p#");
#else
char* is_part = strstr(norm_name, "#P#");
#endif /* _WIN32 */
if (is_part != NULL) { if (is_part != NULL) {
char par_case_name[FN_REFLEN]; char par_case_name[FN_REFLEN];
...@@ -15213,12 +15217,7 @@ innobase_rename_table( ...@@ -15213,12 +15217,7 @@ innobase_rename_table(
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
if (error == DB_TABLE_NOT_FOUND if (error == DB_TABLE_NOT_FOUND
&& innobase_get_lower_case_table_names() == 1) { && innobase_get_lower_case_table_names() == 1) {
char* is_part = NULL; char* is_part = is_partition(norm_from);
#ifdef _WIN32
is_part = strstr(norm_from, "#p#");
#else
is_part = strstr(norm_from, "#P#");
#endif /* _WIN32 */
if (is_part) { if (is_part) {
char par_case_name[FN_REFLEN]; char par_case_name[FN_REFLEN];
...@@ -23526,11 +23525,7 @@ innobase_init_vc_templ( ...@@ -23526,11 +23525,7 @@ innobase_init_vc_templ(
/* For partition table, remove the partition name and use the /* For partition table, remove the partition name and use the
"main" table name to build the template */ "main" table name to build the template */
#ifdef _WIN32 char* is_part = is_partition(tbname);
char* is_part = strstr(tbname, "#p#");
#else
char* is_part = strstr(tbname, "#P#");
#endif /* _WIN32 */
if (is_part != NULL) { if (is_part != NULL) {
*is_part = '\0'; *is_part = '\0';
...@@ -23581,11 +23576,7 @@ innobase_rename_vc_templ( ...@@ -23581,11 +23576,7 @@ innobase_rename_vc_templ(
/* For partition table, remove the partition name and use the /* For partition table, remove the partition name and use the
"main" table name to build the template */ "main" table name to build the template */
#ifdef _WIN32 char* is_part = is_partition(tbname);
char* is_part = strstr(tbname, "#p#");
#else
char* is_part = strstr(tbname, "#P#");
#endif /* _WIN32 */
if (is_part != NULL) { if (is_part != NULL) {
*is_part = '\0'; *is_part = '\0';
......
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