~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/randgen/conf/replication/replication-dml_sql.yy

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009-2010 Sun Microsystems, Inc. All rights reserved.
2
 
# Use is subject to license terms.
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; version 2 of the License.
7
 
#
8
 
# This program is distributed in the hope that it will be useful, but
9
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
 
# General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
16
 
# USA
17
 
 
18
 
# From the manual:
19
 
##################
20
 
# 5.2.4.3. Mixed Binary Logging Format
21
 
# ... automatic switching from statement-based to row-based replication takes place under the following conditions:
22
 
# DML updates an NDBCLUSTER table
23
 
# When a function contains UUID().
24
 
#   --> "value_unsafe_for_sbr"
25
 
# When 2 or more tables with AUTO_INCREMENT columns are updated.
26
 
#   --> "update","delete"
27
 
# When any INSERT DELAYED is executed.
28
 
#   --> "low_priority_delayed_high_priority" but this had to be disabled.
29
 
# When the body of a view requires row-based replication, the statement creating the view also uses it — for example, this occurs when the statement creating a view uses the UUID() function.
30
 
# When a call to a UDF is involved.
31
 
# If a statement is logged by row and the client that executed the statement has any temporary tables, then logging by row is used for all subsequent statements
32
 
#    (except for those accessing temporary tables) until all temporary tables in use by that client are dropped.  This is true whether or not any temporary tables are actually logged.
33
 
#    Temporary tables cannot be logged using the row-based format; thus, once row-based logging is used, all subsequent statements using that table are unsafe,
34
 
#    and we approximate this condition by treating all statements made by that client as unsafe until the client no longer holds any temporary tables.
35
 
# When FOUND_ROWS() or ROW_COUNT() is used. (Bug#12092, Bug#30244)
36
 
#        SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
37
 
#        WHERE id > 100 LIMIT 10;
38
 
#        SELECT FOUND_ROWS();
39
 
#    FOUND_ROWS() or ROW_COUNT() are bigint(21) ;
40
 
#    Without SQL_CALC_FOUND_ROWS within the previous SELECT, FOUND_ROWS() = number of rows found by this SELECT.
41
 
#    --> "value_unsafe_for_sbr", but no SQL_CALC_FOUND_ROWS
42
 
# When USER(), CURRENT_USER(), or CURRENT_USER is used. (Bug#28086)
43
 
#    --> "value_unsafe_for_sbr"
44
 
# When a statement refers to one or more system variables. (Bug#31168)
45
 
#     --> "shake_clock" affects timestamp
46
 
#
47
 
# Exception. The following system variables, when used with session scope (only), do not cause the logging format to switch:
48
 
#   * auto_increment_increment * auto_increment_offset
49
 
#   * character_set_client * character_set_connection * character_set_database * character_set_server * collation_connection * collation_database * collation_server
50
 
#   * foreign_key_checks
51
 
#   * identity
52
 
#   * last_insert_id
53
 
#   * lc_time_names
54
 
#   * pseudo_thread_id
55
 
#   * sql_auto_is_null
56
 
#   * time_zone
57
 
#   * timestamp
58
 
#     --> "shake_clock" affects timestamp
59
 
#   * unique_checks
60
 
#   For information about how replication treats sql_mode, see Section 16.3.1.30, “Replication and Variables”.
61
 
#   * When one of the tables involved is a log table in the mysql database.
62
 
#   * When the LOAD_FILE() function is used. (Bug#39701)
63
 
#   --> "value_unsafe_for_sbr"
64
 
#-----------------------------
65
 
# When using statement-based replication, the LOAD DATA INFILE statement's CONCURRENT  option is not replicated;
66
 
# that is, LOAD DATA CONCURRENT INFILE is replicated as LOAD DATA INFILE, and LOAD DATA CONCURRENT LOCAL INFILE
67
 
# is replicated as LOAD DATA LOCAL INFILE. The CONCURRENT option is replicated when using row-based replication. (Bug#34628)
68
 
#   --> Use of "concurrent_or_empty" in "dml"
69
 
#-------------------------------
70
 
# If you have databases on the master with character sets that differ from the global character_set_server value, you should
71
 
# design your CREATE TABLE statements so that tables in those databases do not implicitly rely on the database default character set.
72
 
# A good workaround is to state the character set and collation explicitly in CREATE TABLE statements.
73
 
#-----------------------------------
74
 
# MySQL 5.4.3 and later.   Every CREATE DATABASE IF NOT EXISTS statement is replicated, whether or not the database already exists on
75
 
# the master. Similarly, every CREATE TABLE IF NOT EXISTS statement is replicated, whether or not the table already exists on the master.
76
 
# This includes CREATE TABLE IF NOT EXISTS ... LIKE. However, replication of CREATE TABLE IF NOT EXISTS ... SELECT follows somewhat
77
 
# different rules; see Section 16.3.1.4, “Replication of CREATE TABLE ... SELECT Statements”, for more information.
78
 
#
79
 
# Replication of CREATE EVENT IF NOT EXISTS.  CREATE EVENT IF NOT EXISTS is always replicated in MySQL 5.4, whether or not the event
80
 
# named in this statement already exists on the master.  See also Bug#45574.
81
 
#-----------------------------------
82
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-differing-tables.html
83
 
#-----------------------------------
84
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-floatvalues.html
85
 
#-----------------------------------
86
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-flush.html
87
 
#-----------------------------------
88
 
# USE LIMIT WITH ORDER BY    safety_check needs to be switched off otherwise we get a false alarm
89
 
#-----------------------------------
90
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-slaveerrors.html
91
 
# FOREIGN KEY, master InnoDB and slave MyISAM
92
 
#-----------------------------------
93
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-max-allowed-packet.html
94
 
# BLOB/TEXT value too big for max-allowed-packet on master or on slave
95
 
#-----------------------------------
96
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-timeout.html
97
 
# Slave: Innodb detects deadlock -> slave_transaction_retries to run the action to replicate ....
98
 
# mleich: Most probably not doable with current RQG
99
 
#-----------------------------------
100
 
# The same system time zone should be set for both master and slave. If not -> problems with NOW() or FROM_UNIXTIME()
101
 
# CONVERT_TZ(...,...,@@session.time_zone)  is properly replicated ...
102
 
#-----------------------------------
103
 
# In situations where transactions mix updates to transactional and nontransactional tables, the order of statements
104
 
# in the binary log is correct, and all needed statements are written to the binary log even in case of a ROLLBACK.
105
 
# However, when a second connection updates the nontransactional table before the first connection's transaction is
106
 
# complete, statements can be logged out of order, because the second connection's update is written immediately after
107
 
# it is performed, regardless of the state of the transaction being performed by the first connection.
108
 
#    --> grammar items trans_table , nontrans_table, + use only one sort of table within transaction
109
 
#    --> LOCK ALL TABLES + runs transaction with both sorts of tables   ???
110
 
#----------------------------------------------------------------------------------------------------------------------
111
 
# Due to the nontransactional nature of MyISAM  tables, it is possible to have a statement that only partially updates
112
 
# a table and returns an error code. This can happen, for example, on a multiple-row insert that has one row violating
113
 
# a key constraint, or if a long update statement is killed after updating some of the rows.
114
 
# If that happens on the master, the slave thread exits and waits for the database administrator to decide what to do
115
 
# about it unless the error code is legitimate and execution of the statement results in the same error code on the slave.
116
 
#-----------------------------------
117
 
# When the storage engine type of the slave is nontransactional, transactions on the master that mix updates of transactional
118
 
# and nontransactional tables should be avoided because they can cause inconsistency of the data between the master's
119
 
# transactional table and the slave's nontransactional table.
120
 
#-----------------------------------
121
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-triggers.html !!!!
122
 
#-----------------------------------
123
 
# TRUNCATE is treated for purposes of logging and replication as DDL rather than DML ...
124
 
# --> later
125
 
#-----------------------------------
126
 
# http://dev.mysql.com/doc/refman/5.4/en/mysqlbinlog-hexdump.html
127
 
#    Type       Name    Meaning
128
 
#    00         UNKNOWN_EVENT   This event should never be present in the log.
129
 
#    01         START_EVENT_V3  This indicates the start of a log file written by MySQL 4 or earlier.
130
 
# X  02         QUERY_EVENT     The most common type of events. These contain statements executed on the master.
131
 
# ?  03         STOP_EVENT      Indicates that master has stopped.
132
 
# X  04         ROTATE_EVENT    Written when the master switches to a new log file.
133
 
#        --> "rotate_event"
134
 
# X  05         INTVAR_EVENT    Used for AUTO_INCREMENT values or when the LAST_INSERT_ID() function is used in the statement.
135
 
#        --> "value" contains NULL and (nested) LAST_INSERT_ID()
136
 
#    06         LOAD_EVENT      Used for LOAD DATA INFILE in MySQL 3.23.
137
 
#    07         SLAVE_EVENT     Reserved for future use.
138
 
#    08         CREATE_FILE_EVENT       Used for LOAD DATA INFILE statements. This indicates the start of execution of such a statement. A temporary file is created on the slave. Used in MySQL 4 only.
139
 
# X  09         APPEND_BLOCK_EVENT      Contains data for use in a LOAD DATA INFILE statement. The data is stored in the temporary file on the slave.
140
 
#        --> "dml" contains LOAD DATA
141
 
#    0a         EXEC_LOAD_EVENT         Used for LOAD DATA INFILE statements. The contents of the temporary file is stored in the table on the slave. Used in MySQL 4 only.
142
 
# X  0b         DELETE_FILE_EVENT       Rollback of a LOAD DATA INFILE statement. The temporary file should be deleted on the slave.
143
 
#        --> "dml" contains LOAD DATA
144
 
#    0c         NEW_LOAD_EVENT  Used for LOAD DATA INFILE in MySQL 4 and earlier.
145
 
# X  0d         RAND_EVENT      Used to send information about random values if the RAND() function is used in the statement.
146
 
#        --> "value_rand"
147
 
# X  0e         USER_VAR_EVENT  Used to replicate user variables.
148
 
#        --> "dml" containing SET @aux + "values" containg @aux
149
 
# X  0f         FORMAT_DESCRIPTION_EVENT        This indicates the start of a log file written by MySQL 5 or later.
150
 
#        --> ?
151
 
# X  10         XID_EVENT       Event indicating commit of an XA transaction.
152
 
# X  11         BEGIN_LOAD_QUERY_EVENT  Used for LOAD DATA INFILE statements in MySQL 5 and later.
153
 
# X  12         EXECUTE_LOAD_QUERY_EVENT        Used for LOAD DATA INFILE statements in MySQL 5 and later.
154
 
#        --> "dml" contains LOAD DATA
155
 
# X  13         TABLE_MAP_EVENT         Information about a table definition. Used in MySQL 5.1.5 and later.
156
 
#    14         PRE_GA_WRITE_ROWS_EVENT         Row data for a single table that should be created. Used in MySQL 5.1.5 to 5.1.17.
157
 
#    15         PRE_GA_UPDATE_ROWS_EVENT        Row data for a single table that needs to be updated. Used in MySQL 5.1.5 to 5.1.17.
158
 
#    16         PRE_GA_DELETE_ROWS_EVENT        Row data for a single table that should be deleted. Used in MySQL 5.1.5 to 5.1.17.
159
 
# X  17         WRITE_ROWS_EVENT        Row data for a single table that should be created. Used in MySQL 5.1.18 and later.
160
 
#        --> insert
161
 
# X  18         UPDATE_ROWS_EVENT       Row data for a single table that needs to be updated. Used in MySQL 5.1.18 and later.
162
 
#        --> update
163
 
# X  19         DELETE_ROWS_EVENT       Row data for a single table that should be deleted. Used in MySQL 5.1.18 and later.
164
 
#        --> delete
165
 
# 1a    INCIDENT_EVENT  Something out of the ordinary happened. Added in MySQL 5.1.18.
166
 
# My (mleich) markings:
167
 
# X needs sub test
168
 
# I most probably already covered (FIXME: Check in hex dump)
169
 
#------------------------------------------------
170
 
# The following restriction applies to statement-based replication only, not to row-based replication.
171
 
# The GET_LOCK(), RELEASE_LOCK(), IS_FREE_LOCK(), and IS_USED_LOCK() functions that handle user-level locks are replicated
172
 
# without the slave knowing the concurrency context on master. Therefore, these functions should not be used to insert
173
 
# into a master's table because the content on the slave would differ.
174
 
# (For example, do not issue a statement such as INSERT INTO mytable VALUES(GET_LOCK(...)).)
175
 
#------------------------------------------------
176
 
# http://dev.mysql.com/doc/refman/5.4/en/replication-features-functions.html
177
 
# The USER(), CURRENT_USER(), UUID(), VERSION(), and LOAD_FILE() functions are replicated without change and thus do not
178
 
# work reliably on the slave unless row-based replication is enabled. This is also true for CURRENT_USER. (See Section 16.1.2, “Replication Formats”.)
179
 
#
180
 
# USER(), CURRENT_USER(), and CURRENT_USER are automatically replicated using row-based replication when using MIXED mode, and generate a warning in STATEMENT mode. (Bug#28086)
181
 
# the SYSDATE() function is not replication-safe
182
 
# FOUND_ROWS() and ROW_COUNT() functions are not replicated reliably using statement-based + generate a warning in STATEMENT mode
183
 
# --> "values"
184
 
 
185
 
#################################################
186
 
# From the discussion:
187
 
# - If you want to change the replication format, do so outside the boundaries of a transaction. (SBR?)
188
 
#   --> "*_dml_event"
189
 
# - In statement based replication, any non-transactional statement should be either placed outside the boundaries of a transaction or before any transactional statement.
190
 
#   note(mleich): transactional/non-transactional statement refers to the table/tables where something is modified
191
 
#------------------------------------------------
192
 
#################################################
193
 
# Experience with mysql-5.1-rep+3 with BINLOG_FORMAT = STATEMENT
194
 
# 1. SAVEPOINT A followed by some UPDATE on a myisam table
195
 
# 2. Mixup of transactional and nontransactional table in any table modifying statement
196
 
#    (independend of the use - modify or just query - of the table)
197
 
# 3. Statement with nontransactional table occurs after statement with transactional table
198
 
# end up with
199
 
# Note 1592     Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT.
200
 
#           Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur
201
 
#           after transactional reads or writes inside a transaction.
202
 
#
203
 
 
204
 
safety_check:
205
 
        # For debugging the grammar use
206
 
        { return '/*' . $pick_mode . '*/' } /* QUERY_IS_REPLICATION_SAFE */ ;
207
 
        # For faster execution set this grammar element to "empty".
208
 
        # ;
209
 
 
210
 
query:
211
 
        binlog_event ;
212
 
 
213
 
query_init:
214
 
        # We need to set "$pick_mode = 3" because of the following possible scenario
215
 
        # Current GLOBAL BINLOG_FORMAT is probably STATEMENT.
216
 
        # --> connect and initial SESSION BINLOG_FORMAT equals GLOBAL BINLOG_FORMAT (STATEMENT)
217
 
        # --> query -> binlog_event -> dml_event -> binlog_format_set ->
218
 
        # --> rand_global_binlog_format (this does not set $pick_mode and has no impact
219
 
        #     on our SESSION BINLOG_FORMAT) --> dml_list --> dml
220
 
        # $pick_mode cannot "help" during statement generation in "dml". So it could happen
221
 
        # that we get a statement using a transactional and a non transactional table.
222
 
        # And this is UNSAFE if our current SESSION BINLOG_FORMAT is STATEMENT.
223
 
        # $pick_mode = 3 brings us to the safe side.
224
 
        { $pick_mode = 3 ; return undef } ;
225
 
 
226
 
binlog_event:
227
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
228
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
229
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
230
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
231
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
232
 
        /* BEGIN 1 */ dml_event    /* 1 END */  |
233
 
        set_iso_level      |
234
 
        set_iso_level      |
235
 
        rotate_event       ;
236
 
        # This fools the RQG deadlock detection shake_clock        ;
237
 
 
238
 
set_iso_level:
239
 
        safety_check SET global_or_session TRANSACTION ISOLATION LEVEL iso_level ;
240
 
iso_level:
241
 
        { if ( $format == 'STATEMENT' ) { return $prng->arrayElement(['REPEATABLE READ','SERIALIZABLE']) } else { return $prng->arrayElement(['READ UNCOMMITTED','READ COMMITTED','REPEATABLE READ','SERIALIZABLE']) } } ;
242
 
 
243
 
global_or_session:
244
 
        SESSION | GLOBAL ;
245
 
 
246
 
shake_clock:
247
 
        safety_check SET SESSION TIMESTAMP = UNIX_TIMESTAMP() plus_minus _digit ;
248
 
 
249
 
rotate_event:
250
 
        # Cause that the master switches to a new binary log file
251
 
        # RESET MASTER is not useful here because it causes
252
 
        # - master.err: [ERROR] Failed to open log (file '/dev/shm/var_290/log/master-bin.000002', errno 2)
253
 
        # - the RQG test does not terminate in usual way (RQG assumes deadlock)
254
 
        safety_check FLUSH LOGS ;
255
 
 
256
 
xid_event:
257
 
        # Omit BEGIN because it is only an alias for START TRANSACTION
258
 
        START TRANSACTION                     |
259
 
        COMMIT                                |
260
 
        ROLLBACK                              |
261
 
        # In SBR after a "SAVEPOINT A" any statement which modifies a nontransactional table is unsafe.
262
 
        # Therefore we enforce here that future statements within the current transaction use
263
 
        # a transactional table.
264
 
        SAVEPOINT A { $pick_mode=3; return undef} |
265
 
        ROLLBACK TO SAVEPOINT A               |
266
 
        RELEASE SAVEPOINT A                   |
267
 
        implicit_commit                       ;
268
 
 
269
 
implicit_commit:
270
 
        # mleich: A CREATE/ALTER TABLE which fails because the object already exists/does not exist causes an
271
 
        #         implicite COMMIT before the "core" of the statement is executed.
272
 
        #         RPL has problems with concurrent DDL but is this also valid for such cases?
273
 
        CREATE TABLE mysql.user ( f1 BIGINT )    |
274
 
        ALTER TABLE does_not_exist CHANGE COLUMN f1 f2 BIGINT |
275
 
        # CREATE DATABASE ic ; CREATE TABLE ic . _letter SELECT * FROM _table LIMIT digit ; DROP DATABASE ic |
276
 
        # CREATE USER _letter | DROP USER _letter | RENAME USER _letter TO _letter |
277
 
        SET AUTOCOMMIT = ON |
278
 
        SET AUTOCOMMIT = OFF |
279
 
        # CREATE TABLE IF NOT EXISTS _letter ENGINE = engine SELECT * FROM _table LIMIT digit |
280
 
        # RENAME TABLE _letter TO _letter |
281
 
        # TRUNCATE TABLE _letter |
282
 
        # DROP TABLE IF EXISTS _letter |
283
 
        # Grant/Revoke
284
 
        # FLUSH
285
 
        # LOAD DATA INFILE causes an implicit commit only for tables using the NDB storage engine
286
 
        LOCK TABLE _table WRITE ; safety_check UNLOCK TABLES ;
287
 
 
288
 
# Guarantee that the transaction has ended before we switch the binlog format
289
 
dml_event:
290
 
        COMMIT ; safety_check binlog_format_set ; dml_list ; safety_check xid_event ;
291
 
dml_list:
292
 
        safety_check dml |
293
 
        safety_check dml nontrans_trans ; dml_list ;
294
 
 
295
 
nontrans_trans:
296
 
        # This is needed for the generation of the following scenario.
297
 
        # m statements of an transaction use non transactional tables followed by
298
 
        # n statements which use transactional tables.
299
 
        { if ( ($prng->int(1,4) == 4) && ($pick_mode == 4) ) { $pick_mode = 3 } ; return undef } ;
300
 
 
301
 
binlog_format_set:
302
 
        # 1. SESSION BINLOG_FORMAT --> How the actions of our current session will be bin logged
303
 
        # 2. GLOBAL BINLOG_FORMAT  --> How actions with DELAYED will be bin logged
304
 
        #                          --> Initial SESSION BINLOG_FORMAT of session started in future
305
 
        # This means any SET GLOBAL BINLOG_FORMAT ... executed by any session has no impact on any
306
 
        # already existing session (except 2.).
307
 
        rand_global_binlog_format  |
308
 
        rand_session_binlog_format |
309
 
        rand_session_binlog_format |
310
 
        rand_session_binlog_format ;
311
 
rand_global_binlog_format:
312
 
        SET GLOBAL BINLOG_FORMAT = STATEMENT |
313
 
        SET GLOBAL BINLOG_FORMAT = MIXED     |
314
 
        SET GLOBAL BINLOG_FORMAT = ROW       ;
315
 
rand_session_binlog_format:
316
 
        SET SESSION BINLOG_FORMAT = { $format = 'STATEMENT' ; $pick_mode = $prng->int(1,4) ; return $format } |
317
 
        SET SESSION BINLOG_FORMAT = { $format = 'MIXED'     ; $pick_mode = 0               ; return $format } |
318
 
        SET SESSION BINLOG_FORMAT = { $format = 'ROW'       ; $pick_mode = 0               ; return $format } ;
319
 
 
320
 
dml:
321
 
        # Enable the next line if
322
 
        #    Bug#49628 corrupt table after legal SQL, LONGTEXT column
323
 
        # is fixed.
324
 
        # generate_outfile ; safety_check LOAD DATA concurrent_or_empty INFILE _tmpnam REPLACE INTO TABLE pick_schema pick_safe_table |
325
 
        # We MUST reduce the huge amount of NULL's
326
 
        UPDATE ignore pick_schema pick_safe_table SET _field[invariant] = col_tinyint WHERE col_tinyint BETWEEN _tinyint[invariant] AND _tinyint[invariant] + _digit AND _field[invariant] IS NULL |
327
 
        UPDATE ignore pick_schema pick_safe_table SET _field[invariant] = col_tinyint WHERE col_tinyint BETWEEN _tinyint[invariant] AND _tinyint[invariant] + _digit AND _field[invariant] IS NULL |
328
 
        update |
329
 
        delete |
330
 
        insert |
331
 
        # LOAD DATA INFILE ... is not supported in prepared statement mode.
332
 
        PREPARE st1 FROM " update " ; safety_check EXECUTE st1 ; DEALLOCATE PREPARE st1 |
333
 
        PREPARE st1 FROM " delete " ; safety_check EXECUTE st1 ; DEALLOCATE PREPARE st1 |
334
 
        PREPARE st1 FROM " insert " ; safety_check EXECUTE st1 ; DEALLOCATE PREPARE st1 |
335
 
        # We need the next statement for other statements which should use a user variable.
336
 
        # As long as
337
 
        #    Bug#49562 SBR out of sync when using numeric data types + user variable
338
 
        # is bot fixed we must prevent that a value assigned to @aux does not exceed
339
 
        # the value range of the column where it is applied (INSERT/UPDATE) later.
340
 
        # SET @aux = value  |
341
 
        SET @aux = 13  |
342
 
        # We need the next statements for other statements which should be affected by switching the database.
343
 
        USE `test` | USE `test1` |
344
 
        select_for_update |
345
 
        xid_event         ;
346
 
 
347
 
generate_outfile:
348
 
        SELECT * FROM pick_schema pick_safe_table ORDER BY _field INTO OUTFILE _tmpnam ;
349
 
concurrent_or_empty:
350
 
        | CONCURRENT ;
351
 
 
352
 
pick_schema:
353
 
        |
354
 
        test .  |
355
 
        test1 . ;
356
 
 
357
 
delete:
358
 
        # Delete in one table, search in one table
359
 
        # Unsafe in statement based replication except we add ORDER BY
360
 
        # DELETE       FROM pick_schema _table            LIMIT 1   |
361
 
        DELETE low_priority quick ignore       FROM pick_schema pick_safe_table               where    |
362
 
        # Delete in two tables, search in two tables
363
 
        # Note: Unfortunately next grammar line leads to frequent failing statements (Unknown table A or B)
364
 
        #       The reason is that in case both tables are located in different SCHEMA's than the
365
 
        #       the schema_name must be written before the table alias.
366
 
        #       Example: DELETE test.A, test1.B FROM test.t1 AS A NATURAL JOIN test1.t7 AS B ....
367
 
        #  DELETE low_priority quick ignore A , B FROM pick_schema pick_safe_table AS A join     where    |
368
 
        DELETE low_priority quick ignore A , B FROM pick_safe_table AS A NATURAL JOIN pick_safe_table B where |
369
 
        DELETE low_priority quick ignore test1.A , test.B FROM test1 . pick_safe_table AS A NATURAL JOIN test . pick_safe_table B where ;
370
 
 
371
 
join:
372
 
        # 1. Do not place a where condition here.
373
 
        # 2. join is also use when modifying two tables in one statement.
374
 
        #    Therefore we must use "pick_safe_table" here.
375
 
        NATURAL JOIN pick_schema pick_safe_table B ;
376
 
subquery:
377
 
        correlated | non_correlated ;
378
 
subquery_part1:
379
 
        AND A. _field[invariant] IN ( SELECT _field[invariant] FROM pick_schema pick_safe_table AS B ;
380
 
correlated:
381
 
        subquery_part1 WHERE B.col_tinyint = A.col_tinyint ) ;
382
 
non_correlated:
383
 
        subquery_part1 ) ;
384
 
where:
385
 
        WHERE col_tinyint BETWEEN _tinyint[invariant] AND _tinyint[invariant] + 2 ;
386
 
 
387
 
insert:
388
 
        # Insert into one table, search in no other table
389
 
        INSERT low_priority_delayed_high_priority ignore INTO pick_schema pick_safe_table ( _field , col_tinyint )   VALUES values_list on_duplicate_key_update |
390
 
        # Insert into one table, search in >= 1 tables
391
 
        INSERT low_priority_delayed_high_priority ignore INTO pick_schema pick_safe_table ( _field_list[invariant] ) SELECT _field_list[invariant] FROM table_in_select AS A addition ;
392
 
 
393
 
values_list:
394
 
        ( value , _tinyint ) |
395
 
        ( value , _tinyint ) , ( value , _tinyint ) ;
396
 
 
397
 
on_duplicate_key_update:
398
 
        # Only 10 %
399
 
        | | | | | | | | |
400
 
        ON DUPLICATE KEY UPDATE _field = value ;
401
 
 
402
 
table_in_select:
403
 
        pick_schema pick_safe_table                                        |
404
 
        ( SELECT _field_list[invariant] FROM pick_schema pick_safe_table ) ;
405
 
 
406
 
addition:
407
 
        where | where subquery | join where | where union where ;
408
 
 
409
 
union:
410
 
        UNION SELECT _field_list[invariant] FROM table_in_select AS B ;
411
 
 
412
 
replace:
413
 
        # HIGH_PRIORITY is not allowed
414
 
        REPLACE low_priority_delayed INTO pick_schema pick_safe_table ( _field , col_tinyint )   VALUES values_list on_duplicate_key_update |
415
 
        REPLACE low_priority_delayed INTO pick_schema pick_safe_table ( _field_list[invariant] ) SELECT _field_list[invariant] FROM table_in_select AS A addition ;
416
 
 
417
 
update:
418
 
        # mleich: Search within another table etc. should be already sufficient covered by "delete" and "insert".
419
 
        # Update one table
420
 
        UPDATE ignore pick_schema pick_safe_table SET _field = value where |
421
 
        # Update two tables
422
 
        UPDATE ignore pick_schema pick_safe_table AS A join SET A. _field = value , B. _field = value where ;
423
 
 
424
 
select_for_update:
425
 
        # SELECT does not get replicated, but we want its sideeffects on the transaction.
426
 
        # FIXME (mleich): 1. If _field picks the blob, do we have a bad impact on throughput?
427
 
        #                 2. Has a column list sideeffects on the transaction at all
428
 
        #                    compared to SELECT 1 FROM ....?
429
 
        SELECT col_tinyint, _field FROM pick_safe_table where FOR UPDATE;
430
 
 
431
 
value:
432
 
        value_numeric          |
433
 
        value_rand             |
434
 
        value_string_converted |
435
 
        value_string           |
436
 
        value_temporal         |
437
 
        @aux                   |
438
 
        NULL                   |
439
 
        { if ($format=='STATEMENT') {return '/*'} } value_unsafe_for_sbr { if ($format=='STATEMENT') {return '*/ 17 '} };
440
 
 
441
 
value_unsafe_for_sbr:
442
 
# Functions which are unsafe when bin log format = 'STATEMENT'
443
 
# + we get a warning : "Statement may not be safe to log in statement format"
444
 
        # bigint(21)
445
 
        FOUND_ROWS()      |
446
 
        ROW_COUNT()       |
447
 
        # varchar(36) CHARACTER SET utf8
448
 
        UUID()            |
449
 
        # bigint(21) unsigned
450
 
        UUID_SHORT()      |
451
 
        # varchar(77) CHARACTER SET utf8
452
 
        CURRENT_USER()    |
453
 
        USER()            |
454
 
        VERSION()         |
455
 
        SYSDATE()         |
456
 
        # _data gets replace by LOAD_FILE( <some path> ) which is unsafe for SBR.
457
 
        # mleich: I assume this refers to the risk that an input file
458
 
        #         might exist on the master but probably not on the slave.
459
 
        #         This is irrelevant for the usual RQG test configuration
460
 
        #         where master and slave run on the same box.
461
 
        _data             ;
462
 
 
463
 
value_numeric:
464
 
        # We have 'bit' -> bit(1),'bit(4)','bit(64)','tinyint','smallint','mediumint','int','bigint',
465
 
        # 'float','double',
466
 
        # 'decimal' -> decimal(10,0),'decimal(35)'
467
 
        # mleich: FIXME 1. We do not need all of these values.
468
 
        #               2. But a smart distribution of values is required so that we do not hit all time
469
 
        #                  outside of the allowed value ranges
470
 
        - _digit         | _digit              |
471
 
        _bit(1)          | _bit(4)             |
472
 
        _tinyint         | _tinyint_unsigned   |
473
 
        _smallint        | _smallint_unsigned  |
474
 
        _mediumint       | _mediumint_unsigned |
475
 
        _int             | _int_unsigned       |
476
 
        _bigint          | _bigint_unsigned    |
477
 
        _bigint          | _bigint_unsigned    |
478
 
        -2.0E-1          | +2.0E-1             |
479
 
        -2.0E+1          | +2.0E+1             |
480
 
        -2.0E-10         | +2.0E-10            |
481
 
        -2.0E+10         | +2.0E+10            |
482
 
        -2.0E-100        | +2.0E-100           |
483
 
        -2.0E+100        | +2.0E+100           |
484
 
        # int(10)
485
 
        CONNECTION_ID()  |
486
 
        # Value of the AUTOINCREMENT (per manual only applicable to integer and floating-point types)
487
 
        # column for the last INSERT.
488
 
        LAST_INSERT_ID() ;
489
 
 
490
 
value_rand:
491
 
        # The ( _digit ) makes thread = 1 tests deterministic.
492
 
        RAND( _digit )   ;
493
 
 
494
 
value_string:
495
 
        # We have 'char' -> char(1),'char(10)',
496
 
        # 'varchar' - varchar(1),'varchar(10)','varchar(257)',
497
 
        # 'tinytext','text','mediumtext','longtext',
498
 
        # 'enum', 'set'
499
 
        # mleich: I fear values > 16 MB are risky, so I omit them.
500
 
        _char(1)    | _char(10)    |
501
 
        _varchar(1) | _varchar(10) | _varchar(257)   |
502
 
        _text(255)  | _text(65535) | _text(16777215) |
503
 
        DATABASE()  |
504
 
        _set        ;
505
 
 
506
 
value_string_converted:
507
 
        CONVERT( value_string USING character_set );
508
 
 
509
 
character_set:
510
 
        UTF8 | UCS2 | LATIN1 | BINARY ;
511
 
 
512
 
value_temporal:
513
 
        # We have 'datetime', 'date', 'timestamp', 'time','year'
514
 
        #    _datetime - a date+time value in the ISO format 2000-01-01 00:00:00
515
 
        #    _date - a valid date in the range from 2000 to 2010
516
 
        #    _timestamp - a date+time value in the MySQL format 20000101000000
517
 
        #    _time - a time in the range from 00:00:00 to 29:59:59
518
 
        #    _year - a year in the range 2000 to 2010
519
 
        _datetime | _date | _time | _datetime | _timestamp | _year |
520
 
        NOW()     ;
521
 
 
522
 
any_table:
523
 
        undef_table    |
524
 
        nontrans_table |
525
 
        trans_table    ;
526
 
 
527
 
undef_table:
528
 
        table0_int_autoinc  |
529
 
        table0_int          |
530
 
        table0              |
531
 
        table1_int_autoinc  |
532
 
        table1_int          |
533
 
        table1              |
534
 
        table10_int_autoinc |
535
 
        table10_int         |
536
 
        table10             ;
537
 
 
538
 
nontrans_table:
539
 
        table0_myisam_int_autoinc  |
540
 
        table0_myisam_int          |
541
 
        table0_myisam              |
542
 
        table1_myisam_int_autoinc  |
543
 
        table1_myisam_int          |
544
 
        table1_myisam              |
545
 
        table10_myisam_int_autoinc |
546
 
        table10_myisam_int         |
547
 
        table10_myisam             ;
548
 
 
549
 
trans_table:
550
 
        table0_innodb_int_autoinc  |
551
 
        table0_innodb_int          |
552
 
        table0_innodb              |
553
 
        table1_innodb_int_autoinc  |
554
 
        table1_innodb_int          |
555
 
        table1_innodb              |
556
 
        table10_innodb_int_autoinc |
557
 
        table10_innodb_int         |
558
 
        table10_innodb             ;
559
 
 
560
 
pick_safe_table:
561
 
        # pick_mode | table type to choose | setting
562
 
        # 0         | any                                  any_table    /*          undef_table                nontrans_table                trans_table    */
563
 
        # 1         | undef                    /*          any_table    */          undef_table    /*          nontrans_table                trans_table    */
564
 
        # 2         | nontrans                 /*          any_table                undef_table    */          nontrans_table    /*          trans_table    */
565
 
        # 3         | trans                    /*          any_table                undef_table                nontrans_table    */          trans_table
566
 
        # 4         | nontrans                 /*          any_table                undef_table    */          nontrans_table    /*          trans_table    */
567
 
        tmarker_init tmarker_set            { return $m0 } any_table { return $m1 } undef_table { return $m2 } nontrans_table { return $m3 } trans_table { return $m4 } ;
568
 
 
569
 
tmarker_init:
570
 
        { $m0 = ''; $m1 = ''; $m2 = ''; $m3 = ''; $m4 = ''; return undef } ;
571
 
 
572
 
tmarker_set:
573
 
        { if ($pick_mode==0) {$m1='/*';$m4='*/'} elsif ($pick_mode==1) {$m0='/*';$m1='*/';$m2='/*';$m4='*/'} elsif ($pick_mode==2) {$m0='/*';$m2='*/';$m3='/*';$m4='*/'} elsif ($pick_mode==3) {$m0='/*';$m3='*/'} elsif ($pick_mode==4) {$m0='/*';$m2='*/';$m3='/*';$m4='*/'} ; return undef };
574
 
 
575
 
 
576
 
#### Basic constructs which are used at various places
577
 
 
578
 
delayed:
579
 
        # "DELAYED" is declared to be unsafe whenever the GLOBAL binlog_format is 'statement'.
580
 
        # --> Either
581
 
        #     - set GLOBAL binlog_format during query_init, don't switch it later and adjust usage of delayed ?
582
 
        #     or
583
 
        #     - do not use DELAYED (my choice, mleich)
584
 
        # DELAYED       |
585
 
        ;
586
 
 
587
 
high_priority:
588
 
        |
589
 
        HIGH_PRIORITY ;
590
 
 
591
 
ignore:
592
 
        # Only 10 %
593
 
        | | | | | | | | |
594
 
        # mleich temporary disabled IGNORE ;
595
 
        ;
596
 
 
597
 
low_priority:
598
 
        | | |
599
 
        LOW_PRIORITY ;
600
 
 
601
 
low_priority_delayed_high_priority:
602
 
# All MyISAM only features.
603
 
        | |
604
 
        low_priority  |
605
 
        delayed       |
606
 
        high_priority ;
607
 
 
608
 
low_priority_delayed:
609
 
        | |
610
 
        low_priority |
611
 
        delayed      ;
612
 
 
613
 
plus_minus:
614
 
        + | - ;
615
 
 
616
 
quick:
617
 
        # Only 10 %
618
 
        | | | | | | | | |
619
 
        QUICK ;