← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2773)

 

#At lp:maria

 2773 knielsen@xxxxxxxxxxxxxxx	2009-10-09
      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.
      added:
        mysql-test/r/mysqltest_ps.result
        mysql-test/t/mysqltest_ps.test
      modified:
        client/mysqltest.cc
        mysql-test/suite/maria/t/maria-recover.test
        mysql-test/suite/parts/t/partition_recover_myisam.test

per-file messages:
  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.
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-09-07 20:50:10 +0000
+++ b/client/mysqltest.cc	2009-10-09 08:09:24 +0000
@@ -100,6 +100,7 @@ static my_bool display_result_vertically
   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
 
       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;

=== added file 'mysql-test/r/mysqltest_ps.result'
--- a/mysql-test/r/mysqltest_ps.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysqltest_ps.result	2009-10-09 08:09:24 +0000
@@ -0,0 +1,40 @@
+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;

=== modified file 'mysql-test/suite/maria/t/maria-recover.test'
--- a/mysql-test/suite/maria/t/maria-recover.test	2009-02-19 09:01:25 +0000
+++ b/mysql-test/suite/maria/t/maria-recover.test	2009-10-09 08:09:24 +0000
@@ -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;

=== modified file 'mysql-test/suite/parts/t/partition_recover_myisam.test'
--- a/mysql-test/suite/parts/t/partition_recover_myisam.test	2009-10-07 07:57:48 +0000
+++ b/mysql-test/suite/parts/t/partition_recover_myisam.test	2009-10-09 08:09:24 +0000
@@ -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;

=== added file 'mysql-test/t/mysqltest_ps.test'
--- a/mysql-test/t/mysqltest_ps.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysqltest_ps.test	2009-10-09 08:09:24 +0000
@@ -0,0 +1,34 @@
+#
+# 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;