diff options
author | unknown <monty@tik.mysql.fi> | 2001-07-04 09:39:58 +0300 |
---|---|---|
committer | unknown <monty@tik.mysql.fi> | 2001-07-04 09:39:58 +0300 |
commit | 9a811481b21c3ac3a349b2311a92558e397bc764 (patch) | |
tree | 1aebd400b499a8cbeaef3fb0b970cba953f38373 /sql/sql_lex.cc | |
parent | 09b6895facbfafb492d543e1ee801fd3075290c0 (diff) | |
download | mariadb-git-9a811481b21c3ac3a349b2311a92558e397bc764.tar.gz |
Added support for ANSI SQL X'hex-string' format.
Fixed mysqldump to use -- instead of # as comment characters.
Removed support for the 3.20 protocol format
Docs/manual.texi:
Update Changelog
client/mysqldump.c:
Fixed dump to use -- instead of # as comment characters.
libmysql/libmysql.c:
Removed support for the 3.20 protocol format
myisam/myisamchk.c:
Fixed typo in printf
mysql-test/r/varbinary.result:
Test of new hex constant format
mysql-test/t/varbinary.test:
Test of new hex constant format
sql/sql_lex.cc:
Added support for ANSI SQL X'hex-string' format.
sql/sql_lex.h:
Added support for ANSI SQL X'hex-string' format.
sql/sql_yacc.yy:
Added support for ANSI SQL X'hex-string' format.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3f6c09073e6..8f77931a05f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -430,7 +430,7 @@ int yylex(void *arg) switch(state) { case STATE_OPERATOR_OR_IDENT: // Next is operator or keyword case STATE_START: // Start of token - // Skipp startspace + // Skip startspace for (c=yyGet() ; (state_map[c] == STATE_SKIP) ; c= yyGet()) { if (c == '\n') @@ -458,6 +458,11 @@ int yylex(void *arg) return((int) c); case STATE_IDENT: // Incomplete keyword or ident + if ((c == 'x' || c == 'X') && yyPeek() == '\'') + { // Found x'hex-number' + state=STATE_HEX_NUMBER; + break; + } #if defined(USE_MB) && defined(USE_MB_IDENT) if (use_mb(default_charset_info)) { @@ -520,7 +525,7 @@ int yylex(void *arg) c=yyGet(); // should be '.' return((int) c); - case STATE_NUMBER_IDENT: // number or ident which starts with num + case STATE_NUMBER_IDENT: // number or ident which num-start while (isdigit((c = yyGet()))) ; if (state_map[c] != STATE_IDENT) { // Can't be identifier @@ -546,10 +551,10 @@ int yylex(void *arg) lex->tok_start[0] == '0' ) { // Varbinary while (isxdigit((c = yyGet()))) ; - if ((lex->ptr - lex->tok_start) >= 4) + if ((lex->ptr - lex->tok_start) >= 4 && state_map[c] != STATE_IDENT) { yylval->lex_str=get_token(lex,yyLength()); - yylval->lex_str.str+=2; // Skipp 0x + yylval->lex_str.str+=2; // Skip 0x yylval->lex_str.length-=2; lex->yytoklen-=2; return (HEX_NUM); @@ -604,20 +609,21 @@ int yylex(void *arg) return(IDENT); case STATE_USER_VARIABLE_DELIMITER: - lex->tok_start=lex->ptr; // Skipp first ` + lex->tok_start=lex->ptr; // Skip first ` while ((c=yyGet()) && state_map[c] != STATE_USER_VARIABLE_DELIMITER && c != (uchar) NAMES_SEP_CHAR) ; 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) - yySkip(); // Skipp end ` + yySkip(); // Skip end ` return(IDENT); case STATE_SIGNED_NUMBER: // Incomplete signed number if (prev_state == STATE_OPERATOR_OR_IDENT) { - if (c == '-' && yyPeek() == '-' && isspace(yyPeek2())) + if (c == '-' && yyPeek() == '-' && + (isspace(yyPeek2()) || iscntrl(yyPeek2()))) state=STATE_COMMENT; else state= STATE_CHAR; // Must be operator @@ -657,7 +663,7 @@ int yylex(void *arg) { c = yyGet(); if (c == '-' || c == '+') - c = yyGet(); // Skipp sign + c = yyGet(); // Skip sign if (!isdigit(c)) { // No digit after sign state= STATE_CHAR; @@ -670,6 +676,21 @@ int yylex(void *arg) yylval->lex_str=get_token(lex,yyLength()); return(REAL_NUM); + case STATE_HEX_NUMBER: // Found x'hexstring' + yyGet(); // Skip ' + while (isxdigit((c = yyGet()))) ; + length=(lex->ptr - lex->tok_start); // Length of hexnum+3 + if (!(length & 1) || c != '\'') + { + return(ABORT_SYM); // Illegal hex constant + } + yyGet(); // get_token makes an unget + yylval->lex_str=get_token(lex,length); + yylval->lex_str.str+=2; // Skip x' + yylval->lex_str.length-=3; // Don't count x' and last ' + lex->yytoklen-=3; + return (HEX_NUM); + case STATE_CMP_OP: // Incomplete comparison operator if (state_map[yyPeek()] == STATE_CMP_OP || state_map[yyPeek()] == STATE_LONG_CMP_OP) |