summaryrefslogtreecommitdiff
path: root/sql/parse_file.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2015-03-10 10:24:20 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2015-03-11 17:39:15 +0100
commit80f03abcca0d902a876d10e6c1dc8c4c6d3b2bfa (patch)
tree3cf78175d7303f3736c6df7786ea9a7ad75b24a2 /sql/parse_file.cc
parent3aa1a600bb3cc72dd30edd8f1c41b90e1157a2ed (diff)
downloadmariadb-git-80f03abcca0d902a876d10e6c1dc8c4c6d3b2bfa.tar.gz
MDEV-7671: Cache VIEW definitions in the TDC
(changes of backported patch are very small: strlen removed, error processing fixed, view open statistics added)
Diffstat (limited to 'sql/parse_file.cc')
-rw-r--r--sql/parse_file.cc62
1 files changed, 32 insertions, 30 deletions
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index ee031c1bbc2..b815c264b5b 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -404,7 +404,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
{
MY_STAT stat_info;
size_t len;
- char *end, *sign;
+ char *buff, *end, *sign;
File_parser *parser;
File file;
DBUG_ENTER("sql_parse_prepare");
@@ -426,7 +426,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0);
}
- if (!(parser->buff= (char*) alloc_root(mem_root, (size_t)(stat_info.st_size+1))))
+ if (!(buff= (char*) alloc_root(mem_root, (size_t)(stat_info.st_size+1))))
{
DBUG_RETURN(0);
}
@@ -437,9 +437,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0);
}
- if ((len= mysql_file_read(file, (uchar *)parser->buff,
- stat_info.st_size, MYF(MY_WME))) ==
- MY_FILE_ERROR)
+ if ((len= mysql_file_read(file, (uchar *)buff, stat_info.st_size,
+ MYF(MY_WME))) == MY_FILE_ERROR)
{
mysql_file_close(file, MYF(MY_WME));
DBUG_RETURN(0);
@@ -450,20 +449,20 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0);
}
- end= parser->end= parser->buff + len;
+ end= buff + len;
*end= '\0'; // barrier for more simple parsing
// 7 = 5 (TYPE=) + 1 (letter at least of type name) + 1 ('\n')
if (len < 7 ||
- parser->buff[0] != 'T' ||
- parser->buff[1] != 'Y' ||
- parser->buff[2] != 'P' ||
- parser->buff[3] != 'E' ||
- parser->buff[4] != '=')
+ buff[0] != 'T' ||
+ buff[1] != 'Y' ||
+ buff[2] != 'P' ||
+ buff[3] != 'E' ||
+ buff[4] != '=')
goto frm_error;
// skip signature;
- parser->file_type.str= sign= parser->buff + 5;
+ parser->file_type.str= sign= buff + 5;
while (*sign >= 'A' && *sign <= 'Z' && sign < end)
sign++;
if (*sign != '\n')
@@ -472,6 +471,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
// EOS for file signature just for safety
*sign= '\0';
+ parser->end= end;
parser->start= sign + 1;
parser->content_ok= 1;
@@ -504,11 +504,12 @@ frm_error:
*/
-static char *
-parse_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
+static const char *
+parse_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
+ LEX_STRING *str)
{
// get string length
- char *eol= strchr(ptr, '\n');
+ const char *eol= strchr(ptr, '\n');
if (eol >= end)
return 0;
@@ -535,7 +536,7 @@ parse_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
*/
my_bool
-read_escaped_string(char *ptr, char *eol, LEX_STRING *str)
+read_escaped_string(const char *ptr, const char *eol, LEX_STRING *str)
{
char *write_pos= str->str;
@@ -595,10 +596,11 @@ read_escaped_string(char *ptr, char *eol, LEX_STRING *str)
*/
-char *
-parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
+const char *
+parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
+ LEX_STRING *str)
{
- char *eol= strchr(ptr, '\n');
+ const char *eol= strchr(ptr, '\n');
if (eol == 0 || eol >= end ||
!(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) ||
@@ -624,11 +626,11 @@ parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
\# pointer on symbol after string
*/
-static char *
-parse_quoted_escaped_string(char *ptr, char *end,
+static const char *
+parse_quoted_escaped_string(const char *ptr, const char *end,
MEM_ROOT *mem_root, LEX_STRING *str)
{
- char *eol;
+ const char *eol;
uint result_len= 0;
bool escaped= 0;
@@ -665,7 +667,7 @@ parse_quoted_escaped_string(char *ptr, char *end,
@param[in] mem_root MEM_ROOT for parameters allocation
*/
-bool get_file_options_ulllist(char *&ptr, char *end, char *line,
+bool get_file_options_ulllist(const char *&ptr, const char *end, const char *line,
uchar* base, File_option *parameter,
MEM_ROOT *mem_root)
{
@@ -676,7 +678,7 @@ bool get_file_options_ulllist(char *&ptr, char *end, char *line,
while (ptr < end)
{
int not_used;
- char *num_end= end;
+ char *num_end= const_cast<char *>(end);
if (!(num= (ulonglong*)alloc_root(mem_root, sizeof(ulonglong))) ||
nlist->push_back(num, mem_root))
goto nlist_err;
@@ -731,18 +733,18 @@ nlist_err:
my_bool
File_parser::parse(uchar* base, MEM_ROOT *mem_root,
struct File_option *parameters, uint required,
- Unknown_key_hook *hook)
+ Unknown_key_hook *hook) const
{
uint first_param= 0, found= 0;
- char *ptr= start;
- char *eol;
+ const char *ptr= start;
+ const char *eol;
LEX_STRING *str;
List<LEX_STRING> *list;
DBUG_ENTER("File_parser::parse");
while (ptr < end && found < required)
{
- char *line= ptr;
+ const char *line= ptr;
if (*ptr == '#')
{
// it is comment
@@ -940,9 +942,9 @@ list_err:
*/
bool
-File_parser_dummy_hook::process_unknown_string(char *&unknown_key,
+File_parser_dummy_hook::process_unknown_string(const char *&unknown_key,
uchar* base, MEM_ROOT *mem_root,
- char *end)
+ const char *end)
{
DBUG_ENTER("file_parser_dummy_hook::process_unknown_string");
DBUG_PRINT("info", ("Unknown key: '%60s'", unknown_key));