Bug #39663 mysqltest: --enable_info, affected_rows and ps-protocol broken
Submitted: 26 Sep 2008 10:55 Modified: 18 Dec 2009 20:34
Reporter: Frazer Clement Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Frazer Clement CPU Architecture:Any

[26 Sep 2008 10:55] Frazer Clement
Description:
Some MTR testcases use --enable_info to add affected rows and other info to the generated output to be compared.

In the 'normal' statement execution path in client/mysqltest.c, care is taken to ensure that the captured affected_rows output is for the user-supplied statement, and not for the system generated statement to obtain the warning information.

In the 'ps' protocol statement execution path, this is not done, and it appears that the affected rows count refers to the 'show warnings' statement implicitly executed.  Where these two happen to be different (e.g. affected row count should be zero, or > 1), tests will fail in ps mode.

May be possible to work-around by using --disable_warnings in the testcase and manually checking the warnings.

How to repeat:
Create testcase which should affect 0 rows (i.e. update a non existing row), execute with --enable_info and --enable_warnings.

In Normal mode, affected_rows output would be 0.
In ps mode, affected_rows would be 1.

Suggested fix:
Same as normal mode workaround (By Magnus Svensson), store affected_rows count on stack before fetching warnings.

Have informally tried this out on local branch and it seems to work.
[26 Sep 2008 10:58] Frazer Clement
Quick fix I tried against mysql-5.1-telco-6.3 : 

=== modified file 'client/mysqltest.c'
--- client/mysqltest.c  2008-09-01 12:28:57 +0000
+++ client/mysqltest.c  2008-09-26 10:43:04 +0000
@@ -6598,6 +6598,16 @@
       */
     }

+    /*
+      Need to grab affected rows information before getting
+      warnings here
+    */
+    ulonglong affected_rows;
+    LINT_INIT(affected_rows);
+
+    if (!disable_info)
+      affected_rows= mysql_affected_rows(mysql);
+
     if (!disable_warnings)
     {
       /* Get the warnings from execute */
@@ -6622,7 +6632,7 @@
     }

     if (!disable_info)
-      append_info(ds, mysql_affected_rows(mysql), mysql_info(mysql));
+      append_info(ds, affected_rows, mysql_info(mysql));

   }
[26 Sep 2008 13:41] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/54545
[26 Sep 2008 13:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/54546
[26 Sep 2008 13:59] Frazer Clement
Resetting status to Open as my patch fixes my testcase, but not the original problem.
Also setting triage fields.

Workaround of using --disable_warnings around statement and separate show warnings; avoids problem.
[26 Sep 2008 14:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/54548
[26 Sep 2008 14:04] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/54549
[29 Sep 2008 11:36] Frazer Clement
Moving state from Patch pending to Open, and re-assigning to Magnus.

Patches recorded against this bug are for workarounds to testcases which failed due to this bug.
[29 Sep 2008 11:47] Magnus BlÄudd
The patch works and is approved. It should go into mysqltest as of 5.1
[2 Oct 2009 18:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/85594

2817 Frazer Clement	2009-10-02
      Bug#39663 mysqltest: --enable_info, affected_rows and ps-protocol broken
      modified:
        client/mysqltest.c
[5 Oct 2009 12:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/85748

2818 Frazer Clement	2009-10-05
      Bug#39663 mysqltest: --enable_info, affected_rows and ps-protocol broken
      modified:
        client/mysqltest.c
[6 Oct 2009 8:57] Bugs System
Pushed into 5.0.87 (revid:joro@sun.com-20091006073202-rj21ggvo2gw032ks) (version source revid:frazer@mysql.com-20091005125700-66vq7h47lqnsw2zu) (merge vers: 5.0.87) (pib:11)
[6 Oct 2009 9:01] Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:frazer@mysql.com-20091005125759-em2nst3syy53scjo) (merge vers: 5.1.40) (pib:11)
[8 Oct 2009 15:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/86210

2816 Frazer Clement	2009-10-08
      Fix compile break from bug#39663 fix
      modified:
        client/mysqltest.c
[14 Oct 2009 14:35] Bugs System
Pushed into 5.0.88 (revid:joro@sun.com-20091014143320-kwcqatf2g9cjbx43) (version source revid:frazer@mysql.com-20091008152315-q39ctwvsu8gnec1u) (merge vers: 5.0.87) (pib:13)
[14 Oct 2009 14:40] Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091014143611-cphb0enjlx6lpat1) (version source revid:satya.bn@sun.com-20091013071829-zc4c3go44j6re592) (merge vers: 5.1.40) (pib:13)
[14 Oct 2009 15:14] Paul DuBois
Test suite change. No changelog entry needed.

Setting report to NDI pending push into 5.5.x+.
[22 Oct 2009 6:36] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 2009 7:08] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091019131708-bc6pv55x6287a0wc) (merge vers: 5.5.0-beta) (pib:13)
[22 Oct 2009 19:21] Paul DuBois
Test suite change. No changelog entry needed.
[18 Dec 2009 10:36] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:52] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:07] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:21] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)