@@ -114,7 +114,6 @@ namespace
114114
115115 bool start_copy_dml_safe () noexcept
116116 {
117- ddl_locked= true ;
118117 if (scan_dbdirs ())
119118 return true ;
120119 flatten_table_lists ();
@@ -129,13 +128,49 @@ namespace
129128 return false ;
130129 }
131130
132- int step () noexcept
131+ int dml_safe_copy_step () noexcept
133132 {
134- if (!ddl_locked )
133+ if (dml_safe_tables_copied == dml_safe_table_list. size () )
135134 return 0 ;
136- return unsafe_copy_phase?
137- unsafe_copy_step ():
138- dml_safe_copy_step ();
135+ const table_ref& table = dml_safe_table_list[dml_safe_tables_copied];
136+ if (copy_table (table) != 0 )
137+ return -1 ;
138+ ++dml_safe_tables_copied;
139+ return dml_safe_table_list.size () - dml_safe_tables_copied;
140+ }
141+
142+ int unsafe_copy_step () noexcept
143+ {
144+ if (have_control_file)
145+ {
146+ if (copy_control_file () != 0 )
147+ return -1 ;
148+ have_control_file = false ;
149+ }
150+ else if (log_files_copied < log_files.size ())
151+ {
152+ if (copy_file (log_files[log_files_copied]) != 0 )
153+ return -1 ;
154+ ++log_files_copied;
155+ }
156+ else if (unsafe_tables_copied < unsafe_tables_list.size ())
157+ {
158+ const table_ref& table = unsafe_tables_list[unsafe_tables_copied];
159+ if (copy_table (table) != 0 )
160+ return -1 ;
161+ ++unsafe_tables_copied;
162+ }
163+ else if (misc_files_copied < misc_files.size ())
164+ {
165+ if (copy_file (misc_files[misc_files_copied]) != 0 )
166+ return -1 ;
167+ ++misc_files_copied;
168+ }
169+ assert (!have_control_file);
170+ return
171+ log_files.size () - log_files_copied +
172+ unsafe_tables_list.size () - unsafe_tables_copied +
173+ misc_files.size () - misc_files_copied;
139174 }
140175
141176 int end (bool /* abort*/ ) noexcept
@@ -186,7 +221,6 @@ namespace
186221 size_t unsafe_tables_copied= 0 ;
187222 size_t log_files_copied= 0 ;
188223 size_t misc_files_copied= 0 ;
189- bool ddl_locked= false ;
190224 bool unsafe_copy_phase = false ;
191225
192226 int scan_dbdirs () noexcept
@@ -382,51 +416,6 @@ namespace
382416 return result;
383417 }
384418
385- int dml_safe_copy_step () noexcept
386- {
387- if (dml_safe_tables_copied == dml_safe_table_list.size ())
388- return 0 ;
389- const table_ref& table = dml_safe_table_list[dml_safe_tables_copied];
390- if (copy_table (table) != 0 )
391- return -1 ;
392- ++dml_safe_tables_copied;
393- return dml_safe_table_list.size () - dml_safe_tables_copied;
394- }
395-
396- int unsafe_copy_step () noexcept
397- {
398- if (have_control_file)
399- {
400- if (copy_control_file () != 0 )
401- return -1 ;
402- have_control_file = false ;
403- }
404- else if (log_files_copied < log_files.size ())
405- {
406- if (copy_file (log_files[log_files_copied]) != 0 )
407- return -1 ;
408- ++log_files_copied;
409- }
410- else if (unsafe_tables_copied < unsafe_tables_list.size ())
411- {
412- const table_ref& table = unsafe_tables_list[unsafe_tables_copied];
413- if (copy_table (table) != 0 )
414- return -1 ;
415- ++unsafe_tables_copied;
416- }
417- else if (misc_files_copied < misc_files.size ())
418- {
419- if (copy_file (misc_files[misc_files_copied]) != 0 )
420- return -1 ;
421- ++misc_files_copied;
422- }
423- assert (!have_control_file);
424- return
425- log_files.size () - log_files_copied +
426- unsafe_tables_list.size () - unsafe_tables_copied +
427- misc_files.size () - misc_files_copied;
428- }
429-
430419 int copy_table (const table_ref& table) noexcept
431420 {
432421 dir_ref dir_name = table.first ;
@@ -567,9 +556,17 @@ int aria_backup_start_proc_phase(THD *thd, backup_proc_phase phase) noexcept
567556 }
568557}
569558
570- int aria_backup_step (THD *thd) noexcept
559+ int aria_backup_step (THD *thd, backup_proc_phase phase ) noexcept
571560{
572- return aria_backup->step ();
561+ switch (phase)
562+ {
563+ case BACKUP_PROC_PHASE_DDL_LOCKED :
564+ return aria_backup->dml_safe_copy_step ();
565+ case BACKUP_PROC_PHASE_COMMIT_LOCKED :
566+ return aria_backup->unsafe_copy_step ();
567+ default :
568+ return 0 ;
569+ }
573570}
574571
575572int aria_backup_end (THD *thd, backup_end_phase phase, bool abort) noexcept
0 commit comments