1 ################################################################################
3 # Stores results from a given query in a temporary table.
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).
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"
12 # We increment the counter (session scope) for the number of queries so that
14 # a) know how many queries to compare
15 # b) determine the name of the temp tables storing each query
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.
22 # Requires the following variables to be set:
23 # $query - the query to be run, which results will be stored in a temp table.
25 # Modifies the following variables:
26 # $query_count - the number of queries processed by this script so far in this
28 # $tmptable - helper variable containing the name of the temp table.
30 # The pattern is "CREATE TEMPORARY TABLE tmpx SELECT ...". This allows us to
31 # store query results by using SQL without causing implicit commits.
33 ################################################################################
35 # increment the query counter
38 let $tmptable= tmp$query_count;
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)
45 # Also disable warnings, because we get 'Unsafe to binlog' warnings for this with 'newer' server versions.
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
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
56 --echo *** Enabling
query log