From dfbaa16160a82b7e70603ba89e76804ba771b7e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 Feb 2004 00:57:22 +0400 Subject: 1. fixed bug @2593 "SHOW CREATE TABLE doesn't properly double quotes" 2. added automatic quotation of keywords in SHOW CREATE TABLE mysql-test/r/show_check.result: added tests for bug #2593 "SHOW CREATE TABLE doesn't properly double quotas" and for automatic quotation of keywords mysql-test/t/show_check.test: added tests for bug #2593 "SHOW CREATE TABLE doesn't properly double quotas" and for automatic quotation of keywords sql/mysql_priv.h: added declaration of function is_keyword sql/sql_lex.cc: added implementation of function is_keyword sql/sql_show.cc: changed function append_identifier and it's subfunctions 1. fixed bug @2593 "SHOW CREATE TABLE doesn't properly double quotes" 2. added automatic quotation of keywords --- sql/mysql_priv.h | 2 ++ sql/sql_lex.cc | 18 +++++++++++++++- sql/sql_show.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 80 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 35740ff8bf1..ef825374301 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -759,6 +759,8 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match); uint check_word(TYPELIB *lib, const char *val, const char *end, const char **end_of_word); +bool is_keyword(const char *name, uint len); + /* sql_parse.cc */ void free_items(Item *item); void cleanup_items(Item *item); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 65c958093bd..b7a8ffa8433 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -181,6 +181,23 @@ static int find_keyword(LEX *lex, uint len, bool function) return 0; } +/* + Check if name is a keyword + + SYNOPSIS + is_keyword() + name checked name + len length of checked name + + RETURN VALUES + 0 name is a keyword + 1 name isn't a keyword +*/ + +bool is_keyword(const char *name, uint len) +{ + return get_hash_symbol(name,len,0)!=0; +} /* make a copy of token before ptr and set yytoklen */ @@ -420,7 +437,6 @@ inline static uint int_token(const char *str,uint length) return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger; } - /* yylex remember the following states from the following yylex() diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3b937f97089..5870e58d9a4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1086,7 +1086,6 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) DBUG_RETURN(0); } -/* possible TODO: call find_keyword() from sql_lex.cc here */ static bool require_quotes(const char *name, uint length) { uint i, d, c; @@ -1100,17 +1099,47 @@ static bool require_quotes(const char *name, uint length) return 0; } +/* + Looking for char in multibyte string + + SYNOPSIS + look_for_char() + name string for looking at + length length of name + q '\'' or '\"' for looking for + + RETURN VALUES + # pointer to found char in string + 0 string doesn't contain required char +*/ + +static const char *look_for_char(const char *name, uint length, char q) +{ + const char *cur= name; + const char *end= cur+length; + uint symbol_length; + for (; curvariables.sql_mode & MODE_ANSI_QUOTES) qtype= '\"'; else qtype= '`'; - if ((thd->options & OPTION_QUOTE_SHOW_CREATE) || - require_quotes(name, length)) + if (is_keyword(name,length)) { packet->append(&qtype, 1); packet->append(name, length, system_charset_info); @@ -1118,7 +1147,35 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) } else { - packet->append(name, length, system_charset_info); + if (!require_quotes(name, length)) + { + if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) + packet->append(name, length, system_charset_info); + else + { + packet->append(&qtype, 1); + packet->append(name, length, system_charset_info); + packet->append(&qtype, 1); + } + } + else + { + packet->append(&qtype, 1); + qplace= look_for_char(name,length,qtype); + while (qplace) + { + if ((part_len= qplace-name)) + { + packet->append(name, part_len, system_charset_info); + length-= part_len; + } + packet->append(qplace, 1, system_charset_info); + name= qplace; + qplace= look_for_char(name+1,length-1,qtype); + } + packet->append(name, length, system_charset_info); + packet->append(&qtype, 1); + } } } -- cgit v1.2.1 From 1e8dcbe01f463abac7845abe5bbeebb49251a5bd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 12:01:27 +0000 Subject: Bug#2703 "MySQL server does not detect if garbage chara at the end of query" Allow the parser to see the garbage characters. Garbage should cause the parser to report an error. sql/sql_lex.cc: Return END_OF_INPUT when at the end of the input buffer. Allows the parser to determine if there is junk after a \0 character. sql/sql_parse.cc: Undo 1.314.1.1 04/02/11 12:32:42 guilhem@mysql.com sql/sql_prepare.cc: Undo 1.73 04/02/11 12:32:42 guilhem@mysql.com --- sql/sql_lex.cc | 9 +++++++-- sql/sql_parse.cc | 18 +----------------- sql/sql_prepare.cc | 10 +--------- 3 files changed, 9 insertions(+), 28 deletions(-) (limited to 'sql') diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 70c69bb7389..90e5b0300f6 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -886,8 +886,13 @@ int yylex(void *arg, void *yythd) } /* fall true */ case MY_LEX_EOL: - lex->next_state=MY_LEX_END; // Mark for next loop - return(END_OF_INPUT); + if (lex->ptr >= lex->end_of_query) + { + lex->next_state=MY_LEX_END; // Mark for next loop + return(END_OF_INPUT); + } + state=MY_LEX_CHAR; + break; case MY_LEX_END: lex->next_state=MY_LEX_END; return(0); // We found end of input last time diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 81d6b80678d..51e1ebee4ad 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3854,23 +3854,7 @@ mysql_parse(THD *thd, char *inBuf, uint length) if (query_cache_send_result_to_client(thd, inBuf, length) <= 0) { LEX *lex=lex_start(thd, (uchar*) inBuf, length); - if (!yyparse((void *)thd) && ! thd->is_fatal_error && - /* - If this is not a multiple query, ensure that it has been - successfully parsed until the last character. This is to prevent - against a wrong (too big) length passed to mysql_real_query(), - mysql_prepare()... which can generate garbage characters at the - end. If the query was initially multiple, found_colon will be false - only when we are in the last query; this last query had already - been end-spaces-stripped by alloc_query() in dispatch_command(); as - end spaces are the only thing we accept at the end of a query, and - they have been stripped already, here we can require that nothing - remains after parsing. - */ - (thd->lex->found_colon || - (char*)(thd->lex->ptr) == (thd->query+thd->query_length+1) || - /* yyerror() will show the garbage chars to the user */ - (yyerror("syntax error"), 0))) + if (!yyparse((void *)thd) && ! thd->is_fatal_error) { #ifndef NO_EMBEDDED_ACCESS_CHECKS if (mqh_used && thd->user_connect && diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cf723e18d85..2cf0000d973 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -909,15 +909,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) lex->safe_to_cache_query= 0; lex->param_count= 0; - if (yyparse((void *)thd) || thd->is_fatal_error || - /* - Check for wrong (too big) length passed to mysql_prepare() resulting in - garbage at the end of the query. There is a similar check in mysql_parse(). - */ - (!thd->lex->found_colon && - (char*)(thd->lex->ptr) != (thd->query+thd->query_length+1) && - /* yyerror() will show the garbage chars to the user */ - (yyerror("syntax error"), 1)) || send_prepare_results(stmt)) + if (yyparse((void *)thd) || thd->is_fatal_error || send_prepare_results(stmt)) goto yyparse_err; lex_end(lex); -- cgit v1.2.1 From c5bc73e9a7d2f4ed2c7602fc6a028e227c08b9f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 18:37:15 +0100 Subject: make all "artificial" syntax errors to report a place where they take place ("...syntax error ... near ...") --- sql/sql_yacc.yy | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'sql') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 76a0f384b15..85ffa2c84a3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2157,13 +2157,13 @@ select_init: SELECT_LEX * sel= lex->current_select; if (sel->set_braces(1)) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } if (sel->linkage == UNION_TYPE && !sel->master_unit()->first_select()->braces) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } /* select in braces, can't contain global parameters */ @@ -2179,13 +2179,13 @@ select_init2: SELECT_LEX * sel= lex->current_select; if (lex->current_select->set_braces(0)) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } if (sel->linkage == UNION_TYPE && sel->master_unit()->first_select()->braces) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } } @@ -2742,7 +2742,7 @@ simple_expr: { if ($1->type() != Item::ROW_ITEM) { - send_error(Lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } $$= new Item_func_interval((Item_row *)$1); @@ -3078,7 +3078,7 @@ in_sum_expr: LEX *lex= Lex; if (lex->current_select->inc_in_sum_expr()) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } } @@ -3249,8 +3249,8 @@ select_derived: if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN && lex->sql_command <= (int)SQLCOM_HA_READ) || lex->sql_command == (int)SQLCOM_KILL) - { - send_error(lex->thd, ER_SYNTAX_ERROR); + { + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || @@ -3885,7 +3885,7 @@ opt_insert_update: for a moment */ if (Lex->sql_command != SQLCOM_INSERT) { - send_error(Lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } } @@ -4491,7 +4491,7 @@ param_marker: } else { - yyerror("You have an error in your SQL syntax"); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } } @@ -5534,7 +5534,7 @@ union_list: } if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { - send_error(lex->thd, ER_SYNTAX_ERROR); + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } if (mysql_new_select(lex, 0)) @@ -5634,8 +5634,8 @@ subselect_start: if (((int)lex->sql_command >= (int)SQLCOM_HA_OPEN && lex->sql_command <= (int)SQLCOM_HA_READ) || lex->sql_command == (int)SQLCOM_KILL) - { - send_error(lex->thd, ER_SYNTAX_ERROR); + { + yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } if (mysql_new_select(Lex, 1)) -- cgit v1.2.1 From b3bf99ed42f6ae344cb646ea421ccba7fbaee69f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 00:28:00 +0400 Subject: some optimization in append_identifier (sql/sql_show.cc) sql/sql_show.cc: some optimization in append_identifier --- sql/sql_show.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sql') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 5870e58d9a4..2d7b89a24a1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1086,7 +1086,7 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) DBUG_RETURN(0); } -static bool require_quotes(const char *name, uint length) +static inline const char *require_quotes(const char *name, uint length) { uint i, d, c; for (i=0; iident_map[c]) - return 1; + return name+i; } return 0; } @@ -1113,7 +1113,8 @@ static bool require_quotes(const char *name, uint length) 0 string doesn't contain required char */ -static const char *look_for_char(const char *name, uint length, char q) +static inline const char *look_for_char(const char *name, + uint length, char q) { const char *cur= name; const char *end= cur+length; @@ -1141,27 +1142,29 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) if (is_keyword(name,length)) { - packet->append(&qtype, 1); + packet->append(&qtype, 1, system_charset_info); packet->append(name, length, system_charset_info); - packet->append(&qtype, 1); + packet->append(&qtype, 1, system_charset_info); } else { - if (!require_quotes(name, length)) + if (!(qplace= require_quotes(name, length))) { if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) packet->append(name, length, system_charset_info); else { - packet->append(&qtype, 1); + packet->append(&qtype, 1, system_charset_info); packet->append(name, length, system_charset_info); - packet->append(&qtype, 1); + packet->append(&qtype, 1, system_charset_info); } } else { - packet->append(&qtype, 1); - qplace= look_for_char(name,length,qtype); + packet->shrink(packet->length()+length+2); + packet->append(&qtype, 1, system_charset_info); + if (*qplace != qtype) + qplace= look_for_char(qplace+1,length-(qplace-name)-1,qtype); while (qplace) { if ((part_len= qplace-name)) @@ -1174,7 +1177,7 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) qplace= look_for_char(name+1,length-1,qtype); } packet->append(name, length, system_charset_info); - packet->append(&qtype, 1); + packet->append(&qtype, 1, system_charset_info); } } } -- cgit v1.2.1 From f2adc11249255e9474db8a83186d23896b78d740 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 11:56:36 +0400 Subject: Another fix for #2208 previous one had error libmysqld/lib_sql.cc: memdup_mysql deleted sql/sql_class.h: String instead of char* sql/sql_parse.cc: storing of the rest of the query --- sql/sql_class.h | 3 +-- sql/sql_parse.cc | 14 +++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/sql_class.h b/sql/sql_class.h index 5034007cd4d..b8cce3096ef 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -565,8 +565,7 @@ public: struct st_mysql_bind *client_params; char *extra_data; ulong extra_length; - char *query_rest; - uint32 query_rest_length; + String query_rest; #endif NET net; // client connection descriptor MEM_ROOT warn_root; // For warnings and errors diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 51e1ebee4ad..69ee43d53d1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -48,7 +48,6 @@ extern "C" int gethostname(char *name, int namelen); #endif -char *memdup_mysql(struct st_mysql *mysql, const char*data, int length); static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); static bool check_db_used(THD *thd,TABLE_LIST *tables); @@ -1420,8 +1419,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #ifndef EMBEDDED_LIBRARY mysql_parse(thd, packet, length); #else - thd->query_rest= (char*)memdup_mysql(thd->mysql, packet, length); - thd->query_rest_length= length; + /* + 'packet' can point inside the query_rest's buffer + so we have to do memmove here + */ + if (thd->query_rest.length() > length) + { + memmove(thd->query_rest.c_ptr(), packet, length); + thd->query_rest.length(length); + } + else + thd->query_rest.copy(length); break; #endif /*EMBEDDED_LIBRARY*/ } -- cgit v1.2.1 From 82364214ecdbc574328efab8e8661468c2ec5b16 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 17:58:02 +0400 Subject: Bug #2699 UTF8 breaks primary keys for cols > 85 characters --- sql/sql_table.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4e66154e2a2..404d2b56e06 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -877,7 +877,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, column->field_name); DBUG_RETURN(-1); } - key_part_info->length=(uint8) length; + if (length > file->max_key_part_length()) + { + my_error(ER_WRONG_SUB_KEY,MYF(0)); + DBUG_RETURN(-1); + } + key_part_info->length=(uint16) length; /* Use packed keys for long strings on the first column */ if (!(db_options & HA_OPTION_NO_PACK_KEYS) && (length >= KEY_DEFAULT_PACK_LENGTH && -- cgit v1.2.1 From 1515c12191bcb50c49512475a72c04a47c963a07 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 15:27:21 +0100 Subject: my_atof is deleted strtod from mit-threads is restored and cleaned up BitKeeper/deleted/.del-atof.c~d3edf47a9884080: Delete: strings/atof.c configure.in: atod() is no longer used in MySQL isinf() now is include/m_string.h: my_strtod, my_atof include/my_global.h: my_atof is deleted define isinf() libmysql/Makefile.shared: use internal strtod sql/gstream.cc: use internal strtod sql/init.cc: my_atof is deleted sql/item.h: use internal strtod sql/item_func.cc: use internal strtod sql/item_sum.h: use internal strtod sql/sql_analyse.cc: use internal strtod strings/Makefile.am: use internal strtod strings/ctype-simple.c: use internal strtod strings/ctype-ucs2.c: use internal strtod strings/strtod.c: cleanup stricter input checks (e.g. ".E10" is no longer a number) don't return an "inf" --- sql/gstream.cc | 2 +- sql/init.cc | 3 --- sql/item.h | 2 +- sql/item_func.cc | 2 +- sql/item_sum.h | 4 ++-- sql/sql_analyse.cc | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/gstream.cc b/sql/gstream.cc index a97ed9cae03..17b85af22bd 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -101,7 +101,7 @@ int GTextReadStream::get_next_number(double *d) char *endptr; - *d = strtod(cur, &endptr); + *d = my_strtod(cur, &endptr); if (endptr) { diff --git a/sql/init.cc b/sql/init.cc index 033dfd72843..084db57f8aa 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -34,9 +34,6 @@ void unireg_init(ulong options) current_pid=(ulong) getpid(); /* Save for later ref */ init_time(); /* Init time-functions (read zone) */ -#ifdef USE_MY_ATOF - init_my_atof(); /* use our atof */ -#endif #ifndef EMBEDDED_LIBRARY my_abort_hook=unireg_abort; /* Abort with close of databases */ #endif diff --git a/sql/item.h b/sql/item.h index 7b5c506079d..6487c8d8391 100644 --- a/sql/item.h +++ b/sql/item.h @@ -441,7 +441,7 @@ class Item_real :public Item public: const double value; // Item_real() :value(0) {} - Item_real(const char *str_arg,uint length) :value(atof(str_arg)) + Item_real(const char *str_arg,uint length) :value(my_atof(str_arg)) { name=(char*) str_arg; decimals=(uint8) nr_of_decimals(str_arg); diff --git a/sql/item_func.cc b/sql/item_func.cc index f90fcd5149e..42f0e64c71b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2255,7 +2255,7 @@ double user_var_entry::val(my_bool *null_value) case INT_RESULT: return (double) *(longlong*) value; case STRING_RESULT: - return atof(value); // This is null terminated + return my_atof(value); // This is null terminated case ROW_RESULT: DBUG_ASSERT(1); // Impossible break; diff --git a/sql/item_sum.h b/sql/item_sum.h index dc84e4d4ab7..1435128af33 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -735,7 +735,7 @@ class Item_func_group_concat : public Item_sum enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;} const char *func_name() const { return "group_concat"; } - enum Type type() const { return SUM_FUNC_ITEM; } + enum Type type() const { return SUM_FUNC_ITEM; } virtual Item_result result_type () const { return STRING_RESULT; } void clear(); bool add(); @@ -747,7 +747,7 @@ class Item_func_group_concat : public Item_sum double val() { String *res; res=val_str(&str_value); - return res ? atof(res->c_ptr()) : 0.0; + return res ? my_atof(res->c_ptr()) : 0.0; } longlong val_int() { diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 9e73e06d9c6..3c9563165fe 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -225,7 +225,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) info->decimals++; if (str == end) { - info->dval = atod(begin); + info->dval = my_atof(begin); return 1; } } -- cgit v1.2.1 From e05c2a90da83787ed5f3e26fdada9040ec00ab27 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 15:27:58 +0100 Subject: small optimization --- sql/sql_string.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 42e700b27aa..debe42046f0 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -437,7 +437,7 @@ bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs) if (!arg_length) // Default argument if (!(arg_length= (uint32) strlen(s))) return FALSE; - if (str_charset->mbmaxlen > 1) + if (cs != str_charset && str_charset->mbmaxlen > 1) { uint32 add_length=arg_length * str_charset->mbmaxlen; if (realloc(str_length+ add_length)) -- cgit v1.2.1 From f05d5c844f7e7cead2b9aa054cf8ad2bcc7daf4b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 14 Feb 2004 02:26:27 +0400 Subject: a little optimization in yylex (case MY_LEX_USER_VARIABLE_DELIMITER for multichar strings) and my_mbcharlen include/m_ctype.h: a trivial optimization of my_mbcharlen (case !USE_MB) sql/sql_lex.cc: a little optimization in yylex (case MY_LEX_USER_VARIABLE_DELIMITER for multichar strings) --- sql/sql_lex.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'sql') diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bd7d0a31546..023415a6794 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -694,10 +694,9 @@ int yylex(void *arg, void *yythd) char quote_char= c; // Used char lex->tok_start=lex->ptr; // Skip first ` while ((c=yyGet())) - { -#ifdef USE_MB - if (my_mbcharlen(cs, c) == 1) -#endif + { + int l; + if ((l= my_mbcharlen(cs, c)) == 1) { if (c == (uchar) NAMES_SEP_CHAR) break; /* Old .frm format can't handle this char */ @@ -711,15 +710,12 @@ int yylex(void *arg, void *yythd) } } #ifdef USE_MB - else + else if (l > 1) { - int l; - if ((l = my_ismbchar(cs, - (const char *)lex->ptr-1, - (const char *)lex->end_of_query)) == 0) - break; lex->ptr += l-1; } + else + break; #endif } if (double_quotes) -- cgit v1.2.1