~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_cache.c

  • Committer: Brian Aker
  • Date: 2008-07-14 22:40:46 UTC
  • Revision ID: brian@tangent.org-20080714224046-x183907w9wp1txwv
Removed sql_manager. Ever heard of just setting up the OS to sync when you
want it to?

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  expected to hit the cache again.
27
27
 
28
28
  Allows "partial read" errors in the record header (when READING_HEADER flag
29
 
  is set) - unread part is zero'ed
 
29
  is set) - unread part is bzero'ed
30
30
 
31
31
  Note: out-of-cache reads are enabled for shared IO_CACHE's too,
32
32
  as these reads will be cached by OS cache (and my_pread is always atomic)
35
35
 
36
36
#include "myisamdef.h"
37
37
 
38
 
int _mi_read_cache(IO_CACHE *info, unsigned char *buff, my_off_t pos, uint32_t length,
 
38
int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length,
39
39
                   int flag)
40
40
{
41
 
  uint32_t read_length,in_buff_length;
 
41
  uint read_length,in_buff_length;
42
42
  my_off_t offset;
43
 
  unsigned char *in_buff_pos;
 
43
  uchar *in_buff_pos;
 
44
  DBUG_ENTER("_mi_read_cache");
44
45
 
45
46
  if (pos < info->pos_in_file)
46
47
  {
49
50
      read_length=(uint) (info->pos_in_file-pos);
50
51
    info->seek_not_done=1;
51
52
    if (my_pread(info->file,buff,read_length,pos,MYF(MY_NABP)))
52
 
      return(1);
 
53
      DBUG_RETURN(1);
53
54
    if (!(length-=read_length))
54
 
      return(0);
 
55
      DBUG_RETURN(0);
55
56
    pos+=read_length;
56
57
    buff+=read_length;
57
58
  }
60
61
      (my_off_t) (info->read_end - info->request_pos))
61
62
  {
62
63
    in_buff_pos=info->request_pos+(uint) offset;
63
 
    in_buff_length= cmin(length, (size_t) (info->read_end-in_buff_pos));
 
64
    in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
64
65
    memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
65
66
    if (!(length-=in_buff_length))
66
 
      return(0);
 
67
      DBUG_RETURN(0);
67
68
    pos+=in_buff_length;
68
69
    buff+=in_buff_length;
69
70
  }
81
82
    else
82
83
      info->read_pos=info->read_end;                    /* All block used */
83
84
    if (!(*info->read_function)(info,buff,length))
84
 
      return(0);
 
85
      DBUG_RETURN(0);
85
86
    read_length=info->error;
86
87
  }
87
88
  else
88
89
  {
89
90
    info->seek_not_done=1;
90
91
    if ((read_length=my_pread(info->file,buff,length,pos,MYF(0))) == length)
91
 
      return(0);
 
92
      DBUG_RETURN(0);
92
93
  }
93
94
  if (!(flag & READING_HEADER) || (int) read_length == -1 ||
94
95
      read_length+in_buff_length < 3)
95
96
  {
 
97
    DBUG_PRINT("error",
 
98
               ("Error %d reading next-multi-part block (Got %d bytes)",
 
99
                my_errno, (int) read_length));
96
100
    if (!my_errno || my_errno == -1)
97
101
      my_errno=HA_ERR_WRONG_IN_RECORD;
98
 
    return(1);
 
102
    DBUG_RETURN(1);
99
103
  }
100
 
  memset(buff+read_length, 0,
101
 
         MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length - read_length);
102
 
  return(0);
 
104
  bzero(buff+read_length,MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length -
 
105
        read_length);
 
106
  DBUG_RETURN(0);
103
107
} /* _mi_read_cache */