summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-10-15 21:41:13 +0300
committerunknown <monty@mashka.mysql.fi>2003-10-15 21:41:13 +0300
commitb06eb4d81a82be2a215e8b9b726d214c559e3f40 (patch)
tree1cffa0627ab98f85815d577bb2824198ce5de99b /sql
parent48446c0f73a99f7cb6a1f00700e6ea066ed28984 (diff)
downloadmariadb-git-b06eb4d81a82be2a215e8b9b726d214c559e3f40.tar.gz
Better fix for CREATE TABLE IF NOT EXISTS ... SELECT
Fixed chsize() problem on windows Extend default timeout on windows clients to 1 year (to avoid timeout problems) include/mysql.h: Added client timeouts (for TCP/IP) libmysql/libmysql.c: Added client timeouts (for TCP/IP) mysql-test/r/create.result: More tests for CREATE TABLE IF NOT EXISTS ... SELECT mysql-test/t/create.test: More tests for CREATE TABLE IF NOT EXISTS ... SELECT mysys/my_chsize.c: Fix for windows sql/handler.h: Remove not used field 'if_not_exists' Ordered fields to be more optimized for new CPU's Added field 'table_existed' sql/slave.cc: Cleanup temporary tables when slave ends sql/sql_class.h: Remove not used 'do_not_drop' field sql/sql_insert.cc: Better fix for CREATE TABLE IF NOT EXISTS ... SELECT sql/sql_table.cc: Better fix for CREATE TABLE IF NOT EXISTS ... SELECT
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.h18
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_insert.cc3
-rw-r--r--sql/sql_table.cc7
5 files changed, 21 insertions, 13 deletions
diff --git a/sql/handler.h b/sql/handler.h
index dfcfa44fbcd..03568e2e070 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -149,21 +149,21 @@ enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
typedef struct st_ha_create_information
{
- ulong table_options;
- enum db_type db_type;
- enum row_type row_type;
- ulong avg_row_length;
- ulonglong max_rows,min_rows;
- ulonglong auto_increment_value;
char *comment,*password;
char *data_file_name, *index_file_name;
- uint options; /* OR of HA_CREATE_ options */
- uint raid_type,raid_chunks;
+ ulonglong max_rows,min_rows;
+ ulonglong auto_increment_value;
+ ulong table_options;
+ ulong avg_row_length;
ulong raid_chunksize;
- bool if_not_exists;
ulong used_fields;
SQL_LIST merge_list;
+ enum db_type db_type;
+ enum row_type row_type;
+ uint options; /* OR of HA_CREATE_ options */
+ uint raid_type,raid_chunks;
uint merge_insert_method;
+ bool table_existed; /* 1 in create if table existed */
} HA_CREATE_INFO;
diff --git a/sql/slave.cc b/sql/slave.cc
index 12698c8eda4..9c380408291 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2719,6 +2719,8 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
RPL_LOG_NAME, llstr(rli->master_log_pos,llbuff));
err:
+ /* Free temporary tables etc */
+ thd->cleanup();
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety
VOID(pthread_mutex_unlock(&LOCK_thread_count));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7c663ce831b..27258c025d8 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -708,7 +708,6 @@ class select_create: public select_insert {
HA_CREATE_INFO *create_info;
MYSQL_LOCK *lock;
Field **field;
- my_bool do_not_drop;
public:
select_create (const char *db_name, const char *table_name,
HA_CREATE_INFO *create_info_par,
@@ -717,7 +716,7 @@ public:
List<Item> &select_fields,enum_duplicates duplic)
:select_insert (NULL, &select_fields, duplic), db(db_name),
name(table_name), extra_fields(&fields_par),keys(&keys_par),
- create_info(create_info_par), lock(0), do_not_drop(0)
+ create_info(create_info_par), lock(0)
{}
int prepare(List<Item> &list);
bool send_data(List<Item> &values);
@@ -725,6 +724,7 @@ public:
void abort();
};
+
class select_union :public select_result {
public:
TABLE *table;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index ad08ad6ccd6..3aefee61c27 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1440,7 +1440,6 @@ select_create::prepare(List<Item> &values)
if (table->fields < values.elements)
{
- do_not_drop=1;
my_printf_error(ER_WRONG_VALUE_COUNT_ON_ROW,
ER(ER_WRONG_VALUE_COUNT_ON_ROW),
MYF(0),1);
@@ -1528,7 +1527,7 @@ void select_create::abort()
enum db_type table_type=table->db_type;
if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table);
- if (!do_not_drop)
+ if (!create_info->table_existed)
quick_rm_table(table_type,db,name);
table=0;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 79105a94dec..94ecf33b9c6 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -728,7 +728,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
&& find_temporary_table(thd,db,table_name))
{
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
+ {
+ create_info->table_existed= 1; // Mark that table existed
DBUG_RETURN(0);
+ }
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
DBUG_RETURN(-1);
}
@@ -739,13 +742,17 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
{
VOID(pthread_mutex_unlock(&LOCK_open));
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
+ {
+ create_info->table_existed= 1; // Mark that table existed
DBUG_RETURN(0);
+ }
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
DBUG_RETURN(-1);
}
}
thd->proc_info="creating table";
+ create_info->table_existed= 0; // Mark that table is created
if (thd->sql_mode & MODE_NO_DIR_IN_CREATE)
create_info->data_file_name= create_info->index_file_name= 0;