85
87
void set_io_cache_arg(void* arg) { cache.arg = arg; }
88
static int read_fixed_length(Session *session, COPY_INFO &info, TableList *table_list,
90
static int read_fixed_length(Session *session, CopyInfo &info, TableList *table_list,
89
91
List<Item> &fields_vars, List<Item> &set_fields,
90
92
List<Item> &set_values, READ_INFO &read_info,
91
93
uint32_t skip_lines,
92
94
bool ignore_check_option_errors);
93
static int read_sep_field(Session *session, COPY_INFO &info, TableList *table_list,
95
static int read_sep_field(Session *session, CopyInfo &info, TableList *table_list,
94
96
List<Item> &fields_vars, List<Item> &set_fields,
95
97
List<Item> &set_values, READ_INFO &read_info,
96
98
String &enclosed, uint32_t skip_lines,
256
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
257
ex->file_name+=dirname_length(ex->file_name);
259
if (!internal::dirname_length(ex->file_name))
261
strcpy(name, drizzle_real_data_home);
262
strncat(name, tdb, FN_REFLEN-strlen(drizzle_real_data_home)-1);
263
(void) internal::fn_format(name, ex->file_name, name, "",
264
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
268
(void) internal::fn_format(name, ex->file_name, drizzle_real_data_home, "",
269
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
271
if (opt_secure_file_priv &&
272
strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
274
/* Read only allowed from within dir specified by secure_file_priv */
275
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
279
struct stat stat_info;
280
if (stat(name,&stat_info))
282
my_error(ER_FILE_NOT_FOUND, MYF(0), name, errno);
286
// if we are not in slave thread, the cursor must be:
287
if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
288
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
289
((stat_info.st_mode & S_IFREG) == S_IFREG ||
290
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
292
my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
295
if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
298
if ((file=internal::my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
300
my_error(ER_CANT_OPEN_FILE, MYF(0), name, errno);
256
fs::path to_file(ex->file_name);
257
fs::path target_path(fs::system_complete(getDataHomeCatalog()));
258
if (not to_file.has_root_directory())
260
int count_elements= 0;
261
for (fs::path::iterator iter= to_file.begin();
262
iter != to_file.end();
263
++iter, ++count_elements)
266
if (count_elements == 1)
270
target_path /= to_file;
274
target_path= to_file;
277
if (not secure_file_priv.string().empty())
279
if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string())
281
/* Read only allowed from within dir specified by secure_file_priv */
282
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
287
struct stat stat_info;
288
if (stat(target_path.file_string().c_str(), &stat_info))
290
my_error(ER_FILE_NOT_FOUND, MYF(0), target_path.file_string().c_str(), errno);
294
// if we are not in slave thread, the cursor must be:
295
if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
296
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
297
((stat_info.st_mode & S_IFREG) == S_IFREG ||
298
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
300
my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), target_path.file_string().c_str());
303
if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
307
if ((file=internal::my_open(target_path.file_string().c_str(), O_RDONLY,MYF(MY_WME))) < 0)
309
my_error(ER_CANT_OPEN_FILE, MYF(0), target_path.file_string().c_str(), errno);
306
313
memset(&info, 0, sizeof(info));
307
314
info.ignore= ignore;
308
315
info.handle_duplicates=handle_duplicates;
388
395
error= -1; // Error on read
391
snprintf(name, sizeof(name), ER(ER_LOAD_INFO), (uint32_t) info.records, (uint32_t) info.deleted,
392
(uint32_t) (info.records - info.copied), (uint32_t) session->cuted_fields);
400
snprintf(msg, sizeof(msg), ER(ER_LOAD_INFO), info.records, info.deleted,
401
(info.records - info.copied), session->cuted_fields);
394
403
if (session->transaction.stmt.hasModifiedNonTransData())
395
404
session->transaction.all.markModifiedNonTransData();
397
406
/* ok to client sent only after binlog write and engine commit */
398
session->my_ok(info.copied + info.deleted, 0, 0L, name);
407
session->my_ok(info.copied + info.deleted, 0, 0L, msg);
400
409
assert(transactional_table || !(info.copied || info.deleted) ||
401
410
session->transaction.stmt.hasModifiedNonTransData());
411
420
****************************************************************************/
414
read_fixed_length(Session *session, COPY_INFO &info, TableList *table_list,
423
read_fixed_length(Session *session, CopyInfo &info, TableList *table_list,
415
424
List<Item> &fields_vars, List<Item> &set_fields,
416
425
List<Item> &set_values, READ_INFO &read_info,
417
426
uint32_t skip_lines, bool ignore_check_option_errors)
533
read_sep_field(Session *session, COPY_INFO &info, TableList *table_list,
542
read_sep_field(Session *session, CopyInfo &info, TableList *table_list,
534
543
List<Item> &fields_vars, List<Item> &set_fields,
535
544
List<Item> &set_values, READ_INFO &read_info,
536
545
String &enclosed, uint32_t skip_lines,