12
13
You should have received a copy of the GNU General Public License
13
14
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
19
/* Copy data from a textfile to table */
314
316
(void) fn_format(name, ex->file_name, mysql_real_data_home, "",
315
317
MY_RELATIVE_PATH | MY_UNPACK_FILENAME |
316
318
MY_RETURN_REAL_PATH);
317
#if !defined(__WIN__) && ! defined(__NETWARE__)
319
if (!my_stat(name,&stat_info,MYF(MY_WME)))
322
// if we are not in slave thread, the file must be:
323
if (!thd->slave_thread &&
324
!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
325
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
326
((stat_info.st_mode & S_IFREG) == S_IFREG ||
327
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
329
my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
332
if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
336
if (thd->slave_thread)
321
if (thd->slave_thread)
338
323
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
339
if (strncmp(active_mi->rli.slave_patternload_file, name,
340
active_mi->rli.slave_patternload_file_size))
343
LOAD DATA INFILE in the slave SQL Thread can only read from
344
--slave-load-tmpdir". This should never happen. Please, report a bug.
347
sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
348
"Please, report a bug.");
349
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
324
if (strncmp(active_mi->rli.slave_patternload_file, name,
325
active_mi->rli.slave_patternload_file_size))
354
This is impossible and should never happen.
328
LOAD DATA INFILE in the slave SQL Thread can only read from
329
--slave-load-tmpdir". This should never happen. Please, report a bug.
359
else if (!is_secure_file_path(name))
361
/* Read only allowed from within dir specified by secure_file_priv */
362
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
332
sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
333
"Please, report a bug.");
334
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
363
335
DBUG_RETURN(TRUE);
339
This is impossible and should never happen.
344
else if (!is_secure_file_path(name))
346
/* Read only allowed from within dir specified by secure_file_priv */
347
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
351
#if !defined(__WIN__) && ! defined(__NETWARE__)
353
if (!my_stat(name, &stat_info, MYF(MY_WME)))
356
// if we are not in slave thread, the file must be:
357
if (!thd->slave_thread &&
358
!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
359
(stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
360
((stat_info.st_mode & S_IFREG) == S_IFREG || // and a regular file
361
(stat_info.st_mode & S_IFIFO) == S_IFIFO))) // or FIFO
363
my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
366
if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
367
370
if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
368
371
DBUG_RETURN(TRUE);
1067
1077
String &field_term, String &line_start, String &line_term,
1068
1078
String &enclosed_par, int escape, bool get_it_from_net,
1070
:file(file_par),escape_char(escape)
1080
:file(file_par), buff_length(tot_length), escape_char(escape),
1081
found_end_of_line(false), eof(false), need_end_io_cache(false),
1082
error(false), line_cuted(false), found_null(false), read_charset(cs)
1073
1084
field_term_ptr=(char*) field_term.ptr();
1074
1085
field_term_length= field_term.length();
1075
1086
line_term_ptr=(char*) line_term.ptr();
1096
1107
(uchar) enclosed_par[0] : INT_MAX;
1097
1108
field_term_char= field_term_length ? (uchar) field_term_ptr[0] : INT_MAX;
1098
1109
line_term_char= line_term_length ? (uchar) line_term_ptr[0] : INT_MAX;
1099
error=eof=found_end_of_line=found_null=line_cuted=0;
1100
buff_length=tot_length;
1103
1112
/* Set of a stack for unget if long terminators */
1104
uint length=max(field_term_length,line_term_length)+1;
1113
uint length= max(cs->mbmaxlen, max(field_term_length, line_term_length)) + 1;
1105
1114
set_if_bigger(length,line_start.length());
1106
1115
stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);