diff options
author | unknown <monty@hundin.mysql.fi> | 2002-12-01 15:05:35 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-12-01 15:05:35 +0200 |
commit | 0da49160c63b51c3954e19dc90dce8ea508ba498 (patch) | |
tree | 22c5e1f3926484729f93f8b6b08d654bf7a71acc /sql/sql_lex.cc | |
parent | 9fcbfc0d12444c19f5b51249425e9324516ee35a (diff) | |
parent | 9b045452c90dd5052bcbb619cabf4337c9532696 (diff) | |
download | mariadb-git-0da49160c63b51c3954e19dc90dce8ea508ba498.tar.gz |
Merge work:/home/bk/mysql-4.1 into hundin.mysql.fi:/my/mysql-4.1
sql/sql_lex.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d765c741932..df4af8b8400 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -220,7 +220,7 @@ static int find_keyword(LEX *lex, uint len, bool function) /* make a copy of token before ptr and set yytoklen */ -LEX_STRING get_token(LEX *lex,uint length) +static LEX_STRING get_token(LEX *lex,uint length) { LEX_STRING tmp; yyUnget(); // ptr points now after last token char @@ -229,8 +229,27 @@ LEX_STRING get_token(LEX *lex,uint length) return tmp; } -/* Return an unescaped text literal without quotes */ -/* Fix sometimes to do only one scan of the string */ +static LEX_STRING get_quoted_token(LEX *lex,uint length, char quote) +{ + LEX_STRING tmp; + byte *from, *to, *end; + yyUnget(); // ptr points now after last token char + tmp.length=lex->yytoklen=length; + tmp.str=(char*) lex->thd->alloc(tmp.length+1); + for (from= (byte*) lex->tok_start, to= tmp.str, end= to+length ; to != end ;) + { + if ((*to++= *from++) == quote) + from++; // Skip double quotes + } + *to= 0; // End null for safety + return tmp; +} + + +/* + Return an unescaped text literal without quotes + Fix sometimes to do only one scan of the string +*/ static char *get_text(LEX *lex) { @@ -667,14 +686,32 @@ int yylex(void *arg, void *yythd) lex->ptr += l-1; } } + yylval->lex_str=get_token(lex,yyLength()); } else #endif { - while ((c=yyGet()) && state_map[c] != STATE_USER_VARIABLE_DELIMITER && - c != (uchar) NAMES_SEP_CHAR) ; + uint double_quotes= 0; + char quote_char= c; + while ((c=yyGet())) + { + if (c == quote_char) + { + if (yyPeek() != quote_char) + break; + c=yyGet(); + double_quotes++; + continue; + } + if (c == (uchar) NAMES_SEP_CHAR) + break; + } + if (double_quotes) + yylval->lex_str=get_quoted_token(lex,yyLength() - double_quotes, + quote_char); + else + yylval->lex_str=get_token(lex,yyLength()); } - yylval->lex_str=get_token(lex,yyLength()); if (lex->convert_set) lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); if (state_map[c] == STATE_USER_VARIABLE_DELIMITER) |