Commit f0233c2e authored by konstantin@mysql.com's avatar konstantin@mysql.com

Fix show warnings limit 0 and show warnings limit 0, 0.

Add test coverage for SHOW WARNINGS LIMIT a, b;
parent 7a1282b3
...@@ -179,3 +179,56 @@ drop table t1; ...@@ -179,3 +179,56 @@ drop table t1;
set table_type=MYISAM; set table_type=MYISAM;
Warnings: Warnings:
Warning 1287 'table_type' is deprecated; use 'storage_engine' instead Warning 1287 'table_type' is deprecated; use 'storage_engine' instead
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
update t1 set a='abc';
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Warning 1265 Data truncated for column 'a' at row 3
Warning 1265 Data truncated for column 'a' at row 4
Warning 1265 Data truncated for column 'a' at row 5
Warning 1265 Data truncated for column 'a' at row 6
Warning 1265 Data truncated for column 'a' at row 7
Warning 1265 Data truncated for column 'a' at row 8
Warning 1265 Data truncated for column 'a' at row 9
Warning 1265 Data truncated for column 'a' at row 10
show warnings limit 2, 1;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 3
show warnings limit 0, 10;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Warning 1265 Data truncated for column 'a' at row 3
Warning 1265 Data truncated for column 'a' at row 4
Warning 1265 Data truncated for column 'a' at row 5
Warning 1265 Data truncated for column 'a' at row 6
Warning 1265 Data truncated for column 'a' at row 7
Warning 1265 Data truncated for column 'a' at row 8
Warning 1265 Data truncated for column 'a' at row 9
Warning 1265 Data truncated for column 'a' at row 10
show warnings limit 9, 1;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 10
show warnings limit 10, 1;
Level Code Message
show warnings limit 9, 2;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 10
show warnings limit 0, 0;
Level Code Message
show warnings limit 1;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 1
show warnings limit 0;
Level Code Message
show warnings limit 1, 0;
Level Code Message
select * from t1 limit 0;
a
select * from t1 limit 1, 0;
a
select * from t1 limit 0, 0;
a
drop table t1;
...@@ -133,3 +133,25 @@ drop table t1; ...@@ -133,3 +133,25 @@ drop table t1;
# Test for deprecated table_type variable # Test for deprecated table_type variable
# #
set table_type=MYISAM; set table_type=MYISAM;
#
# Tests for show warnings limit a, b
#
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
# should generate 10 warnings
update t1 set a='abc';
show warnings limit 2, 1;
show warnings limit 0, 10;
show warnings limit 9, 1;
show warnings limit 10, 1;
show warnings limit 9, 2;
show warnings limit 0, 0;
show warnings limit 1;
show warnings limit 0;
show warnings limit 1, 0;
# make sure behaviour is consistent with select ... limit
select * from t1 limit 0;
select * from t1 limit 1, 0;
select * from t1 limit 0, 0;
drop table t1;
...@@ -203,6 +203,8 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) ...@@ -203,6 +203,8 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
offset--; offset--;
continue; continue;
} }
if (limit-- == 0)
break;
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(warning_level_names[err->level], protocol->store(warning_level_names[err->level],
warning_level_length[err->level], system_charset_info); warning_level_length[err->level], system_charset_info);
...@@ -210,8 +212,6 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) ...@@ -210,8 +212,6 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
protocol->store(err->msg, strlen(err->msg), system_charset_info); protocol->store(err->msg, strlen(err->msg), system_charset_info);
if (protocol->write()) if (protocol->write())
DBUG_RETURN(1); DBUG_RETURN(1);
if (!--limit)
break;
} }
send_eof(thd); send_eof(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
......
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