summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-04 15:37:20 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-04 15:37:20 +0200
commite229fe9801cc9fb7e3783cf708bc7cb695606c64 (patch)
treeaa5cff7e153050d86b7effd693496f071d21e24a
parenteebc67f6f8df9e0bdcde7770e383992ff6cad451 (diff)
downloadmariadb-git-e229fe9801cc9fb7e3783cf708bc7cb695606c64.tar.gz
Added support for DROP TEMPORARY TABLE
Removed mysql_warnings() API function. Post merge fixes. client/mysqltest.c: Don't use mysql_warnings(). include/mysql.h: Removed mysql_warnings() API function libmysql/libmysql.c: Removed mysql_warnings() API function mysql-test/r/rpl_log_pos.result: Updated results mysql-test/t/connect.test: Removed empty lines mysql-test/t/rpl_log_pos.test: Update to new syntax sql/item.h: Fix after merge sql/item_create.cc: Fix after merge sql/mysql_priv.h: Added support for DROP TEMPORARY TABLE sql/sql_db.cc: Added support for DROP TEMPORARY TABLE sql/sql_parse.cc: SHOW WARNINGS now shows notes, warnings and errors. Support for DROP TEMPORARY TABLE Post merge fixes sql/sql_repl.cc: Post merge fixes sql/sql_table.cc: Added support for DROP TEMPORARY TABLE
-rw-r--r--client/mysqltest.c11
-rw-r--r--include/mysql.h1
-rw-r--r--libmysql/libmysql.c12
-rw-r--r--mysql-test/r/rpl_log_pos.result6
-rw-r--r--mysql-test/t/connect.test2
-rw-r--r--mysql-test/t/rpl_log_pos.test8
-rw-r--r--sql/item.h3
-rw-r--r--sql/item_create.cc3
-rw-r--r--sql/mysql_priv.h7
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_parse.cc29
-rw-r--r--sql/sql_repl.cc8
-rw-r--r--sql/sql_table.cc66
13 files changed, 89 insertions, 69 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 9d724404edc..6a637c0533c 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2207,10 +2207,15 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
/* Add all warnings to the result */
if (!disable_result_log && mysql_warning_count(mysql))
{
- MYSQL_RES *warn_res= mysql_warnings(mysql);
+ MYSQL_RES *warn_res=0;
+ uint count= mysql_warning_count(mysql);
+ if (!mysql_real_query(mysql, "SHOW WARNINGS", 13))
+ {
+ warn_res=mysql_store_result(mysql);
+ }
if (!warn_res)
- verbose_msg("Warning count is %d but didn't get any warnings\n",
- mysql_warning_count(mysql));
+ verbose_msg("Warning count is %u but didn't get any warnings\n",
+ count);
else
{
dynstr_append_mem(ds, "Warnings:\n", 10);
diff --git a/include/mysql.h b/include/mysql.h
index 063d7227351..f9b8c1ecbb3 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -381,7 +381,6 @@ MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
-MYSQL_RES * STDCALL mysql_warnings(MYSQL *mysql);
int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
const char *arg);
void STDCALL mysql_free_result(MYSQL_RES *result);
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 8314b3bc24e..8cf59281719 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3515,18 +3515,6 @@ uint STDCALL mysql_thread_safe(void)
#endif
}
-MYSQL_RES *STDCALL mysql_warnings(MYSQL *mysql)
-{
- uint warning_count;
- DBUG_ENTER("mysql_warnings");
- /* Save warning count as mysql_real_query may change this */
- warning_count= mysql->warning_count;
- if (mysql_real_query(mysql, "SHOW WARNINGS", 13))
- DBUG_RETURN(0);
- mysql->warning_count= warning_count;
- DBUG_RETURN(mysql_store_result(mysql));
-}
-
/****************************************************************************
Some support functions
****************************************************************************/
diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result
index 4ba3736604e..fa38e42ae73 100644
--- a/mysql-test/r/rpl_log_pos.result
+++ b/mysql-test/r/rpl_log_pos.result
@@ -10,9 +10,9 @@ master-bin.000001 79
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 127
-slave stop;
+stop slave;
change master to master_log_pos=73;
-slave start;
+start slave;
stop slave;
change master to master_log_pos=73;
show slave status;
@@ -35,7 +35,7 @@ create table if not exists t1 (n int);
drop table if exists t1;
create table t1 (n int);
insert into t1 values (1),(2),(3);
-slave stop;
+stop slave;
change master to master_log_pos=79;
start slave;
select * from t1;
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index 0bc5ca3914f..192d3eaf3e0 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -63,5 +63,3 @@ show tables;
#--error 1045
#connect (con1,localhost,test,zorro,);
#--error 1045
-
-
diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test
index 03c86137ae0..bc1349a959a 100644
--- a/mysql-test/t/rpl_log_pos.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -6,9 +6,9 @@ show master status;
sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=73;
-slave start;
+start slave;
sleep 5;
stop slave;
@@ -19,7 +19,7 @@ start slave;
sleep 5;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=173;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
start slave;
@@ -34,7 +34,7 @@ create table t1 (n int);
insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
-slave stop;
+stop slave;
change master to master_log_pos=79;
start slave;
sync_with_master;
diff --git a/sql/item.h b/sql/item.h
index 1ea76731fd3..89867a8cdbd 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -381,7 +381,8 @@ public:
name=(char*) str_value.ptr();
decimals=NOT_FIXED_DEC;
}
- Item_string(const char *name_par,const char *str,uint length,CHARSET_INFO *cs)
+ Item_string(const char *name_par,const char *str,uint length,
+ CHARSET_INFO *cs)
{
str_value.set(str,length,cs);
max_length=length;
diff --git a/sql/item_create.cc b/sql/item_create.cc
index f277061394a..0dba7f6e3ae 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -311,7 +311,8 @@ Item *create_func_current_user()
length= (uint) (strxmov(buff, thd->priv_user, "@", thd->host_or_ip, NullS) -
buff);
- return new Item_string("CURRENT_USER()", thd->memdup(buff, length), length);
+ return new Item_string("CURRENT_USER()", thd->memdup(buff, length), length,
+ default_charset_info);
}
Item *create_func_quarter(Item* a)
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index cf0cefd76da..3d5adf24e03 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -323,11 +323,12 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
-int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists);
+int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
+ my_bool drop_temporary);
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
- bool log_query);
+ bool drop_temporary, bool log_query);
int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables,
- bool if_exists,
+ bool if_exists, bool drop_temporary,
bool log_query);
int quick_rm_table(enum db_type base,const char *db,
const char *table_name);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 311bf29aee7..7ff4caf356c 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -468,7 +468,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
my_dirend(dirp);
if (thd->killed ||
- (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 1)))
+ (tot_list && mysql_rm_table_part2_with_lock(thd, tot_list, 1, 0, 1)))
DBUG_RETURN(-1);
/*
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6f8c53cede0..85658a93791 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -963,7 +963,7 @@ bool do_command(THD *thd)
}
else if (!packet_length)
{
- send_error(net,net->last_errno,NullS);
+ send_error(thd,net->last_errno,NullS);
net->error=0;
DBUG_RETURN(FALSE);
}
@@ -1629,7 +1629,9 @@ mysql_execute_command(THD *thd)
{
res= mysqld_show_warnings(thd, (ulong)
((1L << (uint) MYSQL_ERROR::WARN_LEVEL_NOTE) |
- (1L << (uint) MYSQL_ERROR::WARN_LEVEL_WARN)));
+ (1L << (uint) MYSQL_ERROR::WARN_LEVEL_WARN) |
+ (1L << (uint) MYSQL_ERROR::WARN_LEVEL_ERROR)
+ ));
break;
}
case SQLCOM_SHOW_ERRORS:
@@ -1883,7 +1885,7 @@ mysql_execute_command(THD *thd)
*/
if (thd->locked_tables || thd->active_transaction())
{
- send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION);
+ send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
break;
}
{
@@ -2293,12 +2295,17 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_DROP_TABLE:
{
- if (check_table_access(thd,DROP_ACL,tables))
- goto error; /* purecov: inspected */
- if (end_active_trans(thd))
- res= -1;
- else
- res = mysql_rm_table(thd,tables,lex->drop_if_exists);
+ if (!lex->drop_temporary)
+ {
+ if (check_table_access(thd,DROP_ACL,tables))
+ goto error; /* purecov: inspected */
+ if (end_active_trans(thd))
+ {
+ res= -1;
+ break;
+ }
+ }
+ res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary);
}
break;
case SQLCOM_DROP_INDEX:
@@ -3777,9 +3784,9 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
if (thd && !error_already_sent)
{
if (result)
- send_error(&thd->net,0);
+ send_error(thd,0);
else
- send_ok(&thd->net);
+ send_ok(thd);
}
return result;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index c3c9d508bf6..5bdc15c2bf0 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -757,7 +757,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
err:
unlock_slave_threads(mi);
if (thd && error)
- send_error(&thd->net, sql_errno, errmsg);
+ send_error(thd, sql_errno, errmsg);
DBUG_RETURN(error);
}
@@ -802,7 +802,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
init_thread_mask(&thread_mask,mi,0 /*not inverse*/);
if (thread_mask) // We refuse if any slave thread is running
{
- net_printf(&thd,ER_SLAVE_MUST_STOP);
+ net_printf(thd,ER_SLAVE_MUST_STOP);
unlock_slave_threads(mi);
DBUG_RETURN(1);
}
@@ -874,7 +874,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
0 /* not only reset, but also reinit */,
&errmsg))
{
- net_printf(&thd, 0, "Failed purging old relay logs: %s",errmsg);
+ net_printf(thd, 0, "Failed purging old relay logs: %s",errmsg);
unlock_slave_threads(mi);
DBUG_RETURN(1);
}
@@ -908,7 +908,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
unlock_slave_threads(mi);
thd->proc_info = 0;
- send_ok(&thd);
+ send_ok(thd);
DBUG_RETURN(0);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1ab84531e40..4848c374932 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -46,7 +46,8 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
** This will wait for all users to free the table before dropping it
*****************************************************************************/
-int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
+int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
+ my_bool drop_temporary)
{
int error;
DBUG_ENTER("mysql_rm_table");
@@ -57,7 +58,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
thd->mysys_var->current_cond= &COND_refresh;
VOID(pthread_mutex_lock(&LOCK_open));
- if (global_read_lock)
+ if (!drop_temporary && global_read_lock)
{
if (thd->global_read_lock)
{
@@ -72,7 +73,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
}
}
- error=mysql_rm_table_part2(thd,tables,if_exists,0);
+ error=mysql_rm_table_part2(thd,tables, if_exists, drop_temporary, 0);
err:
pthread_mutex_unlock(&LOCK_open);
@@ -91,14 +92,15 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
int mysql_rm_table_part2_with_lock(THD *thd,
TABLE_LIST *tables, bool if_exists,
- bool dont_log_query)
+ bool drop_temporary, bool dont_log_query)
{
int error;
thd->mysys_var->current_mutex= &LOCK_open;
thd->mysys_var->current_cond= &COND_refresh;
VOID(pthread_mutex_lock(&LOCK_open));
- error=mysql_rm_table_part2(thd,tables, if_exists, dont_log_query);
+ error=mysql_rm_table_part2(thd,tables, if_exists, drop_temporary,
+ dont_log_query);
pthread_mutex_unlock(&LOCK_open);
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
@@ -111,6 +113,17 @@ int mysql_rm_table_part2_with_lock(THD *thd,
}
/*
+ Execute the drop of a normal or temporary table
+
+ SYNOPSIS
+ mysql_rm_table_part2()
+ thd Thread handler
+ tables Tables to drop
+ if_exists If set, don't give an error if table doesn't exists.
+ In this case we give an warning of level 'NOTE'
+ drop_temporary Only drop temporary tables
+ dont_log_query Don't log the query
+
TODO:
When logging to the binary log, we should log
tmp_tables and transactional tables as separate statements if we
@@ -120,10 +133,15 @@ int mysql_rm_table_part2_with_lock(THD *thd,
The current code only writes DROP statements that only uses temporary
tables to the cache binary log. This should be ok on most cases, but
not all.
+
+ RETURN
+ 0 ok
+ 1 Error
+ -1 Thread was killed
*/
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
- bool dont_log_query)
+ bool drop_temporary, bool dont_log_query)
{
TABLE_LIST *table;
char path[FN_REFLEN];
@@ -142,26 +160,28 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
continue; // removed temporary table
}
- abort_locked_tables(thd,db,table->real_name);
- while (remove_table_from_cache(thd,db,table->real_name) && !thd->killed)
- {
- dropping_tables++;
- (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
- dropping_tables--;
- }
- drop_locked_tables(thd,db,table->real_name);
- if (thd->killed)
- DBUG_RETURN(-1);
-
- /* remove form file and isam files */
- strxmov(path, mysql_data_home, "/", db, "/", table->real_name, reg_ext,
- NullS);
- (void) unpack_filename(path,path);
error=0;
+ if (!drop_temporary)
+ {
+ abort_locked_tables(thd,db,table->real_name);
+ while (remove_table_from_cache(thd,db,table->real_name) && !thd->killed)
+ {
+ dropping_tables++;
+ (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
+ dropping_tables--;
+ }
+ drop_locked_tables(thd,db,table->real_name);
+ if (thd->killed)
+ DBUG_RETURN(-1);
- table_type=get_table_type(path);
+ /* remove form file and isam files */
+ strxmov(path, mysql_data_home, "/", db, "/", table->real_name, reg_ext,
+ NullS);
+ (void) unpack_filename(path,path);
- if (access(path,F_OK))
+ table_type=get_table_type(path);
+ }
+ if (drop_temporary || access(path,F_OK))
{
if (if_exists)
store_warning(thd, ER_BAD_TABLE_ERROR, table->real_name);