1
1
/*
2
- Copyright (c) 2005, 2013 , Oracle and/or its affiliates. All rights reserved.
2
+ Copyright (c) 2005, 2017 , Oracle and/or its affiliates. All rights reserved.
3
3
4
4
This program is free software; you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License as published by
@@ -624,7 +624,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
624
624
int ha_partition::drop_partitions (const char *path)
625
625
{
626
626
List_iterator<partition_element> part_it (m_part_info->partitions );
627
- char part_name_buff[FN_REFLEN];
627
+ char part_name_buff[FN_REFLEN + 1 ];
628
628
uint num_parts= m_part_info->partitions .elements ;
629
629
uint num_subparts= m_part_info->num_subparts ;
630
630
uint i= 0 ;
@@ -657,9 +657,12 @@ int ha_partition::drop_partitions(const char *path)
657
657
{
658
658
partition_element *sub_elem= sub_it++;
659
659
part= i * num_subparts + j;
660
- create_subpartition_name (part_name_buff, path,
661
- part_elem->partition_name ,
662
- sub_elem->partition_name , name_variant);
660
+ if ((ret_error= create_subpartition_name (part_name_buff, path,
661
+ part_elem->partition_name ,
662
+ sub_elem->partition_name ,
663
+ name_variant)))
664
+ error= ret_error;
665
+
663
666
file= m_file[part];
664
667
DBUG_PRINT (" info" , (" Drop subpartition %s" , part_name_buff));
665
668
if ((ret_error= file->ha_delete_table (part_name_buff)))
@@ -670,9 +673,11 @@ int ha_partition::drop_partitions(const char *path)
670
673
}
671
674
else
672
675
{
673
- create_partition_name (part_name_buff, path,
674
- part_elem->partition_name , name_variant,
675
- TRUE );
676
+ if ((ret_error= create_partition_name (part_name_buff, path,
677
+ part_elem->partition_name ,
678
+ name_variant, TRUE )))
679
+ error= ret_error;
680
+
676
681
file= m_file[i];
677
682
DBUG_PRINT (" info" , (" Drop partition %s" , part_name_buff));
678
683
if ((ret_error= file->ha_delete_table (part_name_buff)))
@@ -714,8 +719,8 @@ int ha_partition::rename_partitions(const char *path)
714
719
{
715
720
List_iterator<partition_element> part_it (m_part_info->partitions );
716
721
List_iterator<partition_element> temp_it (m_part_info->temp_partitions );
717
- char part_name_buff[FN_REFLEN];
718
- char norm_name_buff[FN_REFLEN];
722
+ char part_name_buff[FN_REFLEN + 1 ];
723
+ char norm_name_buff[FN_REFLEN + 1 ];
719
724
uint num_parts= m_part_info->partitions .elements ;
720
725
uint part_count= 0 ;
721
726
uint num_subparts= m_part_info->num_subparts ;
@@ -757,10 +762,11 @@ int ha_partition::rename_partitions(const char *path)
757
762
{
758
763
sub_elem= sub_it++;
759
764
file= m_reorged_file[part_count++];
760
- create_subpartition_name (norm_name_buff, path,
761
- part_elem->partition_name ,
762
- sub_elem->partition_name ,
763
- NORMAL_PART_NAME);
765
+ if ((ret_error= create_subpartition_name (norm_name_buff, path,
766
+ part_elem->partition_name ,
767
+ sub_elem->partition_name ,
768
+ NORMAL_PART_NAME)))
769
+ error= ret_error;
764
770
DBUG_PRINT (" info" , (" Delete subpartition %s" , norm_name_buff));
765
771
if ((ret_error= file->ha_delete_table (norm_name_buff)))
766
772
error= ret_error;
@@ -773,9 +779,11 @@ int ha_partition::rename_partitions(const char *path)
773
779
else
774
780
{
775
781
file= m_reorged_file[part_count++];
776
- create_partition_name (norm_name_buff, path,
777
- part_elem->partition_name , NORMAL_PART_NAME,
778
- TRUE );
782
+ if ((ret_error= create_partition_name (norm_name_buff, path,
783
+ part_elem->partition_name ,
784
+ NORMAL_PART_NAME, TRUE )))
785
+ error= ret_error;
786
+
779
787
DBUG_PRINT (" info" , (" Delete partition %s" , norm_name_buff));
780
788
if ((ret_error= file->ha_delete_table (norm_name_buff)))
781
789
error= ret_error;
@@ -825,10 +833,12 @@ int ha_partition::rename_partitions(const char *path)
825
833
{
826
834
sub_elem= sub_it++;
827
835
part= i * num_subparts + j;
828
- create_subpartition_name (norm_name_buff, path,
829
- part_elem->partition_name ,
830
- sub_elem->partition_name ,
831
- NORMAL_PART_NAME);
836
+ if ((ret_error= create_subpartition_name (norm_name_buff, path,
837
+ part_elem->partition_name ,
838
+ sub_elem->partition_name ,
839
+ NORMAL_PART_NAME)))
840
+ error= ret_error;
841
+
832
842
if (part_elem->part_state == PART_IS_CHANGED)
833
843
{
834
844
file= m_reorged_file[part_count++];
@@ -840,10 +850,12 @@ int ha_partition::rename_partitions(const char *path)
840
850
(void ) sync_ddl_log ();
841
851
}
842
852
file= m_new_file[part];
843
- create_subpartition_name (part_name_buff, path,
844
- part_elem->partition_name ,
845
- sub_elem->partition_name ,
846
- TEMP_PART_NAME);
853
+ if ((ret_error= create_subpartition_name (part_name_buff, path,
854
+ part_elem->partition_name ,
855
+ sub_elem->partition_name ,
856
+ TEMP_PART_NAME)))
857
+ error= ret_error;
858
+
847
859
DBUG_PRINT (" info" , (" Rename subpartition from %s to %s" ,
848
860
part_name_buff, norm_name_buff));
849
861
if ((ret_error= file->ha_rename_table (part_name_buff,
@@ -857,9 +869,11 @@ int ha_partition::rename_partitions(const char *path)
857
869
}
858
870
else
859
871
{
860
- create_partition_name (norm_name_buff, path,
861
- part_elem->partition_name , NORMAL_PART_NAME,
862
- TRUE );
872
+ if ((ret_error= create_partition_name (norm_name_buff, path,
873
+ part_elem->partition_name ,
874
+ NORMAL_PART_NAME, TRUE )))
875
+ error= ret_error;
876
+
863
877
if (part_elem->part_state == PART_IS_CHANGED)
864
878
{
865
879
file= m_reorged_file[part_count++];
@@ -871,9 +885,11 @@ int ha_partition::rename_partitions(const char *path)
871
885
(void ) sync_ddl_log ();
872
886
}
873
887
file= m_new_file[i];
874
- create_partition_name (part_name_buff, path,
875
- part_elem->partition_name , TEMP_PART_NAME,
876
- TRUE );
888
+ if ((ret_error= create_partition_name (part_name_buff, path,
889
+ part_elem->partition_name ,
890
+ TEMP_PART_NAME, TRUE )))
891
+ error= ret_error;
892
+
877
893
DBUG_PRINT (" info" , (" Rename partition from %s to %s" ,
878
894
part_name_buff, norm_name_buff));
879
895
if ((ret_error= file->ha_rename_table (part_name_buff,
@@ -1477,7 +1493,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1477
1493
{
1478
1494
List_iterator<partition_element> part_it (m_part_info->partitions );
1479
1495
List_iterator <partition_element> t_it (m_part_info->temp_partitions );
1480
- char part_name_buff[FN_REFLEN];
1496
+ char part_name_buff[FN_REFLEN + 1 ];
1481
1497
uint num_parts= m_part_info->partitions .elements ;
1482
1498
uint num_subparts= m_part_info->num_subparts ;
1483
1499
uint i= 0 ;
@@ -1687,10 +1703,15 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1687
1703
do
1688
1704
{
1689
1705
partition_element *sub_elem= sub_it++;
1690
- create_subpartition_name (part_name_buff, path,
1691
- part_elem->partition_name ,
1692
- sub_elem->partition_name ,
1693
- name_variant);
1706
+ if ((error= create_subpartition_name (part_name_buff, path,
1707
+ part_elem->partition_name ,
1708
+ sub_elem->partition_name ,
1709
+ name_variant)))
1710
+ {
1711
+ cleanup_new_partition (part_count);
1712
+ DBUG_RETURN (error);
1713
+ }
1714
+
1694
1715
part= i * num_subparts + j;
1695
1716
DBUG_PRINT (" info" , (" Add subpartition %s" , part_name_buff));
1696
1717
if ((error= prepare_new_partition (table, create_info,
@@ -1708,9 +1729,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
1708
1729
}
1709
1730
else
1710
1731
{
1711
- create_partition_name (part_name_buff, path,
1712
- part_elem->partition_name , name_variant,
1713
- TRUE );
1732
+ if ((error= create_partition_name (part_name_buff, path,
1733
+ part_elem->partition_name ,
1734
+ name_variant, TRUE )))
1735
+ {
1736
+ cleanup_new_partition (part_count);
1737
+ DBUG_RETURN (error);
1738
+ }
1739
+
1714
1740
DBUG_PRINT (" info" , (" Add partition %s" , part_name_buff));
1715
1741
if ((error= prepare_new_partition (table, create_info,
1716
1742
new_file_array[i],
@@ -1967,8 +1993,8 @@ int ha_partition::del_ren_cre_table(const char *from,
1967
1993
{
1968
1994
int save_error= 0 ;
1969
1995
int error= HA_ERR_INTERNAL_ERROR;
1970
- char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN],
1971
- to_lc_buff[FN_REFLEN], buff[FN_REFLEN];
1996
+ char from_buff[FN_REFLEN + 1 ], to_buff[FN_REFLEN + 1 ], from_lc_buff[FN_REFLEN + 1 ],
1997
+ to_lc_buff[FN_REFLEN + 1 ], buff[FN_REFLEN + 1 ];
1972
1998
char *name_buffer_ptr;
1973
1999
const char *from_path;
1974
2000
const char *to_path= NULL ;
@@ -2015,13 +2041,16 @@ int ha_partition::del_ren_cre_table(const char *from,
2015
2041
i= 0 ;
2016
2042
do
2017
2043
{
2018
- create_partition_name (from_buff, from_path, name_buffer_ptr,
2019
- NORMAL_PART_NAME, FALSE );
2044
+ if ((error= create_partition_name (from_buff, from_path, name_buffer_ptr,
2045
+ NORMAL_PART_NAME, FALSE )))
2046
+ DBUG_RETURN (error);
2020
2047
2021
2048
if (to != NULL )
2022
2049
{ // Rename branch
2023
- create_partition_name (to_buff, to_path, name_buffer_ptr,
2024
- NORMAL_PART_NAME, FALSE );
2050
+ if ((error= create_partition_name (to_buff, to_path, name_buffer_ptr,
2051
+ NORMAL_PART_NAME, FALSE )))
2052
+ DBUG_RETURN (error);
2053
+
2025
2054
error= (*file)->ha_rename_table (from_buff, to_buff);
2026
2055
if (error)
2027
2056
goto rename_error;
@@ -2066,9 +2095,9 @@ int ha_partition::del_ren_cre_table(const char *from,
2066
2095
name_buffer_ptr= m_name_buffer_ptr;
2067
2096
for (abort_file= file, file= m_file; file < abort_file; file++)
2068
2097
{
2069
- create_partition_name (from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME,
2070
- FALSE );
2071
- (void ) (*file)->ha_delete_table ((const char *) from_buff);
2098
+ if (! create_partition_name (from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME,
2099
+ FALSE ))
2100
+ (void ) (*file)->ha_delete_table ((const char *) from_buff);
2072
2101
name_buffer_ptr= strend (name_buffer_ptr) + 1 ;
2073
2102
}
2074
2103
DBUG_RETURN (error);
@@ -2077,12 +2106,12 @@ int ha_partition::del_ren_cre_table(const char *from,
2077
2106
for (abort_file= file, file= m_file; file < abort_file; file++)
2078
2107
{
2079
2108
/* Revert the rename, back from 'to' to the original 'from' */
2080
- create_partition_name (from_buff, from_path, name_buffer_ptr,
2081
- NORMAL_PART_NAME, FALSE );
2082
- create_partition_name (to_buff, to_path, name_buffer_ptr,
2083
- NORMAL_PART_NAME, FALSE );
2084
- /* Ignore error here */
2085
- (void ) (*file)->ha_rename_table (to_buff, from_buff);
2109
+ if (! create_partition_name (from_buff, from_path, name_buffer_ptr,
2110
+ NORMAL_PART_NAME, FALSE ))
2111
+ if (! create_partition_name (to_buff, to_path, name_buffer_ptr,
2112
+ NORMAL_PART_NAME, FALSE ))
2113
+ /* Ignore error here */
2114
+ (void ) (*file)->ha_rename_table (to_buff, from_buff);
2086
2115
name_buffer_ptr= strend (name_buffer_ptr) + 1 ;
2087
2116
}
2088
2117
DBUG_RETURN (error);
@@ -2707,7 +2736,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
2707
2736
char *name_buffer_ptr;
2708
2737
int error= HA_ERR_INITIALIZATION;
2709
2738
handler **file;
2710
- char name_buff[FN_REFLEN];
2739
+ char name_buff[FN_REFLEN + 1 ];
2711
2740
bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
2712
2741
ulonglong check_table_flags;
2713
2742
DBUG_ENTER (" ha_partition::open" );
@@ -2777,8 +2806,10 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
2777
2806
file= m_is_clone_of->m_file ;
2778
2807
for (i= 0 ; i < m_tot_parts; i++)
2779
2808
{
2780
- create_partition_name (name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
2781
- FALSE );
2809
+ if ((error= create_partition_name (name_buff, name, name_buffer_ptr,
2810
+ NORMAL_PART_NAME, FALSE )))
2811
+ goto err_handler;
2812
+
2782
2813
if (!(m_file[i]= file[i]->clone (name_buff, m_clone_mem_root)))
2783
2814
{
2784
2815
error= HA_ERR_INITIALIZATION;
@@ -2793,8 +2824,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
2793
2824
file= m_file;
2794
2825
do
2795
2826
{
2796
- create_partition_name (name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
2797
- FALSE );
2827
+ if ((error= create_partition_name (name_buff, name, name_buffer_ptr,
2828
+ NORMAL_PART_NAME, FALSE )))
2829
+ goto err_handler;
2798
2830
if ((error= (*file)->ha_open (table, name_buff, mode, test_if_locked)))
2799
2831
goto err_handler;
2800
2832
m_num_locks+= (*file)->lock_count ();
0 commit comments