Commit 83702648 authored by unknown's avatar unknown

fixed test of cardinality


mysql-test/r/subselect.result:
  test of cardinality error
mysql-test/t/subselect.test:
  test of cardinality error
parent 50662949
...@@ -120,6 +120,8 @@ SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); ...@@ -120,6 +120,8 @@ SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
(SELECT 1.5,'c','a') = ROW(1.5,2,'a') (SELECT 1.5,'c','a') = ROW(1.5,2,'a')
0 0
SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
Cardinality error (more/less than 1 columns)
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (a int); create table t3 (a int);
......
...@@ -51,6 +51,9 @@ SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); ...@@ -51,6 +51,9 @@ SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
-- error 1239
SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (a int); create table t3 (a int);
......
...@@ -606,7 +606,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -606,7 +606,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
(char *)field_name); (char *)field_name);
if (!r) if (!r)
return 1; return 1;
if (r->check_cols(1) || r->fix_fields(thd, tables, ref)) if (r->fix_fields(thd, tables, ref) || r->check_cols(1))
return 1; return 1;
r->depended_from= last; r->depended_from= last;
cursel->mark_as_dependent(last); cursel->mark_as_dependent(last);
...@@ -630,7 +630,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -630,7 +630,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (!rf) if (!rf)
return 1; return 1;
(rf)->outer_resolving= outer_resolving; (rf)->outer_resolving= outer_resolving;
return rf->check_cols(1) || rf->fix_fields(thd, tables, ref); return rf->fix_fields(thd, tables, ref) || rf->check_cols(1);
} }
} }
} }
......
...@@ -913,10 +913,10 @@ double Item_func_case::val() ...@@ -913,10 +913,10 @@ double Item_func_case::val()
bool bool
Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ {
if (first_expr && (first_expr->check_cols(1) || if (first_expr && (first_expr->fix_fields(thd, tables, &first_expr) ||
first_expr->fix_fields(thd, tables, &first_expr)) || first_expr->check_cols(1)) ||
else_expr && (else_expr->check_cols(1) || else_expr && (else_expr->fix_fields(thd, tables, &else_expr) ||
else_expr->fix_fields(thd, tables, &else_expr))) else_expr->check_cols(1)))
return 1; return 1;
if (Item_func::fix_fields(thd, tables, ref)) if (Item_func::fix_fields(thd, tables, ref))
return 1; return 1;
...@@ -1473,7 +1473,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1473,7 +1473,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
if (abort_on_null) if (abort_on_null)
item->top_level_item(); item->top_level_item();
if (item->check_cols(1) || item->fix_fields(thd, tables, li.ref())) if (item->fix_fields(thd, tables, li.ref()) || item->check_cols(1))
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
used_tables_cache|=item->used_tables(); used_tables_cache|=item->used_tables();
with_sum_func= with_sum_func || item->with_sum_func; with_sum_func= with_sum_func || item->with_sum_func;
...@@ -1785,10 +1785,8 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) ...@@ -1785,10 +1785,8 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref)
bool bool
Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ {
if (args[0]->check_cols(1) || if (args[0]->fix_fields(thd, tables, args) || args[0]->check_cols(1) ||
args[1]->check_cols(1) || args[1]->fix_fields(thd,tables, args + 1) || args[1]->check_cols(1))
args[0]->fix_fields(thd, tables, args) ||
args[1]->fix_fields(thd,tables, args + 1))
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func; with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
max_length= 1; max_length= 1;
......
...@@ -275,8 +275,7 @@ class Item_func_interval :public Item_int_func ...@@ -275,8 +275,7 @@ class Item_func_interval :public Item_int_func
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref) bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref)
{ {
return (item->check_cols(1) || return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
Item_func::fix_fields(thd, tlist, ref)); Item_func::fix_fields(thd, tlist, ref));
} }
void fix_length_and_dec(); void fix_length_and_dec();
......
...@@ -110,8 +110,8 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -110,8 +110,8 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
*/ */
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++) for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{ {
if ((*arg)->check_cols(allowed_arg_cols) || if ((*arg)->fix_fields(thd, tables, arg) ||
(*arg)->fix_fields(thd, tables, arg)) (*arg)->check_cols(allowed_arg_cols))
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
if ((*arg)->maybe_null) if ((*arg)->maybe_null)
maybe_null=1; maybe_null=1;
...@@ -1323,7 +1323,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, ...@@ -1323,7 +1323,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func,
arg != arg_end ; arg != arg_end ;
arg++,i++) arg++,i++)
{ {
if ((*arg)->check_cols(1) || (*arg)->fix_fields(thd, tables, arg)) if ((*arg)->fix_fields(thd, tables, arg) || (*arg)->check_cols(1))
return 1; return 1;
if ((*arg)->binary()) if ((*arg)->binary())
func->set_charset(my_charset_bin); func->set_charset(my_charset_bin);
...@@ -2331,7 +2331,7 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) ...@@ -2331,7 +2331,7 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
while ((item=li++)) while ((item=li++))
{ {
if (item->check_cols(1) || item->fix_fields(thd, tlist, li.ref())) if (item->fix_fields(thd, tlist, li.ref()) || item->check_cols(1))
return 1; return 1;
if (item->type() == Item::REF_ITEM) if (item->type() == Item::REF_ITEM)
li.replace(item= *((Item_ref *)item)->ref); li.replace(item= *((Item_ref *)item)->ref);
......
...@@ -608,8 +608,7 @@ class Item_func_field :public Item_int_func ...@@ -608,8 +608,7 @@ class Item_func_field :public Item_int_func
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref) bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref)
{ {
return (item->check_cols(1) || return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
Item_func::fix_fields(thd, tlist, ref)); Item_func::fix_fields(thd, tlist, ref));
} }
void update_used_tables() void update_used_tables()
......
...@@ -2131,7 +2131,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I ...@@ -2131,7 +2131,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I
if (thd && check_stack_overrun(thd,buff)) if (thd && check_stack_overrun(thd,buff))
return 0; // Fatal error if flag is set! return 0; // Fatal error if flag is set!
if (args[0]->check_cols(1) || args[0]->fix_fields(thd, tables, args)) if (args[0]->fix_fields(thd, tables, args) || args[0]->check_cols(1))
return 1; return 1;
maybe_null=args[0]->maybe_null; maybe_null=args[0]->maybe_null;
const_item_cache=args[0]->const_item(); const_item_cache=args[0]->const_item();
...@@ -2164,7 +2164,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, ...@@ -2164,7 +2164,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables,
if (thd && check_stack_overrun(thd,buff)) if (thd && check_stack_overrun(thd,buff))
return 0; // Fatal error if flag is set! return 0; // Fatal error if flag is set!
if (args[0]->check_cols(1) || args[0]->fix_fields(thd, tables, args)) if (args[0]->fix_fields(thd, tables, args) || args[0]->check_cols(1))
return 1; return 1;
maybe_null=args[0]->maybe_null; maybe_null=args[0]->maybe_null;
set_charset(set_collation); set_charset(set_collation);
......
...@@ -101,8 +101,8 @@ class Item_func_concat_ws :public Item_str_func ...@@ -101,8 +101,8 @@ class Item_func_concat_ws :public Item_str_func
void update_used_tables(); void update_used_tables();
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{ {
return (separator->check_cols(1) || return (separator->fix_fields(thd, tlist, &separator) ||
separator->fix_fields(thd, tlist, &separator) || separator->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref)); Item_func::fix_fields(thd, tlist, ref));
} }
const char *func_name() const { return "concat_ws"; } const char *func_name() const { return "concat_ws"; }
...@@ -382,8 +382,8 @@ class Item_func_elt :public Item_str_func ...@@ -382,8 +382,8 @@ class Item_func_elt :public Item_str_func
String *val_str(String *str); String *val_str(String *str);
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{ {
return (item->check_cols(1) || return (item->fix_fields(thd, tlist, &item) ||
item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref)); Item_func::fix_fields(thd, tlist, ref));
} }
void fix_length_and_dec(); void fix_length_and_dec();
...@@ -415,8 +415,8 @@ class Item_func_make_set :public Item_str_func ...@@ -415,8 +415,8 @@ class Item_func_make_set :public Item_str_func
String *val_str(String *str); String *val_str(String *str);
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{ {
return (item->check_cols(1) || return (item->fix_fields(thd, tlist, &item) ||
item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref)); Item_func::fix_fields(thd, tlist, ref));
} }
void fix_length_and_dec(); void fix_length_and_dec();
......
...@@ -119,7 +119,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -119,7 +119,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
maybe_null=0; maybe_null=0;
for (uint i=0 ; i < arg_count ; i++) for (uint i=0 ; i < arg_count ; i++)
{ {
if (args[i]->check_cols(1) || args[i]->fix_fields(thd, tables, args + i)) if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1))
return 1; return 1;
if (decimals < args[i]->decimals) if (decimals < args[i]->decimals)
decimals=args[i]->decimals; decimals=args[i]->decimals;
...@@ -145,7 +145,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -145,7 +145,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 1; return 1;
} }
thd->allow_sum_func=0; // No included group funcs thd->allow_sum_func=0; // No included group funcs
if (item->check_cols(1) || item->fix_fields(thd, tables, args)) if (item->fix_fields(thd, tables, args) || item->check_cols(1))
return 1; return 1;
hybrid_type=item->result_type(); hybrid_type=item->result_type();
if (hybrid_type == INT_RESULT) if (hybrid_type == INT_RESULT)
......
...@@ -1498,7 +1498,7 @@ int set_var::check(THD *thd) ...@@ -1498,7 +1498,7 @@ int set_var::check(THD *thd)
return 0; return 0;
} }
if (value->check_cols(1) || value->fix_fields(thd, 0, &value)) if (value->fix_fields(thd, 0, &value) || value->check_cols(1))
return -1; return -1;
if (var->check_update_type(value->result_type())) if (var->check_update_type(value->result_type()))
{ {
......
...@@ -1929,8 +1929,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields, ...@@ -1929,8 +1929,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
} }
else else
{ {
if (item->check_cols(1) || if (item->fix_fields(thd, tables, it.ref()) || item->check_cols(1))
item->fix_fields(thd, tables, it.ref()))
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
item= *(it.ref()); //Item can be chenged in fix fields item= *(it.ref()); //Item can be chenged in fix fields
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
...@@ -2090,7 +2089,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2090,7 +2089,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
if (*conds) if (*conds)
{ {
thd->where="where clause"; thd->where="where clause";
if ((*conds)->check_cols(1) || (*conds)->fix_fields(thd, tables, conds)) if ((*conds)->fix_fields(thd, tables, conds) || (*conds)->check_cols(1))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -2101,8 +2100,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2101,8 +2100,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{ {
/* Make a join an a expression */ /* Make a join an a expression */
thd->where="on clause"; thd->where="on clause";
if (table->on_expr->check_cols(1) || if (table->on_expr->fix_fields(thd, tables, &table->on_expr) ||
table->on_expr->fix_fields(thd, tables, &table->on_expr)) table->on_expr->check_cols(1))
DBUG_RETURN(1); DBUG_RETURN(1);
thd->cond_count++; thd->cond_count++;
......
...@@ -106,7 +106,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -106,7 +106,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
tables->table=table; tables->table=table;
if (cond && (cond->check_cols(1) || cond->fix_fields(thd, tables, &cond))) if (cond && (cond->fix_fields(thd, tables, &cond) || cond->check_cols(1)))
return -1; return -1;
/* InnoDB needs to know that this table handle is used in the HANDLER */ /* InnoDB needs to know that this table handle is used in the HANDLER */
......
...@@ -271,8 +271,8 @@ JOIN::prepare(TABLE_LIST *tables_init, ...@@ -271,8 +271,8 @@ JOIN::prepare(TABLE_LIST *tables_init,
thd->where="having clause"; thd->where="having clause";
thd->allow_sum_func=1; thd->allow_sum_func=1;
select_lex->having_fix_field= 1; select_lex->having_fix_field= 1;
bool having_fix_rc= (having->check_cols(1) || bool having_fix_rc= (having->fix_fields(thd, tables_list, &having) ||
having->fix_fields(thd, tables_list, &having)); having->check_cols(1));
select_lex->having_fix_field= 0; select_lex->having_fix_field= 0;
if (having_fix_rc || thd->net.report_error) if (having_fix_rc || thd->net.report_error)
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
...@@ -6912,7 +6912,7 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields, ...@@ -6912,7 +6912,7 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
} }
order->in_field_list=0; order->in_field_list=0;
Item *it= *order->item; Item *it= *order->item;
if (it->check_cols(1) || it->fix_fields(thd, tables, order->item) || if (it->fix_fields(thd, tables, order->item) || it->check_cols(1) ||
thd->fatal_error) thd->fatal_error)
return 1; // Wrong field return 1; // Wrong field
all_fields.push_front(*order->item); // Add new field to field list all_fields.push_front(*order->item); // Add new field to field list
......
...@@ -3572,7 +3572,7 @@ kill: ...@@ -3572,7 +3572,7 @@ kill:
KILL_SYM expr KILL_SYM expr
{ {
LEX *lex=Lex; LEX *lex=Lex;
if ($2->check_cols(1) || $2->fix_fields(lex->thd, 0, &$2)) if ($2->fix_fields(lex->thd, 0, &$2) || $2->check_cols(1))
{ {
send_error(lex->thd, ER_SET_CONSTANTS_ONLY); send_error(lex->thd, ER_SET_CONSTANTS_ONLY);
YYABORT; YYABORT;
......
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