258
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
259
ex->file_name+=dirname_length(ex->file_name);
261
if (!internal::dirname_length(ex->file_name))
263
strcpy(name, getDataHomeCatalog().c_str());
264
strncat(name, "/", 1);
265
strncat(name, tdb, FN_REFLEN-getDataHomeCatalog().size());
266
(void) internal::fn_format(name, ex->file_name, name, "",
267
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
271
(void) internal::fn_format(name, ex->file_name, getDataHomeCatalog().c_str(), "",
272
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
274
if (opt_secure_file_priv)
276
fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv)));
277
fs::path target_path(fs::system_complete(fs::path(name)));
278
if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())
280
/* Read only allowed from within dir specified by secure_file_priv */
281
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
286
struct stat stat_info;
287
if (stat(name,&stat_info))
289
my_error(ER_FILE_NOT_FOUND, MYF(0), name, errno);
293
// if we are not in slave thread, the cursor must be:
294
if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
295
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
296
((stat_info.st_mode & S_IFREG) == S_IFREG ||
297
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
299
my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
302
if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
305
if ((file=internal::my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
307
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);
313
313
memset(&info, 0, sizeof(info));
314
314
info.ignore= ignore;
395
395
error= -1; // Error on read
398
snprintf(name, sizeof(name), ER(ER_LOAD_INFO), info.records, info.deleted,
400
snprintf(msg, sizeof(msg), ER(ER_LOAD_INFO), info.records, info.deleted,
399
401
(info.records - info.copied), session->cuted_fields);
401
403
if (session->transaction.stmt.hasModifiedNonTransData())
402
404
session->transaction.all.markModifiedNonTransData();
404
406
/* ok to client sent only after binlog write and engine commit */
405
session->my_ok(info.copied + info.deleted, 0, 0L, name);
407
session->my_ok(info.copied + info.deleted, 0, 0L, msg);
407
409
assert(transactional_table || !(info.copied || info.deleted) ||
408
410
session->transaction.stmt.hasModifiedNonTransData());