48 struct stat stat_info;
50 if (!(file_name= args[0]->
val_str(str)))
56 fs::path target_path(fs::system_complete(catalog::local_identifier().getPath()));
57 fs::path to_file(file_name->c_ptr());
58 if (not to_file.has_root_directory())
60 target_path /= to_file;
68 if (not secure_file_priv.string().empty())
70 fs::path secure_file_path(fs::system_complete(secure_file_priv));
71 if (target_path.string().substr(0, secure_file_path.string().size()) != secure_file_path.string())
74 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--secure-file-priv");
80 if (stat(target_path.string().c_str(), &stat_info))
82 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
86 if (!(stat_info.st_mode & S_IROTH))
88 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
92 if (stat_info.st_size > (
long) session.variables.max_allowed_packet)
94 push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
95 ER_WARN_ALLOWED_PACKET_OVERFLOWED,
96 ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
97 func_name(), session.variables.max_allowed_packet);
101 if (stat_info.st_size == 0)
106 tmp_value.alloc((
size_t)stat_info.st_size);
107 if ((file = internal::my_open(target_path.string().c_str(), O_RDONLY, MYF(0))) < 0)
112 if (internal::my_read(file, (
unsigned char*) tmp_value.ptr(), (
size_t)stat_info.st_size, MYF(MY_NABP)))
114 internal::my_close(file, MYF(0));
117 if (strlen(tmp_value.ptr()) == 0)
121 tmp_value.length((
size_t)stat_info.st_size);
122 internal::my_close(file, MYF(0));