summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/protocol.cc14
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_error.cc12
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_show.cc12
-rw-r--r--sql/sql_table.cc28
-rw-r--r--sql/sql_union.cc23
10 files changed, 62 insertions, 40 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7c625c208e1..e204d5daeb5 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -254,8 +254,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
/* The rest of the file is included in the server only */
#ifndef MYSQL_CLIENT
-/* If set to 0, then the thread will ignore all warnings with level notes.
- Set by executing SET SQL_NOTES=1 */
+/* If not set then the thread will ignore all warnings with level notes. */
#define OPTION_SQL_NOTES (1L << 31)
/* Bits for different SQL modes modes (including ANSI mode) */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9013a7f5c3d..ed5fbd34ea7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2228,6 +2228,8 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
thd->query_error= 1; // needed to catch query errors during replication
+ if (!thd->no_warnings_for_error)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
/*
thd->lex->current_select == 0 if lex structure is not inited
(not query command (COM_QUERY))
@@ -2239,8 +2241,6 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
(thd->lex->current_select ?
thd->lex->current_select->no_error : 0),
(int) thd->is_fatal_error));
-
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
}
else
{
diff --git a/sql/protocol.cc b/sql/protocol.cc
index b84d170873d..460fa969898 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -59,8 +59,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
uint length;
char buff[MYSQL_ERRMSG_SIZE+2], *pos;
#endif
- const char *orig_err= err;
NET *net= &thd->net;
+ bool generate_warning= 1;
DBUG_ENTER("net_send_error");
DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno,
err ? err : net->last_error[0] ?
@@ -79,14 +79,22 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
else
{
if ((err=net->last_error)[0])
+ {
sql_errno=net->last_errno;
+ generate_warning= 0; // This warning has already been given
+ }
else
{
sql_errno=ER_UNKNOWN_ERROR;
err=ER(sql_errno); /* purecov: inspected */
}
}
- orig_err= err;
+ }
+
+ if (generate_warning)
+ {
+ /* Error that we have not got with my_error() */
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
}
#ifdef EMBEDDED_LIBRARY
@@ -125,8 +133,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
}
VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
#endif /* EMBEDDED_LIBRARY*/
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno,
- orig_err ? orig_err : ER(sql_errno));
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 7dfb7a99ab3..eb98b96c9ec 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -204,7 +204,7 @@ THD::THD()
#endif
net.last_error[0]=0; // If error on boot
ull=0;
- system_thread= cleanup_done= abort_on_warning= 0;
+ system_thread= cleanup_done= abort_on_warning= no_warnings_for_error= 0;
peer_port= 0; // For SHOW PROCESSLIST
#ifdef __WIN__
real_id = 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 2d89ded63c2..5ffdca895bb 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1186,6 +1186,7 @@ public:
bool slow_command;
bool no_trans_update, abort_on_warning;
bool got_warning; /* Set on call to push_warning() */
+ bool no_warnings_for_error; /* no warnings on call to my_error() */
longlong row_count_func; /* For the ROW_COUNT() function */
sp_rcontext *spcont; // SP runtime context
sp_cache *sp_proc_cache;
@@ -1638,7 +1639,6 @@ public:
class select_union :public select_result_interceptor {
public:
TABLE *table;
- COPY_INFO info;
TMP_TABLE_PARAM tmp_table_param;
select_union(TABLE *table_par);
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 79f7579d311..4d254b95514 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -106,8 +106,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
MYSQL_ERROR *err= 0;
DBUG_ENTER("push_warning");
- if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_SQL_NOTES))
- return(0);
+ if (level == MYSQL_ERROR::WARN_LEVEL_NOTE &&
+ !(thd->options & OPTION_SQL_NOTES))
+ DBUG_RETURN(0);
if (thd->query_id != thd->warn_id)
mysql_reset_errors(thd);
@@ -126,9 +127,14 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN &&
thd->really_abort_on_warning())
{
+ /* Avoid my_message() calling push_warning */
+ bool no_warnings_for_error= thd->no_warnings_for_error;
+ thd->no_warnings_for_error= 1;
thd->killed= THD::KILL_BAD_DATA;
my_message(code, msg, MYF(0));
- DBUG_RETURN(NULL);
+ thd->no_warnings_for_error= no_warnings_for_error;
+ /* Store error in error list (as my_message() didn't do it in this case */
+ level= MYSQL_ERROR::WARN_LEVEL_ERROR;
}
if (thd->warn_list.elements < thd->variables.max_error_count)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3e2915e6e07..63d92ca0e5f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2252,6 +2252,7 @@ mysql_execute_command(THD *thd)
lex->sql_command != SQLCOM_LOCK_TABLES &&
lex->sql_command != SQLCOM_UNLOCK_TABLES)
{
+ thd->no_warnings_for_error= 1;
while (1)
{
if (sp_cache_routines(thd, lex, TYPE_ENUM_FUNCTION))
@@ -2331,6 +2332,7 @@ mysql_execute_command(THD *thd)
}
break;
} // while (1)
+ thd->no_warnings_for_error= 0;
}
/*
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 8bf6f36ccdc..ae0b591a403 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1960,14 +1960,15 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
bool with_i_schema;
HA_CREATE_INFO create;
TABLE *table= tables->table;
+ DBUG_ENTER("fill_schema_shemata");
get_index_field_values(thd->lex, &idx_field_vals);
/* information schema name always is first in list */
if (schema_db_add(thd, &files, idx_field_vals.db_value, &with_i_schema))
- return 1;
+ DBUG_RETURN(1);
if (mysql_find_files(thd, &files, NullS, mysql_data_home,
idx_field_vals.db_value, 1))
- return 1;
+ DBUG_RETURN(1);
List_iterator_fast<char> it(files);
while ((file_name=it++))
{
@@ -2000,7 +2001,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
create.default_table_charset->csname);
}
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -3335,11 +3336,13 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
bool get_schema_tables_result(JOIN *join)
{
- DBUG_ENTER("get_schema_tables_result");
JOIN_TAB *tmp_join_tab= join->join_tab+join->tables;
THD *thd= join->thd;
LEX *lex= thd->lex;
bool result= 0;
+ DBUG_ENTER("get_schema_tables_result");
+
+ thd->no_warnings_for_error= 1;
for (JOIN_TAB *tab= join->join_tab; tab < tmp_join_tab; tab++)
{
if (!tab->table || !tab->table->pos_in_table_list)
@@ -3376,6 +3379,7 @@ bool get_schema_tables_result(JOIN *join)
lex->query_tables_last= query_tables_last;
}
}
+ thd->no_warnings_for_error= 0;
DBUG_RETURN(result);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b38014eb4ea..f87a60c4fda 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -191,6 +191,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (lock_table_names(thd, tables))
DBUG_RETURN(1);
+ /* Don't give warnings for not found errors, as we already generate notes */
+ thd->no_warnings_for_error= 1;
+
for (table= tables; table; table= table->next_local)
{
char *db=table->db;
@@ -213,7 +216,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
drop_locked_tables(thd,db,table->table_name);
if (thd->killed)
+ {
+ thd->no_warnings_for_error= 0;
DBUG_RETURN(-1);
+ }
alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove form file and isam files */
strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS);
@@ -286,6 +292,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
unlock_table_names(thd, tables);
+ thd->no_warnings_for_error= 0;
DBUG_RETURN(error);
}
@@ -1955,6 +1962,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
const char *operator_name,
thr_lock_type lock_type,
bool open_for_modify,
+ bool no_warnings_for_error,
uint extra_open_options,
int (*prepare_func)(THD *, TABLE_LIST *,
HA_CHECK_OPT *),
@@ -1994,7 +2002,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* open only one table from local list of command */
next_global_table= table->next_global;
table->next_global= 0;
+ thd->no_warnings_for_error= no_warnings_for_error;
open_and_lock_tables(thd, table);
+ thd->no_warnings_for_error= 0;
table->next_global= next_global_table;
/* if view are unsupported */
if (table->view && !view_operator_func)
@@ -2218,7 +2228,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
{
DBUG_ENTER("mysql_backup_table");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
- "backup", TL_READ, 0, 0, 0,
+ "backup", TL_READ, 0, 0, 0, 0,
&handler::backup, 0));
}
@@ -2227,7 +2237,7 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
{
DBUG_ENTER("mysql_restore_table");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
- "restore", TL_WRITE, 1, 0,
+ "restore", TL_WRITE, 1, 1, 0,
&prepare_for_restore,
&handler::restore, 0));
}
@@ -2237,7 +2247,9 @@ bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{
DBUG_ENTER("mysql_repair_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
- "repair", TL_WRITE, 1, HA_OPEN_FOR_REPAIR,
+ "repair", TL_WRITE, 1,
+ test(check_opt->sql_flags & TT_USEFRM),
+ HA_OPEN_FOR_REPAIR,
&prepare_for_repair,
&handler::repair, 0));
}
@@ -2247,7 +2259,7 @@ bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{
DBUG_ENTER("mysql_optimize_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
- "optimize", TL_WRITE, 1,0,0,
+ "optimize", TL_WRITE, 1,0,0,0,
&handler::optimize, 0));
}
@@ -2283,7 +2295,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
pthread_mutex_unlock(&LOCK_global_system_variables);
check_opt.key_cache= key_cache;
DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt,
- "assign_to_keycache", TL_READ_NO_INSERT, 0,
+ "assign_to_keycache", TL_READ_NO_INSERT, 0, 0,
0, 0, &handler::assign_to_keycache, 0));
}
@@ -2344,7 +2356,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
{
DBUG_ENTER("mysql_preload_keys");
DBUG_RETURN(mysql_admin_table(thd, tables, 0,
- "preload_keys", TL_READ, 0, 0, 0,
+ "preload_keys", TL_READ, 0, 0, 0, 0,
&handler::preload_keys, 0));
}
@@ -2510,7 +2522,7 @@ bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_analyze_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
- "analyze", lock_type, 1,0,0,
+ "analyze", lock_type, 1, 0, 0, 0,
&handler::analyze, 0));
}
@@ -2526,7 +2538,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_check_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"check", lock_type,
- 0, HA_OPEN_FOR_REPAIR, 0,
+ 0, HA_OPEN_FOR_REPAIR, 0, 0,
&handler::check, &view_checksum));
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 29897c70023..c2d401d3a7f 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -49,12 +49,6 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result,
select_union::select_union(TABLE *table_par)
:table(table_par)
{
- bzero((char*) &info,sizeof(info));
- /*
- We can always use IGNORE because the temporary table will only
- contain a unique key if we are using not using UNION ALL
- */
- info.ignore= 1;
}
select_union::~select_union()
@@ -71,22 +65,21 @@ int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
bool select_union::send_data(List<Item> &values)
{
+ int error= 0;
if (unit->offset_limit_cnt)
{ // using limit offset,count
unit->offset_limit_cnt--;
return 0;
}
fill_record(thd, table->field, values, 1);
- if (thd->net.report_error || write_record(thd, table,&info))
+ if (thd->net.report_error)
+ return 1;
+
+ if ((error= table->file->write_row(table->record[0])))
{
- if (thd->net.last_errno == ER_RECORD_FILE_FULL)
- {
- thd->clear_error(); // do not report user about table overflow
- if (create_myisam_from_heap(thd, table, &tmp_table_param,
- info.last_errno, 1))
- return 1;
- }
- else
+ /* create_myisam_from_heap will generate error if needed */
+ if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE &&
+ create_myisam_from_heap(thd, table, &tmp_table_param, error, 1))
return 1;
}
return 0;