~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/local_infile.c

  • Committer: Stewart Smith
  • Date: 2008-09-15 07:13:59 UTC
  • mfrom: (383.1.21 drizzle)
  • mto: This revision was merged to the branch mainline in revision 408.
  • Revision ID: stewart@flamingspork.com-20080915071359-f8bznznyaiqrtqxa
merged

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
#include <drizzled/global.h>
22
 
#include <mysys/my_sys.h>
23
 
#include "my_time.h"
24
 
#include <mysys/mysys_err.h>
25
 
#include <mystrings/m_string.h>
26
 
#include <mystrings/m_ctype.h>
27
22
#include "drizzle.h"
28
23
#include "errmsg.h"
29
 
#include <vio/violite.h>
30
24
#include <sys/stat.h>
31
25
#include <signal.h>
32
26
#include <time.h>
92
86
  {
93
87
    VOID(my_net_write(net,(const uchar*) "",0)); /* Server needs one packet */
94
88
    net_flush(net);
95
 
    strmov(net->sqlstate, unknown_sqlstate);
 
89
    strcpy(net->sqlstate, unknown_sqlstate);
96
90
    net->last_errno=
97
91
      (*options->local_infile_error)(li_ptr,
98
92
                                     net->last_error,
183
177
  data->error_num=    0;
184
178
  data->filename= filename;
185
179
 
186
 
  fn_format(tmp_name, filename, "", "", MY_UNPACK_FILENAME);
187
 
  if ((data->fd = my_open(tmp_name, O_RDONLY, MYF(0))) < 0)
 
180
  if ((data->fd = open(tmp_name, O_RDONLY)) < 0)
188
181
  {
189
 
    data->error_num= my_errno;
 
182
    data->error_num= errno;
190
183
    snprintf(data->error_msg, sizeof(data->error_msg)-1,
191
 
             EE(EE_FILENOTFOUND), tmp_name, data->error_num);
 
184
             _("File '%s' not found (Errcode: %d)"), tmp_name, data->error_num);
192
185
    return 1;
193
186
  }
194
187
  return 0; /* ok */
215
208
  int count;
216
209
  default_local_infile_data*data = (default_local_infile_data *) ptr;
217
210
 
218
 
  if ((count= (int) my_read(data->fd, (uchar *) buf, buf_len, MYF(0))) < 0)
 
211
  if ((count= (int) read(data->fd, (uchar *) buf, buf_len)) < 0)
219
212
  {
220
 
    data->error_num= EE_READ; /* the errmsg for not entire file read */
 
213
    data->error_num= 2; /* the errmsg for not entire file read */
221
214
    snprintf(data->error_msg, sizeof(data->error_msg)-1,
222
 
             EE(EE_READ),
223
 
             data->filename, my_errno);
 
215
             _("Error reading file '%s' (Errcode: %d)"),
 
216
             data->filename, errno);
224
217
  }
225
218
  return count;
226
219
}
243
236
  if (data)          /* If not error on open */
244
237
  {
245
238
    if (data->fd >= 0)
246
 
      my_close(data->fd, MYF(MY_WME));
 
239
      close(data->fd);
247
240
    free(ptr);
248
241
  }
249
242
}
269
262
  default_local_infile_data *data = (default_local_infile_data *) ptr;
270
263
  if (data)          /* If not error on open */
271
264
  {
272
 
    strmake(error_msg, data->error_msg, error_msg_len);
 
265
    strncpy(error_msg, data->error_msg, error_msg_len);
273
266
    return data->error_num;
274
267
  }
275
268
  /* This can only happen if we got error on malloc of handle */
276
 
  strmov(error_msg, ER(CR_OUT_OF_MEMORY));
 
269
  strcpy(error_msg, ER(CR_OUT_OF_MEMORY));
277
270
  return CR_OUT_OF_MEMORY;
278
271
}
279
272