MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / rename_in_schema_file

Function rename_in_schema_file

sql/parse_file.cc:206–232  ·  view source on GitHub ↗

Renames a frm file (including backups) in same schema. @thd thread handler @param schema name of given schema @param old_name original file name @param new_db new schema @param new_name new file name @retval 0 OK @retval 1 Error (only if renaming of frm failed) */

Source from the content-addressed store, hash-verified

204 1 Error (only if renaming of frm failed)
205*/
206my_bool rename_in_schema_file(THD *thd,
207 const char *schema, const char *old_name,
208 const char *new_db, const char *new_name)
209{
210 char old_path[FN_REFLEN + 1], new_path[FN_REFLEN + 1], arc_path[FN_REFLEN + 1];
211
212 build_table_filename(old_path, sizeof(old_path) - 1,
213 schema, old_name, reg_ext, 0);
214 build_table_filename(new_path, sizeof(new_path) - 1,
215 new_db, new_name, reg_ext, 0);
216
217 if (mysql_file_rename(key_file_frm, old_path, new_path, MYF(MY_WME)))
218 return 1;
219
220 /* check if arc_dir exists: disabled unused feature (see bug #17823). */
221 build_table_filename(arc_path, sizeof(arc_path) - 1, schema, "arc", "", 0);
222
223 { // remove obsolete 'arc' directory and files if any
224 MY_DIR *new_dirp;
225 if ((new_dirp = my_dir(arc_path, MYF(MY_DONT_SORT))))
226 {
227 DBUG_PRINT("my",("Archive subdir found: %s", arc_path));
228 (void) mysql_rm_arc_files(thd, new_dirp, arc_path);
229 }
230 }
231 return 0;
232}
233
234/**
235 Prepare frm to parse (read to memory).

Callers

nothing calls this directly

Calls 2

my_dirFunction · 0.85
build_table_filenameFunction · 0.70

Tested by

no test coverage detected