summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-02-26 16:06:31 +0300
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-02-26 16:06:31 +0300
commit84766b060a09ae3709fcd17cadc16c982c0d3a78 (patch)
treed57dcac492c1a0c330c28bcf82a1d33db6111e5b /sql
parenta7dd42b57db41efc174b640f20bf9aff02f88415 (diff)
parent03561d35e30807e841c8544a6f5c07d708c6acbd (diff)
downloadmariadb-git-84766b060a09ae3709fcd17cadc16c982c0d3a78.tar.gz
Manual merge from mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts: Text conflict in scripts/Makefile.am Text conflict in sql/share/Makefile.am
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item_cmpfunc.h18
-rw-r--r--sql/share/Makefile.am8
-rw-r--r--sql/sql_select.cc35
4 files changed, 44 insertions, 21 deletions
diff --git a/sql/item.cc b/sql/item.cc
index a30c1dafac8..ced3afcc1c6 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2210,14 +2210,14 @@ 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);
+ str->set_int(value, unsigned_flag, &my_charset_bin);
return str;
}
void Item_int::print(String *str, enum_query_type query_type)
{
// my_charset_bin is good enough for numbers
- str_value.set(value, &my_charset_bin);
+ str_value.set_int(value, unsigned_flag, &my_charset_bin);
str->append(str_value);
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index f498873a7ad..c3afeebb577 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1477,9 +1477,21 @@ public:
Item_cond(THD *thd, Item_cond *item);
Item_cond(List<Item> &nlist)
:Item_bool_func(), list(nlist), abort_on_null(0) {}
- bool add(Item *item) { return list.push_back(item); }
- bool add_at_head(Item *item) { return list.push_front(item); }
- void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
+ bool add(Item *item)
+ {
+ DBUG_ASSERT(item);
+ return list.push_back(item);
+ }
+ bool add_at_head(Item *item)
+ {
+ DBUG_ASSERT(item);
+ return list.push_front(item);
+ }
+ void add_at_head(List<Item> *nlist)
+ {
+ DBUG_ASSERT(nlist->elements);
+ list.prepand(nlist);
+ }
bool fix_fields(THD *, Item **ref);
enum Type type() const { return COND_ITEM; }
diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am
index 06b349d5de2..b7a9e4ca78b 100644
--- a/sql/share/Makefile.am
+++ b/sql/share/Makefile.am
@@ -22,7 +22,7 @@ dist-hook:
test -d $(distdir)/$$dir || mkdir $(distdir)/$$dir; \
$(INSTALL_DATA) $(srcdir)/$$dir/*.* $(distdir)/$$dir; \
done; \
- sleep 1 ; touch $(srcdir)/*/errmsg.sys
+ sleep 1 ; touch $(builddir)/*/errmsg.sys
$(INSTALL_DATA) $(srcdir)/charsets/README $(distdir)/charsets
$(INSTALL_DATA) $(srcdir)/charsets/Index.xml $(distdir)/charsets
@@ -39,11 +39,11 @@ install-data-local:
for lang in @AVAILABLE_LANGUAGES@; \
do \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$$lang; \
- $(INSTALL_DATA) $(srcdir)/$$lang/errmsg.sys \
+ $(INSTALL_DATA) $(builddir)/$$lang/errmsg.sys \
$(DESTDIR)$(pkgdatadir)/$$lang/errmsg.sys; \
done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets
- $(INSTALL_DATA) $(srcdir)/errmsg-utf8.txt \
+ $(INSTALL_DATA) $(builddir)/errmsg-utf8.txt \
$(DESTDIR)$(pkgdatadir)/errmsg-utf8.txt; \
$(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README
$(INSTALL_DATA) $(srcdir)/charsets/*.xml $(DESTDIR)$(pkgdatadir)/charsets
@@ -53,7 +53,7 @@ uninstall-local:
@RM@ -f -r $(DESTDIR)$(pkgdatadir)
distclean-local:
- @RM@ -f */errmsg.sys
+ @RM@ -f $(builddir)/*/errmsg.sys
# Do nothing
link_sources:
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b79ab3e9699..272ee7b00fa 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7135,9 +7135,11 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab)
}
if (order)
{
- found++;
- DBUG_ASSERT(!(order->used & map));
- order->used|=map;
+ if (!(order->used & map))
+ {
+ found++;
+ order->used|= map;
+ }
continue; // Used in ORDER BY
}
if (!only_eq_ref_tables(join,start_order, (*ref_item)->used_tables()))
@@ -8305,7 +8307,8 @@ static Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
else
{
DBUG_ASSERT(cond->type() == Item::COND_ITEM);
- ((Item_cond *) cond)->add_at_head(&eq_list);
+ if (eq_list.elements)
+ ((Item_cond *) cond)->add_at_head(&eq_list);
}
cond->quick_fix_field();
@@ -13424,12 +13427,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
if (select_limit >= table_records)
{
- /*
- filesort() and join cache are usually faster than reading in
- index order and not using join cache
- */
- if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1)
- DBUG_RETURN(0);
keys= *table->file->keys_to_use_for_scanning();
keys.merge(table->covering_keys);
@@ -13579,6 +13576,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
}
}
+
+ /*
+ filesort() and join cache are usually faster than reading in
+ index order and not using join cache, except in case that chosen
+ index is clustered primary key.
+ */
+ if ((select_limit >= table_records) &&
+ (tab->type == JT_ALL &&
+ tab->join->tables > tab->join->const_tables + 1) &&
+ ((unsigned) best_key != table->s->primary_key ||
+ !table->file->primary_key_is_clustered()))
+ DBUG_RETURN(0);
+
if (best_key >= 0)
{
bool quick_created= FALSE;
@@ -15790,7 +15800,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
Item_cond_and *cond=new Item_cond_and();
TABLE *table=join_tab->table;
- int error;
+ int error= 0;
if (!cond)
DBUG_RETURN(TRUE);
@@ -15808,7 +15818,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
cond->fix_fields(thd, (Item**)&cond);
if (join_tab->select)
{
- error=(int) cond->add(join_tab->select->cond);
+ if (join_tab->select->cond)
+ error=(int) cond->add(join_tab->select->cond);
join_tab->select_cond=join_tab->select->cond=cond;
}
else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0,