summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mjorgensen@blade09.mysql.com>2007-04-21 18:36:06 +0200
committerunknown <mjorgensen@blade09.mysql.com>2007-04-21 18:36:06 +0200
commitc94da3764fde2c4cb775317052b483df9f45d129 (patch)
tree0851ddec4a5985dab32ef88a70bd1a6286f42077 /sql
parent594f7bd2feb50a4d8e84aee13f722ab8b0bb6ce6 (diff)
parent8a702a1e7bc8268d9a9b176429d98f89a4024cf5 (diff)
downloadmariadb-git-c94da3764fde2c4cb775317052b483df9f45d129.tar.gz
Merge bk-internal:/home/bk/mysql-5.0
into blade09.mysql.com:/tmp/mmj/mysql-5.0-runtime
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_select.cc5
-rw-r--r--sql/sql_show.cc36
-rw-r--r--sql/sql_view.cc9
8 files changed, 62 insertions, 24 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 1c0ece8877b..4e4868db80c 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -811,8 +811,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)
@@ -823,8 +833,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 0c4a62aaa24..11b8d34ad65 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 778ea6e9496..d7c4a3eddef 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 6b605e96432..118609671b8 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -276,7 +276,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 de7de0d46e9..2ff29d684d1 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -468,6 +468,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, uchar *buf, uint length);
friend int subselect_union_engine::exec();
@@ -700,6 +701,13 @@ public:
};
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 1
#define ALTER_DROP_COLUMN 2
#define ALTER_CHANGE_COLUMN 4
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index dc018dd43bb..77565ca8f7b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5982,10 +5982,7 @@ make_join_readinfo(JOIN *join, ulonglong options)
*/
if (!ordered_set &&
(table == join->sort_by_table &&
- (!join->order || join->skip_sort_order ||
- test_if_skip_sort_order(tab, join->order, join->select_limit,
- 1))
- ) ||
+ (!join->order || join->skip_sort_order)) ||
(join->sort_by_table == (TABLE *) 1 && i != join->const_tables))
ordered_set= 1;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 8cf3dc022d9..be1355699ba 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2315,18 +2315,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 14d9aeb4df5..d717aea9a3e 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1279,13 +1279,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;
}