MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
record_query_all_columns.inc
1 ################################################################################
2 #
3 # Stores results from a given query in a temporary table.
4 #
5 # This table can then be used later in the same session for comparing results in
6 # various stages of a transaction (see check_repeatable_read.inc).
7 #
8 # The table name will be: tmp$query_count
9 # where $query_count is the value of the counter for the number of stored
10 # queries in this session. Example: "tmp1"
11 #
12 # We increment the counter (session scope) for the number of queries so that
13 # checker scripts may
14 # a) know how many queries to compare
15 # b) determine the name of the temp tables storing each query
16 #
17 # Assumptions:
18 # - we may be in the middle of a transaction with autocommit OFF.
19 # - queries include all columns of table (t1). This is because we want to
20 # successfully add indexes to columns such as `pk`, `int1_key`, etc.
21 #
22 # Requires the following variables to be set:
23 # $query - the query to be run, which results will be stored in a temp table.
24 #
25 # Modifies the following variables:
26 # $query_count - the number of queries processed by this script so far in this
27 # session.
28 # $tmptable - helper variable containing the name of the temp table.
29 #
30 # The pattern is "CREATE TEMPORARY TABLE tmpx SELECT ...". This allows us to
31 # store query results by using SQL without causing implicit commits.
32 #
33 ################################################################################
34 
35 # increment the query counter
36 --inc $query_count
37 
38 let $tmptable= tmp$query_count;
39 
40 # Execute the query and store results in a new temp table.
41 # Creating indexes now because we cannot do that later withut causing implicit commit.
42 # Therefore we assume that columns of these names exist in the result set produced by the queries.
43 --echo *** Disabling query log (we may deadlock and not do this after all)
44 --disable_query_log
45 # Also disable warnings, because we get 'Unsafe to binlog' warnings for this with 'newer' server versions.
46 --disable_warnings
47 --echo *** Creating temp table with results from query '$query' unless we deadlock or time out.
48 --error 0, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT
49 --eval CREATE TEMPORARY TABLE $tmptable (PRIMARY KEY (`pk`), KEY (`int1_key`), KEY (`int2_key`), UNIQUE (`int1_unique`), UNIQUE (`int2_unique`)) $query
50 --enable_warnings
51 
52 # We may not have been able to create temp table due to locking constraints.
53 # In that case, roll back the statement and skip the rest of the test.
54 --source suite/stress_tx_rr/include/check_for_error_rollback_skip.inc
55 
56 --echo *** Enabling query log
57 --enable_query_log