~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/my_pread.cc

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "myisam_priv.h"
17
 
#include "drizzled/error.h"
18
 
#include <cerrno>
 
16
#include "myisamdef.h"
 
17
#include <mysys/mysys_err.h>
 
18
#include <errno.h>
19
19
#include <unistd.h>
20
20
 
21
 
using namespace drizzled;
22
 
 
23
21
/*
24
22
  Read a chunk of bytes from a file from a given position
25
23
 
41
39
    #             Number of bytes read
42
40
*/
43
41
 
44
 
size_t my_pread(int Filedes, unsigned char *Buffer, size_t Count, internal::my_off_t offset,
 
42
size_t my_pread(File Filedes, unsigned char *Buffer, size_t Count, my_off_t offset,
45
43
                myf MyFlags)
46
44
{
47
45
  size_t readbytes;
50
48
  {
51
49
    errno=0;                                    /* Linux doesn't reset this */
52
50
    if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
53
 
      errno= errno ? errno : -1;
 
51
      my_errno= errno ? errno : -1;
54
52
    if (error || readbytes != Count)
55
53
    {
56
54
      if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
60
58
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
61
59
      {
62
60
        if (readbytes == (size_t) -1)
63
 
          my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
 
61
          my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), "unknown", my_errno);
64
62
        else if (MyFlags & (MY_NABP | MY_FNABP))
65
 
          my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
 
63
          my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), "unknown", my_errno);
66
64
      }
67
65
      if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
68
66
        return(MY_FILE_ERROR);          /* Return with error */
96
94
*/
97
95
 
98
96
size_t my_pwrite(int Filedes, const unsigned char *Buffer, size_t Count,
99
 
                 internal::my_off_t offset, myf MyFlags)
 
97
                 my_off_t offset, myf MyFlags)
100
98
{
101
99
  size_t writenbytes, written;
102
100
  uint32_t errors;
107
105
  {
108
106
    if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count)
109
107
      break;
110
 
    errno= errno;
 
108
    my_errno= errno;
111
109
    if (writenbytes != (size_t) -1)
112
110
    {                                   /* Safegueard */
113
111
      written+=writenbytes;
116
114
      offset+=writenbytes;
117
115
    }
118
116
#ifndef NO_BACKGROUND
119
 
    if ((errno == ENOSPC || errno == EDQUOT) &&
 
117
    if (my_thread_var->abort)
 
118
      MyFlags&= ~ MY_WAIT_IF_FULL;              /* End if aborted by user */
 
119
    if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
120
120
        (MyFlags & MY_WAIT_IF_FULL))
121
121
    {
122
122
      if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
123
123
        my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
124
 
                 "unknown", errno, MY_WAIT_FOR_USER_TO_FIX_PANIC);
 
124
                 "unknown", my_errno, MY_WAIT_FOR_USER_TO_FIX_PANIC);
125
125
      sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
126
126
      continue;
127
127
    }
128
 
    if ((writenbytes && writenbytes != (size_t) -1) || errno == EINTR)
 
128
    if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR)
129
129
      continue;                                 /* Retry */
130
130
#endif
131
131
    if (MyFlags & (MY_NABP | MY_FNABP))
132
132
    {
133
133
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
134
134
      {
135
 
        my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG), "unknown", errno);
 
135
        my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG), "unknown", my_errno);
136
136
      }
137
137
      return(MY_FILE_ERROR);            /* Error on read */
138
138
    }