The world's most popular open source database
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define PARSE_FILE_TIMESTAMPLENGTH 19 |
Definition at line 21 of file parse_file.h.
Referenced by File_parser::parse(), and write_parameter().
| enum file_opt_type |
| FILE_OPTIONS_STRING | |
| FILE_OPTIONS_ESTRING | |
| FILE_OPTIONS_ULONGLONG | |
| FILE_OPTIONS_REV | |
| FILE_OPTIONS_TIMESTAMP | |
| FILE_OPTIONS_STRLIST | |
| FILE_OPTIONS_ULLLIST |
Definition at line 23 of file parse_file.h.
00023 { 00024 FILE_OPTIONS_STRING, /* String (LEX_STRING) */ 00025 FILE_OPTIONS_ESTRING, /* Escaped string (LEX_STRING) */ 00026 FILE_OPTIONS_ULONGLONG, /* ulonglong parameter (ulonglong) */ 00027 FILE_OPTIONS_REV, /* Revision version number (ulonglong) */ 00028 FILE_OPTIONS_TIMESTAMP, /* timestamp (LEX_STRING have to be 00029 allocated with length 20 (19+1) */ 00030 FILE_OPTIONS_STRLIST, /* list of escaped strings 00031 (List<LEX_STRING>) */ 00032 FILE_OPTIONS_ULLLIST /* list of ulonglong values 00033 (List<ulonglong>) */ 00034 };
| bool get_file_options_ulllist | ( | char *& | ptr, | |
| char * | end, | |||
| char * | line, | |||
| gptr | base, | |||
| File_option * | parameter, | |||
| MEM_ROOT * | mem_root | |||
| ) |
Definition at line 693 of file parse_file.cc.
References alloc_root(), base_list::empty(), ER_FPARSER_ERROR_IN_PARAMETER, FALSE, my_error(), my_strtoll10(), MYF, File_option::name, File_option::offset, List< T >::push_back(), LEX_STRING::str, and TRUE.
Referenced by File_parser::parse(), and Handle_old_incorrect_sql_modes_hook::process_unknown_string().
00696 { 00697 List<ulonglong> *nlist= (List<ulonglong>*)(base + parameter->offset); 00698 ulonglong *num; 00699 nlist->empty(); 00700 // list parsing 00701 while (ptr < end) 00702 { 00703 int not_used; 00704 char *num_end= end; 00705 if (!(num= (ulonglong*)alloc_root(mem_root, sizeof(ulonglong))) || 00706 nlist->push_back(num, mem_root)) 00707 goto nlist_err; 00708 *num= my_strtoll10(ptr, &num_end, ¬_used); 00709 ptr= num_end; 00710 switch (*ptr) { 00711 case '\n': 00712 goto end_of_nlist; 00713 case ' ': 00714 // we cant go over buffer bounds, because we have \0 at the end 00715 ptr++; 00716 break; 00717 default: 00718 goto nlist_err_w_message; 00719 } 00720 } 00721 00722 end_of_nlist: 00723 if (*(ptr++) != '\n') 00724 goto nlist_err; 00725 return FALSE; 00726 00727 nlist_err_w_message: 00728 my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), parameter->name.str, line); 00729 nlist_err: 00730 return TRUE; 00731 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* parse_escaped_string | ( | char * | ptr, | |
| char * | end, | |||
| MEM_ROOT * | mem_root, | |||
| LEX_STRING * | str | |||
| ) |
Definition at line 621 of file parse_file.cc.
References alloc_root(), read_escaped_string(), LEX_STRING::str, and strchr().
Referenced by File_parser::parse(), and Handle_old_incorrect_trigger_table_hook::process_unknown_string().
00622 { 00623 char *eol= strchr(ptr, '\n'); 00624 00625 if (eol == 0 || eol >= end || 00626 !(str->str= alloc_root(mem_root, (eol - ptr) + 1)) || 00627 read_escaped_string(ptr, eol, str)) 00628 return 0; 00629 00630 return eol+1; 00631 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool rename_in_schema_file | ( | const char * | schema, | |
| const char * | old_name, | |||
| const char * | new_name, | |||
| ulonglong | revision, | |||
| uint | num_view_backups | |||
| ) |
Definition at line 365 of file parse_file.cc.
References access, F_OK, FN_REFLEN, my_rename(), my_snprintf(), MY_WME, MYF, mysql_data_home, NullS, reg_ext, strxnmov(), and unpack_filename().
Referenced by mysql_rename_view().
00368 { 00369 char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN]; 00370 00371 strxnmov(old_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/", 00372 old_name, reg_ext, NullS); 00373 (void) unpack_filename(old_path, old_path); 00374 00375 strxnmov(new_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/", 00376 new_name, reg_ext, NullS); 00377 (void) unpack_filename(new_path, new_path); 00378 00379 if (my_rename(old_path, new_path, MYF(MY_WME))) 00380 return 1; 00381 00382 /* check if arc_dir exists */ 00383 strxnmov(arc_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/arc", NullS); 00384 (void) unpack_filename(arc_path, arc_path); 00385 00386 if (revision > 0 && !access(arc_path, F_OK)) 00387 { 00388 ulonglong limit= ((revision > num_view_backups) ? 00389 revision - num_view_backups : 0); 00390 for (; revision > limit ; revision--) 00391 { 00392 my_snprintf(old_path, FN_REFLEN, "%s/%s%s-%04lu", 00393 arc_path, old_name, reg_ext, (ulong)revision); 00394 (void) unpack_filename(old_path, old_path); 00395 my_snprintf(new_path, FN_REFLEN, "%s/%s%s-%04lu", 00396 arc_path, new_name, reg_ext, (ulong)revision); 00397 (void) unpack_filename(new_path, new_path); 00398 my_rename(old_path, new_path, MYF(0)); 00399 } 00400 } 00401 return 0; 00402 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool sql_create_definition_file | ( | const LEX_STRING * | dir, | |
| const LEX_STRING * | file_name, | |||
| const LEX_STRING * | type, | |||
| gptr | base, | |||
| File_option * | parameters, | |||
| uint | versions | |||
| ) |
Definition at line 214 of file parse_file.cc.
References access, CREATE_MODE, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, end_io_cache(), F_OK, FALSE, fn_format(), FN_REFLEN, init_io_cache(), LEX_STRING::length, memcpy, my_b_append(), my_close(), my_create(), my_delete(), my_mkdir(), my_rename(), my_snprintf(), MY_UNPACK_FILENAME, MY_WME, MYF, File_option::name, NullS, path, SEQ_READ_APPEND, LEX_STRING::str, STRING_WITH_LEN, strlen(), strxnmov(), TRUE, ULONGLONG_MAX, and write_parameter().
Referenced by Table_triggers_list::change_table_name_in_trignames(), Table_triggers_list::create_trigger(), mysql_rename_view(), and save_trigger_file().
00218 { 00219 File handler; 00220 IO_CACHE file; 00221 char path[FN_REFLEN+1]; // +1 to put temporary file name for sure 00222 ulonglong old_version= ULONGLONG_MAX; 00223 int path_end; 00224 File_option *param; 00225 DBUG_ENTER("sql_create_definition_file"); 00226 DBUG_PRINT("enter", ("Dir: %s, file: %s, base 0x%lx", 00227 dir ? dir->str : "(null)", 00228 file_name->str, (ulong) base)); 00229 00230 if (dir) 00231 { 00232 fn_format(path, file_name->str, dir->str, 0, MY_UNPACK_FILENAME); 00233 path_end= strlen(path); 00234 } 00235 else 00236 { 00237 /* 00238 if not dir is passed, it means file_name is a full path, 00239 including dir name, file name itself, and an extension, 00240 and with unpack_filename() executed over it. 00241 */ 00242 path_end= strxnmov(path, FN_REFLEN, file_name->str, NullS) - path; 00243 } 00244 00245 // temporary file name 00246 path[path_end]='~'; 00247 path[path_end+1]= '\0'; 00248 if ((handler= my_create(path, CREATE_MODE, O_RDWR | O_TRUNC, 00249 MYF(MY_WME))) <= 0) 00250 { 00251 DBUG_RETURN(TRUE); 00252 } 00253 00254 if (init_io_cache(&file, handler, 0, SEQ_READ_APPEND, 0L, 0, MYF(MY_WME))) 00255 goto err_w_file; 00256 00257 // write header (file signature) 00258 if (my_b_append(&file, (const byte *)STRING_WITH_LEN("TYPE=")) || 00259 my_b_append(&file, (const byte *)type->str, type->length) || 00260 my_b_append(&file, (const byte *)STRING_WITH_LEN("\n"))) 00261 goto err_w_file; 00262 00263 // write parameters to temporary file 00264 for (param= parameters; param->name.str; param++) 00265 { 00266 if (my_b_append(&file, (const byte *)param->name.str, 00267 param->name.length) || 00268 my_b_append(&file, (const byte *)STRING_WITH_LEN("=")) || 00269 write_parameter(&file, base, param, &old_version) || 00270 my_b_append(&file, (const byte *)STRING_WITH_LEN("\n"))) 00271 goto err_w_cache; 00272 } 00273 00274 if (end_io_cache(&file)) 00275 goto err_w_file; 00276 00277 if (my_close(handler, MYF(MY_WME))) 00278 { 00279 DBUG_RETURN(TRUE); 00280 } 00281 00282 // archive copies management 00283 path[path_end]='\0'; 00284 if (!access(path, F_OK)) 00285 { 00286 if (old_version != ULONGLONG_MAX && max_versions != 0) 00287 { 00288 // save backup 00289 char path_arc[FN_REFLEN]; 00290 // backup old version 00291 char path_to[FN_REFLEN]; 00292 00293 // check archive directory existence 00294 fn_format(path_arc, "arc", dir->str, "", MY_UNPACK_FILENAME); 00295 if (access(path_arc, F_OK)) 00296 { 00297 if (my_mkdir(path_arc, 0777, MYF(MY_WME))) 00298 { 00299 DBUG_RETURN(TRUE); 00300 } 00301 } 00302 00303 my_snprintf(path_to, FN_REFLEN, "%s/%s-%04lu", 00304 path_arc, file_name->str, (ulong) old_version); 00305 if (my_rename(path, path_to, MYF(MY_WME))) 00306 { 00307 DBUG_RETURN(TRUE); 00308 } 00309 00310 // remove very old version 00311 if (old_version > max_versions) 00312 { 00313 my_snprintf(path_to, FN_REFLEN, "%s/%s-%04lu", 00314 path_arc, file_name->str, 00315 (ulong)(old_version - max_versions)); 00316 if (!access(path_arc, F_OK) && my_delete(path_to, MYF(MY_WME))) 00317 { 00318 DBUG_RETURN(TRUE); 00319 } 00320 } 00321 } 00322 else 00323 { 00324 if (my_delete(path, MYF(MY_WME))) // no backups 00325 { 00326 DBUG_RETURN(TRUE); 00327 } 00328 } 00329 } 00330 00331 { 00332 // rename temporary file 00333 char path_to[FN_REFLEN]; 00334 memcpy(path_to, path, path_end+1); 00335 path[path_end]='~'; 00336 if (my_rename(path, path_to, MYF(MY_WME))) 00337 { 00338 DBUG_RETURN(TRUE); 00339 } 00340 } 00341 DBUG_RETURN(FALSE); 00342 err_w_cache: 00343 end_io_cache(&file); 00344 err_w_file: 00345 my_close(handler, MYF(MY_WME)); 00346 DBUG_RETURN(TRUE); 00347 }
Here is the call graph for this function:

Here is the caller graph for this function:

| File_parser* sql_parse_prepare | ( | const LEX_STRING * | file_name, | |
| MEM_ROOT * | mem_root, | |||
| bool | bad_format_errors | |||
| ) |
Definition at line 422 of file parse_file.cc.
References alloc_root(), DBUG_ENTER, DBUG_RETURN, ER_FPARSER_BAD_HEADER, ER_FPARSER_TOO_BIG_FILE, my_close(), my_error(), MY_FILE_ERROR, my_open(), my_read, my_stat(), MY_STAT, MY_WME, MYF, O_SHARE, parser, and LEX_STRING::str.
Referenced by add_table_for_trigger(), Table_triggers_list::check_n_load(), mysql_register_view(), mysql_rename_view(), and open_new_frm().
00424 { 00425 MY_STAT stat_info; 00426 uint len; 00427 char *end, *sign; 00428 File_parser *parser; 00429 File file; 00430 DBUG_ENTER("sql_parse_prepare"); 00431 00432 if (!my_stat(file_name->str, &stat_info, MYF(MY_WME))) 00433 { 00434 DBUG_RETURN(0); 00435 } 00436 00437 if (stat_info.st_size > INT_MAX-1) 00438 { 00439 my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str); 00440 DBUG_RETURN(0); 00441 } 00442 00443 if (!(parser= new(mem_root) File_parser)) 00444 { 00445 DBUG_RETURN(0); 00446 } 00447 00448 if (!(parser->buff= alloc_root(mem_root, stat_info.st_size+1))) 00449 { 00450 DBUG_RETURN(0); 00451 } 00452 00453 if ((file= my_open(file_name->str, O_RDONLY | O_SHARE, MYF(MY_WME))) < 0) 00454 { 00455 DBUG_RETURN(0); 00456 } 00457 00458 if ((len= my_read(file, (byte *)parser->buff, 00459 stat_info.st_size, MYF(MY_WME))) == 00460 MY_FILE_ERROR) 00461 { 00462 my_close(file, MYF(MY_WME)); 00463 DBUG_RETURN(0); 00464 } 00465 00466 if (my_close(file, MYF(MY_WME))) 00467 { 00468 DBUG_RETURN(0); 00469 } 00470 00471 end= parser->end= parser->buff + len; 00472 *end= '\0'; // barrier for more simple parsing 00473 00474 // 7 = 5 (TYPE=) + 1 (letter at least of type name) + 1 ('\n') 00475 if (len < 7 || 00476 parser->buff[0] != 'T' || 00477 parser->buff[1] != 'Y' || 00478 parser->buff[2] != 'P' || 00479 parser->buff[3] != 'E' || 00480 parser->buff[4] != '=') 00481 goto frm_error; 00482 00483 // skip signature; 00484 parser->file_type.str= sign= parser->buff + 5; 00485 while (*sign >= 'A' && *sign <= 'Z' && sign < end) 00486 sign++; 00487 if (*sign != '\n') 00488 goto frm_error; 00489 parser->file_type.length= sign - parser->file_type.str; 00490 // EOS for file signature just for safety 00491 *sign= '\0'; 00492 00493 parser->start= sign + 1; 00494 parser->content_ok= 1; 00495 00496 DBUG_RETURN(parser); 00497 00498 frm_error: 00499 if (bad_format_errors) 00500 { 00501 my_error(ER_FPARSER_BAD_HEADER, MYF(0), file_name->str); 00502 DBUG_RETURN(0); 00503 } 00504 else 00505 DBUG_RETURN(parser); // upper level have to check parser->ok() 00506 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 596 of file mysqld.cc.
Referenced by mysql_make_view(), mysql_register_view(), and mysql_rename_view().
1.4.7

