diff options
author | monty@hundin.mysql.fi <> | 2002-12-01 14:59:06 +0200 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2002-12-01 14:59:06 +0200 |
commit | b96041ffa878ded679e5bc14cd07d2b9c83cc9cd (patch) | |
tree | 7766377feb9c04252823b1c8cf1d7a587f707baf /sql/sql_lex.cc | |
parent | 27dc59e7834a3952dd7be7cca3f07b5b534688be (diff) | |
download | mariadb-git-b96041ffa878ded679e5bc14cd07d2b9c83cc9cd.tar.gz |
Fixed that one can use ` in identifiers: CREATE TABLE `fo``a` ...
Added BOOLEAN as synonym for tinyint
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 5104487c700..fa5911db30d 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -216,7 +216,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 @@ -225,8 +225,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) { @@ -663,14 +682,32 @@ int yylex(void *arg) 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) |