@@ -699,7 +699,6 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
699699 const bool was_insert_delayed= (table_list->lock_type == TL_WRITE_DELAYED);
700700 bool using_bulk_insert= 0 ;
701701 uint value_count;
702- ulong counter = 1 ;
703702 /* counter of iteration in bulk PS operation*/
704703 ulonglong iteration= 0 ;
705704 ulonglong id;
@@ -711,7 +710,6 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
711710 Name_resolution_context_state ctx_state;
712711 SELECT_LEX *returning= thd->lex ->has_returning () ? thd->lex ->returning () : 0 ;
713712 unsigned char *readbuff= NULL ;
714- thd->current_insert_index = 0 ;
715713
716714#ifndef EMBEDDED_LIBRARY
717715 char *query= thd->query ();
@@ -831,10 +829,11 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
831829
832830 while ((values= its++))
833831 {
834- thd->current_insert_index = ++counter ;
832+ thd->get_stmt_da ()-> inc_current_row_for_warning () ;
835833 if (values->elements != value_count)
836834 {
837- my_error (ER_WRONG_VALUE_COUNT_ON_ROW, MYF (0 ), counter);
835+ my_error (ER_WRONG_VALUE_COUNT_ON_ROW, MYF (0 ),
836+ thd->get_stmt_da ()->current_row_for_warning ());
838837 goto abort;
839838 }
840839 if (setup_fields (thd, Ref_ptr_array (),
@@ -843,7 +842,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
843842 switch_to_nullable_trigger_fields (*values, table);
844843 }
845844 its.rewind ();
846- thd->current_insert_index = 0 ;
845+ thd->get_stmt_da ()-> reset_current_row_for_warning () ;
847846
848847 /* Restore the current context. */
849848 ctx_state.restore_state (context, table_list);
@@ -1010,7 +1009,6 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
10101009
10111010 while ((values= its++))
10121011 {
1013- thd->current_insert_index ++;
10141012 if (fields.elements || !value_count)
10151013 {
10161014 /*
@@ -1134,7 +1132,6 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
11341132 } while (bulk_parameters_iterations (thd));
11351133
11361134values_loop_end:
1137- thd->current_insert_index = 0 ;
11381135 free_underlaid_joins (thd, thd->lex ->first_select_lex ());
11391136 joins_freed= TRUE ;
11401137
@@ -1610,8 +1607,6 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
16101607 bool res= 0 ;
16111608 table_map map= 0 ;
16121609 TABLE *table;
1613- thd->current_insert_index = 1 ;
1614-
16151610 DBUG_ENTER (" mysql_prepare_insert" );
16161611 DBUG_PRINT (" enter" , (" table_list: %p view: %d" ,
16171612 table_list, (int ) insert_into_view));
@@ -1665,7 +1660,6 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
16651660 if (!res)
16661661 res= setup_fields (thd, Ref_ptr_array (),
16671662 update_values, MARK_COLUMNS_READ, 0 , NULL , 0 );
1668- thd->current_insert_index = 0 ;
16691663
16701664 if (!res && duplic == DUP_UPDATE)
16711665 {
0 commit comments