~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/include/check_no_concurrent_insert.inc

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-06-17 22:38:56 UTC
  • mto: (1.2.1 upstream) (2.1.4 sid)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20100617223856-p3sfjw3y37l2g0u6
ImportĀ upstreamĀ versionĀ 5.1.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# SUMMARY
 
3
#   Check that statement reading table '$table' doesn't allow concurrent
 
4
#   inserts in it.
 
5
#
 
6
# PARAMETERS 
 
7
#   $table         Table in which concurrent inserts should be disallowed.
 
8
#   $con_aux1      Name of the first auxiliary connection to be used by this
 
9
#                  script.
 
10
#   $con_aux2      Name of the second auxiliary connection to be used by this
 
11
#                  script.
 
12
#   $statement     Statement to be checked.
 
13
#   $restore_table Table which might be modified by statement to be checked
 
14
#                  and thus needs backing up before its execution and
 
15
#                  restoring after it (can be empty).
 
16
#
 
17
# EXAMPLE
 
18
#    lock_sync.test
 
19
#
 
20
--disable_result_log
 
21
--disable_query_log
 
22
 
 
23
# Reset DEBUG_SYNC facility for safety.
 
24
set debug_sync= "RESET";
 
25
 
 
26
if (`SELECT '$restore_table' <> ''`)
 
27
{
 
28
--eval create temporary table t_backup select * from $restore_table;
 
29
}
 
30
 
 
31
connection $con_aux1;
 
32
set debug_sync='after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go';
 
33
--send_eval $statement;
 
34
 
 
35
connection $con_aux2;
 
36
set debug_sync='now WAIT_FOR parked';
 
37
--send_eval insert into $table (i) values (0);
 
38
 
 
39
--enable_result_log
 
40
--enable_query_log
 
41
connection default;
 
42
# Wait until concurrent insert is successfully blocked because
 
43
# of our statement.
 
44
let $wait_condition=
 
45
  select count(*) = 1 from information_schema.processlist
 
46
  where state = "Locked" and info = "insert into $table (i) values (0)";
 
47
--source include/wait_condition.inc
 
48
 
 
49
--disable_result_log
 
50
--disable_query_log
 
51
 
 
52
set debug_sync= 'now SIGNAL go';
 
53
connection $con_aux1;
 
54
--reap
 
55
connection $con_aux2;
 
56
--reap
 
57
connection default;
 
58
 
 
59
if ($success)
 
60
{
 
61
--echo Success: '$statement' doesn't allow concurrent inserts into '$table'.
 
62
}
 
63
if (!$success)
 
64
{
 
65
--echo Error: '$statement' allows concurrent inserts into '$table'!
 
66
}
 
67
 
 
68
--eval delete from $table where i = 0;
 
69
 
 
70
if (`SELECT '$restore_table' <> ''`)
 
71
{
 
72
--eval truncate table $restore_table;
 
73
--eval insert into $restore_table select * from t_backup;
 
74
drop temporary table t_backup;
 
75
}
 
76
 
 
77
# Clean-up. Reset DEBUG_SYNC facility after use.
 
78
set debug_sync= "RESET";
 
79
 
 
80
--enable_result_log
 
81
--enable_query_log