From 8300158d768b4b25633c707137b2713d4433e973 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Feb 2003 15:28:28 +0200 Subject: A fix for a crashing bug with unspecified database in this type of command: load data infile 'filename' into table db.table; --- sql/sql_load.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sql/sql_load.cc') diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ba62b1d5c20..c4ea41cbb69 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -90,6 +90,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool is_fifo=0; LOAD_FILE_INFO lf_info; char * db = table_list->db ? table_list->db : thd->db; + char * tdb= thd->db ? thd->db : db; +/* + 'tdb' can be NULL only if both table_list->db and thd->db are NULL + 'db' itself can be NULL. but in that case it will generate + an error earlier open_ltable()). +*/ + bool transactional_table, log_delayed; DBUG_ENTER("mysql_load"); @@ -168,10 +175,10 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ex->file_name+=dirname_length(ex->file_name); #endif if (!dirname_length(ex->file_name) && - strlen(ex->file_name)+strlen(mysql_data_home)+strlen(thd->db)+3 < + strlen(ex->file_name)+strlen(mysql_data_home)+strlen(tdb)+3 < FN_REFLEN) { - (void) sprintf(name,"%s/%s/%s",mysql_data_home,thd->db,ex->file_name); + (void) sprintf(name,"%s/%s/%s",mysql_data_home,tdb,ex->file_name); unpack_filename(name,name); /* Convert to system format */ } else -- cgit v1.2.1 From 66afa065530f724702b82e51c3c88a8770330230 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2003 00:06:09 +0200 Subject: Code cleanup --- sql/sql_load.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sql/sql_load.cc') diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c4ea41cbb69..62ed0fc5bed 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -89,14 +89,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, *enclosed=ex->enclosed; bool is_fifo=0; LOAD_FILE_INFO lf_info; - char * db = table_list->db ? table_list->db : thd->db; - char * tdb= thd->db ? thd->db : db; -/* - 'tdb' can be NULL only if both table_list->db and thd->db are NULL - 'db' itself can be NULL. but in that case it will generate - an error earlier open_ltable()). -*/ - + char *db = table_list->db; // This is never null + /* If no current database, use database where table is located */ + char *tdb= thd->db ? thd->db : db; bool transactional_table, log_delayed; DBUG_ENTER("mysql_load"); -- cgit v1.2.1