@@ -502,18 +502,17 @@ bool Item_ref_on_list_position::fix_fields(THD *thd,
502502 struct st_table_list *tables,
503503 Item ** reference)
504504{
505- ref= 0 ;
506505 List_iterator<Item> li (list);
507506 Item *item;
508- uint i= 0 ;
509- for (; (item= li++) && i < pos; i++);
510- if (i == pos)
507+ for (uint i= 0 ; (item= li++) && i < pos; i++);
508+ if (item)
511509 {
512510 ref= li.ref ();
513511 return Item_ref_null_helper::fix_fields (thd, tables, reference);
514512 }
515513 else
516514 {
515+ ref= 0 ;
517516 my_error (ER_CARDINALITY_COL, MYF (0 ), pos);
518517 return 1 ;
519518 }
@@ -1280,29 +1279,20 @@ longlong Item_cache_str::val_int()
12801279
12811280bool Item_cache_row::allocate (uint num)
12821281{
1283- n = num;
1282+ item_count = num;
12841283 THD *thd= current_thd;
1285- if (!(values= (Item_cache **) thd->calloc (sizeof (Item_cache *)*n)))
1286- {
1287- my_message (ER_OUT_OF_RESOURCES, ER (ER_OUT_OF_RESOURCES), MYF (0 ));
1288- thd->fatal_error = 1 ;
1289- return 1 ;
1290- }
1291- return 0 ;
1284+ return (!(values=
1285+ (Item_cache **) thd->calloc (sizeof (Item_cache *)*item_count)));
12921286}
12931287
12941288bool Item_cache_row::setup (Item * item)
12951289{
12961290 if (!values && allocate (item->cols ()))
12971291 return 1 ;
1298- for (uint i= 0 ; i < n ; i++)
1292+ for (uint i= 0 ; i < item_count ; i++)
12991293 {
13001294 if (!(values[i]= Item_cache::get_cache (item->el (i)->result_type ())))
1301- {
1302- my_message (ER_OUT_OF_RESOURCES, ER (ER_OUT_OF_RESOURCES), MYF (0 ));
1303- current_thd->fatal_error = 1 ;
13041295 return 1 ;
1305- }
13061296 values[i]->setup (item->el (i));
13071297 }
13081298 return 0 ;
@@ -1312,7 +1302,7 @@ void Item_cache_row::store(Item * item)
13121302{
13131303 null_value= 0 ;
13141304 item->bring_value ();
1315- for (uint i= 0 ; i < n ; i++)
1305+ for (uint i= 0 ; i < item_count ; i++)
13161306 {
13171307 values[i]->store (item->el (i));
13181308 null_value|= values[i]->null_value ;
@@ -1330,7 +1320,7 @@ void Item_cache_row::illegal_method_call(const char *method)
13301320
13311321bool Item_cache_row::check_cols (uint c)
13321322{
1333- if (c != n )
1323+ if (c != item_count )
13341324 {
13351325 my_error (ER_CARDINALITY_COL, MYF (0 ), c);
13361326 return 1 ;
@@ -1340,7 +1330,7 @@ bool Item_cache_row::check_cols(uint c)
13401330
13411331bool Item_cache_row::null_inside ()
13421332{
1343- for (uint i= 0 ; i < n ; i++)
1333+ for (uint i= 0 ; i < item_count ; i++)
13441334 {
13451335 if (values[i]->cols () > 1 )
13461336 {
@@ -1359,7 +1349,7 @@ bool Item_cache_row::null_inside()
13591349
13601350void Item_cache_row::bring_value ()
13611351{
1362- for (uint i= 0 ; i < n ; i++)
1352+ for (uint i= 0 ; i < item_count ; i++)
13631353 values[i]->bring_value ();
13641354 return ;
13651355}
0 commit comments