diff options
author | unknown <bell@sanja.is.com.ua> | 2002-11-29 12:30:04 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-11-29 12:30:04 +0200 |
commit | 042c34d86dad7f37ff39345f6716c2f25ffeab53 (patch) | |
tree | 149db652e4b38984a7f819d9ba21f2e79c669ae5 /sql | |
parent | 5b62dfcdf51a695ebc724cb453919eb909ca274f (diff) | |
download | mariadb-git-042c34d86dad7f37ff39345f6716c2f25ffeab53.tar.gz |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 8 | ||||
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_row.cc | 2 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 8 | ||||
-rw-r--r-- | sql/sql_handler.cc | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 7 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
9 files changed, 21 insertions, 14 deletions
diff --git a/sql/item.cc b/sql/item.cc index 740ec9418c4..2dd5de0e896 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -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; diff --git a/sql/item.h b/sql/item.h index 766bd7fba41..11b141613f3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -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); } }; diff --git a/sql/item_row.cc b/sql/item_row.cc index 95da4f5901e..464a8fd0ec5 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -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; diff --git a/sql/set_var.cc b/sql/set_var.cc index 599c4af06cc..566ca6da860 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -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())) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f8202035d51..8f74903027e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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++; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index c43869d9d55..909e1643fe5 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->fix_fields(thd, tables, &cond)) + if (cond && (cond->check_cols(1) || cond->fix_fields(thd, tables, &cond))) return -1; if (keyname) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index f86add6c389..7943a3e2254 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -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); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f560cb7907f..c1f7e8272bc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cd15fb19dfb..27996acb0f0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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; |