Commit 8e02b39a authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.1

into serg.mysql.com:/usr/home/serg/Abk/mysql-4.1


sql/sql_yacc.yy:
  Auto merged
parents dcae6979 23342bad
...@@ -35,7 +35,7 @@ SELECT ('test',2,3.33)=('test',2,3.33); ...@@ -35,7 +35,7 @@ SELECT ('test',2,3.33)=('test',2,3.33);
('test',2,3.33)=('test',2,3.33) ('test',2,3.33)=('test',2,3.33)
1 1
SELECT ('test',2,3.33)=('test',2,3.33,4); 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; drop table if exists t1;
create table t1 ( a int, b int, c int); create table t1 ( a int, b int, c int);
insert into t1 values (1,2,3), (2,3,1), (3,2,1); insert into t1 values (1,2,3), (2,3,1), (3,2,1);
...@@ -49,3 +49,12 @@ a b c ...@@ -49,3 +49,12 @@ a b c
2 3 1 2 3 1
3 2 1 3 2 1
drop table t1; 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); ...@@ -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 (1,2,3)=(a,b,c);
select * from t1 where (0,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); select * from t1 where (1,2,3)<(a,b,c);
drop table t1; drop table t1;
\ No newline at end of file
-- 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) ...@@ -63,7 +63,7 @@ bool Item::check_cols(uint c)
{ {
if (c != 1) if (c != 1)
{ {
my_error(ER_CARDINALITY_COL, MYF(0), 1); my_error(ER_CARDINALITY_COL, MYF(0), c);
return 1; return 1;
} }
return 0; return 0;
...@@ -570,8 +570,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -570,8 +570,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (!r) if (!r)
return 1; return 1;
int res; int res;
if ((res= r->fix_fields(thd, tables, ref))) if (r->check_cols(1) || r->fix_fields(thd, tables, ref))
return res; return 1;
r->depended_from= last; r->depended_from= last;
thd->lex.current_select->mark_as_dependent(last); thd->lex.current_select->mark_as_dependent(last);
thd->add_possible_loop(r); thd->add_possible_loop(r);
...@@ -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 (!*ref) if (!*ref)
return 1; return 1;
return (*ref)->fix_fields(thd, tables, ref); return (*ref)->check_cols(1) || (*ref)->fix_fields(thd, tables, ref);
} }
fixed= 1; fixed= 1;
return 0; return 0;
......
...@@ -120,6 +120,7 @@ public: ...@@ -120,6 +120,7 @@ public:
longlong val_int() { return item->val_int(); } longlong val_int() { return item->val_int(); }
String* val_str(String* s) { return item->val_str(s); } String* val_str(String* s) { return item->val_str(s); }
void make_field(Send_field* f) { item->make_field(f); } 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) ...@@ -59,7 +59,7 @@ bool Item_row::check_cols(uint c)
{ {
if (c != arg_count) if (c != arg_count)
{ {
my_error(ER_CARDINALITY_COL, MYF(0), arg_count); my_error(ER_CARDINALITY_COL, MYF(0), c);
return 1; return 1;
} }
return 0; return 0;
......
...@@ -1344,7 +1344,7 @@ int set_var::check(THD *thd) ...@@ -1344,7 +1344,7 @@ int set_var::check(THD *thd)
return 0; return 0;
} }
if (value->fix_fields(thd, 0, &value)) if (value->check_cols(1) || value->fix_fields(thd, 0, &value))
return -1; return -1;
if (var->check_update_type(value->result_type())) if (var->check_update_type(value->result_type()))
{ {
......
...@@ -2101,7 +2101,8 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields, ...@@ -2101,7 +2101,8 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
} }
else 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 */ 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 &&
...@@ -2255,7 +2256,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2255,7 +2256,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)->fix_fields(thd, tables, conds)) if ((*conds)->check_cols(1) || (*conds)->fix_fields(thd, tables, conds))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -2266,7 +2267,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) ...@@ -2266,7 +2267,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->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); 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->fix_fields(thd, tables, &cond)) if (cond && (cond->check_cols(1) || cond->fix_fields(thd, tables, &cond)))
return -1; return -1;
if (keyname) if (keyname)
......
...@@ -501,7 +501,8 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables, ...@@ -501,7 +501,8 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
{ {
thd->where="having clause"; thd->where="having clause";
thd->allow_sum_func=1; 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); DBUG_RETURN(1);
if (having->with_sum_func) if (having->with_sum_func)
having->split_sum_func(all_fields); having->split_sum_func(all_fields);
......
...@@ -262,7 +262,8 @@ JOIN::prepare(TABLE_LIST *tables_init, ...@@ -262,7 +262,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->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; 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 */
...@@ -6651,7 +6652,9 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields, ...@@ -6651,7 +6652,9 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
return 0; return 0;
} }
order->in_field_list=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 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
order->item=(Item**) all_fields.head_ref(); order->item=(Item**) all_fields.head_ref();
......
...@@ -3419,7 +3419,7 @@ kill: ...@@ -3419,7 +3419,7 @@ kill:
KILL_SYM expr KILL_SYM expr
{ {
LEX *lex=Lex; 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); 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