diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_acl.cc | 15 | ||||
-rw-r--r-- | sql/sql_parse.cc | 32 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 | ||||
-rw-r--r-- | sql/sql_union.cc | 13 |
4 files changed, 42 insertions, 23 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f2f969551d1..90497cc8b43 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2314,11 +2314,20 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, (!db ? rights : 0), revoke_grant, create_new_users))) result= -1; - else + else if (db) { - if (db && replace_db_table(tables[1].table, db, *Str, rights & DB_ACLS, - revoke_grant)) + ulong db_rights= rights & DB_ACLS; + if (db_rights == rights) + { + if (replace_db_table(tables[1].table, db, *Str, db_rights, + revoke_grant)) + result= -1; + } + else + { + net_printf(&thd->net,ER_WRONG_USAGE,"DB GRANT","GLOBAL PRIVILEGES"); result= -1; + } } } VOID(pthread_mutex_unlock(&acl_cache->lock)); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3b3da6d35b3..1ac4120187b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -196,7 +196,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, thd->db=0; thd->db_length=0; USER_RESOURCES ur; - char tmp_passwd[SCRAMBLE_LENGTH]; + char tmp_passwd[SCRAMBLE_LENGTH + 1]; if (passwd[0] && strlen(passwd) != SCRAMBLE_LENGTH) return 1; @@ -257,10 +257,11 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, db ? db : (char*) ""); thd->db_access=0; /* Don't allow user to connect if he has done too many queries */ - if ((ur.questions || ur.updates || ur.connections) && + if ((ur.questions || ur.updates || ur.connections || max_user_connections) && get_or_create_user_conn(thd,user,thd->host_or_ip,&ur)) return -1; - if (thd->user_connect && thd->user_connect->user_resources.connections && + if (thd->user_connect && ((thd->user_connect->user_resources.connections) || + max_user_connections) && check_for_max_user_connections(thd->user_connect)) return -1; if (db && db[0]) @@ -308,7 +309,7 @@ static int check_for_max_user_connections(USER_CONN *uc) DBUG_ENTER("check_for_max_user_connections"); if (max_user_connections && - (max_user_connections <= (uint) uc->connections)) + (max_user_connections < (uint) uc->connections)) { net_printf(&(current_thd->net),ER_TOO_MANY_USER_CONNECTIONS, uc->user); error=1; @@ -1971,11 +1972,6 @@ mysql_execute_command(void) if (thd->select_limit < select_lex->select_limit) thd->select_limit= HA_POS_ERROR; // No limit - if (check_dup(tables->db, tables->real_name, tables->next)) - { - net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name); - DBUG_VOID_RETURN; - } { /* TODO: Delete the following loop when locks is set by sql_yacc */ TABLE_LIST *table; @@ -3390,10 +3386,22 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, tables ; tables=tables->next) { - if (!strcmp(alias_str,tables->alias) && !strcmp(ptr->db, tables->db)) + if (ptr->db_length == tables->db_length && !memcmp(ptr->db, tables->db, ptr->db_length)) { - net_printf(&thd->net,ER_NONUNIQ_TABLE,alias_str); /* purecov: tested */ - DBUG_RETURN(0); /* purecov: tested */ + if ((thd->lex.sql_command & (SQLCOM_INSERT_SELECT | SQLCOM_REPLACE_SELECT)) + && (tables->lock_type & (TL_WRITE_CONCURRENT_INSERT | + TL_WRITE_LOW_PRIORITY | TL_WRITE_DELAYED | + TL_WRITE))) + { + if (ptr->real_name_length == tables->real_name_length && + !memcmp(ptr->real_name, tables->real_name,ptr->real_name_length)) + thd->lex.select->options |= OPTION_BUFFER_RESULT; + } + else if (!strcmp(alias_str,tables->alias)) + { + net_printf(&thd->net,ER_NONUNIQ_TABLE,alias_str); /* purecov: tested */ + DBUG_RETURN(0); /* purecov: tested */ + } } } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 14e1bebbc4a..5b5972be384 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -972,7 +972,10 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, group ? group : order, select_limit, thd->select_limit)) - goto err; /* purecov: inspected */ + { + if (!join.join_tab[join.const_tables].select->quick) + goto err; + } } join.having=having; // Actually a parameter thd->proc_info="Sending data"; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 55b5d57d07d..bd7bc7027d3 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -33,7 +33,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) TABLE *table; int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; int res; - bool found_rows_for_union= 0; + bool found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; TMP_TABLE_PARAM tmp_table_param; @@ -63,10 +63,6 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) */ lex_sl= sl; order= (ORDER *) lex_sl->order_list.first; - found_rows_for_union = (lex->select_lex.options & OPTION_FOUND_ROWS && - !describe && sl->select_limit); - if (found_rows_for_union) - lex->select_lex.options ^= OPTION_FOUND_ROWS; // This is done to eliminate unnecessary slowing down of the first query if (!order || !describe) last_sl->next=0; // Remove this extra element @@ -144,7 +140,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) thd->select_limit=sl->select_limit+sl->offset_limit; if (thd->select_limit < sl->select_limit) thd->select_limit= HA_POS_ERROR; // no limit - if (thd->select_limit == HA_POS_ERROR) + if (thd->select_limit == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; res=mysql_select(thd, (describe && sl->linkage==NOT_A_SELECT) ? @@ -203,9 +199,12 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) { thd->offset_limit= 0; thd->select_limit= thd->variables.select_limit; + if (found_rows_for_union && !describe) + thd->options|= OPTION_FOUND_ROWS; } if (describe) thd->select_limit= HA_POS_ERROR; // no limit + res=mysql_select(thd,&result_table_list, item_list, NULL, (describe) ? 0 : order, (ORDER*) NULL, NULL, (ORDER*) NULL, @@ -264,7 +263,7 @@ bool select_union::send_data(List<Item> &values) if ((write_record(table,&info))) { if (create_myisam_from_heap(thd, table, tmp_table_param, info.last_errno, - 0)) + 1)) return 1; } return 0; |