Bug #81137 auto add sleep interval between source file's queries
Submitted: 19 Apr 2016 11:37
Reporter: Leon Zhang Zhang Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:mysql 5.5.31 OS:Any
Assigned to: CPU Architecture:Any

[19 Apr 2016 11:37] Leon Zhang Zhang
Description:
There is a scene that when we source a sql file, we want to execute each query separately and sleep several seconds between two queries.
We usually add "select sleep(N);" between queries. It will take much time if we frequency be asked to do so.

How to repeat:
mysql> select 1;select 1;
--------------
select 1
--------------

+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
##default no sleep here
--------------
select 1
--------------

+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

Suggested fix:
cat > test.sql
select 1;
select 1;
ctrl+D

mysql> \i 1
mysql>interval 1
mysql> select 1;select 1;
mysql> source test.sql

--------------
select 1
--------------

+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

sleepping before execute next query
--------------
select 1
--------------

+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

sleepping before execute next query

I have writen a simple patch for this issue, find it in attachment.
[19 Apr 2016 11:40] Leon Zhang Zhang
This patch is base mysql-5.5.31 community

Attachment: mysql_interval.5.5.31.patch (text/x-patch), 2.46 KiB.