Commit 99e70d4f authored by unknown's avatar unknown

many bug fixes


mysql-test/t/subselect.test:
  fixing problems with aliases being forced on derived tables
sql/item_func.cc:
  Fixing a bug that caused MySQL to crash on SELECT ...GROUP BY func(feilds)
sql/item_sum.cc:
  Making us compatible with ISO C++ paragrah 7.1.9.4
sql/item_sum.h:
  Making us compatible with ISO C++ paragrah 7.1.9.4
sql/sql_derived.cc:
  Fixing two more bugs in derived tables.
  
  One in EXPLAIN and another causing wrong result in opt_sum_query()
sql/sql_yacc.yy:
  Making possible INSERT from SELECT list_of_constants
parent fc070bfd
......@@ -15,12 +15,11 @@ SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
-- error 1054
SELECT 1 FROM (SELECT (SELECT a) b) c;
SELECT 1 FROM (SELECT (SELECT a));
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id LIMIT 1);
-- error 1239
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
SELECT * FROM (SELECT 1)a WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
......
......@@ -108,8 +108,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
Set return character set to first argument if we are returning a
string.
*/
if (result_type() == STRING_RESULT)
set_charset((*args)->charset());
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{
if ((*arg)->check_cols(allowed_arg_cols) ||
......@@ -123,6 +121,8 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
used_tables_cache|=(*arg)->used_tables();
const_item_cache&= (*arg)->const_item();
}
if (result_type() == STRING_RESULT)
set_charset((*args)->charset());
}
fix_length_and_dec();
fixed= 1;
......
......@@ -41,7 +41,7 @@ Item_sum::Item_sum(List<Item> &list)
list.empty(); // Fields are used
}
void Item_sum::mark_as_sum_func()
inline void Item_sum::mark_as_sum_func()
{
current_thd->lex.current_select->with_sum_func= with_sum_func= 1;
}
......
......@@ -34,6 +34,7 @@ class Item_sum :public Item_result_field
uint arg_count;
bool quick_group; /* If incremental update of fields */
inline void mark_as_sum_func();
Item_sum() : arg_count(0),quick_group(1)
{
mark_as_sum_func();
......@@ -54,7 +55,6 @@ class Item_sum :public Item_result_field
}
Item_sum(List<Item> &list);
~Item_sum() { result_field=0; }
inline void mark_as_sum_func();
enum Type type() const { return SUM_FUNC_ITEM; }
virtual enum Sumfunctype sum_func () const=0;
......
......@@ -107,9 +107,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
table->derived_select_number= sl->select_number;
table->tmp_table=TMP_TABLE;
if (lex->describe)
tables->table_list->table=tables->table; // to fix a problem in EXPLAIN
else
sl->exclude();
t->db=(char *)"";
t->derived=(SELECT_LEX *)0; // just in case ...
table->file->info(HA_STATUS_VARIABLE);
}
}
delete derived_result;
......
......@@ -2977,7 +2977,7 @@ insert_values:
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
mysql_init_select(lex);
}
select_options select_item_list select_from select_lock_type
select_options select_item_list opt_select_from select_lock_type
union_clause {}
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment