Bug #35701 please allow test language variables in connection and sync_slave_with_master
Submitted: 31 Mar 2008 10:44 Modified: 30 Jan 2009 17:03
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:Tests: Replication Severity:S4 (Feature request)
Version: OS:Any
Assigned to: Sven Sandberg CPU Architecture:Any
Tags: 51rpl, Connection, replication, sync_slave_with_master, testing, variable

[31 Mar 2008 10:44] Sven Sandberg
Description:
It is currently not possible to do the following:

 connection $name_of_connection;

Only some hard-coded connections are available:

 connection master;
 connection slave;

etc. If we could have variables, files like include/diff_tables.inc would work more robustly.

The following test language constructions are affected:

  connection <server>
  sync_slave_with_master <slave>
  disconnect <server>

How to repeat:
source include/master-slave.inc;
source include/have_log_bin.inc;
let $x=slave;
--echo x has value $x
connection $x;
connection master;
sync_slave_with_master $x;
disconnect $x;

Suggested fix:
Allow test language variables to be used for the name of the connection.
[31 Mar 2008 11:09] Sven Sandberg
One more thing: it would be great if the current connection could be read through a test language function (but please give higher priority to the feature request above).

That would allow generic auxiliary test tools like include/wait_for_slave_* or include/diff_tables.inc to be free of side effects. Namely, such a script could first read the connection, then do its work, and then reset the connection to the original one.
[31 Mar 2008 13:55] Magnus Blåudd
The 'select_connection' function need to be update to use the "new" argument parsing function 'check_command_args', that will give "automatic" evaluation of the text after connection.
[9 Oct 2008 17:19] Sven Sandberg
-------- BEGIN TEST CASE FOR THIS BUG --------

source include/master-slave.inc;

--echo ==== hard-coded connection names ====

connection master;
--echo $CURRENT_CONNECTION
CREATE TABLE t1 (id INT, name VARCHAR(100));
save_master_pos;

connection slave;
--echo $CURRENT_CONNECTION
sync_with_master 0;

--echo ==== hard-coded variable values ====
let $m1= master;
let $s1= slave;

connection $m1;
--echo $CURRENT_CONNECTION
INSERT INTO t1 VALUES (1, 'master'), (2, 'slave');
save_master_pos;

connection $s1;
--echo $CURRENT_CONNECTION
sync_with_master 0;

--echo ==== variable values from table ====

let $m2= query_get_value(select name from t1 where id=1, name, 1);
let $s2= query_get_value(select name from t1 where id=2, name, 1);

connection $m2;
--echo $CURRENT_CONNECTION
INSERT INTO t1 VALUES (3, 'foo');
save_master_pos;

connection $s2;
--echo $CURRENT_CONNECTION
sync_with_master 0;

--echo ==== clean up ====

connection master;
drop table t1;
sync_slave_with_master;

exit;

-------- END TEST CASE FOR THIS BUG --------
[10 Oct 2008 7:34] Magnus Blåudd
Approved, reviewed by mail with some comments and the requirement to add mysqltest.result to the patch.
[23 Oct 2008 14:21] 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/56900

2683 Sven Sandberg	2008-10-23
      BUG#35701: please allow test language variables in connection and sync_slave_with_master
      Problem: In the mysqltest language, it was not possible to set the current
      connection from a variable, and it was not possible to read the current
      connection.
      Fix: Allow setting the connection from a variable, like:
      connection $variable;
      and introduce the mysqltest language variable $CURRENT_CONNECTION, which
      holds the name of the current connection.
[23 Oct 2008 14:26] 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/56901

2713 Sven Sandberg	2008-10-23 [merge]
      merged fix for BUG#35701 from 5.1-rpl to 6.0-rpl
[27 Oct 2008 12:33] Sven Sandberg
pushed to 5.1-rpl and 6.0-rpl
[6 Nov 2008 2:25] 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/57960

2684 He Zhenxing	2008-11-05 [merge]
      For test, please ignore
[15 Jan 2009 8:07] 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/63321

2713 Magnus Svensson	2009-01-15
      Bug#35701 please allow test language variables in connection and
      sync_slave_with_master
       - Additional patch for "disconnect $variable"
[30 Jan 2009 13:26] Bugs System
Pushed into 6.0.10-alpha (revid:luis.soares@sun.com-20090129165607-wiskabxm948yx463) (version source revid:luis.soares@sun.com-20090129163120-e2ntks4wgpqde6zt) (merge vers: 6.0.10-alpha) (pib:6)
[30 Jan 2009 15:07] Bugs System
Pushed into 5.1.32 (revid:luis.soares@sun.com-20090129165946-d6jnnfqfokuzr09y) (version source revid:msvensson@mysql.com-20090115080551-cz7kkh72rrgvtxf5) (merge vers: 5.1.31) (pib:6)
[30 Jan 2009 17:03] Paul DuBois
mysqltest: A variable can be used to provide the connection name for the 
connection, disconnect, and sync_slave_with_master commands

Updated the mysqltest manual
[17 Feb 2009 14:52] Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 16:40] Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 18:16] Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090201210519-vehobc4sy3g9s38e) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)