diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dc89888a1a5..06431124356 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -273,7 +273,8 @@ static void free_user(struct user_conn *uc) void init_max_user_conn(void) { - (void) hash_init(&hash_user_connections,max_connections,0,0, + (void) hash_init(&hash_user_connections,system_charset_info,max_connections, + 0,0, (hash_get_key) get_key_conn, (void (*)(void*)) free_user, 0); } @@ -700,7 +701,8 @@ pthread_handler_decl(handle_bootstrap,arg) while (fgets(buff, thd->net.max_packet, file)) { uint length=(uint) strlen(buff); - while (length && (isspace(buff[length-1]) || buff[length-1] == ';')) + while (length && (my_isspace(system_charset_info, buff[length-1]) || + buff[length-1] == ';')) length--; buff[length]=0; thd->current_tablenr=0; @@ -926,13 +928,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { packet_length--; // Remove end null /* Remove garage at start and end of query */ - while (isspace(packet[0]) && packet_length > 0) + while (my_isspace(system_charset_info,packet[0]) && packet_length > 0) { packet++; packet_length--; } char *pos=packet+packet_length; // Point at end null - while (packet_length > 0 && (pos[-1] == ';' || isspace(pos[-1]))) + while (packet_length > 0 && + (pos[-1] == ';' || my_isspace(system_charset_info,pos[-1]))) { pos--; packet_length--; @@ -1233,6 +1236,14 @@ mysql_execute_command(void) Skip if we are in the slave thread, some table rules have been given and the table list says the query should not be replicated */ + if (lex->derived_tables) + { + for (TABLE_LIST *cursor= tables; + cursor; + cursor=cursor->next) + if (cursor->derived && mysql_derived(thd,lex,(SELECT_LEX *)cursor->derived,cursor)) + DBUG_VOID_RETURN; + } if ((lex->select_lex.next && create_total_list(thd,lex,&tables)) || (table_rules_on && tables && thd->slave_thread && !tables_ok(thd,tables))) @@ -2271,7 +2282,8 @@ mysql_execute_command(void) if (user->password.str && (strcmp(thd->user,user->user.str) || user->host.str && - my_strcasecmp(user->host.str, thd->host_or_ip))) + my_strcasecmp(system_charset_info, + user->host.str, thd->host_or_ip))) { if (check_access(thd, UPDATE_ACL, "mysql",0,1)) goto error; @@ -2656,7 +2668,7 @@ mysql_init_query(THD *thd) thd->lex.value_list.empty(); thd->lex.select_lex.table_list.elements=0; thd->free_list=0; thd->lex.union_option=0; - thd->lex.select = &thd->lex.select_lex; + thd->lex.select = thd->lex.last_select = &thd->lex.select_lex; thd->lex.select_lex.table_list.first=0; thd->lex.select_lex.table_list.next= (byte**) &thd->lex.select_lex.table_list.first; thd->lex.select_lex.next=0; @@ -2683,7 +2695,7 @@ mysql_init_select(LEX *lex) select_lex->order_list.next= (byte**) &select_lex->order_list.first; select_lex->group_list.first=0; select_lex->group_list.next= (byte**) &select_lex->group_list.first; - select_lex->next = (SELECT_LEX *)NULL; + select_lex->next = select_lex->prev = (SELECT_LEX *)NULL; } bool @@ -2692,8 +2704,9 @@ mysql_new_select(LEX *lex) SELECT_LEX *select_lex = (SELECT_LEX *) lex->thd->calloc(sizeof(SELECT_LEX)); if (!select_lex) return 1; + lex->select=lex->last_select; lex->select->next=select_lex; - lex->select=select_lex; + lex->select=lex->last_select=select_lex; select_lex->table_list.next= (byte**) &select_lex->table_list.first; select_lex->item_list.empty(); select_lex->when_list.empty(); @@ -3052,8 +3065,8 @@ static void remove_escape(char *name) #ifdef USE_MB int l; /* if ((l = ismbchar(name, name+MBMAXLEN))) { Wei He: I think it's wrong */ - if (use_mb(default_charset_info) && - (l = my_ismbchar(default_charset_info, name, strend))) + if (use_mb(system_charset_info) && + (l = my_ismbchar(system_charset_info, name, strend))) { while (l--) *to++ = *name++; @@ -3107,7 +3120,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, DBUG_RETURN(0); // End of memory alias_str= alias ? alias->str : table->table.str; if (table->table.length > NAME_LEN || - check_table_name(table->table.str,table->table.length) || + (table->table.length && check_table_name(table->table.str,table->table.length)) || table->db.str && check_db_name(table->db.str)) { net_printf(&thd->net,ER_WRONG_TABLE_NAME,table->table.str); @@ -3139,13 +3152,14 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, ptr->name=alias_str; if (lower_case_table_names) { - casedn_str(ptr->db); - casedn_str(table->table.str); + my_casedn_str(system_charset_info,ptr->db); + my_casedn_str(system_charset_info,table->table.str); } ptr->real_name=table->table.str; ptr->real_name_length=table->table.length; ptr->lock_type=flags; ptr->updating=updating; + ptr->derived=(SELECT_LEX *)table->sel; if (use_index) ptr->use_index=(List<String> *) thd->memdup((gptr) use_index, sizeof(*use_index)); |