summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-04-03 21:35:51 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-04-03 21:35:51 +0400
commit3df8e88dd84e3bb6512e8c33498df5db4823d18a (patch)
tree4c53541bd85faea4f3fca21d63e1f8880d3c9189 /sql
parent018b0d3ee7883da0a9ae294bb2d25b747f9e3a41 (diff)
parent0cb83d46e4fd678794ef4d487a10bec6e43688f0 (diff)
downloadmariadb-git-3df8e88dd84e3bb6512e8c33498df5db4823d18a.tar.gz
Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.
Conflicts: Text conflict in mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result Text conflict in sql/log.cc Text conflict in sql/set_var.cc Text conflict in sql/sql_class.cc
Diffstat (limited to 'sql')
-rw-r--r--sql/events.cc4
-rw-r--r--sql/field_conv.cc26
-rw-r--r--sql/item_strfunc.h2
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/log.cc28
-rw-r--r--sql/log_event.cc5
-rw-r--r--sql/log_event.h22
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/sp_head.cc1
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_lex.h1
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sys_vars.cc7
16 files changed, 83 insertions, 31 deletions
diff --git a/sql/events.cc b/sql/events.cc
index a2375b1274b..f36e72d2f18 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -267,7 +267,9 @@ create_query_string(THD *thd, String *buf)
/* Append definer */
append_definer(thd, buf, &(thd->lex->definer->user), &(thd->lex->definer->host));
/* Append the left part of thd->query after "DEFINER" part */
- if (buf->append(thd->lex->stmt_definition_begin))
+ if (buf->append(thd->lex->stmt_definition_begin,
+ thd->lex->stmt_definition_end -
+ thd->lex->stmt_definition_begin))
return 1;
return 0;
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 3574534722e..0bffde9671a 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -122,13 +122,18 @@ set_field_to_null(Field *field)
return 0;
}
field->reset();
- if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN)
- {
+ switch (field->table->in_use->count_cuted_fields) {
+ case CHECK_FIELD_WARN:
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ /* fall through */
+ case CHECK_FIELD_IGNORE:
return 0;
+ case CHECK_FIELD_ERROR_FOR_NULL:
+ if (!field->table->in_use->no_errors)
+ my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ return -1;
}
- if (!field->table->in_use->no_errors)
- my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ DBUG_ASSERT(0); // impossible
return -1;
}
@@ -178,13 +183,18 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
field->table->auto_increment_field_not_null= FALSE;
return 0; // field is set in fill_record()
}
- if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN)
- {
+ switch (field->table->in_use->count_cuted_fields) {
+ case CHECK_FIELD_WARN:
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1);
+ /* fall through */
+ case CHECK_FIELD_IGNORE:
return 0;
+ case CHECK_FIELD_ERROR_FOR_NULL:
+ if (!field->table->in_use->no_errors)
+ my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ return -1;
}
- if (!field->table->in_use->no_errors)
- my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ DBUG_ASSERT(0); // impossible
return -1;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 21ac4d0a8cb..7447d2a79c2 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -722,7 +722,7 @@ public:
void fix_length_and_dec()
{
ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2;
- max_length= min(max_result_length, MAX_BLOB_WIDTH);
+ max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
collation.set(args[0]->collation);
}
};
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index ce39fd245be..9b450f5a4ea 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3411,7 +3411,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type)
{
if (i)
str->append(',');
- (*order[i]->item)->print(str, query_type);
+ pargs[i + arg_count_field]->print(str, query_type);
if (order[i]->asc)
str->append(STRING_WITH_LEN(" ASC"));
else
diff --git a/sql/log.cc b/sql/log.cc
index 225fc51ffc6..9aba8001120 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1880,12 +1880,14 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
binlog_trans_log_savepos(thd, (my_off_t*) sv);
/* Write it to the binary log */
+ String log_query;
+ if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
+ log_query.append(thd->lex->ident.str, thd->lex->ident.length))
+ DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- int const error=
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query(), thd->query_length(), TRUE, FALSE, FALSE,
- errcode);
- DBUG_RETURN(error);
+ Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
+ TRUE, FALSE, TRUE, errcode);
+ DBUG_RETURN(mysql_bin_log.write(&qinfo));
}
static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
@@ -1900,12 +1902,14 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
if (unlikely(thd->transaction.all.modified_non_trans_table ||
(thd->variables.option_bits & OPTION_KEEP_LOG)))
{
+ String log_query;
+ if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
+ log_query.append(thd->lex->ident.str, thd->lex->ident.length))
+ DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- int error=
- thd->binlog_query(THD::STMT_QUERY_TYPE,
- thd->query(), thd->query_length(), TRUE, FALSE, FALSE,
- errcode);
- DBUG_RETURN(error);
+ Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
+ TRUE, FALSE, TRUE, errcode);
+ DBUG_RETURN(mysql_bin_log.write(&qinfo));
}
binlog_trans_log_truncate(thd, *(my_off_t*)sv);
DBUG_RETURN(0);
@@ -4599,7 +4603,9 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
*/
const char *local_db= event_info->get_db();
if ((thd && !(thd->variables.option_bits & OPTION_BIN_LOG)) ||
- !binlog_filter->db_ok(local_db))
+ (thd->lex->sql_command != SQLCOM_ROLLBACK_TO_SAVEPOINT &&
+ thd->lex->sql_command != SQLCOM_SAVEPOINT &&
+ !binlog_filter->db_ok(local_db)))
DBUG_RETURN(0);
#endif /* HAVE_REPLICATION */
diff --git a/sql/log_event.cc b/sql/log_event.cc
index fe86e78f7e3..f63a1477896 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3172,10 +3172,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
::do_apply_event(), then the companion SET also have so
we don't need to reset_one_shot_variables().
*/
- if (!strncmp(query_arg, "BEGIN", q_len_arg) ||
- !strncmp(query_arg, "COMMIT", q_len_arg) ||
- !strncmp(query_arg, "ROLLBACK", q_len_arg) ||
- rpl_filter->db_ok(thd->db))
+ if (is_trans_keyword() || rpl_filter->db_ok(thd->db))
{
thd->set_time((time_t)when);
thd->set_query_and_id((char*)query_arg, q_len_arg, next_query_id());
diff --git a/sql/log_event.h b/sql/log_event.h
index 81669e24708..5f0a0c52103 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -1743,6 +1743,28 @@ public: /* !!! Public in this patch to allow old usage */
const char *query_arg,
uint32 q_len_arg);
#endif /* HAVE_REPLICATION */
+ /*
+ If true, the event always be applied by slave SQL thread or be printed by
+ mysqlbinlog
+ */
+ bool is_trans_keyword()
+ {
+ /*
+ Before the patch for bug#50407, The 'SAVEPOINT and ROLLBACK TO'
+ queries input by user was written into log events directly.
+ So the keywords can be written in both upper case and lower case
+ together, strncasecmp is used to check both cases. they also could be
+ binlogged with comments in the front of these keywords. for examples:
+ / * bla bla * / SAVEPOINT a;
+ / * bla bla * / ROLLBACK TO a;
+ but we don't handle these cases and after the patch, both quiries are
+ binlogged in upper case with no comments.
+ */
+ return !strncmp(query, "BEGIN", q_len) ||
+ !strncmp(query, "COMMIT", q_len) ||
+ !strncasecmp(query, "SAVEPOINT", 9) ||
+ !strncasecmp(query, "ROLLBACK", 8);
+ }
};
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 6b77c95c76f..c16f5d5b714 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -2009,6 +2009,7 @@ extern my_bool opt_log, opt_slow_log;
extern ulonglong log_output_options;
extern my_bool opt_log_queries_not_using_indexes;
extern bool opt_disable_networking, opt_skip_show_db;
+extern bool opt_skip_name_resolve;
extern bool opt_ignore_builtin_innodb;
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 22aa91e7fc4..b8a49e5aadf 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -364,6 +364,7 @@ ulonglong log_output_options;
my_bool opt_log_queries_not_using_indexes= 0;
bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0;
+bool opt_skip_name_resolve=0;
my_bool opt_character_set_client_handshake= 1;
bool server_id_supplied = 0;
bool opt_endinfo, using_udf_functions;
@@ -6173,9 +6174,6 @@ Can't be set to 1 if --log-slave-updates is used.",
#endif
{"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"skip-name-resolve", OPT_SKIP_RESOLVE,
- "Don't resolve hostnames. All hostnames are IP's or 'localhost'.",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-slave-start", 0,
@@ -6925,6 +6923,7 @@ static int mysql_init_variables(void)
opt_log= opt_slow_log= 0;
opt_bin_log= 0;
opt_disable_networking= opt_skip_show_db=0;
+ opt_skip_name_resolve= 0;
opt_ignore_builtin_innodb= 0;
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
@@ -7292,6 +7291,7 @@ mysqld_get_one_option(int optid,
opt_specialflag|= SPECIAL_NO_HOST_CACHE;
break;
case (int) OPT_SKIP_RESOLVE:
+ opt_skip_name_resolve= 1;
opt_specialflag|=SPECIAL_NO_RESOLVE;
break;
case (int) OPT_WANT_CORE:
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c6bf0e381fb..9f41be528a3 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3026,6 +3026,7 @@ int
sp_instr_set_trigger_field::execute(THD *thd, uint *nextp)
{
DBUG_ENTER("sp_instr_set_trigger_field::execute");
+ thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this));
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 4b21bc283e2..7f8399b4509 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3180,6 +3180,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
#endif
backup->option_bits= variables.option_bits;
+ backup->count_cuted_fields= count_cuted_fields;
backup->in_sub_stmt= in_sub_stmt;
backup->enable_slow_log= enable_slow_log;
backup->limit_found_rows= limit_found_rows;
@@ -3217,6 +3218,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
void THD::restore_sub_statement_state(Sub_statement_state *backup)
{
+ DBUG_ENTER("THD::restore_sub_statement_state");
#ifndef EMBEDDED_LIBRARY
/* BUG#33029, if we are replicating from a buggy master, restore
auto_inc_intervals_forced so that the top statement can use the
@@ -3243,6 +3245,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup)
/* ha_release_savepoint() never returns error. */
(void)ha_release_savepoint(this, sv);
}
+ count_cuted_fields= backup->count_cuted_fields;
transaction.savepoints= backup->savepoints;
variables.option_bits= backup->option_bits;
in_sub_stmt= backup->in_sub_stmt;
@@ -3272,6 +3275,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup)
*/
examined_row_count+= backup->examined_row_count;
cuted_fields+= backup->cuted_fields;
+ DBUG_VOID_RETURN;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index de6d92eccfd..715239b0ff7 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1044,6 +1044,7 @@ public:
bool enable_slow_log;
bool last_insert_id_used;
SAVEPOINT *savepoints;
+ enum enum_check_fields count_cuted_fields;
};
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 7423dd9d292..4278f6b3f1d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3245,7 +3245,7 @@ bool select_insert::send_data(List<Item> &values)
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
store_values(values);
- thd->count_cuted_fields= CHECK_FIELD_IGNORE;
+ thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
if (thd->is_error())
{
table->auto_increment_field_not_null= FALSE;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 0b27f73e763..acd13517f37 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2008,6 +2008,7 @@ struct LEX: public Query_tables_list
- CREATE TRIGGER (points to "TRIGGER");
- CREATE PROCEDURE (points to "PROCEDURE");
- CREATE FUNCTION (points to "FUNCTION" or "AGGREGATE");
+ - CREATE EVENT (points to "EVENT")
This pointer is required to add possibly omitted DEFINER-clause to the
DDL-statement before dumping it to the binlog.
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 56102779771..6c9c671a093 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1109,7 +1109,7 @@ JOIN::optimize()
}
}
- if (conds &&!outer_join && const_table_map != found_const_table_map &&
+ if (conds && const_table_map != found_const_table_map &&
(select_options & SELECT_DESCRIBE) &&
select_lex->master_unit() == &thd->lex->unit) // upper level SELECT
{
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index e14286210b4..8ca3d2a46fa 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1579,6 +1579,13 @@ static Sys_var_mybool Sys_skip_networking(
READ_ONLY GLOBAL_VAR(opt_disable_networking), CMD_LINE(OPT_ARG),
DEFAULT(FALSE));
+static Sys_var_mybool Sys_skip_name_resolve(
+ "skip_name_resolve",
+ "Don't resolve hostnames. All hostnames are IP's or 'localhost'.",
+ READ_ONLY GLOBAL_VAR(opt_skip_name_resolve),
+ CMD_LINE(OPT_ARG, OPT_SKIP_RESOLVE),
+ DEFAULT(FALSE));
+
static Sys_var_mybool Sys_skip_show_database(
"skip_show_database", "Don't allow 'SHOW DATABASE' commands",
READ_ONLY GLOBAL_VAR(opt_skip_show_db), CMD_LINE(OPT_ARG),