@@ -281,6 +281,26 @@ void set_my_errno(int err)
281
281
errno = err;
282
282
}
283
283
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
+
284
304
/** Return the InnoDB ROW_FORMAT enum value
285
305
@param[in] row_format row_format from "innodb_default_row_format"
286
306
@return InnoDB ROW_FORMAT value from rec_format_t enum. */
@@ -6715,7 +6735,6 @@ ha_innobase::open(
6715
6735
dict_table_t* ib_table;
6716
6736
char norm_name[FN_REFLEN];
6717
6737
THD* thd;
6718
- char* is_part = NULL;
6719
6738
dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE;
6720
6739
6721
6740
DBUG_ENTER("ha_innobase::open");
@@ -6745,13 +6764,7 @@ ha_innobase::open(
6745
6764
m_upd_buf = NULL;
6746
6765
m_upd_buf_size = 0;
6747
6766
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);
6755
6768
6756
6769
/* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
6757
6770
can be opened even if some FK indexes are missing. If not, the table
@@ -14546,12 +14559,7 @@ ha_innobase::delete_table(
14546
14559
14547
14560
if (err == DB_TABLE_NOT_FOUND
14548
14561
&& 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);
14555
14563
14556
14564
if (is_part) {
14557
14565
char par_case_name[FN_REFLEN];
@@ -14616,11 +14624,7 @@ ha_innobase::delete_table(
14616
14624
native innodb partitioning is completed */
14617
14625
if (err == DB_TABLE_NOT_FOUND
14618
14626
&& 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);
14624
14628
14625
14629
if (is_part != NULL) {
14626
14630
char par_case_name[FN_REFLEN];
@@ -15213,12 +15217,7 @@ innobase_rename_table(
15213
15217
if (error != DB_SUCCESS) {
15214
15218
if (error == DB_TABLE_NOT_FOUND
15215
15219
&& 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);
15222
15221
15223
15222
if (is_part) {
15224
15223
char par_case_name[FN_REFLEN];
@@ -23526,11 +23525,7 @@ innobase_init_vc_templ(
23526
23525
23527
23526
/* For partition table, remove the partition name and use the
23528
23527
"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);
23534
23529
23535
23530
if (is_part != NULL) {
23536
23531
*is_part = '\0';
@@ -23581,11 +23576,7 @@ innobase_rename_vc_templ(
23581
23576
23582
23577
/* For partition table, remove the partition name and use the
23583
23578
"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);
23589
23580
23590
23581
if (is_part != NULL) {
23591
23582
*is_part = '\0';
0 commit comments