~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/sql_load.cc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
 
270
270
  while ((item= it++))
271
271
  {
272
 
    if (item->type() == Item::FIELD_ITEM)
 
272
    Item *real_item= item->real_item();
 
273
 
 
274
    if (real_item->type() == Item::FIELD_ITEM)
273
275
    {
274
 
      Field *field= ((Item_field*)item)->field;
 
276
      Field *field= ((Item_field*)real_item)->field;
275
277
      if (field->flags & BLOB_FLAG)
276
278
      {
277
279
        use_blobs= 1;
280
282
      else
281
283
        tot_length+= field->field_length;
282
284
    }
283
 
    else
 
285
    else if (item->type() == Item::STRING_ITEM)
284
286
      use_vars= 1;
285
287
  }
286
288
  if (use_blobs && !ex->line_term->length() && !field_term->length())
406
408
        (!table->triggers ||
407
409
         !table->triggers->has_delete_triggers()))
408
410
        table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
409
 
    if (!thd->prelocked_mode)
 
411
    if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
410
412
      table->file->ha_start_bulk_insert((ha_rows) 0);
411
413
    table->copy_blobs=1;
412
414
 
427
429
      error= read_sep_field(thd, info, table_list, fields_vars,
428
430
                            set_fields, set_values, read_info,
429
431
                            *enclosed, skip_lines, ignore);
430
 
    if (!thd->prelocked_mode && table->file->ha_end_bulk_insert() && !error)
 
432
    if (thd->locked_tables_mode <= LTM_LOCK_TABLES &&
 
433
        table->file->ha_end_bulk_insert(0) && !error)
431
434
    {
432
435
      table->file->print_error(my_errno, MYF(0));
433
436
      error= 1;
590
593
  List_iterator_fast<Item> it(fields_vars);
591
594
  Item_field *sql_field;
592
595
  TABLE *table= table_list->table;
593
 
  ulonglong id;
594
596
  bool err;
595
597
  DBUG_ENTER("read_fixed_length");
596
598
 
597
 
  id= 0;
598
 
 
599
599
  while (!read_info.read_fixed_length())
600
600
  {
601
601
    if (thd->killed)
721
721
  Item *item;
722
722
  TABLE *table= table_list->table;
723
723
  uint enclosed_length;
724
 
  ulonglong id;
725
724
  bool err;
726
725
  DBUG_ENTER("read_sep_field");
727
726
 
728
727
  enclosed_length=enclosed.length();
729
 
  id= 0;
730
728
 
731
729
  for (;;it.rewind())
732
730
  {
742
740
    {
743
741
      uint length;
744
742
      uchar *pos;
 
743
      Item *real_item;
745
744
 
746
745
      if (read_info.read_field())
747
746
        break;
753
752
      pos=read_info.row_start;
754
753
      length=(uint) (read_info.row_end-pos);
755
754
 
 
755
      real_item= item->real_item();
 
756
 
756
757
      if (!read_info.enclosed &&
757
758
          (enclosed_length && length == 4 &&
758
759
           !memcmp(pos, STRING_WITH_LEN("NULL"))) ||
759
760
          (length == 1 && read_info.found_null))
760
761
      {
761
 
        if (item->type() == Item::FIELD_ITEM)
 
762
 
 
763
        if (real_item->type() == Item::FIELD_ITEM)
762
764
        {
763
 
          Field *field= ((Item_field *)item)->field;
 
765
          Field *field= ((Item_field *)real_item)->field;
764
766
          if (field->reset())
765
767
          {
766
768
            my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
777
779
                                 ER_WARN_NULL_TO_NOTNULL, 1);
778
780
          }
779
781
        }
780
 
        else
 
782
        else if (item->type() == Item::STRING_ITEM)
 
783
        {
781
784
          ((Item_user_var_as_out_param *)item)->set_null_value(
782
785
                                                  read_info.read_charset);
 
786
        }
 
787
        else
 
788
        {
 
789
          my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
 
790
          DBUG_RETURN(1);
 
791
        }
 
792
 
783
793
        continue;
784
794
      }
785
795
 
786
 
      if (item->type() == Item::FIELD_ITEM)
 
796
      if (real_item->type() == Item::FIELD_ITEM)
787
797
      {
788
 
 
789
 
        Field *field= ((Item_field *)item)->field;
 
798
        Field *field= ((Item_field *)real_item)->field;
790
799
        field->set_notnull();
791
800
        read_info.row_end[0]=0;                 // Safe to change end marker
792
801
        if (field == table->next_number_field)
793
802
          table->auto_increment_field_not_null= TRUE;
794
803
        field->store((char*) pos, length, read_info.read_charset);
795
804
      }
796
 
      else
 
805
      else if (item->type() == Item::STRING_ITEM)
 
806
      {
797
807
        ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
798
 
                                                read_info.read_charset);
 
808
                                                        read_info.read_charset);
 
809
      }
 
810
      else
 
811
      {
 
812
        my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
 
813
        DBUG_RETURN(1);
 
814
      }
799
815
    }
800
816
    if (read_info.error)
801
817
      break;
811
827
        break;
812
828
      for (; item ; item= it++)
813
829
      {
814
 
        if (item->type() == Item::FIELD_ITEM)
 
830
        Item *real_item= item->real_item();
 
831
        if (real_item->type() == Item::FIELD_ITEM)
815
832
        {
816
 
          Field *field= ((Item_field *)item)->field;
 
833
          Field *field= ((Item_field *)real_item)->field;
817
834
          if (field->reset())
818
835
          {
819
836
            my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
833
850
                              ER_WARN_TOO_FEW_RECORDS,
834
851
                              ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
835
852
        }
836
 
        else
 
853
        else if (item->type() == Item::STRING_ITEM)
 
854
        {
837
855
          ((Item_user_var_as_out_param *)item)->set_null_value(
838
856
                                                  read_info.read_charset);
 
857
        }
 
858
        else
 
859
        {
 
860
          my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
 
861
          DBUG_RETURN(1);
 
862
        }
839
863
      }
840
864
    }
841
865
 
1142
1166
        cache.read_function = _my_b_net_read;
1143
1167
 
1144
1168
      if (mysql_bin_log.is_open())
1145
 
        cache.pre_read = cache.pre_close =
1146
 
          (IO_CACHE_CALLBACK) log_loaded_block;
 
1169
        cache.pre_read= cache.pre_close = log_loaded_block;
1147
1170
#endif
1148
1171
    }
1149
1172
  }