diff options
author | unknown <sanja@askmonty.org> | 2011-07-21 15:50:25 +0300 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2011-07-21 15:50:25 +0300 |
commit | ef2b4b14e1a917a18b059b49514b7974027d897d (patch) | |
tree | 0bd95eb14c1e0e4abd46f4f980e68b5b2d01867e /sql | |
parent | 4a03a1d777f2c2c4c921a5b52df5da362950b468 (diff) | |
parent | 678f4b2de17a6fa42a056422feb7d7c7f24092da (diff) | |
download | mariadb-git-ef2b4b14e1a917a18b059b49514b7974027d897d.tar.gz |
Merge from 5.2
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/opt_range.h | 4 | ||||
-rw-r--r-- | sql/records.cc | 9 | ||||
-rw-r--r-- | sql/sql_acl.cc | 21 | ||||
-rw-r--r-- | sql/sql_parse.cc | 23 | ||||
-rw-r--r-- | sql/sql_select.cc | 12 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 |
7 files changed, 40 insertions, 36 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 68184a94666..7284be312e3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1640,6 +1640,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group,bool asc); bool push_new_name_resolution_context(THD *thd, TABLE_LIST *left_op, TABLE_LIST *right_op); +Item *normalize_cond(Item *cond); void add_join_on(TABLE_LIST *b,Item *expr); void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields, SELECT_LEX *lex); diff --git a/sql/opt_range.h b/sql/opt_range.h index d7a0c1e2f8f..0ad2b7242f2 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -274,7 +274,6 @@ public: virtual bool reverse_sorted() = 0; virtual bool unique_key_range() { return false; } - virtual bool clustered_pk_range() { return false; } /* Request that this quick select produces sorted output. Not all quick @@ -593,9 +592,6 @@ public: MEM_ROOT alloc; THD *thd; virtual int read_keys_and_merge()= 0; - - bool clustered_pk_range() { return test(pk_quick_select); } - /* used to get rows collected in Unique */ READ_RECORD read_record; }; diff --git a/sql/records.cc b/sql/records.cc index 5ce7d8660e9..60c801f8977 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -195,15 +195,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, if (select && my_b_inited(&select->file)) tempfile= &select->file; - else if (select && select->quick && select->quick->clustered_pk_range()) - { - /* - In case of QUICK_INDEX_MERGE_SELECT with clustered pk range we have to - use its own access method(i.e QUICK_INDEX_MERGE_SELECT::get_next()) as - sort file does not contain rowids which satisfy clustered pk range. - */ - tempfile= 0; - } else tempfile= table->sort.io_cache; if (tempfile && my_b_inited(tempfile) && diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 742a20ab4f3..dc1405a00a4 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7565,21 +7565,15 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? (uchar)(*passwd++) : strlen(passwd); - if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) - { - db= db + passwd_len + 1; - /* strlen() can't be easily deleted without changing protocol */ - db_len= strlen(db); - } - else - { - db= 0; - db_len= 0; - } + db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? + db + passwd_len + 1 : 0; - if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len) + if (passwd + passwd_len + test(db) > (char *)net->read_pos + pkt_len) return packet_error; + /* strlen() can't be easily deleted without changing protocol */ + db_len= db ? strlen(db) : 0; + char *client_plugin= passwd + passwd_len + (db ? db_len + 1 : 0); /* Since 4.1 all database names are stored in utf8 */ @@ -7646,8 +7640,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, if (thd->client_capabilities & CLIENT_PLUGIN_AUTH) { - if ((client_plugin + strlen(client_plugin)) > - (char *)net->read_pos + pkt_len) + if (client_plugin >= (char *)net->read_pos + pkt_len) return packet_error; client_plugin= fix_plugin_ptr(client_plugin); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f10430b022c..18dad6cfff0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6795,6 +6795,28 @@ push_new_name_resolution_context(THD *thd, /** + Fix condition which contains only field (f turns to f <> 0 ) + + @param cond The condition to fix + + @return fixed condition +*/ + +Item *normalize_cond(Item *cond) +{ + if (cond) + { + Item::Type type= cond->type(); + if (type == Item::FIELD_ITEM || type == Item::REF_ITEM) + { + cond= new Item_func_ne(cond, new Item_int(0)); + } + } + return cond; +} + + +/** Add an ON condition to the second operand of a JOIN ... ON. Add an ON condition to the right operand of a JOIN ... ON clause. @@ -6812,6 +6834,7 @@ void add_join_on(TABLE_LIST *b, Item *expr) { if (expr) { + expr= normalize_cond(expr); if (!b->on_expr) b->on_expr= expr; else diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ee0ad5571d0..deb1fed4249 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13082,7 +13082,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, bool using_unique_constraint= 0; bool use_packed_rows= 0; bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS); - char *tmpname,path[FN_REFLEN], tmp_table_name[50]; + char *tmpname,path[FN_REFLEN]; uchar *pos, *group_buff, *bitmaps; uchar *null_flags; Field **reg_field, **from_field, **default_field; @@ -13113,12 +13113,12 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, temp_pool_slot = bitmap_lock_set_next(&temp_pool); if (temp_pool_slot != MY_BIT_NONE) // we got a slot - sprintf(tmp_table_name, "%s_%lx_%i", tmp_file_prefix, + sprintf(path, "%s_%lx_%i", tmp_file_prefix, current_pid, temp_pool_slot); else { /* if we run out of slots or we are not using tempool */ - sprintf(tmp_table_name, "%s%lx_%lx_%x", tmp_file_prefix,current_pid, + sprintf(path, "%s%lx_%lx_%x", tmp_file_prefix,current_pid, thd->thread_id, thd->tmp_table++); } @@ -13126,7 +13126,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, No need to change table name to lower case as we are only creating MyISAM, Aria or HEAP tables here */ - fn_format(path, tmp_table_name, mysql_tmpdir, "", + fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME); if (group) @@ -13179,7 +13179,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, sizeof(*key_part_info)*(param->group_parts+1), ¶m->start_recinfo, sizeof(*param->recinfo)*(field_count*2+4), - &tmpname, (uint) strlen(tmp_table_name)+1, + &tmpname, (uint) strlen(path)+1, &group_buff, (group && ! using_unique_constraint ? param->group_length : 0), &bitmaps, bitmap_buffer_size(field_count)*4, @@ -13198,7 +13198,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, DBUG_RETURN(NULL); /* purecov: inspected */ } param->items_to_copy= copy_func; - strmov(tmpname, tmp_table_name); + strmov(tmpname, path); /* make table according to fields */ bzero((char*) table,sizeof(*table)); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d2cef29cb08..c2fea985aa1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9426,7 +9426,7 @@ where_clause: expr { SELECT_LEX *select= Select; - select->where= $3; + select->where= normalize_cond($3); select->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -9442,7 +9442,7 @@ having_clause: expr { SELECT_LEX *sel= Select; - sel->having= $3; + sel->having= normalize_cond($3); sel->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -10909,7 +10909,7 @@ wild_and_where: } | WHERE expr { - Select->where= $2; + Select->where= normalize_cond($2); if ($2) $2->top_level_item(); } |