Skip to content

Commit 163478d

Browse files
committed
cleanup: InnoDB: is_partition()
1 parent 4aab058 commit 163478d

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,26 @@ void set_my_errno(int err)
281281
errno = err;
282282
}
283283

284+
285+
/** Checks whether the file name belongs to a partition of a table.
286+
@param[in] file_name file name
287+
@return pointer to the end of the table name part of the file name, or NULL */
288+
static
289+
char*
290+
is_partition(
291+
/*=========*/
292+
char* file_name)
293+
{
294+
/* We look for pattern #P# to see if the table is partitioned
295+
MariaDB table. */
296+
#ifdef _WIN32
297+
return strstr(file_name, "#p#");
298+
#else
299+
return strstr(file_name, "#P#");
300+
#endif /* _WIN32 */
301+
}
302+
303+
284304
/** Return the InnoDB ROW_FORMAT enum value
285305
@param[in] row_format row_format from "innodb_default_row_format"
286306
@return InnoDB ROW_FORMAT value from rec_format_t enum. */
@@ -6715,7 +6735,6 @@ ha_innobase::open(
67156735
dict_table_t* ib_table;
67166736
char norm_name[FN_REFLEN];
67176737
THD* thd;
6718-
char* is_part = NULL;
67196738
dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE;
67206739

67216740
DBUG_ENTER("ha_innobase::open");
@@ -6745,13 +6764,7 @@ ha_innobase::open(
67456764
m_upd_buf = NULL;
67466765
m_upd_buf_size = 0;
67476766

6748-
/* We look for pattern #P# to see if the table is partitioned
6749-
MySQL table. */
6750-
#ifdef _WIN32
6751-
is_part = strstr(norm_name, "#p#");
6752-
#else
6753-
is_part = strstr(norm_name, "#P#");
6754-
#endif /* _WIN32 */
6767+
char* is_part = is_partition(norm_name);
67556768

67566769
/* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
67576770
can be opened even if some FK indexes are missing. If not, the table
@@ -14546,12 +14559,7 @@ ha_innobase::delete_table(
1454614559

1454714560
if (err == DB_TABLE_NOT_FOUND
1454814561
&& innobase_get_lower_case_table_names() == 1) {
14549-
char* is_part = NULL;
14550-
#ifdef __WIN__
14551-
is_part = strstr(norm_name, "#p#");
14552-
#else
14553-
is_part = strstr(norm_name, "#P#");
14554-
#endif /* __WIN__ */
14562+
char* is_part = is_partition(norm_name);
1455514563

1455614564
if (is_part) {
1455714565
char par_case_name[FN_REFLEN];
@@ -14616,11 +14624,7 @@ ha_innobase::delete_table(
1461614624
native innodb partitioning is completed */
1461714625
if (err == DB_TABLE_NOT_FOUND
1461814626
&& innobase_get_lower_case_table_names() == 1) {
14619-
#ifdef _WIN32
14620-
char* is_part = strstr(norm_name, "#p#");
14621-
#else
14622-
char* is_part = strstr(norm_name, "#P#");
14623-
#endif /* _WIN32 */
14627+
char* is_part = is_partition(norm_name);
1462414628

1462514629
if (is_part != NULL) {
1462614630
char par_case_name[FN_REFLEN];
@@ -15213,12 +15217,7 @@ innobase_rename_table(
1521315217
if (error != DB_SUCCESS) {
1521415218
if (error == DB_TABLE_NOT_FOUND
1521515219
&& innobase_get_lower_case_table_names() == 1) {
15216-
char* is_part = NULL;
15217-
#ifdef _WIN32
15218-
is_part = strstr(norm_from, "#p#");
15219-
#else
15220-
is_part = strstr(norm_from, "#P#");
15221-
#endif /* _WIN32 */
15220+
char* is_part = is_partition(norm_from);
1522215221

1522315222
if (is_part) {
1522415223
char par_case_name[FN_REFLEN];
@@ -23526,11 +23525,7 @@ innobase_init_vc_templ(
2352623525

2352723526
/* For partition table, remove the partition name and use the
2352823527
"main" table name to build the template */
23529-
#ifdef _WIN32
23530-
char* is_part = strstr(tbname, "#p#");
23531-
#else
23532-
char* is_part = strstr(tbname, "#P#");
23533-
#endif /* _WIN32 */
23528+
char* is_part = is_partition(tbname);
2353423529

2353523530
if (is_part != NULL) {
2353623531
*is_part = '\0';
@@ -23581,11 +23576,7 @@ innobase_rename_vc_templ(
2358123576

2358223577
/* For partition table, remove the partition name and use the
2358323578
"main" table name to build the template */
23584-
#ifdef _WIN32
23585-
char* is_part = strstr(tbname, "#p#");
23586-
#else
23587-
char* is_part = strstr(tbname, "#P#");
23588-
#endif /* _WIN32 */
23579+
char* is_part = is_partition(tbname);
2358923580

2359023581
if (is_part != NULL) {
2359123582
*is_part = '\0';

0 commit comments

Comments
 (0)