summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2007-04-21 00:33:56 +0400
committerevgen@moonbone.local <>2007-04-21 00:33:56 +0400
commit4434ff13a9b20b630f583589a4daa3dcb13f5aba (patch)
tree749783226569f93fbed5d272f9f7ced5a5859dfd /sql
parentbfac9ea67e0812d998a98cbfeae8345376a22511 (diff)
parent6c5d17ef56b43b8423a787e368fe0ce1b43bb792 (diff)
downloadmariadb-git-4434ff13a9b20b630f583589a4daa3dcb13f5aba.tar.gz
Merge moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.0-opt
into moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.1-opt
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.cc18
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_strfunc.h2
-rw-r--r--sql/item_subselect.h6
-rw-r--r--sql/sql_lex.h8
-rw-r--r--sql/sql_show.cc36
-rw-r--r--sql/sql_view.cc9
7 files changed, 61 insertions, 20 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 277c306f4f2..54b1440aae4 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -864,8 +864,18 @@ int Arg_comparator::compare_row()
if (owner->null_value)
{
// NULL was compared
- if (owner->abort_on_null)
- return -1; // We do not need correct NULL returning
+ switch (owner->functype()) {
+ case Item_func::NE_FUNC:
+ break; // NE never aborts on NULL even if abort_on_null is set
+ case Item_func::LT_FUNC:
+ case Item_func::LE_FUNC:
+ case Item_func::GT_FUNC:
+ case Item_func::GE_FUNC:
+ return -1; // <, <=, > and >= always fail on NULL
+ default: // EQ_FUNC
+ if (owner->abort_on_null)
+ return -1; // We do not need correct NULL returning
+ }
was_null= 1;
owner->null_value= 0;
res= 0; // continue comparison (maybe we will meet explicit difference)
@@ -876,8 +886,8 @@ int Arg_comparator::compare_row()
if (was_null)
{
/*
- There was NULL(s) in comparison in some parts, but there was not
- explicit difference in other parts, so we have to return NULL
+ There was NULL(s) in comparison in some parts, but there was no
+ explicit difference in other parts, so we have to return NULL.
*/
owner->null_value= 1;
return -1;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index d6fc1e3dda0..f35b6a126ed 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -333,7 +333,7 @@ public:
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
uint decimal_precision() const { return 1; }
- void top_level_item() { abort_on_null=1; }
+ void top_level_item() { abort_on_null= TRUE; }
friend class Arg_comparator;
};
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 1bf8dfbfe7e..60e7de42a9d 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -790,7 +790,7 @@ class Item_func_crc32 :public Item_int_func
{
String value;
public:
- Item_func_crc32(Item *a) :Item_int_func(a) {}
+ Item_func_crc32(Item *a) :Item_int_func(a) { unsigned_flag= 1; }
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
longlong val_int();
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 37264f2136f..7c21eac6ec3 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -277,7 +277,11 @@ public:
{
return pushed_cond_guards ? pushed_cond_guards + i : NULL;
}
- void set_cond_guard_var(int i, bool v) { pushed_cond_guards[i]= v; }
+ void set_cond_guard_var(int i, bool v)
+ {
+ if ( pushed_cond_guards)
+ pushed_cond_guards[i]= v;
+ }
bool have_guarded_conds() { return test(pushed_cond_guards); }
Item_func_not_all *upper_item; // point on NOT/NOP before ALL/SOME subquery
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 850586c6098..1175776ffd3 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -541,6 +541,7 @@ public:
bool change_result(select_subselect *result, select_subselect *old_result);
void set_limit(st_select_lex *values);
void set_thd(THD *thd_arg) { thd= thd_arg; }
+ inline bool is_union ();
friend void lex_start(THD *thd, const char *buf, uint length);
friend int subselect_union_engine::exec();
@@ -795,6 +796,13 @@ private:
};
typedef class st_select_lex SELECT_LEX;
+
+inline bool st_select_lex_unit::is_union ()
+{
+ return first_select()->next_select() &&
+ first_select()->next_select()->linkage == UNION_TYPE;
+}
+
#define ALTER_ADD_COLUMN (1L << 0)
#define ALTER_DROP_COLUMN (1L << 1)
#define ALTER_CHANGE_COLUMN (1L << 2)
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0d620d33dbb..f1fd246d28d 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2733,18 +2733,32 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
res= open_normal_and_derived_tables(thd, show_table_list,
MYSQL_LOCK_IGNORE_FLUSH);
lex->sql_command= save_sql_command;
- /*
- We should use show_table_list->alias instead of
- show_table_list->table_name because table_name
- could be changed during opening of I_S tables. It's safe
- to use alias because alias contains original table name
- in this case.
+ /*
+ They can drop table after table names list creation and
+ before table opening. We open non existing table and
+ get ER_NO_SUCH_TABLE error. In this case we do not store
+ the record into I_S table and clear error.
*/
- res= schema_table->process_table(thd, show_table_list, table,
- res, orig_base_name,
- show_table_list->alias);
- close_tables_for_reopen(thd, &show_table_list);
- DBUG_ASSERT(!lex->query_tables_own_last);
+ if (thd->net.last_errno == ER_NO_SUCH_TABLE)
+ {
+ res= 0;
+ thd->clear_error();
+ }
+ else
+ {
+ /*
+ We should use show_table_list->alias instead of
+ show_table_list->table_name because table_name
+ could be changed during opening of I_S tables. It's safe
+ to use alias because alias contains original table name
+ in this case.
+ */
+ res= schema_table->process_table(thd, show_table_list, table,
+ res, orig_base_name,
+ show_table_list->alias);
+ close_tables_for_reopen(thd, &show_table_list);
+ DBUG_ASSERT(!lex->query_tables_own_last);
+ }
if (res)
goto err;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index f84847f2f9c..ee99a2974f4 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1270,13 +1270,18 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
unit->slave= save_slave; // fix include_down initialisation
}
+ /*
+ We can safely ignore the VIEW's ORDER BY if we merge into union
+ branch, as order is not important there.
+ */
+ if (!table->select_lex->master_unit()->is_union())
+ table->select_lex->order_list.push_back(&lex->select_lex.order_list);
/*
This SELECT_LEX will be linked in global SELECT_LEX list
to make it processed by mysql_handle_derived(),
but it will not be included to SELECT_LEX tree, because it
will not be executed
- */
- table->select_lex->order_list.push_back(&lex->select_lex.order_list);
+ */
goto ok;
}