MCPcopy Create free account
hub / github.com/MariaDB/server / sql_parse_prepare

Function sql_parse_prepare

sql/parse_file.cc:451–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449*/
450
451File_parser *
452sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
453 bool bad_format_errors)
454{
455 MY_STAT stat_info;
456 size_t len;
457 char *buff, *end, *sign;
458 File_parser *parser;
459 File file;
460 DBUG_ENTER("sql_parse_prepare");
461
462 if (!mysql_file_stat(key_file_fileparser,
463 file_name->str, &stat_info, MYF(MY_WME)))
464 {
465 DBUG_RETURN(0);
466 }
467
468 if (stat_info.st_size > INT_MAX-1)
469 {
470 my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str);
471 DBUG_RETURN(0);
472 }
473
474 if (!(parser= new(mem_root) File_parser))
475 {
476 DBUG_RETURN(0);
477 }
478
479 if (!(buff= (char*) alloc_root(mem_root, (size_t)(stat_info.st_size+1))))
480 {
481 DBUG_RETURN(0);
482 }
483
484 if ((file= mysql_file_open(key_file_fileparser, file_name->str,
485 O_RDONLY | O_SHARE, MYF(MY_WME))) < 0)
486 {
487 DBUG_RETURN(0);
488 }
489
490 if ((len= mysql_file_read(file, (uchar *)buff, (size_t)stat_info.st_size,
491 MYF(MY_WME))) == MY_FILE_ERROR)
492 {
493 mysql_file_close(file, MYF(MY_WME));
494 DBUG_RETURN(0);
495 }
496
497 if (mysql_file_close(file, MYF(MY_WME)))
498 {
499 DBUG_RETURN(0);
500 }
501
502 end= buff + len;
503 *end= '\0'; // barrier for more simple parsing
504
505 // 7 = 5 (TYPE=) + 1 (letter at least of type name) + 1 ('\n')
506 if (len < 7 ||
507 buff[0] != 'T' ||
508 buff[1] != 'Y' ||

Callers 5

open_table_defFunction · 0.85
check_n_loadMethod · 0.85
mysql_register_viewFunction · 0.85
mysql_rename_viewFunction · 0.85

Calls 2

my_errorFunction · 0.85
alloc_rootFunction · 0.85

Tested by

no test coverage detected