@@ -703,7 +703,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
703
703
HA_CREATE_INFO *create_info)
704
704
{
705
705
int error;
706
- char name_buff[FN_REFLEN], name_lc_buff[FN_REFLEN];
706
+ char name_buff[FN_REFLEN + 1 ], name_lc_buff[FN_REFLEN + 1 ];
707
707
char *name_buffer_ptr;
708
708
const char *path;
709
709
uint i;
@@ -745,8 +745,10 @@ int ha_partition::create(const char *name, TABLE *table_arg,
745
745
for (j= 0 ; j < m_part_info->num_subparts ; j++)
746
746
{
747
747
part_elem= sub_it++;
748
- create_partition_name (name_buff, path, name_buffer_ptr,
749
- NORMAL_PART_NAME, FALSE );
748
+ if ((error= create_partition_name (name_buff, path, name_buffer_ptr,
749
+ NORMAL_PART_NAME, FALSE )))
750
+ goto create_error;
751
+
750
752
if ((error= set_up_table_before_create (table_arg, name_buff,
751
753
create_info, part_elem)) ||
752
754
((error= (*file)->ha_create (name_buff, table_arg, create_info))))
@@ -758,8 +760,10 @@ int ha_partition::create(const char *name, TABLE *table_arg,
758
760
}
759
761
else
760
762
{
761
- create_partition_name (name_buff, path, name_buffer_ptr,
762
- NORMAL_PART_NAME, FALSE );
763
+ if ((create_partition_name (name_buff, path, name_buffer_ptr,
764
+ NORMAL_PART_NAME, FALSE )))
765
+ goto create_error;
766
+
763
767
if ((error= set_up_table_before_create (table_arg, name_buff,
764
768
create_info, part_elem)) ||
765
769
((error= (*file)->ha_create (name_buff, table_arg, create_info))))
@@ -775,9 +779,9 @@ int ha_partition::create(const char *name, TABLE *table_arg,
775
779
name_buffer_ptr= m_name_buffer_ptr;
776
780
for (abort_file= file, file= m_file; file < abort_file; file++)
777
781
{
778
- create_partition_name (name_buff, path, name_buffer_ptr, NORMAL_PART_NAME,
779
- FALSE );
780
- (void ) (*file)->ha_delete_table ((const char *) name_buff);
782
+ if (! create_partition_name (name_buff, path, name_buffer_ptr, NORMAL_PART_NAME,
783
+ FALSE ))
784
+ (void ) (*file)->ha_delete_table ((const char *) name_buff);
781
785
name_buffer_ptr= strend (name_buffer_ptr) + 1 ;
782
786
}
783
787
handler::delete_table (name);
@@ -804,7 +808,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
804
808
int ha_partition::drop_partitions (const char *path)
805
809
{
806
810
List_iterator<partition_element> part_it (m_part_info->partitions );
807
- char part_name_buff[FN_REFLEN];
811
+ char part_name_buff[FN_REFLEN + 1 ];
808
812
uint num_parts= m_part_info->partitions .elements ;
809
813
uint num_subparts= m_part_info->num_subparts ;
810
814
uint i= 0 ;
@@ -837,9 +841,12 @@ int ha_partition::drop_partitions(const char *path)
837
841
{
838
842
partition_element *sub_elem= sub_it++;
839
843
part= i * num_subparts + j;
840
- create_subpartition_name (part_name_buff, path,
841
- part_elem->partition_name ,
842
- sub_elem->partition_name , name_variant);
844
+ if ((ret_error= create_subpartition_name (part_name_buff, path,
845
+ part_elem->partition_name ,
846
+ sub_elem->partition_name ,
847
+ name_variant)))
848
+ error= ret_error;
849
+
843
850
file= m_file[part];
844
851
DBUG_PRINT (" info" , (" Drop subpartition %s" , part_name_buff));
845
852
if ((ret_error= file->ha_delete_table (part_name_buff)))
@@ -850,9 +857,11 @@ int ha_partition::drop_partitions(const char *path)
850
857
}
851
858
else
852
859
{
853
- create_partition_name (part_name_buff, path,
854
- part_elem->partition_name , name_variant,
855
- TRUE );
860
+ if ((ret_error= create_partition_name (part_name_buff, path,
861
+ part_elem->partition_name ,
862
+ name_variant, TRUE )))
863
+ error= ret_error;
864
+
856
865
file= m_file[i];
857
866
DBUG_PRINT (" info" , (" Drop partition %s" , part_name_buff));
858
867
if ((ret_error= file->ha_delete_table (part_name_buff)))
@@ -937,10 +946,12 @@ int ha_partition::rename_partitions(const char *path)
937
946
{
938
947
sub_elem= sub_it++;
939
948
file= m_reorged_file[part_count++];
940
- create_subpartition_name (norm_name_buff, path,
941
- part_elem->partition_name ,
942
- sub_elem->partition_name ,
943
- NORMAL_PART_NAME);
949
+ if ((ret_error= create_subpartition_name (norm_name_buff, path,
950
+ part_elem->partition_name ,
951
+ sub_elem->partition_name ,
952
+ NORMAL_PART_NAME)))
953
+ error= ret_error;
954
+
944
955
DBUG_PRINT (" info" , (" Delete subpartition %s" , norm_name_buff));
945
956
if ((ret_error= file->ha_delete_table (norm_name_buff)))
946
957
error= ret_error;
@@ -953,9 +964,11 @@ int ha_partition::rename_partitions(const char *path)
953
964
else
954
965
{
955
966
file= m_reorged_file[part_count++];
956
- create_partition_name (norm_name_buff, path,
957
- part_elem->partition_name , NORMAL_PART_NAME,
958
- TRUE );
967
+ if ((ret_error= create_partition_name (norm_name_buff, path,
968
+ part_elem->partition_name ,
969
+ NORMAL_PART_NAME, TRUE )))
970
+ error= ret_error;
971
+
959
972
DBUG_PRINT (" info" , (" Delete partition %s" , norm_name_buff));
960
973
if ((ret_error= file->ha_delete_table (norm_name_buff)))
961
974
error= ret_error;
@@ -1005,10 +1018,12 @@ int ha_partition::rename_partitions(const char *path)
1005
1018
{
1006
1019
sub_elem= sub_it++;
1007
1020
part= i * num_subparts + j;
1008
- create_subpartition_name (norm_name_buff, path,
1009
- part_elem->partition_name ,
1010
- sub_elem->partition_name ,
1011
- NORMAL_PART_NAME);
1021
+ if ((ret_error= create_subpartition_name (norm_name_buff, path,
1022
+ part_elem->partition_name ,
1023
+ sub_elem->partition_name ,
1024
+ NORMAL_PART_NAME)))
1025
+ error= ret_error;
1026
+
1012
1027
if (part_elem->part_state == PART_IS_CHANGED)
1013
1028
{
1014
1029
file= m_reorged_file[part_count++];
@@ -1020,10 +1035,12 @@ int ha_partition::rename_partitions(const char *path)
1020
1035
(void ) sync_ddl_log ();
1021
1036
}
1022
1037
file= m_new_file[part];
1023
- create_subpartition_name (part_name_buff, path,
1024
- part_elem->partition_name ,
1025
- sub_elem->partition_name ,
1026
- TEMP_PART_NAME);
1038
+ if ((ret_error= create_subpartition_name (part_name_buff, path,
1039
+ part_elem->partition_name ,
1040
+ sub_elem->partition_name ,
1041
+ TEMP_PART_NAME)))
1042
+ error= ret_error;
1043
+
1027
1044
DBUG_PRINT (" info" , (" Rename subpartition from %s to %s" ,
1028
1045
part_name_buff, norm_name_buff));
1029
1046
if ((ret_error= file->ha_rename_table (part_name_buff,
@@ -1037,9 +1054,11 @@ int ha_partition::rename_partitions(const char *path)
1037
1054
}
1038
1055
else
1039
1056
{
1040
- create_partition_name (norm_name_buff, path,
1041
- part_elem->partition_name , NORMAL_PART_NAME,
1042
- TRUE );
1057
+ if ((ret_error= create_partition_name (norm_name_buff, path,
1058
+ part_elem->partition_name ,
1059
+ NORMAL_PART_NAME, TRUE )))
1060
+ error= ret_error;
1061
+
1043
1062
if (part_elem->part_state == PART_IS_CHANGED)
1044
1063
{
1045
1064
file= m_reorged_file[part_count++];
@@ -1051,9 +1070,10 @@ int ha_partition::rename_partitions(const char *path)
1051
1070
(void ) sync_ddl_log ();
1052
1071
}
1053
1072
file= m_new_file[i];
1054
- create_partition_name (part_name_buff, path,
1055
- part_elem->partition_name , TEMP_PART_NAME,
1056
- TRUE );
1073
+ if ((error= create_partition_name (part_name_buff, path,
1074
+ part_elem->partition_name ,
1075
+ TEMP_PART_NAME, TRUE )))
1076
+ error= ret_error;
1057
1077
DBUG_PRINT (" info" , (" Rename partition from %s to %s" ,
1058
1078
part_name_buff, norm_name_buff));
1059
1079
if ((ret_error= file->ha_rename_table (part_name_buff,
@@ -1676,7 +1696,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1676
1696
{
1677
1697
List_iterator<partition_element> part_it (m_part_info->partitions );
1678
1698
List_iterator <partition_element> t_it (m_part_info->temp_partitions );
1679
- char part_name_buff[FN_REFLEN];
1699
+ char part_name_buff[FN_REFLEN + 1 ];
1680
1700
uint num_parts= m_part_info->partitions .elements ;
1681
1701
uint num_subparts= m_part_info->num_subparts ;
1682
1702
uint i= 0 ;
@@ -1904,10 +1924,15 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1904
1924
do
1905
1925
{
1906
1926
partition_element *sub_elem= sub_it++;
1907
- create_subpartition_name (part_name_buff, path,
1908
- part_elem->partition_name ,
1909
- sub_elem->partition_name ,
1910
- name_variant);
1927
+ if ((error= create_subpartition_name (part_name_buff, path,
1928
+ part_elem->partition_name ,
1929
+ sub_elem->partition_name ,
1930
+ name_variant)))
1931
+ {
1932
+ cleanup_new_partition (part_count);
1933
+ DBUG_RETURN (error);
1934
+ }
1935
+
1911
1936
part= i * num_subparts + j;
1912
1937
DBUG_PRINT (" info" , (" Add subpartition %s" , part_name_buff));
1913
1938
if ((error= prepare_new_partition (table, create_info,
@@ -1925,9 +1950,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1925
1950
}
1926
1951
else
1927
1952
{
1928
- create_partition_name (part_name_buff, path,
1929
- part_elem->partition_name , name_variant,
1930
- TRUE );
1953
+ if ((error= create_partition_name (part_name_buff, path,
1954
+ part_elem->partition_name ,
1955
+ name_variant, TRUE )))
1956
+ {
1957
+ cleanup_new_partition (part_count);
1958
+ DBUG_RETURN (error);
1959
+ }
1960
+
1931
1961
DBUG_PRINT (" info" , (" Add partition %s" , part_name_buff));
1932
1962
if ((error= prepare_new_partition (table, create_info,
1933
1963
new_file_array[i],
@@ -2296,8 +2326,8 @@ int ha_partition::del_ren_table(const char *from, const char *to)
2296
2326
{
2297
2327
int save_error= 0 ;
2298
2328
int error= HA_ERR_INTERNAL_ERROR;
2299
- char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN],
2300
- to_lc_buff[FN_REFLEN], buff[FN_REFLEN];
2329
+ char from_buff[FN_REFLEN + 1 ], to_buff[FN_REFLEN + 1 ], from_lc_buff[FN_REFLEN + 1 ],
2330
+ to_lc_buff[FN_REFLEN + 1 ], buff[FN_REFLEN + 1 ];
2301
2331
char *name_buffer_ptr;
2302
2332
const char *from_path;
2303
2333
const char *to_path= NULL ;
@@ -2337,13 +2367,16 @@ int ha_partition::del_ren_table(const char *from, const char *to)
2337
2367
i= 0 ;
2338
2368
do
2339
2369
{
2340
- create_partition_name (from_buff, from_path, name_buffer_ptr,
2341
- NORMAL_PART_NAME, FALSE );
2370
+ if ((error= create_partition_name (from_buff, from_path, name_buffer_ptr,
2371
+ NORMAL_PART_NAME, FALSE )))
2372
+ goto rename_error;
2342
2373
2343
2374
if (to != NULL )
2344
2375
{ // Rename branch
2345
- create_partition_name (to_buff, to_path, name_buffer_ptr,
2346
- NORMAL_PART_NAME, FALSE );
2376
+ if ((error= create_partition_name (to_buff, to_path, name_buffer_ptr,
2377
+ NORMAL_PART_NAME, FALSE )))
2378
+ goto rename_error;
2379
+
2347
2380
error= (*file)->ha_rename_table (from_buff, to_buff);
2348
2381
if (error)
2349
2382
goto rename_error;
@@ -2384,12 +2417,12 @@ int ha_partition::del_ren_table(const char *from, const char *to)
2384
2417
for (abort_file= file, file= m_file; file < abort_file; file++)
2385
2418
{
2386
2419
/* Revert the rename, back from 'to' to the original 'from' */
2387
- create_partition_name (from_buff, from_path, name_buffer_ptr,
2388
- NORMAL_PART_NAME, FALSE );
2389
- create_partition_name (to_buff, to_path, name_buffer_ptr,
2390
- NORMAL_PART_NAME, FALSE );
2391
- /* Ignore error here */
2392
- (void ) (*file)->ha_rename_table (to_buff, from_buff);
2420
+ if (! create_partition_name (from_buff, from_path, name_buffer_ptr,
2421
+ NORMAL_PART_NAME, FALSE ))
2422
+ if (! create_partition_name (to_buff, to_path, name_buffer_ptr,
2423
+ NORMAL_PART_NAME, FALSE ))
2424
+ /* Ignore error here */
2425
+ (void ) (*file)->ha_rename_table (to_buff, from_buff);
2393
2426
name_buffer_ptr= strend (name_buffer_ptr) + 1 ;
2394
2427
}
2395
2428
DBUG_RETURN (error);
@@ -3266,7 +3299,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
3266
3299
char *name_buffer_ptr;
3267
3300
int error= HA_ERR_INITIALIZATION;
3268
3301
handler **file;
3269
- char name_buff[FN_REFLEN];
3302
+ char name_buff[FN_REFLEN + 1 ];
3270
3303
ulonglong check_table_flags;
3271
3304
DBUG_ENTER (" ha_partition::open" );
3272
3305
@@ -3320,8 +3353,13 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
3320
3353
file= m_is_clone_of->m_file ;
3321
3354
for (i= 0 ; i < m_tot_parts; i++)
3322
3355
{
3323
- create_partition_name (name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
3324
- FALSE );
3356
+ if ((error= create_partition_name (name_buff, name, name_buffer_ptr,
3357
+ NORMAL_PART_NAME, FALSE )))
3358
+ {
3359
+ file= &m_file[i];
3360
+ goto err_handler;
3361
+ }
3362
+
3325
3363
/* ::clone() will also set ha_share from the original. */
3326
3364
if (!(m_file[i]= file[i]->clone (name_buff, m_clone_mem_root)))
3327
3365
{
@@ -3337,8 +3375,10 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
3337
3375
file= m_file;
3338
3376
do
3339
3377
{
3340
- create_partition_name (name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
3341
- FALSE );
3378
+ if ((error= create_partition_name (name_buff, name, name_buffer_ptr,
3379
+ NORMAL_PART_NAME, FALSE )))
3380
+ goto err_handler;
3381
+
3342
3382
if ((error= (*file)->ha_open (table, name_buff, mode,
3343
3383
test_if_locked | HA_OPEN_NO_PSI_CALL)))
3344
3384
goto err_handler;
0 commit comments