From fc6b6435b4c3f5203e6ffc3de289f0413a7ef33f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 6 Sep 2011 17:06:04 +0400 Subject: BUG#823930: Wrong result with semijoin materialization and blob fields - Make subquery_types_allow_materialization() detect a case where create_tmp_table() would create a blob column which would make it impossible to use materialization Non-semi-join materialization worked because it detected that this case and felt back to use IN->EXISTS. Semi-join Materialization cannot easily fallback, so we have to detect this case early. --- 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 ca4d41fcbdb..4fcffcfbc2a 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5191,6 +5191,10 @@ Field *Item::make_string_field(TABLE *table) { Field *field; DBUG_ASSERT(collation.collation); + /* + Note: the following check is repeated in + subquery_types_allow_materialization(): + */ if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB) field= new Field_blob(max_length, maybe_null, name, collation.collation); -- cgit v1.2.1 From 3769841d9e706ee018d5273d2901954b9a281c3e Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 8 Sep 2011 23:24:47 +0400 Subject: BUG#833600: Wrong result with view + outer join + uncorrelated subquery (non-semijoin) - The bug was caused by outer join being incorrectly converted into inner because of invalid return values of Item_direct_view_ref::not_null_tables(). - Provided a correct Item_direct_view_ref::not_null_tables() function. --- sql/item.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 4fcffcfbc2a..d0992a379e0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9106,6 +9106,12 @@ table_map Item_direct_view_ref::used_tables() const (view->merged ? (*ref)->used_tables() : view->table->map); } +table_map Item_direct_view_ref::not_null_tables() const +{ + return get_depended_from() ? + 0 : + (view->merged ? (*ref)->not_null_tables() : view->table->map); +} /* we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE -- cgit v1.2.1 From 5ebff8ab788923cfcc25862d6c9e11ea20801fa0 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 13 Sep 2011 23:45:02 +0400 Subject: BUG#730133: Wrong result with jkl = 7, BKA, ICP in maria-5.3 + compound index - Mrr_ordered_index_reader::interrupt_read() and resume_read() should save/restore not just index lookup tuple, but entire index tuple. Key parts that are not used for index lookup can be still used in pushed index condition. Failure to save/restore will cause the index condition to be evaluated over the wrong values. --- sql/item.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index d0992a379e0..02263106fe8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9124,7 +9124,22 @@ table_map Item_ref_null_helper::used_tables() const } +/* Debugger help function */ +static char dbug_item_print_buf[256]; +const char *dbug_print_item(Item *item) +{ + char *buf= dbug_item_print_buf; + String str(buf, sizeof(dbug_item_print_buf), &my_charset_bin); + str.length(0); + if (!item) + return "(Item*)NULL"; + item->print(&str ,QT_ORDINARY); + if (str.c_ptr() == buf) + return buf; + else + return "Couldn't fit into buffer"; +} /***************************************************************************** ** Instantiate templates *****************************************************************************/ -- cgit v1.2.1 From f0323a40d8cbc5228015c1565a4800fd05fd61a8 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 20 Sep 2011 20:40:07 +0400 Subject: BUG#849763: Wrong result with second execution of prepared statement with semijoin + view - The problem was that Item_direct_view_ref and its embedded Item_field were getting incorrect value of item->used_tables() after fix_fields() in the second and subsequent EXECUTE. - Made relevant fixes in Item_field::fix_fields() and find_field_in_tables(), so that the Item_field gets the correct attributes. --- sql/item.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 02263106fe8..a4cd292a5b1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4648,6 +4648,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (!outer_fixed && cached_table && cached_table->select_lex && context->select_lex && cached_table->select_lex != context->select_lex && + !context->select_lex->is_merged_child_of(cached_table->select_lex) && is_outer_table(cached_table, context->select_lex)) { int ret; -- cgit v1.2.1 From 829b1747f9acc3dee0061b6bd4ebaeb38bd7f2f2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 29 Sep 2011 20:12:57 +0200 Subject: make sure that cast(... as date) returns a valid date, as specified by the caller. make Item::send() request a date according to the current SQL mode limitations. --- 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 a4cd292a5b1..8710b8f9024 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5982,7 +5982,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_TIMESTAMP: { MYSQL_TIME tm; - get_date(&tm, TIME_FUZZY_DATE); + get_date(&tm, TIME_FUZZY_DATE | sql_mode_for_dates()); if (!null_value) { if (f_type == MYSQL_TYPE_DATE) -- cgit v1.2.1 From 945f12cf8fc361844f3553599795beb549fc8c1d Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 19 Oct 2011 23:28:37 -0700 Subject: Fixed LP bug #877316. This bug happened due to incompleteness of the fix for bug 872735: the occurrences of the fields in the conditions of correlated subqueries were not taken into account when recalculating covering keys bit maps. --- sql/item.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 8710b8f9024..4d516aa33f8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2172,6 +2172,12 @@ bool Item_field::enumerate_field_refs_processor(uchar *arg) return FALSE; } +bool Item_field::covering_keys_processor(uchar *arg) +{ + if (field && field->table) + field->table->covering_keys.intersect(field->part_of_key); + return FALSE; +} const char *Item_ident::full_name() const { -- cgit v1.2.1 From fdf789a7eadf864ecc0e617f25f795fafda55026 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 22 Oct 2011 00:14:27 -0700 Subject: Fixed LP bug #874378. This bug happened for the queries over multi-table mergeable views because the bitmap TABLE::read_set of the underlying tables were not updated after the views had been merged into the query. Now this bitmaps are updated properly. Also the bitmap TABLE::merge_keys now is updated in prevention of future bugs. --- 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 4d516aa33f8..f5ce0fbc7a7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2172,10 +2172,9 @@ bool Item_field::enumerate_field_refs_processor(uchar *arg) return FALSE; } -bool Item_field::covering_keys_processor(uchar *arg) +bool Item_field::update_table_bitmaps_processor(uchar *arg) { - if (field && field->table) - field->table->covering_keys.intersect(field->part_of_key); + update_table_bitmaps(); return FALSE; } -- cgit v1.2.1 From 2a3858d9d0bd0cccc6609388ff89096441193d5c Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 27 Oct 2011 08:32:24 -0700 Subject: Fixed LP bug #874035. The function Item_direct_view_ref::fix_fields erroneously did not correct the value of the flag maybe_null when the view for which the item was being fixed happened to be an inner table of an outer join. --- sql/item.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index f5ce0fbc7a7..2407de1bf30 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7321,7 +7321,11 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference) ((*ref)->fix_fields(thd, ref))) return TRUE; - return Item_direct_ref::fix_fields(thd, reference); + if (Item_direct_ref::fix_fields(thd, reference)) + return TRUE; + if (view->table && view->table->maybe_null) + maybe_null= TRUE; + return FALSE; } /* -- cgit v1.2.1 From b40bc2b3e3afee92a6d33d80840840fcf9baae11 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Nov 2011 17:42:52 +0200 Subject: Fix of LP BUG#872775. The problem was that merged views has its own nest_level numbering => when we compare nest levels we should take into considiration basis (i.e. 0 level), if it is different then nest levels are not comparable. --- sql/item.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index f5ce0fbc7a7..7056e1dd5d2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -755,7 +755,9 @@ bool Item_ident::remove_dependence_processor(uchar * arg) bool Item_ident::collect_outer_ref_processor(uchar *param) { Collect_deps_prm *prm= (Collect_deps_prm *)param; - if (depended_from && depended_from->nest_level < prm->nest_level) + if (depended_from && + depended_from->nest_level_base == prm->nest_level_base && + depended_from->nest_level < prm->nest_level) prm->parameters->add_unique(this, &cmp_items); return FALSE; } -- cgit v1.2.1