summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/subselect.result2
-rw-r--r--mysql-test/t/subselect.test3
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item_cmpfunc.cc16
-rw-r--r--sql/item_cmpfunc.h3
-rw-r--r--sql/item_func.cc8
-rw-r--r--sql/item_func.h3
-rw-r--r--sql/item_strfunc.cc4
-rw-r--r--sql/item_strfunc.h12
-rw-r--r--sql/item_sum.cc4
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_yacc.yy2
15 files changed, 40 insertions, 40 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 04bf0575db3..2bbbd71f4cd 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -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);
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 1dcbd9a282d..b506baa9fdd 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -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);
diff --git a/sql/item.cc b/sql/item.cc
index 7a2f8e26567..53f63a977e0 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -608,7 +608,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);
@@ -632,7 +632,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);
}
}
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 79807653317..83d05cf5398 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -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;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index bd7d1bfaf7a..8641ab410b3 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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();
diff --git a/sql/item_func.cc b/sql/item_func.cc
index a5d45d42635..6612f61b4a1 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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);
@@ -2333,7 +2333,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);
diff --git a/sql/item_func.h b/sql/item_func.h
index a015f6e69ce..ec361cce4c5 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -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()
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 748ef096dbe..f9bda911eaf 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -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);
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index c56c59bcaef..339a49a3580 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -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();
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 2a96594af4e..570f1e50922 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -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)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 89eb155bc63..9208cf2eddd 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1522,7 +1522,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()))
{
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 13c31046819..16c71b437d2 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1928,8 +1928,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 &&
@@ -2089,7 +2088,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);
}
@@ -2100,8 +2099,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++;
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 0d8af46dbf6..acf3fd2914a 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -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 */
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0243cd7cfb6..3da91ebb5c3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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 */
@@ -6917,7 +6917,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
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a424aefd45f..caafff5166d 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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;