checking columns of top items
mysql-test/r/row_test.result: changed error message (report requestet columns number) new tests mysql-test/t/row_test.test: new tests sql/item.h: checking columns of wrapper items
This commit is contained in:
parent
5b62dfcdf5
commit
042c34d86d
@ -35,7 +35,7 @@ SELECT ('test',2,3.33)=('test',2,3.33);
|
||||
('test',2,3.33)=('test',2,3.33)
|
||||
1
|
||||
SELECT ('test',2,3.33)=('test',2,3.33,4);
|
||||
Cardinality error (more/less than 4 columns)
|
||||
Cardinality error (more/less than 3 columns)
|
||||
drop table if exists t1;
|
||||
create table t1 ( a int, b int, c int);
|
||||
insert into t1 values (1,2,3), (2,3,1), (3,2,1);
|
||||
@ -49,3 +49,12 @@ a b c
|
||||
2 3 1
|
||||
3 2 1
|
||||
drop table t1;
|
||||
select (1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
drop table if exists t1;
|
||||
create table t1 (i int);
|
||||
select 1 from t1 where (1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
select count(*) from t1 order by (1,1);
|
||||
Cardinality error (more/less than 1 columns)
|
||||
drop table t1;
|
||||
|
@ -18,4 +18,19 @@ insert into t1 values (1,2,3), (2,3,1), (3,2,1);
|
||||
select * from t1 where (1,2,3)=(a,b,c);
|
||||
select * from t1 where (0,2,3)=(a,b,c);
|
||||
select * from t1 where (1,2,3)<(a,b,c);
|
||||
drop table t1;
|
||||
drop table t1;
|
||||
|
||||
-- error 1239
|
||||
select (1,1);
|
||||
drop table if exists t1;
|
||||
create table t1 (i int);
|
||||
-- error 1239
|
||||
select 1 from t1 where (1,1);
|
||||
-- error 1239
|
||||
select count(*) from t1 order by (1,1);
|
||||
#TODO remove comments after parser fixing
|
||||
#-- error 1239
|
||||
#select count(*) from t1 order by i having (1,1);
|
||||
#-- error 1239
|
||||
#select 1 from t1 limit (1,1), (1,1);
|
||||
drop table t1;
|
||||
|
@ -63,7 +63,7 @@ bool Item::check_cols(uint c)
|
||||
{
|
||||
if (c != 1)
|
||||
{
|
||||
my_error(ER_CARDINALITY_COL, MYF(0), 1);
|
||||
my_error(ER_CARDINALITY_COL, MYF(0), c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -570,8 +570,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
if (!r)
|
||||
return 1;
|
||||
int res;
|
||||
if ((res= r->fix_fields(thd, tables, ref)))
|
||||
return res;
|
||||
if (r->check_cols(1) || r->fix_fields(thd, tables, ref))
|
||||
return 1;
|
||||
r->depended_from= last;
|
||||
thd->lex.current_select->mark_as_dependent(last);
|
||||
thd->add_possible_loop(r);
|
||||
@ -606,7 +606,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
(char *)field_name);
|
||||
if (!*ref)
|
||||
return 1;
|
||||
return (*ref)->fix_fields(thd, tables, ref);
|
||||
return (*ref)->check_cols(1) || (*ref)->fix_fields(thd, tables, ref);
|
||||
}
|
||||
fixed= 1;
|
||||
return 0;
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
longlong val_int() { return item->val_int(); }
|
||||
String* val_str(String* s) { return item->val_str(s); }
|
||||
void make_field(Send_field* f) { item->make_field(f); }
|
||||
bool check_cols(uint col) { return item->check_cols(col); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ bool Item_row::check_cols(uint c)
|
||||
{
|
||||
if (c != arg_count)
|
||||
{
|
||||
my_error(ER_CARDINALITY_COL, MYF(0), arg_count);
|
||||
my_error(ER_CARDINALITY_COL, MYF(0), c);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1344,7 +1344,7 @@ int set_var::check(THD *thd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (value->fix_fields(thd, 0, &value))
|
||||
if (value->check_cols(1) || value->fix_fields(thd, 0, &value))
|
||||
return -1;
|
||||
if (var->check_update_type(value->result_type()))
|
||||
{
|
||||
|
@ -2101,7 +2101,8 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->fix_fields(thd, tables, it.ref()))
|
||||
if (item->check_cols(1) ||
|
||||
item->fix_fields(thd, tables, it.ref()))
|
||||
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 &&
|
||||
@ -2255,7 +2256,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
|
||||
if (*conds)
|
||||
{
|
||||
thd->where="where clause";
|
||||
if ((*conds)->fix_fields(thd, tables, conds))
|
||||
if ((*conds)->check_cols(1) || (*conds)->fix_fields(thd, tables, conds))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
@ -2266,7 +2267,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->fix_fields(thd, tables, &table->on_expr))
|
||||
if (table->on_expr->check_cols(1) ||
|
||||
table->on_expr->fix_fields(thd, tables, &table->on_expr))
|
||||
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->fix_fields(thd, tables, &cond))
|
||||
if (cond && (cond->check_cols(1) || cond->fix_fields(thd, tables, &cond)))
|
||||
return -1;
|
||||
|
||||
if (keyname)
|
||||
|
@ -501,7 +501,8 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
|
||||
{
|
||||
thd->where="having clause";
|
||||
thd->allow_sum_func=1;
|
||||
if (having->fix_fields(thd, tables, &having) || thd->fatal_error)
|
||||
if (having->check_cols(1) || having->fix_fields(thd, tables, &having)
|
||||
|| thd->fatal_error)
|
||||
DBUG_RETURN(1);
|
||||
if (having->with_sum_func)
|
||||
having->split_sum_func(all_fields);
|
||||
|
@ -262,7 +262,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->fix_fields(thd, tables_list, &having);
|
||||
bool having_fix_rc= (having->check_cols(1) ||
|
||||
having->fix_fields(thd, tables_list, &having));
|
||||
select_lex->having_fix_field= 0;
|
||||
if (having_fix_rc || thd->net.report_error)
|
||||
DBUG_RETURN(-1); /* purecov: inspected */
|
||||
@ -6651,7 +6652,9 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
|
||||
return 0;
|
||||
}
|
||||
order->in_field_list=0;
|
||||
if ((*order->item)->fix_fields(thd, tables, order->item) || thd->fatal_error)
|
||||
Item *it= *order->item;
|
||||
if (it->check_cols(1) || it->fix_fields(thd, tables, order->item) ||
|
||||
thd->fatal_error)
|
||||
return 1; // Wrong field
|
||||
all_fields.push_front(*order->item); // Add new field to field list
|
||||
order->item=(Item**) all_fields.head_ref();
|
||||
|
@ -3416,7 +3416,7 @@ kill:
|
||||
KILL_SYM expr
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if ($2->fix_fields(lex->thd, 0, &$2))
|
||||
if ($2->check_cols(1) || $2->fix_fields(lex->thd, 0, &$2))
|
||||
{
|
||||
send_error(lex->thd, ER_SET_CONSTANTS_ONLY);
|
||||
YYABORT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user