~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to sql/unireg.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
1
/* Copyright (C) 2000-2006 MySQL AB
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; either version 2 of the License, or
6
 
   (at your option) any later version.
 
5
   the Free Software Foundation; version 2 of the License.
7
6
 
8
7
   This program is distributed in the hope that it will be useful,
9
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
714
713
    {
715
714
      if (field->interval_id > int_count)
716
715
      {
717
 
        int_count=field->interval_id;
718
 
        tmp.append(NAMES_SEP_CHAR);
719
 
        for (const char **pos=field->interval->type_names ; *pos ; pos++)
720
 
        {
721
 
          char *val= (char*) *pos;
722
 
          uint str_len= strlen(val);
723
 
          /*
724
 
            Note, hack: in old frm NAMES_SEP_CHAR is used to separate
725
 
            names in the interval (ENUM/SET). To allow names to contain
726
 
            NAMES_SEP_CHAR, we replace it with a comma before writing frm.
727
 
            Backward conversion is done during frm file opening,
728
 
            See table.cc, openfrm() function
729
 
          */
730
 
          for (uint cnt= 0 ; cnt < str_len ; cnt++)
731
 
          {
732
 
            char c= val[cnt];
733
 
            if (c == NAMES_SEP_CHAR)
734
 
              val[cnt]= ',';
735
 
          }
736
 
          tmp.append(*pos);
737
 
          tmp.append(NAMES_SEP_CHAR);
738
 
        }
739
 
        tmp.append('\0');                       // End of intervall
 
716
        unsigned char  sep= 0;
 
717
        unsigned char  occ[256];
 
718
        uint           i;
 
719
        unsigned char *val= NULL;
 
720
 
 
721
        bzero(occ, sizeof(occ));
 
722
 
 
723
        for (i=0; (val= (unsigned char*) field->interval->type_names[i]); i++)
 
724
          for (uint j = 0; j < field->interval->type_lengths[i]; j++)
 
725
            occ[(unsigned int) (val[j])]= 1;
 
726
 
 
727
        if (!occ[(unsigned char)NAMES_SEP_CHAR])
 
728
          sep= (unsigned char) NAMES_SEP_CHAR;
 
729
        else if (!occ[(unsigned int)','])
 
730
          sep= ',';
 
731
        else
 
732
        {
 
733
          for (uint i=1; i<256; i++)
 
734
          {
 
735
            if(!occ[i])
 
736
            {
 
737
              sep= i;
 
738
              break;
 
739
            }
 
740
          }
 
741
 
 
742
          if(!sep)    /* disaster, enum uses all characters, none left as separator */
 
743
          {
 
744
            my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS),
 
745
                       MYF(0));
 
746
            DBUG_RETURN(1);
 
747
          }
 
748
        }
 
749
 
 
750
        int_count= field->interval_id;
 
751
        tmp.append(sep);
 
752
        for (const char **pos=field->interval->type_names ; *pos ; pos++)
 
753
        {
 
754
          tmp.append(*pos);
 
755
          tmp.append(sep);
 
756
        }
 
757
        tmp.append('\0');                      // End of intervall
740
758
      }
741
759
    }
742
760
    if (my_write(file,(byte*) tmp.ptr(),tmp.length(),MYF_RW))