Commit 557c52ea authored by gshchepa/uchum@gleb.loc's avatar gshchepa/uchum@gleb.loc

Merge gleb.loc:/home/uchum/work/bk/5.1

into  gleb.loc:/home/uchum/work/bk/5.1-opt
parents 21b707e4 589c585d
......@@ -83,4 +83,58 @@ connection master;
USE test;
DROP SCHEMA mysqlslap;
sync_slave_with_master;
use test;
connection master;
#
# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but
# on the slave
#
if (`SELECT @@global.binlog_format != 'ROW'`)
{
#flush the logs before the test
connection slave;
FLUSH LOGS;
connection master;
FLUSH LOGS;
}
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1; # to wait for INSERT DELAYED to be done
if (`SELECT @@global.binlog_format != 'ROW'`)
{
#must show two INSERT DELAYED
--replace_column 1 x 2 x 3 x 4 x 5 x
show binlog events in 'master-bin.000002' LIMIT 2,2;
}
select * from t1;
sync_slave_with_master;
echo On slave;
if (`SELECT @@global.binlog_format != 'ROW'`)
{
#must show two INSERT DELAYED
--replace_column 1 x 2 x 3 x 4 x 5 x
show binlog events in 'slave-bin.000002' LIMIT 2,2;
}
select * from t1;
# clean up
connection master;
drop table t1;
sync_slave_with_master;
if (`SELECT @@global.binlog_format != 'ROW'`)
{
#flush the logs after the test
FLUSH LOGS;
connection master;
FLUSH LOGS;
}
connection master;
--echo End of 5.0 tests
......@@ -790,13 +790,71 @@ show tables;
Tables_in_test
show status like 'slow_queries';
Variable_name Value
Slow_queries 1
Slow_queries 0
select 1 from information_schema.tables limit 1;
1
1
show status like 'slow_queries';
Variable_name Value
Slow_queries 2
Slow_queries 1
create table t1 (a int);
create trigger tr1 before insert on t1 for each row
begin
end;
create view v1 as select a from t1;
create procedure p1()
begin
end;
create function f1()
returns int
return 0;
create event e1 on schedule every 1 year starts now()
ends date_add(now(), interval 5 hour) do
begin
end;
flush status;
show databases;
show tables;
show events;
show table status;
show open tables;
show plugins;
show columns in t1;
show slave hosts;
show keys in t1;
show column types;
show table types;
show storage engines;
show authors;
show contributors;
show privileges;
show count(*) warnings;
show count(*) errors;
show warnings;
show status;
show processlist;
show variables;
show charset;
show collation;
show grants;
show create database test;
show create table t1;
show create view v1;
show master status;
show slave status;
show create procedure p1;
show create function f1;
show create trigger tr1;
show procedure status;
show create event e1;
show status like 'slow_queries';
Variable_name Value
Slow_queries 0
drop view v1;
drop table t1;
drop procedure p1;
drop function f1;
drop event e1;
DROP DATABASE IF EXISTS mysqltest1;
DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1;
......@@ -1157,7 +1215,7 @@ select 1 from information_schema.tables limit 1;
1
show status like 'slow_queries';
Variable_name Value
Slow_queries 2
Slow_queries 1
set global log_queries_not_using_indexes=OFF;
show variables like "log_queries_not_using_indexes";
Variable_name Value
......@@ -1167,7 +1225,7 @@ select 1 from information_schema.tables limit 1;
1
show status like 'slow_queries';
Variable_name Value
Slow_queries 2
Slow_queries 1
set global log_queries_not_using_indexes=ON;
show variables like "log_queries_not_using_indexes";
Variable_name Value
......@@ -1177,7 +1235,7 @@ select 1 from information_schema.tables limit 1;
1
show status like 'slow_queries';
Variable_name Value
Slow_queries 4
Slow_queries 2
End of 5.0 tests
SHOW AUTHORS;
create database mysqltest;
......@@ -1351,4 +1409,5 @@ DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLE t1;
DROP EVENT ev1;
SHOW TABLE TYPES;
End of 5.1 tests
......@@ -45,4 +45,18 @@ id name
20 is Bond
USE test;
DROP SCHEMA mysqlslap;
use test;
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
select * from t1;
a
1
On slave
select * from t1;
a
1
drop table t1;
End of 5.0 tests
set @@global.binlog_format = @old_global_binlog_format;
......@@ -41,3 +41,13 @@ select * from t2 order by b;
b a
1 1
drop table t1,t2;
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`data` varchar(100),
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
INSERT INTO t1(data) VALUES(SESSION_USER());
SELECT length(data) < 100 FROM t1;
length(data) < 100
1
drop table t1;
......@@ -45,6 +45,32 @@ id name
20 is Bond
USE test;
DROP SCHEMA mysqlslap;
use test;
FLUSH LOGS;
FLUSH LOGS;
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
show binlog events in 'master-bin.000002' LIMIT 2,2;
Log_name Pos Event_type Server_id End_log_pos Info
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
On slave
show binlog events in 'slave-bin.000002' LIMIT 2,2;
Log_name Pos Event_type Server_id End_log_pos Info
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
drop table t1;
FLUSH LOGS;
FLUSH LOGS;
End of 5.0 tests
set @@global.binlog_format = mixed;
CREATE SCHEMA IF NOT EXISTS mysqlslap;
USE mysqlslap;
......@@ -85,4 +111,30 @@ id name
20 is Bond
USE test;
DROP SCHEMA mysqlslap;
use test;
FLUSH LOGS;
FLUSH LOGS;
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
show binlog events in 'master-bin.000002' LIMIT 2,2;
Log_name Pos Event_type Server_id End_log_pos Info
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
On slave
show binlog events in 'slave-bin.000002' LIMIT 2,2;
Log_name Pos Event_type Server_id End_log_pos Info
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
drop table t1;
FLUSH LOGS;
FLUSH LOGS;
End of 5.0 tests
set @@global.binlog_format = @old_global_binlog_format;
......@@ -40,3 +40,25 @@ drop table t1,t2;
save_master_pos;
connection slave;
sync_with_master;
#
# Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
#
connection master;
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`data` varchar(100),
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
INSERT INTO t1(data) VALUES(SESSION_USER());
save_master_pos;
connection slave;
sync_with_master;
SELECT length(data) < 100 FROM t1;
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
......@@ -549,6 +549,68 @@ show status like 'slow_queries';
# (mysqld is started with --log-queries-not-using-indexes)
select 1 from information_schema.tables limit 1;
show status like 'slow_queries';
create table t1 (a int);
create trigger tr1 before insert on t1 for each row
begin
end;
create view v1 as select a from t1;
create procedure p1()
begin
end;
create function f1()
returns int
return 0;
create event e1 on schedule every 1 year starts now()
ends date_add(now(), interval 5 hour) do
begin
end;
--disable_result_log
flush status;
show databases;
show tables;
show events;
show table status;
show open tables;
show plugins;
show columns in t1;
show slave hosts;
show keys in t1;
show column types;
show table types;
show storage engines;
show authors;
show contributors;
show privileges;
show count(*) warnings;
show count(*) errors;
show warnings;
show status;
show processlist;
show variables;
show charset;
show collation;
show grants;
show create database test;
show create table t1;
show create view v1;
show master status;
show slave status;
show create procedure p1;
show create function f1;
show create trigger tr1;
show procedure status;
show create event e1;
--enable_result_log
show status like 'slow_queries';
drop view v1;
drop table t1;
drop procedure p1;
drop function f1;
drop event e1;
#
# BUG#10491: Server returns data as charset binary SHOW CREATE TABLE or SELECT
# FROM I_S.
......@@ -977,4 +1039,12 @@ DROP FUNCTION f1;
DROP TABLE t1;
DROP EVENT ev1;
#
# Bug #30036: SHOW TABLE TYPES causes the debug client to crash
#
--disable_result_log
SHOW TABLE TYPES;
--enable_result_log
--echo End of 5.1 tests
......@@ -334,6 +334,37 @@ int Item::save_date_in_field(Field *field)
}
/*
Store the string value in field directly
SYNOPSIS
Item::save_str_value_in_field()
field a pointer to field where to store
result the pointer to the string value to be stored
DESCRIPTION
The method is used by Item_*::save_in_field implementations
when we don't need to calculate the value to store
See Item_string::save_in_field() implementation for example
IMPLEMENTATION
Check if the Item is null and stores the NULL or the
result value in the field accordingly.
RETURN
Nonzero value if error
*/
int Item::save_str_value_in_field(Field *field, String *result)
{
if (null_value)
return set_field_to_null(field);
field->set_notnull();
return field->store(result->ptr(), result->length(),
collation.collation);
}
Item::Item():
rsize(0), name(0), orig_name(0), name_length(0), fixed(0),
is_autogenerated_name(TRUE),
......@@ -3046,16 +3077,6 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
}
int Item_copy_string::save_in_field(Field *field, bool no_conversions)
{
if (null_value)
return set_field_to_null(field);
field->set_notnull();
return field->store(str_value.ptr(),str_value.length(),
collation.collation);
}
/*
Functions to convert item to field (for send_fields)
*/
......@@ -4508,6 +4529,12 @@ int Item_null::save_safe_in_field(Field *field)
}
/*
This implementation can lose str_value content, so if the
Item uses str_value to store something, it should
reimplement it's ::save_in_field() as Item_string, for example, does
*/
int Item::save_in_field(Field *field, bool no_conversions)
{
int error;
......@@ -4565,10 +4592,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
{
String *result;
result=val_str(&str_value);
if (null_value)
return set_field_to_null(field);
field->set_notnull();
return field->store(result->ptr(),result->length(),collation.collation);
return save_str_value_in_field(field, result);
}
......
......@@ -653,6 +653,7 @@ public:
int save_time_in_field(Field *field);
int save_date_in_field(Field *field);
int save_str_value_in_field(Field *field, String *result);
virtual Field *get_tmp_table_field() { return 0; }
/* This is also used to create fields in CREATE ... SELECT: */
......@@ -2293,7 +2294,10 @@ public:
my_decimal *val_decimal(my_decimal *);
void make_field(Send_field *field) { item->make_field(field); }
void copy();
int save_in_field(Field *field, bool no_conversions);
int save_in_field(Field *field, bool no_conversions)
{
return save_str_value_in_field(field, &str_value);
}
table_map used_tables() const { return (table_map) 1L; }
bool const_item() const { return 0; }
bool is_null() { return null_value; }
......
......@@ -427,6 +427,10 @@ public:
}
const char *func_name() const { return "user"; }
const char *fully_qualified_func_name() const { return "user()"; }
int save_in_field(Field *field, bool no_conversions)
{
return save_str_value_in_field(field, &str_value);
}
};
......
......@@ -549,6 +549,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
int error, res;
bool transactional_table, joins_freed= FALSE;
bool changed;
bool was_insert_delayed= (table_list->lock_type == TL_WRITE_DELAYED);
uint value_count;
ulong counter = 1;
ulonglong id;
......@@ -832,14 +833,16 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
transactional_table= table->file->has_transactions();
if ((changed= (info.copied || info.deleted || info.updated)))
if ((changed= (info.copied || info.deleted || info.updated)) ||
was_insert_delayed)
{
/*
Invalidate the table in the query cache if something changed.
For the transactional algorithm to work the invalidation must be
before binlog writing and ha_autocommit_or_rollback
*/
query_cache_invalidate3(thd, table_list, 1);
if (changed)
query_cache_invalidate3(thd, table_list, 1);
if (error <= 0 || !transactional_table)
{
if (mysql_bin_log.is_open())
......@@ -880,7 +883,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
error=1;
}
}
if (!transactional_table)
if (!transactional_table && changed)
thd->no_trans_update.all= TRUE;
}
}
......
......@@ -223,7 +223,6 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_REPLACE_SELECT]= CF_CHANGES_DATA | CF_HAS_ROW_COUNT;
sql_command_flags[SQLCOM_SHOW_STATUS_PROC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_STATUS_FUNC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_STATUS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_DATABASES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_TRIGGERS]= CF_STATUS_COMMAND;
......@@ -235,10 +234,36 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_SHOW_VARIABLES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CHARSETS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_COLLATIONS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_STATUS_PROC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND |
CF_SHOW_TABLE_COMMAND);
sql_command_flags[SQLCOM_SHOW_NEW_MASTER]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_BINLOGS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_SLAVE_HOSTS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_BINLOG_EVENTS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_COLUMN_TYPES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_STORAGE_ENGINES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_AUTHORS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CONTRIBUTORS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_PRIVILEGES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_WARNS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_ERRORS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_ENGINE_STATUS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_ENGINE_MUTEX]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_ENGINE_LOGS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_PROCESSLIST]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_GRANTS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE_DB]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_MASTER_STAT]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_SLAVE_STAT]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE_PROC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE_FUNC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE_TRIGGER]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_STATUS_FUNC]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_PROC_CODE]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_FUNC_CODE]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_CREATE_EVENT]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND |
CF_SHOW_TABLE_COMMAND);
sql_command_flags[SQLCOM_SHOW_TABLE_STATUS]= (CF_STATUS_COMMAND |
CF_SHOW_TABLE_COMMAND);
......@@ -1323,7 +1348,8 @@ void log_slow_statement(THD *thd)
thd->variables.long_query_time ||
((thd->server_status &
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
opt_log_queries_not_using_indexes))
opt_log_queries_not_using_indexes &&
!(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND)))
{
thd->status_var.long_query_count++;
slow_log_print(thd, thd->query, thd->query_length, start_of_query);
......
......@@ -12313,7 +12313,6 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
*/
if (!on_primary_key &&
(table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
ha_legacy_type(table->s->db_type()) == DB_TYPE_INNODB &&
table->s->primary_key != MAX_KEY)
{
on_primary_key= TRUE;
......
......@@ -8729,6 +8729,8 @@ show_param:
LEX *lex=Lex;
lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
WARN_DEPRECATED(yythd, "5.2", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES))
MYSQL_YYABORT;
}
| opt_storage ENGINES_SYM
{
......
......@@ -1351,8 +1351,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
{
field->part_of_key= share->keys_in_use;
if (ha_legacy_type(share->db_type()) == DB_TYPE_INNODB &&
field->part_of_sortkey.is_set(key))
if (field->part_of_sortkey.is_set(key))
field->part_of_sortkey= share->keys_in_use;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment