~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_load.cc

  • Committer: Monty Taylor
  • Date: 2009-07-09 00:04:44 UTC
  • mto: (1093.1.9 captain)
  • mto: This revision was merged to the branch mainline in revision 1097.
  • Revision ID: mordred@inaugust.com-20090709000444-1jf6qw4gvyhdab1a
Got rid of #ifdef have utf8 stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
870
870
    while ( to < end_of_buff)
871
871
    {
872
872
      chr = GET;
873
 
#ifdef USE_MB
874
873
      if ((my_mbcharlen(read_charset, chr) > 1) &&
875
874
          to+my_mbcharlen(read_charset, chr) <= end_of_buff)
876
875
      {
877
 
          unsigned char* p = (unsigned char*)to;
878
 
          *to++ = chr;
879
 
          int ml = my_mbcharlen(read_charset, chr);
880
 
          int i;
881
 
          for (i=1; i<ml; i++) {
882
 
              chr = GET;
883
 
              if (chr == my_b_EOF)
884
 
                  goto found_eof;
885
 
              *to++ = chr;
886
 
          }
887
 
          if (my_ismbchar(read_charset,
888
 
                          (const char *)p,
889
 
                          (const char *)to))
890
 
            continue;
891
 
          for (i=0; i<ml; i++)
892
 
            PUSH((unsigned char) *--to);
893
 
          chr = GET;
 
876
        unsigned char* p = (unsigned char*)to;
 
877
        *to++ = chr;
 
878
        int ml = my_mbcharlen(read_charset, chr);
 
879
        int i;
 
880
        for (i=1; i<ml; i++) {
 
881
          chr = GET;
 
882
          if (chr == my_b_EOF)
 
883
            goto found_eof;
 
884
          *to++ = chr;
 
885
        }
 
886
        if (my_ismbchar(read_charset,
 
887
              (const char *)p,
 
888
              (const char *)to))
 
889
          continue;
 
890
        for (i=0; i<ml; i++)
 
891
          PUSH((unsigned char) *--to);
 
892
        chr = GET;
894
893
      }
895
 
#endif
896
894
      if (chr == my_b_EOF)
897
 
        goto found_eof;
 
895
        goto found_eof;
898
896
      if (chr == escape_char)
899
897
      {
900
 
        if ((chr=GET) == my_b_EOF)
901
 
        {
902
 
          *to++= (unsigned char) escape_char;
903
 
          goto found_eof;
904
 
        }
 
898
        if ((chr=GET) == my_b_EOF)
 
899
        {
 
900
          *to++= (unsigned char) escape_char;
 
901
          goto found_eof;
 
902
        }
905
903
        /*
906
904
          When escape_char == enclosed_char, we treat it like we do for
907
905
          handling quotes in SQL parsing -- you can double-up the
920
918
#ifdef ALLOW_LINESEPARATOR_IN_STRINGS
921
919
      if (chr == line_term_char)
922
920
#else
923
 
      if (chr == line_term_char && found_enclosed_char == INT_MAX)
 
921
        if (chr == line_term_char && found_enclosed_char == INT_MAX)
924
922
#endif
925
 
      {
926
 
        if (terminator(line_term_ptr,line_term_length))
927
 
        {                                       // Maybe unexpected linefeed
928
 
          enclosed=0;
929
 
          found_end_of_line=1;
930
 
          row_start=buffer;
931
 
          row_end=  to;
932
 
          return 0;
933
 
        }
934
 
      }
 
923
        {
 
924
          if (terminator(line_term_ptr,line_term_length))
 
925
          {                                     // Maybe unexpected linefeed
 
926
            enclosed=0;
 
927
            found_end_of_line=1;
 
928
            row_start=buffer;
 
929
            row_end=  to;
 
930
            return 0;
 
931
          }
 
932
        }
935
933
      if (chr == found_enclosed_char)
936
934
      {
937
 
        if ((chr=GET) == found_enclosed_char)
938
 
        {                                       // Remove dupplicated
939
 
          *to++ = (unsigned char) chr;
940
 
          continue;
941
 
        }
942
 
        // End of enclosed field if followed by field_term or line_term
943
 
        if (chr == my_b_EOF ||
944
 
            (chr == line_term_char && terminator(line_term_ptr, line_term_length)))
945
 
        {                                       // Maybe unexpected linefeed
946
 
          enclosed=1;
947
 
          found_end_of_line=1;
948
 
          row_start=buffer+1;
949
 
          row_end=  to;
950
 
          return 0;
951
 
        }
952
 
        if (chr == field_term_char &&
953
 
            terminator(field_term_ptr,field_term_length))
954
 
        {
955
 
          enclosed=1;
956
 
          row_start=buffer+1;
957
 
          row_end=  to;
958
 
          return 0;
959
 
        }
960
 
        /*
961
 
          The string didn't terminate yet.
962
 
          Store back next character for the loop
963
 
        */
964
 
        PUSH(chr);
965
 
        /* copy the found term character to 'to' */
966
 
        chr= found_enclosed_char;
 
935
        if ((chr=GET) == found_enclosed_char)
 
936
        {                                       // Remove dupplicated
 
937
          *to++ = (unsigned char) chr;
 
938
          continue;
 
939
        }
 
940
        // End of enclosed field if followed by field_term or line_term
 
941
        if (chr == my_b_EOF ||
 
942
            (chr == line_term_char && terminator(line_term_ptr, line_term_length)))
 
943
        {                                       // Maybe unexpected linefeed
 
944
          enclosed=1;
 
945
          found_end_of_line=1;
 
946
          row_start=buffer+1;
 
947
          row_end=  to;
 
948
          return 0;
 
949
        }
 
950
        if (chr == field_term_char &&
 
951
            terminator(field_term_ptr,field_term_length))
 
952
        {
 
953
          enclosed=1;
 
954
          row_start=buffer+1;
 
955
          row_end=  to;
 
956
          return 0;
 
957
        }
 
958
        /*
 
959
           The string didn't terminate yet.
 
960
           Store back next character for the loop
 
961
         */
 
962
        PUSH(chr);
 
963
        /* copy the found term character to 'to' */
 
964
        chr= found_enclosed_char;
967
965
      }
968
966
      else if (chr == field_term_char && found_enclosed_char == INT_MAX)
969
967
      {
970
 
        if (terminator(field_term_ptr,field_term_length))
971
 
        {
972
 
          enclosed=0;
973
 
          row_start=buffer;
974
 
          row_end=  to;
975
 
          return 0;
976
 
        }
 
968
        if (terminator(field_term_ptr,field_term_length))
 
969
        {
 
970
          enclosed=0;
 
971
          row_start=buffer;
 
972
          row_end=  to;
 
973
          return 0;
 
974
        }
977
975
      }
978
976
      *to++ = (unsigned char) chr;
979
977
    }
980
978
    /*
981
 
    ** We come here if buffer is too small. Enlarge it and continue
982
 
    */
 
979
     ** We come here if buffer is too small. Enlarge it and continue
 
980
     */
983
981
    if (!(new_buffer=(unsigned char*) realloc(buffer, buff_length+1+IO_SIZE)))
984
982
      return (error=1);
985
983
    to=new_buffer + (to-buffer);
1077
1075
  for (;;)
1078
1076
  {
1079
1077
    int chr = GET;
1080
 
#ifdef USE_MB
1081
 
   if (my_mbcharlen(read_charset, chr) > 1)
1082
 
   {
1083
 
       for (uint32_t i=1;
1084
 
            chr != my_b_EOF && i<my_mbcharlen(read_charset, chr);
1085
 
            i++)
1086
 
           chr = GET;
1087
 
       if (chr == escape_char)
1088
 
           continue;
1089
 
   }
1090
 
#endif
1091
 
   if (chr == my_b_EOF)
1092
 
   {
 
1078
    if (my_mbcharlen(read_charset, chr) > 1)
 
1079
    {
 
1080
      for (uint32_t i=1;
 
1081
          chr != my_b_EOF && i<my_mbcharlen(read_charset, chr);
 
1082
          i++)
 
1083
        chr = GET;
 
1084
      if (chr == escape_char)
 
1085
        continue;
 
1086
    }
 
1087
    if (chr == my_b_EOF)
 
1088
    {
1093
1089
      eof=1;
1094
1090
      return 1;
1095
1091
    }
1097
1093
    {
1098
1094
      line_cuted=1;
1099
1095
      if (GET == my_b_EOF)
1100
 
        return 1;
 
1096
        return 1;
1101
1097
      continue;
1102
1098
    }
1103
1099
    if (chr == line_term_char && terminator(line_term_ptr,line_term_length))