Commit c7297eba authored by hf@deer.(none)'s avatar hf@deer.(none)

Fix for LOAD DATA to work with embedded library

parent 548d7dc9
...@@ -34,7 +34,6 @@ static char inited, org_my_init_done; ...@@ -34,7 +34,6 @@ static char inited, org_my_init_done;
#include "../sql/mysqld.cc" #include "../sql/mysqld.cc"
#endif #endif
#define SCRAMBLE_LENGTH 8
C_MODE_START C_MODE_START
#include <mysql.h> #include <mysql.h>
#include "errmsg.h" #include "errmsg.h"
......
...@@ -77,9 +77,6 @@ static int read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, ...@@ -77,9 +77,6 @@ static int read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
List<Item> &fields, READ_INFO &read_info, List<Item> &fields, READ_INFO &read_info,
String &enclosed); String &enclosed);
#ifndef EMBEDDED_LIBRARY
int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
List<Item> &fields, enum enum_duplicates handle_duplicates, List<Item> &fields, enum enum_duplicates handle_duplicates,
bool read_file_from_client,thr_lock_type lock_type) bool read_file_from_client,thr_lock_type lock_type)
...@@ -91,7 +88,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -91,7 +88,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
String *field_term=ex->field_term,*escaped=ex->escaped, String *field_term=ex->field_term,*escaped=ex->escaped,
*enclosed=ex->enclosed; *enclosed=ex->enclosed;
bool is_fifo=0; bool is_fifo=0;
#ifndef EMBEDDED_LIBRARY
LOAD_FILE_INFO lf_info; LOAD_FILE_INFO lf_info;
#endif
char *db = table_list->db; // This is never null char *db = table_list->db; // This is never null
/* If no current database, use database where table is located */ /* If no current database, use database where table is located */
char *tdb= thd->db ? thd->db : db; char *tdb= thd->db ? thd->db : db;
...@@ -184,6 +183,17 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -184,6 +183,17 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
} }
else else
{ {
#ifdef EMBEDDED_LIBRARY
char *chk_name= ex->file_name;
while ((*chk_name == ' ') || (*chk_name == 't'))
chk_name++;
if (*chk_name == FN_CURLIB)
{
sprintf(name, "%s%s", mysql_data_home, ex->file_name);
unpack_filename(name, name);
}
else
#endif /*EMBEDDED_LIBRARY*/
unpack_filename(name,ex->file_name); unpack_filename(name,ex->file_name);
#if !defined(__WIN__) && !defined(OS2) && ! defined(__NETWARE__) #if !defined(__WIN__) && !defined(OS2) && ! defined(__NETWARE__)
MY_STAT stat_info; MY_STAT stat_info;
...@@ -225,6 +235,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -225,6 +235,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_RETURN(-1); // Can't allocate buffers DBUG_RETURN(-1); // Can't allocate buffers
} }
#ifndef EMBEDDED_LIBRARY
if (!opt_old_rpl_compat && mysql_bin_log.is_open()) if (!opt_old_rpl_compat && mysql_bin_log.is_open())
{ {
lf_info.thd = thd; lf_info.thd = thd;
...@@ -238,6 +249,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -238,6 +249,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
lf_info.log_delayed= log_delayed; lf_info.log_delayed= log_delayed;
read_info.set_io_cache_arg((void*) &lf_info); read_info.set_io_cache_arg((void*) &lf_info);
} }
#endif /*!EMBEDDED_LIBRARY*/
restore_record(table,default_values); restore_record(table,default_values);
thd->count_cuted_fields=1; /* calc cuted fields */ thd->count_cuted_fields=1; /* calc cuted fields */
...@@ -293,6 +306,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -293,6 +306,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{ {
if (transactional_table) if (transactional_table)
ha_autocommit_or_rollback(thd,error); ha_autocommit_or_rollback(thd,error);
#ifndef EMBEDDED_LIBRARY
if (!opt_old_rpl_compat && mysql_bin_log.is_open()) if (!opt_old_rpl_compat && mysql_bin_log.is_open())
{ {
if (lf_info.wrote_create_file) if (lf_info.wrote_create_file)
...@@ -315,6 +329,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -315,6 +329,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
mysql_bin_log.write(&d); mysql_bin_log.write(&d);
} }
} }
#endif /*!EMBEDDED_LIBRARY*/
error= -1; // Error on read error= -1; // Error on read
goto err; goto err;
} }
...@@ -327,6 +342,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -327,6 +342,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if (!log_delayed) if (!log_delayed)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
#ifndef EMBEDDED_LIBRARY
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
if (opt_old_rpl_compat) if (opt_old_rpl_compat)
...@@ -348,6 +364,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -348,6 +364,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
} }
} }
} }
#endif /*!EMBEDDED_LIBRARY*/
if (transactional_table) if (transactional_table)
error=ha_autocommit_or_rollback(thd,error); error=ha_autocommit_or_rollback(thd,error);
err: err:
...@@ -359,8 +376,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -359,8 +376,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_RETURN(error); DBUG_RETURN(error);
} }
#endif /* EMBEDDED_LIBRARY */
/**************************************************************************** /****************************************************************************
** Read of rows of fixed size + optional garage + optonal newline ** Read of rows of fixed size + optional garage + optonal newline
****************************************************************************/ ****************************************************************************/
...@@ -640,11 +655,12 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, ...@@ -640,11 +655,12 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
mysys/mf_iocache.c. So we work around the problem with a mysys/mf_iocache.c. So we work around the problem with a
manual assignment manual assignment
*/ */
need_end_io_cache = 1;
#ifndef EMBEDDED_LIBRARY
if (get_it_from_net) if (get_it_from_net)
cache.read_function = _my_b_net_read; cache.read_function = _my_b_net_read;
need_end_io_cache = 1;
#ifndef EMBEDDED_LIBRARY
if (!opt_old_rpl_compat && mysql_bin_log.is_open()) if (!opt_old_rpl_compat && mysql_bin_log.is_open())
cache.pre_read = cache.pre_close = cache.pre_read = cache.pre_close =
(IO_CACHE_CALLBACK) log_loaded_block; (IO_CACHE_CALLBACK) log_loaded_block;
......
...@@ -2755,7 +2755,7 @@ mysql_execute_command(THD *thd) ...@@ -2755,7 +2755,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_CHANGE_DB: case SQLCOM_CHANGE_DB:
mysql_change_db(thd,select_lex->db); mysql_change_db(thd,select_lex->db);
break; break;
#ifndef EMBEDDED_LIBRARY
case SQLCOM_LOAD: case SQLCOM_LOAD:
{ {
uint privilege= (lex->duplicates == DUP_REPLACE ? uint privilege= (lex->duplicates == DUP_REPLACE ?
...@@ -2782,7 +2782,7 @@ mysql_execute_command(THD *thd) ...@@ -2782,7 +2782,7 @@ mysql_execute_command(THD *thd)
lex->duplicates, (bool) lex->local_file, lex->lock_option); lex->duplicates, (bool) lex->local_file, lex->lock_option);
break; break;
} }
#endif /* EMBEDDED_LIBRARY */
case SQLCOM_SET_OPTION: case SQLCOM_SET_OPTION:
if (tables && ((res= check_table_access(thd, SELECT_ACL, tables)) || if (tables && ((res= check_table_access(thd, SELECT_ACL, tables)) ||
(res= open_and_lock_tables(thd,tables)))) (res= open_and_lock_tables(thd,tables))))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment