~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-14 08:26:38 UTC
  • mto: (670.1.24 devel)
  • mto: This revision was merged to the branch mainline in revision 676.
  • Revision ID: dev@torum.net-20081214082638-c8uje8oiwk4s2dh0
First pass of replacing MySQL's strxmov with libc alternatives

Show diffs side-by-side

added added

removed removed

Lines of Context:
1980
1980
    {
1981
1981
      lseek(file,(off_t) (endpos-bufflength),SEEK_SET);
1982
1982
      if (my_read(file, buff, bufflength, MYF(MY_NABP+MY_WME)))
1983
 
        return(0L);
 
1983
        return(0L);
1984
1984
      lseek(file,(off_t) (endpos-bufflength+IO_SIZE),SEEK_SET);
1985
1985
      if ((my_write(file, buff,bufflength,MYF(MY_NABP+MY_WME))))
1986
 
        return(0);
 
1986
        return(0);
1987
1987
      endpos-=bufflength; bufflength=IO_SIZE;
1988
1988
    }
1989
1989
    memset(buff, 0, IO_SIZE);                   /* Null new block */
1990
1990
    lseek(file,(ulong) maxlength,SEEK_SET);
1991
1991
    if (my_write(file,buff,bufflength,MYF(MY_NABP+MY_WME)))
1992
 
        return(0L);
 
1992
      return(0L);
1993
1993
    maxlength+=IO_SIZE;                         /* Fix old ref */
1994
1994
    int2store(fileinfo+6,maxlength);
1995
 
    for (i=names, pos= (unsigned char*) *formnames->type_names+n_length-1; i-- ;
1996
 
         pos+=4)
 
1995
    for (i=names, pos= (unsigned char*) *formnames->type_names+n_length-1; i--;
 
1996
         pos+=4)
1997
1997
    {
1998
1998
      endpos=uint4korr(pos)+IO_SIZE;
1999
1999
      int4store(pos,endpos);
2003
2003
  if (n_length == 1 )
2004
2004
  {                                             /* First name */
2005
2005
    length++;
2006
 
    strxmov((char*) buff,"/",newname,"/",NULL);
 
2006
    sprintf((char*)buff,"/%s/",newname);
2007
2007
  }
2008
2008
  else
2009
 
    strxmov((char*) buff,newname,"/",NULL); /* purecov: inspected */
 
2009
    sprintf((char*)buff,"%s/",newname); /* purecov: inspected */
2010
2010
  lseek(file, 63 + n_length,SEEK_SET);
2011
2011
  if (my_write(file, buff, (size_t) length+1,MYF(MY_NABP+MY_WME)) ||
2012
2012
      (names && my_write(file,(unsigned char*) (*formnames->type_names+n_length-1),
2036
2036
      my_error(ER_NO_SUCH_TABLE, MYF(0), share->db.str, share->table_name.str);
2037
2037
    else
2038
2038
    {
2039
 
      strxmov(buff, share->normalized_path.str, reg_ext, NULL);
 
2039
      sprintf(buff,"%s%s",share->normalized_path.str,reg_ext);
2040
2040
      my_error((db_errno == EMFILE) ? ER_CANT_OPEN_FILE : ER_FILE_NOT_FOUND,
2041
2041
               errortype, buff, db_errno);
2042
2042
    }
2057
2057
    }
2058
2058
    err_no= (db_errno == ENOENT) ? ER_FILE_NOT_FOUND : (db_errno == EAGAIN) ?
2059
2059
      ER_FILE_USED : ER_CANT_OPEN_FILE;
2060
 
    strxmov(buff, share->normalized_path.str, datext, NULL);
 
2060
    sprintf(buff,"%s%s", share->normalized_path.str,datext);
2061
2061
    my_error(err_no,errortype, buff, db_errno);
2062
2062
    delete file;
2063
2063
    break;
2077
2077
    break;
2078
2078
  }
2079
2079
  case 6:
2080
 
    strxmov(buff, share->normalized_path.str, reg_ext, NULL);
 
2080
    sprintf(buff,"%s%s",share->normalized_path.str,reg_ext);
2081
2081
    my_printf_error(ER_NOT_FORM_FILE,
2082
2082
                    _("Table '%-.64s' was created with a different version "
2083
2083
                    "of MySQL and cannot be read"),
2087
2087
    break;
2088
2088
  default:                              /* Better wrong error than none */
2089
2089
  case 4:
2090
 
    strxmov(buff, share->normalized_path.str, reg_ext, NULL);
 
2090
    sprintf(buff,"%s%s",share->normalized_path.str,reg_ext);
2091
2091
    my_error(ER_NOT_FORM_FILE, errortype, buff, 0);
2092
2092
    break;
2093
2093
  }
2432
2432
  return;
2433
2433
}
2434
2434
 
2435
 
int
2436
 
rename_file_ext(const char * from,const char * to,const char * ext)
 
2435
int rename_file_ext(const char * from,const char * to,const char * ext)
2437
2436
{
2438
 
  char from_b[FN_REFLEN],to_b[FN_REFLEN];
2439
 
  strxmov(from_b,from,ext,NULL);
2440
 
  strxmov(to_b,to,ext,NULL);
2441
 
  return (my_rename(from_b,to_b,MYF(MY_WME)));
 
2437
  string from_s, to_s;
 
2438
 
 
2439
  from_s.append(from);
 
2440
  from_s.append(ext);
 
2441
  to_s.append(to);
 
2442
  to_s.append(ext);
 
2443
  return (my_rename(from_s.c_str(),to_s.c_str(),MYF(MY_WME)));
2442
2444
}
2443
2445
 
2444
2446