MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
socket_check1.inc
1 # Example how to use this auxiliary script
2 #-----------------------------------------
3 #
4 ### The table/tables used in $part must have the right content.
5 ### $title_prefix is used for the generation of titles
6 #
7 # let $title_prefix= 4.3;
8 ### $check_num is used for the generation of titles and gets incremented after
9 ### every call of the current script.
10 # let $check_num= 1;
11 ### $diff_column_list is used for the generation of error information and valid for
12 ### every sub test.
13 # let $diff_column_list=
14 # t2.COUNT_READ - t1.COUNT_READ AS D_COUNT_READ,
15 # t2.COUNT_READ AS S2_COUNT_READ,
16 # t1.COUNT_READ AS S1_COUNT_READ,
17 # t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ AS D_SUM_NUMBER_OF_BYTES_READ,
18 # t2.SUM_NUMBER_OF_BYTES_READ AS S2_SUM_NUMBER_OF_BYTES_READ,
19 # t1.SUM_NUMBER_OF_BYTES_READ AS S1_SUM_NUMBER_OF_BYTES_READ,
20 # t2.COUNT_WRITE - t1.COUNT_WRITE AS D_COUNT_WRITE,
21 # t2.COUNT_WRITE AS S2_COUNT_WRITE,
22 # t1.COUNT_WRITE AS S1_COUNT_WRITE,
23 # t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE AS D_UM_NUMBER_OF_BYTES_WRITE,
24 # t2.SUM_NUMBER_OF_BYTES_WRITE AS S2_SUM_NUMBER_OF_BYTES_WRITE,
25 # t1.SUM_NUMBER_OF_BYTES_WRITE AS S1_SUM_NUMBER_OF_BYTES_WRITE,
26 # t2.COUNT_MISC - t1.COUNT_MISC AS D_COUNT_MISC,
27 # t2.COUNT_MISC AS S2_COUNT_MISC,
28 # t1.COUNT_MISC AS S1_COUNT_MISC;
29 ### $part is used for the generation of "check" statements + error information
30 ### and valid for every sub test.
31 # let $part=
32 # FROM mysqltest.socket_summary_by_instance_detail t1
33 # JOIN mysqltest.socket_summary_by_instance_detail t2
34 # USING (EVENT_NAME, OBJECT_INSTANCE_BEGIN, run)
35 # WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
36 # AND EVENT_NAME LIKE ('%client_connection')
37 # AND run = 1;
38 #
39 # --echo # $title_prefix Check the differences caused by SQL statement
40 #
41 # let stmt1= SELECT col2 FROM does_not_exist;
42 # let stmt2= SELECT col2 FROM does_not_exist WHERE col1 = 0;
43 ### $msg is used to generate some explanation of what we compare.
44 # let $msg=
45 # # One statement is longer than the other.
46 # # Both statements fail with the same error message (table does not exist);
47 # let $my_rules=
48 # t2.COUNT_READ - t1.COUNT_READ = 0 AND
49 # t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
50 # t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
51 # t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 0 AND
52 # t2.COUNT_MISC - t1.COUNT_MISC = 0;
53 # --source ../include/socket_check1.inc
54 #
55 # let stmt1= ....
56 # let stmt2= ....
57 # let $my_rules= ...
58 # --source ../include/socket_check1.inc
59 #
60 # ...
61 #
62 
63 --echo # $title_prefix.$check_num Compare impact of statements
64 --echo # $stmt2
65 --echo # $stmt1
66 --echo $msg
67 
68 # Enable this when extending the checks for SQL statements.
69 if(0)
70 {
71  if (`SELECT CONCAT("$stmt1","$stmt2","$my_rules") LIKE '%_not_set%'`)
72  {
73  --echo # INTERNAL ERROR:
74  --echo # At least one of the variables has no value (is like '%_not_set')
75  --echo # stmt1 : $stmt1
76  --echo # stmt2 : $stmt2
77  --echo # my_rules : $my_rules
78  --echo # Sorry, have to abort
79  exit;
80  }
81 }
82 
83 if(`SELECT NOT ( $my_rules )
84  $part
85  AND t2.statement = '$stmt2' AND t1.statement = '$stmt1'`)
86 {
87  --enable_query_log
88  --enable_result_log
89  --echo # The compared statistics looks suspicious
90  --echo # We expect
91  --echo $my_rules
92  --echo
93  --horizontal_results
94  eval
95  SELECT $my_rules AS Expect_1
96  $part
97  AND t2.statement = '$stmt2' AND t1.statement = '$stmt1';
98  --echo
99  --vertical_results
100  eval
101  SELECT $diff_column_list
102  $part
103  AND t1.statement = '$stmt1' AND t2.statement = '$stmt2';
104  --echo
105  --horizontal_results
106 
107  eval
108  SELECT
109  LPAD(COUNT_READ, 8, ' ') AS CNT_READ,
110  LPAD(SUM_NUMBER_OF_BYTES_READ, 10,' ') AS BYTES_READ,
111  LPAD(COUNT_WRITE,9, ' ') AS CNT_WRITE,
112  LPAD(SUM_NUMBER_OF_BYTES_WRITE, 11,' ') AS BYTES_WRITE,
113  LPAD(COUNT_MISC, 8, ' ') AS CNT_MISC, statement
114  FROM mysqltest.socket_summary_by_instance_detail
115  WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
116  AND EVENT_NAME LIKE ('%client_connection')
117  AND run = 1
118  AND statement IN('$stmt2','$stmt1');
119  let $print_details= 1;
120 }
121 # Initialize all variables which depend on the statements to be checked.
122 # This prevents that we run with wrong data.
123 let $stmt1= stmt1_not_set;
124 let $stmt2= stmt2_not_set;
125 let $my_rules= my_rules_not_set;
126 let $msg= msg_not_set;
127 inc $check_num;
128 
129