Commit e702b70d authored by unknown's avatar unknown

Implement mysqltest --enable_prepare_warnings to properly fix some test failures.

The --enable_prepare_warnings allows to not discard warnings from autorepair
of crashed table in --ps-protocol mode.

Use this to properly fix the parts.partition_recover_myisam and
maria.maria-recover tests.

Add a test case for the new feature. This also adds missing test coverage
for the case where the same warning is thrown in both prepare and execute
phase.


client/mysqltest.cc:
  Implement new commands --enable-prepare_warnings and --disable_prepare_warnings.
mysql-test/r/mysqltest_ps.result:
  Add test case for new --enable_prepare_warning mysqltest command.
mysql-test/suite/maria/t/maria-recover.test:
  Better fix of test case using new --enable_prepare_warnings command.
mysql-test/suite/parts/t/partition_recover_myisam.test:
  Fix test failure in --ps-protocol mode.
mysql-test/t/mysqltest_ps.test:
  Add test case for new --enable_prepare_warning mysqltest command.
parent fcb97aa7
......@@ -100,6 +100,7 @@ static my_bool display_result_vertically= FALSE,
display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_warnings= 0;
static my_bool prepare_warnings_enabled= 0;
static my_bool disable_info= 1;
static my_bool abort_on_error= 1;
static my_bool server_initialized= 0;
......@@ -289,7 +290,7 @@ enum enum_commands {
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
Q_MOVE_FILE,
Q_MOVE_FILE, Q_ENABLE_PREPARE_WARNINGS, Q_DISABLE_PREPARE_WARNINGS,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
......@@ -387,6 +388,8 @@ const char *command_names[]=
"send_shutdown",
"shutdown_server",
"move_file",
"enable_prepare_warnings",
"disable_prepare_warnings",
0
};
......@@ -6929,8 +6932,17 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
mysql_free_result(res); /* Free normal result set with meta data */
/* Clear prepare warnings */
dynstr_set(&ds_prepare_warnings, NULL);
/*
Normally, if there is a result set, we do not show warnings from the
prepare phase. This is because some warnings are generated both during
prepare and execute; this would generate different warning output
between normal and ps-protocol test runs.
The --enable_prepare_warnings command can be used to change this so
that warnings from both the prepare and execute phase are shown.
*/
if (!disable_warnings && !prepare_warnings_enabled)
dynstr_set(&ds_prepare_warnings, NULL);
}
else
{
......@@ -7754,6 +7766,8 @@ int main(int argc, char **argv)
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
case Q_DISABLE_WARNINGS: disable_warnings=1; break;
case Q_ENABLE_PREPARE_WARNINGS: prepare_warnings_enabled=1; break;
case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break;
case Q_ENABLE_INFO: disable_info=0; break;
case Q_DISABLE_INFO: disable_info=1; break;
case Q_ENABLE_METADATA: display_metadata=1; break;
......
select 1 + "2 a";
1 + "2 a"
3
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2 a'
create table t (a int primary key, b blob default '');
Warnings:
Warning 1101 BLOB/TEXT column 'b' can't have a default value
select a, (2*a) AS a from t group by a;
a a
Warnings:
Warning 1052 Column 'a' in group statement is ambiguous
drop table t;
select 1 + "2 a";
1 + "2 a"
3
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2 a'
create table t (a int primary key, b blob default '');
Warnings:
Warning 1101 BLOB/TEXT column 'b' can't have a default value
select a, (2*a) AS a from t group by a;
a a
Warnings:
Warning 1052 Column 'a' in group statement is ambiguous
Warning 1052 Column 'a' in group statement is ambiguous
drop table t;
select 1 + "2 a";
1 + "2 a"
3
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2 a'
create table t (a int primary key, b blob default '');
Warnings:
Warning 1101 BLOB/TEXT column 'b' can't have a default value
select a, (2*a) AS a from t group by a;
a a
Warnings:
Warning 1052 Column 'a' in group statement is ambiguous
drop table t;
......@@ -54,11 +54,10 @@ perl;
close FILE;
EOF
# line below will be removed
disable_ps_protocol;
replace_regex /Table.*t_corrupted2/t_corrupted2/ ;
--enable_prepare_warnings
select * from t_corrupted2; # should show corruption and repair messages
enable_ps_protocol;
--disable_prepare_warnings
select * from t_corrupted2; # should show just rows
drop database mysqltest;
......
......@@ -18,7 +18,9 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t1_will_crash.MYI
# Embedded server doesn't chdir to data directory
--replace_regex /Table '.*\/data\/test\/t1_will_crash/Table '.\/test\/t1_will_crash/
--enable_prepare_warnings
SELECT * FROM t1_will_crash;
--disable_prepare_warnings
DROP TABLE t1_will_crash;
CREATE TABLE t1_will_crash (a INT, KEY (a))
ENGINE=MyISAM
......@@ -33,5 +35,7 @@ FLUSH TABLES;
--copy_file std_data/corrupt_t1#P#p1.MYI $MYSQLD_DATADIR/test/t1_will_crash#P#p1.MYI
# Embedded server doesn't chdir to data directory
--replace_regex /Table '.*\/data\/test\/t1_will_crash/Table '.\/test\/t1_will_crash/
--enable_prepare_warnings
SELECT * FROM t1_will_crash;
--disable_prepare_warnings
DROP TABLE t1_will_crash;
#
# Test mysqltest in --ps-protocol mode.
#
if (`SELECT $PS_PROTOCOL = 0`)
{
--skip Need prepared statement protocol
}
#
# Test the --enable_prepare_warnings command.
# Test default value (off), enabling, and disabling.
#
--enable_warnings
select 1 + "2 a";
create table t (a int primary key, b blob default '');
# This statement gives warning both during prepare and execute.
# So gives double warnings when --enable_prepare_warnings.
select a, (2*a) AS a from t group by a;
drop table t;
--enable_prepare_warnings
select 1 + "2 a";
create table t (a int primary key, b blob default '');
select a, (2*a) AS a from t group by a;
drop table t;
--disable_prepare_warnings
select 1 + "2 a";
create table t (a int primary key, b blob default '');
select a, (2*a) AS a from t group by a;
drop table t;
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