From 541cb675c87ae1efa1e1769abaed03e9535eaf27 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Feb 2004 20:14:13 +0200 Subject: fixed subquery with PS (BUG#2462) fixed UNION preparation sql/item.cc: debug output added sql/item.h: debug output added sql/item_cmpfunc.cc: correct cleunup() for Item_in_optimizer sql/item_cmpfunc.h: correct cleunup() for Item_in_optimizer debug output added sql/item_func.h: debug output added sql/item_subselect.cc: support of prepared statemnts added - mostly memorry allocation manegement, only one trabsformatio & correct cleupup() sql/item_subselect.h: support of prepared statemnts added - mostly memorry allocation manegement, only one trabsformatio & correct cleupup() sql/item_sum.cc: debug output added sql/item_sum.h: debug output added sql/sql_class.cc: function to switch allocation arena for Items sql/sql_class.h: function to switch allocation arena for Items pointer on current prepared statement added sql/sql_lex.cc: comment fixed sql/sql_lex.h: item cleanup support sql/sql_prepare.cc: - fixed preparation of PS to avoid storing junk in its memory + correct work with union - fixed tables cleanup for UNION & subqueries sql/sql_select.cc: removed condition which is always true for now fixed layout sql/sql_union.cc: support of UNION subquery cleanup tests/client_test.c: test of repeatable subqueries test of correct UNION initialisation --- sql/item.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 09328dfbf07..44878329373 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -966,8 +966,10 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) void Item_field::cleanup() { + DBUG_ENTER("Item_field::cleanup"); Item_ident::cleanup(); field= result_field= 0; + DBUG_VOID_RETURN; } void Item::init_make_field(Send_field *tmp_field, @@ -1610,9 +1612,11 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) void Item_ref::cleanup() { + DBUG_ENTER("Item_ref::cleanup"); Item_ident::cleanup(); if (hook_ptr) *hook_ptr= orig_item; + DBUG_VOID_RETURN; } -- cgit v1.2.1 From a07e48eca04b1564da9868f229ba5d958994db69 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Feb 2004 10:03:25 +0200 Subject: After merge fixes Added more DBUG statements Ensure that we are comparing end space with BINARY strings Use 'any_db' instead of '' to mean any database. (For HANDLER command) Only strip ' ' when comparing CHAR, not other space-like characters (like \t) BitKeeper/deleted/.del-ctype_tis620.result-old~3578ceb0b8284685: Delete: mysql-test/r/ctype_tis620.result-old BitKeeper/deleted/.del-ctype_tis620.test-old~ffb1bbd2935d1aba: Delete: mysql-test/t/ctype_tis620.test-old client/mysqlbinlog.cc: Added DBUG statements Added call of my_end() to free all used memory on exit heap/hp_info.c: After merge fixes heap/hp_open.c: After merge fixes include/heap.h: After merge fixes include/m_ctype.h: Use pchar instead of 'int' for character parameters. Added 'my_binary_compare()' include/m_string.h: Fixed wrong define innobase/ibuf/ibuf0ibuf.c: After merge fixes innobase/srv/srv0start.c: After merge fixes mysql-test/r/alter_table.result: Fixed results after merge mysql-test/r/auto_increment.result: Fixed results after merge mysql-test/r/bdb.result: Fixed results after merge mysql-test/r/binary.result: Fixed results after merge mysql-test/r/create.result: Fixed results after merge mysql-test/r/ctype_mb.result: Fixed results after merge mysql-test/r/ctype_tis620.result: Fixed results after merge mysql-test/r/ctype_utf8.result: Fixed results after merge mysql-test/r/delete.result: Fixed results after merge mysql-test/r/func_compress.result: Fixed results after merge mysql-test/r/func_gconcat.result: Fixed results after merge mysql-test/r/func_group.result: Fixed results after merge mysql-test/r/func_str.result: Fixed results after merge mysql-test/r/innodb.result: Fixed results after merge mysql-test/r/insert.result: Fixed results after merge mysql-test/r/insert_select.result: Fixed results after merge mysql-test/r/key.result: Fixed results after merge mysql-test/r/loaddata.result: Fixed results after merge mysql-test/r/lock.result: Fixed results after merge mysql-test/r/myisam.result: Fixed results after merge mysql-test/r/null.result: Fixed results after merge mysql-test/r/null_key.result: Fixed results after merge mysql-test/r/order_by.result: Fixed results after merge mysql-test/r/query_cache.result: Fixed results after merge mysql-test/r/range.result: Fixed results after merge mysql-test/r/rpl_multi_delete.result: Fixed results after merge mysql-test/r/rpl_until.result: Fixed results after merge mysql-test/r/subselect.result: Fixed results after merge mysql-test/r/subselect_innodb.result: Fixed results after merge mysql-test/r/type_blob.result: Fixed results after merge mysql-test/r/type_datetime.result: Fixed results after merge mysql-test/r/type_decimal.result: Fixed results after merge mysql-test/r/type_enum.result: Fixed results after merge mysql-test/r/type_float.result: Fixed results after merge mysql-test/r/type_ranges.result: Fixed results after merge mysql-test/r/type_time.result: Fixed results after merge mysql-test/r/type_timestamp.result: Fixed results after merge mysql-test/r/type_uint.result: Fixed results after merge mysql-test/r/type_year.result: Fixed results after merge mysql-test/r/variables.result: Fixed results after merge mysql-test/r/warnings.result: Fixed results after merge mysql-test/t/case.test: Fixed shifted error messages mysql-test/t/create.test: Fixed shifted error messages mysql-test/t/ctype_collate.test: Fixed shifted error messages mysql-test/t/ctype_tis620.test: Merge with 4.0 ctype_tis620 test mysql-test/t/delete.test: Fixed shifted error messages mysql-test/t/derived.test: Fixed shifted error messages mysql-test/t/fulltext.test: Fixed shifted error messages mysql-test/t/func_in.test: Fixed shifted error messages mysql-test/t/func_str.test: Fixed shifted error messages mysql-test/t/func_test.test: Fixed shifted error messages mysql-test/t/grant.test: Fixed shifted error messages mysql-test/t/innodb.test: Change to 4.1 syntax mysql-test/t/key_cache.test: Fixed shifted error messages mysql-test/t/myisam.test: New test of blob and end space mysql-test/t/row.test: Fixed shifted error messages mysql-test/t/rpl_until.test: Fixed shifted error messages mysql-test/t/subselect.test: Fixed shifted error messages mysql-test/t/subselect_innodb.test: Fix test to take into account foreign key constraints mysql-test/t/union.test: Fixed shifted error messages mysql-test/t/user_var.test: Fixed shifted error messages mysql-test/t/variables.test: Fixed shifted error messages mysys/my_handler.c: Merge with 4.0 code sql/ha_heap.cc: After merge fixes sql/handler.cc: After merge fixes sql/item.cc: After merge fixes sql/item_cmpfunc.cc: Ensure that we are comparing end space with BINARY strings sql/item_cmpfunc.h: Ensure that we are comparing end space with BINARY strings sql/log_event.cc: More DBUG statements Ensure that we use all options to LOAD DATA in replication sql/opt_range.cc: After merge fixes sql/sql_db.cc: After merge fixes sql/sql_handler.cc: After merge fixes Use 'any_db' instead of '' to mean 'no database comparison' sql/sql_parse.cc: After merge fixes sql/sql_select.cc: After merge fixes Added function comment for setup_group() sql/sql_string.cc: Added stringcmp() for binary comparison. Added function comments for sortcmp() and stringcmp() sql/sql_string.h: Added stringcmp() sql/sql_table.cc: After merge fixes sql/sql_update.cc: After merge fixes sql/sql_yacc.yy: Use 'any_db' instead of '' to mean any database. Using "" causes a 'wrong db name' error. strings/ctype-big5.c: Strip only end space, not other space characters. strings/ctype-bin.c: Removed some not needed functions. Added function comments Don't remove end space in comparisons Change my_wildcmp_bin() to be 'identical' with other similar code strings/ctype-czech.c: Strip only end space, not other space characters. strings/ctype-gbk.c: Strip only end space, not other space characters. strings/ctype-latin1.c: Strip only end space, not other space characters. strings/ctype-mb.c: Strip only end space, not other space characters. strings/ctype-simple.c: Strip only end space, not other space characters. strings/ctype-sjis.c: Strip only end space, not other space characters. strings/ctype-tis620.c: Added usage of my_instr_simple. This needs to be cleaned up! strings/ctype-utf8.c: Strip only end space, not other space characters. strings/ctype-win1250ch.c: Strip only end space, not other space characters. Fixed indentation strings/strto.c: Code cleanup --- sql/item.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 4d06d0d7765..b9a6a164a86 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -175,12 +175,13 @@ bool Item::eq(const Item *item, bool binary_cmp) const !my_strcasecmp(system_charset_info,name,item->name); } + bool Item_string::eq(const Item *item, bool binary_cmp) const { if (type() == item->type()) { if (binary_cmp) - return !sortcmp(&str_value, &item->str_value, &my_charset_bin); + return !stringcmp(&str_value, &item->str_value); return !sortcmp(&str_value, &item->str_value, collation.collation); } return 0; @@ -1823,7 +1824,7 @@ bool field_is_equal_to_item(Field *field,Item *item) if (item->null_value) return 1; // This must be true field->val_str(&field_tmp,&field_tmp); - return !sortcmp(&field_tmp,item_result,&my_charset_bin); + return !stringcmp(&field_tmp,item_result); } if (res_type == INT_RESULT) return 1; // Both where of type int -- cgit v1.2.1 From ae7eec928c86014f7eef3e48fa28196cf999434c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Feb 2004 01:08:52 +0200 Subject: revision of fix_fields() calls (BUG2838) mysql-test/r/subselect.result: test suite for BUG#2838 mysql-test/t/subselect.test: test suite for BUG#2838 sql/item.cc: revision of fix_fields() calls removed unnecessary variabl, and used correct last parameter of fix_fields() sql/item_cmpfunc.cc: revision of fix_fields() calls (BUG#2838) sql/item_func.cc: revision of fix_fields() calls sql/item_row.cc: changed for efficience (and to be similar for Item_func::fix_fields) sql/item_subselect.cc: fixed last arguments for fix_fields call sql/item_sum.cc: layout fixed revision of fix_fields() calls sql/log_event.cc: revision of fix_fields() calls sql/set_var.cc: revision of fix_fields() calls sql/sql_base.cc: revision of fix_fields() calls sql/sql_class.cc: revision of fix_fields() calls sql/sql_handler.cc: revision of fix_fields() calls --- sql/item.cc | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index eb2550fdbcc..9cf1ccb03ed 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -928,6 +928,10 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) (char *)field_name); if (!rf) return 1; + /* + rf is Item_ref => never substitute other items (in this case) + during fix_fields() => we can use rf after fix_fields() + */ if (rf->fix_fields(thd, tables, ref) || rf->check_cols(1)) return 1; @@ -946,6 +950,10 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) (char *)field_name); if (!rf) return 1; + /* + rf is Item_ref => never substitute other items (in this case) + during fix_fields() => we can use rf after fix_fields() + */ return rf->fix_fields(thd, tables, ref) || rf->check_cols(1); } } @@ -1654,16 +1662,15 @@ bool Item_default_value::eq(const Item *item, bool binary_cmp) const } -bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) +bool Item_default_value::fix_fields(THD *thd, + struct st_table_list *table_list, + Item **items) { if (!arg) - return false; - bool res= arg->fix_fields(thd, table_list, items); - if (res) - return res; - /* arg->type() can be only REF_ITEM or FIELD_ITEM for it defined as - simple_ident in sql_yacc.yy - */ + return 0; + if (arg->fix_fields(thd, table_list, &arg)) + return 1; + if (arg->type() == REF_ITEM) { Item_ref *ref= (Item_ref *)arg; @@ -1707,13 +1714,9 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) { - bool res= arg->fix_fields(thd, table_list, items); - if (res) - return res; - /* - arg->type() can be only REF_ITEM or FIELD_ITEM as arg is - a simple_ident in sql_yacc.yy - */ + if (arg->fix_fields(thd, table_list, &arg)) + return 1; + if (arg->type() == REF_ITEM) { Item_ref *ref= (Item_ref *)arg; -- cgit v1.2.1 From ef44fb9af3ee729de5897f290c13437bbbc09da5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Mar 2004 20:20:47 +0300 Subject: Fixes for bugs #2274 "mysqld gets SIGSEGV during processing of malformed COM_EXECUTE packet" and #2795 "prepare + execute without bind_param crashes server" and #2473 "seg fault running tests/client_test.c": - length checking added to packet parser - default impelemntation of Item_param::set_param_func will work in case of malformed packet. No test cases are possible in our test suite, as there are no tests operating on protocol layer. sql/item.cc: Default set_param function implemented: this is to not sigsegv in case of malformed packet with no parameters data. sql/item.h: - Item_param constructor moved to .cc to be able to assign set_param_func. - now embedded and ordinary versions of set_param have the same signature. sql/mysql_priv.h: mysql_stmt_execute now requires packet_length sql/sql_parse.cc: mysql_stmt_execute now requires packet length. sql/sql_prepare.cc: - length checking added to all functions working with network packet. - set_param_func's in embedded and ordinary version now have the same signature --- sql/item.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 5aaeffff5d2..bd3b89b396b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -517,7 +517,33 @@ String *Item_null::val_str(String *str) { null_value=1; return 0;} -/* Item_param related */ +/*********************** Item_param related ******************************/ + +/* + Default function of Item_param::set_param_func, so in case + of malformed packet the server won't SIGSEGV +*/ + +static void +default_set_param_func(Item_param *param, + uchar **pos __attribute__((unused)), + ulong len __attribute__((unused))) +{ + param->set_null(); +} + +Item_param::Item_param(unsigned position) : + value_is_set(FALSE), + item_result_type(STRING_RESULT), + item_type(STRING_ITEM), + item_is_time(FALSE), + long_data_supplied(FALSE), + pos_in_query(position), + set_param_func(default_set_param_func) +{ + name= (char*) "?"; +} + void Item_param::set_null() { DBUG_ENTER("Item_param::set_null"); -- cgit v1.2.1 From b0cfa449a6f35f0f9d061d7357131a83aa8d1b91 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Mar 2004 13:26:37 +0400 Subject: Fix for #233 (the second one) sql/field.cc: Field_geom::store() returns -1 as a sign of fatal error sql/field_conv.cc: set_field_to_null* return -1 now as the fatal error sql/item.cc: no sign inversions needed sql/opt_range.cc: -1 is the sign of fatal error now sql/sql_base.cc: -1 is the fatal error --- sql/item.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index bd3b89b396b..2e1935b23d4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -639,7 +639,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions) return 0; } String *result=val_str(&str_value); - return (field->store(result->ptr(),result->length(),field->charset())) ? -1 : 0; + return field->store(result->ptr(),result->length(),field->charset()); } bool Item_param::get_time(TIME *res) @@ -1236,7 +1236,7 @@ int Item::save_in_field(Field *field, bool no_conversions) field->set_notnull(); error=field->store(nr); } - return (error) ? -1 : 0; + return error; } @@ -1247,8 +1247,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions) if (null_value) return set_field_to_null(field); field->set_notnull(); - return (field->store(result->ptr(),result->length(),collation.collation)) ? - -1 : 0; + return field->store(result->ptr(),result->length(),collation.collation); } int Item_uint::save_in_field(Field *field, bool no_conversions) @@ -1267,7 +1266,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions) if (null_value) return set_field_to_null(field); field->set_notnull(); - return (field->store(nr)) ? -1 : 0; + return field->store(nr); } @@ -1277,7 +1276,7 @@ int Item_real::save_in_field(Field *field, bool no_conversions) if (null_value) return set_field_to_null(field); field->set_notnull(); - return (field->store(nr)) ? -1 : 0; + return field->store(nr); } /**************************************************************************** @@ -1339,7 +1338,7 @@ int Item_varbinary::save_in_field(Field *field, bool no_conversions) longlong nr=val_int(); error=field->store(nr); } - return (error) ? -1 : 0; + return error; } -- cgit v1.2.1 From f83cf4144065c12cad4007767e2e70d444fd0e05 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Mar 2004 14:26:26 +0200 Subject: DBUG_ASSERT(fixed == 0) added to fix_fields() sql/item.cc: layout fixed fixed bug in prepared statements with subqueries and outer references sql/item.h: neg_transformer get thd argument to call fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed Item_in_optimizer fixed flag neg_arguments(), neg_transformer() call fix_field() on created items to avoid bouble fix field or non-called fixfields() sql/item_cmpfunc.h: neg_transformer get thd argument to call fix_fields fixed forgoten cleanup() call of parent class sql/item_func.cc: DBUG_ASSERT(fixed == 0) and fixed flag check added to fix_fields() sql/item_func.h: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed forgoten cleanup() call of parent class sql/item_row.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() added forgoten 'fixed' flag set sql/item_subselect.cc: DBUG_ASSERT(fixed == 0) added to fix_fields() fixed subquery transformation sql/sql_base.cc: check of fixed flag added sql/sql_derived.cc: fixed cleunup union in derived table during EXPLAIN command processing sql/sql_select.cc: thd argument add to function to allow call fix_fields() of new created items fixed EXPLAIN double preparation check of fixed flag added eliminate_not_funcs fixed for corrcet fix_fields call of new created items sql/sql_select.h: thd argument add to function to allow call fix_fields() of new created items sql/sql_union.cc: union processing fixed tests/client_test.c: layout fixed new test of outer references fron subqueries --- sql/item.cc | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 45cd85d1775..c0eff7e85c2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -103,21 +103,33 @@ void Item::print_item_w_name(String *str) Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par) - :db_name(db_name_par),table_name(table_name_par),field_name(field_name_par), + :changed_during_fix_field(0), db_name(db_name_par), + table_name(table_name_par), field_name(field_name_par), depended_from(0) { name = (char*) field_name_par; } // Constructor used by Item_field & Item_ref (see Item comment) -Item_ident::Item_ident(THD *thd, Item_ident *item): - Item(thd, item), - db_name(item->db_name), - table_name(item->table_name), - field_name(item->field_name), - depended_from(item->depended_from) +Item_ident::Item_ident(THD *thd, Item_ident *item) + :Item(thd, item), + changed_during_fix_field(0), + db_name(item->db_name), + table_name(item->table_name), + field_name(item->field_name), + depended_from(item->depended_from) {} +void Item_ident::cleanup() +{ + Item::cleanup(); + if (changed_during_fix_field) + { + *changed_during_fix_field= this; + changed_during_fix_field= 0; + } +} + bool Item_ident::remove_dependence_processor(byte * arg) { DBUG_ENTER("Item_ident::remove_dependence_processor"); @@ -289,11 +301,14 @@ bool DTCollation::aggregate(DTCollation &dt) return 0; } -Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) +Item_field::Item_field(Field *f) + :Item_ident(NullS, f->table_name, f->field_name) +#ifndef DBUG_OFF + ,double_fix(0) +#endif { set_field(f); collation.set(DERIVATION_IMPLICIT); - fixed= 1; // This item is not needed in fix_fields } // Constructor need to process subselect with temporary tables (see Item) @@ -301,6 +316,9 @@ Item_field::Item_field(THD *thd, Item_field *item) :Item_ident(thd, item), field(item->field), result_field(item->result_field) +#ifndef DBUG_OFF + ,double_fix(0) +#endif { collation.set(DERIVATION_IMPLICIT); } @@ -786,6 +804,9 @@ bool Item::fix_fields(THD *thd, struct st_table_list *list, Item ** ref) { + + // We do not check fields which are fixed during construction + DBUG_ASSERT(fixed == 0 || type() == INT_ITEM || type() == CACHE_ITEM); fixed= 1; return 0; } @@ -847,6 +868,7 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { + DBUG_ASSERT(fixed == 0 || double_fix == 0); if (!field) // If field is not checked { TABLE_LIST *where= 0; @@ -952,6 +974,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ref, (char *)table_name, (char *)field_name); + register_item_tree_changing(ref); if (!rf) return 1; /* @@ -1005,6 +1028,11 @@ void Item_field::cleanup() { DBUG_ENTER("Item_field::cleanup"); Item_ident::cleanup(); + /* + Even if this object was created by direct link to field in setup_wild() + it will be linked correctly next tyme by name of field and table alias. + I.e. we can drop 'field'. + */ field= result_field= 0; DBUG_VOID_RETURN; } @@ -1480,6 +1508,7 @@ bool Item_field::send(Protocol *protocol, String *buffer) bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) { + DBUG_ASSERT(fixed == 0); uint counter; if (!ref) { @@ -1585,6 +1614,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) Item_field* fld; if (!((*reference)= fld= new Item_field(tmp))) return 1; + register_item_tree_changing(reference); mark_as_dependent(thd, last, thd->lex->current_select, fld); return 0; } @@ -1696,6 +1726,7 @@ bool Item_default_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) { + DBUG_ASSERT(fixed == 0); if (!arg) return 0; if (arg->fix_fields(thd, table_list, &arg)) @@ -1744,6 +1775,7 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) { + DBUG_ASSERT(fixed == 0); if (arg->fix_fields(thd, table_list, &arg)) return 1; -- cgit v1.2.1 From 257d8ede4bdc58f001c62c2cdea96241a876d19b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Mar 2004 16:49:48 +0400 Subject: Fix for #3188 mysql-test/r/subselect.result: appropriate test result mysql-test/t/subselect.test: test case sql/item.cc: we can get NULL here if the field isn't unique --- sql/item.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 657b8e1edbe..f684e0ea40c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -893,6 +893,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) table_list, &where, 0)) != not_found_field) { + if (!tmp) + return -1; prev_subselect_item->used_tables_cache|= tmp->table->map; prev_subselect_item->const_item_cache= 0; break; -- cgit v1.2.1 From 1a81e0414515cef6275b5d2f3f27b950aa1ff91f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Mar 2004 15:14:36 +0200 Subject: DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal --- sql/item.cc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 10 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index c0eff7e85c2..703eec0015b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -301,7 +301,7 @@ bool DTCollation::aggregate(DTCollation &dt) return 0; } -Item_field::Item_field(Field *f) +Item_field::Item_field(Field *f, bool already_fixed) :Item_ident(NullS, f->table_name, f->field_name) #ifndef DBUG_OFF ,double_fix(0) @@ -309,6 +309,7 @@ Item_field::Item_field(Field *f) { set_field(f); collation.set(DERIVATION_IMPLICIT); + fixed= already_fixed; } // Constructor need to process subselect with temporary tables (see Item) @@ -359,6 +360,7 @@ const char *Item_ident::full_name() const /* ARGSUSED */ String *Item_field::val_str(String *str) { + DBUG_ASSERT(fixed == 1); if ((null_value=field->is_null())) return 0; str->set_charset(str_value.charset()); @@ -367,6 +369,7 @@ String *Item_field::val_str(String *str) double Item_field::val() { + DBUG_ASSERT(fixed == 1); if ((null_value=field->is_null())) return 0.0; return field->val_real(); @@ -374,6 +377,7 @@ double Item_field::val() longlong Item_field::val_int() { + DBUG_ASSERT(fixed == 1); if ((null_value=field->is_null())) return 0; return field->val_int(); @@ -483,6 +487,7 @@ Item *Item_field::get_tmp_table_item(THD *thd) String *Item_int::val_str(String *str) { + DBUG_ASSERT(fixed == 1); str->set(value, &my_charset_bin); return str; } @@ -497,6 +502,7 @@ void Item_int::print(String *str) String *Item_uint::val_str(String *str) { + DBUG_ASSERT(fixed == 1); str->set((ulonglong) value, &my_charset_bin); return str; } @@ -512,6 +518,7 @@ void Item_uint::print(String *str) String *Item_real::val_str(String *str) { + DBUG_ASSERT(fixed == 1); str->set(value,decimals,&my_charset_bin); return str; } @@ -528,11 +535,25 @@ void Item_string::print(String *str) bool Item_null::eq(const Item *item, bool binary_cmp) const { return item->type() == type(); } -double Item_null::val() { null_value=1; return 0.0; } -longlong Item_null::val_int() { null_value=1; return 0; } +double Item_null::val() +{ + // NULL can be used without fix_fields + null_value=1; + return 0.0; +} +longlong Item_null::val_int() +{ + // NULL can be used without fix_fields + null_value=1; + return 0; +} /* ARGSUSED */ String *Item_null::val_str(String *str) -{ null_value=1; return 0;} +{ + // NULL can be used without fix_fields + null_value=1; + return 0; +} /*********************** Item_param related ******************************/ @@ -668,6 +689,7 @@ bool Item_param::get_time(TIME *res) double Item_param::val() { + DBUG_ASSERT(fixed == 1); int err; switch (item_result_type) { case STRING_RESULT: @@ -683,8 +705,9 @@ double Item_param::val() longlong Item_param::val_int() { - int err; - switch (item_result_type) { + DBUG_ASSERT(fixed == 1); + int err; + switch (item_result_type) { case STRING_RESULT: return my_strntoll(str_value.charset(), str_value.ptr(),str_value.length(),10, @@ -699,6 +722,7 @@ longlong Item_param::val_int() String *Item_param::val_str(String* str) { + DBUG_ASSERT(fixed == 1); switch (item_result_type) { case INT_RESULT: str->set(int_value, &my_charset_bin); @@ -717,7 +741,8 @@ String *Item_param::val_str(String* str) */ String *Item_param::query_val_str(String* str) -{ +{ + DBUG_ASSERT(fixed == 1); switch (item_result_type) { case INT_RESULT: case REAL_RESULT: @@ -790,6 +815,7 @@ void Item_copy_string::copy() /* ARGSUSED */ String *Item_copy_string::val_str(String *str) { + // Item_copy_string is used without fix_fields call if (null_value) return (String*) 0; return &str_value; @@ -806,29 +832,39 @@ bool Item::fix_fields(THD *thd, { // We do not check fields which are fixed during construction - DBUG_ASSERT(fixed == 0 || type() == INT_ITEM || type() == CACHE_ITEM); + DBUG_ASSERT(fixed == 0 || type() == INT_ITEM || type() == CACHE_ITEM || + type() == STRING_ITEM || type() == MYSQL_TYPE_DATETIME); fixed= 1; return 0; } double Item_ref_null_helper::val() { + DBUG_ASSERT(fixed == 1); double tmp= (*ref)->val_result(); owner->was_null|= null_value= (*ref)->null_value; return tmp; } + + longlong Item_ref_null_helper::val_int() { + DBUG_ASSERT(fixed == 1); longlong tmp= (*ref)->val_int_result(); owner->was_null|= null_value= (*ref)->null_value; return tmp; } + + String* Item_ref_null_helper::val_str(String* s) { + DBUG_ASSERT(fixed == 1); String* tmp= (*ref)->str_result(s); owner->was_null|= null_value= (*ref)->null_value; return tmp; } + + bool Item_ref_null_helper::get_date(TIME *ltime, uint fuzzydate) { return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate)); @@ -1352,6 +1388,7 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) longlong Item_varbinary::val_int() { + DBUG_ASSERT(fixed == 1); char *end=(char*) str_value.ptr()+str_value.length(), *ptr=end-min(str_value.length(),sizeof(longlong)); @@ -1612,7 +1649,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) { ref= 0; // To prevent "delete *ref;" on ~Item_erf() of this item Item_field* fld; - if (!((*reference)= fld= new Item_field(tmp))) + if (!((*reference)= fld= new Item_field(tmp, 1))) return 1; register_item_tree_changing(reference); mark_as_dependent(thd, last, thd->lex->current_select, fld); @@ -1728,7 +1765,10 @@ bool Item_default_value::fix_fields(THD *thd, { DBUG_ASSERT(fixed == 0); if (!arg) + { + fixed= 1; return 0; + } if (arg->fix_fields(thd, table_list, &arg)) return 1; @@ -1749,6 +1789,7 @@ bool Item_default_value::fix_fields(THD *thd, def_field->move_field(def_field->table->default_values - def_field->table->record[0]); set_field(def_field); + fixed= 1; return 0; } @@ -1806,6 +1847,7 @@ bool Item_insert_value::fix_fields(THD *thd, set_field(new Field_null(0, 0, Field::NONE, tmp_field->field_name, tmp_field->table, &my_charset_bin)); } + fixed= 1; return 0; } @@ -1969,7 +2011,8 @@ void Item_cache_str::store(Item *item) double Item_cache_str::val() -{ +{ + DBUG_ASSERT(fixed == 1); int err; if (value) return my_strntod(value->charset(), (char*) value->ptr(), @@ -1981,6 +2024,7 @@ double Item_cache_str::val() longlong Item_cache_str::val_int() { + DBUG_ASSERT(fixed == 1); int err; if (value) return my_strntoll(value->charset(), value->ptr(), -- cgit v1.2.1 From f379d7b172401206de5654f52466601de874cade Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 20 Mar 2004 13:36:26 +0200 Subject: after review changes sql/item.cc: removed double_fix & already_fixed in Item_field sql/item.h: added quick_fix_field() for cases when we are sure that no need full fix_field processing fixed neg() method for numeric constants to have the same logic as constant parser Item_null, Item_real, ... are constant which are fixed by creation sql/item_cmpfunc.h: right fix_fields in and_conds call sql/item_func.cc: changed Item_field constructor call fix_field emulation call sql/item_strfunc.cc: correct layout sql/item_subselect.cc: correct layout changed Item_field constructor call sql/item_sum.cc: changed Item_field constructor call sql/item_sum.h: changed Item_field constructor call sql/sql_base.cc: fixed layout right fix_fields calls sql/sql_help.cc: changed Item_field constructor call sql/sql_load.cc: changed Item_field constructor call sql/sql_parse.cc: constant changed sql/sql_select.cc: fixed layout fix_field emulation insted of real fix_fields call sql/sql_show.cc: changed Item_field constructor call sql/sql_union.cc: changed Item_field constructor call double_fix removed sql/sql_update.cc: renamed variable, fixed layout sql/sql_yacc.yy: typo fixed fix_fields emulation calls hegation of numbers fixed --- sql/item.cc | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 2a0afe27949..3df40dba5b7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -301,15 +301,12 @@ bool DTCollation::aggregate(DTCollation &dt) return 0; } -Item_field::Item_field(Field *f, bool already_fixed) +Item_field::Item_field(Field *f) :Item_ident(NullS, f->table_name, f->field_name) -#ifndef DBUG_OFF - ,double_fix(0) -#endif { set_field(f); collation.set(DERIVATION_IMPLICIT); - fixed= already_fixed; + fixed= 1; } // Constructor need to process subselect with temporary tables (see Item) @@ -317,9 +314,6 @@ Item_field::Item_field(THD *thd, Item_field *item) :Item_ident(thd, item), field(item->field), result_field(item->result_field) -#ifndef DBUG_OFF - ,double_fix(0) -#endif { collation.set(DERIVATION_IMPLICIT); } @@ -487,6 +481,7 @@ Item *Item_field::get_tmp_table_item(THD *thd) String *Item_int::val_str(String *str) { + // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); str->set(value, &my_charset_bin); return str; @@ -502,6 +497,7 @@ void Item_int::print(String *str) String *Item_uint::val_str(String *str) { + // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); str->set((ulonglong) value, &my_charset_bin); return str; @@ -518,6 +514,7 @@ void Item_uint::print(String *str) String *Item_real::val_str(String *str) { + // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); str->set(value,decimals,&my_charset_bin); return str; @@ -537,20 +534,23 @@ bool Item_null::eq(const Item *item, bool binary_cmp) const { return item->type() == type(); } double Item_null::val() { - // NULL can be used without fix_fields + // following assert is redundant, because fixed=1 assigned in constructor + DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; } longlong Item_null::val_int() { - // NULL can be used without fix_fields + // following assert is redundant, because fixed=1 assigned in constructor + DBUG_ASSERT(fixed == 1); null_value=1; return 0; } /* ARGSUSED */ String *Item_null::val_str(String *str) { - // NULL can be used without fix_fields + // following assert is redundant, because fixed=1 assigned in constructor + DBUG_ASSERT(fixed == 1); null_value=1; return 0; } @@ -832,8 +832,7 @@ bool Item::fix_fields(THD *thd, { // We do not check fields which are fixed during construction - DBUG_ASSERT(fixed == 0 || type() == INT_ITEM || type() == CACHE_ITEM || - type() == STRING_ITEM || type() == MYSQL_TYPE_DATETIME); + DBUG_ASSERT(fixed == 0 || basic_const_item()); fixed= 1; return 0; } @@ -904,7 +903,7 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { - DBUG_ASSERT(fixed == 0 || double_fix == 0); + DBUG_ASSERT(fixed == 0); if (!field) // If field is not checked { TABLE_LIST *where= 0; @@ -1341,6 +1340,10 @@ int Item_int::save_in_field(Field *field, bool no_conversions) return field->store(nr); } +Item_num *Item_uint::neg() +{ + return new Item_real(name, - ((double) value), 0, max_length); +} int Item_real::save_in_field(Field *field, bool no_conversions) { @@ -1383,10 +1386,12 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) } *ptr=0; // Keep purify happy collation.set(&my_charset_bin, DERIVATION_COERCIBLE); + fixed= 1; } longlong Item_varbinary::val_int() { + // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); char *end=(char*) str_value.ptr()+str_value.length(), *ptr=end-min(str_value.length(),sizeof(longlong)); @@ -1648,7 +1653,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) { ref= 0; // To prevent "delete *ref;" on ~Item_erf() of this item Item_field* fld; - if (!((*reference)= fld= new Item_field(tmp, 1))) + if (!((*reference)= fld= new Item_field(tmp))) return 1; register_item_tree_changing(reference); mark_as_dependent(thd, last, thd->lex->current_select, fld); -- cgit v1.2.1 From 560fc0379bead7a21537df20b80beb8b73cc7c48 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Mar 2004 15:43:13 +0200 Subject: aliases should be compared with my_strcasecmp (BUG#3251) some db comparison code cleupup removed compiler warnings mysql-test/r/lowercase_table.result: test for BUG#3251 mysql-test/t/lowercase_table.test: test for BUG#3251 sql/item.cc: simple strcmp can be used for db name comparison sql/set_var.h: changed initialisation order to satisfy compiler sql/sql_cache.cc: simple strcmp can be used for db name comparison sql/sql_db.cc: better use special cherset for files sql/sql_parse.cc: simple strcmp can be used for db name comparison aliases should be compared with my_strcasecmp sql/sql_select.cc: aliases should be compared with my_strcasecmp --- sql/item.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 3df40dba5b7..7549bac71b8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -456,9 +456,8 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const (!my_strcasecmp(table_alias_charset, item_field->table_name, table_name) && (!item_field->db_name || - (item_field->db_name && !my_strcasecmp(table_alias_charset, - item_field->db_name, - db_name)))))); + (item_field->db_name && !strcmp(item_field->db_name, + db_name)))))); } -- cgit v1.2.1 From b7b69c5d2fe953d2ffe5645e994a1d9c572098dc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Mar 2004 17:57:14 +0400 Subject: Fix for #3266 (garbled TEXT fields as a result of CREATE TABLE SELECT) Problem is that Item::save_in_field modifies str_value member before it calls val_str but Item_copy_string::val_str just returns this str_value as the result. I added local String variable to the Item::save_in_field mysql-test/r/create.result: appropriate test result mysql-test/t/create.test: test case sql/item.cc: local variable added to keep the result --- sql/item.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 7549bac71b8..59f3bc7077e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1282,8 +1282,8 @@ int Item::save_in_field(Field *field, bool no_conversions) String *result; CHARSET_INFO *cs= collation.collation; char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns - str_value.set_quick(buff,sizeof(buff),cs); - result=val_str(&str_value); + String loc_value(buff, sizeof(buff), cs); + result=val_str(&loc_value); if (null_value) return set_field_to_null_with_conversions(field, no_conversions); field->set_notnull(); -- cgit v1.2.1 From 054d2de499625fac668cff166af605a8106b8eaf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Mar 2004 22:11:22 +0200 Subject: Cleanups & safety fixes include/mysql.h: cleanup of load data infile patch libmysql/libmysql.c: cleanup of load data infile patch myisam/mi_search.c: Added missing assert.h mysql-test/r/func_time.result: Make test more secure mysql-test/t/func_time.test: Make test more secure sql/item.cc: restore to use str_value in item::save_in_field sql/item.h: Simple cleanup sql/item_cmpfunc.cc: Safety fix sql/item_cmpfunc.h: Simple optimization sql/item_func.cc: Updated comment sql/sql_base.cc: Simple optimization sql/sql_select.cc: Simple optimization sql/sql_union.cc: safey fixes --- sql/item.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index e889bbf1930..36b263f62cf 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -820,6 +820,16 @@ String *Item_copy_string::val_str(String *str) return &str_value; } + +int Item_copy_string::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store(str_value.ptr(),str_value.length(), + collation.collation); +} + /* Functions to convert item to field (for send_fields) */ @@ -1284,8 +1294,8 @@ int Item::save_in_field(Field *field, bool no_conversions) String *result; CHARSET_INFO *cs= collation.collation; char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns - String loc_value(buff, sizeof(buff), cs); - result=val_str(&loc_value); + str_value.set_quick(buff, sizeof(buff), cs); + result=val_str(&str_value); if (null_value) return set_field_to_null_with_conversions(field, no_conversions); field->set_notnull(); -- cgit v1.2.1 From f6a8ec5f925ec7d37d2858c5799b7a91a95accca Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Mar 2004 04:11:54 +0400 Subject: "Fix" for BUG #2050 "10 to 1 performance drop with server 4.1.1". Actually it is not a bug but right behavior observed as pefomance degradation after we have forced Item_field::fix_fields() to re-execute each time when we are executing prep stmt. This patch implements small optimization which heals this bad behavior. We are caching field position in TABLE::field array in Item's member and are using this position for speeding up field lookups in fix_fields() in case of its re-execution. sql/item.cc: Added cached_field_index member to Item_ident for caching field position in TABLE::field array for quicker field lookup in case fix_fields() is executed twice. sql/item.h: Added cached_field_index member to Item_ident for caching field position in TABLE::field array for quicker field lookup in case fix_fields() is executed twice. sql/mysql_priv.h: Now find_field_in_table has one more in-out parameter which is used for caching field index in TABLE::field array stored for quicker field look up. sql/sql_acl.cc: Now find_field_in_table has one more in-out parameter which is used for caching field index in TABLE::field array stored for quicker field look up. sql/sql_base.cc: Optimization: Now when we are looking up Field by its name we are caching its position in TABLE::field array in Item_ident::cached_field_index, so when we will call fix_fields() second time for this item (e.g. when we are re-executing prep statement) we can reuse this index to speed up this lookup. sql/table.cc: Now we storing in TABLE::name_hash pointers to elements of TABLE::field array, because this allows easily retrieve index of field in this array when it is looked up by its name. sql/table.h: Added comment claryfying what we store in TABLE::name_hash. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/item.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 124310b68d5..a919dc4c133 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -105,7 +105,7 @@ Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par) :changed_during_fix_field(0), db_name(db_name_par), table_name(table_name_par), field_name(field_name_par), - depended_from(0) + cached_field_index(-1), depended_from(0) { name = (char*) field_name_par; } @@ -117,6 +117,7 @@ Item_ident::Item_ident(THD *thd, Item_ident *item) db_name(item->db_name), table_name(item->table_name), field_name(item->field_name), + cached_field_index(item->cached_field_index), depended_from(item->depended_from) {} -- cgit v1.2.1 From ceeaa24d187b228fd6e8b1ac1e667d341155640f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Mar 2004 02:32:41 +0300 Subject: false/true -> FALSE/TRUE Fixes after last merge mysql-test/r/bdb-crash.result: fixed bad merge mysql-test/r/myisam.result: after merge fix mysql-test/r/order_by.result: fixed bad merge mysql-test/t/order_by.test: after merge fix sql/field_conv.cc: false/true -> FALSE/TRUE sql/handler.cc: false/true -> FALSE/TRUE sql/item.cc: false/true -> FALSE/TRUE sql/item_cmpfunc.cc: false/true -> FALSE/TRUE sql/item_sum.cc: false/true -> FALSE/TRUE sql/slave.cc: false/true -> FALSE/TRUE sql/sql_acl.cc: false/true -> FALSE/TRUE sql/sql_cache.cc: after merge fix sql/sql_help.cc: false/true -> FALSE/TRUE sql/sql_olap.cc: false/true -> FALSE/TRUE sql/sql_parse.cc: false/true -> FALSE/TRUE sql/sql_select.cc: fix after bad merge sql/sql_table.cc: fix after bad merge sql/sql_test.cc: false/true -> FALSE/TRUE --- sql/item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 36b263f62cf..48e35f06ec3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -637,7 +637,7 @@ void Item_param::set_time(TIME *tm, timestamp_type type) ltime.time_type= type; - item_is_time= true; + item_is_time= TRUE; item_type= STRING_ITEM; value_is_set= 1; } -- cgit v1.2.1 From d2906f0ed07bc06161d749d03ffa8acb7c09c785 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Mar 2004 21:25:55 +0400 Subject: Fix for Bug #3307 "FLUSH TABLES sometimes breaks prepared statement table resolution". Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Also now using special construnctor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. "Fix" for bug #2050 "10 to 1 performance drop with server 4.1.1" Clean ups in implementation of caching of field number in table. Added caching of table in which field is found in find_field_in_tables(). sql/item.cc: Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Added Item_ident::cached_table for caching table there we found our field. Added special constructor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. sql/item.h: Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Changed type of Item_ident::cached_field_index from int to uint (and so NO_CACHED_FIELD_INDEX is UINT_MAX now) because we want to save one comparison in find_field_in_table(). Added Item_ident::cached_table for caching table there we found our field. Added special constructor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. sql/mysql_priv.h: Changed type of cached_field_index_ptr from int* to uint* (and so NO_CACHED_FIELD_INDEX is UINT_MAX now) because we want to save one comparison in find_field_in_table(). sql/sql_acl.cc: Changed type of find_field_in_table() paremeter to make it faster. sql/sql_base.cc: find_field_in_table(): small optimization and soime clean ups in caching of field index. find_field_in_tables(): added aggresive caching of table in which field is found in Item_ident::cached_table. insert_fields(): using special construnctor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. --- sql/item.cc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index a919dc4c133..b4aa87cd4df 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -103,9 +103,12 @@ void Item::print_item_w_name(String *str) Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par) - :changed_during_fix_field(0), db_name(db_name_par), - table_name(table_name_par), field_name(field_name_par), - cached_field_index(-1), depended_from(0) + : + orig_db_name(db_name_par), orig_table_name(table_name_par), + orig_field_name(field_name_par), changed_during_fix_field(0), + db_name(db_name_par), table_name(table_name_par), + field_name(field_name_par), cached_field_index(NO_CACHED_FIELD_INDEX), + cached_table(0), depended_from(0) { name = (char*) field_name_par; } @@ -113,11 +116,15 @@ Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, // Constructor used by Item_field & Item_ref (see Item comment) Item_ident::Item_ident(THD *thd, Item_ident *item) :Item(thd, item), + orig_db_name(item->orig_db_name), + orig_table_name(item->orig_table_name), + orig_field_name(item->orig_field_name), changed_during_fix_field(0), db_name(item->db_name), table_name(item->table_name), field_name(item->field_name), cached_field_index(item->cached_field_index), + cached_table(item->cached_table), depended_from(item->depended_from) {} @@ -129,6 +136,9 @@ void Item_ident::cleanup() *changed_during_fix_field= this; changed_during_fix_field= 0; } + db_name= orig_db_name; + table_name= orig_table_name; + field_name= orig_field_name; } bool Item_ident::remove_dependence_processor(byte * arg) @@ -310,6 +320,15 @@ Item_field::Item_field(Field *f) fixed= 1; } +Item_field::Item_field(THD *thd, Field *f) + :Item_ident(NullS, thd->strdup(f->table_name), + thd->strdup(f->field_name)) +{ + set_field(f); + collation.set(DERIVATION_IMPLICIT); + fixed= 1; +} + // Constructor need to process subselect with temporary tables (see Item) Item_field::Item_field(THD *thd, Item_field *item) :Item_ident(thd, item), -- cgit v1.2.1 From d4074bbeb382be40006a6d5ac827ec9bb6af3770 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Apr 2004 23:27:22 +0300 Subject: removed unused field layout fised debug information added sql/item.cc: layout fix debug info sql/sql_class.h: removed unused field --- sql/item.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 9cad60b8197..8da4990942c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -103,8 +103,7 @@ void Item::print_item_w_name(String *str) Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par) - : - orig_db_name(db_name_par), orig_table_name(table_name_par), + :orig_db_name(db_name_par), orig_table_name(table_name_par), orig_field_name(field_name_par), changed_during_fix_field(0), db_name(db_name_par), table_name(table_name_par), field_name(field_name_par), cached_field_index(NO_CACHED_FIELD_INDEX), @@ -130,6 +129,11 @@ Item_ident::Item_ident(THD *thd, Item_ident *item) void Item_ident::cleanup() { + DBUG_ENTER("Item_ident::cleanup"); + DBUG_PRINT("enter", ("b:%s(%s), t:%s(%s), f:%s(%s)", + db_name, orig_db_name, + table_name, orig_table_name, + field_name, orig_field_name)); Item::cleanup(); if (changed_during_fix_field) { @@ -139,6 +143,7 @@ void Item_ident::cleanup() db_name= orig_db_name; table_name= orig_table_name; field_name= orig_field_name; + DBUG_VOID_RETURN; } bool Item_ident::remove_dependence_processor(byte * arg) -- cgit v1.2.1 From e65aed9cbd61f5fc3c7cd396d60a9d6cb1d9b218 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 3 Apr 2004 17:23:41 +0300 Subject: for Item_param we have to have value set instead of fave item fixed (BUG#3353) fixed outer joins test of different joins included sql/item.cc: for Item_param we have to have value set instead of fave item fixed sql/sql_base.cc: fixed PS with outer joins tests/client_test.c: test of different types of joins --- sql/item.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 8da4990942c..1efed78799a 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -713,7 +713,7 @@ bool Item_param::get_time(TIME *res) double Item_param::val() { - DBUG_ASSERT(fixed == 1); + DBUG_ASSERT(value_is_set == 1); int err; switch (item_result_type) { case STRING_RESULT: @@ -729,7 +729,7 @@ double Item_param::val() longlong Item_param::val_int() { - DBUG_ASSERT(fixed == 1); + DBUG_ASSERT(value_is_set == 1); int err; switch (item_result_type) { case STRING_RESULT: @@ -746,7 +746,7 @@ longlong Item_param::val_int() String *Item_param::val_str(String* str) { - DBUG_ASSERT(fixed == 1); + DBUG_ASSERT(value_is_set == 1); switch (item_result_type) { case INT_RESULT: str->set(int_value, &my_charset_bin); @@ -766,7 +766,7 @@ String *Item_param::val_str(String* str) String *Item_param::query_val_str(String* str) { - DBUG_ASSERT(fixed == 1); + DBUG_ASSERT(value_is_set == 1); switch (item_result_type) { case INT_RESULT: case REAL_RESULT: -- cgit v1.2.1 From 7873b89fc50d420a5f538a5b60faf79131f86c4f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Apr 2004 13:56:05 +0300 Subject: Fixed many compiler warnings Fixed bugs in group_concat with ORDER BY and DISTINCT (Bugs #2695, #3381 and #3319) Fixed crash when doing rollback in slave and the io thread catched up with the sql thread Set locked_in_memory properly include/mysql_com.h: Fixed compiler warning libmysqld/emb_qcache.cc: Removed not used variable libmysqld/lib_sql.cc: Removed not used variable myisam/mi_locking.c: Added comment myisam/mi_rnext.c: Fixed bug in concurrent insert myisam/mi_rprev.c: Simple optimization mysql-test/r/func_gconcat.result: New tests mysql-test/t/func_gconcat.test: New tests mysql-test/t/func_group.test: Cleanup sql-common/client.c: Removed compiler warning sql/derror.cc: Better comments sql/field.cc: Removed not used function/variable sql/field.h: Removed not needed variable sql/ha_innodb.cc: Removed not used function sql/item.cc: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_func.cc: Fixed compiler warning sql/item_geofunc.cc: Fixed compiler warning sql/item_sum.cc: Fixed bugs in group_concat and added more comments (Bugs #2695, #3381 and #3319) - field->abs_offset was not needed - Wrong assumption of field order in temporary table - Some not used variables removed - Added ORDER BY fields after argument fields so that code in sql_select.cc can move all fields to point to temporary tables, if needed. - Optimized loops sql/item_sum.h: Bug fixing and cleanup of group_concat() sql/log.cc: Removed wrong comment sql/log_event.cc: Removed compiler warning sql/mysqld.cc: Set locked_in_memory properly sql/protocol.cc: Removed compiler warning sql/set_var.cc: Code cleanup sql/slave.cc: Fixed crash when doing rollback in slave and the io thread catched up with the sql thread sql/sql_cache.cc: Removed compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Removed compiler warnings sql/sql_lex.cc: Removed not used lable sql/sql_lex.h: Removed compiler warnings sql/sql_parse.cc: Removed compiler warnings sql/sql_prepare.cc: Removed compiler warnings sql/sql_select.cc: Removed not used variables Added function comments sql/sql_show.cc: Removed compiler warnings sql/sql_yacc.yy: Fix for ORDER BY handling in GROUP_CONCAT() --- sql/item.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 48e35f06ec3..80086c3afd7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -746,7 +746,6 @@ String *Item_param::query_val_str(String* str) case INT_RESULT: case REAL_RESULT: return val_str(str); - break; default: str->set("'", 1, default_charset()); -- cgit v1.2.1