Commit 372e2130 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fixed test of cardinality

parent fc945987
......@@ -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 1.5,'c','a') = ROW(1.5,2,'a')
0
SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
Cardinality error (more/less than 1 columns)
create table t1 (a int);
create table t2 (a int, b int);
create table t3 (a int);
......
......@@ -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,'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 t2 (a int, b int);
create table t3 (a int);
......
......@@ -606,7 +606,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
(char *)field_name);
if (!r)
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;
r->depended_from= last;
cursel->mark_as_dependent(last);
......@@ -630,7 +630,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (!rf)
return 1;
(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()
bool
Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
if (first_expr && (first_expr->check_cols(1) ||
first_expr->fix_fields(thd, tables, &first_expr)) ||
else_expr && (else_expr->check_cols(1) ||
else_expr->fix_fields(thd, tables, &else_expr)))
if (first_expr && (first_expr->fix_fields(thd, tables, &first_expr) ||
first_expr->check_cols(1)) ||
else_expr && (else_expr->fix_fields(thd, tables, &else_expr) ||
else_expr->check_cols(1)))
return 1;
if (Item_func::fix_fields(thd, tables, ref))
return 1;
......@@ -1473,7 +1473,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
if (abort_on_null)
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 */
used_tables_cache|=item->used_tables();
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)
bool
Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
if (args[0]->check_cols(1) ||
args[1]->check_cols(1) ||
args[0]->fix_fields(thd, tables, args) ||
args[1]->fix_fields(thd,tables, args + 1))
if (args[0]->fix_fields(thd, tables, args) || args[0]->check_cols(1) ||
args[1]->fix_fields(thd,tables, args + 1) || args[1]->check_cols(1))
return 1; /* purecov: inspected */
with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func;
max_length= 1;
......
......@@ -275,8 +275,7 @@ public:
longlong val_int();
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref)
{
return (item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
void fix_length_and_dec();
......
......@@ -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++)
{
if ((*arg)->check_cols(allowed_arg_cols) ||
(*arg)->fix_fields(thd, tables, arg))
if ((*arg)->fix_fields(thd, tables, arg) ||
(*arg)->check_cols(allowed_arg_cols))
return 1; /* purecov: inspected */
if ((*arg)->maybe_null)
maybe_null=1;
......@@ -1323,7 +1323,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func,
arg != arg_end ;
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;
if ((*arg)->binary())
func->set_charset(my_charset_bin);
......@@ -2331,7 +2331,7 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
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;
if (item->type() == Item::REF_ITEM)
li.replace(item= *((Item_ref *)item)->ref);
......
......@@ -608,8 +608,7 @@ public:
longlong val_int();
bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref)
{
return (item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
return (item->fix_fields(thd, tlist, &item) || item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
void update_used_tables()
......
......@@ -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))
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;
maybe_null=args[0]->maybe_null;
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,
if (thd && check_stack_overrun(thd,buff))
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;
maybe_null=args[0]->maybe_null;
set_charset(set_collation);
......
......@@ -101,8 +101,8 @@ public:
void update_used_tables();
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
return (separator->check_cols(1) ||
separator->fix_fields(thd, tlist, &separator) ||
return (separator->fix_fields(thd, tlist, &separator) ||
separator->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
const char *func_name() const { return "concat_ws"; }
......@@ -382,8 +382,8 @@ public:
String *val_str(String *str);
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
return (item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
return (item->fix_fields(thd, tlist, &item) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
void fix_length_and_dec();
......@@ -415,8 +415,8 @@ public:
String *val_str(String *str);
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
return (item->check_cols(1) ||
item->fix_fields(thd, tlist, &item) ||
return (item->fix_fields(thd, tlist, &item) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
void fix_length_and_dec();
......
......@@ -119,7 +119,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
maybe_null=0;
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;
if (decimals < args[i]->decimals)
decimals=args[i]->decimals;
......@@ -145,7 +145,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return 1;
}
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;
hybrid_type=item->result_type();
if (hybrid_type == INT_RESULT)
......
......@@ -1498,7 +1498,7 @@ int set_var::check(THD *thd)
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;
if (var->check_update_type(value->result_type()))
{
......
......@@ -1929,8 +1929,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
}
else
{
if (item->check_cols(1) ||
item->fix_fields(thd, tables, it.ref()))
if (item->fix_fields(thd, tables, it.ref()) || item->check_cols(1))
DBUG_RETURN(-1); /* purecov: inspected */
item= *(it.ref()); //Item can be chenged in fix fields
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)
if (*conds)
{
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);
}
......@@ -2101,8 +2100,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{
/* Make a join an a expression */
thd->where="on clause";
if (table->on_expr->check_cols(1) ||
table->on_expr->fix_fields(thd, tables, &table->on_expr))
if (table->on_expr->fix_fields(thd, tables, &table->on_expr) ||
table->on_expr->check_cols(1))
DBUG_RETURN(1);
thd->cond_count++;
......
......@@ -106,7 +106,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
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;
/* InnoDB needs to know that this table handle is used in the HANDLER */
......
......@@ -271,8 +271,8 @@ JOIN::prepare(TABLE_LIST *tables_init,
thd->where="having clause";
thd->allow_sum_func=1;
select_lex->having_fix_field= 1;
bool having_fix_rc= (having->check_cols(1) ||
having->fix_fields(thd, tables_list, &having));
bool having_fix_rc= (having->fix_fields(thd, tables_list, &having) ||
having->check_cols(1));
select_lex->having_fix_field= 0;
if (having_fix_rc || thd->net.report_error)
DBUG_RETURN(-1); /* purecov: inspected */
......@@ -6912,7 +6912,7 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
}
order->in_field_list=0;
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)
return 1; // Wrong field
all_fields.push_front(*order->item); // Add new field to field list
......
......@@ -3572,7 +3572,7 @@ kill:
KILL_SYM expr
{
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);
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