summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-05-07 23:51:18 +0400
committerAlexander Barkov <bar@mariadb.org>2017-05-07 23:51:18 +0400
commit314350a722e65081472113c53657ad239f3bef72 (patch)
tree8b72cd2bf6f2b352b379dbfcbb1a99a48c422335
parent39e31671935bc019f556e945571f37d2d1f3a77f (diff)
parentc619fbeafe8d5019e37fcb7ba5e1a6ce2d431270 (diff)
downloadmariadb-git-314350a722e65081472113c53657ad239f3bef72.tar.gz
Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3
-rw-r--r--client/mysqldump.c14
-rw-r--r--cmake/cpu_info.cmake27
-rw-r--r--cmake/libutils.cmake2
-rw-r--r--cmake/wsrep.cmake2
-rw-r--r--debian/mariadb-server-10.3.install1
-rw-r--r--extra/innochecksum.cc5
-rw-r--r--man/CMakeLists.txt4
-rw-r--r--man/my_safe_process.116
-rw-r--r--man/tokuft_logdump.116
-rw-r--r--mysql-test/include/assert_grep.inc154
-rw-r--r--mysql-test/include/diff_servers.inc67
-rw-r--r--mysql-test/include/galera_wait_ready.inc2
-rw-r--r--mysql-test/include/have_innodb_max_16k.inc4
-rw-r--r--mysql-test/include/mysqlhotcopy.inc2
-rw-r--r--mysql-test/r/create_drop_binlog.result2
-rw-r--r--mysql-test/r/create_drop_view.result2
-rw-r--r--mysql-test/r/cte_nonrecursive.result18
-rw-r--r--mysql-test/r/cte_recursive.result116
-rw-r--r--mysql-test/r/derived_cond_pushdown.result125
-rw-r--r--mysql-test/r/drop.result8
-rw-r--r--mysql-test/r/explain_json.result6
-rw-r--r--mysql-test/r/func_debug.result80
-rw-r--r--mysql-test/r/func_json.result13
-rw-r--r--mysql-test/r/gis-rt-precise.result2
-rw-r--r--mysql-test/r/gis-rtree.result2
-rw-r--r--mysql-test/r/grant.result2
-rw-r--r--mysql-test/r/keyread.result6
-rw-r--r--mysql-test/r/loadxml.result11
-rw-r--r--mysql-test/r/mysqldump.result49
-rw-r--r--mysql-test/r/profiling.result2
-rw-r--r--mysql-test/r/range.result18
-rw-r--r--mysql-test/r/range_mrr_icp.result18
-rw-r--r--mysql-test/r/sp-group.result2
-rw-r--r--mysql-test/r/sp.result2
-rw-r--r--mysql-test/r/subselect.result14
-rw-r--r--mysql-test/r/subselect_no_exists_to_in.result14
-rw-r--r--mysql-test/r/subselect_no_mat.result14
-rw-r--r--mysql-test/r/subselect_no_opts.result14
-rw-r--r--mysql-test/r/subselect_no_scache.result14
-rw-r--r--mysql-test/r/subselect_no_semijoin.result14
-rw-r--r--mysql-test/r/type_date.result35
-rw-r--r--mysql-test/r/view.result2
-rw-r--r--mysql-test/r/win.result30
-rw-r--r--mysql-test/std_data/loaddata/mdev12696.xml9
-rw-r--r--mysql-test/suite/binlog/r/flashback.result5
-rw-r--r--mysql-test/suite/binlog/t/flashback.test4
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_views.result6
-rw-r--r--mysql-test/suite/funcs_1/r/memory_views.result6
-rw-r--r--mysql-test/suite/galera/disabled.def22
-rw-r--r--mysql-test/suite/galera/galera_2nodes.cnf9
-rw-r--r--mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf83
-rw-r--r--mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf87
-rw-r--r--mysql-test/suite/galera/r/GAL-401.result24
-rw-r--r--mysql-test/suite/galera/r/GAL-419.result4
-rw-r--r--mysql-test/suite/galera/r/GAL-480.result39
-rw-r--r--mysql-test/suite/galera/r/MW-313.result32
-rw-r--r--mysql-test/suite/galera/r/MW-328A.result27
-rw-r--r--mysql-test/suite/galera/r/MW-328B.result23
-rw-r--r--mysql-test/suite/galera/r/MW-328C.result23
-rw-r--r--mysql-test/suite/galera/r/MW-328D.result20
-rw-r--r--mysql-test/suite/galera/r/MW-328E.result20
-rw-r--r--mysql-test/suite/galera/r/MW-329.result20
-rw-r--r--mysql-test/suite/galera/r/ev51914.result173
-rw-r--r--mysql-test/suite/galera/r/galera_account_management.result9
-rw-r--r--mysql-test/suite/galera/r/galera_admin.result56
-rw-r--r--mysql-test/suite/galera/r/galera_bf_abort.result8
-rw-r--r--mysql-test/suite/galera/r/galera_defaults.result2
-rw-r--r--mysql-test/suite/galera/r/galera_desync_overlapped.result50
-rw-r--r--mysql-test/suite/galera/r/galera_gcache_recover.result18
-rw-r--r--mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result19
-rw-r--r--mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result107
-rw-r--r--mysql-test/suite/galera/r/galera_many_tables_pk.result11
-rw-r--r--mysql-test/suite/galera/r/galera_restart_on_unknown_option.result40
-rw-r--r--mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result23
-rw-r--r--mysql-test/suite/galera/r/galera_toi_drop_database.result32
-rw-r--r--mysql-test/suite/galera/r/galera_toi_truncate.result22
-rw-r--r--mysql-test/suite/galera/r/galera_var_cluster_address.result1
-rw-r--r--mysql-test/suite/galera/r/galera_var_retry_autocommit.result32
-rw-r--r--mysql-test/suite/galera/r/galera_var_slave_threads.result1
-rw-r--r--mysql-test/suite/galera/r/galera_wsrep_log_conficts.result25
-rw-r--r--mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result5
-rw-r--r--mysql-test/suite/galera/r/lp1376747-2.result23
-rw-r--r--mysql-test/suite/galera/r/lp1376747-3.result27
-rw-r--r--mysql-test/suite/galera/r/lp1376747-4.result47
-rw-r--r--mysql-test/suite/galera/r/lp1376747.result23
-rw-r--r--mysql-test/suite/galera/r/pxc-421.result42
-rw-r--r--mysql-test/suite/galera/t/GAL-401.test51
-rw-r--r--mysql-test/suite/galera/t/GAL-419.test35
-rw-r--r--mysql-test/suite/galera/t/GAL-480.test46
-rw-r--r--mysql-test/suite/galera/t/MW-258.test2
-rw-r--r--mysql-test/suite/galera/t/MW-313-master.opt1
-rw-r--r--mysql-test/suite/galera/t/MW-313.test51
-rw-r--r--mysql-test/suite/galera/t/MW-328-footer.inc18
-rw-r--r--mysql-test/suite/galera/t/MW-328-header.inc29
-rw-r--r--mysql-test/suite/galera/t/MW-328A.test56
-rw-r--r--mysql-test/suite/galera/t/MW-328B.test36
-rw-r--r--mysql-test/suite/galera/t/MW-328C.test36
-rw-r--r--mysql-test/suite/galera/t/MW-328D.test40
-rw-r--r--mysql-test/suite/galera/t/MW-328E.test41
-rw-r--r--mysql-test/suite/galera/t/MW-329-master.opt1
-rw-r--r--mysql-test/suite/galera/t/MW-329.test82
-rw-r--r--mysql-test/suite/galera/t/ev51914.test214
-rw-r--r--mysql-test/suite/galera/t/galera#414.test4
-rw-r--r--mysql-test/suite/galera/t/galera_account_management.test14
-rw-r--r--mysql-test/suite/galera/t/galera_admin.test86
-rw-r--r--mysql-test/suite/galera/t/galera_bf_abort.test13
-rw-r--r--mysql-test/suite/galera/t/galera_desync_overlapped.test59
-rw-r--r--mysql-test/suite/galera/t/galera_flush_local.opt2
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover.cnf7
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover.test77
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf9
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test59
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf9
-rw-r--r--mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test216
-rw-r--r--mysql-test/suite/galera/t/galera_many_tables_pk.test25
-rw-r--r--mysql-test/suite/galera/t/galera_restart_on_unknown_option.test150
-rw-r--r--mysql-test/suite/galera/t/galera_roles.test1
-rw-r--r--mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test49
-rw-r--r--mysql-test/suite/galera/t/galera_toi_drop_database.test56
-rw-r--r--mysql-test/suite/galera/t/galera_toi_truncate.test43
-rw-r--r--mysql-test/suite/galera/t/galera_var_cluster_address.test2
-rw-r--r--mysql-test/suite/galera/t/galera_var_retry_autocommit.test98
-rw-r--r--mysql-test/suite/galera/t/galera_var_slave_threads.test2
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt1
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_log_conficts.test55
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test20
-rw-r--r--mysql-test/suite/galera/t/lp1376747-2.test22
-rw-r--r--mysql-test/suite/galera/t/lp1376747-3.test28
-rw-r--r--mysql-test/suite/galera/t/lp1376747-4.test53
-rw-r--r--mysql-test/suite/galera/t/lp1376747.test24
-rw-r--r--mysql-test/suite/galera/t/pxc-421.test60
-rw-r--r--mysql-test/suite/galera_3nodes/galera_3nodes.cnf8
-rw-r--r--mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result26
-rw-r--r--mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test163
-rw-r--r--mysql-test/suite/gcol/r/innodb_virtual_debug.result30
-rw-r--r--mysql-test/suite/gcol/r/innodb_virtual_fk.result98
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_debug.test30
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_fk.test86
-rw-r--r--mysql-test/suite/innodb/include/innodb_isolation_selects.inc15
-rw-r--r--mysql-test/suite/innodb/r/autoinc_debug.result100
-rw-r--r--mysql-test/suite/innodb/r/deadlock_detect.result30
-rw-r--r--mysql-test/suite/innodb/r/foreign_key.result152
-rw-r--r--mysql-test/suite/innodb/r/ibuf_not_empty.result25
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-online-norebuild.result26
-rw-r--r--mysql-test/suite/innodb/r/innodb-isolation.result1411
-rw-r--r--mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff-disabled56
-rw-r--r--mysql-test/suite/innodb/r/innodb_force_recovery.result90
-rw-r--r--mysql-test/suite/innodb/r/innodb_gis.result9
-rw-r--r--mysql-test/suite/innodb/r/innodb_stats_del_mark.result91
-rw-r--r--mysql-test/suite/innodb/r/insert_debug.result20
-rw-r--r--mysql-test/suite/innodb/r/readahead.result6
-rw-r--r--mysql-test/suite/innodb/r/redo_log_during_checkpoint.result25
-rw-r--r--mysql-test/suite/innodb/r/truncate_debug.result86
-rw-r--r--mysql-test/suite/innodb/r/truncate_purge_debug.result29
-rw-r--r--mysql-test/suite/innodb/t/autoinc_debug.test85
-rw-r--r--mysql-test/suite/innodb/t/deadlock_detect.test55
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test115
-rw-r--r--mysql-test/suite/innodb/t/ibuf_not_empty.test54
-rw-r--r--mysql-test/suite/innodb/t/innodb-index-online-norebuild.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb-index-online-norebuild.test71
-rw-r--r--mysql-test/suite/innodb/t/innodb-isolation.test354
-rw-r--r--mysql-test/suite/innodb/t/innodb_force_recovery.test139
-rw-r--r--mysql-test/suite/innodb/t/innodb_gis.test9
-rw-r--r--mysql-test/suite/innodb/t/innodb_stats_del_mark-master.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb_stats_del_mark.test113
-rw-r--r--mysql-test/suite/innodb/t/insert_debug.test32
-rw-r--r--mysql-test/suite/innodb/t/readahead.test22
-rw-r--r--mysql-test/suite/innodb/t/redo_log_during_checkpoint.test75
-rw-r--r--mysql-test/suite/innodb/t/truncate_debug.test122
-rw-r--r--mysql-test/suite/innodb/t/truncate_purge_debug.opt3
-rw-r--r--mysql-test/suite/innodb/t/truncate_purge_debug.test66
-rw-r--r--mysql-test/suite/innodb_gis/r/0.result2
-rw-r--r--mysql-test/suite/innodb_gis/r/alter_spatial_index.result2
-rw-r--r--mysql-test/suite/innodb_gis/r/create_spatial_index.result5
-rw-r--r--mysql-test/suite/innodb_gis/r/rt_precise.result3
-rw-r--r--mysql-test/suite/innodb_gis/r/rtree.result647
-rw-r--r--mysql-test/suite/innodb_gis/t/rtree.test623
-rw-r--r--mysql-test/suite/innodb_undo/include/have_undo_tablespaces.inc4
-rw-r--r--mysql-test/suite/innodb_undo/include/truncate_recover.inc8
-rw-r--r--mysql-test/suite/innodb_undo/r/truncate.result11
-rw-r--r--mysql-test/suite/innodb_undo/r/truncate_multi_client.result51
-rw-r--r--mysql-test/suite/innodb_undo/r/truncate_recover.result15
-rw-r--r--mysql-test/suite/innodb_undo/t/truncate.test72
-rw-r--r--mysql-test/suite/innodb_undo/t/truncate_multi_client.test77
-rw-r--r--mysql-test/suite/innodb_undo/t/truncate_recover.test50
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-dynamic.result4
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-trans.result4
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_create_drop_view.result2
-rw-r--r--mysql-test/suite/sql_sequence/create.result14
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_deadlock_detect_basic.result56
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_max_undo_log_size_basic.result12
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff4
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb.result40
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_wsrep.result2
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_deadlock_detect_basic.test53
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_max_undo_log_size_basic.test8
-rw-r--r--mysql-test/suite/wsrep/r/binlog_format.result2
-rw-r--r--mysql-test/suite/wsrep/r/wsrep_rpl.result4
-rw-r--r--mysql-test/suite/wsrep/t/binlog_format.test2
-rw-r--r--mysql-test/suite/wsrep/t/wsrep_rpl.test10
-rw-r--r--mysql-test/t/cte_nonrecursive.test19
-rw-r--r--mysql-test/t/cte_recursive.test94
-rw-r--r--mysql-test/t/derived_cond_pushdown.test99
-rw-r--r--mysql-test/t/func_json.test22
-rw-r--r--mysql-test/t/keyread.test10
-rw-r--r--mysql-test/t/loadxml.test13
-rw-r--r--mysql-test/t/mysqldump.test12
-rw-r--r--mysql-test/t/subselect.test17
-rw-r--r--mysql-test/t/type_date.test25
-rw-r--r--mysql-test/t/win.test21
-rw-r--r--plugin/user_variables/CMakeLists.txt3
-rw-r--r--plugin/user_variables/mysql-test/user_variables/basic.result2
-rw-r--r--plugin/user_variables/mysql-test/user_variables/suite.pm3
-rw-r--r--plugin/user_variables/user_variables.cc2
-rw-r--r--scripts/CMakeLists.txt1
-rwxr-xr-x[-rw-r--r--]scripts/wsrep_sst_common0
-rw-r--r--sql/field.cc45
-rw-r--r--sql/field.h22
-rw-r--r--sql/handler.h5
-rw-r--r--sql/item.cc170
-rw-r--r--sql/item.h225
-rw-r--r--sql/item_cmpfunc.cc63
-rw-r--r--sql/item_cmpfunc.h29
-rw-r--r--sql/item_func.cc76
-rw-r--r--sql/item_func.h56
-rw-r--r--sql/item_geofunc.cc4
-rw-r--r--sql/item_geofunc.h4
-rw-r--r--sql/item_jsonfunc.cc14
-rw-r--r--sql/item_row.h9
-rw-r--r--sql/item_strfunc.h3
-rw-r--r--sql/item_subselect.cc36
-rw-r--r--sql/item_subselect.h20
-rw-r--r--sql/item_sum.cc34
-rw-r--r--sql/item_sum.h52
-rw-r--r--sql/item_timefunc.h31
-rw-r--r--sql/item_windowfunc.cc8
-rw-r--r--sql/item_windowfunc.h27
-rw-r--r--sql/log_event.cc5
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/opt_range.cc68
-rw-r--r--sql/opt_range.h11
-rw-r--r--sql/opt_sum.cc2
-rw-r--r--sql/procedure.h14
-rw-r--r--sql/rpl_parallel.cc3
-rw-r--r--sql/share/errmsg-utf8.txt2
-rw-r--r--sql/slave.cc3
-rw-r--r--sql/sql_cte.cc71
-rw-r--r--sql/sql_cte.h20
-rw-r--r--sql/sql_derived.cc20
-rw-r--r--sql/sql_derived.h4
-rw-r--r--sql/sql_load.cc61
-rw-r--r--sql/sql_select.cc86
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_type.cc151
-rw-r--r--sql/sql_type.h109
-rw-r--r--sql/sql_union.cc5
-rw-r--r--sql/sql_window.cc7
-rw-r--r--sql/sys_vars.cc15
-rw-r--r--sql/table.cc1
-rw-r--r--sql/table.h2
-rw-r--r--sql/wsrep_hton.cc2
-rw-r--r--sql/wsrep_mysqld.h1
-rw-r--r--sql/wsrep_thd.cc33
-rw-r--r--storage/innobase/btr/btr0cur.cc2
-rw-r--r--storage/innobase/btr/btr0sea.cc37
-rw-r--r--storage/innobase/buf/buf0buf.cc286
-rw-r--r--storage/innobase/buf/buf0dblwr.cc16
-rw-r--r--storage/innobase/buf/buf0dump.cc6
-rw-r--r--storage/innobase/buf/buf0flu.cc10
-rw-r--r--storage/innobase/buf/buf0lru.cc57
-rw-r--r--storage/innobase/buf/buf0rea.cc21
-rw-r--r--storage/innobase/dict/dict0boot.cc6
-rw-r--r--storage/innobase/dict/dict0mem.cc7
-rw-r--r--storage/innobase/dict/dict0stats.cc16
-rw-r--r--storage/innobase/dict/dict0stats_bg.cc10
-rw-r--r--storage/innobase/fil/fil0crypt.cc29
-rw-r--r--storage/innobase/fil/fil0fil.cc146
-rw-r--r--storage/innobase/fil/fil0pagecompress.cc9
-rw-r--r--storage/innobase/fts/fts0fts.cc31
-rw-r--r--storage/innobase/fts/fts0opt.cc7
-rw-r--r--storage/innobase/ha/ha0ha.cc29
-rw-r--r--storage/innobase/handler/ha_innodb.cc334
-rw-r--r--storage/innobase/handler/ha_innodb.h5
-rw-r--r--storage/innobase/handler/ha_innopart.cc37
-rw-r--r--storage/innobase/handler/ha_innopart.h4
-rw-r--r--storage/innobase/handler/handler0alter.cc131
-rw-r--r--storage/innobase/handler/i_s.cc6
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc4
-rw-r--r--storage/innobase/include/btr0sea.h2
-rw-r--r--storage/innobase/include/buf0buf.h112
-rw-r--r--storage/innobase/include/buf0buf.ic1
-rw-r--r--storage/innobase/include/buf0dblwr.h15
-rw-r--r--storage/innobase/include/dict0dict.ic11
-rw-r--r--storage/innobase/include/fil0crypt.h8
-rw-r--r--storage/innobase/include/fil0fil.h106
-rw-r--r--storage/innobase/include/fts0fts.h10
-rw-r--r--storage/innobase/include/ha_prototypes.h1
-rw-r--r--storage/innobase/include/lock0lock.h5
-rw-r--r--storage/innobase/include/log0log.h8
-rw-r--r--storage/innobase/include/mtr0mtr.h10
-rw-r--r--storage/innobase/include/os0thread.h14
-rw-r--r--storage/innobase/include/page0zip.h14
-rw-r--r--storage/innobase/include/row0mysql.h5
-rw-r--r--storage/innobase/include/srv0srv.h35
-rw-r--r--storage/innobase/include/srv0start.h2
-rw-r--r--storage/innobase/include/sync0types.h26
-rw-r--r--storage/innobase/include/trx0rseg.h5
-rw-r--r--storage/innobase/include/trx0rseg.ic8
-rw-r--r--storage/innobase/include/trx0sys.h6
-rw-r--r--storage/innobase/include/trx0trx.h60
-rw-r--r--storage/innobase/include/univ.i6
-rw-r--r--storage/innobase/lock/lock0lock.cc85
-rw-r--r--storage/innobase/log/log0log.cc14
-rw-r--r--storage/innobase/log/log0recv.cc36
-rw-r--r--storage/innobase/mach/mach0data.cc65
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc27
-rw-r--r--storage/innobase/os/os0file.cc3
-rw-r--r--storage/innobase/os/os0thread.cc31
-rw-r--r--storage/innobase/page/page0zip.cc30
-rw-r--r--storage/innobase/rem/rem0rec.cc8
-rw-r--r--storage/innobase/row/row0ftsort.cc9
-rw-r--r--storage/innobase/row/row0ins.cc30
-rw-r--r--storage/innobase/row/row0log.cc45
-rw-r--r--storage/innobase/row/row0merge.cc99
-rw-r--r--storage/innobase/row/row0mysql.cc47
-rw-r--r--storage/innobase/row/row0purge.cc20
-rw-r--r--storage/innobase/row/row0trunc.cc21
-rw-r--r--storage/innobase/row/row0uins.cc20
-rw-r--r--storage/innobase/row/row0umod.cc35
-rw-r--r--storage/innobase/srv/srv0srv.cc378
-rw-r--r--storage/innobase/srv/srv0start.cc31
-rw-r--r--storage/innobase/sync/sync0arr.cc40
-rw-r--r--storage/innobase/sync/sync0debug.cc260
-rw-r--r--storage/innobase/trx/trx0purge.cc58
-rw-r--r--storage/innobase/trx/trx0roll.cc5
-rw-r--r--storage/innobase/trx/trx0rseg.cc2
-rw-r--r--storage/innobase/trx/trx0sys.cc31
-rw-r--r--storage/innobase/trx/trx0trx.cc116
-rw-r--r--storage/rocksdb/CMakeLists.txt7
-rw-r--r--storage/spider/ha_spider.cc80
-rw-r--r--storage/spider/ha_spider.h2
-rw-r--r--storage/spider/spd_db_handlersocket.cc9
-rw-r--r--storage/spider/spd_db_handlersocket.h3
-rw-r--r--storage/spider/spd_db_include.h3
-rw-r--r--storage/spider/spd_db_mysql.cc59
-rw-r--r--storage/spider/spd_db_mysql.h3
-rw-r--r--storage/spider/spd_db_oracle.cc59
-rw-r--r--storage/spider/spd_db_oracle.h3
-rw-r--r--storage/xtradb/btr/btr0btr.cc2
-rw-r--r--storage/xtradb/btr/btr0defragment.cc2
-rw-r--r--storage/xtradb/buf/buf0buf.cc141
-rw-r--r--storage/xtradb/buf/buf0dblwr.cc8
-rw-r--r--storage/xtradb/buf/buf0flu.cc16
-rw-r--r--storage/xtradb/buf/buf0rea.cc14
-rw-r--r--storage/xtradb/dict/dict0stats.cc4
-rw-r--r--storage/xtradb/fil/fil0crypt.cc61
-rw-r--r--storage/xtradb/fil/fil0fil.cc80
-rw-r--r--storage/xtradb/fil/fil0pagecompress.cc124
-rw-r--r--storage/xtradb/include/buf0buf.h18
-rw-r--r--storage/xtradb/include/dict0dict.ic101
-rw-r--r--storage/xtradb/include/fil0crypt.h6
-rw-r--r--storage/xtradb/include/fil0fil.h37
-rw-r--r--storage/xtradb/include/fil0fil.ic60
-rw-r--r--storage/xtradb/include/fil0pagecompress.h30
-rw-r--r--storage/xtradb/include/fsp0pagecompress.ic63
-rw-r--r--storage/xtradb/include/os0file.h12
-rw-r--r--storage/xtradb/include/os0sync.h5
-rw-r--r--storage/xtradb/include/srv0mon.h63
-rw-r--r--storage/xtradb/include/trx0trx.h17
-rw-r--r--storage/xtradb/include/univ.i28
-rw-r--r--storage/xtradb/lock/lock0lock.cc8
-rw-r--r--storage/xtradb/log/log0recv.cc6
-rw-r--r--storage/xtradb/os/os0file.cc184
-rw-r--r--storage/xtradb/row/row0ftsort.cc7
-rw-r--r--storage/xtradb/row/row0import.cc130
-rw-r--r--storage/xtradb/row/row0merge.cc155
-rw-r--r--storage/xtradb/srv/srv0mon.cc6
-rw-r--r--storage/xtradb/srv/srv0srv.cc4
-rw-r--r--storage/xtradb/sync/sync0arr.cc48
-rw-r--r--storage/xtradb/trx/trx0trx.cc112
-rw-r--r--strings/json_lib.c1
382 files changed, 13694 insertions, 3244 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 281a7a6c7f2..99fcbdb4250 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -114,7 +114,8 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m
opt_slave_apply= 0,
opt_include_master_host_port= 0,
opt_events= 0, opt_comments_used= 0,
- opt_alltspcs=0, opt_notspcs= 0, opt_logging;
+ opt_alltspcs=0, opt_notspcs= 0, opt_logging,
+ opt_drop_trigger= 0 ;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*mysql=0;
@@ -233,6 +234,9 @@ static struct my_option my_long_options[] =
{"add-drop-table", OPT_DROP, "Add a DROP TABLE before each create.",
&opt_drop, &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
+ {"add-drop-trigger", 0, "Add a DROP TRIGGER before each create.",
+ &opt_drop_trigger, &opt_drop_trigger, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+ 0},
{"add-locks", OPT_LOCKS, "Add locks around INSERT statements.",
&opt_lock, &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
@@ -3281,6 +3285,10 @@ static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
if (opt_compact)
fprintf(sql_file, "/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
+ if (opt_drop_trigger)
+ fprintf(sql_file, "/*!50032 DROP TRIGGER IF EXISTS %s */;\n",
+ (*show_trigger_row)[0]);
+
fprintf(sql_file,
"DELIMITER ;;\n"
"/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
@@ -3361,6 +3369,10 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
switch_sql_mode(sql_file, ";", row[1]);
+ if (opt_drop_trigger)
+ fprintf(sql_file, "/*!50032 DROP TRIGGER IF EXISTS %s */;\n",
+ row[0]);
+
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50017"),
C_STRING_WITH_LEN("50003"),
diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake
index 7c2c08a07db..c53759d24d6 100644
--- a/cmake/cpu_info.cmake
+++ b/cmake/cpu_info.cmake
@@ -15,12 +15,25 @@
# Symbols with information about the CPU.
-FIND_PROGRAM(GETCONF getconf)
-MARK_AS_ADVANCED(GETCONF)
+IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ FIND_PROGRAM(SYSCTL sysctl)
+ MARK_AS_ADVANCED(SYSCTL)
-IF(GETCONF)
- EXECUTE_PROCESS(
- COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE
- OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE
- )
+ IF(SYSCTL)
+ EXECUTE_PROCESS(
+ COMMAND ${SYSCTL} -n hw.cachelinesize
+ OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE
+ )
+ ENDIF()
+
+ELSE()
+ FIND_PROGRAM(GETCONF getconf)
+ MARK_AS_ADVANCED(GETCONF)
+
+ IF(GETCONF)
+ EXECUTE_PROCESS(
+ COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE
+ OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE
+ )
+ ENDIF()
ENDIF()
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
index 0965ec8cb83..67b14b72828 100644
--- a/cmake/libutils.cmake
+++ b/cmake/libutils.cmake
@@ -188,7 +188,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
# binaries properly)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND rm ${TARGET_LOCATION}
- COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}
+ COMMAND libtool -static -o ${TARGET_LOCATION}
${STATIC_LIBS}
)
ELSE()
diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake
index 067a9f128a2..0a1c7dd9697 100644
--- a/cmake/wsrep.cmake
+++ b/cmake/wsrep.cmake
@@ -26,7 +26,7 @@ ENDIF()
OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default})
# Set the patch version
-SET(WSREP_PATCH_VERSION "16")
+SET(WSREP_PATCH_VERSION "19")
# Obtain wsrep API version
FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION
diff --git a/debian/mariadb-server-10.3.install b/debian/mariadb-server-10.3.install
index 1469e8ed7c8..1a851ca4671 100644
--- a/debian/mariadb-server-10.3.install
+++ b/debian/mariadb-server-10.3.install
@@ -56,7 +56,6 @@ usr/lib/mysql/plugin/semisync_slave.so
usr/lib/mysql/plugin/server_audit.so
usr/lib/mysql/plugin/simple_password_check.so
usr/lib/mysql/plugin/sql_errlog.so
-usr/lib/mysql/plugin/user_variables.so
usr/lib/mysql/plugin/wsrep_info.so
usr/share/apport/package-hooks/source_mariadb-10.3.py
usr/share/doc/mariadb-server-10.3/mysqld.sym.gz
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index fa50ca72867..238a5a80ac5 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -571,7 +571,6 @@ is_page_corrupted(
if (mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0) {
is_corrupted = fil_space_verify_crypt_checksum(
const_cast<byte*>(buf), page_size,
- strict_verify, is_log_enabled ? log_file : NULL,
mach_read_from_4(buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
cur_page_num);
@@ -581,9 +580,7 @@ is_page_corrupted(
if (is_corrupted) {
is_corrupted = buf_page_is_corrupted(
- true, buf, page_size, NULL,
- cur_page_num, strict_verify,
- is_log_enabled, log_file);
+ true, buf, page_size, NULL);
}
return(is_corrupted);
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index f24c5c95d69..f5899577a47 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -26,7 +26,7 @@ SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1
mysqld_safe_helper.1 tokuftdump.1 wsrep_sst_common.1
wsrep_sst_mysqldump.1 wsrep_sst_rsync.1
wsrep_sst_xtrabackup-v2.1 wsrep_sst_xtrabackup.1
- galera_recovery.1 galera_new_cluster.1)
+ galera_recovery.1 galera_new_cluster.1 tokuft_logdump.1)
SET(MAN8_SERVER mysqld.8)
SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1
mysqlaccess.1 mysqladmin.1 mysqlbinlog.1 mysqlcheck.1
@@ -34,7 +34,7 @@ SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1
mysql_plugin.1)
SET(MAN1_DEVEL mysql_config.1)
SET(MAN1_TEST mysql-stress-test.pl.1 mysql-test-run.pl.1 mysql_client_test.1
- mysqltest_embedded.1 mysql_client_test_embedded.1)
+ mysqltest_embedded.1 mysql_client_test_embedded.1 my_safe_process.1)
INSTALL(FILES ${MAN1_SERVER} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesServer)
INSTALL(FILES ${MAN8_SERVER} DESTINATION ${INSTALL_MANDIR}/man8 COMPONENT ManPagesServer)
diff --git a/man/my_safe_process.1 b/man/my_safe_process.1
new file mode 100644
index 00000000000..fac8ed69fc8
--- /dev/null
+++ b/man/my_safe_process.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBMY_SAFE_PROCESS\FR" "1" "29 March 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+my_safe_process \- Utility program that encapsulates process creation, monitoring and bulletproof process cleanup
+.SH DESCRIPTION
+Use: safe_process [options to safe_process] -- progname arg1 \.\.\. argn\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/tokuft_logdump.1 b/man/tokuft_logdump.1
new file mode 100644
index 00000000000..f6cf08080f7
--- /dev/null
+++ b/man/tokuft_logdump.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBTOKUFT_LOGPRINT\FR" "1" "27 March 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+tokuft_logprint \- Dump the log from stdin to stdout
+.SH DESCRIPTION
+Use: Dump the log from stdin to stdout\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/mysql-test/include/assert_grep.inc b/mysql-test/include/assert_grep.inc
new file mode 100644
index 00000000000..a980a6d73b1
--- /dev/null
+++ b/mysql-test/include/assert_grep.inc
@@ -0,0 +1,154 @@
+# ==== Purpose ====
+#
+# Grep a file for a pattern, produce a single string out of the
+# matching lines, and assert that the string matches a given regular
+# expression.
+#
+# ==== Usage ====
+#
+# --let $assert_text= TEXT
+# --let $assert_file= FILE
+# --let $assert_select= REGEX
+# [--let $assert_match= REGEX | --let $assert_count= NUMBER]
+# [--let $assert_only_after= REGEX]
+# --source include/assert_grep.inc
+#
+# Parameters:
+#
+# $assert_text
+# Text that describes what is being checked. This text is written to
+# the query log so it should not contain non-deterministic elements.
+#
+# $assert_file
+# File to search.
+#
+# $assert_select
+# All lines matching this text will be checked.
+#
+# $assert_match
+# The script will find all lines that match $assert_select,
+# concatenate them to a long string, and assert that it matches
+# $assert_match.
+#
+# $assert_count
+# Instead of asserting that the selected lines match
+# $assert_match, assert that there were exactly $assert_count
+# matching lines.
+#
+# $assert_only_after
+# Reset all the lines matched and the counter when finding this pattern.
+# It is useful for searching things in the mysqld.err log file just
+# after the last server restart for example (discarding the log content
+# of previous server executions).
+
+
+if (!$assert_text)
+{
+ --die !!!ERROR IN TEST: you must set $assert_text
+}
+if (!$assert_file)
+{
+ --die !!!ERROR IN TEST: you must set $assert_file
+}
+if (!$assert_select)
+{
+ --die !!!ERROR IN TEST: you must set $assert_select
+}
+if ($assert_match == '')
+{
+ if ($assert_count == '')
+ {
+ --die !!!ERROR IN TEST: you must set either $assert_match or $assert_count
+ }
+}
+if ($assert_match != '')
+{
+ if ($assert_count != '')
+ {
+ --echo assert_text='$assert_text' assert_count='$assert_count'
+ --die !!!ERROR IN TEST: you must set only one of $assert_match or $assert_count
+ }
+}
+
+
+--let $include_filename= assert_grep.inc [$assert_text]
+--source include/begin_include_file.inc
+
+
+--let _AG_ASSERT_TEXT= $assert_text
+--let _AG_ASSERT_FILE= $assert_file
+--let _AG_ASSERT_SELECT= $assert_select
+--let _AG_ASSERT_MATCH= $assert_match
+--let _AG_ASSERT_COUNT= $assert_count
+--let _AG_OUT= `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/_ag_', UUID())`
+--let _AG_ASSERT_ONLY_AFTER= $assert_only_after
+
+
+--perl
+ use strict;
+ use warnings;
+ my $file= $ENV{'_AG_ASSERT_FILE'};
+ my $assert_select= $ENV{'_AG_ASSERT_SELECT'};
+ my $assert_match= $ENV{'_AG_ASSERT_MATCH'};
+ my $assert_count= $ENV{'_AG_ASSERT_COUNT'};
+ my $assert_only_after= $ENV{'_AG_ASSERT_ONLY_AFTER'};
+ my $out= $ENV{'_AG_OUT'};
+
+ my $result= '';
+ my $count= 0;
+ open(FILE, "$file") or die("Error $? opening $file: $!\n");
+ while (<FILE>) {
+ my $line = $_;
+ if ($assert_only_after && $line =~ /$assert_only_after/) {
+ $result = "";
+ $count = 0;
+ }
+ if ($line =~ /$assert_select/) {
+ if ($assert_count ne '') {
+ $count++;
+ }
+ else {
+ $result .= $line;
+ }
+ }
+ }
+ close(FILE) or die("Error $? closing $file: $!");
+ open OUT, "> $out" or die("Error $? opening $out: $!");
+ if ($assert_count ne '' && ($count != $assert_count)) {
+ print OUT ($count) or die("Error $? writing $out: $!");
+ }
+ elsif ($assert_count eq '' && $result !~ /$assert_match/) {
+ print OUT ($result) or die("Error $? writing $out: $!");
+ }
+ else {
+ print OUT ("assert_grep.inc ok");
+ }
+ close OUT or die("Error $? closing $out: $!");
+EOF
+
+
+--let $_ag_outcome= `SELECT LOAD_FILE('$_AG_OUT')`
+if ($_ag_outcome != 'assert_grep.inc ok')
+{
+ --source include/show_rpl_debug_info.inc
+ --echo include/assert_grep.inc failed!
+ --echo assert_text: '$assert_text'
+ --echo assert_file: '$assert_file'
+ --echo assert_select: '$assert_select'
+ --echo assert_match: '$assert_match'
+ --echo assert_count: '$assert_count'
+ --echo assert_only_after: '$assert_only_after'
+ if ($assert_match != '')
+ {
+ --echo matching lines: '$_ag_outcome'
+ }
+ if ($assert_count != '')
+ {
+ --echo number of matching lines: $_ag_outcome
+ }
+ --die assert_grep.inc failed.
+}
+
+
+--let $include_filename= include/assert_grep.inc [$assert_text]
+--source include/end_include_file.inc
diff --git a/mysql-test/include/diff_servers.inc b/mysql-test/include/diff_servers.inc
new file mode 100644
index 00000000000..5ec7efc38b9
--- /dev/null
+++ b/mysql-test/include/diff_servers.inc
@@ -0,0 +1,67 @@
+# ==== Purpose ====
+#
+# Check that two or more servers have identical databases; fail if not.
+#
+# ==== Usage ====
+#
+# --let $diff_servers= 1 2
+# [--let $databases= db1 db2 ...]
+# [--let $rpl_debug= 1]
+# --source include/diff_servers.inc
+
+# pretty-print header
+--let $_ds_info= servers=$diff_servers
+if ($databases != '')
+{
+ --let $_ds_info= $_ds_info databases=$databases
+}
+--let $include_filename= diff_servers.inc [$_ds_info]
+--source include/begin_include_file.inc
+
+# get databases
+--let $_ds_databases= $diff_database
+if ($_ds_databases == '')
+{
+ --let $_ds_databases= `SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'mtr', 'mysql', 'performance_schema')`
+}
+
+# generate command line
+--let $_ds_arg= --defaults-group-suffix=.
+--let $_ds_number_pos= `SELECT LOCATE('$_ds_arg', '$MYSQL_DUMP') + LENGTH('$_ds_arg')`
+--let $_ds_pre_command= `SELECT SUBSTR('$MYSQL_DUMP', 1, $_ds_number_pos - 1)`
+--let $_ds_post_command= `SELECT SUBSTR('$MYSQL_DUMP', $_ds_number_pos + 1)`
+--let $_ds_post_command= $_ds_post_command --compact --order-by-primary --skip-extended-insert --no-create-info --databases $_ds_databases
+--let $_ds_prev_outfile=
+
+# iterate over servers
+--let $_ds_servers= $diff_servers
+while ($_ds_servers != '')
+{
+ --let $_ds_server_number= `SELECT SUBSTRING_INDEX('$_ds_servers', ' ', 1)`
+ --let $_ds_servers= `SELECT TRIM(SUBSTRING('$_ds_servers', 1 + LENGTH('_$ds_server_number')))`
+ --let $_ds_outfile= $MYSQLTEST_VARDIR/tmp/diff_servers_$_ds_server_number
+
+ if ($rpl_debug)
+ {
+ --echo generating dump from server '$_ds_server_number' using command '$_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile'
+ --echo remaining servers: '$_ds_servers'
+ }
+ --exec $_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile
+
+ if ($_ds_prev_outfile != '')
+ {
+ if ($rpl_debug)
+ {
+ --echo diffing files '$_ds_prev_outfile' and '$_ds_outfile'
+ }
+ --diff_files $_ds_prev_outfile $_ds_outfile
+
+ --remove_file $_ds_prev_outfile
+ }
+ --let $_ds_prev_outfile= $_ds_outfile
+}
+
+--remove_file $_ds_prev_outfile
+
+--let $include_filename= diff_servers.inc [servers=$_ds_info]
+--source include/end_include_file.inc
diff --git a/mysql-test/include/galera_wait_ready.inc b/mysql-test/include/galera_wait_ready.inc
new file mode 100644
index 00000000000..e20f01fad90
--- /dev/null
+++ b/mysql-test/include/galera_wait_ready.inc
@@ -0,0 +1,2 @@
+let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' AND VARIABLE_VALUE = 'ON';
+--source include/wait_condition.inc
diff --git a/mysql-test/include/have_innodb_max_16k.inc b/mysql-test/include/have_innodb_max_16k.inc
new file mode 100644
index 00000000000..f8346666299
--- /dev/null
+++ b/mysql-test/include/have_innodb_max_16k.inc
@@ -0,0 +1,4 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE LOWER(variable_name) = 'innodb_page_size' AND variable_value <= 16384`)
+{
+ --skip Test requires InnoDB with page size not greater than 16k.
+}
diff --git a/mysql-test/include/mysqlhotcopy.inc b/mysql-test/include/mysqlhotcopy.inc
index f775d782b28..2fc14d599d9 100644
--- a/mysql-test/include/mysqlhotcopy.inc
+++ b/mysql-test/include/mysqlhotcopy.inc
@@ -109,7 +109,7 @@ DROP DATABASE hotcopy_save;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
--list_files $MYSQLD_DATADIR/hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
---error 1
+--error 1,9,11,110,2304,255
--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
--exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
diff --git a/mysql-test/r/create_drop_binlog.result b/mysql-test/r/create_drop_binlog.result
index 5a14ed5def9..dc9c1da2c14 100644
--- a/mysql-test/r/create_drop_binlog.result
+++ b/mysql-test/r/create_drop_binlog.result
@@ -160,7 +160,7 @@ Note 1050 Table 'v1' already exists
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
# # Format_desc 1 # VER
diff --git a/mysql-test/r/create_drop_view.result b/mysql-test/r/create_drop_view.result
index fc9dca3ea2e..117f7b851c6 100644
--- a/mysql-test/r/create_drop_view.result
+++ b/mysql-test/r/create_drop_view.result
@@ -55,5 +55,5 @@ id
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
DROP TABLE t1;
diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result
index 5b773067f13..317d8bd05df 100644
--- a/mysql-test/r/cte_nonrecursive.result
+++ b/mysql-test/r/cte_nonrecursive.result
@@ -962,7 +962,7 @@ View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with alias1 as (select 1 AS `one`), alias2 as (select 2 AS `two`)select `alias1`.`one` AS `one`,`alias2`.`two` AS `two` from (`alias1` join `alias2`) latin1 latin1_swedish_ci
drop view v1;
#
-# MDEV-12440: the same CTE table is used in twice
+# MDEV-12440: the same CTE table is used twice
#
create table t1 (a int, b varchar(32));
insert into t1 values
@@ -984,3 +984,19 @@ select * from cte3;
a b
4 dd
drop table t1;
+#
+# MDEV-12558: CTE with the same name as temporary table
+#
+CREATE TABLE t ENGINE=MyISAM AS SELECT 1 AS i;
+CREATE TEMPORARY TABLE cte ENGINE=MyISAM AS SELECT 2 AS f;
+WITH cte AS ( SELECT i FROM t ) SELECT * FROM cte;
+i
+1
+WITH cte AS ( SELECT i FROM t GROUP BY i) SELECT * FROM cte;
+i
+1
+SELECT * FROM cte;
+f
+2
+DROP TABLE cte;
+DROP TABLE t;
diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result
index bf662130d5a..f691db27239 100644
--- a/mysql-test/r/cte_recursive.result
+++ b/mysql-test/r/cte_recursive.result
@@ -2770,3 +2770,119 @@ set standard_compliant_cte=default;
select @@standard_compliant_cte;
@@standard_compliant_cte
1
+#
+# mdev-12554: impossible where in recursive select
+#
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1),(2);
+WITH RECURSIVE
+cte(f) AS ( SELECT i FROM t1 UNION SELECT f FROM t1, cte WHERE 1=0 )
+SELECT * FROM cte;
+f
+1
+2
+DROP TABLE t1;
+#
+# mdev-12556: recursive execution uses Aria temporary tables
+#
+CREATE TABLE t (c1 varchar(255), c2 tinytext);
+INSERT INTO t VALUES ('a','a'),('b','b'),('c','c'),('d','d');
+ANALYZE WITH RECURSIVE cte(f) AS (
+SELECT c1 FROM t
+UNION
+SELECT c1 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+2 SUBQUERY t ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+3 RECURSIVE UNION t ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 4 4.00 100.00 100.00 Using join buffer (flat, BNL join)
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL 0.00 NULL NULL
+WITH RECURSIVE cte(f) AS (
+SELECT c1 FROM t
+UNION
+SELECT c1 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+COUNT(*)
+4
+ANALYZE WITH RECURSIVE cte(f) AS (
+SELECT c2 FROM t
+UNION
+SELECT c2 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+2 SUBQUERY t ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+3 RECURSIVE UNION t ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
+3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 4 4.00 100.00 100.00 Using join buffer (flat, BNL join)
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL 0.00 NULL NULL
+WITH RECURSIVE cte(f) AS (
+SELECT c2 FROM t
+UNION
+SELECT c2 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+COUNT(*)
+4
+DROP TABLE t;
+#
+# mdev-12563: no recursive references on the top level of the CTE spec
+#
+CREATE TABLE t (i int);
+INSERT INTO t VALUES (3), (1),(2);
+SET standard_compliant_cte=0;
+WITH RECURSIVE cte(f) AS (
+SELECT i FROM t
+UNION
+SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte )
+) SELECT * FROM cte;
+f
+3
+1
+2
+WITH RECURSIVE cte(f) AS (
+SELECT i FROM t
+UNION
+SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte WHERE i < 2 )
+UNION
+SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte WHERE i > 2 )
+) SELECT * FROM cte;
+f
+3
+1
+2
+WITH RECURSIVE cte(f) AS (
+SELECT i FROM t
+UNION
+SELECT i FROM t
+WHERE i NOT IN ( SELECT * FROM cte WHERE i < 2
+UNION
+SELECT * FROM cte WHERE i > 2)
+) SELECT * FROM cte;
+f
+3
+1
+2
+WITH RECURSIVE cte(f) AS (
+SELECT i FROM t
+UNION
+SELECT i FROM t
+WHERE i NOT IN ( SELECT * FROM t
+WHERE i IN ( SELECT * FROM cte ) GROUP BY i )
+) SELECT * FROM cte;
+f
+3
+1
+2
+WITH RECURSIVE cte(f) AS (
+SELECT i FROM t
+UNION
+SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte )
+UNION
+SELECT * FROM cte WHERE f > 2
+) SELECT * FROM cte;
+f
+3
+1
+2
+set standard_compliant_cte=default;
+DROP TABLE t;
diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result
index e8a7af4de1f..a662ebba8c5 100644
--- a/mysql-test/r/derived_cond_pushdown.result
+++ b/mysql-test/r/derived_cond_pushdown.result
@@ -7134,7 +7134,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
- "const_condition": "2 < 2 or <in_optimizer>(2,<exists>(subquery#3))",
+ "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
"table": {
"table_name": "t1",
"access_type": "system",
@@ -7218,7 +7218,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
- "const_condition": "2 < 2 or <in_optimizer>(2,<exists>(subquery#3))",
+ "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
"table": {
"table_name": "t1",
"access_type": "system",
@@ -7684,7 +7684,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "v1.b = count(t2.c)",
+ "attached_condition": "v1.b = 2",
"materialized": {
"query_block": {
"select_id": 3,
@@ -7741,7 +7741,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "v1.f = count(t.pk)",
+ "attached_condition": "v1.f = 2",
"materialized": {
"query_block": {
"select_id": 3,
@@ -7761,7 +7761,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "v2.pk > count(t.pk)"
+ "attached_condition": "v2.pk > 2"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
@@ -7820,7 +7820,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = 3",
"materialized": {
"query_block": {
"select_id": 2,
@@ -7877,7 +7877,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = 2.7100000381469727",
"materialized": {
"query_block": {
"select_id": 2,
@@ -7929,7 +7929,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = 3.21",
"materialized": {
"query_block": {
"select_id": 2,
@@ -7981,7 +7981,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = 'aa'",
"materialized": {
"query_block": {
"select_id": 2,
@@ -8035,7 +8035,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = '2007-05-28 00:00:00'",
"materialized": {
"query_block": {
"select_id": 2,
@@ -8087,7 +8087,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = '2007-05-28'",
"materialized": {
"query_block": {
"select_id": 2,
@@ -8139,7 +8139,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
- "attached_condition": "sq.i = min(t2.j)",
+ "attached_condition": "sq.i = '10:00:02'",
"materialized": {
"query_block": {
"select_id": 2,
@@ -8230,7 +8230,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "v1.c = min(t2.c)",
+ "attached_condition": "v1.c = NULL",
"materialized": {
"query_block": {
"select_id": 3,
@@ -8333,7 +8333,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "<in_optimizer>(1,<exists>(subquery#2)) or v1.c = 'foo'",
+ "attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'",
"materialized": {
"query_block": {
"select_id": 3,
@@ -8366,3 +8366,100 @@ DEALLOCATE PREPARE stmt1;
DEALLOCATE PREPARE stmt2;
DROP VIEW v1;
DROP TABLE t1,t2;
+#
+# MDEV-12373: pushdown into derived with side effects is prohibited
+#
+CREATE TABLE sales_documents (
+id int NOT NULL AUTO_INCREMENT,
+sale_id int NULL DEFAULT NULL,
+type tinyint unsigned NULL DEFAULT NULL,
+data text NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
+date date NULL DEFAULT NULL,
+order_number int unsigned NULL DEFAULT NULL,
+created_at int NULL DEFAULT NULL,
+updated_at int NULL DEFAULT NULL,
+generated tinyint NOT NULL DEFAULT '0',
+synced_at int NOT NULL DEFAULT '0',
+sum decimal(13,2) NOT NULL DEFAULT '0',
+PRIMARY KEY (id)
+);
+INSERT INTO sales_documents
+(id, sale_id, type, order_number, data, created_at,
+updated_at, date, generated, synced_at, sum)
+VALUES
+(555, 165, 3, 5, '{}', 1486538300, 1486722835, '2017-02-17', 0, 1486538313, 2320.00),
+(556, 165, 2, 3, '{}', 1486538304, 1486563125, '2017-02-08', 1, 1486538302, 2320.00),
+(557, 158, 2, 2, '{}', 1486538661, 1486538661, '2017-02-08', 0, 1486538660, 2320.00),
+(558, 171, 1, 3, '{}', 1486539104, 1488203405, '2017-02-08', 1, 1486539102, 23230.00),
+(559, 171, 2, 5, '{}', 1486549233, 1487146010, '2017-02-08', 1, 1486549225, 37690.00),
+(560, 172, 1, 1, '{}', 1486658260, 1488203409, '2017-02-09', 1, 1486658256, 40312.00),
+(561, 172, 2, 1, '{}', 1486711997, 1486711997, '2017-02-10', 1, 1486711996, 40312.00),
+(562, 172, 3, 1, '{}', 1486712104, 1486721395, '2017-02-10', 1, 1486712101, 40312.00),
+(563, 171, 3, 2, '{}', 1486712953, 1486720244, '2017-02-10', 1, 1486712910, 23230.00),
+(564, 170, 1, 2, '{}', 1486715948, 1488203410, '2017-02-10', 1, 1486715930, 28873.00),
+(565, 170, 3, 3, '{}', 1486716782, 1486717426, '2017-02-10', 1, 1486716779, 61948.00),
+(566, 166, 3, 4, '{}', 1486720947, 1486720947, '2017-02-10', 1, 1486720945, 4640.00),
+(567, 167, 3, 5, '{}', 1486722741, 1486722783, '2017-02-26', 0, 1486722738, 14755.00),
+(568, 165, 1, 4, '{}', 1486722849, 1486722849, '2017-02-10', 0, 1486722846, 2320.00),
+(569, 173, 2, 2, '{}', 1486723073, 1487071275, '2017-02-10', 1, 1486723071, 14282.00),
+(570, 173, 1, 4, '{}', 1486723100, 1488203412, '2017-02-10', 1, 1486723099, 14282.00),
+(571, 167, 2, 4, '{}', 1486730859, 1486730859, '2017-02-10', 1, 1486730856, 18655.00),
+(572, 167, 1, 5, '{}', 1486730883, 1488203412, '2017-02-10', 1, 1486730877, 18655.00),
+(573, 174, 2, 51, '{}', 1486731622, 1487060259, '2017-02-10', 1, 1486731620, 7140.00),
+(574, 174, 3, 5, '{}', 1486993472, 1486993472, '2017-02-13', 1, 1488216147, 28020.00),
+(575, 174, 1, 6, '{}', 1486993530, 1488203412, '2017-02-13', 1, 1486993505, 7140.00),
+(576, 173, 3, 6, '{}', 1487071425, 1487071425, '2017-02-14', 0, 1487071422, 14282.00),
+(577, 178, 2, 6, '{}', 1487327372, 1487327372, '2017-02-17', 1, 1487327370, 12321.00),
+(578, 177, 2, 7, '{}', 1487327394, 1487327394, '2017-02-17', 0, 1487327391, 4270.00),
+(579, 182, 3, 6, '{}', 1487750589, 1487751693, '2017-02-22', 1, 1487751688, 4270.00),
+(580, 182, 2, 7, '{}', 1487750601, 1487750663, '2017-02-22', 1, 1487750598, 4270.00),
+(581, 182, 1, 7, '{}', 1487750694, 1488203412, '2017-02-22', 1, 1487750692, 4270.00),
+(582, 185, 3, 7, '{}', 1487774051, 1487774051, '2017-02-22', 0, 1487774043, 8913.00),
+(583, 184, 3, 7, '{}', 1487774071, 1487774235, '2017-02-22', 0, 1487774093, 3285.00),
+(584, 184, 2, 8, '{}', 1487774074, 1487774074, '2017-02-22', 0, 1487774073, 3285.00),
+(585, 184, 1, 8, '{}', 1487774081, 1487774081, '2017-02-22', 0, 1487774075, 3285.00),
+(586, 193, 2, 8, '{}', 1487955294, 1487955318, '2017-02-24', 0, 1487955311, 4270.00),
+(587, 193, 1, 8, '{}', 1487955324, 1487955324, '2017-02-24', 0, 1487955320, 4270.00),
+(588, 193, 3, 7, '{}', 1487955341, 1487955341, '2017-02-24', 0, 1487955325, 4270.00),
+(589, 186, 1, 8, '{}', 1487957291, 1487957464, '2017-02-24', 0, 1487957459, 6960.00),
+(590, 186, 2, 8, '{}', 1487957308, 1487957468, '2017-02-24', 0, 1487957465, 6960.00),
+(591, 186, 3, 7, '{}', 1487957312, 1487957473, '2017-02-24', 0, 1487957469, 6960.00),
+(592, 194, 1, 8, '{}', 1488193293, 1488203412, '2017-02-27', 1, 1488193280, 2320.00),
+(593, 194, 2, 8, '{}', 1488193304, 1488193304, '2017-02-27', 1, 1488193303, 2320.00),
+(594, 210, 1, 9, '{}', 1488198896, 1488198896, '2017-02-27', 0, 1488198885, 4270.00),
+(595, 210, 2, 12, '{}', 1488198901, 1488198901, '2017-02-27', 1, 1488532585, 4270.00),
+(596, 210, 3, 10, '{}', 1488198904, 1488198904, '2017-02-27', 1, 1488532565, 4270.00),
+(597, 209, 2, 9, '{}', 1488200016, 1488450772, '2017-02-27', 1, 1488450449, 4270.00),
+(598, 209, 1, 9, '{}', 1488200020, 1488200063, '2017-02-27', 1, 1488200017, 4271.00),
+(599, 209, 3, 7, '{}', 1488200053, 1488200053, '2017-02-27', 0, 1488200021, 4271.00),
+(600, 211, 2, 10, '{}', 1488216265, 1489402027, '2017-02-27', 1, 1488216264, 2320.00),
+(601, 211, 3, 7, '{}', 1488216281, 1488216281, '2017-02-27', 1, 1488216276, 2320.00),
+(602, 211, 1, 10, '{}', 1488216283, 1488216283, '2017-02-27', 1, 1488216282, 2320.00),
+(603, 198, 2, 11, '{}', 1488280125, 1488280125, '2017-02-28', 0, 1488280095, 4270.00),
+(604, 198, 1, 11, '{}', 1488280160, 1488280160, '2017-02-28', 0, 1488280126, 4270.00),
+(605, 198, 3, 8, '{}', 1488280440, 1488280440, '2017-02-28', 0, 1488280435, 4270.00),
+(606, 212, 1, 12, '{}', 1488286301, 1489402168, '2017-02-28', 1, 1488286295, 13825.00),
+(607, 212, 3, 8, '{}', 1488289644, 1488289690, '2017-02-28', 1, 1488289642, 25295.00),
+(608, 212, 2, 13, '{}', 1488290350, 1488290431, '2017-02-28', 1, 1488290347, 13133.75),
+(609, 213, 1, 11, '{}', 1488529470, 1488529470, '2017-03-03', 1, 1488529461, 5660.00),
+(610, 213, 2, 11, '{}', 1488529484, 1488529484, '2017-03-03', 1, 1488529479, 5660.00),
+(611, 213, 3, 9, '{}', 1488529493, 1488529493, '2017-03-03', 1, 1488529489, 5660.00),
+(612, 197, 2, 13, '{}', 1489400715, 1489400715, '2017-03-13', 0, 1489398959, 4270.00),
+(613, 219, 3, 11, '{}', 1490084337, 1490181958, '2017-03-21', 1, 1490084334, 73526.00),
+(614, 216, 3, 11, '{}', 1490085757, 1490086717, '2017-03-21', 0, 1490085755, 5377.00);
+SELECT * FROM
+(SELECT @row := @row + 1 as row, a.* from (
+SELECT t.order_number
+FROM sales_documents t
+WHERE
+t.type = 2 AND
+t.date >= '2017-01-01' AND
+t.date <= '2017-12-31' AND
+t.order_number IS NOT NULL AND
+t.generated = 1
+GROUP BY t.order_number
+) a, (SELECT @row := 0) r) t
+WHERE row <> order_number;
+row order_number
+14 51
+DROP TABLE sales_documents;
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result
index 050e0b9cd2b..f33a482dc0b 100644
--- a/mysql-test/r/drop.result
+++ b/mysql-test/r/drop.result
@@ -209,10 +209,10 @@ Note 1051 Unknown table 'test.table1'
Note 1051 Unknown table 'test.table2'
DROP VIEW IF EXISTS view1,view2,view3,view4;
Warnings:
-Note 4067 Unknown VIEW: 'test.view1'
-Note 4067 Unknown VIEW: 'test.view2'
-Note 4067 Unknown VIEW: 'test.view3'
-Note 4067 Unknown VIEW: 'test.view4'
+Note 4068 Unknown VIEW: 'test.view1'
+Note 4068 Unknown VIEW: 'test.view2'
+Note 4068 Unknown VIEW: 'test.view3'
+Note 4068 Unknown VIEW: 'test.view4'
# Test error message when trigger does not find table
CREATE TABLE table1(a int);
diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result
index f6af5a4dd93..ab9fd528ad2 100644
--- a/mysql-test/r/explain_json.result
+++ b/mysql-test/r/explain_json.result
@@ -813,7 +813,7 @@ EXPLAIN
"ref": ["func"],
"rows": 2,
"filtered": 100,
- "attached_condition": "trigcond(outer_t1.a = t1.a or t1.a is null)",
+ "attached_condition": "trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)",
"using_index": true
}
},
@@ -827,7 +827,7 @@ EXPLAIN
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
- "attached_condition": "t2.b <> outer_t1.a and trigcond(outer_t1.a = t1.a or t1.a is null)"
+ "attached_condition": "t2.b <> outer_t1.a and trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)"
}
}
}
@@ -1108,7 +1108,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
- "attached_condition": "(case when convert(t1.a using utf8) = _utf8'a' collate utf8_bin then NULL else t1.a end)"
+ "attached_condition": "(case when convert(t1.a using utf8) = <cache>(_utf8'a' collate utf8_bin) then NULL else t1.a end)"
}
}
}
diff --git a/mysql-test/r/func_debug.result b/mysql-test/r/func_debug.result
index 02df7eec471..f55bfca80f5 100644
--- a/mysql-test/r/func_debug.result
+++ b/mysql-test/r/func_debug.result
@@ -173,29 +173,29 @@ SELECT DATE'2001-01-01' IN ('2001-01-01','2001-02-02');
DATE'2001-01-01' IN ('2001-01-01','2001-02-02')
1
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT DATE'2001-01-01' IN ('2001-01-01','2001-02-02',NULL);
DATE'2001-01-01' IN ('2001-01-01','2001-02-02',NULL)
1
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT DATE'2001-01-01' NOT IN ('2001-01-01','2001-02-02');
DATE'2001-01-01' NOT IN ('2001-01-01','2001-02-02')
0
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT DATE'2001-01-01' NOT IN ('2001-01-01','2001-02-02',NULL);
DATE'2001-01-01' NOT IN ('2001-01-01','2001-02-02',NULL)
0
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
# Column predicant, compatible types, bisect
CREATE TABLE t1 (a INT UNSIGNED);
@@ -354,38 +354,38 @@ CREATE TABLE t1 (a DATE);
SELECT a IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0) FROM t1;
a IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
-Note 1105 DBUG: [2] arg=3 handler=0 (datetime)
-Note 1105 DBUG: [3] arg=4 handler=0 (datetime)
-Note 1105 DBUG: [4] arg=5 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
+Note 1105 DBUG: [2] arg=3 handler=0 (date)
+Note 1105 DBUG: [3] arg=4 handler=0 (date)
+Note 1105 DBUG: [4] arg=5 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT a IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0,NULL) FROM t1;
a IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0,NULL)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
-Note 1105 DBUG: [2] arg=3 handler=0 (datetime)
-Note 1105 DBUG: [3] arg=4 handler=0 (datetime)
-Note 1105 DBUG: [4] arg=5 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
+Note 1105 DBUG: [2] arg=3 handler=0 (date)
+Note 1105 DBUG: [3] arg=4 handler=0 (date)
+Note 1105 DBUG: [4] arg=5 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT a NOT IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0) FROM t1;
a NOT IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
-Note 1105 DBUG: [2] arg=3 handler=0 (datetime)
-Note 1105 DBUG: [3] arg=4 handler=0 (datetime)
-Note 1105 DBUG: [4] arg=5 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
+Note 1105 DBUG: [2] arg=3 handler=0 (date)
+Note 1105 DBUG: [3] arg=4 handler=0 (date)
+Note 1105 DBUG: [4] arg=5 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT a NOT IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0,NULL) FROM t1;
a NOT IN ('2001-01-01',DATE'2001-01-02',20010102,20010102.0,20010102e0,NULL)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
-Note 1105 DBUG: [2] arg=3 handler=0 (datetime)
-Note 1105 DBUG: [3] arg=4 handler=0 (datetime)
-Note 1105 DBUG: [4] arg=5 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
+Note 1105 DBUG: [2] arg=3 handler=0 (date)
+Note 1105 DBUG: [3] arg=4 handler=0 (date)
+Note 1105 DBUG: [4] arg=5 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=yes
DROP TABLE t1;
CREATE TABLE t1 (a TIME);
@@ -610,26 +610,26 @@ CREATE TABLE t1 (a DATE);
SELECT DATE'2001-01-01' IN (a,'2001-01-01') FROM t1;
DATE'2001-01-01' IN (a,'2001-01-01')
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=no
SELECT DATE'2001-01-01' IN (a,'2001-01-01',NULL) FROM t1;
DATE'2001-01-01' IN (a,'2001-01-01',NULL)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=no
SELECT DATE'2001-01-01' NOT IN (a,'2001-01-01') FROM t1;
DATE'2001-01-01' NOT IN (a,'2001-01-01')
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=no
SELECT DATE'2001-01-01' NOT IN (a,'2001-01-01',NULL) FROM t1;
DATE'2001-01-01' NOT IN (a,'2001-01-01',NULL)
Warnings:
-Note 1105 DBUG: [0] arg=1 handler=0 (datetime)
-Note 1105 DBUG: [1] arg=2 handler=0 (datetime)
+Note 1105 DBUG: [0] arg=1 handler=0 (date)
+Note 1105 DBUG: [1] arg=2 handler=0 (date)
Note 1105 DBUG: types_compatible=yes bisect=no
DROP TABLE t1;
CREATE TABLE t1 (a TIME);
@@ -1147,25 +1147,25 @@ SELECT a IN (1,DATE'2001-01-01') FROM t1;
a IN (1,DATE'2001-01-01')
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (double)
-Note 1105 DBUG: [1] arg=2 handler=1 (datetime)
+Note 1105 DBUG: [1] arg=2 handler=1 (date)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a IN (1,DATE'2001-01-01',NULL) FROM t1;
a IN (1,DATE'2001-01-01',NULL)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (double)
-Note 1105 DBUG: [1] arg=2 handler=1 (datetime)
+Note 1105 DBUG: [1] arg=2 handler=1 (date)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a NOT IN (1,DATE'2001-01-01') FROM t1;
a NOT IN (1,DATE'2001-01-01')
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (double)
-Note 1105 DBUG: [1] arg=2 handler=1 (datetime)
+Note 1105 DBUG: [1] arg=2 handler=1 (date)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a NOT IN (1,DATE'2001-01-01',NULL) FROM t1;
a NOT IN (1,DATE'2001-01-01',NULL)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (double)
-Note 1105 DBUG: [1] arg=2 handler=1 (datetime)
+Note 1105 DBUG: [1] arg=2 handler=1 (date)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a IN (1,TIMESTAMP'2001-01-01 10:20:30') FROM t1;
a IN (1,TIMESTAMP'2001-01-01 10:20:30')
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index eff8f5c9c92..997d3e4d062 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -629,3 +629,16 @@ j p json_remove(j, p)
{"a":1,"b":2,"c":3} $.b {"a": 1, "c": 3}
{"a":1,"b":2,"c":3} $.c {"a": 1, "b": 2}
drop table t1;
+SET @str = 'bar', @path = '$';
+SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
+JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path)
+"$.foo"
+SELECT JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]');
+JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]')
+bar
+CREATE TABLE t1 (f INT NOT NULL);
+INSERT INTO t1 VALUES (0);
+SELECT JSON_KEYS(f) FROM t1 ORDER BY 1;
+JSON_KEYS(f)
+NULL
+DROP TABLE t1;
diff --git a/mysql-test/r/gis-rt-precise.result b/mysql-test/r/gis-rt-precise.result
index 65583a0ce0d..d3308ed90ba 100644
--- a/mysql-test/r/gis-rt-precise.result
+++ b/mysql-test/r/gis-rt-precise.result
@@ -51,7 +51,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 1 Using where
+1 SIMPLE t1 range g g 34 NULL 4 Using where
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
fid AsText(g)
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index b76d02ef1d7..9373237f1d6 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -301,7 +301,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 1 Using where
+1 SIMPLE t2 range g g 34 NULL 4 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 593d998754a..3e3c84d4300 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1428,7 +1428,7 @@ Warnings:
Note 1305 FUNCTION test.test_function does not exist
drop view if exists v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
create table test (col1 varchar(30));
create function test_function() returns varchar(30)
begin
diff --git a/mysql-test/r/keyread.result b/mysql-test/r/keyread.result
new file mode 100644
index 00000000000..d8e9659d4bb
--- /dev/null
+++ b/mysql-test/r/keyread.result
@@ -0,0 +1,6 @@
+create table t1 (f1 int not null, f2 int, f3 int, primary key (f1,f2), key(f2,f3)) engine=innodb;
+create view v1 as select * from t1 where f2 = 1;
+select distinct f1 from v1;
+f1
+drop view v1;
+drop table t1;
diff --git a/mysql-test/r/loadxml.result b/mysql-test/r/loadxml.result
index c3b4c867c98..711fea9e854 100644
--- a/mysql-test/r/loadxml.result
+++ b/mysql-test/r/loadxml.result
@@ -123,3 +123,14 @@ col1 col2 col3
ABC DEF NULL
GHI NULL 123
DROP TABLE t1;
+#
+# MDEV-12696 Crash with LOAD XML and non-updatable VIEW column
+#
+CREATE TABLE t1 (c1 TEXT);
+CREATE VIEW v1 AS SELECT CONCAT(c1,'') AS c1, NULL AS c2 FROM t1;
+LOAD XML INFILE '../../std_data/loaddata/mdev12696.xml' INTO TABLE v1 (c1);
+ERROR HY000: Invalid column reference (v1.c1) in LOAD DATA
+LOAD XML INFILE '../../std_data/loaddata/mdev12696.xml' INTO TABLE v1 (c2);
+ERROR HY000: Invalid column reference (v1.c2) in LOAD DATA
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 1243c455e6c..66b501e8278 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -5534,3 +5534,52 @@ USE `db1`;
DROP DATABASE db1;
DROP DATABASE db2;
FOUND 1 /Database: mysql/ in bug11505.sql
+#
+# Test for --add-drop-trigger
+#
+use test;
+CREATE TABLE t1 (a int, b int);
+CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW
+SET NEW.b=NEW.a + 10;
+INSERT INTO t1 (a) VALUES (1),(2),(3);
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
+
+USE `test`;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+/*!50032 DROP TRIGGER IF EXISTS tt1_t1 */;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW
+SET NEW.b=NEW.a + 10 */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+DROP TABLE t1;
diff --git a/mysql-test/r/profiling.result b/mysql-test/r/profiling.result
index e87bfd49056..32e7e0ddc9d 100644
--- a/mysql-test/r/profiling.result
+++ b/mysql-test/r/profiling.result
@@ -415,7 +415,7 @@ select @@profiling;
drop table if exists t1, t2, t3;
drop view if exists v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
drop function if exists f1;
set session profiling = OFF;
set global profiling_history_size= @start_value;
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 3c57ab980c3..28f5cf635d0 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -2371,7 +2371,7 @@ EXPLAIN
"used_key_parts": ["a", "b"],
"rows": 7,
"filtered": 100,
- "attached_condition": "(t1.a,t1.b) in ((2,3),(3,3),(8,8),(7,7))"
+ "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))"
}
}
}
@@ -2431,7 +2431,7 @@ EXPLAIN
"used_key_parts": ["a"],
"rows": 5,
"filtered": 100,
- "attached_condition": "(t1.a,t1.b + t1.a) in ((4,9),(8,8),(7,7))"
+ "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))"
}
}
}
@@ -2498,7 +2498,7 @@ EXPLAIN
"rows": 3,
"filtered": 100,
"index_condition": "t2.d is not null",
- "attached_condition": "(t2.d,t2.e) in ((3,3),(7,7),(2,2))"
+ "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))"
},
"table": {
"table_name": "t1",
@@ -2581,7 +2581,7 @@ EXPLAIN
"ref": ["test.t1.a"],
"rows": 12,
"filtered": 100,
- "attached_condition": "(t1.a,t2.e) in ((3,3),(7,7),(8,8)) and length(t2.f) = 1"
+ "attached_condition": "(t1.a,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1"
}
}
}
@@ -2666,7 +2666,7 @@ EXPLAIN
"used_key_parts": ["e"],
"rows": 6,
"filtered": 100,
- "attached_condition": "(t2.d,t2.e) in ((4,4),(7,7),(8,8)) and length(t2.f) = 1 and t2.d is not null"
+ "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1 and t2.d is not null"
},
"table": {
"table_name": "t1",
@@ -2716,7 +2716,7 @@ EXPLAIN
"rows": 5,
"filtered": 100,
"index_condition": "t2.d is not null",
- "attached_condition": "(t2.d,t2.e) in ((4,4),(7,7),(8,8)) and length(t2.f) = 1"
+ "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1"
},
"table": {
"table_name": "t1",
@@ -2830,7 +2830,7 @@ EXPLAIN
"ref": ["test.t1.a"],
"rows": 3,
"filtered": 100,
- "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),(7,7),(8,8)) and length(t2.f) = 1"
+ "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1"
}
}
}
@@ -2870,7 +2870,7 @@ EXPLAIN
"rows": 13,
"filtered": 100,
"index_condition": "t1.a is not null",
- "attached_condition": "(t1.a,2) in ((2,2),(7,7),(8,8)) and length(t1.c) = 1"
+ "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and length(t1.c) = 1"
},
"table": {
"table_name": "t2",
@@ -2958,7 +2958,7 @@ EXPLAIN
"rows": 13,
"filtered": 100,
"index_condition": "t1.a is not null",
- "attached_condition": "(t1.a,1 + 1) in ((2,2),(7,7),(8,8)) and length(t1.c) = 1"
+ "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and length(t1.c) = 1"
},
"table": {
"table_name": "t2",
diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result
index 445f0877586..f2860aaab76 100644
--- a/mysql-test/r/range_mrr_icp.result
+++ b/mysql-test/r/range_mrr_icp.result
@@ -2373,7 +2373,7 @@ EXPLAIN
"used_key_parts": ["a", "b"],
"rows": 7,
"filtered": 100,
- "attached_condition": "(t1.a,t1.b) in ((2,3),(3,3),(8,8),(7,7))",
+ "attached_condition": "(t1.a,t1.b) in (<cache>((2,3)),<cache>((3,3)),<cache>((8,8)),<cache>((7,7)))",
"mrr_type": "Rowid-ordered scan"
}
}
@@ -2434,7 +2434,7 @@ EXPLAIN
"used_key_parts": ["a"],
"rows": 5,
"filtered": 100,
- "attached_condition": "(t1.a,t1.b + t1.a) in ((4,9),(8,8),(7,7))",
+ "attached_condition": "(t1.a,t1.b + t1.a) in (<cache>((4,9)),<cache>((8,8)),<cache>((7,7)))",
"mrr_type": "Rowid-ordered scan"
}
}
@@ -2503,7 +2503,7 @@ EXPLAIN
"rows": 3,
"filtered": 100,
"index_condition": "t2.d is not null",
- "attached_condition": "(t2.d,t2.e) in ((3,3),(7,7),(2,2))",
+ "attached_condition": "(t2.d,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((2,2)))",
"mrr_type": "Rowid-ordered scan"
},
"table": {
@@ -2588,7 +2588,7 @@ EXPLAIN
"ref": ["test.t1.a"],
"rows": 12,
"filtered": 100,
- "attached_condition": "(t1.a,t2.e) in ((3,3),(7,7),(8,8)) and length(t2.f) = 1"
+ "attached_condition": "(t1.a,t2.e) in (<cache>((3,3)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1"
}
}
}
@@ -2673,7 +2673,7 @@ EXPLAIN
"used_key_parts": ["e"],
"rows": 6,
"filtered": 100,
- "attached_condition": "(t2.d,t2.e) in ((4,4),(7,7),(8,8)) and length(t2.f) = 1 and t2.d is not null",
+ "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1 and t2.d is not null",
"mrr_type": "Rowid-ordered scan"
},
"table": {
@@ -2724,7 +2724,7 @@ EXPLAIN
"rows": 5,
"filtered": 100,
"index_condition": "t2.d is not null",
- "attached_condition": "(t2.d,t2.e) in ((4,4),(7,7),(8,8)) and length(t2.f) = 1",
+ "attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1",
"mrr_type": "Rowid-ordered scan"
},
"table": {
@@ -2840,7 +2840,7 @@ EXPLAIN
"ref": ["test.t1.a"],
"rows": 3,
"filtered": 100,
- "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),(7,7),(8,8)) and length(t2.f) = 1"
+ "attached_condition": "(t1.a,t2.e) in ((t2.e,t1.a + 1),<cache>((7,7)),<cache>((8,8))) and length(t2.f) = 1"
}
}
}
@@ -2880,7 +2880,7 @@ EXPLAIN
"rows": 13,
"filtered": 100,
"index_condition": "t1.a is not null",
- "attached_condition": "(t1.a,2) in ((2,2),(7,7),(8,8)) and length(t1.c) = 1",
+ "attached_condition": "(t1.a,2) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and length(t1.c) = 1",
"mrr_type": "Rowid-ordered scan"
},
"table": {
@@ -2969,7 +2969,7 @@ EXPLAIN
"rows": 13,
"filtered": 100,
"index_condition": "t1.a is not null",
- "attached_condition": "(t1.a,1 + 1) in ((2,2),(7,7),(8,8)) and length(t1.c) = 1",
+ "attached_condition": "(t1.a,1 + 1) in (<cache>((2,2)),<cache>((7,7)),<cache>((8,8))) and length(t1.c) = 1",
"mrr_type": "Rowid-ordered scan"
},
"table": {
diff --git a/mysql-test/r/sp-group.result b/mysql-test/r/sp-group.result
index db118496e9a..0fc8d45c5b1 100644
--- a/mysql-test/r/sp-group.result
+++ b/mysql-test/r/sp-group.result
@@ -3,7 +3,7 @@ Warnings:
Note 1051 Unknown table 'test.t1'
drop view if exists view_t1;
Warnings:
-Note 4067 Unknown VIEW: 'test.view_t1'
+Note 4068 Unknown VIEW: 'test.view_t1'
SET sql_mode=ONLY_FULL_GROUP_BY;
CREATE TABLE t1 (
pk INT,
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 3312a46dc88..5f1f8f92d50 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -3211,7 +3211,7 @@ drop procedure bug10961|
DROP PROCEDURE IF EXISTS bug6866|
DROP VIEW IF EXISTS tv|
Warnings:
-Note 4067 Unknown VIEW: 'test.tv'
+Note 4068 Unknown VIEW: 'test.tv'
DROP TABLE IF EXISTS tt1,tt2,tt3|
Warnings:
Note 1051 Unknown table 'test.tt1'
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 7bdc01a8aa4..b83ee20e784 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -7204,3 +7204,17 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
diff --git a/mysql-test/r/subselect_no_exists_to_in.result b/mysql-test/r/subselect_no_exists_to_in.result
index 8bbe6e3cf70..87f33d1dbf4 100644
--- a/mysql-test/r/subselect_no_exists_to_in.result
+++ b/mysql-test/r/subselect_no_exists_to_in.result
@@ -7204,6 +7204,20 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
set optimizer_switch=default;
select @@optimizer_switch like '%exists_to_in=off%';
@@optimizer_switch like '%exists_to_in=off%'
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index 5aab2e75134..626990f2c9e 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -7197,6 +7197,20 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 3b66d3efdbf..3637604646f 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -7195,4 +7195,18 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
set @optimizer_switch_for_subselect_test=null;
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index 9f0234015bc..afebd27c192 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -7210,6 +7210,20 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%'
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index a43cfd11b23..0f0fc59341e 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -7195,5 +7195,19 @@ f1 f2 f3
DROP TABLE t1, t2;
SET NAMES default;
End of 10.1 tests
+#
+# MDEV-12564: IN TO EXISTS transformation for rows after
+# conversion an outer join to inner join
+#
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+pk i c pk i c
+1 10 foo 1 10 foo
+DROP TABLE t;
+End of 10.2 tests
set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL;
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 4b0e4a61c64..7c7494903b6 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -429,17 +429,26 @@ select @a;
#
# BUG LP:1008487 virtual bool Item_cache::is_expensive(): Assertion `example' failed
#
+SET TIMESTAMP=UNIX_TIMESTAMP('2017-01-03 00:00:00');
create table t1(a date,key(a));
insert into t1 values ('2012-01-01'),('2012-02-02');
explain
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1_0 ref a a 4 const 0 Using where; Using index
+1 SIMPLE t1_0 ref a a 4 const 1 Using where; Using index
1 SIMPLE t2 index NULL a 4 NULL 2 Using index; Using join buffer (flat, BNL join)
1 SIMPLE t1 index NULL a 4 NULL 2 Using index; Using join buffer (incremental, BNL join)
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
1
+SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-03 00:00:01');
+explain
+select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
+1
drop table t1;
+SET TIMESTAMP=DEFAULT;
#
# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
# MDEV-9972 Least function retuns date in date time format
@@ -845,3 +854,27 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
+#
+# Start of 10.3 tests
+#
+#
+# MDEV-12721 Wrong execution plan for WHERE (date_field <=> timestamp_expr AND TRUE)
+#
+CREATE TABLE t1(a DATE,KEY(a));
+INSERT INTO t1 VALUES ('2012-01-01'),('2012-02-02');
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP'2001-01-01 00:00:01' AND TRUE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP('2001-01-01', '00:00:01') AND TRUE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP'2001-01-01 00:00:00' AND TRUE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 4 const 1 Using where; Using index
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP('2001-01-01', '00:00:00') AND TRUE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 4 const 1 Using where; Using index
+DROP TABLE t1;
+#
+# End of 10.3 tests
+#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index a5b727a8a50..14b92e93133 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -5242,7 +5242,7 @@ CREATE TABLE t4 (i4 INT);
INSERT INTO t4 VALUES (1),(2);
DROP VIEW IF EXISTS v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
CREATE VIEW v1 AS select coalesce(j1,i3) AS v1_field1 from t2 join t3 left join t1 on ( i1 = i2 );
CREATE VIEW v2 AS select v1_field1 from t4 join v1;
prepare my_stmt from "select v1_field1 from v2";
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 26194bc5990..ec83998aa98 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3055,3 +3055,33 @@ name row_cnt pct_of_total
Fred 2 66.67
Joe 1 33.33
drop table t1;
+#
+# MDEV-11990: window function over min/max aggregation
+#
+create table t1 (id int);
+insert into t1 values (1), (2), (3), (2), (4), (2);
+select sum(max(id)) over (order by max(id)) from t1;
+sum(max(id)) over (order by max(id))
+4
+explain
+select sum(max(id)) over (order by max(id)) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary
+create index idx on t1(id);
+select sum(max(id)) over (order by max(id)) from t1;
+sum(max(id)) over (order by max(id))
+4
+explain
+select sum(max(id)) over (order by max(id)) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+select sum(max(id)) over (order by max(id)) from t1 where id < 3;
+sum(max(id)) over (order by max(id))
+2
+select count(max(id)) over (order by max(id)) from t1 where id < 3;
+count(max(id)) over (order by max(id))
+1
+select max(id), rank() over (order by max(id)) from t1 where id < 3;
+max(id) rank() over (order by max(id))
+2 1
+drop table t1;
diff --git a/mysql-test/std_data/loaddata/mdev12696.xml b/mysql-test/std_data/loaddata/mdev12696.xml
new file mode 100644
index 00000000000..a2789acbde5
--- /dev/null
+++ b/mysql-test/std_data/loaddata/mdev12696.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+
+<resultset statement="SELECT 'test' AS c1, NULL AS c2
+" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <row>
+ <field name="c1">test</field>
+ <field name="c2" xsi:nil="true" />
+ </row>
+</resultset>
diff --git a/mysql-test/suite/binlog/r/flashback.result b/mysql-test/suite/binlog/r/flashback.result
index a7973b36ddd..ae8b583fc7a 100644
--- a/mysql-test/suite/binlog/r/flashback.result
+++ b/mysql-test/suite/binlog/r/flashback.result
@@ -502,4 +502,9 @@ a b
2 1
3 2
4 3
+SET binlog_format=statement;
+Warnings:
+Warning 1105 MariaDB Galera and flashback do not support binlog format: STATEMENT
+SET GLOBAL binlog_format=statement;
+ERROR HY000: Flashback does not support binlog_format STATEMENT
DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/flashback.test b/mysql-test/suite/binlog/t/flashback.test
index 2f395a2a7b1..8ef38dbcb9f 100644
--- a/mysql-test/suite/binlog/t/flashback.test
+++ b/mysql-test/suite/binlog/t/flashback.test
@@ -160,4 +160,8 @@ let $MYSQLD_DATADIR= `select @@datadir`;
SELECT * FROM t1;
+SET binlog_format=statement;
+--error ER_FLASHBACK_NOT_SUPPORTED
+SET GLOBAL binlog_format=statement;
+
DROP TABLE t1;
diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result
index 294e0695226..dfe46bbf645 100644
--- a/mysql-test/suite/funcs_1/r/innodb_views.result
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result
@@ -4314,7 +4314,7 @@ CREATE VIEW v2 AS Select * from test.v1;
ERROR 42S02: Table 'test.v1' doesn't exist
DROP VIEW IF EXISTS v2;
Warnings:
-Note 4067 Unknown VIEW: 'test.v2'
+Note 4068 Unknown VIEW: 'test.v2'
Testcase 3.3.1.25
--------------------------------------------------------------------------------
@@ -7566,7 +7566,7 @@ Call sp1() ;
ERROR 42000: PROCEDURE test.sp1 does not exist
Drop view if exists test.v1 ;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
@@ -21312,7 +21312,7 @@ CREATE VIEW v1 AS SELECT f1 FROM t1;
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
Testcase 3.3.1.68
--------------------------------------------------------------------------------
diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result
index 87465035980..b81ea2f309b 100644
--- a/mysql-test/suite/funcs_1/r/memory_views.result
+++ b/mysql-test/suite/funcs_1/r/memory_views.result
@@ -4315,7 +4315,7 @@ CREATE VIEW v2 AS Select * from test.v1;
ERROR 42S02: Table 'test.v1' doesn't exist
DROP VIEW IF EXISTS v2;
Warnings:
-Note 4067 Unknown VIEW: 'test.v2'
+Note 4068 Unknown VIEW: 'test.v2'
Testcase 3.3.1.25
--------------------------------------------------------------------------------
@@ -7567,7 +7567,7 @@ Call sp1() ;
ERROR 42000: PROCEDURE test.sp1 does not exist
Drop view if exists test.v1 ;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
Drop procedure sp1 ;
ERROR 42000: PROCEDURE test.sp1 does not exist
@@ -21314,7 +21314,7 @@ CREATE VIEW v1 AS SELECT f1 FROM t1;
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
-Note 4067 Unknown VIEW: 'test.v1'
+Note 4068 Unknown VIEW: 'test.v1'
Testcase 3.3.1.68
--------------------------------------------------------------------------------
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 20c1cb39f87..6c3efc77e20 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -36,3 +36,25 @@ galera_sst_xtrabackup-v2 : MDEV-11208
galera_sst_xtrabackup-v2_encrypt_with_key : MDEV-11208
mysql-wsrep#33 : TODO: investigate
galera_var_innodb_disallow_writes : MDEV-10949
+MW-258 : MDEV-11229
+galera_as_master : MDEV-11229
+MW-44 : MDEV-11229
+galera_gcs_fc_limit : MDEV-11229
+galera_roles : MDEV-11229
+galera_lock_table : MDEV-11229
+GAL-480 : Investigate
+galera_fk_no_pk :Investigate
+galera_account_management : Investigate
+galera.galera_var_retry_autocommit : MDEV-12319 #Sparodic Faliure
+galera.galera_gcs_fc_limit : MDEV-12319 #Sparodic Faliure
+galera.galera_toi_ddl_nonconflicting : MDEV-12319 #Sparodic Faliure
+galera.mysql-wsrep#198 : MDEV-12319 #Sparodic Faliure
+galera.galera_pc_ignore_sb : MDEV-12319 #Sparodic Faliure
+galera.MW-329 : MDEV-12319 #Sparodic Faliure
+galera.galera_ist_recv_bind : MDEV-12319 #Failed to start mysqld
+galera.galera_ist_restart_joiner : MDEV-12319 #Failed to start mysqld
+galera.galera_ssl_compression : MDEV-12319 #Failed to start mysqld
+galera.galera_wan : MDEV-12319 #Failed to start mysqld
+galera.rpl_row_annotate : MDEV-12319 #Failed to start mysqld
+galera_restart_on_unknown_option : Solve
+galera_kill_applier : Investigate; problem introduced in merge from 10.1
diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf
index e5cf769a910..34bf1fc58fe 100644
--- a/mysql-test/suite/galera/galera_2nodes.cnf
+++ b/mysql-test/suite/galera/galera_2nodes.cnf
@@ -25,7 +25,14 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port'
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
-wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S'
+wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf
new file mode 100644
index 00000000000..716a790fea6
--- /dev/null
+++ b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf
@@ -0,0 +1,83 @@
+
+#
+# Let's understand the topology.
+# * Independent Master with server-id = 1
+# * Galera cluster with 2 nodes: node#1 and node#2 with server-id = 2, 3
+# node#1 act as slave to Independent Master with server-id = 1
+# * Independent Slave with server-id = 4 replicating from galera node#2
+#
+
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld]
+log-slave-updates
+log-bin=mysqld-bin
+binlog-format=row
+gtid-mode=on
+enforce-gtid-consistency=true
+
+[mysqld.1]
+server-id=1
+
+[mysqld.2]
+server-id=2
+
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://'
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.3]
+server-id=3
+
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
+wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.4]
+server-id=4
+
+[ENV]
+NODE_MYPORT_1= @mysqld.1.port
+NODE_MYSOCK_1= @mysqld.1.socket
+
+NODE_MYPORT_2= @mysqld.2.port
+NODE_MYSOCK_2= @mysqld.2.socket
+
+NODE_MYPORT_3= @mysqld.3.port
+NODE_MYSOCK_3= @mysqld.3.socket
+
+NODE_MYPORT_4= @mysqld.4.port
+NODE_MYSOCK_4= @mysqld.4.socket
+
+NODE_GALERAPORT_2= @mysqld.2.#galera_port
+NODE_GALERAPORT_3= @mysqld.3.#galera_port
+
+NODE_SSTPORT_2= @mysqld.2.#sst_port
+NODE_SSTPORT_3= @mysqld.3.#sst_port
diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf
new file mode 100644
index 00000000000..5f0af2e58e5
--- /dev/null
+++ b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf
@@ -0,0 +1,87 @@
+#
+# This .cnf file creates a setup with a 2-node Galera cluster and one stand-alone MySQL server, to be used as a slave
+#
+
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld]
+default-storage-engine=InnoDB
+
+[mysqld.1]
+server-id=1
+binlog-format=row
+log-bin=mysqld-bin
+log_slave_updates
+gtid-mode=on
+enforce-gtid-consistency=true
+event-scheduler=1
+
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://'
+wsrep_provider_options='base_port=@mysqld.1.#galera_port'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.2]
+server-id=2
+binlog-format=row
+log-bin=mysqld-bin
+log_slave_updates
+gtid-mode=on
+enforce-gtid-consistency=true
+event-scheduler=1
+
+wsrep_provider=@ENV.WSREP_PROVIDER
+wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
+wsrep_provider_options='base_port=@mysqld.2.#galera_port'
+
+# enforce read-committed characteristics across the cluster
+wsrep_causal_reads=ON
+wsrep_sync_wait = 7
+
+wsrep_node_address=127.0.0.1
+wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
+wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
+
+# Required for Galera
+innodb_autoinc_lock_mode=2
+
+innodb_flush_log_at_trx_commit=2
+
+[mysqld.3]
+server-id=3
+replicate-ignore-db=test
+replicate-wild-ignore-table=test.%
+log-bin=mysqld-bin
+log_slave_updates
+gtid-mode=on
+enforce-gtid-consistency=true
+event-scheduler=1
+
+[ENV]
+NODE_MYPORT_1= @mysqld.1.port
+NODE_MYSOCK_1= @mysqld.1.socket
+
+NODE_MYPORT_2= @mysqld.2.port
+NODE_MYSOCK_2= @mysqld.2.socket
+
+NODE_MYPORT_3= @mysqld.3.port
+NODE_MYSOCK_3= @mysqld.3.socket
+
+NODE_GALERAPORT_1= @mysqld.1.#galera_port
+NODE_GALERAPORT_2= @mysqld.2.#galera_port
+
+NODE_SSTPORT_1= @mysqld.1.#sst_port
+NODE_SSTPORT_2= @mysqld.2.#sst_port
diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result
new file mode 100644
index 00000000000..b2ecd1c2bfa
--- /dev/null
+++ b/mysql-test/suite/galera/r/GAL-401.result
@@ -0,0 +1,24 @@
+SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true';
+connection node_2;
+SET @@global.wsrep_desync = 1;
+SET SESSION wsrep_dirty_reads=1;
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+connection node_1;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+connection node_2;
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+SHOW STATUS LIKE 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 0
+SET @@global.wsrep_desync = 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` char(1) DEFAULT NULL,
+ PRIMARY KEY (`f1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored.");
+connection node_1;
+SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=false';
diff --git a/mysql-test/suite/galera/r/GAL-419.result b/mysql-test/suite/galera/r/GAL-419.result
new file mode 100644
index 00000000000..410c91b4f98
--- /dev/null
+++ b/mysql-test/suite/galera/r/GAL-419.result
@@ -0,0 +1,4 @@
+SET SESSION wsrep_sync_wait = 0;
+Killing server ...
+SET SESSION wsrep_sync_wait = 0;
+Killing server ...
diff --git a/mysql-test/suite/galera/r/GAL-480.result b/mysql-test/suite/galera/r/GAL-480.result
new file mode 100644
index 00000000000..b762e07423e
--- /dev/null
+++ b/mysql-test/suite/galera/r/GAL-480.result
@@ -0,0 +1,39 @@
+CREATE TABLE t1 (f1 CHAR(10), f0 integer) ENGINE=InnoDB;
+FLUSH TABLE t1 FOR EXPORT;
+UNLOCK TABLES;
+ALTER TABLE t1 DROP COLUMN f1;
+SET SESSION wsrep_osu_method='RSU';
+ALTER TABLE t1 ADD COLUMN f1 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f1;
+ALTER TABLE t1 ADD COLUMN f2 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f2;
+ALTER TABLE t1 ADD COLUMN f3 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f3;
+ALTER TABLE t1 ADD COLUMN f4 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f4;
+ALTER TABLE t1 ADD COLUMN f5 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f5;
+ALTER TABLE t1 ADD COLUMN f6 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f6;
+ALTER TABLE t1 ADD COLUMN f7 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f7;
+ALTER TABLE t1 ADD COLUMN f8 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f8;
+ALTER TABLE t1 ADD COLUMN f9 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f9;
+ALTER TABLE t1 ADD COLUMN f10 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f10;
+ALTER TABLE t1 ADD COLUMN f11 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f11;
+ALTER TABLE t1 ADD COLUMN f12 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f12;
+ALTER TABLE t1 ADD COLUMN f13 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f13;
+ALTER TABLE t1 ADD COLUMN f14 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f14;
+ALTER TABLE t1 ADD COLUMN f15 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f15;
+ALTER TABLE t1 ADD COLUMN f16 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f16;
+SET SESSION wsrep_osu_method='TOI';
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/MW-313.result b/mysql-test/suite/galera/r/MW-313.result
new file mode 100644
index 00000000000..dc605ffc370
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-313.result
@@ -0,0 +1,32 @@
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+SET GLOBAL wsrep_max_ws_rows = 2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+SELECT * FROM t1 GROUP BY f1;
+f1
+1
+SELECT * FROM t1 GROUP BY f1;
+f1
+1
+SELECT * FROM t1 GROUP BY f1;
+f1
+1
+SHOW STATUS LIKE '%wsrep%';
+INSERT INTO t1 SELECT * FROM t1;
+ERROR HY000: wsrep_max_ws_rows exceeded
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES (1);
+INSERT INTO t1 (f1) VALUES (2),(3),(4);
+ERROR HY000: wsrep_max_ws_rows exceeded
+ROLLBACK;
+START TRANSACTION;
+DELETE FROM t1;
+ERROR HY000: wsrep_max_ws_rows exceeded
+DROP TABLE t1;
+SET GLOBAL wsrep_max_ws_rows = 0;
diff --git a/mysql-test/suite/galera/r/MW-328A.result b/mysql-test/suite/galera/r/MW-328A.result
new file mode 100644
index 00000000000..db0301b6bf2
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-328A.result
@@ -0,0 +1,27 @@
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+INSERT INTO t1 (f1) VALUES (1);
+CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB;
+CREATE PROCEDURE proc_update ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4);
+END WHILE;
+END|
+connect node_1X, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1X;
+CALL proc_update();;
+connection node_2;
+SET SESSION wsrep_retry_autocommit = 0;
+have_successes
+1
+have_deadlocks
+1
+connection node_1;
+connection node_1X;
+Got one of the listed errors
+connection node_1;
+DROP PROCEDURE proc_update;
+DROP TABLE t1, t2;
+CALL mtr.add_suppression("conflict state 3 after post commit");
diff --git a/mysql-test/suite/galera/r/MW-328B.result b/mysql-test/suite/galera/r/MW-328B.result
new file mode 100644
index 00000000000..e898e315ca8
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-328B.result
@@ -0,0 +1,23 @@
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+INSERT INTO t1 (f1) VALUES (1);
+CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB;
+CREATE PROCEDURE proc_update ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4);
+END WHILE;
+END|
+connect node_1X, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1X;
+CALL proc_update();;
+connection node_2;
+SET SESSION wsrep_retry_autocommit = 0;
+connection node_1;
+connection node_1X;
+Got one of the listed errors
+connection node_1;
+DROP PROCEDURE proc_update;
+DROP TABLE t1, t2;
+CALL mtr.add_suppression("conflict state 3 after post commit");
diff --git a/mysql-test/suite/galera/r/MW-328C.result b/mysql-test/suite/galera/r/MW-328C.result
new file mode 100644
index 00000000000..d8e164e7b4a
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-328C.result
@@ -0,0 +1,23 @@
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+INSERT INTO t1 (f1) VALUES (1);
+CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB;
+CREATE PROCEDURE proc_update ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4);
+END WHILE;
+END|
+connect node_1X, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1X;
+CALL proc_update();;
+connection node_2;
+SET SESSION wsrep_retry_autocommit = 10000;
+connection node_1;
+connection node_1X;
+Got one of the listed errors
+connection node_1;
+DROP PROCEDURE proc_update;
+DROP TABLE t1, t2;
+CALL mtr.add_suppression("conflict state 3 after post commit");
diff --git a/mysql-test/suite/galera/r/MW-328D.result b/mysql-test/suite/galera/r/MW-328D.result
new file mode 100644
index 00000000000..6562136ec27
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-328D.result
@@ -0,0 +1,20 @@
+CREATE TABLE t1 (i INT) ENGINE = InnoDB;
+INSERT INTO t1 (i) VALUES(1);
+CREATE TABLE t2 (i INT) ENGINE = InnoDB;
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+SELECT * FROM t1 WHERE i = 1 LOCK IN SHARE MODE;
+i
+1
+connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1a;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE i = 1 FOR UPDATE;;
+connection node_1;
+DELETE FROM t1 WHERE i = 1;
+COMMIT;
+connection node_1a;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/galera/r/MW-328E.result b/mysql-test/suite/galera/r/MW-328E.result
new file mode 100644
index 00000000000..89654ec066a
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-328E.result
@@ -0,0 +1,20 @@
+create table t1 (i int primary key, j int) engine=innodb;
+create table t2 (i int primary key, j int) engine=innodb;
+insert into t1 values (1,0);
+insert into t2 values (2,0);
+set autocommit=off;
+start transaction;
+update t1 set j=1 where i=1;
+connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1a;
+set autocommit=off;
+start transaction;
+begin;
+update t2 set j=1 where i=2;
+connection node_1;
+insert into t1 select * from t2;;
+connection node_1a;
+insert into t2 select * from t1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result
new file mode 100644
index 00000000000..655d8e9e291
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-329.result
@@ -0,0 +1,20 @@
+CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+INSERT INTO t1 (f1) VALUES (1),(65535);
+FLUSH STATUS;
+SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
+VARIABLE_VALUE = 0
+1
+CREATE PROCEDURE proc_insert ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 ));
+END WHILE;
+END|
+CALL proc_insert();;
+SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
+VARIABLE_VALUE > 0
+1
+DROP PROCEDURE proc_insert;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/ev51914.result b/mysql-test/suite/galera/r/ev51914.result
new file mode 100644
index 00000000000..3f3d67d01ef
--- /dev/null
+++ b/mysql-test/suite/galera/r/ev51914.result
@@ -0,0 +1,173 @@
+connection node_1;
+SAVEPOINT in a stored function should be forbidden
+CREATE FUNCTION f1 () RETURNS INT BEGIN
+SAVEPOINT s;
+RETURN 1;
+END|
+SELECT f1();
+f1()
+1
+DROP FUNCTION f1;
+ROLLBACK TO SAVEPOINT in a stored function should be forbidden
+CREATE FUNCTION f2 () RETURNS INT BEGIN
+ROLLBACK TO SAVEPOINT s;
+RETURN 1;
+END|
+BEGIN;
+SAVEPOINT s;
+SELECT f2();
+ERROR 42000: SAVEPOINT s does not exist
+COMMIT;
+DROP FUNCTION f2;
+BEGIN;
+SAVEPOINT S;
+ROLLBACK TO SAVEPOINT S;
+COMMIT;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 values (110), (111), (112), (113), (114);
+Direct SAVEPOINT in a trigger should be forbidden
+connection node_2;
+CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s;
+connection node_1;
+INSERT INTO t1 VALUES (1);
+DROP TRIGGER i1_t1;
+CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s;
+INSERT INTO t1 VALUES (2);
+DROP TRIGGER i2_t1;
+INSERT INTO t1 VALUES (3);
+CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
+UPDATE t1 SET a=4 WHERE a=3;
+DROP TRIGGER u1_t1;
+CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
+UPDATE t1 SET a=4 WHERE a=3;
+DROP TRIGGER u2_t1;
+CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s;
+DELETE FROM t1;
+DROP TRIGGER d1_t1;
+CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s;
+DELETE FROM t1;
+DROP TRIGGER d1_t1;
+SAVEPOINT in a compound statement in a trigger should be forbidden
+CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
+SAVEPOINT s;
+END|
+INSERT INTO t1 VALUES (5);
+DROP TRIGGER i3_t1;
+SAVEPOINT in a PS call in a trigger should be forbidden
+CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
+PREPARE set_savepoint FROM "SAVEPOINT s";
+EXECUTE set_savepoint;
+DEALLOCATE PREPARE set_savepoint;
+END|
+ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
+connection node_2;
+SAVEPOINT in SP called from a trigger should be forbidden
+CREATE PROCEDURE p1() BEGIN
+SAVEPOINT s;
+END|
+connection node_1;
+CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
+INSERT INTO t1 VALUES (6);
+DROP TRIGGER i5_t1;
+SAVEPOINT in a SP called from a PS called from a trigger be forbidden
+PREPARE call_p1 FROM "CALL p1";
+CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1;
+ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
+SAVEPOINT in a function called from a trigger should be forbidden
+CREATE FUNCTION f1 () RETURNS INT BEGIN
+SAVEPOINT s;
+RETURN 1;
+END|
+CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1();
+INSERT INTO t1 VALUES (7);
+DROP TRIGGER i7_t1;
+SAVEPOINT in a SP called from a SP called from a trigger should be forbidden
+CREATE PROCEDURE p2() BEGIN
+CALL p1();
+END|
+CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2;
+INSERT INTO t1 VALUES (8);
+DROP TRIGGER i8_t1;
+SAVEPOINT in a SP called from a trigger called from a SP should be forbidden
+CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
+CREATE PROCEDURE p3() BEGIN
+INSERT INTO t1 VALUES (9);
+END|
+CALL p3();
+DROP TRIGGER i9_t1;
+ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden
+CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s;
+BEGIN;
+SAVEPOINT s;
+INSERT INTO t1 VALUES (5);
+ERROR 42000: SAVEPOINT s does not exist
+COMMIT;
+DROP TRIGGER i4_t1;
+ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden
+CREATE PROCEDURE p4() BEGIN
+ROLLBACK TO SAVEPOINT s;
+END|
+CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4;
+BEGIN;
+SAVEPOINT s;
+INSERT INTO t1 VALUES (6);
+ERROR 42000: SAVEPOINT s does not exist
+COMMIT;
+DROP TRIGGER i5_t1;
+SAVEPOINT in a SP next to a trigger should work
+CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1;
+CREATE PROCEDURE p5() BEGIN
+SAVEPOINT s;
+INSERT INTO t1 VALUES (10);
+ROLLBACK TO SAVEPOINT s;
+END|
+BEGIN;
+CALL p5();
+COMMIT;
+DROP TRIGGER i6_t1;
+connection node_2;
+create trigger t1 before insert on t1 for each row
+begin
+insert into t2 values (NULL);
+end|
+connection node_1;
+INSERT INTO t1 VALUES (201), (202), (203);
+connection node_1;
+SELECT * FROM t1;
+a
+5
+6
+7
+8
+9
+201
+202
+203
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+3
+connection node_2;
+SELECT * FROM t1;
+a
+5
+6
+7
+8
+9
+201
+202
+203
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+3
+connection node_1;
+DEALLOCATE PREPARE call_p1;
+connection node_2;
+DROP TABLE t1, t2;
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP FUNCTION f1;
diff --git a/mysql-test/suite/galera/r/galera_account_management.result b/mysql-test/suite/galera/r/galera_account_management.result
index 7fb472a5c2d..6c81d401136 100644
--- a/mysql-test/suite/galera/r/galera_account_management.result
+++ b/mysql-test/suite/galera/r/galera_account_management.result
@@ -5,6 +5,15 @@ SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2');
COUNT(*) = 2
1
connection node_1;
+ALTER USER user1 PASSWORD EXPIRE;
+SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
+password_expired = 'Y'
+1
+connection node_2;
+SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
+password_expired = 'Y'
+1
+connection node_1;
RENAME USER user2 TO user3;
connection node_2;
SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2';
diff --git a/mysql-test/suite/galera/r/galera_admin.result b/mysql-test/suite/galera/r/galera_admin.result
new file mode 100644
index 00000000000..ed753247236
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_admin.result
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS t1, t2;
+DROP TABLE IF EXISTS x1, x2;
+connection node_1;
+CREATE TABLE t1 (f1 INTEGER);
+CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
+SET GLOBAL wsrep_replicate_myisam = TRUE;
+CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
+INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+connection node_2;
+# ANALYZE test
+connection node_2;
+connection node_1;
+ANALYZE TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+test.t2 analyze status OK
+connection node_2;
+# OPTIMIZE test
+connection node_2;
+connection node_1;
+OPTIMIZE TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
+test.t1 optimize status OK
+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
+test.t2 optimize status OK
+connection node_2;
+# REPAIR test
+connection node_2;
+connection node_1;
+REPAIR TABLE x1, x2;
+Table Op Msg_type Msg_text
+test.x1 repair status OK
+test.x2 repair status OK
+connection node_2;
+connection node_2;
+SELECT COUNT(*) = 10 FROM t1;
+COUNT(*) = 10
+1
+SELECT COUNT(*) = 10 FROM x1;
+COUNT(*) = 10
+1
+SELECT COUNT(*) = 10000 FROM t2;
+COUNT(*) = 10000
+1
+SELECT COUNT(*) = 10 FROM x2;
+COUNT(*) = 10
+1
+connection node_1;
+DROP TABLE t1, t2;
+DROP TABLE x1, x2;
+SET GLOBAL wsrep_replicate_myisam = FALSE;
diff --git a/mysql-test/suite/galera/r/galera_bf_abort.result b/mysql-test/suite/galera/r/galera_bf_abort.result
index c55f1a4dfcb..cc750f05050 100644
--- a/mysql-test/suite/galera/r/galera_bf_abort.result
+++ b/mysql-test/suite/galera/r/galera_bf_abort.result
@@ -1,9 +1,9 @@
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (1,'node_2');
+INSERT INTO t1 VALUES (1,'node_1');
+INSERT INTO t1 VALUES (2, 'node_2');
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
wsrep_local_aborts_increment
1
diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result
index b6a16f72ec3..cb306734002 100644
--- a/mysql-test/suite/galera/r/galera_defaults.result
+++ b/mysql-test/suite/galera/r/galera_defaults.result
@@ -50,7 +50,7 @@ WSREP_SST_DONOR
WSREP_SST_DONOR_REJECTS_QUERIES OFF
WSREP_SST_METHOD rsync
WSREP_SYNC_WAIT 7
-<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <GCS_RECV_Q_HARD_LIMIT>; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992;
+<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <RECV_Q_HARD_LIMIT>;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME LIKE 'wsrep_%'
AND VARIABLE_NAME != 'wsrep_debug_sync_waiters';
diff --git a/mysql-test/suite/galera/r/galera_desync_overlapped.result b/mysql-test/suite/galera/r/galera_desync_overlapped.result
new file mode 100644
index 00000000000..f9920e7f7ad
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_desync_overlapped.result
@@ -0,0 +1,50 @@
+connection node_1;
+CREATE TABLE ten (f1 INTEGER);
+INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
+CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
+SET GLOBAL wsrep_desync = 1;
+show status like 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 1
+SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2';
+INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
+connection node_1a;
+SET GLOBAL wsrep_desync = 1;
+Warnings:
+Warning 1231 'wsrep_desync' is already ON.
+show status like 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 1
+SET DEBUG_SYNC='now WAIT_FOR alter1';
+SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2';
+INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
+connection node_1;
+connection node_1a;
+connection node_1;
+SET DEBUG_SYNC='RESET';
+SET GLOBAL wsrep_desync = 0;
+show status like 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 0
+SET GLOBAL wsrep_desync = 0;
+Warnings:
+Warning 1231 'wsrep_desync' is already OFF.
+show status like 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 0
+show status like 'wsrep_desync_count';
+Variable_name Value
+wsrep_desync_count 0
+SET GLOBAL wsrep_desync = 0;
+Warnings:
+Warning 1231 'wsrep_desync' is already OFF.
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+1000
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/r/galera_gcache_recover.result b/mysql-test/suite/galera/r/galera_gcache_recover.result
new file mode 100644
index 00000000000..127bcba39d8
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_gcache_recover.result
@@ -0,0 +1,18 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+SET SESSION wsrep_sync_wait = 0;
+SET SESSION wsrep_sync_wait = 0;
+Killing server ...
+INSERT INTO t1 VALUES (2);
+Killing server ...
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+INSERT INTO t1 VALUES (3);
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+include/diff_servers.inc [servers=1 2]
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+include/assert_grep.inc [async IST sender starting to serve]
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence]
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result
new file mode 100644
index 00000000000..30ee5772411
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result
@@ -0,0 +1,19 @@
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB;
+SET SESSION wsrep_sync_wait = 0;
+Killing server ...
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+Killing server ...
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+include/diff_servers.inc [servers=1 2]
+DROP TABLE t1;
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+include/assert_grep.inc [IST first seqno 2 not found from cache, falling back to SST]
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result
new file mode 100644
index 00000000000..868b39bfbd6
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result
@@ -0,0 +1,107 @@
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB;
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+CREATE PROCEDURE insert_simple ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f1, f2) VALUES (DEFAULT,'abcdef');
+END WHILE;
+END|
+CREATE PROCEDURE insert_multi ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f1) VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT);
+END WHILE;
+END|
+CREATE PROCEDURE insert_transaction ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+SET AUTOCOMMIT = OFF;
+WHILE 1 DO
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+INSERT INTO t1 (f1) VALUES (DEFAULT);
+COMMIT;
+END WHILE;
+END|
+CREATE PROCEDURE update_simple ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+UPDATE t1 SET f2 = CONCAT(f2,f2);
+END WHILE;
+END|
+CREATE PROCEDURE insert_1k ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024));
+END WHILE;
+END|
+CREATE PROCEDURE insert_1m ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024));
+END WHILE;
+END|
+CREATE PROCEDURE insert_10m ()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET SESSION wsrep_sync_wait = 0;
+WHILE 1 DO
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+END WHILE;
+END|
+CALL insert_simple();;
+CALL insert_multi();;
+CALL insert_transaction ();;
+CALL update_simple ();;
+CALL insert_1k ();;
+CALL insert_1m ();;
+CALL insert_10m ();;
+SET SESSION wsrep_sync_wait = 0;
+Killing server ...
+Killing server ...
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+ERROR HY000: Lost connection to MySQL server during query
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+Performing --wsrep-recover ...
+Using --wsrep-start-position when starting mysqld ...
+include/diff_servers.inc [servers=1 2]
+DROP TABLE t1;
+DROP TABLE ten;
+DROP PROCEDURE insert_simple;
+DROP PROCEDURE insert_multi;
+DROP PROCEDURE insert_transaction;
+DROP PROCEDURE update_simple;
+DROP PROCEDURE insert_1k;
+DROP PROCEDURE insert_1m;
+CALL mtr.add_suppression("conflict state 7 after post commit");
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+include/assert_grep.inc [async IST sender starting to serve]
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence]
diff --git a/mysql-test/suite/galera/r/galera_many_tables_pk.result b/mysql-test/suite/galera/r/galera_many_tables_pk.result
index 38cf19a8d8f..ade0cb91344 100644
--- a/mysql-test/suite/galera/r/galera_many_tables_pk.result
+++ b/mysql-test/suite/galera/r/galera_many_tables_pk.result
@@ -1,7 +1,7 @@
connection node_1;
connection node_2;
-SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%';
-COUNT(*) = 900
+SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%';
+COUNT(*) = 100
1
connection node_1;
SET AUTOCOMMIT=OFF;
@@ -9,8 +9,8 @@ START TRANSACTION;
COMMIT;
connection node_2;
CREATE TABLE sum_table (f1 INTEGER);
-SELECT SUM(f1) = 900 FROM sum_table;
-SUM(f1) = 900
+SELECT SUM(f1) = 100 FROM sum_table;
+SUM(f1) = 100
1
connection node_1;
SET AUTOCOMMIT=OFF;
@@ -18,11 +18,12 @@ START TRANSACTION;
connection node_2;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
-UPDATE t900 SET f1 = 3;
+UPDATE t100 SET f1 = 3;
connection node_1;
COMMIT;
connection node_2;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+include/diff_servers.inc [servers=1 2]
DROP SCHEMA test;
CREATE SCHEMA test;
diff --git a/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result b/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result
new file mode 100644
index 00000000000..a21b1edf3e7
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_restart_on_unknown_option.result
@@ -0,0 +1,40 @@
+CALL mtr.add_suppression("Aborting");
+CALL mtr.add_suppression("unknown option '--galera-unknown-option'");
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
+SELECT * FROM t1;
+f1 f2
+1 a
+2 a
+3 a
+Shutting down server ...
+UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
+UPDATE t1 SET f2 = 'c' WHERE f1 > 2;
+SELECT * FROM t1;
+f1 f2
+1 a
+2 b
+3 c
+Starting server ...
+Starting server ...
+SELECT * FROM t1;
+f1 f2
+1 a
+2 b
+3 c
+Shutting down server ...
+UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
+UPDATE t1 SET f2 = 'd' WHERE f1 > 2;
+SELECT * FROM t1;
+f1 f2
+1 a
+2 d
+3 d
+Starting server ...
+Starting server ...
+SELECT * FROM t1;
+f1 f2
+1 a
+2 d
+3 d
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result b/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result
new file mode 100644
index 00000000000..8366cfd27c8
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_toi_ddl_fk_update.result
@@ -0,0 +1,23 @@
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+CREATE TABLE parent (
+id INT PRIMARY KEY,
+KEY (id)
+) ENGINE=InnoDB;
+CREATE TABLE child (
+id INT PRIMARY KEY AUTO_INCREMENT,
+parent_id INT
+) ENGINE=InnoDB;
+INSERT INTO parent VALUES (1);
+INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
+ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;;
+UPDATE parent SET id = 2 WHERE id = 1;;
+SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
+COUNT(*) = 10000
+1
+SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
+COUNT(*) = 10000
+1
+DROP TABLE child;
+DROP TABLE parent;
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/r/galera_toi_drop_database.result b/mysql-test/suite/galera/r/galera_toi_drop_database.result
new file mode 100644
index 00000000000..c36d4d3eedd
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_toi_drop_database.result
@@ -0,0 +1,32 @@
+connection node_1;
+CREATE DATABASE database1;
+USE database1;
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
+SET SESSION wsrep_retry_autocommit = 0;
+INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
+connection node_1a;
+USE database1;
+SET SESSION wsrep_retry_autocommit = 0;
+INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
+connection node_2;
+DROP DATABASE database1;;
+connection node_1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_1a;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_2;
+connection node_1;
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
+COUNT(*) = 0
+1
+USE database1;
+ERROR 42000: Unknown database 'database1'
+connection node_2;
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
+COUNT(*) = 0
+1
+USE database1;
+ERROR 42000: Unknown database 'database1'
diff --git a/mysql-test/suite/galera/r/galera_toi_truncate.result b/mysql-test/suite/galera/r/galera_toi_truncate.result
new file mode 100644
index 00000000000..aa407ba7610
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_toi_truncate.result
@@ -0,0 +1,22 @@
+connection node_1;
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+connection node_2;
+SET SESSION wsrep_retry_autocommit = 0;
+INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
+connection node_1;
+TRUNCATE TABLE t1;;
+connection node_1;
+connection node_2;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_2;
+SELECT COUNT(*) = 0 FROM t1;
+COUNT(*) = 0
+1
+connection node_1;
+SELECT COUNT(*) = 0 FROM t1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/r/galera_var_cluster_address.result b/mysql-test/suite/galera/r/galera_var_cluster_address.result
index 251a73a6f9a..81265f44397 100644
--- a/mysql-test/suite/galera/r/galera_var_cluster_address.result
+++ b/mysql-test/suite/galera/r/galera_var_cluster_address.result
@@ -43,6 +43,7 @@ CALL mtr.add_suppression("failed to open gcomm backend connection: 110: failed t
CALL mtr.add_suppression("Failed to open backend connection: -110 \\(Connection timed out\\)");
CALL mtr.add_suppression("gcs connect failed: Connection timed out");
CALL mtr.add_suppression("WSREP: wsrep::connect\\(foo://\\) failed: 7");
+CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7");
disconnect node_2;
disconnect node_1;
# End of test
diff --git a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result
new file mode 100644
index 00000000000..f4d17ad9a41
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result
@@ -0,0 +1,32 @@
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5);
+SET SESSION wsrep_retry_autocommit = 0;
+INSERT INTO t1 (f1) VALUES (1),(2);;
+TRUNCATE TABLE t1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+SET SESSION wsrep_retry_autocommit = 1;
+INSERT INTO t1 (f1) VALUES (3),(4);;
+TRUNCATE TABLE t1;
+SELECT * FROM test.t1;
+f1 f2
+3 0
+4 0
+CREATE PROCEDURE repeated_truncate ()
+BEGIN
+DECLARE i INT;
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+SET i = 0;
+WHILE i <= 1000 DO
+TRUNCATE TABLE t1;
+SET i = i + 1;
+END WHILE;
+END|
+CALL repeated_truncate();
+SET SESSION wsrep_retry_autocommit = 1;
+INSERT INTO t1 (f1) VALUES (5),(6);
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+SET SESSION wsrep_retry_autocommit = 1024;
+INSERT INTO t1 (f1) VALUES (7),(8);;
+include/diff_servers.inc [servers=1 2]
+DROP TABLE t1;
+DROP PROCEDURE repeated_truncate;
diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result
index c132c1bb7e2..102f7cb6386 100644
--- a/mysql-test/suite/galera/r/galera_var_slave_threads.result
+++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result
@@ -1,3 +1,4 @@
+CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread.");
connection node_1;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB;
diff --git a/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result
new file mode 100644
index 00000000000..18a857d4471
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result
@@ -0,0 +1,25 @@
+CREATE TABLE t1 (
+f1 VARCHAR(255) PRIMARY KEY
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO t1 VALUES ('abc');
+connection node_2;
+SELECT f1 = 'abc' FROM t1;
+f1 = 'abc'
+1
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+UPDATE t1 SET f1 = 'klm';
+connection node_2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+UPDATE t1 SET f1 = 'xyz';
+connection node_1;
+COMMIT;
+connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
+connection node_2a;
+connection node_2;
+COMMIT;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+include/assert_grep.inc [cluster conflict due to high priority abort for threads]
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result b/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result
new file mode 100644
index 00000000000..f19dc40205b
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_wsrep_provider_options_syntax.result
@@ -0,0 +1,5 @@
+call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'");
+call mtr.add_suppression("WSREP\: Set options returned 7");
+SET GLOBAL wsrep_provider_options="gmcasts.segment=1";
+ERROR HY000: Incorrect arguments to SET
+Unhandled exceptions: 0
diff --git a/mysql-test/suite/galera/r/lp1376747-2.result b/mysql-test/suite/galera/r/lp1376747-2.result
new file mode 100644
index 00000000000..dba3eb45af5
--- /dev/null
+++ b/mysql-test/suite/galera/r/lp1376747-2.result
@@ -0,0 +1,23 @@
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+connection node_2;
+FLUSH TABLES t1 FOR EXPORT;
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+connection node_2;
+UNLOCK TABLES;
+### t1 should have column f2
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT * from t1;
+id f2
+1 NULL
+2 3
+connection node_1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/lp1376747-3.result b/mysql-test/suite/galera/r/lp1376747-3.result
new file mode 100644
index 00000000000..a2c55b5f1f6
--- /dev/null
+++ b/mysql-test/suite/galera/r/lp1376747-3.result
@@ -0,0 +1,27 @@
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+connection node_2;
+FLUSH TABLE WITH READ LOCK;
+### This shouldn't block.
+FLUSH TABLES t1 FOR EXPORT;
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+connection node_2;
+UNLOCK TABLES;
+### t1 should have column f2
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+connection node_1;
+INSERT INTO t1 VALUES (2,3);
+connection node_2;
+SELECT * from t1;
+id f2
+1 NULL
+2 3
+connection node_1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result
new file mode 100644
index 00000000000..f1d32aa8f69
--- /dev/null
+++ b/mysql-test/suite/galera/r/lp1376747-4.result
@@ -0,0 +1,47 @@
+connection node_1;
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+connection node_2;
+SET session wsrep_sync_wait=0;
+SET session wsrep_causal_reads=OFF;
+Warnings:
+Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
+FLUSH TABLE WITH READ LOCK;
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+connection node_2a;
+SET session wsrep_sync_wait=0;
+SET session wsrep_causal_reads=OFF;
+Warnings:
+Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+FLUSH TABLES t1 WITH READ LOCK;;
+connection node_2;
+UNLOCK TABLES;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+connection node_2a;
+UNLOCK TABLES;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT * from t1;
+id f2
+1 NULL
+2 3
+connection node_1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/lp1376747.result b/mysql-test/suite/galera/r/lp1376747.result
new file mode 100644
index 00000000000..4858835c83f
--- /dev/null
+++ b/mysql-test/suite/galera/r/lp1376747.result
@@ -0,0 +1,23 @@
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+connection node_2;
+FLUSH TABLES t1 WITH READ LOCK;
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+connection node_2;
+UNLOCK TABLES;
+### t1 should have column f2
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT * from t1;
+id f2
+1 NULL
+2 3
+connection node_1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/pxc-421.result b/mysql-test/suite/galera/r/pxc-421.result
new file mode 100644
index 00000000000..4fde5a26819
--- /dev/null
+++ b/mysql-test/suite/galera/r/pxc-421.result
@@ -0,0 +1,42 @@
+connection node_1;
+set GLOBAL wsrep_slave_threads=26;
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 (f1) SELECT * from t1 as x1;
+connection node_2;
+set GLOBAL wsrep_slave_threads=16;
+SET GLOBAL wsrep_provider='none';
+INSERT INTO t1 VALUES (2);
+connection node_1;
+INSERT INTO t1 VALUES (3);
+connection node_2;
+INSERT INTO t1 VALUES (4);
+set GLOBAL wsrep_slave_threads=5;
+SELECT COUNT(*) = 5 FROM t1;
+COUNT(*) = 5
+1
+connection node_1;
+set GLOBAL wsrep_slave_threads=12;
+SELECT COUNT(*) = 4 FROM t1;
+COUNT(*) = 4
+1
+INSERT INTO t1 VALUES (100), (101), (102);
+connection node_2;
+set GLOBAL wsrep_slave_threads=5;
+INSERT INTO t1 (f1) SELECT * from t1 as x1;
+show global variables like 'wsrep_slave_threads';
+Variable_name Value
+wsrep_slave_threads 5
+SET GLOBAL wsrep_slave_threads = 1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+connection node_1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+15
+show global variables like 'wsrep_slave_threads';
+Variable_name Value
+wsrep_slave_threads 12
+SET GLOBAL wsrep_slave_threads = 1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test
new file mode 100644
index 00000000000..66015f970c9
--- /dev/null
+++ b/mysql-test/suite/galera/t/GAL-401.test
@@ -0,0 +1,51 @@
+# This tests proper desync counter cleanup when DONOR/DESYNC state is cleared.
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+# Make node 1 tolerate split-brain
+SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true';
+
+# Desync and disconnect node 2 from the PC:
+--connection node_2
+SET @@global.wsrep_desync = 1;
+SET SESSION wsrep_dirty_reads=1;
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
+--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+
+# Wait until node 2 disappears from the PC:
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+
+# Modify app state to force node 2 into PRIMARY upon reconnection.
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+
+# Reconnect node 2 to the PC:
+--connection node_2
+SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# Must return 0:
+SHOW STATUS LIKE 'wsrep_desync_count';
+
+# Resync node_2, should pass:
+SET @@global.wsrep_desync = 0;
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored.");
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=false';
diff --git a/mysql-test/suite/galera/t/GAL-419.test b/mysql-test/suite/galera/t/GAL-419.test
new file mode 100644
index 00000000000..e50b948bf35
--- /dev/null
+++ b/mysql-test/suite/galera/t/GAL-419.test
@@ -0,0 +1,35 @@
+#
+# GAL-419 safe_to_bootstrap: boostrap using wsrep_cluster_address=gcomm:// not prevented
+#
+
+--source include/galera_cluster.inc
+--source include/big_test.inc
+
+--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+--source include/kill_galera.inc
+
+--connection node_1
+SET SESSION wsrep_sync_wait = 0;
+--source include/kill_galera.inc
+
+--sleep 2
+
+# Node #1 has wsrep_cluster_address=gcomm:// in my.cnf, so should fail to bootstrap
+
+--error 1
+--exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf | grep 'This node is not safe to bootstrap the cluster'
+
+# Unless we remove grastate.dat
+
+--remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+
+--connection node_1
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/start_mysqld.inc
+--source include/wait_until_connected_again.inc
+
+--connection node_2
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
diff --git a/mysql-test/suite/galera/t/GAL-480.test b/mysql-test/suite/galera/t/GAL-480.test
new file mode 100644
index 00000000000..c2b34f2a935
--- /dev/null
+++ b/mysql-test/suite/galera/t/GAL-480.test
@@ -0,0 +1,46 @@
+--source include/galera_cluster.inc
+
+--connection node_1
+CREATE TABLE t1 (f1 CHAR(10), f0 integer) ENGINE=InnoDB;
+
+FLUSH TABLE t1 FOR EXPORT;
+UNLOCK TABLES;
+
+ALTER TABLE t1 DROP COLUMN f1;
+
+SET SESSION wsrep_osu_method='RSU';
+ALTER TABLE t1 ADD COLUMN f1 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f1;
+ALTER TABLE t1 ADD COLUMN f2 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f2;
+ALTER TABLE t1 ADD COLUMN f3 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f3;
+ALTER TABLE t1 ADD COLUMN f4 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f4;
+ALTER TABLE t1 ADD COLUMN f5 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f5;
+ALTER TABLE t1 ADD COLUMN f6 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f6;
+ALTER TABLE t1 ADD COLUMN f7 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f7;
+ALTER TABLE t1 ADD COLUMN f8 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f8;
+ALTER TABLE t1 ADD COLUMN f9 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f9;
+ALTER TABLE t1 ADD COLUMN f10 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f10;
+ALTER TABLE t1 ADD COLUMN f11 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f11;
+ALTER TABLE t1 ADD COLUMN f12 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f12;
+ALTER TABLE t1 ADD COLUMN f13 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f13;
+ALTER TABLE t1 ADD COLUMN f14 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f14;
+ALTER TABLE t1 ADD COLUMN f15 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f15;
+ALTER TABLE t1 ADD COLUMN f16 CHAR(10);
+ALTER TABLE t1 DROP COLUMN f16;
+
+SET SESSION wsrep_osu_method='TOI';
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/MW-258.test b/mysql-test/suite/galera/t/MW-258.test
index f00b82d6bb4..174dd2c02c6 100644
--- a/mysql-test/suite/galera/t/MW-258.test
+++ b/mysql-test/suite/galera/t/MW-258.test
@@ -34,7 +34,7 @@ UNLOCK TABLES;
--connection node_1
--echo value after RSU:
---sleep 2
+--sleep 3
SHOW STATUS LIKE 'wsrep_desync_count';
SHOW VARIABLES LIKE 'wsrep_desync';
SET GLOBAL wsrep_desync=0;
diff --git a/mysql-test/suite/galera/t/MW-313-master.opt b/mysql-test/suite/galera/t/MW-313-master.opt
new file mode 100644
index 00000000000..8a755e98b00
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-313-master.opt
@@ -0,0 +1 @@
+--log-bin --log-slave-updates
diff --git a/mysql-test/suite/galera/t/MW-313.test b/mysql-test/suite/galera/t/MW-313.test
new file mode 100644
index 00000000000..92fd835c615
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-313.test
@@ -0,0 +1,51 @@
+#
+# MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_row.inc
+
+# No error expected for SELECT and SHOW
+
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+
+SET GLOBAL wsrep_max_ws_rows = 2;
+
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+SELECT * FROM t1 GROUP BY f1;
+SELECT * FROM t1 GROUP BY f1;
+
+--error 0
+SELECT * FROM t1 GROUP BY f1;
+
+--disable_result_log
+--error 0
+SHOW STATUS LIKE '%wsrep%';
+--enable_result_log
+
+# Error expected for DML
+
+--error ER_ERROR_DURING_COMMIT
+INSERT INTO t1 SELECT * FROM t1;
+
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES (1);
+
+--error ER_ERROR_DURING_COMMIT
+INSERT INTO t1 (f1) VALUES (2),(3),(4);
+
+ROLLBACK;
+START TRANSACTION;
+--error ER_ERROR_DURING_COMMIT
+DELETE FROM t1;
+
+DROP TABLE t1;
+SET GLOBAL wsrep_max_ws_rows = 0;
diff --git a/mysql-test/suite/galera/t/MW-328-footer.inc b/mysql-test/suite/galera/t/MW-328-footer.inc
new file mode 100644
index 00000000000..5b736df220f
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328-footer.inc
@@ -0,0 +1,18 @@
+#
+# Cleanup for MW-328 tests
+#
+
+--connection node_1
+--disable_query_log
+--eval KILL CONNECTION $sp_connection_id
+--enable_query_log
+
+--connection node_1X
+--error 2013,1317
+--reap
+
+--connection node_1
+DROP PROCEDURE proc_update;
+DROP TABLE t1, t2;
+
+CALL mtr.add_suppression("conflict state 3 after post commit");
diff --git a/mysql-test/suite/galera/t/MW-328-header.inc b/mysql-test/suite/galera/t/MW-328-header.inc
new file mode 100644
index 00000000000..f0a6ccaccc6
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328-header.inc
@@ -0,0 +1,29 @@
+#
+# Initialization for MW-328 tests
+#
+
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+INSERT INTO t1 (f1) VALUES (1);
+
+CREATE TABLE t2 (f1 CHAR(20)) ENGINE=InnoDB;
+
+#
+# Have some random updates going on against t1
+#
+
+DELIMITER |;
+CREATE PROCEDURE proc_update ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ UPDATE t1 SET f2 = LEFT(MD5(RAND()), 4);
+ END WHILE;
+END|
+
+DELIMITER ;|
+
+--connect node_1X, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1X
+--let $sp_connection_id = `SELECT CONNECTION_ID()`
+--send CALL proc_update();
diff --git a/mysql-test/suite/galera/t/MW-328A.test b/mysql-test/suite/galera/t/MW-328A.test
new file mode 100644
index 00000000000..4d6e1ea3625
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328A.test
@@ -0,0 +1,56 @@
+#
+# MW-328 Fix unnecessary/silent BF aborts
+#
+
+#
+# Attempt to insert into t2 and check if insert actually inserted rows if
+# a success was reported.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source suite/galera/t/MW-328-header.inc
+
+--connection node_2
+--let $count = 100
+--let $successes = 0
+--let $deadlocks = 0
+
+SET SESSION wsrep_retry_autocommit = 0;
+
+--disable_query_log
+
+while ($count)
+{
+ TRUNCATE TABLE t2;
+
+ --error 0,1213
+ INSERT IGNORE INTO t2 SELECT f2 FROM t1;
+ if ($mysql_errno != 1213) {
+ --inc $successes
+ if (`SELECT COUNT(*) = 0 FROM t2`) {
+ --die No rows arrived in table t2
+ }
+ }
+
+ if ($mysql_errno == 1213) {
+ --inc $deadlocks
+
+ }
+
+ --dec $count
+}
+
+--enable_query_log
+
+#
+# Check that the test produced both deadlocks and successes
+#
+
+--disable_query_log
+--eval SELECT $successes > 0 AS have_successes
+--eval SELECT $deadlocks > 0 AS have_deadlocks
+--enable_query_log
+
+
+--source suite/galera/t/MW-328-footer.inc
diff --git a/mysql-test/suite/galera/t/MW-328B.test b/mysql-test/suite/galera/t/MW-328B.test
new file mode 100644
index 00000000000..a7b4053ab0c
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328B.test
@@ -0,0 +1,36 @@
+#
+# MW-328 Fix unnecessary/silent BF aborts
+#
+
+#
+# Make sure an unrelated SELECT following a BF-aborted query never
+# gets the deadlock error
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source suite/galera/t/MW-328-header.inc
+
+--connection node_2
+--let $count = 100
+
+SET SESSION wsrep_retry_autocommit = 0;
+
+--disable_query_log
+
+while ($count)
+{
+ --error 0,1213
+ INSERT IGNORE INTO t2 SELECT f2 FROM t1;
+
+ --disable_result_log
+ --error 0
+ SELECT 1 FROM DUAL;
+ --enable_result_log
+
+ --dec $count
+}
+
+--enable_query_log
+
+--source suite/galera/t/MW-328-footer.inc
diff --git a/mysql-test/suite/galera/t/MW-328C.test b/mysql-test/suite/galera/t/MW-328C.test
new file mode 100644
index 00000000000..b681e743ab3
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328C.test
@@ -0,0 +1,36 @@
+#
+# MW-328 Fix unnecessary/silent BF aborts
+#
+
+#
+# Make sure that a high value of wsrep_retry_autocommit
+# masks all deadlock errors
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source suite/galera/t/MW-328-header.inc
+
+--connection node_2
+--let $count = 100
+
+SET SESSION wsrep_retry_autocommit = 10000;
+
+--disable_query_log
+
+while ($count)
+{
+ --error 0
+ INSERT IGNORE INTO t2 SELECT f2 FROM t1;
+
+ --disable_result_log
+ --error 0
+ SELECT 1 FROM DUAL;
+ --enable_result_log
+
+ --dec $count
+}
+
+--enable_query_log
+
+--source suite/galera/t/MW-328-footer.inc
diff --git a/mysql-test/suite/galera/t/MW-328D.test b/mysql-test/suite/galera/t/MW-328D.test
new file mode 100644
index 00000000000..d5cffdb8f47
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328D.test
@@ -0,0 +1,40 @@
+#
+# MW-328 Fix unnecessary/silent BF aborts
+#
+
+#
+# Test that non-Galera deadlock error still behaves as expected
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (i INT) ENGINE = InnoDB;
+INSERT INTO t1 (i) VALUES(1);
+
+CREATE TABLE t2 (i INT) ENGINE = InnoDB;
+
+# Create a deadlock situation
+
+--connection node_1
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+SELECT * FROM t1 WHERE i = 1 LOCK IN SHARE MODE;
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+--send INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE i = 1 FOR UPDATE;
+
+--connection node_1
+--sleep 2
+DELETE FROM t1 WHERE i = 1;
+COMMIT;
+
+# We expect that ER_LOCK_DEADLOCK will be delivered even though it was a INSERT INGORE statement
+--connection node_1a
+--error ER_LOCK_DEADLOCK
+--reap
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/galera/t/MW-328E.test b/mysql-test/suite/galera/t/MW-328E.test
new file mode 100644
index 00000000000..fd4b0bf9039
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-328E.test
@@ -0,0 +1,41 @@
+#
+# MW-328 Fix unnecessary/silent BF aborts
+#
+
+#
+# Test that non-Galera deadlock error still behaves as expected (case #2)
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+create table t1 (i int primary key, j int) engine=innodb;
+create table t2 (i int primary key, j int) engine=innodb;
+
+insert into t1 values (1,0);
+insert into t2 values (2,0);
+
+set autocommit=off;
+start transaction;
+update t1 set j=1 where i=1;
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+set autocommit=off;
+start transaction;
+begin;
+update t2 set j=1 where i=2;
+
+--connection node_1
+# Hang expected here
+--send insert into t1 select * from t2;
+
+--sleep 2
+--connection node_1a
+--error ER_LOCK_DEADLOCK
+insert into t2 select * from t1;
+
+--connection node_1
+--reap
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/galera/t/MW-329-master.opt b/mysql-test/suite/galera/t/MW-329-master.opt
new file mode 100644
index 00000000000..6565a6af3c4
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-329-master.opt
@@ -0,0 +1 @@
+--wsrep-retry-autocommit=0
diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test
new file mode 100644
index 00000000000..acf6763b396
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-329.test
@@ -0,0 +1,82 @@
+#
+# #MW-329 Fix incorrect affected rows count after replay
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (f1 INTEGER, f2 CHAR(20) DEFAULT 'abc') ENGINE=InnoDB;
+
+# We start with a populated table
+INSERT INTO t1 (f1) VALUES (1),(65535);
+
+# Clear the wsrep_local_replays counter
+
+FLUSH STATUS;
+SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
+
+#
+# Run concurrent INSERTs
+#
+
+DELIMITER |;
+CREATE PROCEDURE proc_insert ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f1) VALUES (FLOOR( 1 + RAND( ) * 65535 ));
+ END WHILE;
+END|
+DELIMITER ;|
+
+--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1b
+--let $connection_id = `SELECT CONNECTION_ID()`
+--send CALL proc_insert();
+
+#
+# Run concurrent UPDATEs. We expect that each UPDATE will report that
+# some rows were matched and updated
+#
+
+--connection node_2
+--let $count = 10
+while ($count)
+{
+ --let $signature = `SELECT LEFT(MD5(RAND()), 10)`
+ --disable_query_log
+ --error 0,ER_LOCK_DEADLOCK
+ --eval UPDATE t1 SET f2 = '$signature'
+ --enable_query_log
+ --let $row_count = `SELECT ROW_COUNT()`
+ if (`SELECT @@error_count = 0`) {
+ if (`SELECT $row_count = 0`) {
+ --die ROW_COUNT() = 0
+ }
+ }
+ --dec $count
+}
+
+#
+# Confirm that some transaction replays occurred
+#
+
+SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays';
+
+#
+# Terminate the stored procedure
+#
+
+--connection node_1
+--disable_query_log
+--eval KILL CONNECTION $connection_id
+--enable_query_log
+
+--connection node_1b
+--error 0,2013,1317
+--reap
+
+--connection node_1
+DROP PROCEDURE proc_insert;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/ev51914.test b/mysql-test/suite/galera/t/ev51914.test
new file mode 100644
index 00000000000..e5edacabe89
--- /dev/null
+++ b/mysql-test/suite/galera/t/ev51914.test
@@ -0,0 +1,214 @@
+# Disable SAVEPOINT and ROLLBACK TO SAVEPOINT in SP, SF, TR.
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+
+--connection node_1
+--echo SAVEPOINT in a stored function should be forbidden
+--delimiter |
+CREATE FUNCTION f1 () RETURNS INT BEGIN
+ SAVEPOINT s;
+ RETURN 1;
+END|
+--delimiter ;
+
+SELECT f1();
+
+DROP FUNCTION f1;
+
+--echo ROLLBACK TO SAVEPOINT in a stored function should be forbidden
+--delimiter |
+CREATE FUNCTION f2 () RETURNS INT BEGIN
+ ROLLBACK TO SAVEPOINT s;
+ RETURN 1;
+END|
+--delimiter ;
+
+BEGIN;
+SAVEPOINT s;
+--error ER_SP_DOES_NOT_EXIST
+SELECT f2();
+COMMIT;
+
+DROP FUNCTION f2;
+
+BEGIN;
+SAVEPOINT S;
+ROLLBACK TO SAVEPOINT S;
+COMMIT;
+
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 values (110), (111), (112), (113), (114);
+
+--echo Direct SAVEPOINT in a trigger should be forbidden
+--connection node_2
+CREATE TRIGGER i1_t1 BEFORE INSERT ON t1 FOR EACH ROW SAVEPOINT s;
+
+--connection node_1
+INSERT INTO t1 VALUES (1);
+DROP TRIGGER i1_t1;
+
+CREATE TRIGGER i2_t1 AFTER INSERT ON t1 FOR EACH ROW SAVEPOINT s;
+INSERT INTO t1 VALUES (2);
+DROP TRIGGER i2_t1;
+
+INSERT INTO t1 VALUES (3);
+CREATE TRIGGER u1_t1 BEFORE UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
+UPDATE t1 SET a=4 WHERE a=3;
+DROP TRIGGER u1_t1;
+
+CREATE TRIGGER u2_t1 AFTER UPDATE ON t1 FOR EACH ROW SAVEPOINT s;
+UPDATE t1 SET a=4 WHERE a=3;
+DROP TRIGGER u2_t1;
+
+CREATE TRIGGER d1_t1 BEFORE DELETE ON t1 FOR EACH ROW SAVEPOINT s;
+DELETE FROM t1;
+DROP TRIGGER d1_t1;
+
+CREATE TRIGGER d1_t1 AFTER DELETE ON t1 FOR EACH ROW SAVEPOINT s;
+DELETE FROM t1;
+DROP TRIGGER d1_t1;
+
+--echo SAVEPOINT in a compound statement in a trigger should be forbidden
+--delimiter |
+CREATE TRIGGER i3_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
+ SAVEPOINT s;
+END|
+--delimiter ;
+INSERT INTO t1 VALUES (5);
+DROP TRIGGER i3_t1;
+
+--echo SAVEPOINT in a PS call in a trigger should be forbidden
+# echo handled by SAVEPOINT forbidden in PS
+--delimiter |
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN
+ PREPARE set_savepoint FROM "SAVEPOINT s";
+ EXECUTE set_savepoint;
+ DEALLOCATE PREPARE set_savepoint;
+END|
+--delimiter ;
+
+--connection node_2
+--echo SAVEPOINT in SP called from a trigger should be forbidden
+--delimiter |
+CREATE PROCEDURE p1() BEGIN
+ SAVEPOINT s;
+END|
+--delimiter ;
+--connection node_1
+CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
+INSERT INTO t1 VALUES (6);
+DROP TRIGGER i5_t1;
+
+--echo SAVEPOINT in a SP called from a PS called from a trigger be forbidden
+# echo handled by SAVEPOINT forbidden in PS
+PREPARE call_p1 FROM "CALL p1";
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW EXECUTE call_p1;
+
+--echo SAVEPOINT in a function called from a trigger should be forbidden
+--delimiter |
+CREATE FUNCTION f1 () RETURNS INT BEGIN
+ SAVEPOINT s;
+ RETURN 1;
+END|
+--delimiter ;
+CREATE TRIGGER i7_t1 BEFORE INSERT ON t1 FOR EACH ROW SET @foo = f1();
+INSERT INTO t1 VALUES (7);
+DROP TRIGGER i7_t1;
+
+--echo SAVEPOINT in a SP called from a SP called from a trigger should be forbidden
+--delimiter |
+CREATE PROCEDURE p2() BEGIN
+ CALL p1();
+END|
+--delimiter ;
+CREATE TRIGGER i8_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p2;
+INSERT INTO t1 VALUES (8);
+DROP TRIGGER i8_t1;
+
+--echo SAVEPOINT in a SP called from a trigger called from a SP should be forbidden
+CREATE TRIGGER i9_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p1;
+--delimiter |
+CREATE PROCEDURE p3() BEGIN
+ INSERT INTO t1 VALUES (9);
+END|
+--delimiter ;
+CALL p3();
+DROP TRIGGER i9_t1;
+
+--echo ROLLBACK TO SAVEPOINT in trigger as a trivial statement should be forbidden
+# Trigger activation creates a new savepoint level, making the earlier levels
+# inaccessible. Thus forbidding SAVEPOINT should be enough as then there is
+# no valid savepoint to pass to ROLLBACK TO SAVEPOINT, but we forbid it once
+# more just in case.
+CREATE TRIGGER i4_t1 BEFORE INSERT ON t1 FOR EACH ROW ROLLBACK TO SAVEPOINT s;
+BEGIN;
+SAVEPOINT s;
+--error ER_SP_DOES_NOT_EXIST
+INSERT INTO t1 VALUES (5);
+COMMIT;
+DROP TRIGGER i4_t1;
+
+--echo ROLLBACK TO SAVEPOINT in a trigger in a SP call should be forbidden
+--delimiter |
+CREATE PROCEDURE p4() BEGIN
+ ROLLBACK TO SAVEPOINT s;
+END|
+--delimiter ;
+CREATE TRIGGER i5_t1 BEFORE INSERT ON t1 FOR EACH ROW CALL p4;
+BEGIN;
+SAVEPOINT s;
+--error ER_SP_DOES_NOT_EXIST
+INSERT INTO t1 VALUES (6);
+COMMIT;
+DROP TRIGGER i5_t1;
+
+--echo SAVEPOINT in a SP next to a trigger should work
+CREATE TRIGGER i6_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = NEW.a + 1;
+--delimiter |
+CREATE PROCEDURE p5() BEGIN
+ SAVEPOINT s;
+ INSERT INTO t1 VALUES (10);
+ ROLLBACK TO SAVEPOINT s;
+END|
+--delimiter ;
+BEGIN;
+CALL p5();
+COMMIT;
+DROP TRIGGER i6_t1;
+
+--connection node_2
+delimiter |;
+create trigger t1 before insert on t1 for each row
+begin
+ insert into t2 values (NULL);
+end|
+delimiter ;|
+
+--connection node_1
+INSERT INTO t1 VALUES (201), (202), (203);
+
+--connection node_1
+SELECT * FROM t1;
+SELECT COUNT(*) FROM t2;
+
+--connection node_2
+SELECT * FROM t1;
+SELECT COUNT(*) FROM t2;
+
+--connection node_1
+DEALLOCATE PREPARE call_p1;
+
+--connection node_2
+DROP TABLE t1, t2;
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP FUNCTION f1;
diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test
index 0ee6dcac700..dccb28e4054 100644
--- a/mysql-test/suite/galera/t/galera#414.test
+++ b/mysql-test/suite/galera/t/galera#414.test
@@ -24,10 +24,14 @@ SET SESSION wsrep_on = OFF;
SET SESSION wsrep_on = ON;
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
+--source include/wait_condition.inc
--connection node_1
CALL mtr.add_suppression("Failed to set packet size");
--connection node_2
+--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
+--source include/wait_condition.inc
CALL mtr.add_suppression("Failed to set packet size");
diff --git a/mysql-test/suite/galera/t/galera_account_management.test b/mysql-test/suite/galera/t/galera_account_management.test
index 357319ad106..6dea0fcfa9e 100644
--- a/mysql-test/suite/galera/t/galera_account_management.test
+++ b/mysql-test/suite/galera/t/galera_account_management.test
@@ -18,14 +18,12 @@ SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2');
# ALTER USER
#
-# LP bug 1376269
-#
-#--connection node_1
-#ALTER USER user1 PASSWORD EXPIRE;
-#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
-#
-#--connection node_2
-#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
+--connection node_1
+ALTER USER user1 PASSWORD EXPIRE;
+SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
+
+--connection node_2
+SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1';
#
# RENAME USER
diff --git a/mysql-test/suite/galera/t/galera_admin.test b/mysql-test/suite/galera/t/galera_admin.test
new file mode 100644
index 00000000000..e3c43256ad5
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_admin.test
@@ -0,0 +1,86 @@
+#
+# Test that various admin commands from sql_admin.cc
+# Currently, REPAIR, OPTIMIZE and ANALYZE are tested.
+# Jira: PXC-390
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP TABLE IF EXISTS x1, x2;
+--enable_warnings
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER);
+CREATE TABLE t2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER);
+SET GLOBAL wsrep_replicate_myisam = TRUE;
+CREATE TABLE x1 (f1 INTEGER) ENGINE=MyISAM;
+CREATE TABLE x2 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+INSERT INTO x1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+INSERT INTO t2 (f2) SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4;
+INSERT INTO x2 (f2) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+
+# Wait until all the data from t2 has been replicated
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 10 FROM x1;
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*) = 10 FROM x2;
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*) = 10 FROM t1;
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*) = 10000 FROM t2;
+--source include/wait_condition.inc
+
+
+--echo # ANALYZE test
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+
+--connection node_1
+ANALYZE TABLE t1, t2;
+
+--connection node_2
+--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
+--source include/wait_condition.inc
+
+
+
+--echo # OPTIMIZE test
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+
+--connection node_1
+OPTIMIZE TABLE t1, t2;
+
+--connection node_2
+--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
+--source include/wait_condition.inc
+
+
+
+--echo # REPAIR test
+--connection node_2
+--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
+
+--connection node_1
+REPAIR TABLE x1, x2;
+
+--connection node_2
+--let $wait_condition = SELECT VARIABLE_VALUE >= $wsrep_last_committed_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'
+--source include/wait_condition.inc
+
+
+
+--connection node_2
+SELECT COUNT(*) = 10 FROM t1;
+SELECT COUNT(*) = 10 FROM x1;
+SELECT COUNT(*) = 10000 FROM t2;
+SELECT COUNT(*) = 10 FROM x2;
+
+--connection node_1
+DROP TABLE t1, t2;
+DROP TABLE x1, x2;
+SET GLOBAL wsrep_replicate_myisam = FALSE;
diff --git a/mysql-test/suite/galera/t/galera_bf_abort.test b/mysql-test/suite/galera/t/galera_bf_abort.test
index 69825ea4919..f3476fba490 100644
--- a/mysql-test/suite/galera/t/galera_bf_abort.test
+++ b/mysql-test/suite/galera/t/galera_bf_abort.test
@@ -5,20 +5,25 @@
# Test a local transaction being aborted by a slave one
#
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB;
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
SET AUTOCOMMIT=OFF;
START TRANSACTION;
-INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (1,'node_2');
--connection node_1
-INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (1,'node_1');
+
+--connection node_2a
+--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'node_1'
+--source include/wait_condition.inc
--connection node_2
--error ER_LOCK_DEADLOCK
-INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (2, 'node_2');
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
diff --git a/mysql-test/suite/galera/t/galera_desync_overlapped.test b/mysql-test/suite/galera/t/galera_desync_overlapped.test
new file mode 100644
index 00000000000..8b78e8cdeb7
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_desync_overlapped.test
@@ -0,0 +1,59 @@
+#
+# Test for overlapped transactions under manual desync.
+#
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+
+--let $galera_connection_name = node_1a
+--let $galera_server_number = 1
+--source include/galera_connect.inc
+
+--connection node_1
+
+CREATE TABLE ten (f1 INTEGER);
+INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+CREATE TABLE t1 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
+CREATE TABLE t2 (f1 INTEGER, PRIMARY KEY (f1)) Engine=InnoDB;
+
+SET GLOBAL wsrep_desync = 1;
+show status like 'wsrep_desync_count';
+SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter1 WAIT_FOR alter2';
+send INSERT INTO t1 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
+
+--connection node_1a
+
+SET GLOBAL wsrep_desync = 1;
+show status like 'wsrep_desync_count';
+SET DEBUG_SYNC='now WAIT_FOR alter1';
+SET DEBUG_SYNC='before_execute_sql_command SIGNAL alter2';
+send INSERT INTO t2 (f1) SELECT 0000 + (100 * a1.f1) + (10 * a2.f1) + a3.f1 FROM ten AS a1, ten AS a2, ten AS a3;
+
+--connection node_1
+reap;
+
+--connection node_1a
+reap;
+
+--connection node_1
+
+SET DEBUG_SYNC='RESET';
+
+SET GLOBAL wsrep_desync = 0;
+show status like 'wsrep_desync_count';
+SET GLOBAL wsrep_desync = 0;
+show status like 'wsrep_desync_count';
+
+--disable_query_log
+call mtr.add_suppression("Trying to make wsrep_desync = OFF on the node that is already synchronized.");
+--enable_query_log
+show status like 'wsrep_desync_count';
+SET GLOBAL wsrep_desync = 0;
+
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/t/galera_flush_local.opt b/mysql-test/suite/galera/t/galera_flush_local.opt
index 45a0ca24dc7..5a1fb6748d9 100644
--- a/mysql-test/suite/galera/t/galera_flush_local.opt
+++ b/mysql-test/suite/galera/t/galera_flush_local.opt
@@ -1 +1 @@
---query_cache_type=1 --query_cache_size=1000000 --userstat=1 --wsrep_replicate_myisam=true
+--query_cache_type=1 --query_cache_size=1000000
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover.cnf b/mysql-test/suite/galera/t/galera_gcache_recover.cnf
new file mode 100644
index 00000000000..c7b59b6a27e
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover.cnf
@@ -0,0 +1,7 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true'
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover.test b/mysql-test/suite/galera/t/galera_gcache_recover.test
new file mode 100644
index 00000000000..e1bfe517d27
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover.test
@@ -0,0 +1,77 @@
+#
+# Kill entire cluster while gcache.recover=yes. Expect that node #2 will rejoin using IST
+#
+
+--source include/galera_cluster.inc
+--source include/big_test.inc
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+SET SESSION wsrep_sync_wait = 0;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) > 0 FROM t1;
+--source include/wait_condition.inc
+
+SET SESSION wsrep_sync_wait = 0;
+--source include/kill_galera.inc
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+INSERT INTO t1 VALUES (2);
+
+--source include/kill_galera.inc
+
+--sleep 1
+
+--connection node_1
+--let $galera_wsrep_recover_server_id=1
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/start_mysqld.inc
+
+INSERT INTO t1 VALUES (3);
+
+--connection node_2
+--let $galera_wsrep_recover_server_id=2
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+--source include/galera_wait_ready.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--let $diff_servers = 1 2
+--source include/diff_servers.inc
+
+--connection node_1
+# Warning happens when the cluster is started for the first time
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+
+# Confirm that IST took place
+--let $assert_text = async IST sender starting to serve
+--let $assert_select = async IST sender starting to serve
+--let $assert_count = 1
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err
+--let $assert_only_after = starting as process
+--source include/assert_grep.inc
+
+--connection node_2
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+
+# Confirm that gcache recovery took place
+
+--let $assert_text = Recovering GCache ring buffer: found gapless sequence
+--let $assert_select = Recovering GCache ring buffer: found gapless sequence
+--let $assert_count = 1
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err
+--let $assert_only_after = starting as process
+--source include/assert_grep.inc
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf
new file mode 100644
index 00000000000..da74ea9fc5d
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.cnf
@@ -0,0 +1,9 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+max_allowed_packet=10M
+innodb_log_file_size=110M
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true;gcache.size=10M'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true;gcache.size=10M'
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test
new file mode 100644
index 00000000000..b7fd9cf3aed
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test
@@ -0,0 +1,59 @@
+#
+# Attempt gcache recovery on a full gcache. Node will not be able to join via IST due to gcache rollover
+#
+
+--source include/galera_cluster.inc
+--source include/big_test.inc
+
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB;
+
+--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+--source include/kill_galera.inc
+
+--connection node_1
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+--source include/kill_galera.inc
+
+--connection node_1
+--let $galera_wsrep_recover_server_id=1
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name = $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/start_mysqld.inc
+--connection node_2
+--let $galera_wsrep_recover_server_id=2
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+--source include/galera_wait_ready.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--let $diff_servers = 1 2
+--source include/diff_servers.inc
+
+--connection node_1
+DROP TABLE t1;
+
+# Warning always happens when the cluster is started for the first time
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+
+# Confirm that IST did not take place
+--let $assert_text = IST first seqno 2 not found from cache, falling back to SST
+--let $assert_select = IST first seqno 2 not found from cache, falling back to SST
+--let $assert_count = 1
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err
+--let $assert_only_after = starting as process
+--source include/assert_grep.inc
+
+--connection node_2
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf
new file mode 100644
index 00000000000..c08551eae84
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.cnf
@@ -0,0 +1,9 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+innodb_log_file_size=110M
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.recover=yes;pc.ignore_sb=true;'
+
+[mysqld.2]
+innodb_log_file_size=110M
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.recover=yes;pc.ignore_sb=true;'
diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test
new file mode 100644
index 00000000000..3bfcdc9f117
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test
@@ -0,0 +1,216 @@
+#
+# Kill entire cluster while various transactions are in progress
+# restore the cluster and expect that node #2 will rejoin using IST
+#
+
+--source include/galera_cluster.inc
+--source include/big_test.inc
+
+SET SESSION wsrep_sync_wait = 0;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB;
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+DELIMITER |;
+CREATE PROCEDURE insert_simple ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f1, f2) VALUES (DEFAULT,'abcdef');
+ END WHILE;
+END|
+
+CREATE PROCEDURE insert_multi ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f1) VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT);
+ END WHILE;
+END|
+
+CREATE PROCEDURE insert_transaction ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ SET AUTOCOMMIT = OFF;
+ WHILE 1 DO
+ START TRANSACTION;
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ INSERT INTO t1 (f1) VALUES (DEFAULT);
+ COMMIT;
+ END WHILE;
+END|
+
+DELIMITER ;|
+DELIMITER |;
+
+CREATE PROCEDURE update_simple ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ UPDATE t1 SET f2 = CONCAT(f2,f2);
+ END WHILE;
+END|
+
+CREATE PROCEDURE insert_1k ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024));
+ END WHILE;
+END|
+
+CREATE PROCEDURE insert_1m ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024));
+ END WHILE;
+END|
+
+CREATE PROCEDURE insert_10m ()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ SET SESSION wsrep_sync_wait = 0;
+ WHILE 1 DO
+ INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10));
+ END WHILE;
+END|
+
+DELIMITER ;|
+
+--connect node_1_insert_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_insert_multi, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_insert_transaction, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_update_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_insert_1k, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_insert_1m, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connect node_1_insert_10m, 127.0.0.1, root, , test, $NODE_MYPORT_1
+
+--connection node_1_insert_simple
+--send CALL insert_simple();
+
+--connection node_1_insert_multi
+--send CALL insert_multi();
+
+--connection node_1_insert_transaction
+--send CALL insert_transaction ();
+
+--connection node_1_update_simple
+--send CALL update_simple ();
+
+--connection node_1_insert_1k
+--send CALL insert_1k ();
+
+--connection node_1_insert_1m
+--send CALL insert_1m ();
+
+--connection node_1_insert_10m
+--send CALL insert_10m ();
+
+--connection node_2
+SET SESSION wsrep_sync_wait = 0;
+--source include/kill_galera.inc
+
+--sleep 10
+--connection node_1
+--source include/kill_galera.inc
+
+--connection node_1_insert_simple
+--error 2013
+--reap
+
+--connection node_1_insert_multi
+--error 2013
+--reap
+
+--connection node_1_insert_transaction
+--error 2013
+--reap
+
+--connection node_1_update_simple
+--error 2013
+--reap
+
+--connection node_1_insert_1k
+--error 2013
+--reap
+
+--connection node_1_insert_1m
+--error 2013
+--reap
+
+--connection node_1_insert_10m
+--error 2013
+--reap
+
+--connection node_1
+--let $galera_wsrep_recover_server_id=1
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name = $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/start_mysqld.inc
+--connection node_2
+--let $galera_wsrep_recover_server_id=2
+--source suite/galera/include/galera_wsrep_recover.inc
+
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
+
+--connection node_1
+--source include/wait_until_connected_again.inc
+--source include/galera_wait_ready.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+
+--let $diff_servers = 1 2
+--source include/diff_servers.inc
+
+--connection node_1
+DROP TABLE t1;
+DROP TABLE ten;
+DROP PROCEDURE insert_simple;
+DROP PROCEDURE insert_multi;
+DROP PROCEDURE insert_transaction;
+DROP PROCEDURE update_simple;
+DROP PROCEDURE insert_1k;
+DROP PROCEDURE insert_1m;
+
+--connection node_1
+CALL mtr.add_suppression("conflict state 7 after post commit");
+
+# Warning happens when the cluster is started for the first time
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+
+# Confirm that IST took place
+--let $assert_text = async IST sender starting to serve
+--let $assert_select = async IST sender starting to serve
+--let $assert_count = 1
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err
+--let $assert_only_after = starting as process
+--source include/assert_grep.inc
+
+--connection node_2
+CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
+
+# Confirm that gcache recovery took place
+
+--let $assert_text = Recovering GCache ring buffer: found gapless sequence
+--let $assert_select = Recovering GCache ring buffer: found gapless sequence
+--let $assert_count = 1
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err
+--let $assert_only_after = starting as process
+--source include/assert_grep.inc
diff --git a/mysql-test/suite/galera/t/galera_many_tables_pk.test b/mysql-test/suite/galera/t/galera_many_tables_pk.test
index 520459e3210..551307b123f 100644
--- a/mysql-test/suite/galera/t/galera_many_tables_pk.test
+++ b/mysql-test/suite/galera/t/galera_many_tables_pk.test
@@ -7,18 +7,12 @@ if (!`SELECT @@open_files_limit >= 1024`){
}
#
-# This test forces 900 tables with a PK to participate in a single
-# transaction. The reason for 900 is that some linux system has by default
-# a limit of 1024 open files / process
-#
-
-#
-# First, create 900 tables and make sure the DDLs are all propagated
+# First, create 100 tables and make sure the DDLs are all propagated
#
--connection node_1
---let $count = 900
+--let $count = 100
while ($count)
{
--disable_query_log
@@ -29,7 +23,7 @@ while ($count)
}
--connection node_2
-SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%';
+SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%';
#
# Second, create a transaction that uses all those tables
@@ -39,7 +33,7 @@ SELECT COUNT(*) = 900 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test'
SET AUTOCOMMIT=OFF;
START TRANSACTION;
---let $count = 900
+--let $count = 100
while ($count)
{
--disable_query_log
@@ -58,7 +52,7 @@ COMMIT;
--connection node_2
CREATE TABLE sum_table (f1 INTEGER);
---let $count = 900
+--let $count = 100
while ($count)
{
--disable_query_log
@@ -68,7 +62,7 @@ while ($count)
--dec $count
}
-SELECT SUM(f1) = 900 FROM sum_table;
+SELECT SUM(f1) = 100 FROM sum_table;
#
# Fourth, create a deadlock
@@ -78,7 +72,7 @@ SELECT SUM(f1) = 900 FROM sum_table;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
---let $count = 900
+--let $count = 100
while ($count)
{
--disable_query_log
@@ -91,7 +85,7 @@ while ($count)
--connection node_2
SET AUTOCOMMIT=OFF;
START TRANSACTION;
-UPDATE t900 SET f1 = 3;
+UPDATE t100 SET f1 = 3;
--connection node_1
COMMIT;
@@ -100,5 +94,8 @@ COMMIT;
--error ER_LOCK_DEADLOCK
COMMIT;
+--let $diff_servers = 1 2
+--source include/diff_servers.inc
+
DROP SCHEMA test;
CREATE SCHEMA test;
diff --git a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test
new file mode 100644
index 00000000000..2f27678b547
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test
@@ -0,0 +1,150 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+# Suppress expected warnings:
+
+CALL mtr.add_suppression("Aborting");
+CALL mtr.add_suppression("unknown option '--galera-unknown-option'");
+
+#
+# We should count the number of "Assertion failed" warnings
+# in the log file before and after testing. To do this we need
+# to save original log file before testing:
+#
+--let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err
+--perl
+ use strict;
+ my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
+ my $test_log_copy=$test_log . '.copy';
+ if (-e $test_log_copy) {
+ unlink $test_log_copy;
+ }
+EOF
+--copy_file $TEST_LOG $TEST_LOG.copy
+
+--connection node_2
+
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
+
+SELECT * FROM t1;
+
+# Initiate normal shutdown on the node 2 and
+# waiting until shutdown has been completed:
+
+--echo Shutting down server ...
+--source include/shutdown_mysqld.inc
+
+--connection node_1
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+# Some updates on node 1:
+
+UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
+UPDATE t1 SET f2 = 'c' WHERE f1 > 2;
+
+SELECT * FROM t1;
+
+# Remove the "grastate.dat" file (to initiate new SST)
+# and restart node 2 with unknown option:
+
+--connection node_2
+
+--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+
+--let $start_mysqld_params=--galera-unknown-option
+
+--echo Starting server ...
+--exec echo "try:$start_mysqld_params" > $_expect_file_name
+
+# Sleep to ensure that server exited...
+
+--sleep 30
+
+# Restart node 2 without unknown option:
+
+--let $start_mysqld_params=
+
+--echo Starting server ...
+--source include/start_mysqld.inc
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+# Sanity check (node 2 is running now and can perform SQL operators):
+
+SELECT * FROM t1;
+
+# Initiate normal shutdown on the node 2 and
+# waiting until shutdown has been completed:
+
+--echo Shutting down server ...
+--source include/shutdown_mysqld.inc
+
+--connection node_1
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+# Some updates on node 1 - to initiate IST next time:
+
+UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
+UPDATE t1 SET f2 = 'd' WHERE f1 > 2;
+
+SELECT * FROM t1;
+
+# Restart node 2 with unknown option:
+
+--connection node_2
+
+--let $start_mysqld_params=--galera-unknown-option
+
+--echo Starting server ...
+--exec echo "try:$start_mysqld_params" > $_expect_file_name
+
+# Sleep to ensure that server exited...
+
+--sleep 30
+
+# Restart node 2 without unknown option:
+
+--let $start_mysqld_params=
+
+--echo Starting server ...
+--source include/start_mysqld.inc
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
+--source include/wait_condition.inc
+
+# Sanity check (node 2 is running now and can perform SQL operators):
+
+SELECT * FROM t1;
+
+--connection node_1
+
+DROP TABLE t1;
+
+#
+# We should count the number of "Assertion failed" warnings
+# in the log file during test phase - to print the error message
+# if quantity of such warnings in log file increased at the end
+# of the test:
+#
+--perl
+ use strict;
+ my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
+ my $test_log_copy=$test_log . '.copy';
+ open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n");
+ my $initial=grep(/Assertion * failed/gi,<FILE>);
+ close(FILE);
+ open(FILE, $test_log) or die("Unable to open $test_log: $!\n");
+ my $count_warnings=grep(/Assertion * failed/gi,<FILE>);
+ close(FILE);
+ if ($count_warnings != $initial) {
+ my $diff=$count_warnings-$initial;
+ print "Assertion failed $diff times.\n";
+ }
+EOF
+--remove_file $TEST_LOG.copy
diff --git a/mysql-test/suite/galera/t/galera_roles.test b/mysql-test/suite/galera/t/galera_roles.test
index 79951ad10c8..3005562db9c 100644
--- a/mysql-test/suite/galera/t/galera_roles.test
+++ b/mysql-test/suite/galera/t/galera_roles.test
@@ -102,6 +102,7 @@ REVOKE EXECUTE ON PROCEDURE test1.pr1 FROM role1;
--echo # Connect with foo_node_1
--connection foo_node_1
+--sleep 1
--error ER_PROCACCESS_DENIED_ERROR
CALL test1.pr1();
diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test b/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test
new file mode 100644
index 00000000000..f42fae4ed51
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_toi_ddl_fk_update.test
@@ -0,0 +1,49 @@
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+#
+# This test creates a new FK constraint while an UPDATE is running
+#
+
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+CREATE TABLE parent (
+ id INT PRIMARY KEY,
+ KEY (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE child (
+ id INT PRIMARY KEY AUTO_INCREMENT,
+ parent_id INT
+) ENGINE=InnoDB;
+
+INSERT INTO parent VALUES (1);
+
+INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;
+
+--connection node_1
+--sleep 1
+--send ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;
+
+--connection node_2
+--sleep 1
+--send UPDATE parent SET id = 2 WHERE id = 1;
+
+--connection node_1
+--reap
+
+--connection node_2
+--reap
+
+--connection node_2
+SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
+
+--connection node_1
+SELECT COUNT(*) = 10000 FROM child WHERE parent_id = 2;
+
+DROP TABLE child;
+DROP TABLE parent;
+
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/t/galera_toi_drop_database.test b/mysql-test/suite/galera/t/galera_toi_drop_database.test
new file mode 100644
index 00000000000..e790a0ba812
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_toi_drop_database.test
@@ -0,0 +1,56 @@
+#
+# Test the operation of DDLs that affect multiple database objects
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--let $galera_connection_name = node_1a
+--let $galera_server_number = 1
+--source include/galera_connect.inc
+
+--connection node_1
+CREATE DATABASE database1;
+USE database1;
+
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
+
+# Make sure autocommit retrying does not kick in as this will mask the error we expect to get
+SET SESSION wsrep_retry_autocommit = 0;
+# Attemp to insert 1M rows
+--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
+
+--connection node_1a
+USE database1;
+SET SESSION wsrep_retry_autocommit = 0;
+--send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
+
+--connection node_2
+--sleep 1
+--send DROP DATABASE database1;
+
+--connection node_1
+--sleep 1
+--error ER_LOCK_DEADLOCK
+--reap
+
+--connection node_1a
+--error ER_LOCK_DEADLOCK
+--reap
+
+--connection node_2
+--reap
+
+--connection node_1
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
+--error ER_BAD_DB_ERROR
+USE database1;
+
+--connection node_2
+SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
+--error ER_BAD_DB_ERROR
+USE database1;
diff --git a/mysql-test/suite/galera/t/galera_toi_truncate.test b/mysql-test/suite/galera/t/galera_toi_truncate.test
new file mode 100644
index 00000000000..59ef5c2028f
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_toi_truncate.test
@@ -0,0 +1,43 @@
+#
+# Test the operation of TRUNCATE with concurrent DML.
+# The DML should be BF-aborted if the DDL arrives from another node
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+#
+# INSERT and TRUNCATE on different nodes
+#
+
+--connection node_1
+CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+
+# Insert 100K rows
+--connection node_2
+# Prevent autocommit retring from masking the deadlock error we expect to get
+SET SESSION wsrep_retry_autocommit = 0;
+--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
+
+--connection node_1
+--sleep 1
+--send TRUNCATE TABLE t1;
+
+--connection node_1
+--reap
+
+--connection node_2
+--error ER_LOCK_DEADLOCK
+--reap
+
+--connection node_2
+SELECT COUNT(*) = 0 FROM t1;
+
+--connection node_1
+SELECT COUNT(*) = 0 FROM t1;
+
+DROP TABLE t1;
+DROP TABLE ten;
diff --git a/mysql-test/suite/galera/t/galera_var_cluster_address.test b/mysql-test/suite/galera/t/galera_var_cluster_address.test
index 740c38765f6..0f857eb1aac 100644
--- a/mysql-test/suite/galera/t/galera_var_cluster_address.test
+++ b/mysql-test/suite/galera/t/galera_var_cluster_address.test
@@ -69,9 +69,11 @@ CALL mtr.add_suppression("failed to open gcomm backend connection: 110: failed t
CALL mtr.add_suppression("Failed to open backend connection: -110 \\(Connection timed out\\)");
CALL mtr.add_suppression("gcs connect failed: Connection timed out");
CALL mtr.add_suppression("WSREP: wsrep::connect\\(foo://\\) failed: 7");
+CALL mtr.add_suppression("WSREP: wsrep::connect\\(gcomm://192.0.2.1\\) failed: 7");
# Restore original auto_increment_offset values.
--source include/auto_increment_offset_restore.inc
--source include/galera_end.inc
--echo # End of test
+
diff --git a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test
new file mode 100644
index 00000000000..bf4da3234c5
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test
@@ -0,0 +1,98 @@
+#
+# Test that the wsrep_retry_autocommit variable is respected. We use an INSERT that
+# proceeds very slowly due to extra SLEEP() in a trigger
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5);
+
+#
+# With wsrep_retry_autocommit = 0, error is certain
+#
+
+--connection node_1
+SET SESSION wsrep_retry_autocommit = 0;
+--send INSERT INTO t1 (f1) VALUES (1),(2);
+
+--connection node_2
+--sleep 1
+TRUNCATE TABLE t1;
+
+--connection node_1
+--error ER_LOCK_DEADLOCK
+--reap
+
+#
+# With wsrep_retry_autocommit = 1, success against one TRUNCATE
+#
+
+--connection node_1
+SET SESSION wsrep_retry_autocommit = 1;
+--send INSERT INTO t1 (f1) VALUES (3),(4);
+
+--connection node_2
+--sleep 1
+TRUNCATE TABLE t1;
+
+--connection node_1
+--error 0
+--reap
+SELECT * FROM test.t1;
+
+#
+# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs
+#
+
+--connection node_2
+DELIMITER |;
+CREATE PROCEDURE repeated_truncate ()
+BEGIN
+ DECLARE i INT;
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+
+ SET i = 0;
+ WHILE i <= 1000 DO
+ TRUNCATE TABLE t1;
+ SET i = i + 1;
+ END WHILE;
+END|
+DELIMITER ;|
+
+# Begin streaming TRUNCATEs
+--let $truncate_connection_id = `SELECT CONNECTION_ID()`
+--send CALL repeated_truncate()
+
+--connection node_1
+SET SESSION wsrep_retry_autocommit = 1;
+--sleep 1
+--error ER_LOCK_DEADLOCK
+INSERT INTO t1 (f1) VALUES (5),(6);
+
+#
+# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs
+#
+
+--connection node_1
+SET SESSION wsrep_retry_autocommit = 1024;
+--send INSERT INTO t1 (f1) VALUES (7),(8);
+
+--sleep 6
+
+# Once he stream of TRUNCATEs is complete
+--connection node_2
+--reap
+
+# the INSERT will eventually be sucessfull
+--connection node_1
+--error 0
+--reap
+
+--let $diff_servers = 1 2
+--source include/diff_servers.inc
+
+DROP TABLE t1;
+DROP PROCEDURE repeated_truncate;
diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test
index 812ba99027f..1c4dd8eba3a 100644
--- a/mysql-test/suite/galera/t/galera_var_slave_threads.test
+++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test
@@ -6,7 +6,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
-
+CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread.");
--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads`
--connection node_1
diff --git a/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt b/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt
new file mode 100644
index 00000000000..930c483bd64
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wsrep_log_conficts-master.opt
@@ -0,0 +1 @@
+--wsrep_log_conflicts=ON
diff --git a/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test b/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test
new file mode 100644
index 00000000000..3af08cbf637
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wsrep_log_conficts.test
@@ -0,0 +1,55 @@
+#
+# Test --wsrep_log_conflicts=ON
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (
+ f1 VARCHAR(255) PRIMARY KEY
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO t1 VALUES ('abc');
+
+--connection node_2
+SELECT f1 = 'abc' FROM t1;
+
+#
+# Provoke a conflict
+#
+
+--connection node_1
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+UPDATE t1 SET f1 = 'klm';
+
+--connection node_2
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+UPDATE t1 SET f1 = 'xyz';
+
+--connection node_1
+COMMIT;
+
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+--connection node_2a
+--let $wait_condition = SELECT f1 = 'klm' FROM t1;
+--source include/wait_condition.inc
+
+--connection node_2
+--error ER_LOCK_DEADLOCK
+COMMIT;
+
+#
+# We can not really check the log output very much because it is quite variable
+#
+
+--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err
+--let $assert_only_after = CURRENT_TEST
+
+--let $assert_text = cluster conflict due to high priority abort for threads
+--let $assert_select = cluster conflict due to high priority abort for threads
+--let $assert_match = cluster conflict due to high priority abort for threads
+--source include/assert_grep.inc
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test b/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test
new file mode 100644
index 00000000000..fe1abcf6c35
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wsrep_provider_options_syntax.test
@@ -0,0 +1,20 @@
+#
+# PXC-318: Typo in wsrep_provider_options causes an unhandled exception
+#
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--let LOGF=$MYSQLTEST_VARDIR/log/mysqld.1.err
+--disable_info
+call mtr.add_suppression("WSREP\: Unknown parameter 'gmcasts\.segment'");
+call mtr.add_suppression("WSREP\: Set options returned 7");
+--error ER_WRONG_ARGUMENTS
+SET GLOBAL wsrep_provider_options="gmcasts.segment=1";
+# Search for unhandled exception message.
+perl;
+ use strict;
+ my $logf= $ENV{'LOGF'} or die "LOGF not set";
+ open(FILE, "$logf") or die("Unable to open $logf: $!\n");
+ my $count_warnings=grep(/terminate called after throwing an instance of /gi,<FILE>);
+ print "Unhandled exceptions: $count_warnings\n";
+ close(FILE);
+EOF
diff --git a/mysql-test/suite/galera/t/lp1376747-2.test b/mysql-test/suite/galera/t/lp1376747-2.test
new file mode 100644
index 00000000000..360681d7674
--- /dev/null
+++ b/mysql-test/suite/galera/t/lp1376747-2.test
@@ -0,0 +1,22 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+FLUSH TABLES t1 FOR EXPORT;
+
+--connection node_1
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+
+--connection node_2
+UNLOCK TABLES;
+
+--echo ### t1 should have column f2
+SHOW CREATE TABLE t1;
+SELECT * from t1;
+
+--connection node_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/lp1376747-3.test b/mysql-test/suite/galera/t/lp1376747-3.test
new file mode 100644
index 00000000000..75fe7d276cd
--- /dev/null
+++ b/mysql-test/suite/galera/t/lp1376747-3.test
@@ -0,0 +1,28 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+FLUSH TABLE WITH READ LOCK;
+--echo ### This shouldn't block.
+FLUSH TABLES t1 FOR EXPORT;
+
+--connection node_1
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+
+--connection node_2
+UNLOCK TABLES;
+
+--echo ### t1 should have column f2
+SHOW CREATE TABLE t1;
+
+--connection node_1
+INSERT INTO t1 VALUES (2,3);
+
+--connection node_2
+SELECT * from t1;
+
+--connection node_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test
new file mode 100644
index 00000000000..be56ee5edc1
--- /dev/null
+++ b/mysql-test/suite/galera/t/lp1376747-4.test
@@ -0,0 +1,53 @@
+#
+# Test Flush tables with read lock along with
+# flush tables <table> with read lock for compatibility.
+# Also, making sure all DDL and DMLs are propagated
+# after provider is unpaused
+#
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--let $galera_connection_name = node_2a
+--let $galera_server_number = 2
+--source include/galera_connect.inc
+
+--connection node_1
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+SET session wsrep_sync_wait=0;
+SET session wsrep_causal_reads=OFF;
+FLUSH TABLE WITH READ LOCK;
+
+--connection node_1
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+
+--connection node_2a
+SET session wsrep_sync_wait=0;
+SET session wsrep_causal_reads=OFF;
+SHOW CREATE TABLE t1;
+--sleep 1
+--send FLUSH TABLES t1 WITH READ LOCK;
+
+--connection node_2
+# let the flush table wait in pause state before we unlock
+# table otherwise there is window where-in flush table is
+# yet to wait in pause and unlock allows alter table to proceed.
+# this is because send in asynchronous.
+--sleep 3
+# this will release existing lock but will not resume
+# the cluster as there is new FTRL that is still pausing it.
+UNLOCK TABLES;
+SHOW CREATE TABLE t1;
+
+--connection node_2a
+--reap
+UNLOCK TABLES;
+--sleep 1
+SHOW CREATE TABLE t1;
+SELECT * from t1;
+
+--connection node_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/lp1376747.test b/mysql-test/suite/galera/t/lp1376747.test
new file mode 100644
index 00000000000..769bb665c77
--- /dev/null
+++ b/mysql-test/suite/galera/t/lp1376747.test
@@ -0,0 +1,24 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+FLUSH TABLES t1 WITH READ LOCK;
+
+--connection node_1
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+INSERT INTO t1 VALUES (2,3);
+
+--sleep 2
+
+--connection node_2
+UNLOCK TABLES;
+
+--echo ### t1 should have column f2
+SHOW CREATE TABLE t1;
+SELECT * from t1;
+
+--connection node_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/pxc-421.test b/mysql-test/suite/galera/t/pxc-421.test
new file mode 100644
index 00000000000..8a360b12f4c
--- /dev/null
+++ b/mysql-test/suite/galera/t/pxc-421.test
@@ -0,0 +1,60 @@
+#
+# PXC-421: Test deadlock involving updates of
+# wsrep_provider, wsrep_cluster_address and wsrep_slave_threads.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--connection node_1
+--let $wsrep_slave_1 = `SELECT @@wsrep_slave_threads`
+set GLOBAL wsrep_slave_threads=26;
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 (f1) SELECT * from t1 as x1;
+
+--connection node_2
+--let $wsrep_slave_2 = `SELECT @@wsrep_slave_threads`
+set GLOBAL wsrep_slave_threads=16;
+--let $wsrep_provider_orig = `SELECT @@wsrep_provider`
+--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address`
+
+SET GLOBAL wsrep_provider='none';
+INSERT INTO t1 VALUES (2);
+
+--connection node_1
+INSERT INTO t1 VALUES (3);
+
+--connection node_2
+--disable_query_log
+--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig';
+--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig';
+--enable_query_log
+
+--source include/wait_until_connected_again.inc
+--source include/galera_wait_ready.inc
+
+INSERT INTO t1 VALUES (4);
+set GLOBAL wsrep_slave_threads=5;
+
+# Node #2 has all the inserts
+SELECT COUNT(*) = 5 FROM t1;
+
+--connection node_1
+set GLOBAL wsrep_slave_threads=12;
+# Node #1 is missing the insert made while Node #2 was not replicated
+SELECT COUNT(*) = 4 FROM t1;
+INSERT INTO t1 VALUES (100), (101), (102);
+
+--connection node_2
+set GLOBAL wsrep_slave_threads=5;
+INSERT INTO t1 (f1) SELECT * from t1 as x1;
+show global variables like 'wsrep_slave_threads';
+--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2
+SELECT COUNT(*) FROM t1;
+
+--connection node_1
+SELECT COUNT(*) FROM t1;
+show global variables like 'wsrep_slave_threads';
+--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf
index eaa2899968c..1ed273fdcb5 100644
--- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf
+++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf
@@ -27,7 +27,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port'
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
-wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S'
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S'
+
+wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
@@ -36,7 +38,9 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
-wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S'
+wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S'
+
+wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port'
diff --git a/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result
new file mode 100644
index 00000000000..21f747d280b
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result
@@ -0,0 +1,26 @@
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 1']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0']
+SET SESSION wsrep_on = OFF;
+Killing server ...
+safe_to_bootstrap: 1
+safe_to_bootstrap: 0
+safe_to_bootstrap: 0
+CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
+CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test
new file mode 100644
index 00000000000..7c9991e68c4
--- /dev/null
+++ b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test
@@ -0,0 +1,163 @@
+#
+# Test the safe_to_bootstrap in grastate.dat
+#
+
+--source include/galera_cluster.inc
+CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
+
+#
+# At start, all grastate.dat files have safe_to_boostrap: 0
+#
+
+--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0'
+--let $assert_select= safe_to_bootstrap: 0
+--let $assert_count= 1
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
+--source include/assert_grep.inc
+
+#
+# Shut down one node
+#
+
+--connection node_2
+--source include/shutdown_mysqld.inc
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# Still, all grastate.dat files should have safe_to_boostrap: 0
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
+--source include/assert_grep.inc
+
+#
+# Shut down one more node
+#
+
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+--source include/shutdown_mysqld.inc
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# Now, nodes 2,3 should have safe_to_boostrap: 0
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
+--source include/assert_grep.inc
+
+# But node #1 should have safe_to_boostrap: 1
+
+--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 1'
+--let $assert_select= safe_to_bootstrap: 1
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+--source include/assert_grep.inc
+
+# Restart one node
+
+--connection node_2
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
+
+--connection node_1
+--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+# All nodes should be back to 'safe_to_bootstrap: 0'
+
+--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0'
+--let $assert_select= safe_to_bootstrap: 0
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+--source include/assert_grep.inc
+
+--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
+--source include/assert_grep.inc
+
+#
+# Kill the cluster
+#
+
+--connection node_2
+--source include/shutdown_mysqld.inc
+
+--connection node_1
+SET SESSION wsrep_on = OFF;
+--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+--source include/kill_galera.inc
+
+#
+# Only node #1 should have safe_to_bootstrap: 1
+# include/assert_grep.inc requires a running server, so we revert to simple grep
+#
+
+--error 0
+--exec grep 'safe_to_bootstrap: 1' $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
+
+--error 0
+--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+
+--error 0
+--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
+
+#
+# Attempt to bootstrap nodes #2, #3, should fail
+#
+
+--error 1
+--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster'
+--error 1
+--exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster'
+
+#
+# Attempt to bootstrap starting from node #1, should succeed
+#
+
+--connection node_1
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/start_mysqld.inc
+--source include/wait_until_connected_again.inc
+
+--connection node_2
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+--source include/start_mysqld.inc
+
+--connection node_3
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
+--source include/start_mysqld.inc
+
+--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
+--source include/wait_condition.inc
+
+--connection node_2
+CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
+
+--connection node_3
+CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/gcol/r/innodb_virtual_debug.result b/mysql-test/suite/gcol/r/innodb_virtual_debug.result
index a80ec95a2ca..af220c7cd17 100644
--- a/mysql-test/suite/gcol/r/innodb_virtual_debug.result
+++ b/mysql-test/suite/gcol/r/innodb_virtual_debug.result
@@ -223,5 +223,35 @@ vbcol
11
ac
drop table ibstd_14;
+#
+# Bug#22018745 CORRUPTION IN ONLINE TABLE REBUILD
+# (ROW_FORMAT=REDUNDANT, INDEXED VIRTUAL COLUMN)
+#
+CREATE TABLE t (
+b char(5) PRIMARY KEY,
+v char(3) GENERATED ALWAYS AS (substr(b,1,3)) VIRTUAL, KEY(v)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT;
+connection con1;
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL prepared WAIT_FOR apply';
+OPTIMIZE TABLE t;
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR prepared';
+INSERT INTO t SET b='fubar';
+BEGIN;
+DELETE FROM t;
+ROLLBACK;
+SET DEBUG_SYNC='now SIGNAL apply';
+connection con1;
+Table Op Msg_type Msg_text
+test.t optimize note Table does not support optimize, doing recreate + analyze instead
+test.t optimize status OK
+connection default;
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+SELECT * FROM t;
+b v
+fubar fub
+DROP TABLE t;
disconnect con1;
SET DEBUG_SYNC = 'RESET';
diff --git a/mysql-test/suite/gcol/r/innodb_virtual_fk.result b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
index 17ea0341049..1584c433009 100644
--- a/mysql-test/suite/gcol/r/innodb_virtual_fk.result
+++ b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
@@ -590,3 +590,101 @@ SELECT * FROM t2;
fld1 fld2
1 1
DROP TABLE t2, t1;
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+KEY (f1, f2), FOREIGN KEY(f1) REFERENCES t1(f1))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+EXPLAIN SELECT f1, f2 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL f1 9 NULL 1 Using index
+SELECT f1, f2 FROM t2;
+f1 f2
+1 1
+INSERT INTO t2(f1) VALUES(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`))
+DROP TABLE t2, t1;
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+KEY (f1, f2), FOREIGN KEY(f1) REFERENCES t1(f1)
+ON UPDATE CASCADE)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+EXPLAIN SELECT f1, f2 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL f1 9 NULL 1 Using index
+SELECT f1, f2 FROM t2;
+f1 f2
+1 1
+UPDATE t1 SET f1 = 2 WHERE f1 = 1;
+EXPLAIN SELECT f1, f2 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL f1 9 NULL 1 Using index
+SELECT f1, f2 FROM t2;
+f1 f2
+2 2
+DROP TABLE t2, t1;
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+KEY (f1, f2))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+SET FOREIGN_KEY_CHECKS = 0;
+ALTER TABLE t2 ADD FOREIGN KEY (f1) REFERENCES t1(f1)
+ON UPDATE CASCADE, ALGORITHM=INPLACE;
+SET FOREIGN_KEY_CHECKS = 1;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f2 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL f1 9 NULL 1 Using index
+SELECT f1, f2 FROM t2;
+f1 f2
+3 3
+DROP TABLE t2, t1;
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+KEY (f1, f2))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 ADD FOREIGN KEY (f1) REFERENCES t1(f1)
+ON UPDATE CASCADE, ALGORITHM=COPY;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f2 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL f1 9 NULL 1 Using index
+SELECT f1, f2 FROM t2;
+f1 f2
+3 3
+DROP TABLE t2, t1;
+CREATE TABLE t1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=INNODB;
+CREATE TABLE t2(f1 INT NOT NULL, f2 INT AS (1) VIRTUAL,
+f3 INT AS (2) VIRTUAL,
+FOREIGN KEY idx (f1) REFERENCES t1(f1) ON UPDATE CASCADE,
+KEY idx1 (f2, f1, f3))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 DROP COLUMN f2, ALGORITHM=INPLACE;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f3 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx1 9 NULL 1 Using index
+SELECT f1, f3 FROM t2;
+f1 f3
+3 2
+DROP TABLE t2, t1;
+CREATE TABLE t1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=INNODB;
+CREATE TABLE t2(f1 INT NOT NULL, f2 INT AS (1) VIRTUAL,
+f3 INT AS (2) VIRTUAL,
+FOREIGN KEY idx (f1) REFERENCES t1(f1) ON UPDATE CASCADE,
+KEY idx1 (f2, f1, f3))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 DROP COLUMN f2, ALGORITHM=COPY;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f3 FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx1 9 NULL 1 Using index
+SELECT f1, f3 FROM t2;
+f1 f3
+3 2
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug.test b/mysql-test/suite/gcol/t/innodb_virtual_debug.test
index 72be27775ed..7ccf0fb8fc7 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_debug.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_debug.test
@@ -233,6 +233,36 @@ select vbcol from ibstd_14;
drop table ibstd_14;
+--echo #
+--echo # Bug#22018745 CORRUPTION IN ONLINE TABLE REBUILD
+--echo # (ROW_FORMAT=REDUNDANT, INDEXED VIRTUAL COLUMN)
+--echo #
+
+CREATE TABLE t (
+ b char(5) PRIMARY KEY,
+ v char(3) GENERATED ALWAYS AS (substr(b,1,3)) VIRTUAL, KEY(v)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT;
+
+connection con1;
+SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL prepared WAIT_FOR apply';
+--send OPTIMIZE TABLE t
+connection default;
+
+SET DEBUG_SYNC='now WAIT_FOR prepared';
+INSERT INTO t SET b='fubar';
+BEGIN;
+DELETE FROM t;
+ROLLBACK;
+SET DEBUG_SYNC='now SIGNAL apply';
+
+connection con1;
+reap;
+
+connection default;
+CHECK TABLE t;
+SELECT * FROM t;
+DROP TABLE t;
+
disconnect con1;
SET DEBUG_SYNC = 'RESET';
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_fk.test b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
index 78b2159e020..6b02b0adbbe 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_fk.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
@@ -490,3 +490,89 @@ UPDATE t1 SET fld1= 2;
SELECT fld2 FROM t2;
SELECT * FROM t2;
DROP TABLE t2, t1;
+
+# Foreign key constraint references to virtual index
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+ KEY (f1, f2), FOREIGN KEY(f1) REFERENCES t1(f1))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+EXPLAIN SELECT f1, f2 FROM t2;
+SELECT f1, f2 FROM t2;
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2(f1) VALUES(2);
+DROP TABLE t2, t1;
+
+# Update foreign key constraint references to virtual index
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+ KEY (f1, f2), FOREIGN KEY(f1) REFERENCES t1(f1)
+ ON UPDATE CASCADE)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+EXPLAIN SELECT f1, f2 FROM t2;
+SELECT f1, f2 FROM t2;
+UPDATE t1 SET f1 = 2 WHERE f1 = 1;
+EXPLAIN SELECT f1, f2 FROM t2;
+SELECT f1, f2 FROM t2;
+DROP TABLE t2, t1;
+
+# Add foreign key constraint via inplace alter references to virtual index
+
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+ KEY (f1, f2))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+SET FOREIGN_KEY_CHECKS = 0;
+ALTER TABLE t2 ADD FOREIGN KEY (f1) REFERENCES t1(f1)
+ ON UPDATE CASCADE, ALGORITHM=INPLACE;
+SET FOREIGN_KEY_CHECKS = 1;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f2 FROM t2;
+SELECT f1, f2 FROM t2;
+DROP TABLE t2, t1;
+
+# Add foreign key constraint via copy alter references to virtual index
+
+CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY)ENGINE=INNODB;
+CREATE TABLE t2 (f1 INT NOT NULL, f2 INT AS (f1) VIRTUAL,
+ KEY (f1, f2))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 ADD FOREIGN KEY (f1) REFERENCES t1(f1)
+ ON UPDATE CASCADE, ALGORITHM=COPY;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f2 FROM t2;
+SELECT f1, f2 FROM t2;
+DROP TABLE t2, t1;
+
+# Drop column via inplace alter which triggers to remove the FK index idx
+
+CREATE TABLE t1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=INNODB;
+CREATE TABLE t2(f1 INT NOT NULL, f2 INT AS (1) VIRTUAL,
+ f3 INT AS (2) VIRTUAL,
+ FOREIGN KEY idx (f1) REFERENCES t1(f1) ON UPDATE CASCADE,
+ KEY idx1 (f2, f1, f3))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 DROP COLUMN f2, ALGORITHM=INPLACE;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f3 FROM t2;
+SELECT f1, f3 FROM t2;
+DROP TABLE t2, t1;
+
+# Drop column via copy alter which triggers to remove the FK index idx
+
+CREATE TABLE t1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=INNODB;
+CREATE TABLE t2(f1 INT NOT NULL, f2 INT AS (1) VIRTUAL,
+ f3 INT AS (2) VIRTUAL,
+ FOREIGN KEY idx (f1) REFERENCES t1(f1) ON UPDATE CASCADE,
+ KEY idx1 (f2, f1, f3))ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2(f1) VALUES(1);
+ALTER TABLE t2 DROP COLUMN f2, ALGORITHM=COPY;
+UPDATE t1 SET f1 = 3;
+EXPLAIN SELECT f1, f3 FROM t2;
+SELECT f1, f3 FROM t2;
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/innodb/include/innodb_isolation_selects.inc b/mysql-test/suite/innodb/include/innodb_isolation_selects.inc
new file mode 100644
index 00000000000..922f5c1c42c
--- /dev/null
+++ b/mysql-test/suite/innodb/include/innodb_isolation_selects.inc
@@ -0,0 +1,15 @@
+# These same selects are used many times in innodb_isolation.test
+
+--echo ########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(c1) FROM t1;
+SELECT COUNT(c2) FROM t1; # Uses secondary index k2
+SELECT COUNT(c3) FROM t1; # Uses clustered index
+SELECT SUM(c1) FROM t1; # Uses secondary index
+SELECT SUM(c2) FROM t1; # Uses secondary index
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; # Uses clustered index
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+--echo ###############################################
diff --git a/mysql-test/suite/innodb/r/autoinc_debug.result b/mysql-test/suite/innodb/r/autoinc_debug.result
new file mode 100644
index 00000000000..eb9dfc2a028
--- /dev/null
+++ b/mysql-test/suite/innodb/r/autoinc_debug.result
@@ -0,0 +1,100 @@
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
+# SETTING auto_increment_increment IN CONNECTION DEFAULT
+SET AUTO_INCREMENT_INCREMENT = 1;
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+id
+1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+# SETTING auto_increment_increment IN CONNECTION1
+SET AUTO_INCREMENT_INCREMENT = 2;
+SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
+INSERT INTO t1 VALUES(NULL);
+connect con1, localhost, root,,;
+SET AUTO_INCREMENT_INCREMENT = 2;
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
+insert into t1 values(NULL);
+connection default;
+SELECT * FROM t1;
+id
+1
+3
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+SET DEBUG_SYNC= 'now SIGNAL opened1';
+connection con1;
+SELECT * FROM t1;
+id
+1
+3
+5
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+connection default;
+disconnect con1;
+DROP TABLE t1;
+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
+# SETTING auto_increment_increment IN CONNECTION DEFAULT
+SET AUTO_INCREMENT_INCREMENT = 1;
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+id
+1
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+SET DEBUG_SYNC = 'now SIGNAL flushed';
+connect con1, localhost, root,,;
+# SETTING auto_increment_increment in connection1
+SET AUTO_INCREMENT_INCREMENT = 2;
+SET DEBUG_SYNC= 'now WAIT_FOR flushed';
+SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
+INSERT INTO t1 values(NULL);
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
+INSERT INTO t1 VALUES(NULL);
+connection con1;
+SELECT * FROM t1;
+id
+1
+3
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
+SET DEBUG_SYNC= 'now SIGNAL opened1';
+disconnect con1;
+connection default;
+SELECT * FROM t1;
+id
+1
+3
+5
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
diff --git a/mysql-test/suite/innodb/r/deadlock_detect.result b/mysql-test/suite/innodb/r/deadlock_detect.result
new file mode 100644
index 00000000000..c3e3794ed21
--- /dev/null
+++ b/mysql-test/suite/innodb/r/deadlock_detect.result
@@ -0,0 +1,30 @@
+SET GLOBAL innodb_deadlock_detect=OFF;
+SET GLOBAL innodb_lock_wait_timeout=2;
+connection default;
+CREATE TABLE t1(
+id INT,
+PRIMARY KEY(id)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1), (2), (3);
+BEGIN;
+SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
+id
+1
+connect con1,localhost,root,,;
+BEGIN;
+SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
+id
+2
+SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
+connection default;
+SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
+connection con1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ROLLBACK;
+connection default;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ROLLBACK;
+DROP TABLE t1;
+disconnect con1;
+SET GLOBAL innodb_lock_wait_timeout=default;
+SET GLOBAL innodb_deadlock_detect=default;
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result
new file mode 100644
index 00000000000..c0a6b37c1a0
--- /dev/null
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@ -0,0 +1,152 @@
+#
+# Bug #19027905 ASSERT RET.SECOND DICT_CREATE_FOREIGN_CONSTRAINTS_LOW
+# DICT_CREATE_FOREIGN_CONSTR
+#
+create table t1 (f1 int primary key) engine=InnoDB;
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1),
+constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB;
+ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1)) engine=innodb;
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 121 "Duplicate key on write or update")
+set foreign_key_checks = 0;
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+ERROR HY000: Duplicate FOREIGN KEY constraint name 'test/c1'
+drop table t2, t1;
+#
+# Bug #20031243 CREATE TABLE FAILS TO CHECK IF FOREIGN KEY COLUMN
+# NULL/NOT NULL MISMATCH
+#
+set foreign_key_checks = 1;
+show variables like 'foreign_key_checks';
+Variable_name Value
+foreign_key_checks ON
+CREATE TABLE t1
+(a INT NOT NULL,
+b INT NOT NULL,
+INDEX idx(a)) ENGINE=InnoDB;
+CREATE TABLE t2
+(a INT KEY,
+b INT,
+INDEX ind(b),
+FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE)
+ENGINE=InnoDB;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL,
+ KEY `idx` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `ind` (`b`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1, 80);
+INSERT INTO t1 VALUES (2, 81);
+INSERT INTO t1 VALUES (3, 82);
+INSERT INTO t1 VALUES (4, 83);
+INSERT INTO t1 VALUES (5, 84);
+INSERT INTO t2 VALUES (51, 1);
+INSERT INTO t2 VALUES (52, 2);
+INSERT INTO t2 VALUES (53, 3);
+INSERT INTO t2 VALUES (54, 4);
+INSERT INTO t2 VALUES (55, 5);
+SELECT a, b FROM t1 ORDER BY a;
+a b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+53 3
+54 4
+55 5
+INSERT INTO t2 VALUES (56, 6);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE)
+ALTER TABLE t1 CHANGE a id INT;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+53 3
+54 4
+55 5
+# Operations on child table
+INSERT INTO t2 VALUES (56, 6);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
+UPDATE t2 SET b = 99 WHERE a = 51;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
+DELETE FROM t2 WHERE a = 53;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+54 4
+55 5
+# Operations on parent table
+DELETE FROM t1 WHERE id = 1;
+UPDATE t1 SET id = 50 WHERE id = 5;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+2 81
+3 82
+4 83
+50 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+52 2
+54 4
+55 50
+DROP TABLE t2, t1;
+#
+# bug#25126722 FOREIGN KEY CONSTRAINT NAME IS NULL AFTER RESTART
+# base bug#24818604 [GR]
+#
+CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+SELECT * FROM t1;
+c1
+1
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/ibuf_not_empty.result b/mysql-test/suite/innodb/r/ibuf_not_empty.result
new file mode 100644
index 00000000000..2c898b8916d
--- /dev/null
+++ b/mysql-test/suite/innodb/r/ibuf_not_empty.result
@@ -0,0 +1,25 @@
+CREATE TABLE t1(
+a INT AUTO_INCREMENT PRIMARY KEY,
+b CHAR(1),
+c INT,
+INDEX(b))
+ENGINE=InnoDB STATS_PERSISTENT=0;
+SET GLOBAL innodb_change_buffering_debug = 1;
+INSERT INTO t1 VALUES(0,'x',1);
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check Warning InnoDB: Index 'b' contains #### entries, should be 4096.
+test.t1 check error Corrupt
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-index-online-norebuild.result b/mysql-test/suite/innodb/r/innodb-index-online-norebuild.result
new file mode 100644
index 00000000000..b9077643870
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-index-online-norebuild.result
@@ -0,0 +1,26 @@
+# INPLACE ALTER WITH INPLACE_IGNORE FLAG AND CHANGE CREATE OPTION
+# CHANGE THE COLUMN DEFAULT (INPLACE_IGNORE)
+# AND TABLE CHARSET(CHANGE CREATE)
+CREATE TABLE t1(
+id INT PRIMARY KEY,
+f1 INT NOT NULL DEFAULT 0)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1, 2);
+SET SQL_MODE='STRICT_ALL_TABLES';
+ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL DEFAULT 0,
+DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+DROP TABLE t1;
+# CHANGE THE COMMENT OF COLUMN(INPLACE IGNORE)
+# AND TABLE CHARSET(CHANGE CREATE)
+CREATE TABLE t1(id INT COMMENT 'independence day')ENGINE=INNODB;
+INSERT INTO t1 values(1);
+ALTER TABLE t1 MODIFY COLUMN id INT COMMENT 'identifier',
+DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+DROP TABLE t1;
+# RENAME THE TABLE(INPLACE IGNORE)
+# AND CHANGE TABLE CHARSET(CHANGE CREATE)
+CREATE TABLE t1(
+f1 INT NOT NULL,
+f2 INT NOT NULL)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1, 2);
+ALTER TABLE t1 RENAME t2, DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+DROP TABLE t2;
diff --git a/mysql-test/suite/innodb/r/innodb-isolation.result b/mysql-test/suite/innodb/r/innodb-isolation.result
new file mode 100644
index 00000000000..2248d25b39a
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-isolation.result
@@ -0,0 +1,1411 @@
+#
+# WL#6742 - Test the interaction of multiple transactions using
+# different isolation levels to make sure that the value returned
+# by count(*) always reflects the correct view of the table according
+# to the transaction's selected isolation level.
+#
+#
+# Traverse various indexes to get the right counts.
+# This especially tests count(*) which is pushed down to InnoDB in WL#6742.
+#
+CREATE TABLE t1 (
+c1 INT AUTO_INCREMENT PRIMARY KEY,
+c2 INT,
+c3 INT,
+c4 INT,
+INDEX k2(c2)
+) Engine=InnoDB;
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 (SELECT * FROM t1);
+affected rows: 10
+info: Records: 10 Duplicates: 0 Warnings: 0
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+55
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+10
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.5000 10 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Do some DML in the default connection and leave the transaction pending.
+#
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1;
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+DELETE FROM t1 WHERE c1 = 6;
+affected rows: 1
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+49
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.4444 10 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Start transactions of Repeatable Read, Read Committed, and Read Uncommitted
+#
+# Connection 1 REPEATABLE READ
+#
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+55
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+10
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.5000 10 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+UPDATE t1 SET c2 = c2 * 5 WHERE c1 = 2;
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+DELETE FROM t1 WHERE c1 = 7;
+affected rows: 1
+INSERT INTO t1(c2,c3,c4) VALUES (100, 1, 1);
+affected rows: 1
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 5 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+11 100 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+59
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+113
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.9000 11 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+8 1
+9 1
+10 1
+11 100
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Test a lock wait timeout during COUNT(*)
+#
+SET innodb_lock_wait_timeout = 1;
+SELECT COUNT(*) FROM t1 FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+#
+# Connection 2 READ COMMITTED
+#
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+55
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+10
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.5000 10 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+UPDATE t1 SET c2 = c2 * 7 WHERE c1 = 3;
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+DELETE FROM t1 WHERE c1 = 8;
+affected rows: 1
+INSERT INTO t1(c2,c3,c4) VALUES (1000, 1, 1);
+affected rows: 1
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 7 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+9 1 1 1
+10 1 1 1
+12 1000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+59
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+1015
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.9000 12 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+9 1
+10 1
+12 1000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Connection 3 READ UNCOMMITTED
+#
+connect con3,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+BEGIN;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 5 1 1
+3 7 1 1
+4 1 1 1
+5 1 1 1
+9 1 1 1
+10 1 1 1
+11 100 1 1
+12 1000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+57
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+1119
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.3333 12 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+9 1
+10 1
+11 100
+12 1000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+UPDATE t1 SET c2 = c2 * 11 WHERE c1 = 4;
+affected rows: 1
+info: Rows matched: 1 Changed: 1 Warnings: 0
+INSERT INTO t1(c2,c3,c4) VALUES (10000, 1, 1);
+affected rows: 1
+DELETE FROM t1 WHERE c1 in(9);
+affected rows: 1
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 5 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+10 1 1 1
+11 100 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+61
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11128
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7778 13 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Connection default REPEATABLE READ
+#
+connection default;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+49
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.4444 10 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Commit the 3 extra connections
+#
+# Connection 1 REPEATABLE READ
+#
+connection con1;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 5 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+11 100 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+59
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+113
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.9000 11 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+8 1
+9 1
+10 1
+11 100
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Connection 2 READ COMMITTED
+#
+connection con2;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 7 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+9 1 1 1
+10 1 1 1
+12 1000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+59
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+1015
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.9000 12 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+9 1
+10 1
+12 1000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Connection 3 READ UNCOMMITTED
+#
+connection con3;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 5 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+10 1 1 1
+11 100 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+61
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11128
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7778 13 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+COMMIT;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 5 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+10 1 1 1
+11 100 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+61
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11128
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7778 13 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Connection 2 READ COMMITTED
+#
+connection con2;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+10 1 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+63
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11024
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.3000 13 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+10 1
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+COMMIT;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 1 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+6 1 1 1
+7 1 1 1
+10 1 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+63
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11024
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.3000 13 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+7 1
+10 1
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Connection 1 REPEATABLE READ
+#
+connection con1;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 5 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+6 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+11 100 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+59
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+113
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.9000 11 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+8 1
+9 1
+10 1
+11 100
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+5
+###############################################
+#
+# Select the first 5 records FOR UPDATE using count(*) in a subquery.
+# The second record is still pending so we get a lock timeout.
+#
+SET innodb_lock_wait_timeout = 1;
+SELECT c1, c2 FROM t1 WHERE c1 < ((SELECT COUNT(*) FROM t1) / 2) FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT COUNT(*) FROM t1 FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+COMMIT;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 1 1 1
+2 5 1 1
+3 7 1 1
+4 11 1 1
+5 1 1 1
+6 1 1 1
+10 1 1 1
+11 100 1 1
+12 1000 1 1
+13 10000 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+10
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+10
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+10
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+67
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11127
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7000 13 1 1.0000 10
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+6 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Show The EXPLAIN output for these queries;
+#
+EXPLAIN SELECT * FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
+EXPLAIN SELECT COUNT(*) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 5 NULL 12 Using index
+EXPLAIN SELECT COUNT(c1) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 5 NULL 12 Using index
+EXPLAIN SELECT COUNT(c2) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 5 NULL 12 #
+EXPLAIN SELECT COUNT(c3) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
+EXPLAIN SELECT SUM(c1) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 5 NULL 12 #
+EXPLAIN SELECT SUM(c2) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 5 NULL 12 #
+EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
+EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
+2 SUBQUERY t1 index NULL k2 5 NULL 12 #
+EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
+2 SUBQUERY t1 index NULL k2 5 NULL 12 #
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 7 #
+2 SUBQUERY t1 index NULL k2 5 NULL 12 #
+#
+# Make all indexes in t2 obsolete to the active repeatable read transaction
+# in the default connection.
+#
+ALTER TABLE t2 row_format=redundant;
+#
+# Connection default REPEATABLE READ
+# Do more DML in the default REPEATABLE READ transaction in order to use recently committed records.
+#
+connection default;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 1
+2 1 1 1
+3 1 1 1
+4 1 1 1
+5 1 1 1
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+49
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+5.4444 10 1 1.0000 9
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+7 1
+8 1
+9 1
+10 1
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+UPDATE t1 SET c4 = c2 * 10;
+affected rows: 9
+info: Rows matched: 9 Changed: 9 Warnings: 0
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 30
+2 5 1 50
+3 7 1 70
+4 11 1 110
+5 1 1 10
+7 1 1 1
+8 1 1 1
+9 1 1 1
+10 1 1 10
+11 100 1 1000
+12 1000 1 10000
+13 10000 1 100000
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+12
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+12
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+12
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+12
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+85
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11131
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+7.0833 13 1 1.0000 111283
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+7 1
+8 1
+9 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+7
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+6
+###############################################
+#
+# Table t2 has been altered to a new row format.
+# The index should not be useable.
+#
+SELECT COUNT(*) FROM t2;
+ERROR HY000: Table definition has changed, please retry transaction
+SELECT * FROM t2;
+ERROR HY000: Table definition has changed, please retry transaction
+COMMIT;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+10
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 30
+2 5 1 50
+3 7 1 70
+4 11 1 110
+5 1 1 10
+10 1 1 10
+11 100 1 1000
+12 1000 1 10000
+13 10000 1 100000
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+61
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11128
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7778 13 1 1.0000 111280
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Connection 2
+#
+connection con2;
+########## innodb_isolation_selects.inc ##########
+SELECT * FROM t1;
+c1 c2 c3 c4
+1 3 1 30
+2 5 1 50
+3 7 1 70
+4 11 1 110
+5 1 1 10
+10 1 1 10
+11 100 1 1000
+12 1000 1 10000
+13 10000 1 100000
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9
+SELECT COUNT(c1) FROM t1;
+COUNT(c1)
+9
+SELECT COUNT(c2) FROM t1;
+COUNT(c2)
+9
+SELECT COUNT(c3) FROM t1;
+COUNT(c3)
+9
+SELECT SUM(c1) FROM t1;
+SUM(c1)
+61
+SELECT SUM(c2) FROM t1;
+SUM(c2)
+11128
+SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4)
+6.7778 13 1 1.0000 111280
+SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+c1 c2
+5 1
+10 1
+11 100
+12 1000
+13 10000
+SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+COUNT(c2)
+5
+SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+COUNT(*)
+4
+###############################################
+#
+# Try COUNT(*) on a DISCARDED table.
+#
+connection default;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t4 (SELECT * FROM t1);
+SELECT COUNT(*) FROM t4;
+COUNT(*)
+9
+ALTER TABLE t4 DISCARD TABLESPACE;
+SELECT COUNT(*) FROM t4;
+ERROR HY000: Tablespace has been discarded for table `t4`
+#
+# Test the interaction of a repeatable read transaction
+# to changes that happen outside its view.
+#
+CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+UPDATE t5 SET aa=a, bb=b;
+CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+UPDATE t6 SET aa=a, bb=b;
+CREATE TABLE t7 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+UPDATE t7 SET aa=a, bb=b;
+BEGIN;
+SELECT * FROM t5;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 inserted by client 1 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+SELECT COUNT(*) FROM t5;
+COUNT(*)
+4
+SELECT * FROM t6;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 inserted by client 1 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+SELECT COUNT(*) FROM t6;
+COUNT(*)
+4
+SELECT * FROM t7;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 inserted by client 1 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+SELECT COUNT(*) FROM t7;
+COUNT(*)
+4
+#
+# Connection 1
+#
+connection con1;
+INSERT INTO t5(b) VALUES ("inserted by client 2");
+UPDATE t5 SET a = 10 where a = 1;
+UPDATE t5 SET b = "updated by client 2" where a = 2;
+DELETE FROM t5 WHERE a = 3;
+SELECT * FROM t5;
+a b aa bb
+2 updated by client 2 2 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+5 inserted by client 2 NULL NULL
+10 inserted by client 1 1 inserted by client 1
+SELECT COUNT(*) FROM t5;
+COUNT(*)
+4
+INSERT INTO t6(b) VALUES ("inserted by client 2");
+UPDATE t6 SET a = 10 where a = 1;
+UPDATE t6 SET b = "updated by client 2" where a = 2;
+DELETE FROM t6 WHERE a = 3;
+SELECT * FROM t6;
+a b aa bb
+2 updated by client 2 2 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+5 inserted by client 2 NULL NULL
+10 inserted by client 1 1 inserted by client 1
+SELECT COUNT(*) FROM t6;
+COUNT(*)
+4
+INSERT INTO t7(b) VALUES ("inserted by client 2");
+UPDATE t7 SET a = 10 where a = 1;
+UPDATE t7 SET b = "updated by client 2" where a = 2;
+DELETE FROM t7 WHERE a = 3;
+SELECT * FROM t7;
+a b aa bb
+2 updated by client 2 2 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+5 inserted by client 2 NULL NULL
+10 inserted by client 1 1 inserted by client 1
+SELECT COUNT(*) FROM t7;
+COUNT(*)
+4
+#
+# Connection default
+#
+connection default;
+SELECT * FROM t5;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 inserted by client 1 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+SELECT * FROM t5;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 inserted by client 1 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 inserted by client 1 4 inserted by client 1
+11 inserted by client 1 NULL NULL
+UPDATE t5 SET a = a + 100;
+SELECT * FROM t5;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+102 updated by client 2 2 inserted by client 1
+104 inserted by client 1 4 inserted by client 1
+105 inserted by client 2 NULL NULL
+110 inserted by client 1 1 inserted by client 1
+111 inserted by client 1 NULL NULL
+SELECT COUNT(*) FROM t5;
+COUNT(*)
+7
+UPDATE t6 SET b = "updated by client 2";
+SELECT * FROM t6;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+2 updated by client 2 2 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+4 updated by client 2 4 inserted by client 1
+5 updated by client 2 NULL NULL
+10 updated by client 2 1 inserted by client 1
+SELECT COUNT(*) FROM t6;
+COUNT(*)
+6
+DELETE FROM t7;
+SELECT * FROM t7;
+a b aa bb
+1 inserted by client 1 1 inserted by client 1
+3 inserted by client 1 3 inserted by client 1
+SELECT COUNT(*) FROM t7;
+COUNT(*)
+2
+COMMIT;
+SELECT * FROM t5;
+a b aa bb
+102 updated by client 2 2 inserted by client 1
+104 inserted by client 1 4 inserted by client 1
+105 inserted by client 2 NULL NULL
+110 inserted by client 1 1 inserted by client 1
+111 inserted by client 1 NULL NULL
+SELECT COUNT(*) FROM t5;
+COUNT(*)
+5
+SELECT * FROM t6;
+a b aa bb
+2 updated by client 2 2 inserted by client 1
+4 updated by client 2 4 inserted by client 1
+5 updated by client 2 NULL NULL
+10 updated by client 2 1 inserted by client 1
+SELECT COUNT(*) FROM t6;
+COUNT(*)
+4
+SELECT * FROM t7;
+a b aa bb
+SELECT COUNT(*) FROM t7;
+COUNT(*)
+0
+#
+# Cleanup
+#
+DROP TABLE t1,t2,t4,t5,t6,t7;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+#
+# Bug #23596760: FORCE INDEX IS SKIPPED WHILE EXECUTING SELECT COUNT(*)
+#
+CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY,
+c2 INT NOT NULL DEFAULT 1,
+c3 char(20) DEFAULT '',
+KEY c2_idx (c2)) ENGINE=InnoDB;
+INSERT INTO t1(c1) VALUES (1), (2), (3);
+INSERT INTO t1(c1) SELECT c1 + 10 FROM t1;
+INSERT INTO t1(c1) SELECT c1 + 100 FROM t1;
+CREATE TABLE t2 SELECT * FROM t1;
+EXPLAIN SELECT COUNT(*) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL c2_idx 4 NULL 12 Using index
+EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL c2_idx 4 NULL 12 Using index
+EXPLAIN SELECT COUNT(*) FROM t1, t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL c2_idx 4 NULL 12 Using index
+1 SIMPLE t2 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx), t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL c2_idx 4 NULL 12 Using index
+1 SIMPLE t2 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff-disabled b/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff-disabled
deleted file mode 100644
index 4aea0b451ec..00000000000
--- a/mysql-test/suite/innodb/r/innodb-wl5522,xtradb.rdiff-disabled
+++ /dev/null
@@ -1,56 +0,0 @@
---- suite/innodb/r/innodb-wl5522.result
-+++ suite/innodb/r/innodb-wl5522.reject
-@@ -580,7 +580,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
-@@ -592,7 +592,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
-@@ -766,7 +766,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
-@@ -778,7 +778,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
-@@ -955,7 +955,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
-@@ -967,7 +967,7 @@
- ERROR HY000: Tablespace has been discarded for table 't1'
- restore: t1 .ibd and .cfg files
- ALTER TABLE t1 IMPORT TABLESPACE;
--ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21)
-+ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21)
- unlink: t1.ibd
- unlink: t1.cfg
- DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb_force_recovery.result b/mysql-test/suite/innodb/r/innodb_force_recovery.result
new file mode 100644
index 00000000000..e405a79dd53
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_force_recovery.result
@@ -0,0 +1,90 @@
+create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
+create table t2(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
+insert into t1 values(1, 2);
+insert into t2 values(1, 2);
+SET GLOBAL innodb_fast_shutdown = 0;
+# Restart the server with innodb_force_recovery as 4.
+select * from t1;
+f1 f2
+1 2
+insert into t1 values(2, 3);
+ERROR HY000: Running in read-only mode
+alter table t1 add f3 int not null, algorithm=copy;
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 165 "Table is read only")
+alter table t1 add f3 int not null, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Operation not allowed when innodb_forced_recovery > 0.. Try ALGORITHM=COPY
+drop index idx on t1;
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 165 "Table is read only")
+alter table t1 drop index idx, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Operation not allowed when innodb_forced_recovery > 0.. Try ALGORITHM=COPY
+update t1 set f1=3 where f2=2;
+ERROR HY000: Running in read-only mode
+create table t3(f1 int not null)engine=innodb;
+ERROR HY000: Can't create table `test`.`t3` (errno: 165 "Table is read only")
+drop table t3;
+ERROR 42S02: Unknown table 'test.t3'
+rename table t1 to t3;
+ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 165 "Table is read only")
+truncate table t1;
+ERROR HY000: Table 't1' is read only
+drop table t1;
+show tables;
+Tables_in_test
+t2
+# Restart the server with innodb_force_recovery as 5.
+select * from t2;
+f1 f2
+1 2
+insert into t2 values(2, 3);
+ERROR HY000: Running in read-only mode
+alter table t2 add f3 int not null, algorithm=copy;
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 165 "Table is read only")
+alter table t2 add f3 int not null, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Operation not allowed when innodb_forced_recovery > 0.. Try ALGORITHM=COPY
+drop index idx on t2;
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 165 "Table is read only")
+update t2 set f1=3 where f2=2;
+ERROR HY000: Running in read-only mode
+create table t1(f1 int not null)engine=innodb;
+ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
+drop table t1;
+ERROR 42S02: Unknown table 'test.t1'
+rename table t2 to t3;
+ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
+truncate table t2;
+ERROR HY000: Table 't2' is read only
+drop table t2;
+ERROR HY000: Table 't2' is read only
+show tables;
+Tables_in_test
+t2
+# Restart the server with innodb_force_recovery as 6.
+select * from t2;
+f1 f2
+1 2
+insert into t2 values(2, 3);
+ERROR HY000: Table 't2' is read only
+alter table t2 add f3 int not null, algorithm=copy;
+ERROR HY000: Table 't2' is read only
+alter table t2 add f3 int not null, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Operation not allowed when innodb_forced_recovery > 0.. Try ALGORITHM=COPY
+drop index idx on t2;
+ERROR HY000: Table 't2' is read only
+update t2 set f1=3 where f2=2;
+ERROR HY000: Table 't2' is read only
+create table t1(f1 int not null)engine=innodb;
+ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
+drop table t1;
+ERROR 42S02: Unknown table 'test.t1'
+rename table t2 to t3;
+ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
+truncate table t2;
+ERROR HY000: Table 't2' is read only
+drop table t2;
+ERROR HY000: Table 't2' is read only
+show tables;
+Tables_in_test
+t2
+drop table t2;
+show tables;
+Tables_in_test
diff --git a/mysql-test/suite/innodb/r/innodb_gis.result b/mysql-test/suite/innodb/r/innodb_gis.result
index baae47d4544..a99d7dd72a5 100644
--- a/mysql-test/suite/innodb/r/innodb_gis.result
+++ b/mysql-test/suite/innodb/r/innodb_gis.result
@@ -599,3 +599,12 @@ create unique index a on t1(a);
drop table t1;
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
drop table t1;
+create table t1(id int not null primary key, g1 geometry not null, spatial index(g1));
+insert into t1 values(1, polygonfromtext('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'));
+explain select id from t1 where contains(g1, pointfromtext('POINT(1 1)'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range g1 g1 34 NULL 1 Using where
+select id from t1 where contains(g1, pointfromtext('POINT(1 1)'));
+id
+1
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb_stats_del_mark.result b/mysql-test/suite/innodb/r/innodb_stats_del_mark.result
new file mode 100644
index 00000000000..67538bf8eb3
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_stats_del_mark.result
@@ -0,0 +1,91 @@
+#
+# Bug 23333990 PERSISTENT INDEX STATISTICS UPDATE BEFORE
+# TRANSACTION IS COMMITTED
+#
+"Test 1:- Uncommited delete test"
+CREATE TABLE t1 (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+val INT UNSIGNED NOT NULL,
+INDEX (val)) ENGINE=INNODB
+STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
+INSERT INTO t1 (val) VALUES (CEIL(RAND()*20));
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+262144
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+connect con1, localhost, root,,;
+START TRANSACTION;
+DELETE FROM t1;
+SELECT COUNT(*) FROM t1;
+connection default;
+Test correctly estimates the number of rows as > 20000
+even when in other uncommmited transaction
+all rows have been deleted.
+connection con1;
+COUNT(*)
+0
+commit;
+connection default;
+Test 2:- Insert and rollback test
+CREATE TABLE t2 (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+val INT UNSIGNED NOT NULL,
+INDEX (val)) ENGINE=INNODB
+STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
+connection con1;
+START TRANSACTION;
+INSERT INTO t2 (val) VALUES (CEIL(RAND()*20));
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+SELECT COUNT(*) FROM t2;
+connection default;
+select count(*) from t2;
+count(*)
+0
+Test correctly estimates the number of rows as > 20000
+even when in other uncommited transaction
+many rows are inserted.
+connection con1;
+COUNT(*)
+262144
+Rollback the insert
+rollback;
+disconnect con1;
+connection default;
+Test correctly estimates the number of rows as 1
+after rollback.
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb/r/insert_debug.result b/mysql-test/suite/innodb/r/insert_debug.result
index 0d176afa116..3ac9df58c16 100644
--- a/mysql-test/suite/innodb/r/insert_debug.result
+++ b/mysql-test/suite/innodb/r/insert_debug.result
@@ -9,3 +9,23 @@ PARTITION BY HASH (c1) PARTITIONS 15;
DROP TABLE t1;
SET GLOBAL innodb_change_buffering_debug=0;
SET GLOBAL innodb_limit_optimistic_insert_debug=0;
+#
+# Bug#25082593 FOREIGN KEY VALIDATION DOESN'T NEED
+# TO ACQUIRE GAP LOCK IN READ COMMITTED
+#
+SET GLOBAL innodb_limit_optimistic_insert_debug=2;
+CREATE TABLE t1(col1 INT PRIMARY KEY) ENGINE=INNODB;
+CREATE TABLE t2(col1 INT PRIMARY KEY, col2 INT NOT NULL,
+FOREIGN KEY(col2) REFERENCES t1(col1)) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1), (3), (4);
+connect con1,localhost,root;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+INSERT INTO t2 VALUES(1, 3);
+connection default;
+START TRANSACTION;
+INSERT INTO t1 VALUES(2);
+disconnect con1;
+SET GLOBAL innodb_limit_optimistic_insert_debug=0;
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/readahead.result b/mysql-test/suite/innodb/r/readahead.result
new file mode 100644
index 00000000000..f7d6e6fae31
--- /dev/null
+++ b/mysql-test/suite/innodb/r/readahead.result
@@ -0,0 +1,6 @@
+# Bug#25330449 ASSERT SIZE==SPACE->SIZE DURING BUF_READ_AHEAD_RANDOM
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=INNODB ROW_FORMAT=COMPRESSED;
+SET @saved = @@GLOBAL.innodb_random_read_ahead;
+SET GLOBAL innodb_random_read_ahead = 1;
+DROP TABLE t1;
+SET GLOBAL innodb_random_read_ahead = @saved;
diff --git a/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result b/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result
new file mode 100644
index 00000000000..efe48682a6f
--- /dev/null
+++ b/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result
@@ -0,0 +1,25 @@
+SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
+SET GLOBAL innodb_dict_stats_disabled_debug = 1;
+SET GLOBAL innodb_master_thread_disabled_debug = 1;
+SET GLOBAL innodb_log_checkpoint_now = 1;
+CREATE DATABASE very_long_database_name;
+USE very_long_database_name;
+set debug_dbug = '+d,increase_mtr_checkpoint_size';
+set debug_dbug = '+d,crash_after_checkpoint';
+set global innodb_log_checkpoint_now = 1;
+ERROR HY000: Lost connection to MySQL server during query
+# Skip MLOG_FILE_NAME redo records during recovery
+DROP DATABASE very_long_database_name;
+SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
+SET GLOBAL innodb_dict_stats_disabled_debug = 1;
+SET GLOBAL innodb_master_thread_disabled_debug = 1;
+SET GLOBAL innodb_log_checkpoint_now = 1;
+# Commit the multi-rec mini transaction if mtr size
+# exceeds LOG_CHECKPOINT_FREE_PER_THREAD size during checkpoint.
+CREATE DATABASE very_long_database_name;
+USE very_long_database_name;
+set debug_dbug = '+d,crash_after_checkpoint';
+set global innodb_log_checkpoint_now = 1;
+ERROR HY000: Lost connection to MySQL server during query
+# Skip MLOG_FILE_NAME redo records during recovery
+DROP DATABASE very_long_database_name;
diff --git a/mysql-test/suite/innodb/r/truncate_debug.result b/mysql-test/suite/innodb/r/truncate_debug.result
new file mode 100644
index 00000000000..47316fed2f7
--- /dev/null
+++ b/mysql-test/suite/innodb/r/truncate_debug.result
@@ -0,0 +1,86 @@
+#
+# Bug #23070734 CONCURRENT TRUNCATE TABLES CAUSE STALLS
+#
+Test_1 :- Check if DDL operations are possible on
+table being truncated. Also check if
+DDL operations on other tables succeed.
+create table t1 (f1 int,f2 int,key(f2),f3 int) engine=innodb;
+create index idx1 on t1(f3);
+create table t2 (f1 int,f2 int,key(f2),f3 int) engine=innodb;
+create table t3 (f1 int,f2 int,key(f2)) engine=innodb;
+insert into t1 values (10,20,30),(30,40,50),(50,60,70);
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t2 values (10,20,30),(30,40,50),(50,60,70);
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t3 values (10,20),(30,40),(50,50);
+insert into t3 select * from t3;
+insert into t3 select * from t3;
+SET session lock_wait_timeout = 1;
+connect con1,localhost,root,,;
+SET DEBUG_SYNC= 'buffer_pool_scan SIGNAL started WAIT_FOR finish_scan';
+truncate table t1;
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR started';
+Check Analyze table. Gives lock time out error.
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze Error Lock wait timeout exceeded; try restarting transaction
+test.t1 analyze status Operation failed
+Check if we can turn off auto recalculation.
+alter table t1 STATS_AUTO_RECALC=0;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check if we can turn off persistent stats on the table
+alter table t1 STATS_PERSISTENT=0;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check if DML is possible on table being truncated
+insert into t1 values (10,89,99);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check if DDL is possible on table being truncated
+alter table t1 add column f4 int;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+check if table can be created with the same name
+create table t1 (bd int) engine=innodb;
+Got one of the listed errors
+check if index can be created on table being truncated
+create index idx1 on t1(f1);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check if DROP of table is possible during truncate
+drop table t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check if select is possible during truncate
+select * from t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t2 where t2.f1=t1.f1;
+ERROR 42S22: Unknown column 't1.f1' in 'where clause'
+Check concurrent truncate operation on table;
+truncate table t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+Check concurrent selects and inserts on the other table
+insert into t3 values (10,20),(30,40),(50,50);
+select * from t3 where f1=40;
+f1 f2
+Concurrent truncate on other tables
+truncate table t2;
+Concurrent alters on the other tables
+alter table t2 add column f4 int;
+check if index can be created on the other table
+create index idx1 on t2(f3);
+Check if we can turn off persistent stats off entire instance
+SET GLOBAL innodb_stats_persistent=off;
+connect con2,localhost,root,,;
+set global innodb_adaptive_hash_index=off;
+connection default;
+SET DEBUG_SYNC= 'now SIGNAL finish_scan';
+SET DEBUG_SYNC= 'RESET';
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection default;
+SET session lock_wait_timeout=default;
+set global innodb_adaptive_hash_index=on;
+drop table t1,t2,t3;
diff --git a/mysql-test/suite/innodb/r/truncate_purge_debug.result b/mysql-test/suite/innodb/r/truncate_purge_debug.result
new file mode 100644
index 00000000000..edece3019bc
--- /dev/null
+++ b/mysql-test/suite/innodb/r/truncate_purge_debug.result
@@ -0,0 +1,29 @@
+#
+# Bug #23070734 CONCURRENT TRUNCATE TABLES CAUSE STALLS
+#
+create table t1 (f1 int ,f2 int,key(f2)) engine=innodb;
+begin;
+insert into t1 values (10,45),(20,78),(30,88),(40,23),(50,78),(60,11),(70,56),(80,90);
+delete from t1;
+connect con2,localhost,root,,;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection default;
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+commit;
+connect con1,localhost,root,,;
+SET DEBUG_SYNC= 'buffer_pool_scan SIGNAL started WAIT_FOR finish_scan';
+truncate table t1;
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR started';
+COMMIT;
+disconnect con2;
+connection default;
+InnoDB 0 transactions not purged
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
+SET DEBUG_SYNC = 'now SIGNAL finish_scan';
+SET DEBUG_SYNC = 'RESET';
+connection con1;
+disconnect con1;
+connection default;
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/autoinc_debug.test b/mysql-test/suite/innodb/t/autoinc_debug.test
new file mode 100644
index 00000000000..2e662565490
--- /dev/null
+++ b/mysql-test/suite/innodb/t/autoinc_debug.test
@@ -0,0 +1,85 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/not_embedded.inc
+
+# Two parallel connection with autoinc column after restart.
+
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
+
+--echo # SETTING auto_increment_increment IN CONNECTION DEFAULT
+SET AUTO_INCREMENT_INCREMENT = 1;
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+
+--source include/restart_mysqld.inc
+
+--echo # SETTING auto_increment_increment IN CONNECTION1
+SET AUTO_INCREMENT_INCREMENT = 2;
+
+SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
+
+SEND INSERT INTO t1 VALUES(NULL);
+
+connect(con1, localhost, root,,);
+SET AUTO_INCREMENT_INCREMENT = 2;
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
+send insert into t1 values(NULL);
+
+connection default;
+reap;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+SET DEBUG_SYNC= 'now SIGNAL opened1';
+
+connection con1;
+reap;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+connection default;
+disconnect con1;
+
+DROP TABLE t1;
+
+# Two parallel connection with autoinc column without restart.
+
+CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
+
+--echo # SETTING auto_increment_increment IN CONNECTION DEFAULT
+SET AUTO_INCREMENT_INCREMENT = 1;
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+SET DEBUG_SYNC = 'now SIGNAL flushed';
+
+connect(con1, localhost, root,,);
+
+--echo # SETTING auto_increment_increment in connection1
+SET AUTO_INCREMENT_INCREMENT = 2;
+
+SET DEBUG_SYNC= 'now WAIT_FOR flushed';
+SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
+
+send INSERT INTO t1 values(NULL);
+
+connection default;
+
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
+
+send INSERT INTO t1 VALUES(NULL);
+
+connection con1;
+reap;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+SET DEBUG_SYNC= 'now SIGNAL opened1';
+disconnect con1;
+
+connection default;
+reap;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
diff --git a/mysql-test/suite/innodb/t/deadlock_detect.test b/mysql-test/suite/innodb/t/deadlock_detect.test
new file mode 100644
index 00000000000..85d8c1f67f2
--- /dev/null
+++ b/mysql-test/suite/innodb/t/deadlock_detect.test
@@ -0,0 +1,55 @@
+#
+# wl#9383 INNODB: ADD AN OPTION TO TURN OFF/ON DEADLOCK CHECKER
+#
+
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+--source include/count_sessions.inc
+
+SET GLOBAL innodb_deadlock_detect=OFF;
+SET GLOBAL innodb_lock_wait_timeout=2;
+
+connection default;
+
+CREATE TABLE t1(
+ id INT,
+ PRIMARY KEY(id)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES(1), (2), (3);
+
+BEGIN;
+
+SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
+
+connect (con1,localhost,root,,);
+
+BEGIN;
+
+SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
+
+send SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
+
+connection default;
+send SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
+
+connection con1;
+--error ER_LOCK_WAIT_TIMEOUT
+reap;
+
+ROLLBACK;
+
+connection default;
+--error ER_LOCK_WAIT_TIMEOUT
+reap;
+
+ROLLBACK;
+
+DROP TABLE t1;
+
+disconnect con1;
+
+--source include/wait_until_count_sessions.inc
+
+SET GLOBAL innodb_lock_wait_timeout=default;
+SET GLOBAL innodb_deadlock_detect=default;
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
new file mode 100644
index 00000000000..750465f2b85
--- /dev/null
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -0,0 +1,115 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # Bug #19027905 ASSERT RET.SECOND DICT_CREATE_FOREIGN_CONSTRAINTS_LOW
+--echo # DICT_CREATE_FOREIGN_CONSTR
+--echo #
+
+create table t1 (f1 int primary key) engine=InnoDB;
+--error ER_CANT_CREATE_TABLE
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1),
+constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB;
+create table t2 (f1 int primary key,
+ constraint c1 foreign key (f1) references t1(f1)) engine=innodb;
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+
+set foreign_key_checks = 0;
+--error ER_DUP_CONSTRAINT_NAME
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+
+drop table t2, t1;
+
+--echo #
+--echo # Bug #20031243 CREATE TABLE FAILS TO CHECK IF FOREIGN KEY COLUMN
+--echo # NULL/NOT NULL MISMATCH
+--echo #
+
+set foreign_key_checks = 1;
+show variables like 'foreign_key_checks';
+
+CREATE TABLE t1
+(a INT NOT NULL,
+ b INT NOT NULL,
+ INDEX idx(a)) ENGINE=InnoDB;
+
+CREATE TABLE t2
+(a INT KEY,
+ b INT,
+ INDEX ind(b),
+ FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE)
+ ENGINE=InnoDB;
+
+show create table t1;
+show create table t2;
+
+INSERT INTO t1 VALUES (1, 80);
+INSERT INTO t1 VALUES (2, 81);
+INSERT INTO t1 VALUES (3, 82);
+INSERT INTO t1 VALUES (4, 83);
+INSERT INTO t1 VALUES (5, 84);
+
+INSERT INTO t2 VALUES (51, 1);
+INSERT INTO t2 VALUES (52, 2);
+INSERT INTO t2 VALUES (53, 3);
+INSERT INTO t2 VALUES (54, 4);
+INSERT INTO t2 VALUES (55, 5);
+
+SELECT a, b FROM t1 ORDER BY a;
+SELECT a, b FROM t2 ORDER BY a;
+
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES (56, 6);
+
+ALTER TABLE t1 CHANGE a id INT;
+
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+--echo # Operations on child table
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES (56, 6);
+--error ER_NO_REFERENCED_ROW_2
+UPDATE t2 SET b = 99 WHERE a = 51;
+DELETE FROM t2 WHERE a = 53;
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+--echo # Operations on parent table
+DELETE FROM t1 WHERE id = 1;
+UPDATE t1 SET id = 50 WHERE id = 5;
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+DROP TABLE t2, t1;
+
+--echo #
+--echo # bug#25126722 FOREIGN KEY CONSTRAINT NAME IS NULL AFTER RESTART
+--echo # base bug#24818604 [GR]
+--echo #
+
+CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1))
+ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+--source include/restart_mysqld.inc
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+SELECT * FROM t1;
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/ibuf_not_empty.test b/mysql-test/suite/innodb/t/ibuf_not_empty.test
new file mode 100644
index 00000000000..a1a2da1f903
--- /dev/null
+++ b/mysql-test/suite/innodb/t/ibuf_not_empty.test
@@ -0,0 +1,54 @@
+--source include/have_innodb.inc
+# innodb_change_buffering_debug option is debug only
+--source include/have_debug.inc
+# Embedded server tests do not support restarting
+--source include/not_embedded.inc
+# The test is not big enough to use change buffering with larger page size.
+--source include/have_innodb_max_16k.inc
+
+--disable_query_log
+call mtr.add_suppression("InnoDB: Failed to find tablespace for table `test`\\.`t1` in the cache\\. Attempting to load the tablespace with space id");
+call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t1, old maximum was");
+--enable_query_log
+
+CREATE TABLE t1(
+ a INT AUTO_INCREMENT PRIMARY KEY,
+ b CHAR(1),
+ c INT,
+ INDEX(b))
+ENGINE=InnoDB STATS_PERSISTENT=0;
+
+# The flag innodb_change_buffering_debug is only available in debug builds.
+# It instructs InnoDB to try to evict pages from the buffer pool when
+# change buffering is possible, so that the change buffer will be used
+# whenever possible.
+SET GLOBAL innodb_change_buffering_debug = 1;
+
+# Create enough rows for the table, so that the change buffer will be
+# used for modifying the secondary index page. There must be multiple
+# index pages, because changes to the root page are never buffered.
+INSERT INTO t1 VALUES(0,'x',1);
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+INSERT INTO t1 SELECT 0,b,c FROM t1;
+
+--let $restart_parameters= --innodb-force-recovery=6
+--source include/restart_mysqld.inc
+
+--replace_regex /contains \d+ entries/contains #### entries/
+check table t1;
+
+--let $restart_parameters=
+--source include/restart_mysqld.inc
+
+# Cleanup
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-index-online-norebuild.opt b/mysql-test/suite/innodb/t/innodb-index-online-norebuild.opt
new file mode 100644
index 00000000000..39b93371503
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-index-online-norebuild.opt
@@ -0,0 +1 @@
+--loose-innodb-sys-tables
diff --git a/mysql-test/suite/innodb/t/innodb-index-online-norebuild.test b/mysql-test/suite/innodb/t/innodb-index-online-norebuild.test
new file mode 100644
index 00000000000..518b4efe1df
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-index-online-norebuild.test
@@ -0,0 +1,71 @@
+--source include/have_innodb.inc
+
+--echo # INPLACE ALTER WITH INPLACE_IGNORE FLAG AND CHANGE CREATE OPTION
+
+--echo # CHANGE THE COLUMN DEFAULT (INPLACE_IGNORE)
+--echo # AND TABLE CHARSET(CHANGE CREATE)
+
+CREATE TABLE t1(
+ id INT PRIMARY KEY,
+ f1 INT NOT NULL DEFAULT 0)ENGINE=INNODB;
+
+INSERT INTO t1 VALUES(1, 2);
+
+let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
+
+# Allow the following operation to report errors.
+SET SQL_MODE='STRICT_ALL_TABLES';
+ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL DEFAULT 0,
+ DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+
+let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
+
+if ($id_before_alter != $id_after_alter)
+{
+ --echo "Table rebuild happened";
+}
+
+DROP TABLE t1;
+
+--echo # CHANGE THE COMMENT OF COLUMN(INPLACE IGNORE)
+--echo # AND TABLE CHARSET(CHANGE CREATE)
+
+CREATE TABLE t1(id INT COMMENT 'independence day')ENGINE=INNODB;
+
+INSERT INTO t1 values(1);
+
+let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
+
+ALTER TABLE t1 MODIFY COLUMN id INT COMMENT 'identifier',
+ DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+
+let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
+
+if ($id_before_alter != $id_after_alter)
+{
+ --echo "Table rebuild happened";
+}
+
+DROP TABLE t1;
+
+--echo # RENAME THE TABLE(INPLACE IGNORE)
+--echo # AND CHANGE TABLE CHARSET(CHANGE CREATE)
+
+CREATE TABLE t1(
+ f1 INT NOT NULL,
+ f2 INT NOT NULL)ENGINE=INNODB;
+
+INSERT INTO t1 VALUES(1, 2);
+
+let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
+
+ALTER TABLE t1 RENAME t2, DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
+
+let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t2"`;
+
+if ($id_before_alter != $id_after_alter)
+{
+ --echo "Table rebuild happened";
+}
+
+DROP TABLE t2;
diff --git a/mysql-test/suite/innodb/t/innodb-isolation.test b/mysql-test/suite/innodb/t/innodb-isolation.test
new file mode 100644
index 00000000000..56cd668b305
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-isolation.test
@@ -0,0 +1,354 @@
+
+#Note:- WL6742 has been removed from 5.7 (Bug 23046302),
+# but we are keeping this test since it tests
+# count(*) correctness for various isolation
+# levels.
+
+--echo #
+--echo # WL#6742 - Test the interaction of multiple transactions using
+--echo # different isolation levels to make sure that the value returned
+--echo # by count(*) always reflects the correct view of the table according
+--echo # to the transaction's selected isolation level.
+--echo #
+
+--source include/have_innodb.inc
+
+--disable_query_log
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $initial_timeout=`select @@innodb_lock_wait_timeout`;
+--enable_query_log
+
+--echo #
+--echo # Traverse various indexes to get the right counts.
+--echo # This especially tests count(*) which is pushed down to InnoDB in WL#6742.
+--echo #
+CREATE TABLE t1 (
+ c1 INT AUTO_INCREMENT PRIMARY KEY,
+ c2 INT,
+ c3 INT,
+ c4 INT,
+ INDEX k2(c2)
+) Engine=InnoDB;
+let $1=10;
+while ($1 > 0) {
+ INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1);
+ dec $1;
+}
+
+CREATE TABLE t2 LIKE t1;
+--enable_info
+INSERT INTO t2 (SELECT * FROM t1);
+--disable_info
+
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Do some DML in the default connection and leave the transaction pending.
+--echo #
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+--enable_info
+UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1;
+DELETE FROM t1 WHERE c1 = 6;
+--disable_info
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Start transactions of Repeatable Read, Read Committed, and Read Uncommitted
+--echo #
+--echo # Connection 1 REPEATABLE READ
+--echo #
+connect (con1,localhost,root,,);
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+--source suite/innodb/include/innodb_isolation_selects.inc
+--enable_info
+UPDATE t1 SET c2 = c2 * 5 WHERE c1 = 2;
+DELETE FROM t1 WHERE c1 = 7;
+INSERT INTO t1(c2,c3,c4) VALUES (100, 1, 1);
+--disable_info
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Test a lock wait timeout during COUNT(*)
+--echo #
+SET innodb_lock_wait_timeout = 1;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT COUNT(*) FROM t1 FOR UPDATE;
+
+
+--echo #
+--echo # Connection 2 READ COMMITTED
+--echo #
+connect (con2,localhost,root,,);
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+--source suite/innodb/include/innodb_isolation_selects.inc
+--enable_info
+UPDATE t1 SET c2 = c2 * 7 WHERE c1 = 3;
+DELETE FROM t1 WHERE c1 = 8;
+INSERT INTO t1(c2,c3,c4) VALUES (1000, 1, 1);
+--disable_info
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 3 READ UNCOMMITTED
+--echo #
+connect (con3,localhost,root,,);
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+BEGIN;
+--source suite/innodb/include/innodb_isolation_selects.inc
+--enable_info
+UPDATE t1 SET c2 = c2 * 11 WHERE c1 = 4;
+INSERT INTO t1(c2,c3,c4) VALUES (10000, 1, 1);
+DELETE FROM t1 WHERE c1 in(9);
+--disable_info
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection default REPEATABLE READ
+--echo #
+connection default;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Commit the 3 extra connections
+--echo #
+--echo # Connection 1 REPEATABLE READ
+--echo #
+connection con1;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 2 READ COMMITTED
+--echo #
+connection con2;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 3 READ UNCOMMITTED
+--echo #
+connection con3;
+--source suite/innodb/include/innodb_isolation_selects.inc
+COMMIT;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 2 READ COMMITTED
+--echo #
+connection con2;
+--source suite/innodb/include/innodb_isolation_selects.inc
+COMMIT;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 1 REPEATABLE READ
+--echo #
+connection con1;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Select the first 5 records FOR UPDATE using count(*) in a subquery.
+--echo # The second record is still pending so we get a lock timeout.
+--echo #
+SET innodb_lock_wait_timeout = 1;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT c1, c2 FROM t1 WHERE c1 < ((SELECT COUNT(*) FROM t1) / 2) FOR UPDATE;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT COUNT(*) FROM t1 FOR UPDATE;
+COMMIT;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Show The EXPLAIN output for these queries;
+--echo #
+# column 10 is the row count provided by handler::info(). In InnoDB, this is
+# a statistical estimate. After the multi-transactional changes above,
+# Solaris reports 10 rows which is correct, but other OSes report 9.
+--replace_column 10 #
+EXPLAIN SELECT * FROM t1;
+EXPLAIN SELECT COUNT(*) FROM t1;
+EXPLAIN SELECT COUNT(c1) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT COUNT(c2) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT COUNT(c3) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT SUM(c1) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT SUM(c2) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
+--replace_column 10 #
+EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+--replace_column 10 #
+EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
+--replace_column 10 #
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
+
+--echo #
+--echo # Make all indexes in t2 obsolete to the active repeatable read transaction
+--echo # in the default connection.
+--echo #
+ALTER TABLE t2 row_format=redundant;
+
+--echo #
+--echo # Connection default REPEATABLE READ
+--echo # Do more DML in the default REPEATABLE READ transaction in order to use recently committed records.
+--echo #
+connection default;
+--source suite/innodb/include/innodb_isolation_selects.inc
+--enable_info
+UPDATE t1 SET c4 = c2 * 10;
+--disable_info
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Table t2 has been altered to a new row format.
+--echo # The index should not be useable.
+--echo #
+--error ER_TABLE_DEF_CHANGED
+SELECT COUNT(*) FROM t2;
+--error ER_TABLE_DEF_CHANGED
+SELECT * FROM t2;
+
+COMMIT;
+SELECT COUNT(*) FROM t2;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Connection 2
+--echo #
+connection con2;
+--source suite/innodb/include/innodb_isolation_selects.inc
+
+--echo #
+--echo # Try COUNT(*) on a DISCARDED table.
+--echo #
+connection default;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t4 (SELECT * FROM t1);
+SELECT COUNT(*) FROM t4;
+ALTER TABLE t4 DISCARD TABLESPACE;
+--error ER_TABLESPACE_DISCARDED
+SELECT COUNT(*) FROM t4;
+
+
+--echo #
+--echo # Test the interaction of a repeatable read transaction
+--echo # to changes that happen outside its view.
+--echo #
+
+CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+UPDATE t5 SET aa=a, bb=b;
+CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+INSERT INTO t6(b) VALUES ("inserted by client 1");
+UPDATE t6 SET aa=a, bb=b;
+CREATE TABLE t7 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB;
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+INSERT INTO t7(b) VALUES ("inserted by client 1");
+UPDATE t7 SET aa=a, bb=b;
+BEGIN;
+SELECT * FROM t5;
+SELECT COUNT(*) FROM t5;
+SELECT * FROM t6;
+SELECT COUNT(*) FROM t6;
+SELECT * FROM t7;
+SELECT COUNT(*) FROM t7;
+
+--echo #
+--echo # Connection 1
+--echo #
+connection con1;
+INSERT INTO t5(b) VALUES ("inserted by client 2");
+UPDATE t5 SET a = 10 where a = 1;
+UPDATE t5 SET b = "updated by client 2" where a = 2;
+DELETE FROM t5 WHERE a = 3;
+SELECT * FROM t5;
+SELECT COUNT(*) FROM t5;
+INSERT INTO t6(b) VALUES ("inserted by client 2");
+UPDATE t6 SET a = 10 where a = 1;
+UPDATE t6 SET b = "updated by client 2" where a = 2;
+DELETE FROM t6 WHERE a = 3;
+SELECT * FROM t6;
+SELECT COUNT(*) FROM t6;
+INSERT INTO t7(b) VALUES ("inserted by client 2");
+UPDATE t7 SET a = 10 where a = 1;
+UPDATE t7 SET b = "updated by client 2" where a = 2;
+DELETE FROM t7 WHERE a = 3;
+SELECT * FROM t7;
+SELECT COUNT(*) FROM t7;
+
+--echo #
+--echo # Connection default
+--echo #
+connection default;
+SELECT * FROM t5;
+INSERT INTO t5(b) VALUES ("inserted by client 1");
+SELECT * FROM t5;
+UPDATE t5 SET a = a + 100;
+SELECT * FROM t5;
+SELECT COUNT(*) FROM t5;
+
+UPDATE t6 SET b = "updated by client 2";
+SELECT * FROM t6;
+SELECT COUNT(*) FROM t6;
+
+DELETE FROM t7;
+SELECT * FROM t7;
+SELECT COUNT(*) FROM t7;
+
+COMMIT;
+SELECT * FROM t5;
+SELECT COUNT(*) FROM t5;
+SELECT * FROM t6;
+SELECT COUNT(*) FROM t6;
+SELECT * FROM t7;
+SELECT COUNT(*) FROM t7;
+
+--echo #
+--echo # Cleanup
+--echo #
+DROP TABLE t1,t2,t4,t5,t6,t7;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+--disable_query_log
+eval set global innodb_lock_wait_timeout=$initial_timeout;
+--enable_query_log
+
+--echo #
+--echo # Bug #23596760: FORCE INDEX IS SKIPPED WHILE EXECUTING SELECT COUNT(*)
+--echo #
+
+CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY,
+ c2 INT NOT NULL DEFAULT 1,
+ c3 char(20) DEFAULT '',
+ KEY c2_idx (c2)) ENGINE=InnoDB;
+
+INSERT INTO t1(c1) VALUES (1), (2), (3);
+INSERT INTO t1(c1) SELECT c1 + 10 FROM t1;
+INSERT INTO t1(c1) SELECT c1 + 100 FROM t1;
+
+CREATE TABLE t2 SELECT * FROM t1;
+
+let query1= SELECT COUNT(*) FROM t1;
+let query2= SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx);
+let query3= SELECT COUNT(*) FROM t1, t2;
+let query4= SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx), t2;
+
+eval EXPLAIN $query1;
+eval EXPLAIN $query2;
+eval EXPLAIN $query3;
+eval EXPLAIN $query4;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/innodb/t/innodb_force_recovery.test b/mysql-test/suite/innodb/t/innodb_force_recovery.test
new file mode 100644
index 00000000000..31b9660e872
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_force_recovery.test
@@ -0,0 +1,139 @@
+# Not supported in embedded
+--source include/not_embedded.inc
+
+# This test case needs InnoDB.
+-- source include/have_innodb.inc
+
+--disable_query_log
+call mtr.add_suppression("InnoDB: Failed to find tablespace for table .* in the cache. Attempting to load the tablespace with space id");
+call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t[12], old maximum was");
+--enable_query_log
+
+create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
+create table t2(f1 int not null, f2 int not null, index idx(f2))engine=innodb;
+insert into t1 values(1, 2);
+insert into t2 values(1, 2);
+
+SET GLOBAL innodb_fast_shutdown = 0;
+
+--echo # Restart the server with innodb_force_recovery as 4.
+--let $restart_parameters= --innodb-force-recovery=4
+--source include/restart_mysqld.inc
+
+select * from t1;
+
+--error ER_READ_ONLY_MODE
+insert into t1 values(2, 3);
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+alter table t1 add f3 int not null, algorithm=copy;
+
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t1 add f3 int not null, algorithm=inplace;
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+drop index idx on t1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t1 drop index idx, algorithm=inplace;
+
+--error ER_READ_ONLY_MODE
+update t1 set f1=3 where f2=2;
+
+--error ER_CANT_CREATE_TABLE
+create table t3(f1 int not null)engine=innodb;
+
+--error ER_BAD_TABLE_ERROR
+drop table t3;
+
+--error ER_ERROR_ON_RENAME
+rename table t1 to t3;
+
+--error ER_OPEN_AS_READONLY
+truncate table t1;
+
+drop table t1;
+show tables;
+
+--echo # Restart the server with innodb_force_recovery as 5.
+--let $restart_parameters= --innodb-force-recovery=5
+--source include/restart_mysqld.inc
+
+select * from t2;
+
+--error ER_READ_ONLY_MODE
+insert into t2 values(2, 3);
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+alter table t2 add f3 int not null, algorithm=copy;
+
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t2 add f3 int not null, algorithm=inplace;
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+drop index idx on t2;
+
+--error ER_READ_ONLY_MODE
+update t2 set f1=3 where f2=2;
+
+--error ER_CANT_CREATE_TABLE
+create table t1(f1 int not null)engine=innodb;
+
+--error ER_BAD_TABLE_ERROR
+drop table t1;
+
+--error ER_ERROR_ON_RENAME
+rename table t2 to t3;
+
+--error ER_OPEN_AS_READONLY
+truncate table t2;
+
+--error ER_OPEN_AS_READONLY
+drop table t2;
+show tables;
+
+--echo # Restart the server with innodb_force_recovery as 6.
+--let $restart_parameters= --innodb-force-recovery=6
+--source include/restart_mysqld.inc
+
+select * from t2;
+
+--error ER_OPEN_AS_READONLY
+insert into t2 values(2, 3);
+
+--error ER_OPEN_AS_READONLY
+alter table t2 add f3 int not null, algorithm=copy;
+
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t2 add f3 int not null, algorithm=inplace;
+
+--error ER_OPEN_AS_READONLY
+drop index idx on t2;
+
+--error ER_OPEN_AS_READONLY
+update t2 set f1=3 where f2=2;
+
+--error ER_CANT_CREATE_TABLE
+create table t1(f1 int not null)engine=innodb;
+
+--error ER_BAD_TABLE_ERROR
+drop table t1;
+
+--error ER_ERROR_ON_RENAME
+rename table t2 to t3;
+
+--error ER_OPEN_AS_READONLY
+truncate table t2;
+
+--error ER_OPEN_AS_READONLY
+drop table t2;
+show tables;
+
+--let $restart_parameters=
+--source include/restart_mysqld.inc
+
+drop table t2;
+show tables;
diff --git a/mysql-test/suite/innodb/t/innodb_gis.test b/mysql-test/suite/innodb/t/innodb_gis.test
index 45d66d95002..cb04c15f0b6 100644
--- a/mysql-test/suite/innodb/t/innodb_gis.test
+++ b/mysql-test/suite/innodb/t/innodb_gis.test
@@ -11,3 +11,12 @@ SET storage_engine=innodb;
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
drop table t1;
+#
+# MDEV-12462 SPATIAL index fails to work with CONTAINS
+#
+
+create table t1(id int not null primary key, g1 geometry not null, spatial index(g1));
+insert into t1 values(1, polygonfromtext('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'));
+explain select id from t1 where contains(g1, pointfromtext('POINT(1 1)'));
+select id from t1 where contains(g1, pointfromtext('POINT(1 1)'));
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/innodb_stats_del_mark-master.opt b/mysql-test/suite/innodb/t/innodb_stats_del_mark-master.opt
new file mode 100644
index 00000000000..145ee2b4264
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_stats_del_mark-master.opt
@@ -0,0 +1 @@
+--innodb_stats_include_delete_marked=on
diff --git a/mysql-test/suite/innodb/t/innodb_stats_del_mark.test b/mysql-test/suite/innodb/t/innodb_stats_del_mark.test
new file mode 100644
index 00000000000..36f7a2ea099
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_stats_del_mark.test
@@ -0,0 +1,113 @@
+--source include/have_innodb.inc
+--source include/big_test.inc
+
+--echo #
+--echo # Bug 23333990 PERSISTENT INDEX STATISTICS UPDATE BEFORE
+--echo # TRANSACTION IS COMMITTED
+--echo #
+
+--echo "Test 1:- Uncommited delete test"
+CREATE TABLE t1 (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ val INT UNSIGNED NOT NULL,
+ INDEX (val)) ENGINE=INNODB
+ STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
+
+
+INSERT INTO t1 (val) VALUES (CEIL(RAND()*20));
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+INSERT INTO t1 (val) SELECT CEIL(RAND()*20) FROM t1;
+
+SELECT COUNT(*) FROM t1;
+ANALYZE TABLE t1;
+
+connect(con1, localhost, root,,);
+START TRANSACTION;
+DELETE FROM t1;
+send SELECT COUNT(*) FROM t1;
+
+connection default;
+let $row_count= query_get_value(EXPLAIN SELECT * FROM t1 WHERE val=4, rows,1);
+if ($row_count > 20000)
+{
+--echo Test correctly estimates the number of rows as > 20000
+--echo even when in other uncommmited transaction
+--echo all rows have been deleted.
+}
+
+connection con1;
+reap;
+commit;
+
+connection default;
+
+--echo Test 2:- Insert and rollback test
+CREATE TABLE t2 (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ val INT UNSIGNED NOT NULL,
+ INDEX (val)) ENGINE=INNODB
+ STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
+
+connection con1;
+
+START TRANSACTION;
+INSERT INTO t2 (val) VALUES (CEIL(RAND()*20));
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+INSERT INTO t2 (val) SELECT CEIL(RAND()*20) FROM t2;
+send SELECT COUNT(*) FROM t2;
+
+connection default;
+select count(*) from t2;
+let $row_count= query_get_value(EXPLAIN SELECT * FROM t2 WHERE val=4, rows,1);
+if ($row_count > 20000)
+{
+--echo Test correctly estimates the number of rows as > 20000
+--echo even when in other uncommited transaction
+--echo many rows are inserted.
+}
+
+connection con1;
+reap;
+--echo Rollback the insert
+rollback;
+disconnect con1;
+
+connection default;
+let $row_count= query_get_value(EXPLAIN SELECT * FROM t2 WHERE val=4, rows,1);
+if ($row_count <= 1)
+{
+--echo Test correctly estimates the number of rows as $row_count
+--echo after rollback.
+}
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb/t/insert_debug.test b/mysql-test/suite/innodb/t/insert_debug.test
index 36ceba2ee8b..c370c402ac7 100644
--- a/mysql-test/suite/innodb/t/insert_debug.test
+++ b/mysql-test/suite/innodb/t/insert_debug.test
@@ -15,3 +15,35 @@ DROP TABLE t1;
SET GLOBAL innodb_change_buffering_debug=0;
SET GLOBAL innodb_limit_optimistic_insert_debug=0;
+
+--echo #
+--echo # Bug#25082593 FOREIGN KEY VALIDATION DOESN'T NEED
+--echo # TO ACQUIRE GAP LOCK IN READ COMMITTED
+--echo #
+
+SET GLOBAL innodb_limit_optimistic_insert_debug=2;
+
+CREATE TABLE t1(col1 INT PRIMARY KEY) ENGINE=INNODB;
+
+CREATE TABLE t2(col1 INT PRIMARY KEY, col2 INT NOT NULL,
+FOREIGN KEY(col2) REFERENCES t1(col1)) ENGINE=INNODB;
+
+INSERT INTO t1 VALUES(1), (3), (4);
+
+connect (con1,localhost,root);
+
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+INSERT INTO t2 VALUES(1, 3);
+
+connection default;
+START TRANSACTION;
+
+INSERT INTO t1 VALUES(2);
+
+disconnect con1;
+
+SET GLOBAL innodb_limit_optimistic_insert_debug=0;
+
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/readahead.test b/mysql-test/suite/innodb/t/readahead.test
new file mode 100644
index 00000000000..b4b8e8e38f0
--- /dev/null
+++ b/mysql-test/suite/innodb/t/readahead.test
@@ -0,0 +1,22 @@
+--source include/have_innodb.inc
+--source include/have_innodb_max_16k.inc
+# Embedded server tests do not support restarting
+--source include/not_embedded.inc
+
+--echo # Bug#25330449 ASSERT SIZE==SPACE->SIZE DURING BUF_READ_AHEAD_RANDOM
+
+let $MYSQLD_DATADIR=`SELECT @@datadir`;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=INNODB ROW_FORMAT=COMPRESSED;
+
+--source include/shutdown_mysqld.inc
+--remove_file $MYSQLD_DATADIR/ib_buffer_pool
+
+--write_file $MYSQLD_DATADIR/ib_buffer_pool
+EOF
+
+--source include/start_mysqld.inc
+SET @saved = @@GLOBAL.innodb_random_read_ahead;
+SET GLOBAL innodb_random_read_ahead = 1;
+
+DROP TABLE t1;
+SET GLOBAL innodb_random_read_ahead = @saved;
diff --git a/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test b/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test
new file mode 100644
index 00000000000..9ff01739f60
--- /dev/null
+++ b/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test
@@ -0,0 +1,75 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/big_test.inc
+# Embedded server tests do not support restarting
+--source include/not_embedded.inc
+# We are crashing the server on purpose
+--source include/not_valgrind.inc
+--source include/not_crashrep.inc
+
+# The test does work with any page size, but we want to reduce the
+# test running time by limiting the combinations. The redo log format
+# is independent of the page size.
+--source include/have_innodb_16k.inc
+
+SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
+SET GLOBAL innodb_dict_stats_disabled_debug = 1;
+SET GLOBAL innodb_master_thread_disabled_debug = 1;
+SET GLOBAL innodb_log_checkpoint_now = 1;
+
+CREATE DATABASE very_long_database_name;
+USE very_long_database_name;
+let $i=1300;
+--disable_query_log
+while ($i)
+{
+ eval CREATE TABLE veryLongTableNameToCreateMLOG_FILE_NAMErecords$i (a SERIAL)
+ ENGINE=InnoDB;
+ dec $i;
+}
+--enable_query_log
+
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
+
+set debug_dbug = '+d,increase_mtr_checkpoint_size';
+set debug_dbug = '+d,crash_after_checkpoint';
+--error 2013
+set global innodb_log_checkpoint_now = 1;
+
+--echo # Skip MLOG_FILE_NAME redo records during recovery
+--source include/start_mysqld.inc
+
+DROP DATABASE very_long_database_name;
+
+SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
+SET GLOBAL innodb_dict_stats_disabled_debug = 1;
+SET GLOBAL innodb_master_thread_disabled_debug = 1;
+SET GLOBAL innodb_log_checkpoint_now = 1;
+
+--echo # Commit the multi-rec mini transaction if mtr size
+--echo # exceeds LOG_CHECKPOINT_FREE_PER_THREAD size during checkpoint.
+
+CREATE DATABASE very_long_database_name;
+USE very_long_database_name;
+let $i=1300;
+--disable_query_log
+while ($i)
+{
+ eval CREATE TABLE veryLongTableNameToCreateMLOG_FILE_NAMErecords$i (a SERIAL)
+ ENGINE=InnoDB;
+ dec $i;
+}
+--enable_query_log
+
+--exec echo "wait" > $_expect_file_name
+set debug_dbug = '+d,crash_after_checkpoint';
+--error 2013
+set global innodb_log_checkpoint_now = 1;
+
+--echo # Skip MLOG_FILE_NAME redo records during recovery
+--let $restart_parameters = --debug-dbug=d,reduce_recv_parsing_buf
+--source include/start_mysqld.inc
+
+DROP DATABASE very_long_database_name;
diff --git a/mysql-test/suite/innodb/t/truncate_debug.test b/mysql-test/suite/innodb/t/truncate_debug.test
new file mode 100644
index 00000000000..fed5cf9392b
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_debug.test
@@ -0,0 +1,122 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #23070734 CONCURRENT TRUNCATE TABLES CAUSE STALLS
+--echo #
+
+--echo Test_1 :- Check if DDL operations are possible on
+--echo table being truncated. Also check if
+--echo DDL operations on other tables succeed.
+
+create table t1 (f1 int,f2 int,key(f2),f3 int) engine=innodb;
+create index idx1 on t1(f3);
+create table t2 (f1 int,f2 int,key(f2),f3 int) engine=innodb;
+create table t3 (f1 int,f2 int,key(f2)) engine=innodb;
+
+insert into t1 values (10,20,30),(30,40,50),(50,60,70);
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t2 values (10,20,30),(30,40,50),(50,60,70);
+
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+
+insert into t3 values (10,20),(30,40),(50,50);
+insert into t3 select * from t3;
+insert into t3 select * from t3;
+
+SET session lock_wait_timeout = 1;
+
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC= 'buffer_pool_scan SIGNAL started WAIT_FOR finish_scan';
+send truncate table t1;
+
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR started';
+
+--echo Check Analyze table. Gives lock time out error.
+analyze table t1;
+
+--echo Check if we can turn off auto recalculation.
+--error ER_LOCK_WAIT_TIMEOUT
+alter table t1 STATS_AUTO_RECALC=0;
+
+--echo Check if we can turn off persistent stats on the table
+--error ER_LOCK_WAIT_TIMEOUT
+alter table t1 STATS_PERSISTENT=0;
+
+--echo Check if DML is possible on table being truncated
+--error ER_LOCK_WAIT_TIMEOUT
+insert into t1 values (10,89,99);
+
+--echo Check if DDL is possible on table being truncated
+--error ER_LOCK_WAIT_TIMEOUT
+alter table t1 add column f4 int;
+
+--echo check if table can be created with the same name
+--error ER_TABLE_EXISTS_ERROR,ER_LOCK_WAIT_TIMEOUT
+create table t1 (bd int) engine=innodb;
+
+--echo check if index can be created on table being truncated
+--error ER_LOCK_WAIT_TIMEOUT
+create index idx1 on t1(f1);
+
+--echo Check if DROP of table is possible during truncate
+--error ER_LOCK_WAIT_TIMEOUT
+drop table t1;
+
+--echo Check if select is possible during truncate
+--error ER_LOCK_WAIT_TIMEOUT
+select * from t1;
+
+--error ER_BAD_FIELD_ERROR
+select * from t2 where t2.f1=t1.f1;
+
+--echo Check concurrent truncate operation on table;
+--error ER_LOCK_WAIT_TIMEOUT
+truncate table t1;
+
+--echo Check concurrent selects and inserts on the other table
+insert into t3 values (10,20),(30,40),(50,50);
+select * from t3 where f1=40;
+
+--echo Concurrent truncate on other tables
+truncate table t2;
+
+--echo Concurrent alters on the other tables
+alter table t2 add column f4 int;
+
+--echo check if index can be created on the other table
+create index idx1 on t2(f3);
+
+--echo Check if we can turn off persistent stats off entire instance
+SET GLOBAL innodb_stats_persistent=off;
+
+connect (con2,localhost,root,,);
+send set global innodb_adaptive_hash_index=off;
+
+connection default;
+SET DEBUG_SYNC= 'now SIGNAL finish_scan';
+SET DEBUG_SYNC= 'RESET';
+
+connection con1;
+reap;
+disconnect con1;
+
+connection con2;
+reap;
+disconnect con2;
+
+connection default;
+
+SET session lock_wait_timeout=default;
+set global innodb_adaptive_hash_index=on;
+
+drop table t1,t2,t3;
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/truncate_purge_debug.opt b/mysql-test/suite/innodb/t/truncate_purge_debug.opt
new file mode 100644
index 00000000000..8bed7e46166
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_purge_debug.opt
@@ -0,0 +1,3 @@
+--innodb-purge-threads=1
+--innodb-purge-batch-size=1
+--innodb-stats-persistent=OFF
diff --git a/mysql-test/suite/innodb/t/truncate_purge_debug.test b/mysql-test/suite/innodb/t/truncate_purge_debug.test
new file mode 100644
index 00000000000..70ebd28024d
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_purge_debug.test
@@ -0,0 +1,66 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #23070734 CONCURRENT TRUNCATE TABLES CAUSE STALLS
+--echo #
+
+create table t1 (f1 int ,f2 int,key(f2)) engine=innodb;
+begin;
+insert into t1 values (10,45),(20,78),(30,88),(40,23),(50,78),(60,11),(70,56),(80,90);
+delete from t1;
+
+connect (con2,localhost,root,,);
+# Stop the purge thread
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection default;
+# Ensure that the history list length will actually be decremented by purge.
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+commit;
+
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC= 'buffer_pool_scan SIGNAL started WAIT_FOR finish_scan';
+send truncate table t1;
+
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR started';
+# Allow purge to proceed, by discarding our read view.
+COMMIT;
+disconnect con2;
+
+connection default;
+
+# Wait for everything to be purged.
+
+let $wait_counter= 300;
+while ($wait_counter)
+{
+ --replace_regex /.*History list length ([0-9]+).*/\1/
+ let $remaining= `SHOW ENGINE INNODB STATUS`;
+ if ($remaining == 'InnoDB 0')
+ {
+ let $wait_counter= 0;
+ }
+ if ($wait_counter)
+ {
+ real_sleep 0.1;
+ dec $wait_counter;
+ }
+}
+echo $remaining transactions not purged;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
+
+SET DEBUG_SYNC = 'now SIGNAL finish_scan';
+SET DEBUG_SYNC = 'RESET';
+
+connection con1;
+reap;
+disconnect con1;
+
+connection default;
+drop table t1;
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb_gis/r/0.result b/mysql-test/suite/innodb_gis/r/0.result
index 41d560e7d95..e5b285e519a 100644
--- a/mysql-test/suite/innodb_gis/r/0.result
+++ b/mysql-test/suite/innodb_gis/r/0.result
@@ -610,7 +610,7 @@ set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
set transaction isolation level read uncommitted;
select count(*) from t1 where ST_Within(t1.c2, @g1);
count(*)
-0
+1
disconnect con1;
connection a;
commit;
diff --git a/mysql-test/suite/innodb_gis/r/alter_spatial_index.result b/mysql-test/suite/innodb_gis/r/alter_spatial_index.result
index 973377cb141..abc3c5b5f05 100644
--- a/mysql-test/suite/innodb_gis/r/alter_spatial_index.result
+++ b/mysql-test/suite/innodb_gis/r/alter_spatial_index.result
@@ -66,6 +66,7 @@ c1 ST_Astext(c2) ST_Astext(c4)
SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)');
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
c1 ST_Astext(c2) ST_Astext(c4)
+4 POINT(50 50) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
UPDATE tab SET C2 = ST_GeomFromText('POINT(100 100)')
WHERE MBRContains(tab.c4, @g1);
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
@@ -230,7 +231,6 @@ Table Op Msg_type Msg_text
test.tab check status OK
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab ORDER BY c1;
c1 ST_Astext(c2) ST_Astext(c4)
-4 POINT(50 50) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
6 POINT(3 3) POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
diff --git a/mysql-test/suite/innodb_gis/r/create_spatial_index.result b/mysql-test/suite/innodb_gis/r/create_spatial_index.result
index 9629fa03fef..fe46ef2e2f8 100644
--- a/mysql-test/suite/innodb_gis/r/create_spatial_index.result
+++ b/mysql-test/suite/innodb_gis/r/create_spatial_index.result
@@ -76,6 +76,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort
SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
+4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
WHERE MBRContains(tab.c4, @g1);
id select_type table type possible_keys key key_len ref rows Extra
@@ -399,6 +400,7 @@ test.tab check status OK
SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)');
SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
+4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
@@ -408,7 +410,6 @@ test.tab check status OK
SET @g1 = ST_GeomFromText('POLYGON((100 200,1010 1010,1020 1020,500 300,300 200,100 300,100 200))');
SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
-4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
5 POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
DELETE FROM tab WHERE ST_Crosses(tab.c4, @g1);
SELECT c1,ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1) ORDER BY c1;
@@ -503,6 +504,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort
SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
+4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
WHERE MBRContains(tab.c4, @g1);
id select_type table type possible_keys key key_len ref rows Extra
@@ -919,6 +921,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE tab range idx3 idx3 34 NULL 1 Using where; Using filesort
SELECT c1,ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
c1 ST_Astext(c4)
+4 POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
EXPLAIN UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
WHERE MBRContains(tab.c4, @g1);
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/suite/innodb_gis/r/rt_precise.result b/mysql-test/suite/innodb_gis/r/rt_precise.result
index e52f2ab5aa3..9e2c6adc2d9 100644
--- a/mysql-test/suite/innodb_gis/r/rt_precise.result
+++ b/mysql-test/suite/innodb_gis/r/rt_precise.result
@@ -55,5 +55,8 @@ count(*)
SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g,
ST_GeomFromText('Polygon((40 40,60 40,60 60,40 40))')) ORDER BY fid;
fid ST_AsText(g)
+45 LINESTRING(51 51,60 60)
+46 LINESTRING(51 41,60 50)
+56 LINESTRING(41 41,50 50)
DROP TABLE t1;
End of 5.5 tests.
diff --git a/mysql-test/suite/innodb_gis/r/rtree.result b/mysql-test/suite/innodb_gis/r/rtree.result
index a2b685f1747..285a499b16c 100644
--- a/mysql-test/suite/innodb_gis/r/rtree.result
+++ b/mysql-test/suite/innodb_gis/r/rtree.result
@@ -10,9 +10,12 @@ test.t1 analyze status OK
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 1 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 5 Using where
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
ST_astext(t1.g)
+POINT(1 1)
+POINT(1.5 1.5)
+POINT(3 3)
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
delete from t1 where MBRWithin(t1.g, @g1);
check table t1;
@@ -20,9 +23,6 @@ Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
-POINT(1 1)
-POINT(1.5 1.5)
-POINT(3 3)
POINT(3.1 3.1)
POINT(5 5)
set @g1 = ST_GeomFromText('Polygon((5 5,5 5,5 5,5 5,5 5))');
@@ -32,9 +32,6 @@ Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
-POINT(1 1)
-POINT(1.5 1.5)
-POINT(3 3)
POINT(3.1 3.1)
POINT(2 2)
show indexes from t1;
@@ -59,7 +56,6 @@ INSERT INTO t1 VALUES("left3", ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1
SET @p = ST_GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))');
SELECT name, ST_AsText(square) from t1 where MBRContains(@p, square);
name ST_AsText(square)
-small POLYGON((0 0,0 1,1 1,1 0,0 0))
SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square);
name ST_AsText(square)
up3 POLYGON((0 3,0 5,2 5,2 3,0 3))
@@ -94,7 +90,6 @@ down2 POLYGON((0 -2,0 0,2 0,2 -2,0 -2))
left2 POLYGON((-2 0,-2 2,0 2,0 0,-2 0))
SELECT name, ST_AsText(square) from t1 where MBRWithin(@p, square);
name ST_AsText(square)
-big POLYGON((0 0,0 3,3 3,3 0,0 0))
SET @vert1 = ST_GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = ST_GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = ST_GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
@@ -157,9 +152,12 @@ test.t1 analyze status OK
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 1 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 5 Using where
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
ST_astext(t1.g)
+POINT(1 1)
+POINT(1.5 1.5)
+POINT(3 3)
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
delete from t1 where MBRWithin(t1.g, @g1);
check table t1;
@@ -167,9 +165,6 @@ Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
-POINT(1 1)
-POINT(1.5 1.5)
-POINT(3 3)
POINT(3.1 3.1)
POINT(5 5)
set @g1 = ST_GeomFromText('Polygon((5 5,5 5,5 5,5 5,5 5))');
@@ -179,9 +174,6 @@ Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
-POINT(1 1)
-POINT(1.5 1.5)
-POINT(3 3)
POINT(3.1 3.1)
POINT(2 2)
show indexes from t1;
@@ -225,7 +217,7 @@ SELECT COUNT(*)
FROM t1
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
COUNT(*)
-9
+0
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
@@ -234,7 +226,7 @@ SELECT COUNT(*)
FROM t1
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
COUNT(*)
-9
+0
DROP TABLE t1;
CREATE TABLE t1( i INT, g GEOMETRY NOT NULL, SPATIAL INDEX (g)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, LINESTRING(POINT(1,1), POINT(4, 4)));
@@ -249,3 +241,622 @@ test.t1 check status OK
DELETE FROM t1
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((0 0,4 0, 4 4, 0 4, 0 0))'),g);
DROP TABLE t1;
+CREATE TABLE address (
+address_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+address VARCHAR(50) NOT NULL,
+address2 VARCHAR(50) DEFAULT NULL,
+district VARCHAR(20) NOT NULL,
+city_id SMALLINT UNSIGNED NOT NULL,
+postal_code VARCHAR(10) DEFAULT NULL,
+phone VARCHAR(20) NOT NULL,
+location GEOMETRY NOT NULL,
+last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (address_id),
+SPATIAL KEY `idx_location` (location)
+)ENGINE=InnoDB DEFAULT CHARSET=utf8;
+SET AUTOCOMMIT=0;
+INSERT INTO `address` VALUES (1,'47 MySakila Drive',NULL,'Alberta',300,'','',0x0000000001010000003E0A325D63345CC0761FDB8D99D94840,'2014-09-25 22:30:27'),
+(2,'28 MySQL Boulevard',NULL,'QLD',576,'','',0x0000000001010000008E10D4DF812463404EE08C5022A23BC0,'2014-09-25 22:30:09'),
+(3,'23 Workhaven Lane',NULL,'Alberta',300,'','14033335568',0x000000000101000000CDC4196863345CC01DEE7E7099D94840,'2014-09-25 22:30:27'),
+(4,'1411 Lillydale Drive',NULL,'QLD',576,'','6172235589',0x0000000001010000005B0DE4341F26634042D6AE6422A23BC0,'2014-09-25 22:30:09'),
+(5,'1913 Hanoi Way','','Nagasaki',463,'35200','28303384290',0x00000000010100000028D1370E21376040ABB58BC45F944040,'2014-09-25 22:31:53'),
+(6,'1121 Loja Avenue','','California',449,'17886','838635286649',0x0000000001010000003C94579D8B525DC0E860472DDE0D4140,'2014-09-25 22:34:01'),
+(7,'692 Joliet Street','','Attika',38,'83579','448477190408',0x000000000101000000076F59CF5AB737404105D1A45EFD4240,'2014-09-25 22:31:07'),
+(8,'1566 Inegl Manor','','Mandalay',349,'53561','705814003527',0x00000000010100000006240626DCD857403C45B357C4753540,'2014-09-25 22:32:18'),
+(9,'53 Idfu Parkway','','Nantou',361,'42399','10655648674',0x0000000001010000001F813FFC7C2A5E40357A354069EA3740,'2014-09-25 22:33:16'),
+(10,'1795 Santiago de Compostela Way','','Texas',295,'18743','860452626434',0x00000000010100000050502F9D7BE058C0D0CF7932A4813B40,'2014-09-25 22:33:55'),
+(11,'900 Santiago de Compostela Parkway','','Central Serbia',280,'93896','716571220373',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:11'),
+(12,'478 Joliet Way','','Hamilton',200,'77948','657282285970',0x000000000101000000DC84D61E11E9654072B7353344E442C0,'2014-09-25 22:32:22'),
+(13,'613 Korolev Drive','','Masqat',329,'45844','380657522649',0x00000000010100000001023164D04B4D40CEAC003A279D3740,'2014-09-25 22:32:29'),
+(14,'1531 Sal Drive','','Esfahan',162,'53628','648856936185',0x000000000101000000DE0951195AD64940635A400D84534040,'2014-09-25 22:31:36'),
+(15,'1542 Tarlac Parkway','','Kanagawa',440,'1027','635297277345',0x000000000101000000B4CDE8A27C6B61406B7D361724C74140,'2014-09-25 22:31:53'),
+(16,'808 Bhopal Manor','','Haryana',582,'10672','465887807014',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:30'),
+(17,'270 Amroha Parkway','','Osmaniye',384,'29610','695479687538',0x0000000001010000001F436C55B71F4240A11408967E894240,'2014-09-25 22:33:27'),
+(18,'770 Bydgoszcz Avenue','','California',120,'16266','517338314235',0x0000000001010000006D63A2F7FC515EC04C040539835A4340,'2014-09-25 22:33:47'),
+(19,'419 Iligan Lane','','Madhya Pradesh',76,'72878','990911107354',0x000000000101000000B7B01303C9595340E6F10FB633413740,'2014-09-25 22:31:13'),
+(20,'360 Toulouse Parkway','','England',495,'54308','949312333307',0x000000000101000000860FDBCCD7DBE63FFDCFAB4BD7C44940,'2014-09-25 22:33:40'),
+(21,'270 Toulon Boulevard','','Kalmykia',156,'81766','407752414682',0x000000000101000000FD0BA947BF204640316D495865274740,'2014-09-25 22:32:48'),
+(22,'320 Brest Avenue','','Kaduna',252,'43331','747791594069',0x0000000001010000006D3425FECDC01D40623FD532630B2540,'2014-09-25 22:32:25'),
+(23,'1417 Lancaster Avenue','','Northern Cape',267,'72192','272572357893',0x000000000101000000FEE8E5C127C338404DED56E075BB3CC0,'2014-09-25 22:33:03'),
+(24,'1688 Okara Way','','Nothwest Border Prov',327,'21954','144453869132',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:30'),
+(25,'262 A Corua (La Corua) Parkway','','Dhaka',525,'34418','892775750063',0x000000000101000000F13790E4A87A5640E7F6370DF63F3840,'2014-09-25 22:30:12'),
+(26,'28 Charlotte Amalie Street','','Rabat-Sal-Zammour-Z',443,'37551','161968374323',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:16'),
+(27,'1780 Hino Boulevard','','Liepaja',303,'7716','902731229323',0x000000000101000000360F1604450435403CA3AD4A22424C40,'2014-09-25 22:31:58'),
+(28,'96 Tafuna Way','','Crdoba',128,'99865','934730187245',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:05'),
+(29,'934 San Felipe de Puerto Plata Street','','Sind',472,'99780','196495945706',0x0000000001010000008E6B8D52D3285140D58E876302F53B40,'2014-09-25 22:32:31'),
+(30,'18 Duisburg Boulevard','','',121,'58327','998009777982',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:08'),
+(31,'217 Botshabelo Place','','Southern Mindanao',138,'49521','665356572025',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:36'),
+(32,'1425 Shikarpur Manor','','Bihar',346,'65599','678220867005',0x0000000001010000007F9F16284E9E55408201840F25603940,'2014-09-25 22:31:20'),
+(33,'786 Aurora Avenue','','Yamaguchi',474,'65750','18461860151',0x000000000101000000E712584AA05E6040D15735ADB9FA4040,'2014-09-25 22:31:53'),
+(34,'1668 Anpolis Street','','Taipei',316,'50199','525255540978',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(35,'33 Gorontalo Way','','West Bengali',257,'30348','745994947458',0x0000000001010000001A828879FB17564061585936CEAB3640,'2014-09-25 22:31:18'),
+(36,'176 Mandaluyong Place','','Uttar Pradesh',239,'65213','627705991774',0x00000000010100000073309B0043A553409E3AA0B657743940,'2014-09-25 22:31:17'),
+(37,'127 Purnea (Purnia) Manor','','Piemonte',17,'79388','911872220378',0x0000000001010000002A2B97D75B382140F2892B1D62744640,'2014-09-25 22:31:42'),
+(38,'61 Tama Street','','Okayama',284,'94065','708403338270',0x0000000001010000001F7013A488B86040670696C8AA4A4140,'2014-09-25 22:31:49'),
+(39,'391 Callao Drive','','Midi-Pyrnes',544,'34021','440512153169',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:01'),
+(40,'334 Munger (Monghyr) Lane','','Markazi',31,'38145','481183273622',0x000000000101000000737275B636D848404B958334BE0B4140,'2014-09-25 22:31:36'),
+(41,'1440 Fukuyama Loop','','Henan',362,'47929','912257250465',0x0000000001010000005E3CCD1319225C405886DD1C537F4040,'2014-09-25 22:30:40'),
+(42,'269 Cam Ranh Parkway','','Chisinau',115,'34689','489783829737',0x000000000101000000AD97F0958ADB3C40CCD47F31B6804740,'2014-09-25 22:32:15'),
+(43,'306 Antofagasta Place','','Esprito Santo',569,'3989','378318851631',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:23'),
+(44,'671 Graz Street','','Oriental',353,'94399','680768868518',0x00000000010100000083F7FAFFDD7707C0F7B7BA5285954140,'2014-09-25 22:32:16'),
+(45,'42 Brindisi Place','','Yerevan',586,'16744','42384721397',0x000000000101000000281BC528BE4146403BD400EF2E174440,'2014-09-25 22:30:08'),
+(46,'1632 Bislig Avenue','','Nonthaburi',394,'61117','471675840679',0x000000000101000000935C59FDEC1F5940D5D0611976D32B40,'2014-09-25 22:33:20'),
+(47,'1447 Imus Way','','Tahiti',167,'48942','539758313890',0x00000000010100000090CE0A56E6B562C059BB9289008E31C0,'2014-09-25 22:31:02'),
+(48,'1998 Halifax Drive','','Lipetsk',308,'76022','177727722820',0x00000000010100000087985CD60EC943409F1738EA324D4A40,'2014-09-25 22:32:54'),
+(49,'1718 Valencia Street','','Antofagasta',27,'37359','675292816413',0x0000000001010000007E82D5A24F9951C0C46B4DA901A737C0,'2014-09-25 22:30:29'),
+(50,'46 Pjatigorsk Lane','','Moscow (City)',343,'23616','262076994845',0x0000000001010000009C51F355F2C4424002E3CFA6D9DF4B40,'2014-09-25 22:32:55'),
+(51,'686 Garland Manor','','Cear',247,'52535','69493378813',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:19'),
+(52,'909 Garland Manor','','Tatarstan',367,'69367','705800322606',0x000000000101000000376DC66988E949402CA85E6D7BD14B40,'2014-09-25 22:32:55'),
+(53,'725 Isesaki Place','','Mekka',237,'74428','876295323994',0x000000000101000000213361455799434061EB0896D98A3540,'2014-09-25 22:33:00'),
+(54,'115 Hidalgo Parkway','','Khartum',379,'80168','307703950263',0x00000000010100000004503173263D40404D0DD9E5004A2F40,'2014-09-25 22:33:11'),
+(55,'1135 Izumisano Parkway','','California',171,'48150','171822533480',0x0000000001010000009763C3E4D75B5DC0799A2732CE0B4140,'2014-09-25 22:33:50'),
+(56,'939 Probolinggo Loop','','Galicia',1,'4166','680428310138',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(57,'17 Kabul Boulevard','','Chiba',355,'38594','697760867968',0x000000000101000000EB257CA5E27C61406F70D86C9BED4140,'2014-09-25 22:31:51'),
+(58,'1964 Allappuzha (Alleppey) Street','','Yamaguchi',227,'48980','920811325222',0x000000000101000000C2572A5E1B876040D19A7A38DC144140,'2014-09-25 22:31:47'),
+(59,'1697 Kowloon and New Kowloon Loop','','Moskova',49,'57807','499352017190',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(60,'1668 Saint Louis Place','','Tahiti',397,'39072','347487831378',0x0000000001010000006FF3C64921B262C0F8F47DDD8E8931C0,'2014-09-25 22:31:02'),
+(61,'943 Tokat Street','','Vaduz',560,'45428','889318963672',0x0000000001010000007F784C93080B23400341800C1D924740,'2014-09-25 22:31:58'),
+(62,'1114 Liepaja Street','','Sarawak',282,'69226','212869228936',0x000000000101000000047FAE6C55955B408285DDC199E9F83F,'2014-09-25 22:32:00'),
+(63,'1213 Ranchi Parkway','','Karnataka',350,'94352','800024380485',0x000000000101000000000080279AD7C641AA21BB1CC0202B40,'2014-09-25 22:31:21'),
+(64,'81 Hodeida Way','','Rajasthan',231,'55561','250767749542',0x0000000001010000000A09BDA36BF25240F8B138526CEB3A40,'2014-09-25 22:31:17'),
+(65,'915 Ponce Place','','Basel-Stadt',56,'83980','1395251317',0x0000000001010000000D6146C2084B1E40E58B07A579C74740,'2014-09-25 22:33:12'),
+(66,'1717 Guadalajara Lane','','Missouri',441,'85505','914090181665',0x000000000101000000A926D247AA8C56C0A456F3774A504340,'2014-09-25 22:33:59'),
+(67,'1214 Hanoi Way','','Nebraska',306,'67055','491001136577',0x000000000101000000D6671888AF2A58C0C0E2152DE5684440,'2014-09-25 22:33:56'),
+(68,'1966 Amroha Avenue','','Sichuan',139,'70385','333489324603',0x0000000001010000000A7778190FE05A402F6013E346373F40,'2014-09-25 22:30:32'),
+(69,'698 Otsu Street','','Cayenne',105,'71110','409983924481',0x000000000101000000D879C0E1AA2A4AC0D57EC6E0BCBB1340,'2014-09-25 22:31:02'),
+(70,'1150 Kimchon Manor','','Skne ln',321,'96109','663449333709',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:11'),
+(71,'1586 Guaruj Place','','Hunan',579,'5135','947233365992',0x000000000101000000AD3A06BFE83F5C4083047B0217DA3B40,'2014-09-25 22:30:46'),
+(72,'57 Arlington Manor','','Madhya Pradesh',475,'48960','990214419142',0x0000000001010000008E6D63FDB069534027D9EA724A6E3940,'2014-09-25 22:31:27'),
+(73,'1031 Daugavpils Parkway','','Bchar',63,'59025','107137400143',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:29:59'),
+(74,'1124 Buenaventura Drive','','Mekka',13,'6856','407733804223',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:59'),
+(75,'492 Cam Ranh Street','','Eastern Visayas',61,'50805','565018274456',0x0000000001010000007500C45D3D335F40B90265AE675B2540,'2014-09-25 22:32:34'),
+(76,'89 Allappuzha (Alleppey) Manor','','National Capital Reg',517,'75444','255800440636',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:39'),
+(77,'1947 Poos de Caldas Boulevard','','Chiayi',114,'60951','427454485876',0x0000000001010000002F06C54524195E40B4475E8C37763740,'2014-09-25 22:33:14'),
+(78,'1206 Dos Quebradas Place','','So Paulo',431,'20207','241832790687',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(79,'1551 Rampur Lane','','Changhwa',108,'72394','251164340471',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:14'),
+(80,'602 Paarl Street','','Pavlodar',402,'98889','896314772871',0x000000000101000000359078C34740534032D010E912234A40,'2014-09-25 22:31:55'),
+(81,'1692 Ede Loop','','So Paulo',30,'9223','918711376618',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:16'),
+(82,'936 Salzburg Lane','','Uttar Pradesh',425,'96709','875756771675',0x0000000001010000000C0EE5FAAD4F5440CBF8F71917383A40,'2014-09-25 22:31:24'),
+(83,'586 Tete Way','','Kanagawa',256,'1079','18581624103',0x000000000101000000783B0CF79B716140E96D22E989A74140,'2014-09-25 22:31:48'),
+(84,'1888 Kabul Drive','','Oyo & Osun',217,'20936','701457319790',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:24'),
+(85,'320 Baiyin Parkway','','Mahajanga',319,'37307','223664661973',0x000000000101000000EAFD90C888284740CDC75AE8EF6E2FC0,'2014-09-25 22:31:59'),
+(86,'927 Baha Blanca Parkway','','Krim',479,'9495','821972242086',0x000000000101000000417DCB9C2E0E4140BC29406F857A4640,'2014-09-25 22:33:33'),
+(87,'929 Tallahassee Loop','','Gauteng',497,'74671','800716535041',0x000000000101000000647F8FB05E6B3C407F60D8ABD9403AC0,'2014-09-25 22:33:06'),
+(88,'125 Citt del Vaticano Boulevard','','Puebla',40,'67912','48417642933',0x000000000101000000536232B0E99B58C03D0D18247DE83240,'2014-09-25 22:32:02'),
+(89,'1557 Ktahya Boulevard','','England',88,'88002','720998247660',0x0000000001010000001B43A5B67908FCBF439D03159FE54A40,'2014-09-25 22:33:36'),
+(90,'870 Ashqelon Loop','','Songkhla',489,'84931','135117278909',0x000000000101000000E82510C017265940115A6A1899CB1C40,'2014-09-25 22:33:20'),
+(91,'1740 Portoviejo Avenue','','Sucre',480,'29932','198123170793',0x000000000101000000C4AD275F75D952C07A51BB5F059C2240,'2014-09-25 22:30:53'),
+(92,'1942 Ciparay Parkway','','Cheju',113,'82624','978987363654',0x00000000010100000048F13B97F3A25F40358EA2186AB34040,'2014-09-25 22:33:06'),
+(93,'1926 El Alto Avenue','','Buenos Aires',289,'75543','846225459260',0x000000000101000000AD05AC0B2EFA4CC0C5D0A057F27541C0,'2014-09-25 22:30:05'),
+(94,'1952 Chatsworth Drive','','Guangdong',332,'25958','991562402283',0x000000000101000000A5F386A08F085D406DF65157885A3840,'2014-09-25 22:30:40'),
+(95,'1370 Le Mans Avenue','','Brunei and Muara',53,'52163','345679835036',0x00000000010100000013E85D06ADBC5C402A0E5652DDC21340,'2014-09-25 22:30:23'),
+(96,'984 Effon-Alaiye Avenue','','Gois',183,'17119','132986892228',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:17'),
+(97,'832 Nakhon Sawan Manor','','Inner Mongolia',592,'49021','275595571388',0x000000000101000000535C55F6DDAD5E400000001D69FABC41,'2014-09-25 22:30:50'),
+(98,'152 Kitwe Parkway','','Caraga',82,'53182','835433605312',0x000000000101000000DF652BD43F945F4006CAB788396E2040,'2014-09-25 22:32:35'),
+(99,'1697 Tanauan Lane','','Punjab',399,'22870','4764773857',0x000000000101000000CA97063447E95240B933B852742A4040,'2014-09-25 22:31:22'),
+(100,'1308 Arecibo Way','','Georgia',41,'30695','6171054059',0x000000000101000000FC00FFEF637E54C0BD9EF9E648BC4040,'2014-09-25 22:33:43'),
+(101,'1599 Plock Drive','','Tete',534,'71986','817248913162',0x000000000101000000DC77561C18CB4040B443577D092830C0,'2014-09-25 22:32:18'),
+(102,'669 Firozabad Loop','','Abu Dhabi',12,'92265','412903167998',0x0000000001010000009C76E73F5AE14B404AD05FE811313840,'2014-09-25 22:33:35'),
+(103,'588 Vila Velha Manor','','Kyongsangbuk',268,'51540','333339908719',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(104,'1913 Kamakura Place','','Lipetsk',238,'97287','942570536750',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:49'),
+(105,'733 Mandaluyong Place','','Asir',2,'77459','196568435814',0x0000000001010000007823980FAD404540798FD89365373240,'2014-09-25 22:32:59'),
+(106,'659 Vaduz Drive','','Ha Darom',34,'49708','709935135487',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:40'),
+(107,'1177 Jelets Way','','Kwara & Kogi',220,'3305','484292626944',0x0000000001010000001767672CF53712407E3E25427E192140,'2014-09-25 22:32:24'),
+(108,'1386 Yangor Avenue','','Provence-Alpes-Cte',543,'80720','449216226468',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:01'),
+(109,'454 Nakhon Sawan Boulevard','','Funafuti',173,'76383','963887147572',0x0000000001010000005822ABB636666640FF74A84B6B0C21C0,'2014-09-25 22:33:31'),
+(110,'1867 San Juan Bautista Tuxtepec Avenue','','Ivanovo',225,'78311','547003310357',0x000000000101000000BC6DF0CF567C4440E2B034F0A37F4C40,'2014-09-25 22:32:48'),
+(111,'1532 Dzerzinsk Way','','Buenos Aires',334,'9599','330838016880',0x000000000101000000BF93BB74385D4DC0E207420D3A5541C0,'2014-09-25 22:30:06'),
+(112,'1002 Ahmadnagar Manor','','Mxico',213,'93026','371490777743',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:07'),
+(113,'682 Junan Way','','North West',273,'30418','622255216127',0x000000000101000000714683CAAEAA3A406AEDC73725DA3AC0,'2014-09-25 22:33:04'),
+(114,'804 Elista Drive','','Hubei',159,'61069','379804592943',0x0000000001010000009E013FF4EE5E5B40E7E099D0245F3E40,'2014-09-25 22:30:33'),
+(115,'1378 Alvorada Avenue','','Distrito Federal',102,'75834','272234298332',0x0000000001010000000C3444BA44B850C047B1378CDDF92440,'2014-09-25 22:34:03'),
+(116,'793 Cam Ranh Avenue','','California',292,'87057','824370924746',0x00000000010100000003AF3B82C0885DC0610212A859594140,'2014-09-25 22:33:55'),
+(117,'1079 Tel Aviv-Jaffa Boulevard','','Sucre',132,'10885','358178933857',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:04'),
+(118,'442 Rae Bareli Place','','Nordrhein-Westfalen',148,'24321','886636413768',0x000000000101000000C19EC085860F1B40E37ED12F5BB74940,'2014-09-25 22:31:04'),
+(119,'1107 Nakhon Sawan Avenue','','Mxico',365,'75149','867546627903',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:11'),
+(120,'544 Malm Parkway','','Central Java',403,'63502','386759646229',0x0000000001010000003AEF5A9D77575B4026F103A106C51BC0,'2014-09-25 22:31:34'),
+(121,'1967 Sincelejo Place','','Gujarat',176,'73644','577812616052',0x00000000010100000059912CBBBB2B52408DBC074378373740,'2014-09-25 22:31:16'),
+(122,'333 Goinia Way','','Texas',185,'78625','909029256431',0x0000000001010000002AE67BA1DB3F58C0E46B2AE67B5F4040,'2014-09-25 22:33:51'),
+(123,'1987 Coacalco de Berriozbal Loop','','al-Qalyubiya',476,'96065','787654415858',0x000000000101000000595AFC5C23403F40AFBA698E07203E40,'2014-09-25 22:30:58'),
+(124,'241 Mosul Lane','','Risaralda',147,'76157','765345144779',0x000000000101000000983A23A5B4EA52C06155BDFC4E5B1340,'2014-09-25 22:30:52'),
+(125,'211 Chiayi Drive','','Uttar Pradesh',164,'58186','665993880048',0x000000000101000000A44BA4D961C1534007F247AC20C73A40,'2014-09-25 22:31:15'),
+(126,'1175 Tanauan Way','','Lima',305,'64615','937222955822',0x000000000101000000848A60D2CE4153C0E5417A8A1C1628C0,'2014-09-25 22:32:33'),
+(127,'117 Boa Vista Way','','Uttar Pradesh',566,'6804','677976133614',0x00000000010100000085364AA8AAC0544086BAFE1312513940,'2014-09-25 22:31:29'),
+(128,'848 Tafuna Manor','','Ktahya',281,'45142','614935229095',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:27'),
+(129,'569 Baicheng Lane','','Gauteng',85,'60304','490211944645',0x000000000101000000D71E51FC73423C4048AE51C543363AC0,'2014-09-25 22:33:02'),
+(130,'1666 Qomsheh Drive','','So Paulo',410,'66255','582835362905',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(131,'801 Hagonoy Drive','','Smolensk',484,'8439','237426099212',0x0000000001010000001EB814A122054040BB8509FE12644B40,'2014-09-25 22:32:57'),
+(132,'1050 Garden Grove Avenue','','Slaskie',236,'4999','973047364353',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:42'),
+(133,'1854 Tieli Street','','Shandong',302,'15819','509492324775',0x0000000001010000007A820E0492FE5C408F0475255D3A4240,'2014-09-25 22:30:39'),
+(134,'758 Junan Lane','','Gois',190,'82639','935448624185',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(135,'1752 So Leopoldo Parkway','','Taka-Karpatia',345,'14014','252265130067',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:32'),
+(136,'898 Belm Manor','','Free State',87,'49757','707169393853',0x000000000101000000ED4CFCAC8DB43A409EAC623B29453DC0,'2014-09-25 22:33:02'),
+(137,'261 Saint Louis Way','','Coahuila de Zaragoza',541,'83401','321944036800',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:13'),
+(138,'765 Southampton Drive','','al-Qalyubiya',421,'4285','23712411567',0x0000000001010000001BEB877DA7343F409FBC7E77E12D3E40,'2014-09-25 22:30:57'),
+(139,'943 Johannesburg Avenue','','Maharashtra',417,'5892','90921003005',0x000000000101000000F27A3029BE7652405E2ADB2C03853240,'2014-09-25 22:31:24'),
+(140,'788 Atinsk Street','','Karnataka',211,'81691','146497509724',0x0000000001010000000000801B1998C64157A945E977E62E40,'2014-09-25 22:31:17'),
+(141,'1749 Daxian Place','','Gelderland',29,'11044','963369996279',0x000000000101000000E4CE96BDB6E0174000B0952B171C4A40,'2014-09-25 22:32:20'),
+(142,'1587 Sullana Lane','','Inner Mongolia',207,'85769','468060467018',0x000000000101000000870CF505BEE95B407422669BC0674440,'2014-09-25 22:30:35'),
+(143,'1029 Dzerzinsk Manor','','Ynlin',542,'57519','33173584456',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:16'),
+(144,'1666 Beni-Mellal Place','','Tennessee',123,'13377','9099941466',0x00000000010100000005D1A45E01D755C084CCDFCECF434240,'2014-09-25 22:33:48'),
+(145,'928 Jaffna Loop','','Hiroshima',172,'93762','581852137991',0x0000000001010000002F2988CBBBAB6040E2FF33EFDD3D4140,'2014-09-25 22:31:45'),
+(146,'483 Ljubertsy Parkway','','Scotland',149,'60562','581174211853',0x000000000101000000C53E5CCD95CC07C0FAFD518A0C3C4C40,'2014-09-25 22:33:36'),
+(147,'374 Bat Yam Boulevard','','Kilis',266,'97700','923261616249',0x000000000101000000184FF344C68E4240FD55DBA8A95B4240,'2014-09-25 22:33:26'),
+(148,'1027 Songkhla Manor','','Minsk',340,'30861','563660187896',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:13'),
+(149,'999 Sanaa Loop','','Gauteng',491,'3439','918032330119',0x0000000001010000000E0D309864193C40F234AA1D0F7939C0,'2014-09-25 22:33:05'),
+(150,'879 Newcastle Way','','Michigan',499,'90732','206841104594',0x000000000101000000916A8E62EFC154C08244C99A474A4540,'2014-09-25 22:34:01'),
+(151,'1337 Lincoln Parkway','','Saitama',555,'99457','597815221267',0x0000000001010000005E0E6036A6746140456227614BEE4140,'2014-09-25 22:31:55'),
+(152,'1952 Pune Lane','','Saint-Denis',442,'92150','354615066969',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:46'),
+(153,'782 Mosul Street','','Massachusetts',94,'25545','885899703621',0x000000000101000000E9C4D44C2DC151C0D1686105AE0A4540,'2014-09-25 22:33:46'),
+(154,'781 Shimonoseki Drive','','Michoacn de Ocampo',202,'95444','632316273199',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:06'),
+(155,'1560 Jelets Boulevard','','Shandong',291,'77777','189446090264',0x00000000010100000018D57D5B0B6A5D40ADDA3521AD184240,'2014-09-25 22:30:38'),
+(156,'1963 Moscow Place','','Assam',354,'64863','761379480249',0x000000000101000000203BB9F04D2C57405D595826B2593A40,'2014-09-25 22:31:21'),
+(157,'456 Escobar Way','','Jakarta Raya',232,'36061','719202533520',0x000000000101000000DDC2A9C516B65A4095CCFB49C6DB18C0,'2014-09-25 22:31:33'),
+(158,'798 Cianjur Avenue','','Shanxi',590,'76990','499408708580',0x00000000010100000013D6C6D889BF5B409B4BBBE2F3824140,'2014-09-25 22:30:49'),
+(159,'185 Novi Sad Place','','Bern',72,'41778','904253967161',0x00000000010100000000D0BC772FCA1D40377D2C335B794740,'2014-09-25 22:33:13'),
+(160,'1367 Yantai Manor','','Ondo & Ekiti',381,'21294','889538496300',0x000000000101000000C25E72ED555514408A7A1C61ACAA1C40,'2014-09-25 22:32:26'),
+(161,'1386 Nakhon Sawan Boulevard','','Pyongyang-si',420,'53502','368899174225',0x000000000101000000F4BA8FED46705F40A55F6C6B55844340,'2014-09-25 22:32:28'),
+(162,'369 Papeete Way','','North Carolina',187,'66639','170117068815',0x000000000101000000C49D66DCAFF253C07A2D324B4C094240,'2014-09-25 22:33:52'),
+(163,'1440 Compton Place','','North Austria',307,'81037','931059836497',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:10'),
+(164,'1623 Baha Blanca Manor','','Moskova',310,'81511','149981248346',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:54'),
+(165,'97 Shimoga Avenue','','Tel Aviv',533,'44660','177167004331',0x0000000001010000009A56AFC7E96341403192E2885A0A4040,'2014-09-25 22:31:41'),
+(166,'1740 Le Mans Loop','','Pays de la Loire',297,'22853','168476538960',0x000000000101000000452A8C2D04B9D23F0000006AB82DBD41,'2014-09-25 22:31:01'),
+(167,'1287 Xiangfan Boulevard','','Gifu',253,'57844','819416131190',0x0000000001010000006AE514D3BB1B61408141D2A755B54140,'2014-09-25 22:31:48'),
+(168,'842 Salzburg Lane','','Adana',529,'3313','697151428760',0x0000000001010000007207A0072DD5414093228D6555A64240,'2014-09-25 22:33:29'),
+(169,'154 Tallahassee Loop','','Xinxiang',199,'62250','935508855935',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:34'),
+(170,'710 San Felipe del Progreso Avenue','','Lilongwe',304,'76901','843801144113',0x00000000010100000089C855D1C4E44040501D064E11EF2BC0,'2014-09-25 22:31:59'),
+(171,'1540 Wroclaw Drive','','Maharashtra',107,'62686','182363341674',0x0000000001010000004E10D0D8F2D253407CFB294476F23340,'2014-09-25 22:31:14'),
+(172,'475 Atinsk Way','','Gansu',240,'59571','201705577290',0x0000000001010000007872970E678C59405544978114404340,'2014-09-25 22:30:36'),
+(173,'1294 Firozabad Drive','','Jiangxi',407,'70618','161801569569',0x000000000101000000EED7F8A7AF775C402332079C00943B40,'2014-09-25 22:30:40'),
+(174,'1877 Ezhou Lane','','Rajasthan',550,'63337','264541743403',0x00000000010100000029722DFF466C52401969F34938923840,'2014-09-25 22:31:28'),
+(175,'316 Uruapan Street','','Perak',223,'58194','275788967899',0x0000000001010000005A3629BB4F4559400AC5B18927561240,'2014-09-25 22:31:59'),
+(176,'29 Pyongyang Loop','','Batman',58,'47753','734780743462',0x0000000001010000001C430070EC9044403C8963B895F14240,'2014-09-25 22:33:23'),
+(177,'1010 Klerksdorp Way','','Steiermark',186,'6802','493008546874',0x000000000101000000CFEE35A90DE72E409C0425BB88884740,'2014-09-25 22:30:10'),
+(178,'1848 Salala Boulevard','','Miranda',373,'25220','48265851133',0x0000000001010000006D08E984ABB150C02F90FBB1A43B2440,'2014-09-25 22:34:04'),
+(179,'431 Xiangtan Avenue','','Kerala',18,'4854','230250973122',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:10'),
+(180,'757 Rustenburg Avenue','','Skikda',483,'89668','506134035434',0x000000000101000000BFD76BD509A31B4063867C8626704240,'2014-09-25 22:30:01'),
+(181,'146 Johannesburg Way','','Tamaulipas',330,'54132','953689007081',0x0000000001010000003C45B357446058C0EAD621ED35E13940,'2014-09-25 22:32:09'),
+(182,'1891 Rizhao Boulevard','','So Paulo',456,'47288','391065549876',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(183,'1089 Iwatsuki Avenue','','Kirov',270,'35109','866092335135',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:50'),
+(184,'1410 Benin City Parkway','','Risaralda',405,'29747','104150372603',0x0000000001010000007C4F9B278DEC52C0795BE9B5D9401340,'2014-09-25 22:30:52'),
+(185,'682 Garden Grove Place','','Tennessee',333,'67497','72136330362',0x0000000001010000004204C188228356C06B4F24F323934140,'2014-09-25 22:33:57'),
+(186,'533 al-Ayn Boulevard','','California',126,'8862','662227486184',0x000000000101000000BF2264C5158E5DC08533AE6EABF24040,'2014-09-25 22:33:48'),
+(187,'1839 Szkesfehrvr Parkway','','Gois',317,'55709','947468818183',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(188,'741 Ambattur Manor','','Noord-Brabant',438,'43310','302590383819',0x000000000101000000699E6D7F78371540EF0D74A37ED94940,'2014-09-25 22:32:21'),
+(189,'927 Barcelona Street','','Chaharmahal va Bakht',467,'65121','951486492670',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:38'),
+(190,'435 0 Way','','West Bengali',195,'74750','760171523969',0x000000000101000000D9846A3906075640037168DB7A0F3640,'2014-09-25 22:31:16'),
+(191,'140 Chiayi Parkway','','Sumy',506,'38982','855863906434',0x0000000001010000002C43C1317066414051BB5F05F8754940,'2014-09-25 22:33:34'),
+(192,'1166 Changhwa Street','','Caraga',62,'58852','650752094490',0x0000000001010000009DB756201F715F40F53E9F1221832140,'2014-09-25 22:32:34'),
+(193,'891 Novi Sad Manor','','Ontario',383,'5379','247646995453',0x0000000001010000005E49F25C5FB653C0DE6AE74537F34540,'2014-09-25 22:30:28'),
+(194,'605 Rio Claro Parkway','','Tabora',513,'49348','352469351088',0x0000000001010000004E8B0B51CF694040DF67017F9D1014C0,'2014-09-25 22:33:18'),
+(195,'1077 San Felipe de Puerto Plata Place','','Rostov-na-Donu',369,'65387','812824036424',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:56'),
+(196,'9 San Miguel de Tucumn Manor','','Uttar Pradesh',169,'90845','956188728558',0x00000000010100000067DBC424B7995340A461E75C40263B40,'2014-09-25 22:31:15'),
+(197,'447 Surakarta Loop','','Nyanza',271,'10428','940830176580',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:56'),
+(198,'345 Oshawa Boulevard','','Tokyo-to',204,'32114','104491201771',0x000000000101000000FB5E9E29CF6C61404BFCF61A27D64140,'2014-09-25 22:31:45'),
+(199,'1792 Valle de la Pascua Place','','Nordrhein-Westfalen',477,'15540','419419591240',0x000000000101000000E9BD8CBD720C204056725F18FA6F4940,'2014-09-25 22:31:06'),
+(200,'1074 Binzhou Manor','','Baden-Wrttemberg',325,'36490','331132568928',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:05'),
+(201,'817 Bradford Loop','','Jiangsu',109,'89459','264286442804',0x000000000101000000C3E1BB830EFD5D4006B243A10AC63F40,'2014-09-25 22:30:31'),
+(202,'955 Bamenda Way','','Ondo & Ekiti',218,'1545','768481779568',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:24'),
+(203,'1149 A Corua (La Corua) Boulevard','','Haiphong',194,'95824','470884141195',0x0000000001010000007573F1B7BDAB5A4050A0997164DD3440,'2014-09-25 22:34:06'),
+(204,'387 Mwene-Ditu Drive','','Ahal',35,'8073','764477681869',0x000000000101000000B0253F3D11314D40A538A2D68FFA4240,'2014-09-25 22:33:30'),
+(205,'68 Molodetno Manor','','Nordrhein-Westfalen',575,'4662','146640639760',0x000000000101000000EEF3739E0C691D40FE486CD2C8B84940,'2014-09-25 22:31:06'),
+(206,'642 Nador Drive','','Maharashtra',77,'3924','369050085652',0x000000000101000000559D7A4908F25240E010AAD4EC0B3540,'2014-09-25 22:31:13'),
+(207,'1688 Nador Lane','','Sulawesi Utara',184,'61613','652218196731',0x000000000101000000E358727044945E4093F139C148B9E83F,'2014-09-25 22:31:32'),
+(208,'1215 Pyongyang Parkway','','Usak',557,'25238','646237101779',0x000000000101000000019E59B7E6673D40735E08DE35564340,'2014-09-25 22:33:30'),
+(209,'1679 Antofagasta Street','','Alto Paran',122,'86599','905903574913',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:32'),
+(210,'1304 s-Hertogenbosch Way','','Santa Catarina',83,'10925','90336226227',0x000000000101000000BDEAB765768848C05755D40561EB3AC0,'2014-09-25 22:30:16'),
+(211,'850 Salala Loop','','Kitaa',371,'10800','403404780639',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:07'),
+(212,'624 Oshawa Boulevard','','West Bengali',51,'89959','49677664184',0x0000000001010000000FBCB5A7BF315640EA7CD34F93383940,'2014-09-25 22:31:11'),
+(213,'43 Dadu Avenue','','Rajasthan',74,'4855','95666951770',0x000000000101000000BCF957A0A7A852404046E5CBB0583940,'2014-09-25 22:31:12'),
+(214,'751 Lima Loop','','Aden',7,'99405','756460337785',0x0000000001010000005ECF21BAB1844640A9007388138F2940,'2014-09-25 22:34:08'),
+(215,'1333 Haldia Street','','Jilin',174,'82161','408304391718',0x00000000010100000007A51E5844345F404CE71E6D77974640,'2014-09-25 22:30:33'),
+(216,'660 Jedda Boulevard','','Washington',65,'25053','168758068397',0x00000000010100000009EEF60FD88C5EC03C331C2A21CE4740,'2014-09-25 22:33:45'),
+(217,'1001 Miyakonojo Lane','','Taizz',518,'67924','584316724815',0x0000000001010000006642DD51AD024640782C1103B8282B40,'2014-09-25 22:34:11'),
+(218,'226 Brest Manor','','California',508,'2299','785881412500',0x000000000101000000CF9F36AA53825EC0B54D96FF35AF4240,'2014-09-25 22:34:02'),
+(219,'1229 Valencia Parkway','','Haskovo',498,'99124','352679173732',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:24'),
+(220,'1201 Qomsheh Manor','','Gois',28,'21464','873492228462',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:15'),
+(221,'866 Shivapuri Manor','','Uttar Pradesh',448,'22474','778502731092',0x000000000101000000940BDF0C48A4534072648ADE4E953C40,'2014-09-25 22:31:26'),
+(222,'1168 Najafabad Parkway','','Kabol',251,'40301','886649065861',0x0000000001010000009173AC9C074B51408EBDCDD199434140,'2014-09-25 22:29:59'),
+(223,'1244 Allappuzha (Alleppey) Place','','Buenos Aires',567,'20657','991802825778',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:08'),
+(224,'1842 Luzinia Boulevard','','Zanzibar West',593,'94420','706878974831',0x00000000010100000045E169E855994340B62C5F97E1A718C0,'2014-09-25 22:33:19'),
+(225,'1926 Gingoog Street','','Sisilia',511,'22824','469738825391',0x0000000001010000004DD9E907758D2E40719AF4ADC58A4240,'2014-09-25 22:31:44'),
+(226,'810 Palghat (Palakkad) Boulevard','','Jaroslavl',235,'73431','516331171356',0x00000000010100000069D48DC1D4EF43400294D0A79FD04C40,'2014-09-25 22:32:49'),
+(227,'1820 Maring Parkway','','Punjab',324,'88307','99760893676',0x0000000001010000001E053EF5FE5E52406C617193AC4A4040,'2014-09-25 22:32:30'),
+(228,'60 Poos de Caldas Street','','Rajasthan',243,'82338','963063788669',0x00000000010100000069EED7536140524079605B9AB6443A40,'2014-09-25 22:31:18'),
+(229,'1014 Loja Manor','','Tamil Nadu',22,'66851','460795526514',0x000000000101000000803E366E560A5440A1212DDF44322A40,'2014-09-25 22:31:10'),
+(230,'201 Effon-Alaiye Way','','Asuncin',37,'64344','684192903087',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:31'),
+(231,'430 Alessandria Loop','','Saarland',439,'47446','669828224459',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:06'),
+(232,'754 Valencia Place','','Phnom Penh',406,'87911','594319417514',0x0000000001010000009093D3E89F3A5A40AACCDE63FA1F2740,'2014-09-25 22:30:25'),
+(233,'356 Olomouc Manor','','Gois',26,'93323','22326410776',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:15'),
+(234,'1256 Bislig Boulevard','','Botosani',86,'50598','479007229460',0x00000000010100000085059C4AABAA3A408DAC46C032E04740,'2014-09-25 22:32:46'),
+(235,'954 Kimchon Place','','West Bengali',559,'42420','541327526474',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:28'),
+(236,'885 Yingkou Manor','','Kaduna',596,'31390','588964509072',0x00000000010100000006CF296D16E41E4038E3EAB6FA382640,'2014-09-25 22:32:28'),
+(237,'1736 Cavite Place','','Qina',216,'98775','431770603551',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(238,'346 Skikda Parkway','','Hawalli',233,'90628','630424482919',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:57'),
+(239,'98 Stara Zagora Boulevard','','Valle',96,'76448','610173756082',0x00000000010100000084CD4AA4FE4153C0DB9953138E0A0F40,'2014-09-25 22:30:51'),
+(240,'1479 Rustenburg Boulevard','','Southern Tagalog',527,'18727','727785483194',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:40'),
+(241,'647 A Corua (La Corua) Street','','Chollanam',357,'36971','792557457753',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(242,'1964 Gijn Manor','','Karnataka',473,'14408','918119601885',0x000000000101000000BBC3DCA458E45240DA4246F6F7DC2B40,'2014-09-25 22:31:26'),
+(243,'47 Syktyvkar Lane','','West Java',118,'22236','63937119031',0x000000000101000000EDABBC2E8DB05A40C3C1397E037E1AC0,'2014-09-25 22:31:31'),
+(244,'1148 Saarbrcken Parkway','','Fukushima',226,'1921','137773001988',0x000000000101000000AD8ACB4C449C614053F8229001874240,'2014-09-25 22:31:47'),
+(245,'1103 Bilbays Parkway','','Hubei',578,'87660','279979529227',0x000000000101000000A76ED34444095C401234C1CB67054040,'2014-09-25 22:30:45'),
+(246,'1246 Boksburg Parkway','','Hebei',422,'28349','890283544295',0x000000000101000000B66A323EA7E55D40E508BE0E41F74340,'2014-09-25 22:30:41'),
+(247,'1483 Pathankot Street','','Tucumn',454,'37288','686015532180',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:06'),
+(248,'582 Papeete Loop','','Central Visayas',294,'27722','569868543137',0x0000000001010000001F189BB1C3FC5E407DC4F9E5DD9E2440,'2014-09-25 22:32:38'),
+(249,'300 Junan Street','','Kyonggi',553,'81314','890289150158',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(250,'829 Grand Prairie Way','','Paran',328,'6461','741070712873',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(251,'1473 Changhwa Parkway','','Mxico',124,'75933','266798132374',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:03'),
+(252,'1309 Weifang Street','','Florida',520,'57338','435785045362',0x000000000101000000EC0CF8A1F71155C0995A006432703E40,'2014-09-25 22:34:02'),
+(253,'1760 Oshawa Manor','','Tianjin',535,'38140','56257502250',0x000000000101000000FBBD5EAB4E4B5D40EB0A6C8434924340,'2014-09-25 22:30:43'),
+(254,'786 Stara Zagora Way','','Oyo & Osun',390,'98332','716256596301',0x000000000101000000DB45E22F77770F4073C8BC44AB691F40,'2014-09-25 22:32:27'),
+(255,'1966 Tonghae Street','','Anhalt Sachsen',198,'36481','567359279425',0x0000000001010000000000009825D59D41450A0A2879C84940,'2014-09-25 22:31:05'),
+(256,'1497 Yuzhou Drive','','England',312,'3433','246810237916',0x000000000101000000CC4642B68718C0BFCA822E8617C14940,'2014-09-25 22:33:37'),
+(258,'752 Ondo Loop','','Miyazaki',338,'32474','134673576619',0x00000000010100000048AD8B36226260408871EDFABBBB3F40,'2014-09-25 22:31:50'),
+(259,'1338 Zalantun Lane','','Minas Gerais',413,'45403','840522972766',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(260,'127 Iwakuni Boulevard','','Central Luzon',192,'20777','987442542471',0x0000000001010000000E6954E0E42E5E40AF05627E13AB2D40,'2014-09-25 22:32:37'),
+(261,'51 Laredo Avenue','','Sagaing',342,'68146','884536620568',0x0000000001010000008720BD97B1C85740D4D7F335CB1B3640,'2014-09-25 22:32:18'),
+(262,'771 Yaound Manor','','Sofala',64,'86768','245477603573',0x000000000101000000103345CA606B414046CB2665F7D733C0,'2014-09-25 22:32:17'),
+(263,'532 Toulon Street','','Santiago',460,'69517','46871694740',0x000000000101000000ECD33B269CAC51C09AB67F65A5733340,'2014-09-25 22:30:55'),
+(264,'1027 Banjul Place','','West Bengali',197,'50390','538241037443',0x000000000101000000FE14223BCA1A5640AC6F6072A3EE3640,'2014-09-25 22:31:16'),
+(265,'1158 Mandi Bahauddin Parkway','','Shanxi',136,'98484','276555730211',0x000000000101000000ECC84741A6525C40A93C7084FB0B4440,'2014-09-25 22:30:32'),
+(266,'862 Xintai Lane','','Cagayan Valley',548,'30065','265153400632',0x00000000010100000015580053866E5E408A5CCBBFF19C3140,'2014-09-25 22:32:41'),
+(267,'816 Cayenne Parkway','','Manab',414,'93629','282874611748',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(268,'1831 Nam Dinh Loop','','National Capital Reg',323,'51990','322888976727',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:38'),
+(269,'446 Kirovo-Tepetsk Lane','','Osaka',203,'19428','303967439816',0x0000000001010000008D94D2D8C3F36040608CED5AE7554140,'2014-09-25 22:31:45'),
+(270,'682 Halisahar Place','','Severn Morava',378,'20536','475553436330',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:54'),
+(271,'1587 Loja Manor','','Salzburg',447,'5410','621625204422',0x0000000001010000002C83C53C86162A405886DD1C53E64740,'2014-09-25 22:30:10'),
+(272,'1762 Paarl Parkway','','Hunan',298,'53928','192459639410',0x00000000010100000067333D177CDB5B40DBA8A9C024B03B40,'2014-09-25 22:30:39'),
+(273,'1519 Ilorin Place','','Kerala',395,'49298','357445645426',0x0000000001010000000C4FF921002A5340BD772F52838C2540,'2014-09-25 22:31:21'),
+(274,'920 Kumbakonam Loop','','California',446,'75090','685010736240',0x00000000010100000012EF4ADCF4695EC01B95E535C0564240,'2014-09-25 22:34:00'),
+(275,'906 Goinia Way','','Wielkopolskie',255,'83565','701767622697',0x0000000001010000007FA2B2614D1732404064366D6BE14940,'2014-09-25 22:32:42'),
+(276,'1675 Xiangfan Manor','','Tamil Nadu',283,'11763','271149517630',0x00000000010100000042B687180AD95340EE4108C897EC2540,'2014-09-25 22:31:20'),
+(277,'85 San Felipe de Puerto Plata Drive','','Shandong',584,'46063','170739645687',0x000000000101000000EA605859365C5E40EF1010DDFDBC4240,'2014-09-25 22:30:48'),
+(278,'144 South Hill Loop','','Guanajuato',445,'2012','45387294817',0x0000000001010000002B84D558424C59C0699B2CFF6B923440,'2014-09-25 22:32:11'),
+(279,'1884 Shikarpur Avenue','','Haryana',263,'85548','959949395183',0x0000000001010000002CE395DA413F5340EB460EC7A9B03D40,'2014-09-25 22:31:19'),
+(280,'1980 Kamjanets-Podilskyi Street','','Illinois',404,'89502','874337098891',0x000000000101000000167CE420B26556C0B7966EB7C9584440,'2014-09-25 22:33:57'),
+(281,'1944 Bamenda Way','','Michigan',573,'24645','75975221996',0x000000000101000000B8B64B76C7C154C0EF254344203D4540,'2014-09-25 22:34:03'),
+(282,'556 Baybay Manor','','Oyo & Osun',374,'55802','363982224739',0x000000000101000000F5C6FFD3C30E1140FC30E7BE41502040,'2014-09-25 22:32:25'),
+(283,'457 Tongliao Loop','','Bursa',222,'56254','880756161823',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:25'),
+(284,'600 Bradford Street','','East Azerbaidzan',514,'96204','117592274996',0x000000000101000000EE4E2D115E25474044FF5FD09D0A4340,'2014-09-25 22:31:40'),
+(285,'1006 Santa Brbara dOeste Manor','','Ondo & Ekiti',389,'36229','85059738746',0x000000000101000000FBC67CE5E6581640531A7B40EAC81C40,'2014-09-25 22:32:26'),
+(286,'1308 Sumy Loop','','Fujian',175,'30657','583021225407',0x000000000101000000DC7AF25597D35D409617AAACB70F3A40,'2014-09-25 22:30:34'),
+(287,'1405 Chisinau Place','','Ponce',411,'8160','62781725285',0x000000000101000000974341DF4CA750C03F219628D6023240,'2014-09-25 22:32:45'),
+(288,'226 Halifax Street','','Xinxiang',277,'58492','790651020929',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:38'),
+(289,'1279 Udine Parkway','','Edo & Delta',69,'75860','195003555232',0x000000000101000000FFB7EDD68D8216408FF4B3A217571940,'2014-09-25 22:32:23'),
+(290,'1336 Benin City Drive','','Shiga',386,'46044','341242939532',0x000000000101000000D5810761C9FB60401B07A8BA91804140,'2014-09-25 22:31:53'),
+(291,'1155 Liaocheng Place','','Oyo & Osun',152,'22650','558236142492',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:23'),
+(292,'1993 Tabuk Lane','','Tamil Nadu',522,'64221','648482415405',0x0000000001010000002AF3A0EA210854407F94C78965D92940,'2014-09-25 22:31:27'),
+(293,'86 Higashiosaka Lane','','Guanajuato',563,'33768','957128697225',0x0000000001010000002DAF5C6F1B4C59C07F34F7EBA9643440,'2014-09-25 22:32:14'),
+(294,'1912 Allende Manor','','Kowloon and New Kowl',279,'58124','172262454487',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:09'),
+(295,'544 Tarsus Boulevard','','Gurico',562,'53145','892523334',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:05'),
+(296,'1936 Cuman Avenue','','Virginia',433,'61195','976798660411',0x000000000101000000FD7B3A6840FC53C065F4ED6EAFA24240,'2014-09-25 22:33:58'),
+(297,'1192 Tongliao Street','','Sharja',470,'19065','350970907017',0x000000000101000000AA27F38FBEB44B4053E68B625E563940,'2014-09-25 22:33:35'),
+(298,'44 Najafabad Way','','Baskimaa',146,'61391','96604821070',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(299,'32 Pudukkottai Lane','','Ohio',140,'38834','967274728547',0x000000000101000000077AA86D430C55C0409C2C5A25E14340,'2014-09-25 22:33:49'),
+(300,'661 Chisinau Lane','','Pietari',274,'8856','816436065431',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:51'),
+(301,'951 Stara Zagora Manor','','Punjab',400,'98573','429925609431',0x0000000001010000001E296C50C51953405651723DC0533E40,'2014-09-25 22:31:22'),
+(302,'922 Vila Velha Loop','','Maharashtra',9,'4085','510737228015',0x000000000101000000738F5B8242AF5240612129D835183340,'2014-09-25 22:31:10'),
+(303,'898 Jining Lane','','Pohjois-Pohjanmaa',387,'40070','161643343536',0x0000000001010000003DFB80F6D9773940C8D0B183CA405040,'2014-09-25 22:31:00'),
+(304,'1635 Kuwana Boulevard','','Hiroshima',205,'52137','710603868323',0x000000000101000000AA944330B38E6040247035FCB8324140,'2014-09-25 22:31:46'),
+(305,'41 El Alto Parkway','','Maharashtra',398,'56883','51917807050',0x000000000101000000D487E41A55315340BC3088FEBF443340,'2014-09-25 22:31:22'),
+(306,'1883 Maikop Lane','','Kaliningrad',254,'68469','96110042435',0x00000000010100000020DF94A8CD82344015D918856E5A4B40,'2014-09-25 22:32:50'),
+(307,'1908 Gaziantep Place','','Liaoning',536,'58979','108053751300',0x0000000001010000004DAA6C0EC6E65E408E9F7C30DF344540,'2014-09-25 22:30:43'),
+(308,'687 Alessandria Parkway','','Sanaa',455,'57587','407218522294',0x0000000001010000000C60257A741A4640854A123A9EB52E40,'2014-09-25 22:34:10'),
+(309,'827 Yuncheng Drive','','Callao',99,'79047','504434452842',0x000000000101000000C2514DA48F4753C0271CD544FA1C28C0,'2014-09-25 22:32:32'),
+(310,'913 Coacalco de Berriozbal Loop','','Texas',33,'42141','262088367001',0x00000000010100000023371EC7EA4658C0A86851442B5E4040,'2014-09-25 22:33:43'),
+(311,'715 So Bernardo do Campo Lane','','Kedah',507,'84804','181179321332',0x000000000101000000D8DBC1E3361F5940520DFB3DB1961640,'2014-09-25 22:32:00'),
+(312,'1354 Siegen Street','','Rio de Janeiro',25,'80184','573441801529',0x0000000001010000009146054EB62846C0FCA0D398B50137C0,'2014-09-25 22:30:15'),
+(313,'1191 Sungai Petani Boulevard','','Missouri',262,'9668','983259819766',0x00000000010100000055890D7107A557C0CB7564F6C38C4340,'2014-09-25 22:33:54'),
+(314,'1224 Huejutla de Reyes Boulevard','','Lombardia',91,'70923','806016930576',0x000000000101000000D85B6F40F06D24405EEE38EA8DC44640,'2014-09-25 22:31:43'),
+(315,'543 Bergamo Avenue','','Minas Gerais',215,'59686','103602195112',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(316,'746 Joliet Lane','','Kursk',286,'94878','688485191923',0x00000000010100000085949F54FB174240E0DCBAF660DE4940,'2014-09-25 22:32:52'),
+(317,'780 Kimberley Way','','Tabuk',515,'17032','824396883951',0x0000000001010000001BD47E6B274942408B53AD8559663C40,'2014-09-25 22:33:00'),
+(318,'1774 Yaound Place','','Hubei',166,'91400','613124286867',0x0000000001010000002A00C633E8B15C404C63C5BA027D3E40,'2014-09-25 22:30:33'),
+(319,'1957 Yantai Lane','','So Paulo',490,'59255','704948322302',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(320,'1542 Lubumbashi Boulevard','','Tel Aviv',57,'62472','508800331065',0x000000000101000000765F84DF3C6041403CAB60AF0B034040,'2014-09-25 22:31:41'),
+(321,'651 Pathankot Loop','','Maharashtra',336,'59811','139378397418',0x0000000001010000002198FE8062A952408AC168FBFCD23040,'2014-09-25 22:31:20'),
+(322,'1359 Zhoushan Parkway','','Streymoyar',545,'29763','46568045367',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:59'),
+(323,'1769 Iwaki Lane','','Kujawsko-Pomorskie',97,'25787','556100547674',0x000000000101000000487B7203F4013240837EF0EBD18F4A40,'2014-09-25 22:32:41'),
+(324,'1145 Vilnius Manor','','Mxico',451,'73170','674805712553',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:12'),
+(325,'1892 Nabereznyje Telny Lane','','Tutuila',516,'28396','478229987054',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:02'),
+(326,'470 Boksburg Street','','Central',81,'97960','908029859266',0x000000000101000000DAE78C83263855405BE21291AB023B40,'2014-09-25 22:32:19'),
+(327,'1427 A Corua (La Corua) Place','','Buenos Aires',45,'85799','972574862516',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:04'),
+(328,'479 San Felipe del Progreso Avenue','','Morelos',130,'54949','869051782691',0x000000000101000000C87E710484BC58C039FD8F02FACD3240,'2014-09-25 22:32:04'),
+(329,'867 Benin City Avenue','','Henan',591,'78543','168884817145',0x000000000101000000A0F2F972B05D5C405D68531AD6144140,'2014-09-25 22:30:50'),
+(330,'981 Kumbakonam Place','','Distrito Federal',89,'87611','829116184079',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:17'),
+(331,'1016 Iwakuni Street','','St George',269,'49833','961370847344',0x000000000101000000A1DC11A9C49C4EC0D11B936A44512A40,'2014-09-25 22:32:59'),
+(332,'663 Baha Blanca Parkway','','Adana',5,'33463','834418779292',0x000000000101000000BE72182719AA4140CCD1E3F736804240,'2014-09-25 22:33:22'),
+(333,'1860 Taguig Loop','','West Java',119,'59550','38158430589',0x00000000010100000042ACA34FD0E55A40D698C6E52ED81BC0,'2014-09-25 22:31:32'),
+(334,'1816 Bydgoszcz Loop','','Dhaka',234,'64308','965273813662',0x000000000101000000A717C627AE7C564080BD1D3C6EEB3840,'2014-09-25 22:30:12'),
+(335,'587 Benguela Manor','','Illinois',42,'91590','165450987037',0x00000000010100000097CEE2207C1456C0DDEFABCD5AE14440,'2014-09-25 22:33:44'),
+(336,'430 Kumbakonam Drive','','Santa F',457,'28814','105470691550',0x00000000010100000004C1882249304DC055DF54FF7B4E41C0,'2014-09-25 22:30:07'),
+(337,'1838 Tabriz Lane','','Dhaka',143,'1195','38988715447',0x0000000001010000001A5D948F139A5640C4D21B49DDB53740,'2014-09-25 22:30:12'),
+(338,'431 Szkesfehrvr Avenue','','Baki',48,'57828','119501405123',0x000000000101000000A77686A92DF248400FAECACF57304440,'2014-09-25 22:30:11'),
+(339,'503 Sogamoso Loop','','Sumqayit',505,'49812','834626715837',0x0000000001010000006C83C94395D548402C8EB9217C4B4440,'2014-09-25 22:30:11'),
+(340,'507 Smolensk Loop','','Sousse',492,'22971','80303246192',0x000000000101000000298EA8F52346254075DA649EA6E94140,'2014-09-25 22:33:21'),
+(341,'1920 Weifang Avenue','','Uttar Pradesh',427,'15643','869507847714',0x0000000001010000001F3EFA70DAC153407410CF6D1DCF3C40,'2014-09-25 22:31:25'),
+(342,'124 al-Manama Way','','Hiroshima',382,'52368','647899404952',0x0000000001010000004BE07B244AA760407B0ED18D55354140,'2014-09-25 22:31:52'),
+(343,'1443 Mardan Street','','Western Cape',392,'31483','231383037471',0x000000000101000000FB6074D42CF73240B0B03B3833DA40C0,'2014-09-25 22:33:05'),
+(344,'1909 Benguela Lane','','Henan',581,'19913','624138001031',0x000000000101000000F4AD6AA480775C4066EB2AEE89A74140,'2014-09-25 22:30:47'),
+(345,'68 Ponce Parkway','','Hanoi',201,'85926','870635127812',0x0000000001010000005DF525C0D5755A4000F61B3746063540,'2014-09-25 22:34:06'),
+(346,'1217 Konotop Avenue','','Gelderland',151,'504','718917251754',0x000000000101000000F438679F22A2164019B4EB3944044A40,'2014-09-25 22:32:20'),
+(347,'1293 Nam Dinh Way','','Roraima',84,'71583','697656479977',0x0000000001010000008EE6C8CA2F564EC0D9C23DE0CB8E0640,'2014-09-25 22:30:17'),
+(348,'785 Vaduz Street','','Baja California',335,'36170','895616862749',0x0000000001010000000D61EB0816DD5CC07DB328475C504040,'2014-09-25 22:32:10'),
+(349,'1516 Escobar Drive','','Tongatapu',370,'46069','64536069371',0x0000000001010000009132987575E665C0BE11DDB3AE2335C0,'2014-09-25 22:33:20'),
+(350,'1628 Nagareyama Lane','','Central',453,'60079','20064292617',0x00000000010100000019A5F04520C14CC029006B7AF55639C0,'2014-09-25 22:32:32'),
+(351,'1157 Nyeri Loop','','Adygea',320,'56380','262744791493',0x000000000101000000AC91B8228C0D4440EBD10AC2CB4D4640,'2014-09-25 22:32:55'),
+(352,'1673 Tangail Drive','','Daugavpils',137,'26857','627924259271',0x0000000001010000004377A45588883A40E580B80611F14B40,'2014-09-25 22:31:57'),
+(353,'381 Kabul Way','','Taipei',209,'87272','55477302294',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(354,'953 Hodeida Street','','Southern Tagalog',221,'18841','53912826864',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:37'),
+(355,'469 Nakhon Sawan Street','','Tuvassia',531,'58866','689199636560',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:58'),
+(356,'1378 Beira Loop','','Krasnojarsk',597,'40792','840957664136',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:58'),
+(357,'1641 Changhwa Place','','Nord-Ouest',52,'37636','256546485220',0x000000000101000000103B53E8BC4A2440A4C0A7DEBFD61740,'2014-09-25 22:30:25'),
+(358,'1698 Southport Loop','','Hidalgo',393,'49009','754358349853',0x0000000001010000007AB82E46EEAE58C03DED951EF21D3440,'2014-09-25 22:32:11'),
+(359,'519 Nyeri Manor','','So Paulo',461,'37650','764680915323',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(360,'619 Hunuco Avenue','','Shimane',331,'81508','142596392389',0x000000000101000000A09ADC399EA160405B1D4AFE71BC4140,'2014-09-25 22:31:50'),
+(361,'45 Aparecida de Goinia Place','','Madhya Pradesh',464,'7431','650496654258',0x0000000001010000009E0CE94BCA345440C9FDB38B0E953840,'2014-09-25 22:31:26'),
+(362,'482 Kowloon and New Kowloon Manor','','Bratislava',90,'97056','738968474939',0x00000000010100000070DC18F1531B3140BDB90908F7124840,'2014-09-25 22:33:02'),
+(363,'604 Bern Place','','Jharkhand',429,'5373','620719383725',0x000000000101000000799F9916AB55554037CC86EB07593740,'2014-09-25 22:31:25'),
+(364,'1623 Kingstown Drive','','Buenos Aires',20,'91299','296394569728',0x000000000101000000791563AAAA2A4DC0E4839ECDAA6A41C0,'2014-09-25 22:30:04'),
+(365,'1009 Zanzibar Lane','','Arecibo',32,'64875','102396298916',0x000000000101000000FBBD5EABCEAD50C0E9787187F2783240,'2014-09-25 22:32:45'),
+(366,'114 Jalib al-Shuyukh Manor','','Centre',585,'60440','845378657301',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:25'),
+(367,'1163 London Parkway','','Par',66,'6066','675120358494',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:16'),
+(368,'1658 Jastrzebie-Zdrj Loop','','Central',372,'96584','568367775448',0x0000000001010000002B73A900CEEF4240660811BA956FB9BF,'2014-09-25 22:31:56'),
+(369,'817 Laredo Avenue','','Jalisco',188,'77449','151249681135',0x000000000101000000F00BF9B113D959C03E4EE2BDB4AA3440,'2014-09-25 22:32:06'),
+(370,'1565 Tangail Manor','','Okinawa',377,'45750','634445428822',0x000000000101000000D94C744CCCAA5F4045A1C096B2C53940,'2014-09-25 22:31:52'),
+(371,'1912 Emeishan Drive','','Balikesir',50,'33050','99883471275',0x000000000101000000F1074D5CD8E23B400B2A053818D34340,'2014-09-25 22:33:22'),
+(372,'230 Urawa Drive','','Andhra Pradesh',8,'2738','166898395731',0x0000000001010000008B04AE869F515340B2930BDF0C402F40,'2014-09-25 22:31:09'),
+(373,'1922 Miraj Way','','Esfahan',356,'13203','320471479776',0x00000000010100000017050B71F6AE494026231DD434514040,'2014-09-25 22:31:37'),
+(374,'433 Florencia Street','','Chihuahua',250,'91330','561729882725',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:08'),
+(375,'1049 Matamoros Parkway','','Karnataka',191,'69640','960505250340',0x0000000001010000007923F3C89F355340386744696F563140,'2014-09-25 22:31:16'),
+(376,'1061 Ede Avenue','','Southern Tagalog',98,'57810','333390595558',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:35'),
+(377,'154 Oshawa Manor','','East Java',415,'72771','440365973660',0x00000000010100000005B93077D24D5C4065074B2B74041FC0,'2014-09-25 22:31:34'),
+(378,'1191 Tandil Drive','','Southern Tagalog',523,'6362','45554316010',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:40'),
+(379,'1133 Rizhao Avenue','','Pernambuco',572,'2800','600264533987',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:23'),
+(380,'1519 Santiago de los Caballeros Loop','','East Kasai',348,'22025','409315295763',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(381,'1618 Olomouc Manor','','Kurgan',285,'26385','96846695220',0x000000000101000000B1694A5755555040EA8FD552E5B94B40,'2014-09-25 22:32:51'),
+(382,'220 Hidalgo Drive','','Kermanshah',265,'45298','342720754566',0x0000000001010000004E7A843F6888474008605EDB36284140,'2014-09-25 22:31:37'),
+(383,'686 Donostia-San Sebastin Lane','','Guangdong',471,'97390','71857599858',0x000000000101000000F90A1C1A60845C400FDB711EA98B3640,'2014-09-25 22:30:42'),
+(384,'97 Mogiljov Lane','','Gujarat',73,'89294','924815207181',0x000000000101000000B4F116FEC209524097DB076A42C63540,'2014-09-25 22:31:11'),
+(385,'1642 Charlotte Amalie Drive','','Slaskie',549,'75442','821476736117',0x000000000101000000DDC4DA2967F73240D5D6E3198F114940,'2014-09-25 22:32:44'),
+(386,'1368 Maracabo Boulevard','','',493,'32716','934352415130',0x000000000101000000731074B4AA8A4FC050920953EF2E3240,'2014-09-25 22:30:03'),
+(387,'401 Sucre Boulevard','','New Hampshire',322,'25007','486395999608',0x000000000101000000817FA54E1BDD51C013718456717F4540,'2014-09-25 22:33:56'),
+(388,'368 Hunuco Boulevard','','Namibe',360,'17165','106439158941',0x000000000101000000B5858CECEF4D28404D8EF11769642EC0,'2014-09-25 22:30:03'),
+(389,'500 Lincoln Parkway','','Jiangsu',210,'95509','550306965159',0x0000000001010000003C399E2A3AC15D404409449957CB4040,'2014-09-25 22:30:35'),
+(390,'102 Chapra Drive','','Ibaragi',521,'14073','776031833752',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:54'),
+(391,'1793 Meixian Place','','Hmelnytskyi',258,'33535','619966287415',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:31'),
+(392,'514 Ife Way','','Shaba',315,'69973','900235712074',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(393,'717 Changzhou Lane','','Southern Tagalog',104,'21615','426255288071',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:36'),
+(394,'753 Ilorin Avenue','','Sichuan',157,'3656','464511145118',0x0000000001010000008531D8C3CDD8594059D70D805D883D40,'2014-09-25 22:30:32'),
+(395,'1337 Mit Ghamr Avenue','','Nakhon Sawan',358,'29810','175283210378',0x0000000001010000009A588572C70859404D237722D2682F40,'2014-09-25 22:33:19'),
+(396,'767 Pyongyang Drive','','Osaka',229,'83536','667736124769',0x000000000101000000149A7F4FC7EA6040A02413A6DE2F4140,'2014-09-25 22:31:48'),
+(397,'614 Pak Kret Street','','Addis Abeba',6,'27796','47808359842',0x0000000001010000009F84E3439A5F43402233BCFEC90C2240,'2014-09-25 22:30:59'),
+(398,'954 Lapu-Lapu Way','','Moskova',278,'8816','737229003916',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:51'),
+(399,'331 Bydgoszcz Parkway','','Asturia',181,'966','537374465982',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:09'),
+(400,'1152 Citrus Heights Manor','','al-Qadarif',15,'5239','765957414528',0x00000000010100000084F6459D14B14140AA36EE83E2112C40,'2014-09-25 22:33:11'),
+(401,'168 Cianjur Manor','','Saitama',228,'73824','679095087143',0x000000000101000000DEA925C2EB75614032005471E3F94140,'2014-09-25 22:31:48'),
+(402,'616 Hagonoy Avenue','','Krasnojarsk',39,'46043','604177838256',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(403,'1190 0 Place','','Rio Grande do Sul',44,'10417','841876514789',0x0000000001010000002347DF49B00D4BC086151340D6543FC0,'2014-09-25 22:30:16'),
+(404,'734 Bchar Place','','Punjab',375,'30586','280578750435',0x0000000001010000006D3B6D8D885C5240C4A40925DDCE3E40,'2014-09-25 22:32:31'),
+(405,'530 Lausanne Lane','','Texas',135,'11067','775235029633',0x0000000001010000009C830C89A03358C0E2D3F7753B644040,'2014-09-25 22:33:49'),
+(406,'454 Patiala Lane','','Fukushima',276,'13496','794553031307',0x000000000101000000EC3D4B46448C614091306711E5BB4240,'2014-09-25 22:31:49'),
+(407,'1346 Mysore Drive','','Bretagne',92,'61507','516647474029',0x0000000001010000004474BE8EEEEE11C070010DDBBB3F4840,'2014-09-25 22:31:00'),
+(408,'990 Etawah Loop','','Tamil Nadu',564,'79940','206169448769',0x000000000101000000D54B42D8DF3C5340FE518A0C61A72440,'2014-09-25 22:31:29'),
+(409,'1266 Laredo Parkway','','Saitama',380,'7664','1483365694',0x000000000101000000FBD97EE8F87361403BA5283C0DF44140,'2014-09-25 22:31:52'),
+(410,'88 Nagaon Manor','','Buenos Aires',524,'86868','779461480495',0x000000000101000000CA3736960B914DC0D78A91802CA942C0,'2014-09-25 22:30:07'),
+(411,'264 Bhimavaram Manor','','St Thomas',111,'54749','302526949177',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:08'),
+(412,'1639 Saarbrcken Drive','','North West',437,'9827','328494873422',0x00000000010100000015CB8866F93D3B40E48AE65CE5AA39C0,'2014-09-25 22:33:05'),
+(413,'692 Amroha Drive','','Northern',230,'35575','359478883004',0x00000000010100000027648CB47900544098E777503F562340,'2014-09-25 22:33:10'),
+(414,'1936 Lapu-Lapu Parkway','','Bauchi & Gombe',141,'7122','653436985797',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:23'),
+(415,'432 Garden Grove Street','','Ontario',430,'65630','615964523510',0x0000000001010000003E867DF1FBDB53C05900AEBF80EF4540,'2014-09-25 22:30:28'),
+(416,'1445 Carmen Parkway','','West Java',117,'70809','598912394463',0x000000000101000000957950F550C55A40B3BFA21122171BC0,'2014-09-25 22:31:30'),
+(417,'791 Salinas Street','','Punjab',208,'40509','129953030512',0x000000000101000000579E9B911CFA524075D256804A883F40,'2014-09-25 22:31:17'),
+(418,'126 Acua Parkway','','West Bengali',71,'58888','480039662421',0x000000000101000000C3013E89191056404E9F7829D01A3840,'2014-09-25 22:31:11'),
+(419,'397 Sunnyvale Avenue','','Guanajuato',19,'55566','680851640676',0x000000000101000000754419059C2F59C02409C21550EA3440,'2014-09-25 22:32:01'),
+(420,'992 Klerksdorp Loop','','Utrecht',23,'33711','855290087237',0x000000000101000000C1DFD4ACD88C15404FDC3BB4D9134A40,'2014-09-25 22:32:19'),
+(421,'966 Arecibo Loop','','Sind',134,'94018','15273765306',0x000000000101000000BE9B1320AFF15040D93400659DBB3A40,'2014-09-25 22:32:30'),
+(422,'289 Santo Andr Manor','','al-Sharqiya',16,'72410','214976066017',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:59'),
+(423,'437 Chungho Drive','','Puerto Plata',450,'59489','491271355190',0x000000000101000000225A86930FAC51C0082692431FCB3340,'2014-09-25 22:30:55'),
+(424,'1948 Bayugan Parkway','','Bihar',264,'60622','987306329957',0x0000000001010000007613211A82E45540D685C4E2DC893940,'2014-09-25 22:31:19'),
+(425,'1866 al-Qatif Avenue','','California',155,'89420','546793516940',0x000000000101000000B4EE7AC4C3815DC0165D28AAC8084140,'2014-09-25 22:33:50'),
+(426,'1661 Abha Drive','','Tamil Nadu',416,'14400','270456873752',0x000000000101000000D3B36A2192B45340FBC5111038C32440,'2014-09-25 22:31:23'),
+(427,'1557 Cape Coral Parkway','','Hubei',293,'46875','368284120423',0x00000000010100000034CC1A06BDEA5B402D5A25FD62314040,'2014-09-25 22:30:38'),
+(428,'1727 Matamoros Place','','Sawhaj',465,'78813','129673677866',0x00000000010100000083E38D27DDB13F40555BA093948E3A40,'2014-09-25 22:30:57'),
+(429,'1269 Botosani Manor','','Guangdong',468,'47394','736517327853',0x000000000101000000C8E1DDDB3ED65C40281B20E230C83640,'2014-09-25 22:30:42'),
+(430,'355 Vitria de Santo Anto Way','','Oaxaca',452,'81758','548003849552',0x0000000001010000000363D8BC050858C0503750E09D163240,'2014-09-25 22:32:13'),
+(431,'1596 Acua Parkway','','Jharkhand',418,'70425','157133457169',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:24'),
+(432,'259 Ipoh Drive','','So Paulo',189,'64964','419009857119',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(433,'1823 Hoshiarpur Lane','','Komi',510,'33191','307133768620',0x000000000101000000C6DA8420AC674940DD9ACF1495D64E40,'2014-09-25 22:32:57'),
+(434,'1404 Taguig Drive','','Okayama',547,'87212','572068624538',0x000000000101000000205D11A1F6BF6040BFE90203AD864140,'2014-09-25 22:31:54'),
+(435,'740 Udaipur Lane','','Nizni Novgorod',150,'33505','497288595103',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(436,'287 Cuautla Boulevard','','Chuquisaca',501,'72736','82619513349',0x0000000001010000002A0B15D2D05050C049C44ABB870833C0,'2014-09-25 22:30:14'),
+(437,'1766 Almirante Brown Street','','KwaZulu-Natal',364,'63104','617567598243',0x000000000101000000FDAB7DF090EE3D40488D64EA09C23BC0,'2014-09-25 22:33:04'),
+(438,'596 Huixquilucan Place','','Nampula',351,'65892','342709348083',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:17'),
+(439,'1351 Aparecida de Goinia Parkway','','Northern Mindanao',391,'41775','959834530529',0x000000000101000000DAFF006B55F55E40898C58D5DC4F2040,'2014-09-25 22:32:38'),
+(440,'722 Bradford Lane','','Shandong',249,'90920','746251338300',0x000000000101000000653E7B890CB55D4078A0A932E7954140,'2014-09-25 22:30:37'),
+(441,'983 Santa F Way','','British Colombia',565,'47472','145720452260',0x000000000101000000719CCA58A3C75EC0EEE7B92AF59F4840,'2014-09-25 22:30:28'),
+(442,'1245 Ibirit Way','','La Romana',290,'40926','331888642162',0x0000000001010000006D59BE2E433E51C04FC87322666D3240,'2014-09-25 22:30:54'),
+(443,'1836 Korla Parkway','','Copperbelt',272,'55405','689681677428',0x000000000101000000064257C796363C40BB7EC16ED89A29C0,'2014-09-25 22:34:11'),
+(444,'231 Kaliningrad Place','','Lombardia',70,'57833','575081026569',0x0000000001010000007A185A9D9C552340A77E390E17D94640,'2014-09-25 22:31:42'),
+(445,'495 Bhimavaram Lane','','Maharashtra',144,'3','82088937724',0x0000000001010000003EE1911DC0B15240B39943520BE73440,'2014-09-25 22:31:15'),
+(446,'1924 Shimonoseki Drive','','Batna',59,'52625','406784385440',0x000000000101000000347CB03154B21840DF814B112AC74140,'2014-09-25 22:29:59'),
+(447,'105 Dzerzinsk Manor','','Inner Mongolia',540,'48570','240776414296',0x000000000101000000F1C05B7BFA905E40F5EC03DA67CE4540,'2014-09-25 22:30:44'),
+(448,'614 Denizli Parkway','','Rio Grande do Sul',486,'29444','876491807547',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(449,'1289 Belm Boulevard','','Tartumaa',530,'88306','237368926031',0x00000000010100000079680EFF9FB93A406C7E575FB8304D40,'2014-09-25 22:30:58'),
+(450,'203 Tambaram Street','','Buenos Aires',161,'73942','411549550611',0x000000000101000000E753C72AA5604DC0438CD7BCAA2A41C0,'2014-09-25 22:30:05'),
+(451,'1704 Tambaram Manor','','West Bengali',554,'2834','39463554936',0x000000000101000000A4E9A2D755065640F598EDAFC3793640,'2014-09-25 22:31:28'),
+(452,'207 Cuernavaca Loop','','Tatarstan',352,'52671','782900030287',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:55'),
+(453,'319 Springs Loop','','Baijeri',160,'99552','72524459905',0x0000000001010000006A62CB3C0304264081FEE7D5A5CB4840,'2014-09-25 22:31:05'),
+(454,'956 Nam Dinh Manor','','Kerman',481,'21872','474047727727',0x000000000101000000F16206CF29D74B40CFA91A738D733D40,'2014-09-25 22:31:39'),
+(455,'1947 Paarl Way','','Central Java',509,'23636','834061016202',0x000000000101000000C4D78D2D3AB55B40AC996B8775391EC0,'2014-09-25 22:31:35'),
+(456,'814 Simferopol Loop','','Sinaloa',154,'48745','524567129902',0x000000000101000000954330B3F42F5BC090CCD9F115313A40,'2014-09-25 22:32:05'),
+(457,'535 Ahmadnagar Manor','','Abu Dhabi',3,'41136','985109775584',0x000000000101000000D3E6EE29EF2E4B4099C6E52E78773840,'2014-09-25 22:33:34'),
+(458,'138 Caracas Boulevard','','Zulia',326,'16790','974433019532',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:04'),
+(459,'251 Florencia Drive','','Michoacn de Ocampo',556,'16119','118011831565',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:13'),
+(460,'659 Gatineau Boulevard','','La Paz',153,'28587','205524798287',0x00000000010100000017E7B9CFBB0B51C0A029858ABB7B30C0,'2014-09-25 22:30:13'),
+(461,'1889 Valparai Way','','Ziguinchor',600,'75559','670370974122',0x00000000010100000020E1C50C9E4530C0FC219111AB2A2940,'2014-09-25 22:33:01'),
+(462,'1485 Bratislava Place','','Illinois',435,'83183','924663855568',0x000000000101000000A081A2C30D4656C04453D1B3B4224540,'2014-09-25 22:33:59'),
+(463,'935 Aden Boulevard','','Central Java',532,'64709','335052544020',0x000000000101000000C7139C55FA485B40BEE435655D7A1BC0,'2014-09-25 22:31:35'),
+(464,'76 Kermanshah Manor','','Esfahan',423,'23343','762361821578',0x000000000101000000FF66182DF6EE4940A60BB1FA23014040,'2014-09-25 22:31:37'),
+(465,'734 Tanshui Avenue','','Caquet',170,'70664','366776723320',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:52'),
+(466,'118 Jaffna Loop','','Northern Mindanao',182,'10447','325526730021',0x00000000010100000028B27B9777475F40BAEA4B80ABAA2140,'2014-09-25 22:32:36'),
+(467,'1621 Tongliao Avenue','','Irkutsk',558,'22173','209342540247',0x000000000101000000C7269E584CE95940E56A1ACA3F604A40,'2014-09-25 22:32:58'),
+(468,'1844 Usak Avenue','','Nova Scotia',196,'84461','164414772677',0x0000000001010000004205871744C94FC0162B0F779A524640,'2014-09-25 22:30:27'),
+(469,'1872 Toulon Loop','','OHiggins',428,'7939','928809465153',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:30'),
+(470,'1088 Ibirit Place','','Jalisco',595,'88502','49084281333',0x0000000001010000007820578FA0D859C06AE514D33BB93440,'2014-09-25 22:32:15'),
+(471,'1322 Mosul Parkway','','Shandong',145,'95400','268053970382',0x0000000001010000002856574F779F5D402425E2523ABB4240,'2014-09-25 22:30:32'),
+(472,'1447 Chatsworth Place','','Chihuahua',129,'41545','769370126331',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:04'),
+(473,'1257 Guadalajara Street','','Karnataka',78,'33599','195337700615',0x000000000101000000052049A4C8ED5240E702F2800DD33040,'2014-09-25 22:31:14'),
+(474,'1469 Plock Lane','','Galicia',388,'95835','622884741180',0x000000000101000000FB44F9DDCF741FC0ED9A90D6182B4540,'2014-09-25 22:33:09'),
+(475,'434 Ourense (Orense) Manor','','Hodeida',206,'14122','562370137426',0x000000000101000000F56FF2B62D7A4540DF80E03B7B982D40,'2014-09-25 22:34:10'),
+(476,'270 Tambaram Parkway','','Gauteng',244,'9668','248446668735',0x0000000001010000005B5540EB2B0B3C4082412D61C8333AC0,'2014-09-25 22:33:03'),
+(477,'1786 Salinas Place','','Nam Ha',359,'66546','206060652238',0x00000000010100000044BD851A2A7E5A40C2DB8310908D3440,'2014-09-25 22:34:07'),
+(478,'1078 Stara Zagora Drive','','Aceh',301,'69221','932992626595',0x00000000010100000034057CC8A5495840D2C9ADA470B81440,'2014-09-25 22:31:33'),
+(479,'1854 Okara Boulevard','','Drenthe',158,'42123','131912793873',0x0000000001010000006E8AC745B5A01B40947BCBE6BB634A40,'2014-09-25 22:32:21'),
+(480,'421 Yaound Street','','Sumy',385,'11363','726875628268',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:33'),
+(481,'1153 Allende Way','','Qubec',179,'20336','856872225376',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:26'),
+(482,'808 Naala-Porto Parkway','','England',500,'41060','553452430707',0x0000000001010000000E6036A6CC4201C0B9D7930A74B44A40,'2014-09-25 22:33:41'),
+(483,'632 Usolje-Sibirskoje Parkway','','Ha Darom',36,'73085','667648979883',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:41'),
+(484,'98 Pyongyang Boulevard','','Ohio',11,'88749','191958435142',0x0000000001010000008AB1A778376154C0990524AB6C8A4440,'2014-09-25 22:33:42'),
+(485,'984 Novoterkassk Loop','','Gaziantep',180,'28165','435118527255',0x000000000101000000CAAF7A1BF6B04240AA8889BC9B874240,'2014-09-25 22:33:25'),
+(486,'64 Korla Street','','Mwanza',347,'25145','510383179153',0x0000000001010000002A28FB9DDC7B40402EBB719C252204C0,'2014-09-25 22:33:17'),
+(487,'1785 So Bernardo do Campo Street','','Veracruz',125,'71182','684529463244',0x000000000101000000A1551CBD509C57C0141F44D72A223240,'2014-09-25 22:32:04'),
+(488,'698 Jelets Boulevard','','Denizli',142,'2596','975185523021',0x000000000101000000EECD6F9868163D40B226BB3E18E34240,'2014-09-25 22:33:24'),
+(489,'1297 Alvorada Parkway','','Ningxia',587,'11839','508348602835',0x0000000001010000001583D1F679915A4029876066E93B4340,'2014-09-25 22:30:49'),
+(490,'1909 Dayton Avenue','','Guangdong',469,'88513','702955450528',0x0000000001010000007BE0BE6955655C405457998466E43840,'2014-09-25 22:30:42'),
+(491,'1789 Saint-Denis Parkway','','Coahuila de Zaragoza',4,'8268','936806643983',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:01'),
+(492,'185 Mannheim Lane','','Stavropol',408,'23661','589377568313',0x000000000101000000333E82D19B87454024592CEA38064640,'2014-09-25 22:32:56'),
+(493,'184 Mandaluyong Street','','Baja California Sur',288,'94239','488425406814',0x000000000101000000173B2BB3D2935BC078F6F0C05B233840,'2014-09-25 22:32:09'),
+(494,'591 Sungai Petani Drive','','Okayama',376,'46400','37247325001',0x0000000001010000001966B2C9EBBD60404CC054D8B1544140,'2014-09-25 22:31:51'),
+(495,'656 Matamoros Drive','','Boyac',487,'19489','17305839123',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(496,'775 ostka Drive','','al-Daqahliya',337,'22358','171973024401',0x000000000101000000FC4DCD8A4D423F403EDF60B9EFB63E40,'2014-09-25 22:30:57'),
+(497,'1013 Tabuk Boulevard','','West Bengali',261,'96203','158399646978',0x0000000001010000005D1B857F6C1B5640793BC269C1F53640,'2014-09-25 22:31:19'),
+(498,'319 Plock Parkway','','Istanbul',504,'26101','854259976812',0x000000000101000000B6EFF6C54A453D40277E3100F97A4440,'2014-09-25 22:33:28'),
+(499,'1954 Kowloon and New Kowloon Way','','Chimborazo',434,'63667','898559280434',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(500,'362 Rajkot Lane','','Gansu',47,'98030','962020153680',0x0000000001010000004F6FEB13E50A5A4028733D1B03464240,'2014-09-25 22:30:31'),
+(501,'1060 Tandil Lane','','Shandong',432,'72349','211256301880',0x000000000101000000CAB61D6423DD5D40ADF1E379BAB64140,'2014-09-25 22:30:41'),
+(502,'1515 Korla Way','','England',589,'57197','959467760895',0x0000000001010000004C42D8DFC852F1BFBA826DC493FA4A40,'2014-09-25 22:33:42'),
+(503,'1416 San Juan Bautista Tuxtepec Avenue','','Zufar',444,'50592','144206758053',0x000000000101000000A6684018D30B4B40078662E1DA033140,'2014-09-25 22:32:29'),
+(504,'1 Valle de Santiago Avenue','','Apulia',93,'86208','465897838272',0x000000000101000000CAFED4D3A2EF3140584D7C5AEA504440,'2014-09-25 22:31:43'),
+(505,'519 Brescia Parkway','','East Java',318,'69504','793996678771',0x000000000101000000A3C794B487E15B400A230736F8841EC0,'2014-09-25 22:31:33'),
+(506,'414 Mandaluyong Street','','Lubelskie',314,'16370','52709222667',0x0000000001010000000FE6C0BC1191364020F0C000C2A04940,'2014-09-25 22:32:43'),
+(507,'1197 Sokoto Boulevard','','West Bengali',478,'87687','868602816371',0x000000000101000000109546CC6C1B56408F0FC4C3C5B53A40,'2014-09-25 22:31:27'),
+(508,'496 Celaya Drive','','Nagano',552,'90797','759586584889',0x000000000101000000254E3805034961402486D3388A334240,'2014-09-25 22:31:54'),
+(509,'786 Matsue Way','','Illinois',245,'37469','111177206479',0x0000000001010000000F3B9D75570556C0FA91C77839C34440,'2014-09-25 22:33:54'),
+(510,'48 Maracabo Place','','Central Luzon',519,'1570','82671830126',0x000000000101000000223999B8D53A5E408D87AD8F3D2D2F40,'2014-09-25 22:32:39'),
+(511,'1152 al-Qatif Lane','','Kalimantan Barat',412,'44816','131370665218',0x000000000101000000107FA88F9B545B4021037976F9D69FBF,'2014-09-25 22:31:34'),
+(512,'1269 Ipoh Avenue','','Eskisehir',163,'54674','402630109080',0x000000000101000000E9D32AFA43853E40767D303A6AE34340,'2014-09-25 22:33:24'),
+(513,'758 Korolev Parkway','','Andhra Pradesh',568,'75474','441628280920',0x00000000010100000031DA99F859285440AF528BD2EF843040,'2014-09-25 22:31:29'),
+(514,'1747 Rustenburg Place','','Bihar',110,'51369','442673923363',0x0000000001010000000BFD5DE9C62E554041C4BC7D0CC83940,'2014-09-25 22:31:14'),
+(515,'886 Tonghae Place','','Volgograd',259,'19450','711928348157',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:50'),
+(516,'1574 Goinia Boulevard','','Heilongjiang',502,'39529','59634255214',0x00000000010100000017128B73AFBF5F40C5ECC094DC514740,'2014-09-25 22:30:43'),
+(517,'548 Uruapan Street','','Ontario',312,'35653','879347453467',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:38'),
+(519,'962 Tama Loop','','',583,'65952','282667506728',0x000000000101000000FA545FA722DD6440AA7A9EE4B321E1BF,'2014-09-25 22:32:19'),
+(520,'1778 Gijn Manor','','Hubei',594,'35156','288910576761',0x000000000101000000E358727044305C40A58A3D0F49104040,'2014-09-25 22:30:50'),
+(521,'568 Dhule (Dhulia) Loop','','Coquimbo',127,'92568','602101369463',0x0000000001010000000000804A296FC5C1DDA85F330AC13EC0,'2014-09-25 22:30:30'),
+(522,'1768 Udine Loop','','Battambang',60,'32347','448876499197',0x000000000101000000708802C7AFCC59402ABC15D396342A40,'2014-09-25 22:30:24'),
+(523,'608 Birgunj Parkway','','Taipei',116,'400','627425618482',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:14'),
+(524,'680 A Corua (La Corua) Manor','','Sivas',482,'49806','158326114853',0x000000000101000000936EF02A10824240F2F6D676C9DF4340,'2014-09-25 22:33:28'),
+(525,'1949 Sanya Street','','Gumma',224,'61244','132100972047',0x000000000101000000943F29A406696140E4CA8FAE88284240,'2014-09-25 22:31:47'),
+(526,'617 Klerksdorp Place','','Khanh Hoa',366,'94707','574973479129',0x0000000001010000004A1751C96F4C5B4032F504D37A7D2840,'2014-09-25 22:34:07'),
+(527,'1993 0 Loop','','Liaoning',588,'41214','25865528181',0x000000000101000000B65E1D119D8E5E40171A3ED818554440,'2014-09-25 22:30:49'),
+(528,'1176 Southend-on-Sea Manor','','Southern Tagalog',458,'81651','236679267178',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:39'),
+(529,'600 Purnea (Purnia) Avenue','','Nghe An',571,'18043','638409958875',0x000000000101000000962364204F6C5A407A6D365662AC3240,'2014-09-25 22:34:07'),
+(530,'1003 Qinhuangdao Street','','West Java',419,'25972','35533115997',0x0000000001010000005EA516A55FDC5A40A21639FA4E3A1AC0,'2014-09-25 22:31:35'),
+(531,'1986 Sivas Place','','Friuli-Venezia Giuli',551,'95775','182059202712',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:44'),
+(532,'1427 Tabuk Place','','Florida',101,'31342','214756839122',0x0000000001010000003C702942C57C54C02A5D555117903A40,'2014-09-25 22:33:47'),
+(533,'556 Asuncin Way','','Mogiljov',339,'35364','338244023543',0x0000000001010000006B6DD04D51583E40673513C259F54A40,'2014-09-25 22:30:13'),
+(534,'486 Ondo Parkway','','Benguela',67,'35202','105882218332',0x000000000101000000BD83E9C59ACF2A40B9FA56900B2729C0,'2014-09-25 22:30:02'),
+(535,'635 Brest Manor','','Andhra Pradesh',75,'40899','80593242951',0x00000000010100000079FA52897C615440D2C9ADA4708A3040,'2014-09-25 22:31:13'),
+(536,'166 Jinchang Street','','Buenos Aires',165,'86760','717566026669',0x0000000001010000003EB896242A434DC0E0771DBB556D41C0,'2014-09-25 22:30:05'),
+(537,'958 Sagamihara Lane','','Mie',287,'88408','427274926505',0x000000000101000000BED29E37BA1761409B5F837467884140,'2014-09-25 22:31:50'),
+(538,'1817 Livorno Way','','Khanh Hoa',100,'79401','478380208348',0x000000000101000000944A78422F4A5B40236D3E09C7D72740,'2014-09-25 22:34:05'),
+(539,'1332 Gaziantep Lane','','Shandong',80,'22813','383353187467',0x000000000101000000BC2F1D2911815D4074B0A316EFAE4240,'2014-09-25 22:30:31'),
+(540,'949 Allende Lane','','Uttar Pradesh',24,'67521','122981120653',0x0000000001010000008C91DBE5119E534039A8B34934E73C40,'2014-09-25 22:31:11'),
+(541,'195 Ilorin Street','','Chari-Baguirmi',363,'49250','8912935608',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:29'),
+(542,'193 Bhusawal Place','','Kang-won',539,'9750','745267607502',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(543,'43 Vilnius Manor','','Colorado',42,'79814','484500282381',0x0000000001010000009389004C3E355AC0D03582435EDD4340,'2014-09-25 22:33:44'),
+(544,'183 Haiphong Street','','Jilin',46,'69953','488600270038',0x000000000101000000AFA3607C87B45E4038A85890C1CD4640,'2014-09-25 22:30:30'),
+(545,'163 Augusta-Richmond County Loop','','Carabobo',561,'33030','754579047924',0x000000000101000000CC0C1B657D0051C06B7F677BF4522440,'2014-09-25 22:34:05'),
+(546,'191 Jos Azueta Parkway','','Ruse',436,'13629','932156667696',0x00000000010100000067A9ABF188F83940CD6CA1759EED4540,'2014-09-25 22:30:23'),
+(547,'379 Lublin Parkway','','Toscana',309,'74568','921960450089',0x00000000010100000090920D5AFEA62440CC13BEADAAC54540,'2014-09-25 22:31:44'),
+(548,'1658 Cuman Loop','','Sumatera Selatan',396,'51309','784907335610',0x00000000010100000018D75306E9885A40E8209EDB3A4E01C0,'2014-09-25 22:31:34'),
+(549,'454 Qinhuangdao Drive','','Tadla-Azilal',68,'25866','786270036240',0x000000000101000000419479F53B6619C04F09E3022B2B4040,'2014-09-25 22:32:16'),
+(550,'1715 Okayama Street','','So Paulo',485,'55676','169352919175',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(551,'182 Nukualofa Drive','','Sumy',275,'15414','426346224043',0x00000000010100000079F71109F099404055BBCBEAC29E4940,'2014-09-25 22:33:32'),
+(552,'390 Wroclaw Way','','Hainan',462,'5753','357593328658',0x000000000101000000F70FD88B57605B40364E5480393E3240,'2014-09-25 22:30:41'),
+(553,'1421 Quilmes Lane','','Ishikawa',260,'19151','135407755975',0x0000000001010000008F9F32A30414614053AEF02E174C4240,'2014-09-25 22:31:49'),
+(554,'947 Trshavn Place','','Central Luzon',528,'841','50898428626',0x000000000101000000C56DD9C644265E4002B5BD82D9F52E40,'2014-09-25 22:32:40'),
+(555,'1764 Jalib al-Shuyukh Parkway','','Galicia',459,'77642','84794532510',0x00000000010100000090FFB8B3651721C09DB23FF5B4704540,'2014-09-25 22:33:10'),
+(556,'346 Cam Ranh Avenue','','Zhejiang',599,'39976','978430786151',0x000000000101000000A0E63FFF188D5E4056DBA8A9C0023E40,'2014-09-25 22:30:51'),
+(557,'1407 Pachuca de Soto Place','','Rio Grande do Sul',21,'26284','380077794770',0x000000000101000000A3CEDC43C28449C0608209922DFD3DC0,'2014-09-25 22:30:14'),
+(558,'904 Clarksville Drive','','Zhejiang',193,'52234','955349440539',0x000000000101000000E5886B6BFA2A5E4038E04E7D7B7A3E40,'2014-09-25 22:30:34'),
+(559,'1917 Kumbakonam Parkway','','Vojvodina',368,'11892','698182547686',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:11'),
+(560,'1447 Imus Place','','Gujarat',426,'12905','62127829280',0x000000000101000000667F4523C4B25140819C8B1AA74A3640,'2014-09-25 22:31:25'),
+(561,'1497 Fengshan Drive','','KwaZulu-Natal',112,'63022','368738360376',0x000000000101000000938FDD054AE43E402AF97DA42DEB3DC0,'2014-09-25 22:33:03'),
+(562,'869 Shikarpur Way','','England',496,'57380','590764256785',0x000000000101000000894FF003460D08C0828472ECEAD24A40,'2014-09-25 22:33:40'),
+(563,'1059 Yuncheng Avenue','','Vilna',570,'47498','107092893983',0x00000000010100000046B82462A5473940BA0ACE8536584B40,'2014-09-25 22:31:58'),
+(564,'505 Madiun Boulevard','','Dolnoslaskie',577,'97271','970638808606',0x000000000101000000F0D46D9A8808314023A93B05AF914940,'2014-09-25 22:32:44'),
+(565,'1741 Hoshiarpur Boulevard','','al-Sharqiya',79,'22372','855066328617',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(566,'1229 Varanasi (Benares) Manor','','Buenos Aires',43,'40195','817740355461',0x00000000010100000014DA28A1AA2A4DC02E156580555541C0,'2014-09-25 22:30:04'),
+(567,'1894 Boa Vista Way','','Texas',178,'77464','239357986667',0x000000000101000000C1D1448EE32858C0AD8D0CCDD0744040,'2014-09-25 22:33:51'),
+(568,'1342 Sharja Way','','Sokoto & Kebbi & Zam',488,'93655','946114054231',0x0000000001010000005B087250C2F41440E711ED74311F2A40,'2014-09-25 22:32:27'),
+(569,'1342 Abha Boulevard','','Bukarest',95,'10714','997453607116',0x000000000101000000924FD9FA331B3A40B1CBA61254374640,'2014-09-25 22:32:46'),
+(570,'415 Pune Avenue','','Shandong',580,'44274','203202500108',0x000000000101000000CC3857DE1F705D408F26CDD545F34140,'2014-09-25 22:30:47'),
+(571,'1746 Faaa Way','','Huanuco',214,'32515','863080561151',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:33'),
+(572,'539 Hami Way','','Tokat',538,'52196','525518075499',0x0000000001010000006F302F1BF8464240AD7B759F2D284440,'2014-09-25 22:33:29'),
+(573,'1407 Surakarta Manor','','Moskova',466,'33224','324346485054',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:56'),
+(574,'502 Mandi Bahauddin Parkway','','Anzotegui',55,'15992','618156722572',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:03'),
+(575,'1052 Pathankot Avenue','','Sichuan',299,'77397','128499386727',0x000000000101000000AA054026E3F05940CCC12275F18F3D40,'2014-09-25 22:30:39'),
+(576,'1351 Sousse Lane','','Coahuila de Zaragoza',341,'37815','203804046132',0x0000000001010000006AB86D84EA5A59C027AA12C028E83A40,'2014-09-25 22:32:10'),
+(577,'1501 Pangkal Pinang Avenue','','Mazowieckie',409,'943','770864062795',0x0000000001010000001646C4DED5B43340308AD46AFE454A40,'2014-09-25 22:32:43'),
+(578,'1405 Hagonoy Avenue','','Slaskie',133,'86587','867287719310',0x0000000001010000002431F77FC41F3340F5B06197F2654940,'2014-09-25 22:32:42'),
+(579,'521 San Juan Bautista Tuxtepec Place','','Qaraghandy',598,'95093','844018348565',0x0000000001010000006848CB3711F15040E32A604C44E44740,'2014-09-25 22:31:56'),
+(580,'923 Tangail Boulevard','','Tokyo-to',10,'33384','315528269898',0x00000000010100000078E5C468A76B6140C3A27D079ADA4140,'2014-09-25 22:31:45'),
+(581,'186 Skikda Lane','','Morelos',131,'89422','14465669789',0x00000000010100000048C2BE9DC4CE58C0DA3DD4111BED3240,'2014-09-25 22:32:05'),
+(582,'1568 Celaya Parkway','','Kaohsiung',168,'34750','278669994384',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(583,'1489 Kakamigahara Lane','','Taipei',526,'98883','29341849811',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:16'),
+(584,'1819 Alessandria Loop','','Campeche',103,'53829','377633994405',0x0000000001010000008636A5611DF556C0374F1A0F5BA53240,'2014-09-25 22:32:02'),
+(585,'1208 Tama Loop','','Ninawa',344,'73605','954786054144',0x000000000101000000314F9DFD378F4540961EF23BF22A4240,'2014-09-25 22:31:40'),
+(586,'951 Springs Lane','','Central Mindanao',219,'96115','165164761435',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:37'),
+(587,'760 Miyakonojo Drive','','Guerrero',246,'64682','294449058179',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:08'),
+(588,'966 Asuncin Way','','Hidalgo',212,'62703','995527378381',0x000000000101000000EBBD4230D89A58C0E30632F1FD233540,'2014-09-25 22:32:07'),
+(589,'1584 Ljubertsy Lane','','England',494,'22954','285710089439',0x00000000010100000035385B8AF577F6BF8C7560EFB4734940,'2014-09-25 22:33:38'),
+(590,'247 Jining Parkway','','Banjul',54,'53446','170115379190',0x0000000001010000001BE4E434FA9330C08A8F4FC8CEE72A40,'2014-09-25 22:31:04'),
+(591,'773 Dallas Manor','','Buenos Aires',424,'12664','914466027044',0x00000000010100000009C3802557204DC0B75CA21FB25C41C0,'2014-09-25 22:30:06'),
+(592,'1923 Stara Zagora Lane','','Nantou',546,'95179','182178609211',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:17'),
+(593,'1402 Zanzibar Boulevard','','Guanajuato',106,'71102','387448063440',0x000000000101000000FCB7DCAA353459C05CA8A1B206863440,'2014-09-25 22:32:03'),
+(594,'1464 Kursk Parkway','','Shandong',574,'17381','338758048786',0x0000000001010000008CA2073E86C65D40055669E6245B4240,'2014-09-25 22:30:44'),
+(595,'1074 Sanaa Parkway','','Loja',311,'22474','154124128457',0x00000000010100000092DBE51112CD53C00EF96706F1F10FC0,'2014-09-25 22:30:55'),
+(596,'1759 Niznekamsk Avenue','','al-Manama',14,'39414','864392582257',0x000000000101000000044D9539A74A49401224004922373A40,'2014-09-25 22:30:11'),
+(597,'32 Liaocheng Way','','Minas Gerais',248,'1944','410877354933',0x000000000101000000C2757BFFD5AC45C0424F1432A1C335C0,'2014-09-25 22:30:19'),
+(598,'42 Fontana Avenue','','Fejr',512,'14684','437829801725',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:09'),
+(599,'1895 Zhezqazghan Drive','','California',177,'36693','137809746111',0x0000000001010000003EC7ECD1407C5DC057FA1A930FE34040,'2014-09-25 22:33:51'),
+(600,'1837 Kaduna Parkway','','Inner Mongolia',241,'82580','640843562301',0x000000000101000000D61A4AEDC5465C400E64E2FB87834440,'2014-09-25 22:30:37'),
+(601,'844 Bucuresti Place','','Liaoning',242,'36603','935952366111',0x000000000101000000B88086EDDD6D5E407CED9925018D4340,'2014-09-25 22:30:37'),
+(602,'1101 Bucuresti Boulevard','','West Greece',401,'97661','199514580428',0x000000000101000000AAC1EA7E04BC3540E65F26E5491F4340,'2014-09-25 22:31:07'),
+(603,'1103 Quilmes Boulevard','','Piura',503,'52137','644021380889',0x000000000101000000AD9685C0DB2B54C09B012EC8969D13C0,'2014-09-25 22:32:34'),
+(604,'1331 Usak Boulevard','','Vaud',296,'61960','145308717464',0x000000000101000000CE273CB203881A40205734E72A424740,'2014-09-25 22:33:14'),
+(605,'1325 Fukuyama Street','','Heilongjiang',537,'27107','288241215394',0x00000000010100000017540A70700160401E1C47077F7D4740,'2014-09-25 22:30:44');
+COMMIT;
+DROP TABLE address;
diff --git a/mysql-test/suite/innodb_gis/t/rtree.test b/mysql-test/suite/innodb_gis/t/rtree.test
index 3a0e5311b32..58d81576b3e 100644
--- a/mysql-test/suite/innodb_gis/t/rtree.test
+++ b/mysql-test/suite/innodb_gis/t/rtree.test
@@ -234,3 +234,626 @@ DELETE FROM t1
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((0 0,4 0, 4 4, 0 4, 0 0))'),g);
DROP TABLE t1;
+
+# Test with real world data.
+CREATE TABLE address (
+ address_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ address VARCHAR(50) NOT NULL,
+ address2 VARCHAR(50) DEFAULT NULL,
+ district VARCHAR(20) NOT NULL,
+ city_id SMALLINT UNSIGNED NOT NULL,
+ postal_code VARCHAR(10) DEFAULT NULL,
+ phone VARCHAR(20) NOT NULL,
+ location GEOMETRY NOT NULL,
+ last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (address_id),
+ SPATIAL KEY `idx_location` (location)
+)ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+SET AUTOCOMMIT=0;
+INSERT INTO `address` VALUES (1,'47 MySakila Drive',NULL,'Alberta',300,'','',0x0000000001010000003E0A325D63345CC0761FDB8D99D94840,'2014-09-25 22:30:27'),
+(2,'28 MySQL Boulevard',NULL,'QLD',576,'','',0x0000000001010000008E10D4DF812463404EE08C5022A23BC0,'2014-09-25 22:30:09'),
+(3,'23 Workhaven Lane',NULL,'Alberta',300,'','14033335568',0x000000000101000000CDC4196863345CC01DEE7E7099D94840,'2014-09-25 22:30:27'),
+(4,'1411 Lillydale Drive',NULL,'QLD',576,'','6172235589',0x0000000001010000005B0DE4341F26634042D6AE6422A23BC0,'2014-09-25 22:30:09'),
+(5,'1913 Hanoi Way','','Nagasaki',463,'35200','28303384290',0x00000000010100000028D1370E21376040ABB58BC45F944040,'2014-09-25 22:31:53'),
+(6,'1121 Loja Avenue','','California',449,'17886','838635286649',0x0000000001010000003C94579D8B525DC0E860472DDE0D4140,'2014-09-25 22:34:01'),
+(7,'692 Joliet Street','','Attika',38,'83579','448477190408',0x000000000101000000076F59CF5AB737404105D1A45EFD4240,'2014-09-25 22:31:07'),
+(8,'1566 Inegl Manor','','Mandalay',349,'53561','705814003527',0x00000000010100000006240626DCD857403C45B357C4753540,'2014-09-25 22:32:18'),
+(9,'53 Idfu Parkway','','Nantou',361,'42399','10655648674',0x0000000001010000001F813FFC7C2A5E40357A354069EA3740,'2014-09-25 22:33:16'),
+(10,'1795 Santiago de Compostela Way','','Texas',295,'18743','860452626434',0x00000000010100000050502F9D7BE058C0D0CF7932A4813B40,'2014-09-25 22:33:55'),
+(11,'900 Santiago de Compostela Parkway','','Central Serbia',280,'93896','716571220373',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:11'),
+(12,'478 Joliet Way','','Hamilton',200,'77948','657282285970',0x000000000101000000DC84D61E11E9654072B7353344E442C0,'2014-09-25 22:32:22'),
+(13,'613 Korolev Drive','','Masqat',329,'45844','380657522649',0x00000000010100000001023164D04B4D40CEAC003A279D3740,'2014-09-25 22:32:29'),
+(14,'1531 Sal Drive','','Esfahan',162,'53628','648856936185',0x000000000101000000DE0951195AD64940635A400D84534040,'2014-09-25 22:31:36'),
+(15,'1542 Tarlac Parkway','','Kanagawa',440,'1027','635297277345',0x000000000101000000B4CDE8A27C6B61406B7D361724C74140,'2014-09-25 22:31:53'),
+(16,'808 Bhopal Manor','','Haryana',582,'10672','465887807014',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:30'),
+(17,'270 Amroha Parkway','','Osmaniye',384,'29610','695479687538',0x0000000001010000001F436C55B71F4240A11408967E894240,'2014-09-25 22:33:27'),
+(18,'770 Bydgoszcz Avenue','','California',120,'16266','517338314235',0x0000000001010000006D63A2F7FC515EC04C040539835A4340,'2014-09-25 22:33:47'),
+(19,'419 Iligan Lane','','Madhya Pradesh',76,'72878','990911107354',0x000000000101000000B7B01303C9595340E6F10FB633413740,'2014-09-25 22:31:13'),
+(20,'360 Toulouse Parkway','','England',495,'54308','949312333307',0x000000000101000000860FDBCCD7DBE63FFDCFAB4BD7C44940,'2014-09-25 22:33:40'),
+(21,'270 Toulon Boulevard','','Kalmykia',156,'81766','407752414682',0x000000000101000000FD0BA947BF204640316D495865274740,'2014-09-25 22:32:48'),
+(22,'320 Brest Avenue','','Kaduna',252,'43331','747791594069',0x0000000001010000006D3425FECDC01D40623FD532630B2540,'2014-09-25 22:32:25'),
+(23,'1417 Lancaster Avenue','','Northern Cape',267,'72192','272572357893',0x000000000101000000FEE8E5C127C338404DED56E075BB3CC0,'2014-09-25 22:33:03'),
+(24,'1688 Okara Way','','Nothwest Border Prov',327,'21954','144453869132',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:30'),
+(25,'262 A Corua (La Corua) Parkway','','Dhaka',525,'34418','892775750063',0x000000000101000000F13790E4A87A5640E7F6370DF63F3840,'2014-09-25 22:30:12'),
+(26,'28 Charlotte Amalie Street','','Rabat-Sal-Zammour-Z',443,'37551','161968374323',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:16'),
+(27,'1780 Hino Boulevard','','Liepaja',303,'7716','902731229323',0x000000000101000000360F1604450435403CA3AD4A22424C40,'2014-09-25 22:31:58'),
+(28,'96 Tafuna Way','','Crdoba',128,'99865','934730187245',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:05'),
+(29,'934 San Felipe de Puerto Plata Street','','Sind',472,'99780','196495945706',0x0000000001010000008E6B8D52D3285140D58E876302F53B40,'2014-09-25 22:32:31'),
+(30,'18 Duisburg Boulevard','','',121,'58327','998009777982',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:08'),
+(31,'217 Botshabelo Place','','Southern Mindanao',138,'49521','665356572025',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:36'),
+(32,'1425 Shikarpur Manor','','Bihar',346,'65599','678220867005',0x0000000001010000007F9F16284E9E55408201840F25603940,'2014-09-25 22:31:20'),
+(33,'786 Aurora Avenue','','Yamaguchi',474,'65750','18461860151',0x000000000101000000E712584AA05E6040D15735ADB9FA4040,'2014-09-25 22:31:53'),
+(34,'1668 Anpolis Street','','Taipei',316,'50199','525255540978',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(35,'33 Gorontalo Way','','West Bengali',257,'30348','745994947458',0x0000000001010000001A828879FB17564061585936CEAB3640,'2014-09-25 22:31:18'),
+(36,'176 Mandaluyong Place','','Uttar Pradesh',239,'65213','627705991774',0x00000000010100000073309B0043A553409E3AA0B657743940,'2014-09-25 22:31:17'),
+(37,'127 Purnea (Purnia) Manor','','Piemonte',17,'79388','911872220378',0x0000000001010000002A2B97D75B382140F2892B1D62744640,'2014-09-25 22:31:42'),
+(38,'61 Tama Street','','Okayama',284,'94065','708403338270',0x0000000001010000001F7013A488B86040670696C8AA4A4140,'2014-09-25 22:31:49'),
+(39,'391 Callao Drive','','Midi-Pyrnes',544,'34021','440512153169',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:01'),
+(40,'334 Munger (Monghyr) Lane','','Markazi',31,'38145','481183273622',0x000000000101000000737275B636D848404B958334BE0B4140,'2014-09-25 22:31:36'),
+(41,'1440 Fukuyama Loop','','Henan',362,'47929','912257250465',0x0000000001010000005E3CCD1319225C405886DD1C537F4040,'2014-09-25 22:30:40'),
+(42,'269 Cam Ranh Parkway','','Chisinau',115,'34689','489783829737',0x000000000101000000AD97F0958ADB3C40CCD47F31B6804740,'2014-09-25 22:32:15'),
+(43,'306 Antofagasta Place','','Esprito Santo',569,'3989','378318851631',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:23'),
+(44,'671 Graz Street','','Oriental',353,'94399','680768868518',0x00000000010100000083F7FAFFDD7707C0F7B7BA5285954140,'2014-09-25 22:32:16'),
+(45,'42 Brindisi Place','','Yerevan',586,'16744','42384721397',0x000000000101000000281BC528BE4146403BD400EF2E174440,'2014-09-25 22:30:08'),
+(46,'1632 Bislig Avenue','','Nonthaburi',394,'61117','471675840679',0x000000000101000000935C59FDEC1F5940D5D0611976D32B40,'2014-09-25 22:33:20'),
+(47,'1447 Imus Way','','Tahiti',167,'48942','539758313890',0x00000000010100000090CE0A56E6B562C059BB9289008E31C0,'2014-09-25 22:31:02'),
+(48,'1998 Halifax Drive','','Lipetsk',308,'76022','177727722820',0x00000000010100000087985CD60EC943409F1738EA324D4A40,'2014-09-25 22:32:54'),
+(49,'1718 Valencia Street','','Antofagasta',27,'37359','675292816413',0x0000000001010000007E82D5A24F9951C0C46B4DA901A737C0,'2014-09-25 22:30:29'),
+(50,'46 Pjatigorsk Lane','','Moscow (City)',343,'23616','262076994845',0x0000000001010000009C51F355F2C4424002E3CFA6D9DF4B40,'2014-09-25 22:32:55'),
+(51,'686 Garland Manor','','Cear',247,'52535','69493378813',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:19'),
+(52,'909 Garland Manor','','Tatarstan',367,'69367','705800322606',0x000000000101000000376DC66988E949402CA85E6D7BD14B40,'2014-09-25 22:32:55'),
+(53,'725 Isesaki Place','','Mekka',237,'74428','876295323994',0x000000000101000000213361455799434061EB0896D98A3540,'2014-09-25 22:33:00'),
+(54,'115 Hidalgo Parkway','','Khartum',379,'80168','307703950263',0x00000000010100000004503173263D40404D0DD9E5004A2F40,'2014-09-25 22:33:11'),
+(55,'1135 Izumisano Parkway','','California',171,'48150','171822533480',0x0000000001010000009763C3E4D75B5DC0799A2732CE0B4140,'2014-09-25 22:33:50'),
+(56,'939 Probolinggo Loop','','Galicia',1,'4166','680428310138',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(57,'17 Kabul Boulevard','','Chiba',355,'38594','697760867968',0x000000000101000000EB257CA5E27C61406F70D86C9BED4140,'2014-09-25 22:31:51'),
+(58,'1964 Allappuzha (Alleppey) Street','','Yamaguchi',227,'48980','920811325222',0x000000000101000000C2572A5E1B876040D19A7A38DC144140,'2014-09-25 22:31:47'),
+(59,'1697 Kowloon and New Kowloon Loop','','Moskova',49,'57807','499352017190',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(60,'1668 Saint Louis Place','','Tahiti',397,'39072','347487831378',0x0000000001010000006FF3C64921B262C0F8F47DDD8E8931C0,'2014-09-25 22:31:02'),
+(61,'943 Tokat Street','','Vaduz',560,'45428','889318963672',0x0000000001010000007F784C93080B23400341800C1D924740,'2014-09-25 22:31:58'),
+(62,'1114 Liepaja Street','','Sarawak',282,'69226','212869228936',0x000000000101000000047FAE6C55955B408285DDC199E9F83F,'2014-09-25 22:32:00'),
+(63,'1213 Ranchi Parkway','','Karnataka',350,'94352','800024380485',0x000000000101000000000080279AD7C641AA21BB1CC0202B40,'2014-09-25 22:31:21'),
+(64,'81 Hodeida Way','','Rajasthan',231,'55561','250767749542',0x0000000001010000000A09BDA36BF25240F8B138526CEB3A40,'2014-09-25 22:31:17'),
+(65,'915 Ponce Place','','Basel-Stadt',56,'83980','1395251317',0x0000000001010000000D6146C2084B1E40E58B07A579C74740,'2014-09-25 22:33:12'),
+(66,'1717 Guadalajara Lane','','Missouri',441,'85505','914090181665',0x000000000101000000A926D247AA8C56C0A456F3774A504340,'2014-09-25 22:33:59'),
+(67,'1214 Hanoi Way','','Nebraska',306,'67055','491001136577',0x000000000101000000D6671888AF2A58C0C0E2152DE5684440,'2014-09-25 22:33:56'),
+(68,'1966 Amroha Avenue','','Sichuan',139,'70385','333489324603',0x0000000001010000000A7778190FE05A402F6013E346373F40,'2014-09-25 22:30:32'),
+(69,'698 Otsu Street','','Cayenne',105,'71110','409983924481',0x000000000101000000D879C0E1AA2A4AC0D57EC6E0BCBB1340,'2014-09-25 22:31:02'),
+(70,'1150 Kimchon Manor','','Skne ln',321,'96109','663449333709',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:11'),
+(71,'1586 Guaruj Place','','Hunan',579,'5135','947233365992',0x000000000101000000AD3A06BFE83F5C4083047B0217DA3B40,'2014-09-25 22:30:46'),
+(72,'57 Arlington Manor','','Madhya Pradesh',475,'48960','990214419142',0x0000000001010000008E6D63FDB069534027D9EA724A6E3940,'2014-09-25 22:31:27'),
+(73,'1031 Daugavpils Parkway','','Bchar',63,'59025','107137400143',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:29:59'),
+(74,'1124 Buenaventura Drive','','Mekka',13,'6856','407733804223',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:59'),
+(75,'492 Cam Ranh Street','','Eastern Visayas',61,'50805','565018274456',0x0000000001010000007500C45D3D335F40B90265AE675B2540,'2014-09-25 22:32:34'),
+(76,'89 Allappuzha (Alleppey) Manor','','National Capital Reg',517,'75444','255800440636',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:39'),
+(77,'1947 Poos de Caldas Boulevard','','Chiayi',114,'60951','427454485876',0x0000000001010000002F06C54524195E40B4475E8C37763740,'2014-09-25 22:33:14'),
+(78,'1206 Dos Quebradas Place','','So Paulo',431,'20207','241832790687',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(79,'1551 Rampur Lane','','Changhwa',108,'72394','251164340471',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:14'),
+(80,'602 Paarl Street','','Pavlodar',402,'98889','896314772871',0x000000000101000000359078C34740534032D010E912234A40,'2014-09-25 22:31:55'),
+(81,'1692 Ede Loop','','So Paulo',30,'9223','918711376618',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:16'),
+(82,'936 Salzburg Lane','','Uttar Pradesh',425,'96709','875756771675',0x0000000001010000000C0EE5FAAD4F5440CBF8F71917383A40,'2014-09-25 22:31:24'),
+(83,'586 Tete Way','','Kanagawa',256,'1079','18581624103',0x000000000101000000783B0CF79B716140E96D22E989A74140,'2014-09-25 22:31:48'),
+(84,'1888 Kabul Drive','','Oyo & Osun',217,'20936','701457319790',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:24'),
+(85,'320 Baiyin Parkway','','Mahajanga',319,'37307','223664661973',0x000000000101000000EAFD90C888284740CDC75AE8EF6E2FC0,'2014-09-25 22:31:59'),
+(86,'927 Baha Blanca Parkway','','Krim',479,'9495','821972242086',0x000000000101000000417DCB9C2E0E4140BC29406F857A4640,'2014-09-25 22:33:33'),
+(87,'929 Tallahassee Loop','','Gauteng',497,'74671','800716535041',0x000000000101000000647F8FB05E6B3C407F60D8ABD9403AC0,'2014-09-25 22:33:06'),
+(88,'125 Citt del Vaticano Boulevard','','Puebla',40,'67912','48417642933',0x000000000101000000536232B0E99B58C03D0D18247DE83240,'2014-09-25 22:32:02'),
+(89,'1557 Ktahya Boulevard','','England',88,'88002','720998247660',0x0000000001010000001B43A5B67908FCBF439D03159FE54A40,'2014-09-25 22:33:36'),
+(90,'870 Ashqelon Loop','','Songkhla',489,'84931','135117278909',0x000000000101000000E82510C017265940115A6A1899CB1C40,'2014-09-25 22:33:20'),
+(91,'1740 Portoviejo Avenue','','Sucre',480,'29932','198123170793',0x000000000101000000C4AD275F75D952C07A51BB5F059C2240,'2014-09-25 22:30:53'),
+(92,'1942 Ciparay Parkway','','Cheju',113,'82624','978987363654',0x00000000010100000048F13B97F3A25F40358EA2186AB34040,'2014-09-25 22:33:06'),
+(93,'1926 El Alto Avenue','','Buenos Aires',289,'75543','846225459260',0x000000000101000000AD05AC0B2EFA4CC0C5D0A057F27541C0,'2014-09-25 22:30:05'),
+(94,'1952 Chatsworth Drive','','Guangdong',332,'25958','991562402283',0x000000000101000000A5F386A08F085D406DF65157885A3840,'2014-09-25 22:30:40'),
+(95,'1370 Le Mans Avenue','','Brunei and Muara',53,'52163','345679835036',0x00000000010100000013E85D06ADBC5C402A0E5652DDC21340,'2014-09-25 22:30:23'),
+(96,'984 Effon-Alaiye Avenue','','Gois',183,'17119','132986892228',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:17'),
+(97,'832 Nakhon Sawan Manor','','Inner Mongolia',592,'49021','275595571388',0x000000000101000000535C55F6DDAD5E400000001D69FABC41,'2014-09-25 22:30:50'),
+(98,'152 Kitwe Parkway','','Caraga',82,'53182','835433605312',0x000000000101000000DF652BD43F945F4006CAB788396E2040,'2014-09-25 22:32:35'),
+(99,'1697 Tanauan Lane','','Punjab',399,'22870','4764773857',0x000000000101000000CA97063447E95240B933B852742A4040,'2014-09-25 22:31:22'),
+(100,'1308 Arecibo Way','','Georgia',41,'30695','6171054059',0x000000000101000000FC00FFEF637E54C0BD9EF9E648BC4040,'2014-09-25 22:33:43'),
+(101,'1599 Plock Drive','','Tete',534,'71986','817248913162',0x000000000101000000DC77561C18CB4040B443577D092830C0,'2014-09-25 22:32:18'),
+(102,'669 Firozabad Loop','','Abu Dhabi',12,'92265','412903167998',0x0000000001010000009C76E73F5AE14B404AD05FE811313840,'2014-09-25 22:33:35'),
+(103,'588 Vila Velha Manor','','Kyongsangbuk',268,'51540','333339908719',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(104,'1913 Kamakura Place','','Lipetsk',238,'97287','942570536750',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:49'),
+(105,'733 Mandaluyong Place','','Asir',2,'77459','196568435814',0x0000000001010000007823980FAD404540798FD89365373240,'2014-09-25 22:32:59'),
+(106,'659 Vaduz Drive','','Ha Darom',34,'49708','709935135487',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:40'),
+(107,'1177 Jelets Way','','Kwara & Kogi',220,'3305','484292626944',0x0000000001010000001767672CF53712407E3E25427E192140,'2014-09-25 22:32:24'),
+(108,'1386 Yangor Avenue','','Provence-Alpes-Cte',543,'80720','449216226468',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:01'),
+(109,'454 Nakhon Sawan Boulevard','','Funafuti',173,'76383','963887147572',0x0000000001010000005822ABB636666640FF74A84B6B0C21C0,'2014-09-25 22:33:31'),
+(110,'1867 San Juan Bautista Tuxtepec Avenue','','Ivanovo',225,'78311','547003310357',0x000000000101000000BC6DF0CF567C4440E2B034F0A37F4C40,'2014-09-25 22:32:48'),
+(111,'1532 Dzerzinsk Way','','Buenos Aires',334,'9599','330838016880',0x000000000101000000BF93BB74385D4DC0E207420D3A5541C0,'2014-09-25 22:30:06'),
+(112,'1002 Ahmadnagar Manor','','Mxico',213,'93026','371490777743',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:07'),
+(113,'682 Junan Way','','North West',273,'30418','622255216127',0x000000000101000000714683CAAEAA3A406AEDC73725DA3AC0,'2014-09-25 22:33:04'),
+(114,'804 Elista Drive','','Hubei',159,'61069','379804592943',0x0000000001010000009E013FF4EE5E5B40E7E099D0245F3E40,'2014-09-25 22:30:33'),
+(115,'1378 Alvorada Avenue','','Distrito Federal',102,'75834','272234298332',0x0000000001010000000C3444BA44B850C047B1378CDDF92440,'2014-09-25 22:34:03'),
+(116,'793 Cam Ranh Avenue','','California',292,'87057','824370924746',0x00000000010100000003AF3B82C0885DC0610212A859594140,'2014-09-25 22:33:55'),
+(117,'1079 Tel Aviv-Jaffa Boulevard','','Sucre',132,'10885','358178933857',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:04'),
+(118,'442 Rae Bareli Place','','Nordrhein-Westfalen',148,'24321','886636413768',0x000000000101000000C19EC085860F1B40E37ED12F5BB74940,'2014-09-25 22:31:04'),
+(119,'1107 Nakhon Sawan Avenue','','Mxico',365,'75149','867546627903',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:11'),
+(120,'544 Malm Parkway','','Central Java',403,'63502','386759646229',0x0000000001010000003AEF5A9D77575B4026F103A106C51BC0,'2014-09-25 22:31:34'),
+(121,'1967 Sincelejo Place','','Gujarat',176,'73644','577812616052',0x00000000010100000059912CBBBB2B52408DBC074378373740,'2014-09-25 22:31:16'),
+(122,'333 Goinia Way','','Texas',185,'78625','909029256431',0x0000000001010000002AE67BA1DB3F58C0E46B2AE67B5F4040,'2014-09-25 22:33:51'),
+(123,'1987 Coacalco de Berriozbal Loop','','al-Qalyubiya',476,'96065','787654415858',0x000000000101000000595AFC5C23403F40AFBA698E07203E40,'2014-09-25 22:30:58'),
+(124,'241 Mosul Lane','','Risaralda',147,'76157','765345144779',0x000000000101000000983A23A5B4EA52C06155BDFC4E5B1340,'2014-09-25 22:30:52'),
+(125,'211 Chiayi Drive','','Uttar Pradesh',164,'58186','665993880048',0x000000000101000000A44BA4D961C1534007F247AC20C73A40,'2014-09-25 22:31:15'),
+(126,'1175 Tanauan Way','','Lima',305,'64615','937222955822',0x000000000101000000848A60D2CE4153C0E5417A8A1C1628C0,'2014-09-25 22:32:33'),
+(127,'117 Boa Vista Way','','Uttar Pradesh',566,'6804','677976133614',0x00000000010100000085364AA8AAC0544086BAFE1312513940,'2014-09-25 22:31:29'),
+(128,'848 Tafuna Manor','','Ktahya',281,'45142','614935229095',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:27'),
+(129,'569 Baicheng Lane','','Gauteng',85,'60304','490211944645',0x000000000101000000D71E51FC73423C4048AE51C543363AC0,'2014-09-25 22:33:02'),
+(130,'1666 Qomsheh Drive','','So Paulo',410,'66255','582835362905',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(131,'801 Hagonoy Drive','','Smolensk',484,'8439','237426099212',0x0000000001010000001EB814A122054040BB8509FE12644B40,'2014-09-25 22:32:57'),
+(132,'1050 Garden Grove Avenue','','Slaskie',236,'4999','973047364353',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:42'),
+(133,'1854 Tieli Street','','Shandong',302,'15819','509492324775',0x0000000001010000007A820E0492FE5C408F0475255D3A4240,'2014-09-25 22:30:39'),
+(134,'758 Junan Lane','','Gois',190,'82639','935448624185',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(135,'1752 So Leopoldo Parkway','','Taka-Karpatia',345,'14014','252265130067',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:32'),
+(136,'898 Belm Manor','','Free State',87,'49757','707169393853',0x000000000101000000ED4CFCAC8DB43A409EAC623B29453DC0,'2014-09-25 22:33:02'),
+(137,'261 Saint Louis Way','','Coahuila de Zaragoza',541,'83401','321944036800',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:13'),
+(138,'765 Southampton Drive','','al-Qalyubiya',421,'4285','23712411567',0x0000000001010000001BEB877DA7343F409FBC7E77E12D3E40,'2014-09-25 22:30:57'),
+(139,'943 Johannesburg Avenue','','Maharashtra',417,'5892','90921003005',0x000000000101000000F27A3029BE7652405E2ADB2C03853240,'2014-09-25 22:31:24'),
+(140,'788 Atinsk Street','','Karnataka',211,'81691','146497509724',0x0000000001010000000000801B1998C64157A945E977E62E40,'2014-09-25 22:31:17'),
+(141,'1749 Daxian Place','','Gelderland',29,'11044','963369996279',0x000000000101000000E4CE96BDB6E0174000B0952B171C4A40,'2014-09-25 22:32:20'),
+(142,'1587 Sullana Lane','','Inner Mongolia',207,'85769','468060467018',0x000000000101000000870CF505BEE95B407422669BC0674440,'2014-09-25 22:30:35'),
+(143,'1029 Dzerzinsk Manor','','Ynlin',542,'57519','33173584456',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:16'),
+(144,'1666 Beni-Mellal Place','','Tennessee',123,'13377','9099941466',0x00000000010100000005D1A45E01D755C084CCDFCECF434240,'2014-09-25 22:33:48'),
+(145,'928 Jaffna Loop','','Hiroshima',172,'93762','581852137991',0x0000000001010000002F2988CBBBAB6040E2FF33EFDD3D4140,'2014-09-25 22:31:45'),
+(146,'483 Ljubertsy Parkway','','Scotland',149,'60562','581174211853',0x000000000101000000C53E5CCD95CC07C0FAFD518A0C3C4C40,'2014-09-25 22:33:36'),
+(147,'374 Bat Yam Boulevard','','Kilis',266,'97700','923261616249',0x000000000101000000184FF344C68E4240FD55DBA8A95B4240,'2014-09-25 22:33:26'),
+(148,'1027 Songkhla Manor','','Minsk',340,'30861','563660187896',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:13'),
+(149,'999 Sanaa Loop','','Gauteng',491,'3439','918032330119',0x0000000001010000000E0D309864193C40F234AA1D0F7939C0,'2014-09-25 22:33:05'),
+(150,'879 Newcastle Way','','Michigan',499,'90732','206841104594',0x000000000101000000916A8E62EFC154C08244C99A474A4540,'2014-09-25 22:34:01'),
+(151,'1337 Lincoln Parkway','','Saitama',555,'99457','597815221267',0x0000000001010000005E0E6036A6746140456227614BEE4140,'2014-09-25 22:31:55'),
+(152,'1952 Pune Lane','','Saint-Denis',442,'92150','354615066969',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:46'),
+(153,'782 Mosul Street','','Massachusetts',94,'25545','885899703621',0x000000000101000000E9C4D44C2DC151C0D1686105AE0A4540,'2014-09-25 22:33:46'),
+(154,'781 Shimonoseki Drive','','Michoacn de Ocampo',202,'95444','632316273199',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:06'),
+(155,'1560 Jelets Boulevard','','Shandong',291,'77777','189446090264',0x00000000010100000018D57D5B0B6A5D40ADDA3521AD184240,'2014-09-25 22:30:38'),
+(156,'1963 Moscow Place','','Assam',354,'64863','761379480249',0x000000000101000000203BB9F04D2C57405D595826B2593A40,'2014-09-25 22:31:21'),
+(157,'456 Escobar Way','','Jakarta Raya',232,'36061','719202533520',0x000000000101000000DDC2A9C516B65A4095CCFB49C6DB18C0,'2014-09-25 22:31:33'),
+(158,'798 Cianjur Avenue','','Shanxi',590,'76990','499408708580',0x00000000010100000013D6C6D889BF5B409B4BBBE2F3824140,'2014-09-25 22:30:49'),
+(159,'185 Novi Sad Place','','Bern',72,'41778','904253967161',0x00000000010100000000D0BC772FCA1D40377D2C335B794740,'2014-09-25 22:33:13'),
+(160,'1367 Yantai Manor','','Ondo & Ekiti',381,'21294','889538496300',0x000000000101000000C25E72ED555514408A7A1C61ACAA1C40,'2014-09-25 22:32:26'),
+(161,'1386 Nakhon Sawan Boulevard','','Pyongyang-si',420,'53502','368899174225',0x000000000101000000F4BA8FED46705F40A55F6C6B55844340,'2014-09-25 22:32:28'),
+(162,'369 Papeete Way','','North Carolina',187,'66639','170117068815',0x000000000101000000C49D66DCAFF253C07A2D324B4C094240,'2014-09-25 22:33:52'),
+(163,'1440 Compton Place','','North Austria',307,'81037','931059836497',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:10'),
+(164,'1623 Baha Blanca Manor','','Moskova',310,'81511','149981248346',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:54'),
+(165,'97 Shimoga Avenue','','Tel Aviv',533,'44660','177167004331',0x0000000001010000009A56AFC7E96341403192E2885A0A4040,'2014-09-25 22:31:41'),
+(166,'1740 Le Mans Loop','','Pays de la Loire',297,'22853','168476538960',0x000000000101000000452A8C2D04B9D23F0000006AB82DBD41,'2014-09-25 22:31:01'),
+(167,'1287 Xiangfan Boulevard','','Gifu',253,'57844','819416131190',0x0000000001010000006AE514D3BB1B61408141D2A755B54140,'2014-09-25 22:31:48'),
+(168,'842 Salzburg Lane','','Adana',529,'3313','697151428760',0x0000000001010000007207A0072DD5414093228D6555A64240,'2014-09-25 22:33:29'),
+(169,'154 Tallahassee Loop','','Xinxiang',199,'62250','935508855935',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:34'),
+(170,'710 San Felipe del Progreso Avenue','','Lilongwe',304,'76901','843801144113',0x00000000010100000089C855D1C4E44040501D064E11EF2BC0,'2014-09-25 22:31:59'),
+(171,'1540 Wroclaw Drive','','Maharashtra',107,'62686','182363341674',0x0000000001010000004E10D0D8F2D253407CFB294476F23340,'2014-09-25 22:31:14'),
+(172,'475 Atinsk Way','','Gansu',240,'59571','201705577290',0x0000000001010000007872970E678C59405544978114404340,'2014-09-25 22:30:36'),
+(173,'1294 Firozabad Drive','','Jiangxi',407,'70618','161801569569',0x000000000101000000EED7F8A7AF775C402332079C00943B40,'2014-09-25 22:30:40'),
+(174,'1877 Ezhou Lane','','Rajasthan',550,'63337','264541743403',0x00000000010100000029722DFF466C52401969F34938923840,'2014-09-25 22:31:28'),
+(175,'316 Uruapan Street','','Perak',223,'58194','275788967899',0x0000000001010000005A3629BB4F4559400AC5B18927561240,'2014-09-25 22:31:59'),
+(176,'29 Pyongyang Loop','','Batman',58,'47753','734780743462',0x0000000001010000001C430070EC9044403C8963B895F14240,'2014-09-25 22:33:23'),
+(177,'1010 Klerksdorp Way','','Steiermark',186,'6802','493008546874',0x000000000101000000CFEE35A90DE72E409C0425BB88884740,'2014-09-25 22:30:10'),
+(178,'1848 Salala Boulevard','','Miranda',373,'25220','48265851133',0x0000000001010000006D08E984ABB150C02F90FBB1A43B2440,'2014-09-25 22:34:04'),
+(179,'431 Xiangtan Avenue','','Kerala',18,'4854','230250973122',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:10'),
+(180,'757 Rustenburg Avenue','','Skikda',483,'89668','506134035434',0x000000000101000000BFD76BD509A31B4063867C8626704240,'2014-09-25 22:30:01'),
+(181,'146 Johannesburg Way','','Tamaulipas',330,'54132','953689007081',0x0000000001010000003C45B357446058C0EAD621ED35E13940,'2014-09-25 22:32:09'),
+(182,'1891 Rizhao Boulevard','','So Paulo',456,'47288','391065549876',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(183,'1089 Iwatsuki Avenue','','Kirov',270,'35109','866092335135',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:50'),
+(184,'1410 Benin City Parkway','','Risaralda',405,'29747','104150372603',0x0000000001010000007C4F9B278DEC52C0795BE9B5D9401340,'2014-09-25 22:30:52'),
+(185,'682 Garden Grove Place','','Tennessee',333,'67497','72136330362',0x0000000001010000004204C188228356C06B4F24F323934140,'2014-09-25 22:33:57'),
+(186,'533 al-Ayn Boulevard','','California',126,'8862','662227486184',0x000000000101000000BF2264C5158E5DC08533AE6EABF24040,'2014-09-25 22:33:48'),
+(187,'1839 Szkesfehrvr Parkway','','Gois',317,'55709','947468818183',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(188,'741 Ambattur Manor','','Noord-Brabant',438,'43310','302590383819',0x000000000101000000699E6D7F78371540EF0D74A37ED94940,'2014-09-25 22:32:21'),
+(189,'927 Barcelona Street','','Chaharmahal va Bakht',467,'65121','951486492670',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:38'),
+(190,'435 0 Way','','West Bengali',195,'74750','760171523969',0x000000000101000000D9846A3906075640037168DB7A0F3640,'2014-09-25 22:31:16'),
+(191,'140 Chiayi Parkway','','Sumy',506,'38982','855863906434',0x0000000001010000002C43C1317066414051BB5F05F8754940,'2014-09-25 22:33:34'),
+(192,'1166 Changhwa Street','','Caraga',62,'58852','650752094490',0x0000000001010000009DB756201F715F40F53E9F1221832140,'2014-09-25 22:32:34'),
+(193,'891 Novi Sad Manor','','Ontario',383,'5379','247646995453',0x0000000001010000005E49F25C5FB653C0DE6AE74537F34540,'2014-09-25 22:30:28'),
+(194,'605 Rio Claro Parkway','','Tabora',513,'49348','352469351088',0x0000000001010000004E8B0B51CF694040DF67017F9D1014C0,'2014-09-25 22:33:18'),
+(195,'1077 San Felipe de Puerto Plata Place','','Rostov-na-Donu',369,'65387','812824036424',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:56'),
+(196,'9 San Miguel de Tucumn Manor','','Uttar Pradesh',169,'90845','956188728558',0x00000000010100000067DBC424B7995340A461E75C40263B40,'2014-09-25 22:31:15'),
+(197,'447 Surakarta Loop','','Nyanza',271,'10428','940830176580',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:56'),
+(198,'345 Oshawa Boulevard','','Tokyo-to',204,'32114','104491201771',0x000000000101000000FB5E9E29CF6C61404BFCF61A27D64140,'2014-09-25 22:31:45'),
+(199,'1792 Valle de la Pascua Place','','Nordrhein-Westfalen',477,'15540','419419591240',0x000000000101000000E9BD8CBD720C204056725F18FA6F4940,'2014-09-25 22:31:06'),
+(200,'1074 Binzhou Manor','','Baden-Wrttemberg',325,'36490','331132568928',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:05'),
+(201,'817 Bradford Loop','','Jiangsu',109,'89459','264286442804',0x000000000101000000C3E1BB830EFD5D4006B243A10AC63F40,'2014-09-25 22:30:31'),
+(202,'955 Bamenda Way','','Ondo & Ekiti',218,'1545','768481779568',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:24'),
+(203,'1149 A Corua (La Corua) Boulevard','','Haiphong',194,'95824','470884141195',0x0000000001010000007573F1B7BDAB5A4050A0997164DD3440,'2014-09-25 22:34:06'),
+(204,'387 Mwene-Ditu Drive','','Ahal',35,'8073','764477681869',0x000000000101000000B0253F3D11314D40A538A2D68FFA4240,'2014-09-25 22:33:30'),
+(205,'68 Molodetno Manor','','Nordrhein-Westfalen',575,'4662','146640639760',0x000000000101000000EEF3739E0C691D40FE486CD2C8B84940,'2014-09-25 22:31:06'),
+(206,'642 Nador Drive','','Maharashtra',77,'3924','369050085652',0x000000000101000000559D7A4908F25240E010AAD4EC0B3540,'2014-09-25 22:31:13'),
+(207,'1688 Nador Lane','','Sulawesi Utara',184,'61613','652218196731',0x000000000101000000E358727044945E4093F139C148B9E83F,'2014-09-25 22:31:32'),
+(208,'1215 Pyongyang Parkway','','Usak',557,'25238','646237101779',0x000000000101000000019E59B7E6673D40735E08DE35564340,'2014-09-25 22:33:30'),
+(209,'1679 Antofagasta Street','','Alto Paran',122,'86599','905903574913',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:32'),
+(210,'1304 s-Hertogenbosch Way','','Santa Catarina',83,'10925','90336226227',0x000000000101000000BDEAB765768848C05755D40561EB3AC0,'2014-09-25 22:30:16'),
+(211,'850 Salala Loop','','Kitaa',371,'10800','403404780639',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:07'),
+(212,'624 Oshawa Boulevard','','West Bengali',51,'89959','49677664184',0x0000000001010000000FBCB5A7BF315640EA7CD34F93383940,'2014-09-25 22:31:11'),
+(213,'43 Dadu Avenue','','Rajasthan',74,'4855','95666951770',0x000000000101000000BCF957A0A7A852404046E5CBB0583940,'2014-09-25 22:31:12'),
+(214,'751 Lima Loop','','Aden',7,'99405','756460337785',0x0000000001010000005ECF21BAB1844640A9007388138F2940,'2014-09-25 22:34:08'),
+(215,'1333 Haldia Street','','Jilin',174,'82161','408304391718',0x00000000010100000007A51E5844345F404CE71E6D77974640,'2014-09-25 22:30:33'),
+(216,'660 Jedda Boulevard','','Washington',65,'25053','168758068397',0x00000000010100000009EEF60FD88C5EC03C331C2A21CE4740,'2014-09-25 22:33:45'),
+(217,'1001 Miyakonojo Lane','','Taizz',518,'67924','584316724815',0x0000000001010000006642DD51AD024640782C1103B8282B40,'2014-09-25 22:34:11'),
+(218,'226 Brest Manor','','California',508,'2299','785881412500',0x000000000101000000CF9F36AA53825EC0B54D96FF35AF4240,'2014-09-25 22:34:02'),
+(219,'1229 Valencia Parkway','','Haskovo',498,'99124','352679173732',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:24'),
+(220,'1201 Qomsheh Manor','','Gois',28,'21464','873492228462',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:15'),
+(221,'866 Shivapuri Manor','','Uttar Pradesh',448,'22474','778502731092',0x000000000101000000940BDF0C48A4534072648ADE4E953C40,'2014-09-25 22:31:26'),
+(222,'1168 Najafabad Parkway','','Kabol',251,'40301','886649065861',0x0000000001010000009173AC9C074B51408EBDCDD199434140,'2014-09-25 22:29:59'),
+(223,'1244 Allappuzha (Alleppey) Place','','Buenos Aires',567,'20657','991802825778',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:08'),
+(224,'1842 Luzinia Boulevard','','Zanzibar West',593,'94420','706878974831',0x00000000010100000045E169E855994340B62C5F97E1A718C0,'2014-09-25 22:33:19'),
+(225,'1926 Gingoog Street','','Sisilia',511,'22824','469738825391',0x0000000001010000004DD9E907758D2E40719AF4ADC58A4240,'2014-09-25 22:31:44'),
+(226,'810 Palghat (Palakkad) Boulevard','','Jaroslavl',235,'73431','516331171356',0x00000000010100000069D48DC1D4EF43400294D0A79FD04C40,'2014-09-25 22:32:49'),
+(227,'1820 Maring Parkway','','Punjab',324,'88307','99760893676',0x0000000001010000001E053EF5FE5E52406C617193AC4A4040,'2014-09-25 22:32:30'),
+(228,'60 Poos de Caldas Street','','Rajasthan',243,'82338','963063788669',0x00000000010100000069EED7536140524079605B9AB6443A40,'2014-09-25 22:31:18'),
+(229,'1014 Loja Manor','','Tamil Nadu',22,'66851','460795526514',0x000000000101000000803E366E560A5440A1212DDF44322A40,'2014-09-25 22:31:10'),
+(230,'201 Effon-Alaiye Way','','Asuncin',37,'64344','684192903087',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:31'),
+(231,'430 Alessandria Loop','','Saarland',439,'47446','669828224459',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:06'),
+(232,'754 Valencia Place','','Phnom Penh',406,'87911','594319417514',0x0000000001010000009093D3E89F3A5A40AACCDE63FA1F2740,'2014-09-25 22:30:25'),
+(233,'356 Olomouc Manor','','Gois',26,'93323','22326410776',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:15'),
+(234,'1256 Bislig Boulevard','','Botosani',86,'50598','479007229460',0x00000000010100000085059C4AABAA3A408DAC46C032E04740,'2014-09-25 22:32:46'),
+(235,'954 Kimchon Place','','West Bengali',559,'42420','541327526474',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:28'),
+(236,'885 Yingkou Manor','','Kaduna',596,'31390','588964509072',0x00000000010100000006CF296D16E41E4038E3EAB6FA382640,'2014-09-25 22:32:28'),
+(237,'1736 Cavite Place','','Qina',216,'98775','431770603551',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(238,'346 Skikda Parkway','','Hawalli',233,'90628','630424482919',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:57'),
+(239,'98 Stara Zagora Boulevard','','Valle',96,'76448','610173756082',0x00000000010100000084CD4AA4FE4153C0DB9953138E0A0F40,'2014-09-25 22:30:51'),
+(240,'1479 Rustenburg Boulevard','','Southern Tagalog',527,'18727','727785483194',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:40'),
+(241,'647 A Corua (La Corua) Street','','Chollanam',357,'36971','792557457753',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(242,'1964 Gijn Manor','','Karnataka',473,'14408','918119601885',0x000000000101000000BBC3DCA458E45240DA4246F6F7DC2B40,'2014-09-25 22:31:26'),
+(243,'47 Syktyvkar Lane','','West Java',118,'22236','63937119031',0x000000000101000000EDABBC2E8DB05A40C3C1397E037E1AC0,'2014-09-25 22:31:31'),
+(244,'1148 Saarbrcken Parkway','','Fukushima',226,'1921','137773001988',0x000000000101000000AD8ACB4C449C614053F8229001874240,'2014-09-25 22:31:47'),
+(245,'1103 Bilbays Parkway','','Hubei',578,'87660','279979529227',0x000000000101000000A76ED34444095C401234C1CB67054040,'2014-09-25 22:30:45'),
+(246,'1246 Boksburg Parkway','','Hebei',422,'28349','890283544295',0x000000000101000000B66A323EA7E55D40E508BE0E41F74340,'2014-09-25 22:30:41'),
+(247,'1483 Pathankot Street','','Tucumn',454,'37288','686015532180',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:06'),
+(248,'582 Papeete Loop','','Central Visayas',294,'27722','569868543137',0x0000000001010000001F189BB1C3FC5E407DC4F9E5DD9E2440,'2014-09-25 22:32:38'),
+(249,'300 Junan Street','','Kyonggi',553,'81314','890289150158',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(250,'829 Grand Prairie Way','','Paran',328,'6461','741070712873',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:20'),
+(251,'1473 Changhwa Parkway','','Mxico',124,'75933','266798132374',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:03'),
+(252,'1309 Weifang Street','','Florida',520,'57338','435785045362',0x000000000101000000EC0CF8A1F71155C0995A006432703E40,'2014-09-25 22:34:02'),
+(253,'1760 Oshawa Manor','','Tianjin',535,'38140','56257502250',0x000000000101000000FBBD5EAB4E4B5D40EB0A6C8434924340,'2014-09-25 22:30:43'),
+(254,'786 Stara Zagora Way','','Oyo & Osun',390,'98332','716256596301',0x000000000101000000DB45E22F77770F4073C8BC44AB691F40,'2014-09-25 22:32:27'),
+(255,'1966 Tonghae Street','','Anhalt Sachsen',198,'36481','567359279425',0x0000000001010000000000009825D59D41450A0A2879C84940,'2014-09-25 22:31:05'),
+(256,'1497 Yuzhou Drive','','England',312,'3433','246810237916',0x000000000101000000CC4642B68718C0BFCA822E8617C14940,'2014-09-25 22:33:37'),
+(258,'752 Ondo Loop','','Miyazaki',338,'32474','134673576619',0x00000000010100000048AD8B36226260408871EDFABBBB3F40,'2014-09-25 22:31:50'),
+(259,'1338 Zalantun Lane','','Minas Gerais',413,'45403','840522972766',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(260,'127 Iwakuni Boulevard','','Central Luzon',192,'20777','987442542471',0x0000000001010000000E6954E0E42E5E40AF05627E13AB2D40,'2014-09-25 22:32:37'),
+(261,'51 Laredo Avenue','','Sagaing',342,'68146','884536620568',0x0000000001010000008720BD97B1C85740D4D7F335CB1B3640,'2014-09-25 22:32:18'),
+(262,'771 Yaound Manor','','Sofala',64,'86768','245477603573',0x000000000101000000103345CA606B414046CB2665F7D733C0,'2014-09-25 22:32:17'),
+(263,'532 Toulon Street','','Santiago',460,'69517','46871694740',0x000000000101000000ECD33B269CAC51C09AB67F65A5733340,'2014-09-25 22:30:55'),
+(264,'1027 Banjul Place','','West Bengali',197,'50390','538241037443',0x000000000101000000FE14223BCA1A5640AC6F6072A3EE3640,'2014-09-25 22:31:16'),
+(265,'1158 Mandi Bahauddin Parkway','','Shanxi',136,'98484','276555730211',0x000000000101000000ECC84741A6525C40A93C7084FB0B4440,'2014-09-25 22:30:32'),
+(266,'862 Xintai Lane','','Cagayan Valley',548,'30065','265153400632',0x00000000010100000015580053866E5E408A5CCBBFF19C3140,'2014-09-25 22:32:41'),
+(267,'816 Cayenne Parkway','','Manab',414,'93629','282874611748',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(268,'1831 Nam Dinh Loop','','National Capital Reg',323,'51990','322888976727',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:38'),
+(269,'446 Kirovo-Tepetsk Lane','','Osaka',203,'19428','303967439816',0x0000000001010000008D94D2D8C3F36040608CED5AE7554140,'2014-09-25 22:31:45'),
+(270,'682 Halisahar Place','','Severn Morava',378,'20536','475553436330',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:54'),
+(271,'1587 Loja Manor','','Salzburg',447,'5410','621625204422',0x0000000001010000002C83C53C86162A405886DD1C53E64740,'2014-09-25 22:30:10'),
+(272,'1762 Paarl Parkway','','Hunan',298,'53928','192459639410',0x00000000010100000067333D177CDB5B40DBA8A9C024B03B40,'2014-09-25 22:30:39'),
+(273,'1519 Ilorin Place','','Kerala',395,'49298','357445645426',0x0000000001010000000C4FF921002A5340BD772F52838C2540,'2014-09-25 22:31:21'),
+(274,'920 Kumbakonam Loop','','California',446,'75090','685010736240',0x00000000010100000012EF4ADCF4695EC01B95E535C0564240,'2014-09-25 22:34:00'),
+(275,'906 Goinia Way','','Wielkopolskie',255,'83565','701767622697',0x0000000001010000007FA2B2614D1732404064366D6BE14940,'2014-09-25 22:32:42'),
+(276,'1675 Xiangfan Manor','','Tamil Nadu',283,'11763','271149517630',0x00000000010100000042B687180AD95340EE4108C897EC2540,'2014-09-25 22:31:20'),
+(277,'85 San Felipe de Puerto Plata Drive','','Shandong',584,'46063','170739645687',0x000000000101000000EA605859365C5E40EF1010DDFDBC4240,'2014-09-25 22:30:48'),
+(278,'144 South Hill Loop','','Guanajuato',445,'2012','45387294817',0x0000000001010000002B84D558424C59C0699B2CFF6B923440,'2014-09-25 22:32:11'),
+(279,'1884 Shikarpur Avenue','','Haryana',263,'85548','959949395183',0x0000000001010000002CE395DA413F5340EB460EC7A9B03D40,'2014-09-25 22:31:19'),
+(280,'1980 Kamjanets-Podilskyi Street','','Illinois',404,'89502','874337098891',0x000000000101000000167CE420B26556C0B7966EB7C9584440,'2014-09-25 22:33:57'),
+(281,'1944 Bamenda Way','','Michigan',573,'24645','75975221996',0x000000000101000000B8B64B76C7C154C0EF254344203D4540,'2014-09-25 22:34:03'),
+(282,'556 Baybay Manor','','Oyo & Osun',374,'55802','363982224739',0x000000000101000000F5C6FFD3C30E1140FC30E7BE41502040,'2014-09-25 22:32:25'),
+(283,'457 Tongliao Loop','','Bursa',222,'56254','880756161823',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:25'),
+(284,'600 Bradford Street','','East Azerbaidzan',514,'96204','117592274996',0x000000000101000000EE4E2D115E25474044FF5FD09D0A4340,'2014-09-25 22:31:40'),
+(285,'1006 Santa Brbara dOeste Manor','','Ondo & Ekiti',389,'36229','85059738746',0x000000000101000000FBC67CE5E6581640531A7B40EAC81C40,'2014-09-25 22:32:26'),
+(286,'1308 Sumy Loop','','Fujian',175,'30657','583021225407',0x000000000101000000DC7AF25597D35D409617AAACB70F3A40,'2014-09-25 22:30:34'),
+(287,'1405 Chisinau Place','','Ponce',411,'8160','62781725285',0x000000000101000000974341DF4CA750C03F219628D6023240,'2014-09-25 22:32:45'),
+(288,'226 Halifax Street','','Xinxiang',277,'58492','790651020929',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:38'),
+(289,'1279 Udine Parkway','','Edo & Delta',69,'75860','195003555232',0x000000000101000000FFB7EDD68D8216408FF4B3A217571940,'2014-09-25 22:32:23'),
+(290,'1336 Benin City Drive','','Shiga',386,'46044','341242939532',0x000000000101000000D5810761C9FB60401B07A8BA91804140,'2014-09-25 22:31:53'),
+(291,'1155 Liaocheng Place','','Oyo & Osun',152,'22650','558236142492',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:23'),
+(292,'1993 Tabuk Lane','','Tamil Nadu',522,'64221','648482415405',0x0000000001010000002AF3A0EA210854407F94C78965D92940,'2014-09-25 22:31:27'),
+(293,'86 Higashiosaka Lane','','Guanajuato',563,'33768','957128697225',0x0000000001010000002DAF5C6F1B4C59C07F34F7EBA9643440,'2014-09-25 22:32:14'),
+(294,'1912 Allende Manor','','Kowloon and New Kowl',279,'58124','172262454487',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:09'),
+(295,'544 Tarsus Boulevard','','Gurico',562,'53145','892523334',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:05'),
+(296,'1936 Cuman Avenue','','Virginia',433,'61195','976798660411',0x000000000101000000FD7B3A6840FC53C065F4ED6EAFA24240,'2014-09-25 22:33:58'),
+(297,'1192 Tongliao Street','','Sharja',470,'19065','350970907017',0x000000000101000000AA27F38FBEB44B4053E68B625E563940,'2014-09-25 22:33:35'),
+(298,'44 Najafabad Way','','Baskimaa',146,'61391','96604821070',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:08'),
+(299,'32 Pudukkottai Lane','','Ohio',140,'38834','967274728547',0x000000000101000000077AA86D430C55C0409C2C5A25E14340,'2014-09-25 22:33:49'),
+(300,'661 Chisinau Lane','','Pietari',274,'8856','816436065431',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:51'),
+(301,'951 Stara Zagora Manor','','Punjab',400,'98573','429925609431',0x0000000001010000001E296C50C51953405651723DC0533E40,'2014-09-25 22:31:22'),
+(302,'922 Vila Velha Loop','','Maharashtra',9,'4085','510737228015',0x000000000101000000738F5B8242AF5240612129D835183340,'2014-09-25 22:31:10'),
+(303,'898 Jining Lane','','Pohjois-Pohjanmaa',387,'40070','161643343536',0x0000000001010000003DFB80F6D9773940C8D0B183CA405040,'2014-09-25 22:31:00'),
+(304,'1635 Kuwana Boulevard','','Hiroshima',205,'52137','710603868323',0x000000000101000000AA944330B38E6040247035FCB8324140,'2014-09-25 22:31:46'),
+(305,'41 El Alto Parkway','','Maharashtra',398,'56883','51917807050',0x000000000101000000D487E41A55315340BC3088FEBF443340,'2014-09-25 22:31:22'),
+(306,'1883 Maikop Lane','','Kaliningrad',254,'68469','96110042435',0x00000000010100000020DF94A8CD82344015D918856E5A4B40,'2014-09-25 22:32:50'),
+(307,'1908 Gaziantep Place','','Liaoning',536,'58979','108053751300',0x0000000001010000004DAA6C0EC6E65E408E9F7C30DF344540,'2014-09-25 22:30:43'),
+(308,'687 Alessandria Parkway','','Sanaa',455,'57587','407218522294',0x0000000001010000000C60257A741A4640854A123A9EB52E40,'2014-09-25 22:34:10'),
+(309,'827 Yuncheng Drive','','Callao',99,'79047','504434452842',0x000000000101000000C2514DA48F4753C0271CD544FA1C28C0,'2014-09-25 22:32:32'),
+(310,'913 Coacalco de Berriozbal Loop','','Texas',33,'42141','262088367001',0x00000000010100000023371EC7EA4658C0A86851442B5E4040,'2014-09-25 22:33:43'),
+(311,'715 So Bernardo do Campo Lane','','Kedah',507,'84804','181179321332',0x000000000101000000D8DBC1E3361F5940520DFB3DB1961640,'2014-09-25 22:32:00'),
+(312,'1354 Siegen Street','','Rio de Janeiro',25,'80184','573441801529',0x0000000001010000009146054EB62846C0FCA0D398B50137C0,'2014-09-25 22:30:15'),
+(313,'1191 Sungai Petani Boulevard','','Missouri',262,'9668','983259819766',0x00000000010100000055890D7107A557C0CB7564F6C38C4340,'2014-09-25 22:33:54'),
+(314,'1224 Huejutla de Reyes Boulevard','','Lombardia',91,'70923','806016930576',0x000000000101000000D85B6F40F06D24405EEE38EA8DC44640,'2014-09-25 22:31:43'),
+(315,'543 Bergamo Avenue','','Minas Gerais',215,'59686','103602195112',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(316,'746 Joliet Lane','','Kursk',286,'94878','688485191923',0x00000000010100000085949F54FB174240E0DCBAF660DE4940,'2014-09-25 22:32:52'),
+(317,'780 Kimberley Way','','Tabuk',515,'17032','824396883951',0x0000000001010000001BD47E6B274942408B53AD8559663C40,'2014-09-25 22:33:00'),
+(318,'1774 Yaound Place','','Hubei',166,'91400','613124286867',0x0000000001010000002A00C633E8B15C404C63C5BA027D3E40,'2014-09-25 22:30:33'),
+(319,'1957 Yantai Lane','','So Paulo',490,'59255','704948322302',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(320,'1542 Lubumbashi Boulevard','','Tel Aviv',57,'62472','508800331065',0x000000000101000000765F84DF3C6041403CAB60AF0B034040,'2014-09-25 22:31:41'),
+(321,'651 Pathankot Loop','','Maharashtra',336,'59811','139378397418',0x0000000001010000002198FE8062A952408AC168FBFCD23040,'2014-09-25 22:31:20'),
+(322,'1359 Zhoushan Parkway','','Streymoyar',545,'29763','46568045367',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:59'),
+(323,'1769 Iwaki Lane','','Kujawsko-Pomorskie',97,'25787','556100547674',0x000000000101000000487B7203F4013240837EF0EBD18F4A40,'2014-09-25 22:32:41'),
+(324,'1145 Vilnius Manor','','Mxico',451,'73170','674805712553',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:12'),
+(325,'1892 Nabereznyje Telny Lane','','Tutuila',516,'28396','478229987054',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:02'),
+(326,'470 Boksburg Street','','Central',81,'97960','908029859266',0x000000000101000000DAE78C83263855405BE21291AB023B40,'2014-09-25 22:32:19'),
+(327,'1427 A Corua (La Corua) Place','','Buenos Aires',45,'85799','972574862516',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:04'),
+(328,'479 San Felipe del Progreso Avenue','','Morelos',130,'54949','869051782691',0x000000000101000000C87E710484BC58C039FD8F02FACD3240,'2014-09-25 22:32:04'),
+(329,'867 Benin City Avenue','','Henan',591,'78543','168884817145',0x000000000101000000A0F2F972B05D5C405D68531AD6144140,'2014-09-25 22:30:50'),
+(330,'981 Kumbakonam Place','','Distrito Federal',89,'87611','829116184079',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:17'),
+(331,'1016 Iwakuni Street','','St George',269,'49833','961370847344',0x000000000101000000A1DC11A9C49C4EC0D11B936A44512A40,'2014-09-25 22:32:59'),
+(332,'663 Baha Blanca Parkway','','Adana',5,'33463','834418779292',0x000000000101000000BE72182719AA4140CCD1E3F736804240,'2014-09-25 22:33:22'),
+(333,'1860 Taguig Loop','','West Java',119,'59550','38158430589',0x00000000010100000042ACA34FD0E55A40D698C6E52ED81BC0,'2014-09-25 22:31:32'),
+(334,'1816 Bydgoszcz Loop','','Dhaka',234,'64308','965273813662',0x000000000101000000A717C627AE7C564080BD1D3C6EEB3840,'2014-09-25 22:30:12'),
+(335,'587 Benguela Manor','','Illinois',42,'91590','165450987037',0x00000000010100000097CEE2207C1456C0DDEFABCD5AE14440,'2014-09-25 22:33:44'),
+(336,'430 Kumbakonam Drive','','Santa F',457,'28814','105470691550',0x00000000010100000004C1882249304DC055DF54FF7B4E41C0,'2014-09-25 22:30:07'),
+(337,'1838 Tabriz Lane','','Dhaka',143,'1195','38988715447',0x0000000001010000001A5D948F139A5640C4D21B49DDB53740,'2014-09-25 22:30:12'),
+(338,'431 Szkesfehrvr Avenue','','Baki',48,'57828','119501405123',0x000000000101000000A77686A92DF248400FAECACF57304440,'2014-09-25 22:30:11'),
+(339,'503 Sogamoso Loop','','Sumqayit',505,'49812','834626715837',0x0000000001010000006C83C94395D548402C8EB9217C4B4440,'2014-09-25 22:30:11'),
+(340,'507 Smolensk Loop','','Sousse',492,'22971','80303246192',0x000000000101000000298EA8F52346254075DA649EA6E94140,'2014-09-25 22:33:21'),
+(341,'1920 Weifang Avenue','','Uttar Pradesh',427,'15643','869507847714',0x0000000001010000001F3EFA70DAC153407410CF6D1DCF3C40,'2014-09-25 22:31:25'),
+(342,'124 al-Manama Way','','Hiroshima',382,'52368','647899404952',0x0000000001010000004BE07B244AA760407B0ED18D55354140,'2014-09-25 22:31:52'),
+(343,'1443 Mardan Street','','Western Cape',392,'31483','231383037471',0x000000000101000000FB6074D42CF73240B0B03B3833DA40C0,'2014-09-25 22:33:05'),
+(344,'1909 Benguela Lane','','Henan',581,'19913','624138001031',0x000000000101000000F4AD6AA480775C4066EB2AEE89A74140,'2014-09-25 22:30:47'),
+(345,'68 Ponce Parkway','','Hanoi',201,'85926','870635127812',0x0000000001010000005DF525C0D5755A4000F61B3746063540,'2014-09-25 22:34:06'),
+(346,'1217 Konotop Avenue','','Gelderland',151,'504','718917251754',0x000000000101000000F438679F22A2164019B4EB3944044A40,'2014-09-25 22:32:20'),
+(347,'1293 Nam Dinh Way','','Roraima',84,'71583','697656479977',0x0000000001010000008EE6C8CA2F564EC0D9C23DE0CB8E0640,'2014-09-25 22:30:17'),
+(348,'785 Vaduz Street','','Baja California',335,'36170','895616862749',0x0000000001010000000D61EB0816DD5CC07DB328475C504040,'2014-09-25 22:32:10'),
+(349,'1516 Escobar Drive','','Tongatapu',370,'46069','64536069371',0x0000000001010000009132987575E665C0BE11DDB3AE2335C0,'2014-09-25 22:33:20'),
+(350,'1628 Nagareyama Lane','','Central',453,'60079','20064292617',0x00000000010100000019A5F04520C14CC029006B7AF55639C0,'2014-09-25 22:32:32'),
+(351,'1157 Nyeri Loop','','Adygea',320,'56380','262744791493',0x000000000101000000AC91B8228C0D4440EBD10AC2CB4D4640,'2014-09-25 22:32:55'),
+(352,'1673 Tangail Drive','','Daugavpils',137,'26857','627924259271',0x0000000001010000004377A45588883A40E580B80611F14B40,'2014-09-25 22:31:57'),
+(353,'381 Kabul Way','','Taipei',209,'87272','55477302294',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(354,'953 Hodeida Street','','Southern Tagalog',221,'18841','53912826864',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:37'),
+(355,'469 Nakhon Sawan Street','','Tuvassia',531,'58866','689199636560',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:58'),
+(356,'1378 Beira Loop','','Krasnojarsk',597,'40792','840957664136',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:58'),
+(357,'1641 Changhwa Place','','Nord-Ouest',52,'37636','256546485220',0x000000000101000000103B53E8BC4A2440A4C0A7DEBFD61740,'2014-09-25 22:30:25'),
+(358,'1698 Southport Loop','','Hidalgo',393,'49009','754358349853',0x0000000001010000007AB82E46EEAE58C03DED951EF21D3440,'2014-09-25 22:32:11'),
+(359,'519 Nyeri Manor','','So Paulo',461,'37650','764680915323',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:21'),
+(360,'619 Hunuco Avenue','','Shimane',331,'81508','142596392389',0x000000000101000000A09ADC399EA160405B1D4AFE71BC4140,'2014-09-25 22:31:50'),
+(361,'45 Aparecida de Goinia Place','','Madhya Pradesh',464,'7431','650496654258',0x0000000001010000009E0CE94BCA345440C9FDB38B0E953840,'2014-09-25 22:31:26'),
+(362,'482 Kowloon and New Kowloon Manor','','Bratislava',90,'97056','738968474939',0x00000000010100000070DC18F1531B3140BDB90908F7124840,'2014-09-25 22:33:02'),
+(363,'604 Bern Place','','Jharkhand',429,'5373','620719383725',0x000000000101000000799F9916AB55554037CC86EB07593740,'2014-09-25 22:31:25'),
+(364,'1623 Kingstown Drive','','Buenos Aires',20,'91299','296394569728',0x000000000101000000791563AAAA2A4DC0E4839ECDAA6A41C0,'2014-09-25 22:30:04'),
+(365,'1009 Zanzibar Lane','','Arecibo',32,'64875','102396298916',0x000000000101000000FBBD5EABCEAD50C0E9787187F2783240,'2014-09-25 22:32:45'),
+(366,'114 Jalib al-Shuyukh Manor','','Centre',585,'60440','845378657301',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:25'),
+(367,'1163 London Parkway','','Par',66,'6066','675120358494',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:16'),
+(368,'1658 Jastrzebie-Zdrj Loop','','Central',372,'96584','568367775448',0x0000000001010000002B73A900CEEF4240660811BA956FB9BF,'2014-09-25 22:31:56'),
+(369,'817 Laredo Avenue','','Jalisco',188,'77449','151249681135',0x000000000101000000F00BF9B113D959C03E4EE2BDB4AA3440,'2014-09-25 22:32:06'),
+(370,'1565 Tangail Manor','','Okinawa',377,'45750','634445428822',0x000000000101000000D94C744CCCAA5F4045A1C096B2C53940,'2014-09-25 22:31:52'),
+(371,'1912 Emeishan Drive','','Balikesir',50,'33050','99883471275',0x000000000101000000F1074D5CD8E23B400B2A053818D34340,'2014-09-25 22:33:22'),
+(372,'230 Urawa Drive','','Andhra Pradesh',8,'2738','166898395731',0x0000000001010000008B04AE869F515340B2930BDF0C402F40,'2014-09-25 22:31:09'),
+(373,'1922 Miraj Way','','Esfahan',356,'13203','320471479776',0x00000000010100000017050B71F6AE494026231DD434514040,'2014-09-25 22:31:37'),
+(374,'433 Florencia Street','','Chihuahua',250,'91330','561729882725',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:08'),
+(375,'1049 Matamoros Parkway','','Karnataka',191,'69640','960505250340',0x0000000001010000007923F3C89F355340386744696F563140,'2014-09-25 22:31:16'),
+(376,'1061 Ede Avenue','','Southern Tagalog',98,'57810','333390595558',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:35'),
+(377,'154 Oshawa Manor','','East Java',415,'72771','440365973660',0x00000000010100000005B93077D24D5C4065074B2B74041FC0,'2014-09-25 22:31:34'),
+(378,'1191 Tandil Drive','','Southern Tagalog',523,'6362','45554316010',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:40'),
+(379,'1133 Rizhao Avenue','','Pernambuco',572,'2800','600264533987',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:23'),
+(380,'1519 Santiago de los Caballeros Loop','','East Kasai',348,'22025','409315295763',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(381,'1618 Olomouc Manor','','Kurgan',285,'26385','96846695220',0x000000000101000000B1694A5755555040EA8FD552E5B94B40,'2014-09-25 22:32:51'),
+(382,'220 Hidalgo Drive','','Kermanshah',265,'45298','342720754566',0x0000000001010000004E7A843F6888474008605EDB36284140,'2014-09-25 22:31:37'),
+(383,'686 Donostia-San Sebastin Lane','','Guangdong',471,'97390','71857599858',0x000000000101000000F90A1C1A60845C400FDB711EA98B3640,'2014-09-25 22:30:42'),
+(384,'97 Mogiljov Lane','','Gujarat',73,'89294','924815207181',0x000000000101000000B4F116FEC209524097DB076A42C63540,'2014-09-25 22:31:11'),
+(385,'1642 Charlotte Amalie Drive','','Slaskie',549,'75442','821476736117',0x000000000101000000DDC4DA2967F73240D5D6E3198F114940,'2014-09-25 22:32:44'),
+(386,'1368 Maracabo Boulevard','','',493,'32716','934352415130',0x000000000101000000731074B4AA8A4FC050920953EF2E3240,'2014-09-25 22:30:03'),
+(387,'401 Sucre Boulevard','','New Hampshire',322,'25007','486395999608',0x000000000101000000817FA54E1BDD51C013718456717F4540,'2014-09-25 22:33:56'),
+(388,'368 Hunuco Boulevard','','Namibe',360,'17165','106439158941',0x000000000101000000B5858CECEF4D28404D8EF11769642EC0,'2014-09-25 22:30:03'),
+(389,'500 Lincoln Parkway','','Jiangsu',210,'95509','550306965159',0x0000000001010000003C399E2A3AC15D404409449957CB4040,'2014-09-25 22:30:35'),
+(390,'102 Chapra Drive','','Ibaragi',521,'14073','776031833752',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:54'),
+(391,'1793 Meixian Place','','Hmelnytskyi',258,'33535','619966287415',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:31'),
+(392,'514 Ife Way','','Shaba',315,'69973','900235712074',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(393,'717 Changzhou Lane','','Southern Tagalog',104,'21615','426255288071',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:36'),
+(394,'753 Ilorin Avenue','','Sichuan',157,'3656','464511145118',0x0000000001010000008531D8C3CDD8594059D70D805D883D40,'2014-09-25 22:30:32'),
+(395,'1337 Mit Ghamr Avenue','','Nakhon Sawan',358,'29810','175283210378',0x0000000001010000009A588572C70859404D237722D2682F40,'2014-09-25 22:33:19'),
+(396,'767 Pyongyang Drive','','Osaka',229,'83536','667736124769',0x000000000101000000149A7F4FC7EA6040A02413A6DE2F4140,'2014-09-25 22:31:48'),
+(397,'614 Pak Kret Street','','Addis Abeba',6,'27796','47808359842',0x0000000001010000009F84E3439A5F43402233BCFEC90C2240,'2014-09-25 22:30:59'),
+(398,'954 Lapu-Lapu Way','','Moskova',278,'8816','737229003916',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:51'),
+(399,'331 Bydgoszcz Parkway','','Asturia',181,'966','537374465982',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:09'),
+(400,'1152 Citrus Heights Manor','','al-Qadarif',15,'5239','765957414528',0x00000000010100000084F6459D14B14140AA36EE83E2112C40,'2014-09-25 22:33:11'),
+(401,'168 Cianjur Manor','','Saitama',228,'73824','679095087143',0x000000000101000000DEA925C2EB75614032005471E3F94140,'2014-09-25 22:31:48'),
+(402,'616 Hagonoy Avenue','','Krasnojarsk',39,'46043','604177838256',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(403,'1190 0 Place','','Rio Grande do Sul',44,'10417','841876514789',0x0000000001010000002347DF49B00D4BC086151340D6543FC0,'2014-09-25 22:30:16'),
+(404,'734 Bchar Place','','Punjab',375,'30586','280578750435',0x0000000001010000006D3B6D8D885C5240C4A40925DDCE3E40,'2014-09-25 22:32:31'),
+(405,'530 Lausanne Lane','','Texas',135,'11067','775235029633',0x0000000001010000009C830C89A03358C0E2D3F7753B644040,'2014-09-25 22:33:49'),
+(406,'454 Patiala Lane','','Fukushima',276,'13496','794553031307',0x000000000101000000EC3D4B46448C614091306711E5BB4240,'2014-09-25 22:31:49'),
+(407,'1346 Mysore Drive','','Bretagne',92,'61507','516647474029',0x0000000001010000004474BE8EEEEE11C070010DDBBB3F4840,'2014-09-25 22:31:00'),
+(408,'990 Etawah Loop','','Tamil Nadu',564,'79940','206169448769',0x000000000101000000D54B42D8DF3C5340FE518A0C61A72440,'2014-09-25 22:31:29'),
+(409,'1266 Laredo Parkway','','Saitama',380,'7664','1483365694',0x000000000101000000FBD97EE8F87361403BA5283C0DF44140,'2014-09-25 22:31:52'),
+(410,'88 Nagaon Manor','','Buenos Aires',524,'86868','779461480495',0x000000000101000000CA3736960B914DC0D78A91802CA942C0,'2014-09-25 22:30:07'),
+(411,'264 Bhimavaram Manor','','St Thomas',111,'54749','302526949177',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:08'),
+(412,'1639 Saarbrcken Drive','','North West',437,'9827','328494873422',0x00000000010100000015CB8866F93D3B40E48AE65CE5AA39C0,'2014-09-25 22:33:05'),
+(413,'692 Amroha Drive','','Northern',230,'35575','359478883004',0x00000000010100000027648CB47900544098E777503F562340,'2014-09-25 22:33:10'),
+(414,'1936 Lapu-Lapu Parkway','','Bauchi & Gombe',141,'7122','653436985797',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:23'),
+(415,'432 Garden Grove Street','','Ontario',430,'65630','615964523510',0x0000000001010000003E867DF1FBDB53C05900AEBF80EF4540,'2014-09-25 22:30:28'),
+(416,'1445 Carmen Parkway','','West Java',117,'70809','598912394463',0x000000000101000000957950F550C55A40B3BFA21122171BC0,'2014-09-25 22:31:30'),
+(417,'791 Salinas Street','','Punjab',208,'40509','129953030512',0x000000000101000000579E9B911CFA524075D256804A883F40,'2014-09-25 22:31:17'),
+(418,'126 Acua Parkway','','West Bengali',71,'58888','480039662421',0x000000000101000000C3013E89191056404E9F7829D01A3840,'2014-09-25 22:31:11'),
+(419,'397 Sunnyvale Avenue','','Guanajuato',19,'55566','680851640676',0x000000000101000000754419059C2F59C02409C21550EA3440,'2014-09-25 22:32:01'),
+(420,'992 Klerksdorp Loop','','Utrecht',23,'33711','855290087237',0x000000000101000000C1DFD4ACD88C15404FDC3BB4D9134A40,'2014-09-25 22:32:19'),
+(421,'966 Arecibo Loop','','Sind',134,'94018','15273765306',0x000000000101000000BE9B1320AFF15040D93400659DBB3A40,'2014-09-25 22:32:30'),
+(422,'289 Santo Andr Manor','','al-Sharqiya',16,'72410','214976066017',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:59'),
+(423,'437 Chungho Drive','','Puerto Plata',450,'59489','491271355190',0x000000000101000000225A86930FAC51C0082692431FCB3340,'2014-09-25 22:30:55'),
+(424,'1948 Bayugan Parkway','','Bihar',264,'60622','987306329957',0x0000000001010000007613211A82E45540D685C4E2DC893940,'2014-09-25 22:31:19'),
+(425,'1866 al-Qatif Avenue','','California',155,'89420','546793516940',0x000000000101000000B4EE7AC4C3815DC0165D28AAC8084140,'2014-09-25 22:33:50'),
+(426,'1661 Abha Drive','','Tamil Nadu',416,'14400','270456873752',0x000000000101000000D3B36A2192B45340FBC5111038C32440,'2014-09-25 22:31:23'),
+(427,'1557 Cape Coral Parkway','','Hubei',293,'46875','368284120423',0x00000000010100000034CC1A06BDEA5B402D5A25FD62314040,'2014-09-25 22:30:38'),
+(428,'1727 Matamoros Place','','Sawhaj',465,'78813','129673677866',0x00000000010100000083E38D27DDB13F40555BA093948E3A40,'2014-09-25 22:30:57'),
+(429,'1269 Botosani Manor','','Guangdong',468,'47394','736517327853',0x000000000101000000C8E1DDDB3ED65C40281B20E230C83640,'2014-09-25 22:30:42'),
+(430,'355 Vitria de Santo Anto Way','','Oaxaca',452,'81758','548003849552',0x0000000001010000000363D8BC050858C0503750E09D163240,'2014-09-25 22:32:13'),
+(431,'1596 Acua Parkway','','Jharkhand',418,'70425','157133457169',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:24'),
+(432,'259 Ipoh Drive','','So Paulo',189,'64964','419009857119',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:18'),
+(433,'1823 Hoshiarpur Lane','','Komi',510,'33191','307133768620',0x000000000101000000C6DA8420AC674940DD9ACF1495D64E40,'2014-09-25 22:32:57'),
+(434,'1404 Taguig Drive','','Okayama',547,'87212','572068624538',0x000000000101000000205D11A1F6BF6040BFE90203AD864140,'2014-09-25 22:31:54'),
+(435,'740 Udaipur Lane','','Nizni Novgorod',150,'33505','497288595103',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:47'),
+(436,'287 Cuautla Boulevard','','Chuquisaca',501,'72736','82619513349',0x0000000001010000002A0B15D2D05050C049C44ABB870833C0,'2014-09-25 22:30:14'),
+(437,'1766 Almirante Brown Street','','KwaZulu-Natal',364,'63104','617567598243',0x000000000101000000FDAB7DF090EE3D40488D64EA09C23BC0,'2014-09-25 22:33:04'),
+(438,'596 Huixquilucan Place','','Nampula',351,'65892','342709348083',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:17'),
+(439,'1351 Aparecida de Goinia Parkway','','Northern Mindanao',391,'41775','959834530529',0x000000000101000000DAFF006B55F55E40898C58D5DC4F2040,'2014-09-25 22:32:38'),
+(440,'722 Bradford Lane','','Shandong',249,'90920','746251338300',0x000000000101000000653E7B890CB55D4078A0A932E7954140,'2014-09-25 22:30:37'),
+(441,'983 Santa F Way','','British Colombia',565,'47472','145720452260',0x000000000101000000719CCA58A3C75EC0EEE7B92AF59F4840,'2014-09-25 22:30:28'),
+(442,'1245 Ibirit Way','','La Romana',290,'40926','331888642162',0x0000000001010000006D59BE2E433E51C04FC87322666D3240,'2014-09-25 22:30:54'),
+(443,'1836 Korla Parkway','','Copperbelt',272,'55405','689681677428',0x000000000101000000064257C796363C40BB7EC16ED89A29C0,'2014-09-25 22:34:11'),
+(444,'231 Kaliningrad Place','','Lombardia',70,'57833','575081026569',0x0000000001010000007A185A9D9C552340A77E390E17D94640,'2014-09-25 22:31:42'),
+(445,'495 Bhimavaram Lane','','Maharashtra',144,'3','82088937724',0x0000000001010000003EE1911DC0B15240B39943520BE73440,'2014-09-25 22:31:15'),
+(446,'1924 Shimonoseki Drive','','Batna',59,'52625','406784385440',0x000000000101000000347CB03154B21840DF814B112AC74140,'2014-09-25 22:29:59'),
+(447,'105 Dzerzinsk Manor','','Inner Mongolia',540,'48570','240776414296',0x000000000101000000F1C05B7BFA905E40F5EC03DA67CE4540,'2014-09-25 22:30:44'),
+(448,'614 Denizli Parkway','','Rio Grande do Sul',486,'29444','876491807547',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(449,'1289 Belm Boulevard','','Tartumaa',530,'88306','237368926031',0x00000000010100000079680EFF9FB93A406C7E575FB8304D40,'2014-09-25 22:30:58'),
+(450,'203 Tambaram Street','','Buenos Aires',161,'73942','411549550611',0x000000000101000000E753C72AA5604DC0438CD7BCAA2A41C0,'2014-09-25 22:30:05'),
+(451,'1704 Tambaram Manor','','West Bengali',554,'2834','39463554936',0x000000000101000000A4E9A2D755065640F598EDAFC3793640,'2014-09-25 22:31:28'),
+(452,'207 Cuernavaca Loop','','Tatarstan',352,'52671','782900030287',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:55'),
+(453,'319 Springs Loop','','Baijeri',160,'99552','72524459905',0x0000000001010000006A62CB3C0304264081FEE7D5A5CB4840,'2014-09-25 22:31:05'),
+(454,'956 Nam Dinh Manor','','Kerman',481,'21872','474047727727',0x000000000101000000F16206CF29D74B40CFA91A738D733D40,'2014-09-25 22:31:39'),
+(455,'1947 Paarl Way','','Central Java',509,'23636','834061016202',0x000000000101000000C4D78D2D3AB55B40AC996B8775391EC0,'2014-09-25 22:31:35'),
+(456,'814 Simferopol Loop','','Sinaloa',154,'48745','524567129902',0x000000000101000000954330B3F42F5BC090CCD9F115313A40,'2014-09-25 22:32:05'),
+(457,'535 Ahmadnagar Manor','','Abu Dhabi',3,'41136','985109775584',0x000000000101000000D3E6EE29EF2E4B4099C6E52E78773840,'2014-09-25 22:33:34'),
+(458,'138 Caracas Boulevard','','Zulia',326,'16790','974433019532',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:04'),
+(459,'251 Florencia Drive','','Michoacn de Ocampo',556,'16119','118011831565',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:13'),
+(460,'659 Gatineau Boulevard','','La Paz',153,'28587','205524798287',0x00000000010100000017E7B9CFBB0B51C0A029858ABB7B30C0,'2014-09-25 22:30:13'),
+(461,'1889 Valparai Way','','Ziguinchor',600,'75559','670370974122',0x00000000010100000020E1C50C9E4530C0FC219111AB2A2940,'2014-09-25 22:33:01'),
+(462,'1485 Bratislava Place','','Illinois',435,'83183','924663855568',0x000000000101000000A081A2C30D4656C04453D1B3B4224540,'2014-09-25 22:33:59'),
+(463,'935 Aden Boulevard','','Central Java',532,'64709','335052544020',0x000000000101000000C7139C55FA485B40BEE435655D7A1BC0,'2014-09-25 22:31:35'),
+(464,'76 Kermanshah Manor','','Esfahan',423,'23343','762361821578',0x000000000101000000FF66182DF6EE4940A60BB1FA23014040,'2014-09-25 22:31:37'),
+(465,'734 Tanshui Avenue','','Caquet',170,'70664','366776723320',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:52'),
+(466,'118 Jaffna Loop','','Northern Mindanao',182,'10447','325526730021',0x00000000010100000028B27B9777475F40BAEA4B80ABAA2140,'2014-09-25 22:32:36'),
+(467,'1621 Tongliao Avenue','','Irkutsk',558,'22173','209342540247',0x000000000101000000C7269E584CE95940E56A1ACA3F604A40,'2014-09-25 22:32:58'),
+(468,'1844 Usak Avenue','','Nova Scotia',196,'84461','164414772677',0x0000000001010000004205871744C94FC0162B0F779A524640,'2014-09-25 22:30:27'),
+(469,'1872 Toulon Loop','','OHiggins',428,'7939','928809465153',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:30'),
+(470,'1088 Ibirit Place','','Jalisco',595,'88502','49084281333',0x0000000001010000007820578FA0D859C06AE514D33BB93440,'2014-09-25 22:32:15'),
+(471,'1322 Mosul Parkway','','Shandong',145,'95400','268053970382',0x0000000001010000002856574F779F5D402425E2523ABB4240,'2014-09-25 22:30:32'),
+(472,'1447 Chatsworth Place','','Chihuahua',129,'41545','769370126331',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:04'),
+(473,'1257 Guadalajara Street','','Karnataka',78,'33599','195337700615',0x000000000101000000052049A4C8ED5240E702F2800DD33040,'2014-09-25 22:31:14'),
+(474,'1469 Plock Lane','','Galicia',388,'95835','622884741180',0x000000000101000000FB44F9DDCF741FC0ED9A90D6182B4540,'2014-09-25 22:33:09'),
+(475,'434 Ourense (Orense) Manor','','Hodeida',206,'14122','562370137426',0x000000000101000000F56FF2B62D7A4540DF80E03B7B982D40,'2014-09-25 22:34:10'),
+(476,'270 Tambaram Parkway','','Gauteng',244,'9668','248446668735',0x0000000001010000005B5540EB2B0B3C4082412D61C8333AC0,'2014-09-25 22:33:03'),
+(477,'1786 Salinas Place','','Nam Ha',359,'66546','206060652238',0x00000000010100000044BD851A2A7E5A40C2DB8310908D3440,'2014-09-25 22:34:07'),
+(478,'1078 Stara Zagora Drive','','Aceh',301,'69221','932992626595',0x00000000010100000034057CC8A5495840D2C9ADA470B81440,'2014-09-25 22:31:33'),
+(479,'1854 Okara Boulevard','','Drenthe',158,'42123','131912793873',0x0000000001010000006E8AC745B5A01B40947BCBE6BB634A40,'2014-09-25 22:32:21'),
+(480,'421 Yaound Street','','Sumy',385,'11363','726875628268',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:33'),
+(481,'1153 Allende Way','','Qubec',179,'20336','856872225376',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:26'),
+(482,'808 Naala-Porto Parkway','','England',500,'41060','553452430707',0x0000000001010000000E6036A6CC4201C0B9D7930A74B44A40,'2014-09-25 22:33:41'),
+(483,'632 Usolje-Sibirskoje Parkway','','Ha Darom',36,'73085','667648979883',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:41'),
+(484,'98 Pyongyang Boulevard','','Ohio',11,'88749','191958435142',0x0000000001010000008AB1A778376154C0990524AB6C8A4440,'2014-09-25 22:33:42'),
+(485,'984 Novoterkassk Loop','','Gaziantep',180,'28165','435118527255',0x000000000101000000CAAF7A1BF6B04240AA8889BC9B874240,'2014-09-25 22:33:25'),
+(486,'64 Korla Street','','Mwanza',347,'25145','510383179153',0x0000000001010000002A28FB9DDC7B40402EBB719C252204C0,'2014-09-25 22:33:17'),
+(487,'1785 So Bernardo do Campo Street','','Veracruz',125,'71182','684529463244',0x000000000101000000A1551CBD509C57C0141F44D72A223240,'2014-09-25 22:32:04'),
+(488,'698 Jelets Boulevard','','Denizli',142,'2596','975185523021',0x000000000101000000EECD6F9868163D40B226BB3E18E34240,'2014-09-25 22:33:24'),
+(489,'1297 Alvorada Parkway','','Ningxia',587,'11839','508348602835',0x0000000001010000001583D1F679915A4029876066E93B4340,'2014-09-25 22:30:49'),
+(490,'1909 Dayton Avenue','','Guangdong',469,'88513','702955450528',0x0000000001010000007BE0BE6955655C405457998466E43840,'2014-09-25 22:30:42'),
+(491,'1789 Saint-Denis Parkway','','Coahuila de Zaragoza',4,'8268','936806643983',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:01'),
+(492,'185 Mannheim Lane','','Stavropol',408,'23661','589377568313',0x000000000101000000333E82D19B87454024592CEA38064640,'2014-09-25 22:32:56'),
+(493,'184 Mandaluyong Street','','Baja California Sur',288,'94239','488425406814',0x000000000101000000173B2BB3D2935BC078F6F0C05B233840,'2014-09-25 22:32:09'),
+(494,'591 Sungai Petani Drive','','Okayama',376,'46400','37247325001',0x0000000001010000001966B2C9EBBD60404CC054D8B1544140,'2014-09-25 22:31:51'),
+(495,'656 Matamoros Drive','','Boyac',487,'19489','17305839123',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:53'),
+(496,'775 ostka Drive','','al-Daqahliya',337,'22358','171973024401',0x000000000101000000FC4DCD8A4D423F403EDF60B9EFB63E40,'2014-09-25 22:30:57'),
+(497,'1013 Tabuk Boulevard','','West Bengali',261,'96203','158399646978',0x0000000001010000005D1B857F6C1B5640793BC269C1F53640,'2014-09-25 22:31:19'),
+(498,'319 Plock Parkway','','Istanbul',504,'26101','854259976812',0x000000000101000000B6EFF6C54A453D40277E3100F97A4440,'2014-09-25 22:33:28'),
+(499,'1954 Kowloon and New Kowloon Way','','Chimborazo',434,'63667','898559280434',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(500,'362 Rajkot Lane','','Gansu',47,'98030','962020153680',0x0000000001010000004F6FEB13E50A5A4028733D1B03464240,'2014-09-25 22:30:31'),
+(501,'1060 Tandil Lane','','Shandong',432,'72349','211256301880',0x000000000101000000CAB61D6423DD5D40ADF1E379BAB64140,'2014-09-25 22:30:41'),
+(502,'1515 Korla Way','','England',589,'57197','959467760895',0x0000000001010000004C42D8DFC852F1BFBA826DC493FA4A40,'2014-09-25 22:33:42'),
+(503,'1416 San Juan Bautista Tuxtepec Avenue','','Zufar',444,'50592','144206758053',0x000000000101000000A6684018D30B4B40078662E1DA033140,'2014-09-25 22:32:29'),
+(504,'1 Valle de Santiago Avenue','','Apulia',93,'86208','465897838272',0x000000000101000000CAFED4D3A2EF3140584D7C5AEA504440,'2014-09-25 22:31:43'),
+(505,'519 Brescia Parkway','','East Java',318,'69504','793996678771',0x000000000101000000A3C794B487E15B400A230736F8841EC0,'2014-09-25 22:31:33'),
+(506,'414 Mandaluyong Street','','Lubelskie',314,'16370','52709222667',0x0000000001010000000FE6C0BC1191364020F0C000C2A04940,'2014-09-25 22:32:43'),
+(507,'1197 Sokoto Boulevard','','West Bengali',478,'87687','868602816371',0x000000000101000000109546CC6C1B56408F0FC4C3C5B53A40,'2014-09-25 22:31:27'),
+(508,'496 Celaya Drive','','Nagano',552,'90797','759586584889',0x000000000101000000254E3805034961402486D3388A334240,'2014-09-25 22:31:54'),
+(509,'786 Matsue Way','','Illinois',245,'37469','111177206479',0x0000000001010000000F3B9D75570556C0FA91C77839C34440,'2014-09-25 22:33:54'),
+(510,'48 Maracabo Place','','Central Luzon',519,'1570','82671830126',0x000000000101000000223999B8D53A5E408D87AD8F3D2D2F40,'2014-09-25 22:32:39'),
+(511,'1152 al-Qatif Lane','','Kalimantan Barat',412,'44816','131370665218',0x000000000101000000107FA88F9B545B4021037976F9D69FBF,'2014-09-25 22:31:34'),
+(512,'1269 Ipoh Avenue','','Eskisehir',163,'54674','402630109080',0x000000000101000000E9D32AFA43853E40767D303A6AE34340,'2014-09-25 22:33:24'),
+(513,'758 Korolev Parkway','','Andhra Pradesh',568,'75474','441628280920',0x00000000010100000031DA99F859285440AF528BD2EF843040,'2014-09-25 22:31:29'),
+(514,'1747 Rustenburg Place','','Bihar',110,'51369','442673923363',0x0000000001010000000BFD5DE9C62E554041C4BC7D0CC83940,'2014-09-25 22:31:14'),
+(515,'886 Tonghae Place','','Volgograd',259,'19450','711928348157',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:50'),
+(516,'1574 Goinia Boulevard','','Heilongjiang',502,'39529','59634255214',0x00000000010100000017128B73AFBF5F40C5ECC094DC514740,'2014-09-25 22:30:43'),
+(517,'548 Uruapan Street','','Ontario',312,'35653','879347453467',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:38'),
+(519,'962 Tama Loop','','',583,'65952','282667506728',0x000000000101000000FA545FA722DD6440AA7A9EE4B321E1BF,'2014-09-25 22:32:19'),
+(520,'1778 Gijn Manor','','Hubei',594,'35156','288910576761',0x000000000101000000E358727044305C40A58A3D0F49104040,'2014-09-25 22:30:50'),
+(521,'568 Dhule (Dhulia) Loop','','Coquimbo',127,'92568','602101369463',0x0000000001010000000000804A296FC5C1DDA85F330AC13EC0,'2014-09-25 22:30:30'),
+(522,'1768 Udine Loop','','Battambang',60,'32347','448876499197',0x000000000101000000708802C7AFCC59402ABC15D396342A40,'2014-09-25 22:30:24'),
+(523,'608 Birgunj Parkway','','Taipei',116,'400','627425618482',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:14'),
+(524,'680 A Corua (La Corua) Manor','','Sivas',482,'49806','158326114853',0x000000000101000000936EF02A10824240F2F6D676C9DF4340,'2014-09-25 22:33:28'),
+(525,'1949 Sanya Street','','Gumma',224,'61244','132100972047',0x000000000101000000943F29A406696140E4CA8FAE88284240,'2014-09-25 22:31:47'),
+(526,'617 Klerksdorp Place','','Khanh Hoa',366,'94707','574973479129',0x0000000001010000004A1751C96F4C5B4032F504D37A7D2840,'2014-09-25 22:34:07'),
+(527,'1993 0 Loop','','Liaoning',588,'41214','25865528181',0x000000000101000000B65E1D119D8E5E40171A3ED818554440,'2014-09-25 22:30:49'),
+(528,'1176 Southend-on-Sea Manor','','Southern Tagalog',458,'81651','236679267178',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:39'),
+(529,'600 Purnea (Purnia) Avenue','','Nghe An',571,'18043','638409958875',0x000000000101000000962364204F6C5A407A6D365662AC3240,'2014-09-25 22:34:07'),
+(530,'1003 Qinhuangdao Street','','West Java',419,'25972','35533115997',0x0000000001010000005EA516A55FDC5A40A21639FA4E3A1AC0,'2014-09-25 22:31:35'),
+(531,'1986 Sivas Place','','Friuli-Venezia Giuli',551,'95775','182059202712',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:44'),
+(532,'1427 Tabuk Place','','Florida',101,'31342','214756839122',0x0000000001010000003C702942C57C54C02A5D555117903A40,'2014-09-25 22:33:47'),
+(533,'556 Asuncin Way','','Mogiljov',339,'35364','338244023543',0x0000000001010000006B6DD04D51583E40673513C259F54A40,'2014-09-25 22:30:13'),
+(534,'486 Ondo Parkway','','Benguela',67,'35202','105882218332',0x000000000101000000BD83E9C59ACF2A40B9FA56900B2729C0,'2014-09-25 22:30:02'),
+(535,'635 Brest Manor','','Andhra Pradesh',75,'40899','80593242951',0x00000000010100000079FA52897C615440D2C9ADA4708A3040,'2014-09-25 22:31:13'),
+(536,'166 Jinchang Street','','Buenos Aires',165,'86760','717566026669',0x0000000001010000003EB896242A434DC0E0771DBB556D41C0,'2014-09-25 22:30:05'),
+(537,'958 Sagamihara Lane','','Mie',287,'88408','427274926505',0x000000000101000000BED29E37BA1761409B5F837467884140,'2014-09-25 22:31:50'),
+(538,'1817 Livorno Way','','Khanh Hoa',100,'79401','478380208348',0x000000000101000000944A78422F4A5B40236D3E09C7D72740,'2014-09-25 22:34:05'),
+(539,'1332 Gaziantep Lane','','Shandong',80,'22813','383353187467',0x000000000101000000BC2F1D2911815D4074B0A316EFAE4240,'2014-09-25 22:30:31'),
+(540,'949 Allende Lane','','Uttar Pradesh',24,'67521','122981120653',0x0000000001010000008C91DBE5119E534039A8B34934E73C40,'2014-09-25 22:31:11'),
+(541,'195 Ilorin Street','','Chari-Baguirmi',363,'49250','8912935608',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:29'),
+(542,'193 Bhusawal Place','','Kang-won',539,'9750','745267607502',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:07'),
+(543,'43 Vilnius Manor','','Colorado',42,'79814','484500282381',0x0000000001010000009389004C3E355AC0D03582435EDD4340,'2014-09-25 22:33:44'),
+(544,'183 Haiphong Street','','Jilin',46,'69953','488600270038',0x000000000101000000AFA3607C87B45E4038A85890C1CD4640,'2014-09-25 22:30:30'),
+(545,'163 Augusta-Richmond County Loop','','Carabobo',561,'33030','754579047924',0x000000000101000000CC0C1B657D0051C06B7F677BF4522440,'2014-09-25 22:34:05'),
+(546,'191 Jos Azueta Parkway','','Ruse',436,'13629','932156667696',0x00000000010100000067A9ABF188F83940CD6CA1759EED4540,'2014-09-25 22:30:23'),
+(547,'379 Lublin Parkway','','Toscana',309,'74568','921960450089',0x00000000010100000090920D5AFEA62440CC13BEADAAC54540,'2014-09-25 22:31:44'),
+(548,'1658 Cuman Loop','','Sumatera Selatan',396,'51309','784907335610',0x00000000010100000018D75306E9885A40E8209EDB3A4E01C0,'2014-09-25 22:31:34'),
+(549,'454 Qinhuangdao Drive','','Tadla-Azilal',68,'25866','786270036240',0x000000000101000000419479F53B6619C04F09E3022B2B4040,'2014-09-25 22:32:16'),
+(550,'1715 Okayama Street','','So Paulo',485,'55676','169352919175',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:22'),
+(551,'182 Nukualofa Drive','','Sumy',275,'15414','426346224043',0x00000000010100000079F71109F099404055BBCBEAC29E4940,'2014-09-25 22:33:32'),
+(552,'390 Wroclaw Way','','Hainan',462,'5753','357593328658',0x000000000101000000F70FD88B57605B40364E5480393E3240,'2014-09-25 22:30:41'),
+(553,'1421 Quilmes Lane','','Ishikawa',260,'19151','135407755975',0x0000000001010000008F9F32A30414614053AEF02E174C4240,'2014-09-25 22:31:49'),
+(554,'947 Trshavn Place','','Central Luzon',528,'841','50898428626',0x000000000101000000C56DD9C644265E4002B5BD82D9F52E40,'2014-09-25 22:32:40'),
+(555,'1764 Jalib al-Shuyukh Parkway','','Galicia',459,'77642','84794532510',0x00000000010100000090FFB8B3651721C09DB23FF5B4704540,'2014-09-25 22:33:10'),
+(556,'346 Cam Ranh Avenue','','Zhejiang',599,'39976','978430786151',0x000000000101000000A0E63FFF188D5E4056DBA8A9C0023E40,'2014-09-25 22:30:51'),
+(557,'1407 Pachuca de Soto Place','','Rio Grande do Sul',21,'26284','380077794770',0x000000000101000000A3CEDC43C28449C0608209922DFD3DC0,'2014-09-25 22:30:14'),
+(558,'904 Clarksville Drive','','Zhejiang',193,'52234','955349440539',0x000000000101000000E5886B6BFA2A5E4038E04E7D7B7A3E40,'2014-09-25 22:30:34'),
+(559,'1917 Kumbakonam Parkway','','Vojvodina',368,'11892','698182547686',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:11'),
+(560,'1447 Imus Place','','Gujarat',426,'12905','62127829280',0x000000000101000000667F4523C4B25140819C8B1AA74A3640,'2014-09-25 22:31:25'),
+(561,'1497 Fengshan Drive','','KwaZulu-Natal',112,'63022','368738360376',0x000000000101000000938FDD054AE43E402AF97DA42DEB3DC0,'2014-09-25 22:33:03'),
+(562,'869 Shikarpur Way','','England',496,'57380','590764256785',0x000000000101000000894FF003460D08C0828472ECEAD24A40,'2014-09-25 22:33:40'),
+(563,'1059 Yuncheng Avenue','','Vilna',570,'47498','107092893983',0x00000000010100000046B82462A5473940BA0ACE8536584B40,'2014-09-25 22:31:58'),
+(564,'505 Madiun Boulevard','','Dolnoslaskie',577,'97271','970638808606',0x000000000101000000F0D46D9A8808314023A93B05AF914940,'2014-09-25 22:32:44'),
+(565,'1741 Hoshiarpur Boulevard','','al-Sharqiya',79,'22372','855066328617',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:30:56'),
+(566,'1229 Varanasi (Benares) Manor','','Buenos Aires',43,'40195','817740355461',0x00000000010100000014DA28A1AA2A4DC02E156580555541C0,'2014-09-25 22:30:04'),
+(567,'1894 Boa Vista Way','','Texas',178,'77464','239357986667',0x000000000101000000C1D1448EE32858C0AD8D0CCDD0744040,'2014-09-25 22:33:51'),
+(568,'1342 Sharja Way','','Sokoto & Kebbi & Zam',488,'93655','946114054231',0x0000000001010000005B087250C2F41440E711ED74311F2A40,'2014-09-25 22:32:27'),
+(569,'1342 Abha Boulevard','','Bukarest',95,'10714','997453607116',0x000000000101000000924FD9FA331B3A40B1CBA61254374640,'2014-09-25 22:32:46'),
+(570,'415 Pune Avenue','','Shandong',580,'44274','203202500108',0x000000000101000000CC3857DE1F705D408F26CDD545F34140,'2014-09-25 22:30:47'),
+(571,'1746 Faaa Way','','Huanuco',214,'32515','863080561151',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:33'),
+(572,'539 Hami Way','','Tokat',538,'52196','525518075499',0x0000000001010000006F302F1BF8464240AD7B759F2D284440,'2014-09-25 22:33:29'),
+(573,'1407 Surakarta Manor','','Moskova',466,'33224','324346485054',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:56'),
+(574,'502 Mandi Bahauddin Parkway','','Anzotegui',55,'15992','618156722572',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:34:03'),
+(575,'1052 Pathankot Avenue','','Sichuan',299,'77397','128499386727',0x000000000101000000AA054026E3F05940CCC12275F18F3D40,'2014-09-25 22:30:39'),
+(576,'1351 Sousse Lane','','Coahuila de Zaragoza',341,'37815','203804046132',0x0000000001010000006AB86D84EA5A59C027AA12C028E83A40,'2014-09-25 22:32:10'),
+(577,'1501 Pangkal Pinang Avenue','','Mazowieckie',409,'943','770864062795',0x0000000001010000001646C4DED5B43340308AD46AFE454A40,'2014-09-25 22:32:43'),
+(578,'1405 Hagonoy Avenue','','Slaskie',133,'86587','867287719310',0x0000000001010000002431F77FC41F3340F5B06197F2654940,'2014-09-25 22:32:42'),
+(579,'521 San Juan Bautista Tuxtepec Place','','Qaraghandy',598,'95093','844018348565',0x0000000001010000006848CB3711F15040E32A604C44E44740,'2014-09-25 22:31:56'),
+(580,'923 Tangail Boulevard','','Tokyo-to',10,'33384','315528269898',0x00000000010100000078E5C468A76B6140C3A27D079ADA4140,'2014-09-25 22:31:45'),
+(581,'186 Skikda Lane','','Morelos',131,'89422','14465669789',0x00000000010100000048C2BE9DC4CE58C0DA3DD4111BED3240,'2014-09-25 22:32:05'),
+(582,'1568 Celaya Parkway','','Kaohsiung',168,'34750','278669994384',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:15'),
+(583,'1489 Kakamigahara Lane','','Taipei',526,'98883','29341849811',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:16'),
+(584,'1819 Alessandria Loop','','Campeche',103,'53829','377633994405',0x0000000001010000008636A5611DF556C0374F1A0F5BA53240,'2014-09-25 22:32:02'),
+(585,'1208 Tama Loop','','Ninawa',344,'73605','954786054144',0x000000000101000000314F9DFD378F4540961EF23BF22A4240,'2014-09-25 22:31:40'),
+(586,'951 Springs Lane','','Central Mindanao',219,'96115','165164761435',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:37'),
+(587,'760 Miyakonojo Drive','','Guerrero',246,'64682','294449058179',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:32:08'),
+(588,'966 Asuncin Way','','Hidalgo',212,'62703','995527378381',0x000000000101000000EBBD4230D89A58C0E30632F1FD233540,'2014-09-25 22:32:07'),
+(589,'1584 Ljubertsy Lane','','England',494,'22954','285710089439',0x00000000010100000035385B8AF577F6BF8C7560EFB4734940,'2014-09-25 22:33:38'),
+(590,'247 Jining Parkway','','Banjul',54,'53446','170115379190',0x0000000001010000001BE4E434FA9330C08A8F4FC8CEE72A40,'2014-09-25 22:31:04'),
+(591,'773 Dallas Manor','','Buenos Aires',424,'12664','914466027044',0x00000000010100000009C3802557204DC0B75CA21FB25C41C0,'2014-09-25 22:30:06'),
+(592,'1923 Stara Zagora Lane','','Nantou',546,'95179','182178609211',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:33:17'),
+(593,'1402 Zanzibar Boulevard','','Guanajuato',106,'71102','387448063440',0x000000000101000000FCB7DCAA353459C05CA8A1B206863440,'2014-09-25 22:32:03'),
+(594,'1464 Kursk Parkway','','Shandong',574,'17381','338758048786',0x0000000001010000008CA2073E86C65D40055669E6245B4240,'2014-09-25 22:30:44'),
+(595,'1074 Sanaa Parkway','','Loja',311,'22474','154124128457',0x00000000010100000092DBE51112CD53C00EF96706F1F10FC0,'2014-09-25 22:30:55'),
+(596,'1759 Niznekamsk Avenue','','al-Manama',14,'39414','864392582257',0x000000000101000000044D9539A74A49401224004922373A40,'2014-09-25 22:30:11'),
+(597,'32 Liaocheng Way','','Minas Gerais',248,'1944','410877354933',0x000000000101000000C2757BFFD5AC45C0424F1432A1C335C0,'2014-09-25 22:30:19'),
+(598,'42 Fontana Avenue','','Fejr',512,'14684','437829801725',0x00000000010100000000000000000000000000000000000000,'2014-09-25 22:31:09'),
+(599,'1895 Zhezqazghan Drive','','California',177,'36693','137809746111',0x0000000001010000003EC7ECD1407C5DC057FA1A930FE34040,'2014-09-25 22:33:51'),
+(600,'1837 Kaduna Parkway','','Inner Mongolia',241,'82580','640843562301',0x000000000101000000D61A4AEDC5465C400E64E2FB87834440,'2014-09-25 22:30:37'),
+(601,'844 Bucuresti Place','','Liaoning',242,'36603','935952366111',0x000000000101000000B88086EDDD6D5E407CED9925018D4340,'2014-09-25 22:30:37'),
+(602,'1101 Bucuresti Boulevard','','West Greece',401,'97661','199514580428',0x000000000101000000AAC1EA7E04BC3540E65F26E5491F4340,'2014-09-25 22:31:07'),
+(603,'1103 Quilmes Boulevard','','Piura',503,'52137','644021380889',0x000000000101000000AD9685C0DB2B54C09B012EC8969D13C0,'2014-09-25 22:32:34'),
+(604,'1331 Usak Boulevard','','Vaud',296,'61960','145308717464',0x000000000101000000CE273CB203881A40205734E72A424740,'2014-09-25 22:33:14'),
+(605,'1325 Fukuyama Street','','Heilongjiang',537,'27107','288241215394',0x00000000010100000017540A70700160401E1C47077F7D4740,'2014-09-25 22:30:44');
+COMMIT;
+
+DROP TABLE address;
diff --git a/mysql-test/suite/innodb_undo/include/have_undo_tablespaces.inc b/mysql-test/suite/innodb_undo/include/have_undo_tablespaces.inc
new file mode 100644
index 00000000000..87830a4a5f0
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/include/have_undo_tablespaces.inc
@@ -0,0 +1,4 @@
+if (`select count(*) = 0 from information_schema.global_variables where variable_name like 'innodb_undo_tablespaces' and variable_value >= 2`)
+{
+ --skip Test requires InnoDB with at-least 2 undo tablespaces.
+}
diff --git a/mysql-test/suite/innodb_undo/include/truncate_recover.inc b/mysql-test/suite/innodb_undo/include/truncate_recover.inc
new file mode 100644
index 00000000000..fe068afa6e3
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/include/truncate_recover.inc
@@ -0,0 +1,8 @@
+begin;
+update t1 set c = 'MariaDB';
+update t1 set c = 'InnoDB';
+eval set global debug_dbug = '+d,$SEARCH_PATTERN';
+commit;
+--source include/shutdown_mysqld.inc
+--source include/search_pattern_in_file.inc
+--source include/start_mysqld.inc
diff --git a/mysql-test/suite/innodb_undo/r/truncate.result b/mysql-test/suite/innodb_undo/r/truncate.result
new file mode 100644
index 00000000000..4f62d85e08a
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/r/truncate.result
@@ -0,0 +1,11 @@
+SET GLOBAL innodb_fast_shutdown=0;
+create table t1(keyc int primary key, c1 char(100)) engine = innodb;
+begin;
+update t1 set c1 = 'mysql';
+update t1 set c1 = 'oracle';
+delete from t1;
+commit;
+drop table t1;
+SET GLOBAL innodb_fast_shutdown=0;
+SET GLOBAL innodb_undo_log_truncate=1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
diff --git a/mysql-test/suite/innodb_undo/r/truncate_multi_client.result b/mysql-test/suite/innodb_undo/r/truncate_multi_client.result
new file mode 100644
index 00000000000..c1ce2845996
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/r/truncate_multi_client.result
@@ -0,0 +1,51 @@
+SET GLOBAL innodb_fast_shutdown=0;
+create table t1(keyc int primary key, c char(100)) engine = innodb;
+create table t2(keyc int primary key, c char(100)) engine = innodb;
+CREATE PROCEDURE populate_t1()
+BEGIN
+DECLARE i INT DEFAULT 1;
+while (i <= 20000) DO
+insert into t1 values (i, 'a');
+SET i = i + 1;
+END WHILE;
+END |
+CREATE PROCEDURE populate_t2()
+BEGIN
+DECLARE i INT DEFAULT 1;
+while (i <= 20000) DO
+insert into t2 values (i, 'a');
+SET i = i + 1;
+END WHILE;
+END |
+connect con1,localhost,root,,;
+begin;
+call populate_t1();
+connect con2,localhost,root,,;
+begin;
+call populate_t2();
+connection con1;
+update t1 set c = 'mysql';
+connection con2;
+update t2 set c = 'mysql';
+connection con1;
+update t1 set c = 'oracle';
+connection con2;
+update t2 set c = 'oracle';
+connection con1;
+delete from t1;
+connection con2;
+delete from t2;
+connection con1;
+commit;
+disconnect con1;
+connection con2;
+commit;
+disconnect con2;
+connection default;
+drop table t1, t2;
+drop PROCEDURE populate_t1;
+drop PROCEDURE populate_t2;
+SET GLOBAL innodb_fast_shutdown=0;
+SET GLOBAL innodb_undo_log_truncate=1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
+FOUND 1 /Truncating UNDO tablespace 1/ in mysqld.1.err
diff --git a/mysql-test/suite/innodb_undo/r/truncate_recover.result b/mysql-test/suite/innodb_undo/r/truncate_recover.result
new file mode 100644
index 00000000000..f89bc0a9e47
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/r/truncate_recover.result
@@ -0,0 +1,15 @@
+create table t1(keyc int primary key, c char(100)) engine = innodb;
+begin;
+commit;
+begin;
+update t1 set c = 'MariaDB';
+update t1 set c = 'InnoDB';
+set global debug_dbug = '+d,ib_undo_trunc_before_truncate';
+commit;
+FOUND 1 /ib_undo_trunc_before_truncate/ in mysqld.1.err
+begin;
+update t1 set c = 'MariaDB';
+update t1 set c = 'InnoDB';
+set global debug_dbug = '+d,ib_undo_trunc_before_ddl_log_end';
+commit;
+FOUND 1 /ib_undo_trunc_before_ddl_log_end/ in mysqld.1.err
diff --git a/mysql-test/suite/innodb_undo/t/truncate.test b/mysql-test/suite/innodb_undo/t/truncate.test
new file mode 100644
index 00000000000..2c612478929
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/t/truncate.test
@@ -0,0 +1,72 @@
+#
+# WL#6965: Truncate UNDO logs.
+#
+
+--source include/have_innodb.inc
+--source include/have_innodb_max_16k.inc
+--source include/have_undo_tablespaces.inc
+
+# The test is restarting the server to force undo truncation.
+--source include/not_embedded.inc
+
+SET GLOBAL innodb_fast_shutdown=0;
+--let $restart_parameters=--innodb_undo_tablespaces=2 --innodb_undo_logs=4
+--source include/restart_mysqld.inc
+
+let MYSQLD_DATADIR = `select @@datadir`;
+
+#-----------------------------------------------------------------------------
+#
+# 1. Perform enough DML action so that undo tablespace size grows beyond
+# set threshold and then wait and see if it is being truncated.
+#
+create table t1(keyc int primary key, c1 char(100)) engine = innodb;
+begin;
+--disable_query_log
+let $i=30000;
+while ($i) {
+ eval insert into t1 values(30000-$i, '');
+ dec $i;
+}
+--enable_query_log
+update t1 set c1 = 'mysql';
+update t1 set c1 = 'oracle';
+delete from t1;
+commit;
+drop table t1;
+
+let CHECKFILE = $MYSQL_TMP_DIR/check.txt;
+perl;
+($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1)
+ = stat("$ENV{MYSQLD_DATADIR}/undo001");
+($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2)
+ = stat("$ENV{MYSQLD_DATADIR}/undo002");
+open(OUT, ">$ENV{CHECKFILE}") || die;
+print OUT "let \$size1='$size1,$size2';\n";
+close(OUT);
+EOF
+SET GLOBAL innodb_fast_shutdown=0;
+SET GLOBAL innodb_undo_log_truncate=1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
+--source include/shutdown_mysqld.inc
+--source $CHECKFILE
+perl;
+($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1)
+ = stat("$ENV{MYSQLD_DATADIR}/undo001");
+($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2)
+ = stat("$ENV{MYSQLD_DATADIR}/undo002");
+open(OUT, ">$ENV{CHECKFILE}") || die;
+print OUT "let \$size2='$size1,$size2';\n";
+close(OUT);
+EOF
+
+--source $CHECKFILE
+--remove_file $CHECKFILE
+
+if ($size1 == $size2)
+{
+ echo Truncation did not happen: $size1 == $size2;
+}
+
+--let $restart_parameters=
+--source include/start_mysqld.inc
diff --git a/mysql-test/suite/innodb_undo/t/truncate_multi_client.test b/mysql-test/suite/innodb_undo/t/truncate_multi_client.test
new file mode 100644
index 00000000000..ac4ead00b51
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/t/truncate_multi_client.test
@@ -0,0 +1,77 @@
+#
+# WL#6965: Truncate UNDO logs.
+#
+
+--source include/have_innodb.inc
+# This test is restarting the server.
+--source include/not_embedded.inc
+# With larger innodb_page_size, the undo log tablespaces do not grow enough.
+--source include/have_innodb_max_16k.inc
+--source include/have_undo_tablespaces.inc
+
+SET GLOBAL innodb_fast_shutdown=0;
+--let $restart_parameters=--innodb_undo_tablespaces=2 --innodb_undo_logs=4
+--source include/restart_mysqld.inc
+
+#-----------------------------------------------------------------------------
+#
+# Perform DML action using multiple clients and multiple undo tablespace.
+#
+#
+create table t1(keyc int primary key, c char(100)) engine = innodb;
+create table t2(keyc int primary key, c char(100)) engine = innodb;
+#
+delimiter |;
+CREATE PROCEDURE populate_t1()
+BEGIN
+ DECLARE i INT DEFAULT 1;
+ while (i <= 20000) DO
+ insert into t1 values (i, 'a');
+ SET i = i + 1;
+ END WHILE;
+END |
+delimiter ;|
+#
+delimiter |;
+CREATE PROCEDURE populate_t2()
+BEGIN
+ DECLARE i INT DEFAULT 1;
+ while (i <= 20000) DO
+ insert into t2 values (i, 'a');
+ SET i = i + 1;
+ END WHILE;
+END |
+delimiter ;|
+#
+#
+connect (con1,localhost,root,,);
+begin;
+send call populate_t1();
+
+connect (con2,localhost,root,,);
+begin;
+send call populate_t2();
+
+connection con1; reap; send update t1 set c = 'mysql';
+connection con2; reap; send update t2 set c = 'mysql';
+connection con1; reap; send update t1 set c = 'oracle';
+connection con2; reap; send update t2 set c = 'oracle';
+connection con1; reap; send delete from t1;
+connection con2; reap; send delete from t2;
+connection con1; reap; commit; disconnect con1;
+connection con2; reap; commit; disconnect con2;
+
+connection default;
+drop table t1, t2;
+drop PROCEDURE populate_t1;
+drop PROCEDURE populate_t2;
+
+SET GLOBAL innodb_fast_shutdown=0;
+SET GLOBAL innodb_undo_log_truncate=1;
+SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
+
+--source include/restart_mysqld.inc
+
+let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
+let SEARCH_PATTERN = Truncating UNDO tablespace 1;
+--source include/search_pattern_in_file.inc
diff --git a/mysql-test/suite/innodb_undo/t/truncate_recover.test b/mysql-test/suite/innodb_undo/t/truncate_recover.test
new file mode 100644
index 00000000000..8087d191f1e
--- /dev/null
+++ b/mysql-test/suite/innodb_undo/t/truncate_recover.test
@@ -0,0 +1,50 @@
+#
+# WL#6965: Truncate UNDO logs.
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+# With larger innodb_page_size, the undo log tablespaces do not grow enough.
+--source include/have_innodb_max_16k.inc
+--source include/have_undo_tablespaces.inc
+
+# Valgrind would complain about memory leaks when we crash on purpose.
+--source include/not_valgrind.inc
+# Embedded server does not support crashing
+--source include/not_embedded.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
+--disable_query_log
+# FIXME: The doublewrite buffer should not issue these warnings.
+# FIXME: Maybe buf_dblwr_process() should empty the buffer at the end?
+call mtr.add_suppression("InnoDB: A copy of page.*in the doublewrite buffer slot.*is not within space bounds");
+FLUSH TABLES;
+--enable_query_log
+
+--let $restart_parameters=--innodb-undo-logs=4 --innodb-undo-tablespaces=2 --innodb-undo-log-truncate=1 --innodb-max-undo-log-size=10485760 --innodb-purge-rseg-truncate-frequency=1 --innodb-fast-shutdown=0
+--source include/restart_mysqld.inc
+
+let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
+
+create table t1(keyc int primary key, c char(100)) engine = innodb;
+begin;
+--disable_query_log
+let $i=30000;
+while ($i) {
+ eval insert into t1 values(30000-$i, '');
+ dec $i;
+}
+--enable_query_log
+commit;
+
+let SEARCH_PATTERN = ib_undo_trunc_before_truncate;
+--source include/truncate_recover.inc
+
+let SEARCH_PATTERN = ib_undo_trunc_before_ddl_log_end;
+--source include/truncate_recover.inc
+
+let SEARCH_PATTERN = ib_undo_trunc_trunc_done;
+let $restart_parameters=
+--source include/truncate_recover.inc
+drop table t1;
diff --git a/mysql-test/suite/maria/maria-gis-rtree-dynamic.result b/mysql-test/suite/maria/maria-gis-rtree-dynamic.result
index a0535026722..8bea5edb6fb 100644
--- a/mysql-test/suite/maria/maria-gis-rtree-dynamic.result
+++ b/mysql-test/suite/maria/maria-gis-rtree-dynamic.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
+1 SIMPLE t1 range g g 34 NULL 11 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -302,7 +302,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 1 Using where
+1 SIMPLE t2 range g g 34 NULL 4 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
diff --git a/mysql-test/suite/maria/maria-gis-rtree-trans.result b/mysql-test/suite/maria/maria-gis-rtree-trans.result
index dbcbdeb1661..4a2f97fbd41 100644
--- a/mysql-test/suite/maria/maria-gis-rtree-trans.result
+++ b/mysql-test/suite/maria/maria-gis-rtree-trans.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
+1 SIMPLE t1 range g g 34 NULL 11 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -302,7 +302,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 1 Using where
+1 SIMPLE t2 range g g 34 NULL 4 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
diff --git a/mysql-test/suite/maria/maria-gis-rtree.result b/mysql-test/suite/maria/maria-gis-rtree.result
index 3ecdcc64928..901a7bee397 100644
--- a/mysql-test/suite/maria/maria-gis-rtree.result
+++ b/mysql-test/suite/maria/maria-gis-rtree.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
+1 SIMPLE t1 range g g 34 NULL 11 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -302,7 +302,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 1 Using where
+1 SIMPLE t2 range g g 34 NULL 4 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
diff --git a/mysql-test/suite/rpl/r/rpl_create_drop_view.result b/mysql-test/suite/rpl/r/rpl_create_drop_view.result
index ea1e3354045..0c18249ca08 100644
--- a/mysql-test/suite/rpl/r/rpl_create_drop_view.result
+++ b/mysql-test/suite/rpl/r/rpl_create_drop_view.result
@@ -99,7 +99,7 @@ DROP VIEW v1;
ERROR 42S02: Unknown VIEW: 'test.v1'
DROP VIEW IF EXISTS v2;
Warnings:
-Note 4067 Unknown VIEW: 'test.v2'
+Note 4068 Unknown VIEW: 'test.v2'
# Syncing slave with master
connection slave;
SELECT * FROM v1;
diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result
index 70f9745d409..59dfe62acee 100644
--- a/mysql-test/suite/sql_sequence/create.result
+++ b/mysql-test/suite/sql_sequence/create.result
@@ -165,7 +165,7 @@ drop sequence t1;
ERROR 42S02: 'test.t1' is not a SEQUENCE
drop sequence if exists t1;
Warnings:
-Note 4066 Unknown SEQUENCE: 'test.t1'
+Note 4067 Unknown SEQUENCE: 'test.t1'
create sequence t1 start with 10 maxvalue=9;
ERROR HY000: Sequence 'test.t1' values are conflicting
create sequence t1 minvalue= 100 maxvalue=10;
@@ -374,7 +374,7 @@ key key1 (next_value)
ERROR HY000: Sequence 'test.t1' table structure is invalid (Sequence tables cannot have any keys)
drop sequence if exists t1;
Warnings:
-Note 4066 Unknown SEQUENCE: 'test.t1'
+Note 4067 Unknown SEQUENCE: 'test.t1'
create sequence t1;
create sequence t2;
create table t3 (a int) engine=myisam;
@@ -384,8 +384,8 @@ CREATE SEQUENCE s1;
drop sequence s1;
drop sequence if exists t1,t2,t3,t4;
Warnings:
-Note 4066 Unknown SEQUENCE: 'test.t3'
-Note 4066 Unknown SEQUENCE: 'test.t4'
+Note 4067 Unknown SEQUENCE: 'test.t3'
+Note 4067 Unknown SEQUENCE: 'test.t4'
drop table if exists t1,t2,t3;
Warnings:
Note 1051 Unknown table 'test.t1'
@@ -411,9 +411,9 @@ CREATE TABLE t2 (a int);
CREATE SEQUENCE s1;
drop sequence if exists t1,t2,s1,s2;
Warnings:
-Note 4066 Unknown SEQUENCE: 'test.t1'
-Note 4066 Unknown SEQUENCE: 'test.t2'
-Note 4066 Unknown SEQUENCE: 'test.s2'
+Note 4067 Unknown SEQUENCE: 'test.t1'
+Note 4067 Unknown SEQUENCE: 'test.t2'
+Note 4067 Unknown SEQUENCE: 'test.s2'
drop table if exists t1,t2;
CREATE TEMPORARY SEQUENCE s1;
DROP SEQUENCE s1;
diff --git a/mysql-test/suite/sys_vars/r/innodb_deadlock_detect_basic.result b/mysql-test/suite/sys_vars/r/innodb_deadlock_detect_basic.result
new file mode 100644
index 00000000000..615fc782ad5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/innodb_deadlock_detect_basic.result
@@ -0,0 +1,56 @@
+SET @start_global_value = @@global.innodb_deadlock_detect;
+SELECT @start_global_value;
+@start_global_value
+1
+Valid values are 'ON' and 'OFF'
+select @@global.innodb_deadlock_detect in (0, 1);
+@@global.innodb_deadlock_detect in (0, 1)
+1
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+1
+select @@session.innodb_deadlock_detect in (0, 1);
+ERROR HY000: Variable 'innodb_deadlock_detect' is a GLOBAL variable
+select @@session.innodb_deadlock_detect;
+ERROR HY000: Variable 'innodb_deadlock_detect' is a GLOBAL variable
+show global variables like 'innodb_deadlock_detect';
+Variable_name Value
+innodb_deadlock_detect ON
+show session variables like 'innodb_deadlock_detect';
+Variable_name Value
+innodb_deadlock_detect ON
+set global innodb_deadlock_detect='OFF';
+set session innodb_deadlock_detect='OFF';
+ERROR HY000: Variable 'innodb_deadlock_detect' is a GLOBAL variable and should be set with SET GLOBAL
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+0
+set @@global.innodb_deadlock_detect=1;
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+1
+set global innodb_deadlock_detect=0;
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+0
+set @@global.innodb_deadlock_detect='ON';
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+1
+set global innodb_deadlock_detect=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_deadlock_detect'
+set global innodb_deadlock_detect=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_deadlock_detect'
+set global innodb_deadlock_detect=2;
+ERROR 42000: Variable 'innodb_deadlock_detect' can't be set to the value of '2'
+set global innodb_deadlock_detect='AUTO';
+ERROR 42000: Variable 'innodb_deadlock_detect' can't be set to the value of 'AUTO'
+set global innodb_deadlock_detect=-3;
+ERROR 42000: Variable 'innodb_deadlock_detect' can't be set to the value of '-3'
+select @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+1
+SET @@global.innodb_deadlock_detect = @start_global_value;
+SELECT @@global.innodb_deadlock_detect;
+@@global.innodb_deadlock_detect
+1
diff --git a/mysql-test/suite/sys_vars/r/innodb_max_undo_log_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_max_undo_log_size_basic.result
index 3854060b33b..47565ac40ad 100644
--- a/mysql-test/suite/sys_vars/r/innodb_max_undo_log_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/innodb_max_undo_log_size_basic.result
@@ -4,17 +4,21 @@ COUNT(@@GLOBAL.innodb_max_undo_log_size)
1
1 Expected
'#---------------------BS_STVARS_035_02----------------------#'
+SET @save = @@GLOBAL.innodb_max_undo_log_size;
SET @@GLOBAL.innodb_max_undo_log_size=1073741824;
SELECT COUNT(@@GLOBAL.innodb_max_undo_log_size);
COUNT(@@GLOBAL.innodb_max_undo_log_size)
1
1 Expected
SET @@GLOBAL.innodb_max_undo_log_size=18446744073709551615;
-SELECT @@GLOBAL.innodb_max_undo_log_size;
-@@GLOBAL.innodb_max_undo_log_size
-18446744073709551615
-18446744073709551615 Expected
+Warnings:
+Warning 1292 Truncated incorrect innodb_max_undo_log_size value: '18446744073709551615'
+SELECT FLOOR(@@GLOBAL.innodb_max_undo_log_size / @@GLOBAL.innodb_page_size);
+FLOOR(@@GLOBAL.innodb_max_undo_log_size / @@GLOBAL.innodb_page_size)
+4294967296
+4294967296 Expected
SET @@GLOBAL.innodb_max_undo_log_size=1073741824;
+SET GLOBAL innodb_max_undo_log_size = @save;
'#---------------------BS_STVARS_035_03----------------------#'
SELECT @@GLOBAL.innodb_max_undo_log_size = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
index 9bf02940d75..2b9e9ad6baf 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
@@ -571,9 +571,9 @@
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
- VARIABLE_COMMENT Number of undo tablespaces to use.
+ VARIABLE_COMMENT Number of undo tablespaces to use.
NUMERIC_MIN_VALUE 0
- NUMERIC_MAX_VALUE 95
+ NUMERIC_MAX_VALUE 127
@@ -2630,7 +2630,7 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 4
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
index 051c74af15e..a17d17929be 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
@@ -580,6 +580,20 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME INNODB_DEADLOCK_DETECT
+SESSION_VALUE NULL
+GLOBAL_VALUE ON
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE ON
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT Enable/disable InnoDB deadlock detector (default ON). if set to OFF, deadlock detection is skipped, and we rely on innodb_lock_wait_timeout in case of deadlock.
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT NONE
VARIABLE_NAME INNODB_DEBUG_FORCE_SCRUBBING
SESSION_VALUE NULL
GLOBAL_VALUE OFF
@@ -1590,14 +1604,14 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_MAX_UNDO_LOG_SIZE
SESSION_VALUE NULL
-GLOBAL_VALUE 1073741824
+GLOBAL_VALUE 10485760
GLOBAL_VALUE_ORIGIN COMPILE-TIME
-DEFAULT_VALUE 1073741824
+DEFAULT_VALUE 10485760
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
-VARIABLE_COMMENT Maximum size of UNDO tablespace in MB (If UNDO tablespace grows beyond this size it will be truncated in due course).
+VARIABLE_COMMENT Desired maximum UNDO tablespace size in bytes
NUMERIC_MIN_VALUE 10485760
-NUMERIC_MAX_VALUE 18446744073709551615
+NUMERIC_MAX_VALUE 281474976710656
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -2106,6 +2120,20 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
+VARIABLE_NAME INNODB_STATS_INCLUDE_DELETE_MARKED
+SESSION_VALUE NULL
+GLOBAL_VALUE OFF
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE OFF
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT Include delete marked records when calculating persistent statistics
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_STATS_METHOD
SESSION_VALUE NULL
GLOBAL_VALUE nulls_equal
@@ -2449,9 +2477,9 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
-VARIABLE_COMMENT Number of undo tablespaces to use.
+VARIABLE_COMMENT Number of undo tablespaces to use.
NUMERIC_MIN_VALUE 0
-NUMERIC_MAX_VALUE 95
+NUMERIC_MAX_VALUE 127
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY YES
diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
index 53838366a16..802ee3b1c6d 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
@@ -367,7 +367,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME WSREP_PATCH_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE wsrep_25.16
+GLOBAL_VALUE wsrep_25.19
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
diff --git a/mysql-test/suite/sys_vars/t/innodb_deadlock_detect_basic.test b/mysql-test/suite/sys_vars/t/innodb_deadlock_detect_basic.test
new file mode 100644
index 00000000000..8cac13906c8
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_deadlock_detect_basic.test
@@ -0,0 +1,53 @@
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_deadlock_detect;
+SELECT @start_global_value;
+
+#
+# exists as global
+#
+--echo Valid values are 'ON' and 'OFF'
+select @@global.innodb_deadlock_detect in (0, 1);
+select @@global.innodb_deadlock_detect;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.innodb_deadlock_detect in (0, 1);
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.innodb_deadlock_detect;
+show global variables like 'innodb_deadlock_detect';
+show session variables like 'innodb_deadlock_detect';
+
+#
+# show that it's writable
+#
+set global innodb_deadlock_detect='OFF';
+--error ER_GLOBAL_VARIABLE
+set session innodb_deadlock_detect='OFF';
+select @@global.innodb_deadlock_detect;
+set @@global.innodb_deadlock_detect=1;
+select @@global.innodb_deadlock_detect;
+set global innodb_deadlock_detect=0;
+select @@global.innodb_deadlock_detect;
+set @@global.innodb_deadlock_detect='ON';
+select @@global.innodb_deadlock_detect;
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_deadlock_detect=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_deadlock_detect=1e1;
+--error ER_WRONG_VALUE_FOR_VAR
+set global innodb_deadlock_detect=2;
+--error ER_WRONG_VALUE_FOR_VAR
+set global innodb_deadlock_detect='AUTO';
+--error ER_WRONG_VALUE_FOR_VAR
+set global innodb_deadlock_detect=-3;
+select @@global.innodb_deadlock_detect;
+
+#
+# Cleanup
+#
+
+SET @@global.innodb_deadlock_detect = @start_global_value;
+SELECT @@global.innodb_deadlock_detect;
diff --git a/mysql-test/suite/sys_vars/t/innodb_max_undo_log_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_max_undo_log_size_basic.test
index 9882578923e..e311d6fb873 100644
--- a/mysql-test/suite/sys_vars/t/innodb_max_undo_log_size_basic.test
+++ b/mysql-test/suite/sys_vars/t/innodb_max_undo_log_size_basic.test
@@ -37,17 +37,21 @@ SELECT COUNT(@@GLOBAL.innodb_max_undo_log_size);
# Check if Value can set #
####################################################################
+SET @save = @@GLOBAL.innodb_max_undo_log_size;
+
SET @@GLOBAL.innodb_max_undo_log_size=1073741824;
SELECT COUNT(@@GLOBAL.innodb_max_undo_log_size);
--echo 1 Expected
SET @@GLOBAL.innodb_max_undo_log_size=18446744073709551615;
-SELECT @@GLOBAL.innodb_max_undo_log_size;
---echo 18446744073709551615 Expected
+SELECT FLOOR(@@GLOBAL.innodb_max_undo_log_size / @@GLOBAL.innodb_page_size);
+--echo 4294967296 Expected
SET @@GLOBAL.innodb_max_undo_log_size=1073741824;
+SET GLOBAL innodb_max_undo_log_size = @save;
+
--echo '#---------------------BS_STVARS_035_03----------------------#'
#################################################################
# Check if the value in GLOBAL Table matches value in variable #
diff --git a/mysql-test/suite/wsrep/r/binlog_format.result b/mysql-test/suite/wsrep/r/binlog_format.result
index 83af2b67762..079ceb975dd 100644
--- a/mysql-test/suite/wsrep/r/binlog_format.result
+++ b/mysql-test/suite/wsrep/r/binlog_format.result
@@ -1,4 +1,4 @@
-call mtr.add_suppression("WSREP: MariaDB Galera and flashback do not support binlog format.*");
+call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format");
call mtr.add_suppression("WSREP: Cannot get fake transaction ID from storage engine.");
#
# MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT
diff --git a/mysql-test/suite/wsrep/r/wsrep_rpl.result b/mysql-test/suite/wsrep/r/wsrep_rpl.result
index 20ebb4802de..0d8f7bd9d7a 100644
--- a/mysql-test/suite/wsrep/r/wsrep_rpl.result
+++ b/mysql-test/suite/wsrep/r/wsrep_rpl.result
@@ -8,14 +8,14 @@ connection master;
connection slave;
connection master;
CREATE TABLE t1(i INT) ENGINE = INNODB;
-SET @@GLOBAL.wsrep_max_ws_rows = 1;
+SET @@GLOBAL.wsrep_max_ws_rows = 2;
INSERT INTO t1 VALUES(1), (2);
connection slave;
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
connection slave;
-SET @@GLOBAL.wsrep_max_ws_rows = 1;
+SET @@GLOBAL.wsrep_max_ws_rows = 2;
connection master;
DELETE FROM t1;
connection slave;
diff --git a/mysql-test/suite/wsrep/t/binlog_format.test b/mysql-test/suite/wsrep/t/binlog_format.test
index 02602b9cb2b..07001b17a84 100644
--- a/mysql-test/suite/wsrep/t/binlog_format.test
+++ b/mysql-test/suite/wsrep/t/binlog_format.test
@@ -1,7 +1,7 @@
--source include/have_wsrep_provider.inc
--source include/have_binlog_format_row.inc
-call mtr.add_suppression("WSREP: MariaDB Galera and flashback do not support binlog format.*");
+call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format");
call mtr.add_suppression("WSREP: Cannot get fake transaction ID from storage engine.");
--echo #
diff --git a/mysql-test/suite/wsrep/t/wsrep_rpl.test b/mysql-test/suite/wsrep/t/wsrep_rpl.test
index 1cc7214325d..4f34aadc365 100644
--- a/mysql-test/suite/wsrep/t/wsrep_rpl.test
+++ b/mysql-test/suite/wsrep/t/wsrep_rpl.test
@@ -15,18 +15,13 @@ let $wsrep_max_ws_rows_slave = `SELECT @@GLOBAL.wsrep_max_ws_rows`;
connection master;
CREATE TABLE t1(i INT) ENGINE = INNODB;
-# Setting wsrep_max_ws_rows should have no impact on replication master
-# unless its a cluster node.
-SET @@GLOBAL.wsrep_max_ws_rows = 1;
+SET @@GLOBAL.wsrep_max_ws_rows = 2;
INSERT INTO t1 VALUES(1), (2);
-
sync_slave_with_master;
SELECT COUNT(*) = 2 FROM t1;
connection slave;
-# Setting wsrep_max_ws_rows should have no impact on replication slave
-# unless its a cluster node.
-SET @@GLOBAL.wsrep_max_ws_rows = 1;
+SET @@GLOBAL.wsrep_max_ws_rows = 2;
connection master;
DELETE FROM t1;
@@ -38,7 +33,6 @@ connection master;
DROP TABLE t1;
sync_slave_with_master;
-
# Restore wsrep_max_ws_rows on master and slave
connection master;
eval SET @@GLOBAL.wsrep_max_ws_rows = $wsrep_max_ws_rows_master;
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test
index bcdc06afbad..0cc63104fa5 100644
--- a/mysql-test/t/cte_nonrecursive.test
+++ b/mysql-test/t/cte_nonrecursive.test
@@ -644,7 +644,7 @@ show create view v1;
drop view v1;
--echo #
---echo # MDEV-12440: the same CTE table is used in twice
+--echo # MDEV-12440: the same CTE table is used twice
--echo #
create table t1 (a int, b varchar(32));
@@ -665,4 +665,19 @@ cte2 as (select * from cte1 where b > 'c'),
cte3 as (select * from cte2 where a > 1 union select * from cte2 where a > 1)
select * from cte3;
-drop table t1; \ No newline at end of file
+drop table t1;
+
+--echo #
+--echo # MDEV-12558: CTE with the same name as temporary table
+--echo #
+
+CREATE TABLE t ENGINE=MyISAM AS SELECT 1 AS i;
+CREATE TEMPORARY TABLE cte ENGINE=MyISAM AS SELECT 2 AS f;
+
+WITH cte AS ( SELECT i FROM t ) SELECT * FROM cte;
+WITH cte AS ( SELECT i FROM t GROUP BY i) SELECT * FROM cte;
+
+SELECT * FROM cte;
+
+DROP TABLE cte;
+DROP TABLE t;
diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test
index 26dbe2bccc0..5701ee896cb 100644
--- a/mysql-test/t/cte_recursive.test
+++ b/mysql-test/t/cte_recursive.test
@@ -1834,3 +1834,97 @@ drop table objects, modules, module_arguments, module_results;
set standard_compliant_cte=default;
select @@standard_compliant_cte;
+--echo #
+--echo # mdev-12554: impossible where in recursive select
+--echo #
+
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1),(2);
+
+WITH RECURSIVE
+cte(f) AS ( SELECT i FROM t1 UNION SELECT f FROM t1, cte WHERE 1=0 )
+SELECT * FROM cte;
+
+DROP TABLE t1;
+
+--echo #
+--echo # mdev-12556: recursive execution uses Aria temporary tables
+--echo #
+
+CREATE TABLE t (c1 varchar(255), c2 tinytext);
+INSERT INTO t VALUES ('a','a'),('b','b'),('c','c'),('d','d');
+
+let $q1=
+WITH RECURSIVE cte(f) AS (
+ SELECT c1 FROM t
+ UNION
+ SELECT c1 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+
+let $q2=
+WITH RECURSIVE cte(f) AS (
+ SELECT c2 FROM t
+ UNION
+ SELECT c2 FROM t, cte
+) SELECT COUNT(*) FROM cte;
+
+eval ANALYZE $q1;
+eval $q1;
+
+eval ANALYZE $q2;
+eval $q2;
+
+DROP TABLE t;
+
+--echo #
+--echo # mdev-12563: no recursive references on the top level of the CTE spec
+--echo #
+
+CREATE TABLE t (i int);
+INSERT INTO t VALUES (3), (1),(2);
+
+SET standard_compliant_cte=0;
+
+WITH RECURSIVE cte(f) AS (
+ SELECT i FROM t
+ UNION
+ SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte )
+) SELECT * FROM cte;
+
+WITH RECURSIVE cte(f) AS (
+ SELECT i FROM t
+ UNION
+ SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte WHERE i < 2 )
+ UNION
+ SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte WHERE i > 2 )
+) SELECT * FROM cte;
+
+WITH RECURSIVE cte(f) AS (
+ SELECT i FROM t
+ UNION
+ SELECT i FROM t
+ WHERE i NOT IN ( SELECT * FROM cte WHERE i < 2
+ UNION
+ SELECT * FROM cte WHERE i > 2)
+) SELECT * FROM cte;
+
+WITH RECURSIVE cte(f) AS (
+ SELECT i FROM t
+ UNION
+ SELECT i FROM t
+ WHERE i NOT IN ( SELECT * FROM t
+ WHERE i IN ( SELECT * FROM cte ) GROUP BY i )
+) SELECT * FROM cte;
+
+WITH RECURSIVE cte(f) AS (
+ SELECT i FROM t
+ UNION
+ SELECT i FROM t WHERE i NOT IN ( SELECT * FROM cte )
+ UNION
+ SELECT * FROM cte WHERE f > 2
+) SELECT * FROM cte;
+
+set standard_compliant_cte=default;
+
+DROP TABLE t;
+
diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test
index 47d01617b83..bc448093e33 100644
--- a/mysql-test/t/derived_cond_pushdown.test
+++ b/mysql-test/t/derived_cond_pushdown.test
@@ -1353,3 +1353,102 @@ DEALLOCATE PREPARE stmt2;
DROP VIEW v1;
DROP TABLE t1,t2;
+--echo #
+--echo # MDEV-12373: pushdown into derived with side effects is prohibited
+--echo #
+
+CREATE TABLE sales_documents (
+ id int NOT NULL AUTO_INCREMENT,
+ sale_id int NULL DEFAULT NULL,
+ type tinyint unsigned NULL DEFAULT NULL,
+ data text NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
+ date date NULL DEFAULT NULL,
+ order_number int unsigned NULL DEFAULT NULL,
+ created_at int NULL DEFAULT NULL,
+ updated_at int NULL DEFAULT NULL,
+ generated tinyint NOT NULL DEFAULT '0',
+ synced_at int NOT NULL DEFAULT '0',
+ sum decimal(13,2) NOT NULL DEFAULT '0',
+ PRIMARY KEY (id)
+);
+
+INSERT INTO sales_documents
+(id, sale_id, type, order_number, data, created_at,
+ updated_at, date, generated, synced_at, sum)
+VALUES
+(555, 165, 3, 5, '{}', 1486538300, 1486722835, '2017-02-17', 0, 1486538313, 2320.00),
+(556, 165, 2, 3, '{}', 1486538304, 1486563125, '2017-02-08', 1, 1486538302, 2320.00),
+(557, 158, 2, 2, '{}', 1486538661, 1486538661, '2017-02-08', 0, 1486538660, 2320.00),
+(558, 171, 1, 3, '{}', 1486539104, 1488203405, '2017-02-08', 1, 1486539102, 23230.00),
+(559, 171, 2, 5, '{}', 1486549233, 1487146010, '2017-02-08', 1, 1486549225, 37690.00),
+(560, 172, 1, 1, '{}', 1486658260, 1488203409, '2017-02-09', 1, 1486658256, 40312.00),
+(561, 172, 2, 1, '{}', 1486711997, 1486711997, '2017-02-10', 1, 1486711996, 40312.00),
+(562, 172, 3, 1, '{}', 1486712104, 1486721395, '2017-02-10', 1, 1486712101, 40312.00),
+(563, 171, 3, 2, '{}', 1486712953, 1486720244, '2017-02-10', 1, 1486712910, 23230.00),
+(564, 170, 1, 2, '{}', 1486715948, 1488203410, '2017-02-10', 1, 1486715930, 28873.00),
+(565, 170, 3, 3, '{}', 1486716782, 1486717426, '2017-02-10', 1, 1486716779, 61948.00),
+(566, 166, 3, 4, '{}', 1486720947, 1486720947, '2017-02-10', 1, 1486720945, 4640.00),
+(567, 167, 3, 5, '{}', 1486722741, 1486722783, '2017-02-26', 0, 1486722738, 14755.00),
+(568, 165, 1, 4, '{}', 1486722849, 1486722849, '2017-02-10', 0, 1486722846, 2320.00),
+(569, 173, 2, 2, '{}', 1486723073, 1487071275, '2017-02-10', 1, 1486723071, 14282.00),
+(570, 173, 1, 4, '{}', 1486723100, 1488203412, '2017-02-10', 1, 1486723099, 14282.00),
+(571, 167, 2, 4, '{}', 1486730859, 1486730859, '2017-02-10', 1, 1486730856, 18655.00),
+(572, 167, 1, 5, '{}', 1486730883, 1488203412, '2017-02-10', 1, 1486730877, 18655.00),
+(573, 174, 2, 51, '{}', 1486731622, 1487060259, '2017-02-10', 1, 1486731620, 7140.00),
+(574, 174, 3, 5, '{}', 1486993472, 1486993472, '2017-02-13', 1, 1488216147, 28020.00),
+(575, 174, 1, 6, '{}', 1486993530, 1488203412, '2017-02-13', 1, 1486993505, 7140.00),
+(576, 173, 3, 6, '{}', 1487071425, 1487071425, '2017-02-14', 0, 1487071422, 14282.00),
+(577, 178, 2, 6, '{}', 1487327372, 1487327372, '2017-02-17', 1, 1487327370, 12321.00),
+(578, 177, 2, 7, '{}', 1487327394, 1487327394, '2017-02-17', 0, 1487327391, 4270.00),
+(579, 182, 3, 6, '{}', 1487750589, 1487751693, '2017-02-22', 1, 1487751688, 4270.00),
+(580, 182, 2, 7, '{}', 1487750601, 1487750663, '2017-02-22', 1, 1487750598, 4270.00),
+(581, 182, 1, 7, '{}', 1487750694, 1488203412, '2017-02-22', 1, 1487750692, 4270.00),
+(582, 185, 3, 7, '{}', 1487774051, 1487774051, '2017-02-22', 0, 1487774043, 8913.00),
+(583, 184, 3, 7, '{}', 1487774071, 1487774235, '2017-02-22', 0, 1487774093, 3285.00),
+(584, 184, 2, 8, '{}', 1487774074, 1487774074, '2017-02-22', 0, 1487774073, 3285.00),
+(585, 184, 1, 8, '{}', 1487774081, 1487774081, '2017-02-22', 0, 1487774075, 3285.00),
+(586, 193, 2, 8, '{}', 1487955294, 1487955318, '2017-02-24', 0, 1487955311, 4270.00),
+(587, 193, 1, 8, '{}', 1487955324, 1487955324, '2017-02-24', 0, 1487955320, 4270.00),
+(588, 193, 3, 7, '{}', 1487955341, 1487955341, '2017-02-24', 0, 1487955325, 4270.00),
+(589, 186, 1, 8, '{}', 1487957291, 1487957464, '2017-02-24', 0, 1487957459, 6960.00),
+(590, 186, 2, 8, '{}', 1487957308, 1487957468, '2017-02-24', 0, 1487957465, 6960.00),
+(591, 186, 3, 7, '{}', 1487957312, 1487957473, '2017-02-24', 0, 1487957469, 6960.00),
+(592, 194, 1, 8, '{}', 1488193293, 1488203412, '2017-02-27', 1, 1488193280, 2320.00),
+(593, 194, 2, 8, '{}', 1488193304, 1488193304, '2017-02-27', 1, 1488193303, 2320.00),
+(594, 210, 1, 9, '{}', 1488198896, 1488198896, '2017-02-27', 0, 1488198885, 4270.00),
+(595, 210, 2, 12, '{}', 1488198901, 1488198901, '2017-02-27', 1, 1488532585, 4270.00),
+(596, 210, 3, 10, '{}', 1488198904, 1488198904, '2017-02-27', 1, 1488532565, 4270.00),
+(597, 209, 2, 9, '{}', 1488200016, 1488450772, '2017-02-27', 1, 1488450449, 4270.00),
+(598, 209, 1, 9, '{}', 1488200020, 1488200063, '2017-02-27', 1, 1488200017, 4271.00),
+(599, 209, 3, 7, '{}', 1488200053, 1488200053, '2017-02-27', 0, 1488200021, 4271.00),
+(600, 211, 2, 10, '{}', 1488216265, 1489402027, '2017-02-27', 1, 1488216264, 2320.00),
+(601, 211, 3, 7, '{}', 1488216281, 1488216281, '2017-02-27', 1, 1488216276, 2320.00),
+(602, 211, 1, 10, '{}', 1488216283, 1488216283, '2017-02-27', 1, 1488216282, 2320.00),
+(603, 198, 2, 11, '{}', 1488280125, 1488280125, '2017-02-28', 0, 1488280095, 4270.00),
+(604, 198, 1, 11, '{}', 1488280160, 1488280160, '2017-02-28', 0, 1488280126, 4270.00),
+(605, 198, 3, 8, '{}', 1488280440, 1488280440, '2017-02-28', 0, 1488280435, 4270.00),
+(606, 212, 1, 12, '{}', 1488286301, 1489402168, '2017-02-28', 1, 1488286295, 13825.00),
+(607, 212, 3, 8, '{}', 1488289644, 1488289690, '2017-02-28', 1, 1488289642, 25295.00),
+(608, 212, 2, 13, '{}', 1488290350, 1488290431, '2017-02-28', 1, 1488290347, 13133.75),
+(609, 213, 1, 11, '{}', 1488529470, 1488529470, '2017-03-03', 1, 1488529461, 5660.00),
+(610, 213, 2, 11, '{}', 1488529484, 1488529484, '2017-03-03', 1, 1488529479, 5660.00),
+(611, 213, 3, 9, '{}', 1488529493, 1488529493, '2017-03-03', 1, 1488529489, 5660.00),
+(612, 197, 2, 13, '{}', 1489400715, 1489400715, '2017-03-13', 0, 1489398959, 4270.00),
+(613, 219, 3, 11, '{}', 1490084337, 1490181958, '2017-03-21', 1, 1490084334, 73526.00),
+(614, 216, 3, 11, '{}', 1490085757, 1490086717, '2017-03-21', 0, 1490085755, 5377.00);
+
+SELECT * FROM
+(SELECT @row := @row + 1 as row, a.* from (
+ SELECT t.order_number
+ FROM sales_documents t
+ WHERE
+ t.type = 2 AND
+ t.date >= '2017-01-01' AND
+ t.date <= '2017-12-31' AND
+ t.order_number IS NOT NULL AND
+ t.generated = 1
+ GROUP BY t.order_number
+) a, (SELECT @row := 0) r) t
+WHERE row <> order_number;
+
+DROP TABLE sales_documents;
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index 72b8681ac44..0fc8e97b284 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -274,3 +274,25 @@ insert into t1 values
('{"a":1,"b":2,"c":3}','$.c');
select j, p, json_remove(j, p) from t1;
drop table t1;
+
+#
+# MDEV-12364 Server crashes in __memcpy_sse2_unaligned / String::copy on JSON_SEARCH with variables.
+#
+SET @str = 'bar', @path = '$';
+SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
+
+#
+# MDEV-12351 Assertion `cur_step->type & JSON_PATH_KEY' failed in json_find_path.
+#
+
+SELECT JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]');
+
+#
+# MDEV-12363 Assertion `0' failed in Type_handler_string_result::make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*)
+#
+
+CREATE TABLE t1 (f INT NOT NULL);
+INSERT INTO t1 VALUES (0);
+SELECT JSON_KEYS(f) FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
diff --git a/mysql-test/t/keyread.test b/mysql-test/t/keyread.test
new file mode 100644
index 00000000000..d9d3002d392
--- /dev/null
+++ b/mysql-test/t/keyread.test
@@ -0,0 +1,10 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-12293 Assertion `table->no_keyread || !table->covering_keys.is_set(tab->index) || table->file->keyread == tab->index' failed
+#
+create table t1 (f1 int not null, f2 int, f3 int, primary key (f1,f2), key(f2,f3)) engine=innodb;
+create view v1 as select * from t1 where f2 = 1;
+select distinct f1 from v1;
+drop view v1;
+drop table t1;
diff --git a/mysql-test/t/loadxml.test b/mysql-test/t/loadxml.test
index 93e6e82189f..b26a2eacc00 100644
--- a/mysql-test/t/loadxml.test
+++ b/mysql-test/t/loadxml.test
@@ -130,3 +130,16 @@ CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 INTEGER);
LOAD XML INFILE '../../std_data/bug16171518_2.dat' INTO TABLE t1;
SELECT * FROM t1 ORDER BY col1, col2, col3;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-12696 Crash with LOAD XML and non-updatable VIEW column
+--echo #
+
+CREATE TABLE t1 (c1 TEXT);
+CREATE VIEW v1 AS SELECT CONCAT(c1,'') AS c1, NULL AS c2 FROM t1;
+--error ER_LOAD_DATA_INVALID_COLUMN
+LOAD XML INFILE '../../std_data/loaddata/mdev12696.xml' INTO TABLE v1 (c1);
+--error ER_LOAD_DATA_INVALID_COLUMN,
+LOAD XML INFILE '../../std_data/loaddata/mdev12696.xml' INTO TABLE v1 (c2);
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index ea08f540cf3..6d4e0e3f2b9 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -2582,3 +2582,15 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/bug11505.sql;
let SEARCH_PATTERN=Database: mysql;
exec $MYSQL_DUMP mysql func > $SEARCH_FILE;
source include/search_pattern_in_file.inc;
+
+--echo #
+--echo # Test for --add-drop-trigger
+--echo #
+use test;
+CREATE TABLE t1 (a int, b int);
+CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW
+ SET NEW.b=NEW.a + 10;
+
+INSERT INTO t1 (a) VALUES (1),(2),(3);
+--exec $MYSQL_DUMP --triggers --no-data --no-create-info --add-drop-trigger --skip-comments --databases test
+DROP TABLE t1;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index f2e0adf9d53..282013222de 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -6056,3 +6056,20 @@ DROP TABLE t1, t2;
SET NAMES default;
--echo End of 10.1 tests
+
+--echo #
+--echo # MDEV-12564: IN TO EXISTS transformation for rows after
+--echo # conversion an outer join to inner join
+--echo #
+
+CREATE TABLE t (
+pk int PRIMARY KEY, i int NOT NULL, c varchar(8), KEY(c)
+) ENGINE=MyISAM;
+INSERT INTO t VALUES (1,10,'foo'),(2,20,'bar');
+
+SELECT * FROM t t1 RIGHT JOIN t t2 ON (t2.pk = t1.pk)
+ WHERE (t2.i, t2.pk) NOT IN ( SELECT t3.i, t3.i FROM t t3, t t4 ) AND t1.c = 'foo';
+
+DROP TABLE t;
+
+--echo End of 10.2 tests
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 11924f696db..7c4af618c23 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -369,12 +369,18 @@ select @a;
--echo #
--echo # BUG LP:1008487 virtual bool Item_cache::is_expensive(): Assertion `example' failed
--echo #
+SET TIMESTAMP=UNIX_TIMESTAMP('2017-01-03 00:00:00');
create table t1(a date,key(a));
insert into t1 values ('2012-01-01'),('2012-02-02');
explain
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
+SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-03 00:00:01');
+explain
+select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
+select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
drop table t1;
+SET TIMESTAMP=DEFAULT;
--echo #
--echo # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
@@ -580,3 +586,22 @@ DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #
+
+--echo #
+--echo # Start of 10.3 tests
+--echo #
+
+--echo #
+--echo # MDEV-12721 Wrong execution plan for WHERE (date_field <=> timestamp_expr AND TRUE)
+--echo #
+CREATE TABLE t1(a DATE,KEY(a));
+INSERT INTO t1 VALUES ('2012-01-01'),('2012-02-02');
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP'2001-01-01 00:00:01' AND TRUE;
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP('2001-01-01', '00:00:01') AND TRUE;
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP'2001-01-01 00:00:00' AND TRUE;
+EXPLAIN SELECT 1 FROM t1 WHERE t1.a <=> TIMESTAMP('2001-01-01', '00:00:00') AND TRUE;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 82c1dadf5ad..95d32c5bd14 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -1856,3 +1856,24 @@ from
) q;
drop table t1;
+
+--echo #
+--echo # MDEV-11990: window function over min/max aggregation
+--echo #
+
+create table t1 (id int);
+insert into t1 values (1), (2), (3), (2), (4), (2);
+
+select sum(max(id)) over (order by max(id)) from t1;
+explain
+select sum(max(id)) over (order by max(id)) from t1;
+
+create index idx on t1(id);
+select sum(max(id)) over (order by max(id)) from t1;
+explain
+select sum(max(id)) over (order by max(id)) from t1;
+select sum(max(id)) over (order by max(id)) from t1 where id < 3;
+select count(max(id)) over (order by max(id)) from t1 where id < 3;
+select max(id), rank() over (order by max(id)) from t1 where id < 3;
+
+drop table t1;
diff --git a/plugin/user_variables/CMakeLists.txt b/plugin/user_variables/CMakeLists.txt
index b9ec7d18ba1..6638a5cb622 100644
--- a/plugin/user_variables/CMakeLists.txt
+++ b/plugin/user_variables/CMakeLists.txt
@@ -1 +1,2 @@
-MYSQL_ADD_PLUGIN(user_variables user_variables.cc)
+MYSQL_ADD_PLUGIN(user_variables user_variables.cc
+ DEFAULT RECOMPILE_FOR_EMBEDDED)
diff --git a/plugin/user_variables/mysql-test/user_variables/basic.result b/plugin/user_variables/mysql-test/user_variables/basic.result
index 02de31b5e09..5650fa0dcce 100644
--- a/plugin/user_variables/mysql-test/user_variables/basic.result
+++ b/plugin/user_variables/mysql-test/user_variables/basic.result
@@ -7,7 +7,7 @@ PLUGIN_AUTHOR Sergey Vojtovich
PLUGIN_DESCRIPTION User-defined variables
PLUGIN_LICENSE GPL
LOAD_OPTION ON
-PLUGIN_MATURITY Alpha
+PLUGIN_MATURITY Gamma
SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES;
Table Create Table
user_variables CREATE TEMPORARY TABLE `user_variables` (
diff --git a/plugin/user_variables/mysql-test/user_variables/suite.pm b/plugin/user_variables/mysql-test/user_variables/suite.pm
index ae757eedee4..b927bf40ecc 100644
--- a/plugin/user_variables/mysql-test/user_variables/suite.pm
+++ b/plugin/user_variables/mysql-test/user_variables/suite.pm
@@ -6,7 +6,8 @@ return "No USER_VARIABLES plugin" unless
$ENV{USER_VARIABLES_SO} or
$::mysqld_variables{'user-variables'} eq "ON";
-return "Not run for embedded server" if $::opt_embedded_server;
+return "Not run for embedded server" if $::opt_embedded_server and
+ $ENV{USER_VARIABLES_SO};
sub is_default { 1 }
diff --git a/plugin/user_variables/user_variables.cc b/plugin/user_variables/user_variables.cc
index 981c39cdb86..9190b2effb7 100644
--- a/plugin/user_variables/user_variables.cc
+++ b/plugin/user_variables/user_variables.cc
@@ -134,6 +134,6 @@ maria_declare_plugin(user_variables)
NULL,
NULL,
"1.0",
- MariaDB_PLUGIN_MATURITY_ALPHA
+ MariaDB_PLUGIN_MATURITY_GAMMA
}
maria_declare_plugin_end;
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index eb15b884481..e7f20e78a63 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -255,6 +255,7 @@ ELSE()
IF(WITH_WSREP)
SET(WSREP_SCRIPTS
wsrep_sst_mysqldump
+ wsrep_sst_common
wsrep_sst_rsync
wsrep_sst_xtrabackup
wsrep_sst_xtrabackup-v2
diff --git a/scripts/wsrep_sst_common b/scripts/wsrep_sst_common
index 466bb46b382..466bb46b382 100644..100755
--- a/scripts/wsrep_sst_common
+++ b/scripts/wsrep_sst_common
diff --git a/sql/field.cc b/sql/field.cc
index ebb7e1fa479..b0345788bf3 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1179,7 +1179,7 @@ bool Field::test_if_equality_guarantees_uniqueness(const Item *item) const
bool Field::can_be_substituted_to_equal_item(const Context &ctx,
const Item_equal *item_equal)
{
- DBUG_ASSERT(item_equal->compare_type() != STRING_RESULT);
+ DBUG_ASSERT(item_equal->compare_type_handler()->cmp_type() != STRING_RESULT);
DBUG_ASSERT(cmp_type() != STRING_RESULT);
switch (ctx.subst_constraint()) {
case ANY_SUBST:
@@ -1192,7 +1192,7 @@ bool Field::can_be_substituted_to_equal_item(const Context &ctx,
Items don't know the context they are in and there are functions like
IF (<hex_string>, 'yes', 'no').
*/
- return ctx.compare_type() == item_equal->compare_type();
+ return ctx.compare_type_handler() == item_equal->compare_type_handler();
case IDENTITY_SUBST:
return true;
}
@@ -1308,7 +1308,7 @@ Item *Field_num::get_equal_zerofill_const_item(THD *thd, const Context &ctx,
break;
}
DBUG_ASSERT(const_item->const_item());
- DBUG_ASSERT(ctx.compare_type() != STRING_RESULT);
+ DBUG_ASSERT(ctx.compare_type_handler()->cmp_type() != STRING_RESULT);
return const_item;
}
@@ -2013,11 +2013,11 @@ bool Field_str::test_if_equality_guarantees_uniqueness(const Item *item) const
bool Field_str::can_be_substituted_to_equal_item(const Context &ctx,
const Item_equal *item_equal)
{
- DBUG_ASSERT(item_equal->compare_type() == STRING_RESULT);
+ DBUG_ASSERT(item_equal->compare_type_handler()->cmp_type() == STRING_RESULT);
switch (ctx.subst_constraint()) {
case ANY_SUBST:
- return ctx.compare_type() == item_equal->compare_type() &&
- (ctx.compare_type() != STRING_RESULT ||
+ return ctx.compare_type_handler() == item_equal->compare_type_handler() &&
+ (ctx.compare_type_handler()->cmp_type() != STRING_RESULT ||
ctx.compare_collation() == item_equal->compare_collation());
case IDENTITY_SUBST:
return ((charset()->state & MY_CS_BINSORT) &&
@@ -5859,6 +5859,39 @@ int Field_time::store_decimal(const my_decimal *d)
}
+bool Field_time::can_be_substituted_to_equal_item(const Context &ctx,
+ const Item_equal *item_equal)
+{
+ DBUG_ASSERT(item_equal->compare_type_handler()->cmp_type() != STRING_RESULT);
+ switch (ctx.subst_constraint()) {
+ case ANY_SUBST:
+ /*
+ A TIME field in a DATETIME comparison can be substituted to
+ Item_equal with TIME comparison.
+
+ SET timestamp=UNIX_TIMESTAMP('2015-08-30 10:20:30');
+ CREATE OR REPLACE TABLE t1 (a TIME);
+ INSERT INTO t1 VALUES ('00:00:00'),('00:00:01');
+ SELECT * FROM t1 WHERE a>=TIMESTAMP'2015-08-30 00:00:00'
+ AND a='00:00:00';
+
+ The above query can be simplified to:
+ SELECT * FROM t1 WHERE TIME'00:00:00'>=TIMESTAMP'2015-08-30 00:00:00'
+ AND a='00:00:00';
+ And further to:
+ SELECT * FROM t1 WHERE a=TIME'00:00:00';
+ */
+ if (ctx.compare_type_handler() == &type_handler_datetime &&
+ item_equal->compare_type_handler() == &type_handler_time)
+ return true;
+ return ctx.compare_type_handler() == item_equal->compare_type_handler();
+ case IDENTITY_SUBST:
+ return true;
+ }
+ return false;
+}
+
+
Item *Field_time::get_equal_const_item(THD *thd, const Context &ctx,
Item *const_item)
{
diff --git a/sql/field.h b/sql/field.h
index 1333c924fa5..cdb80a5973a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -365,24 +365,25 @@ public:
Subst_constraint m_subst_constraint;
/*
Comparison type.
- Impostant only when ANY_SUBSTS.
+ Important only when ANY_SUBSTS.
*/
- Item_result m_compare_type;
+ const Type_handler *m_compare_handler;
/*
Collation of the comparison operation.
Important only when ANY_SUBST.
*/
CHARSET_INFO *m_compare_collation;
public:
- Context(Subst_constraint subst, Item_result type, CHARSET_INFO *cs)
+ Context(Subst_constraint subst, const Type_handler *h, CHARSET_INFO *cs)
:m_subst_constraint(subst),
- m_compare_type(type),
- m_compare_collation(cs) { }
+ m_compare_handler(h),
+ m_compare_collation(cs)
+ { DBUG_ASSERT(h == h->type_handler_for_comparison()); }
Subst_constraint subst_constraint() const { return m_subst_constraint; }
- Item_result compare_type() const
+ const Type_handler *compare_type_handler() const
{
DBUG_ASSERT(m_subst_constraint == ANY_SUBST);
- return m_compare_type;
+ return m_compare_handler;
}
CHARSET_INFO *compare_collation() const
{
@@ -394,12 +395,13 @@ public:
{ // Use this to request only exact value, no invariants.
public:
Context_identity()
- :Context(IDENTITY_SUBST, STRING_RESULT, &my_charset_bin) { }
+ :Context(IDENTITY_SUBST, &type_handler_long_blob, &my_charset_bin) { }
};
class Context_boolean: public Context
{ // Use this when an item is [a part of] a boolean expression
public:
- Context_boolean() :Context(ANY_SUBST, INT_RESULT, &my_charset_bin) { }
+ Context_boolean()
+ :Context(ANY_SUBST, &type_handler_longlong, &my_charset_bin) { }
};
};
@@ -2643,6 +2645,8 @@ public:
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), curdays(0)
{}
+ bool can_be_substituted_to_equal_item(const Context &ctx,
+ const Item_equal *item_equal);
const Type_handler *type_handler() const { return &type_handler_time; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
Copy_func *get_copy_func(const Field *from) const
diff --git a/sql/handler.h b/sql/handler.h
index ef4b66a8311..98269118bea 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2899,10 +2899,9 @@ public:
bool keyread_enabled() { return keyread < MAX_KEY; }
int ha_start_keyread(uint idx)
{
- if (keyread_enabled())
- return 0;
+ int res= keyread_enabled() ? 0 : extra(HA_EXTRA_KEYREAD);
keyread= idx;
- return extra(HA_EXTRA_KEYREAD);
+ return res;
}
int ha_end_keyread()
{
diff --git a/sql/item.cc b/sql/item.cc
index adb40ee3e4e..e775862ca3a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -972,6 +972,13 @@ bool Item_field::check_field_expression_processor(void *arg)
Field *org_field= (Field*) arg;
if (field->flags & NO_DEFAULT_VALUE_FLAG)
return 0;
+ if (field->flags & AUTO_INCREMENT_FLAG)
+ {
+ my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD,
+ MYF(0),
+ org_field->field_name.str, field->field_name.str);
+ return 1;
+ }
if ((field->default_value && field->default_value->flags) || field->vcol_info)
{
if (field == org_field ||
@@ -1687,7 +1694,7 @@ CALL p1();
bool Item_splocal::check_cols(uint n)
{
DBUG_ASSERT(m_thd->spcont);
- if (cmp_type() != ROW_RESULT)
+ if (Type_handler_hybrid_field_type::cmp_type() != ROW_RESULT)
return Item::check_cols(n);
if (n != this_item()->cols() || n == 1)
@@ -3504,7 +3511,7 @@ Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg):
Item_basic_value(thd),
Rewritable_query_parameter(pos_in_query_arg, len_in_query_arg),
- Type_handler_hybrid_field_type(MYSQL_TYPE_VARCHAR),
+ Type_handler_hybrid_field_type(&type_handler_varchar),
state(NO_VALUE),
/* Don't pretend to be a literal unless value for this item is set. */
item_type(PARAM_ITEM),
@@ -3786,11 +3793,11 @@ bool Item_param::set_from_item(THD *thd, Item *item)
switch (item->cmp_type()) {
case REAL_RESULT:
set_double(tmp.value.m_double);
- set_handler_by_field_type(MYSQL_TYPE_DOUBLE);
+ set_handler(&type_handler_double);
break;
case INT_RESULT:
set_int(tmp.value.m_longlong, MY_INT64_NUM_DECIMAL_DIGITS);
- set_handler_by_field_type(MYSQL_TYPE_LONGLONG);
+ set_handler(&type_handler_longlong);
break;
case STRING_RESULT:
{
@@ -3799,7 +3806,7 @@ bool Item_param::set_from_item(THD *thd, Item *item)
Exact value of max_length is not known unless data is converted to
charset of connection, so we have to set it later.
*/
- set_handler_by_field_type(MYSQL_TYPE_VARCHAR);
+ set_handler(&type_handler_varchar);
if (set_str(tmp.m_string.ptr(), tmp.m_string.length()))
DBUG_RETURN(1);
@@ -3808,7 +3815,7 @@ bool Item_param::set_from_item(THD *thd, Item *item)
case DECIMAL_RESULT:
{
set_decimal(&tmp.m_decimal, unsigned_flag);
- set_handler_by_field_type(MYSQL_TYPE_NEWDECIMAL);
+ set_handler(&type_handler_newdecimal);
break;
}
case TIME_RESULT:
@@ -6024,7 +6031,8 @@ Item *Item_field::replace_equal_field(THD *thd, uchar *arg)
comparison context, and it's safe to replace it to the constant from
item_equal.
*/
- DBUG_ASSERT(cmp_type() == item_equal->compare_type());
+ DBUG_ASSERT(type_handler()->type_handler_for_comparison()->cmp_type() ==
+ item_equal->compare_type_handler()->cmp_type());
return const_item2;
}
Item_field *subst=
@@ -6064,7 +6072,7 @@ void Item::make_field(THD *thd, Send_field *tmp_field)
void Item_empty_string::make_field(THD *thd, Send_field *tmp_field)
{
- init_make_field(tmp_field, string_field_type());
+ init_make_field(tmp_field, string_type_handler()->field_type());
}
@@ -9094,101 +9102,14 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
Item *item= *ref;
if (item->basic_const_item())
return; // Can't be better
-
- Item *new_item= NULL;
- Item_result res_type= item_cmp_type(comp_item, item);
- const char *name= item->name.str; // Alloced on THD::mem_root
- MEM_ROOT *mem_root= thd->mem_root;
-
- switch (res_type) {
- case TIME_RESULT:
+ Type_handler_hybrid_field_type cmp(comp_item->type_handler_for_comparison());
+ if (!cmp.aggregate_for_comparison(item->type_handler_for_comparison()))
{
- bool is_null;
- Item **ref_copy= ref;
- /* the following call creates a constant and puts it in new_item */
- enum_field_types type= item->field_type_for_temporal_comparison(comp_item);
- get_datetime_value(thd, &ref_copy, &new_item, type, &is_null);
- if (is_null)
- new_item= new (mem_root) Item_null(thd, name);
- break;
- }
- case STRING_RESULT:
- {
- char buff[MAX_FIELD_WIDTH];
- String tmp(buff,sizeof(buff),&my_charset_bin),*result;
- result=item->val_str(&tmp);
- if (item->null_value)
- new_item= new (mem_root) Item_null(thd, name);
- else
- {
- uint length= result->length();
- char *tmp_str= thd->strmake(result->ptr(), length);
- new_item= new (mem_root) Item_string(thd, name, tmp_str, length, result->charset());
- }
- break;
- }
- case INT_RESULT:
- {
- longlong result=item->val_int();
- uint length=item->max_length;
- bool null_value=item->null_value;
- new_item= (null_value ? (Item*) new (mem_root) Item_null(thd, name) :
- (Item*) new (mem_root) Item_int(thd, name, result, length));
- break;
- }
- case ROW_RESULT:
- if (item->type() == Item::ROW_ITEM && comp_item->type() == Item::ROW_ITEM)
- {
- /*
- Substitute constants only in Item_row's. Don't affect other Items
- with ROW_RESULT (eg Item_singlerow_subselect).
-
- For such Items more optimal is to detect if it is constant and replace
- it with Item_row. This would optimize queries like this:
- SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1);
- */
- Item_row *item_row= (Item_row*) item;
- Item_row *comp_item_row= (Item_row*) comp_item;
- uint col;
- new_item= 0;
- /*
- If item and comp_item are both Item_row's and have same number of cols
- then process items in Item_row one by one.
- We can't ignore NULL values here as this item may be used with <=>, in
- which case NULL's are significant.
- */
- DBUG_ASSERT(item->result_type() == comp_item->result_type());
- DBUG_ASSERT(item_row->cols() == comp_item_row->cols());
- col= item_row->cols();
- while (col-- > 0)
- resolve_const_item(thd, item_row->addr(col),
- comp_item_row->element_index(col));
- break;
- }
- /* Fallthrough */
- case REAL_RESULT:
- { // It must REAL_RESULT
- double result= item->val_real();
- uint length=item->max_length,decimals=item->decimals;
- bool null_value=item->null_value;
- new_item= (null_value ? (Item*) new (mem_root) Item_null(thd, name) : (Item*)
- new (mem_root) Item_float(thd, name, result, decimals, length));
- break;
- }
- case DECIMAL_RESULT:
- {
- my_decimal decimal_value;
- my_decimal *result= item->val_decimal(&decimal_value);
- uint length= item->max_length, decimals= item->decimals;
- bool null_value= item->null_value;
- new_item= (null_value ?
- (Item*) new (mem_root) Item_null(thd, name) :
- (Item*) new (mem_root) Item_decimal(thd, name, result, length, decimals));
- break;
- }
+ Item *new_item= cmp.type_handler()->
+ make_const_item_for_comparison(thd, item, comp_item);
+ if (new_item)
+ thd->change_item_tree(ref, new_item);
}
- if (new_item)
- thd->change_item_tree(ref, new_item);
}
/**
@@ -9297,27 +9218,24 @@ void Item_cache::store(Item *item)
void Item_cache::print(String *str, enum_query_type query_type)
{
if (example && // There is a cached item
- (query_type & QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS)) // Caller is show-create-table
+ (query_type & QT_NO_DATA_EXPANSION)) // Caller is show-create-table
{
// Instead of "cache" or the cached value, print the cached item name
example->print(str, query_type);
+ return;
}
- else
+
+ if (value_cached)
{
- if (value_cached && !(query_type & QT_NO_DATA_EXPANSION))
- {
- print_value(str);
- return;
- }
- if (!(query_type & QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS))
- str->append(STRING_WITH_LEN("<cache>("));
- if (example)
- example->print(str, query_type);
- else
- Item::print(str, query_type);
- if (!(query_type & QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS))
- str->append(')');
+ print_value(str);
+ return;
}
+ str->append(STRING_WITH_LEN("<cache>("));
+ if (example)
+ example->print(str, query_type);
+ else
+ Item::print(str, query_type);
+ str->append(')');
}
/**
@@ -9405,9 +9323,8 @@ Item *Item_cache_int::convert_to_basic_const_item(THD *thd)
}
-Item_cache_temporal::Item_cache_temporal(THD *thd,
- enum_field_types field_type_arg):
- Item_cache_int(thd, field_type_arg)
+Item_cache_temporal::Item_cache_temporal(THD *thd, const Type_handler *handler)
+ :Item_cache_int(thd, handler)
{
if (mysql_timestamp_type() == MYSQL_TIMESTAMP_ERROR)
set_handler(&type_handler_datetime2);
@@ -9553,7 +9470,7 @@ void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg)
Item *Item_cache_temporal::clone_item(THD *thd)
{
Item_cache_temporal *item= new (thd->mem_root)
- Item_cache_temporal(thd, Item_cache_temporal::field_type());
+ Item_cache_temporal(thd, Item_cache_temporal::type_handler());
item->store_packed(value, example);
return item;
}
@@ -9923,7 +9840,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item)
DBUG_ASSERT(item->fixed);
maybe_null= item->maybe_null;
get_full_info(item);
- DBUG_ASSERT(!decimals || Item_type_holder::result_type() != INT_RESULT);
+ DBUG_ASSERT(!decimals || result_type() != INT_RESULT);
prev_decimal_int_part= item->decimal_int_part();
}
@@ -9972,14 +9889,14 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
which is on the right side of the UNION, the data type handler
changes to type_handler_longlong, while decimals is still NOT_FIXED_DEC.
*/
- if (Item_type_holder::result_type() == INT_RESULT)
+ if (result_type() == INT_RESULT)
decimals= 0;
else
decimals= MY_MAX(decimals, item->decimals);
Type_geometry_attributes::join(item);
- if (Item_type_holder::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
int item_int_part= item->decimal_int_part();
@@ -9991,7 +9908,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
unsigned_flag);
}
- switch (Item_type_holder::result_type())
+ switch (result_type())
{
case STRING_RESULT:
{
@@ -10366,8 +10283,7 @@ void Virtual_column_info::print(String *str)
(enum_query_type)(QT_ITEM_ORIGINAL_FUNC_NULLIF |
QT_ITEM_IDENT_SKIP_DB_NAMES |
QT_ITEM_IDENT_SKIP_TABLE_NAMES |
- QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS |
- QT_TO_SYSTEM_CHARSET |
- QT_NO_DATA_EXPANSION),
+ QT_NO_DATA_EXPANSION |
+ QT_TO_SYSTEM_CHARSET),
LOWEST_PRECEDENCE);
}
diff --git a/sql/item.h b/sql/item.h
index 76ff7ced80a..ad34320c560 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -337,6 +337,19 @@ typedef struct replace_equal_field_arg
struct st_join_table *context_tab;
} REPLACE_EQUAL_FIELD_ARG;
+
+class Load_data_out_param
+{
+public:
+ Load_data_out_param() { }
+ virtual ~Load_data_out_param() { }
+ virtual void load_data_set_null_value(CHARSET_INFO *cs) = 0;
+ virtual void load_data_set_value(const char *str, uint length,
+ CHARSET_INFO *cs) = 0;
+ virtual void load_data_print(THD *thd, String *str) = 0;
+};
+
+
class Settable_routine_parameter
{
public:
@@ -715,10 +728,14 @@ public:
return type_handler()->Item_send(this, protocol, buffer);
}
virtual bool eq(const Item *, bool binary_cmp) const;
- virtual enum_field_types field_type() const= 0;
- virtual const Type_handler *type_handler() const
+ enum_field_types field_type() const
+ {
+ return type_handler()->field_type();
+ }
+ virtual const Type_handler *type_handler() const= 0;
+ const Type_handler *type_handler_for_comparison() const
{
- return Type_handler::get_handler_by_field_type(field_type());
+ return type_handler()->type_handler_for_comparison();
}
virtual const Type_handler *real_type_handler() const
{
@@ -729,18 +746,18 @@ public:
return type_handler();
}
/* result_type() of an item specifies how the value should be returned */
- virtual Item_result result_type() const
+ Item_result result_type() const
{
return type_handler()->result_type();
}
/* ... while cmp_type() specifies how it should be compared */
- virtual Item_result cmp_type() const
+ Item_result cmp_type() const
{
return type_handler()->cmp_type();
}
- enum_field_types string_field_type() const
+ const Type_handler *string_type_handler() const
{
- return Type_handler::string_type_handler(max_length)->field_type();
+ return Type_handler::string_type_handler(max_length);
}
/*
Calculate the maximum length of an expression.
@@ -1304,23 +1321,6 @@ public:
return f_type == MYSQL_TYPE_TIME ? val_time_packed() :
val_datetime_packed();
}
- enum_field_types field_type_for_temporal_comparison(const Item *other) const
- {
- if (cmp_type() == TIME_RESULT)
- {
- if (other->cmp_type() == TIME_RESULT)
- return Field::field_type_merge(field_type(), other->field_type());
- else
- return field_type();
- }
- else
- {
- if (other->cmp_type() == TIME_RESULT)
- return other->field_type();
- DBUG_ASSERT(0); // Two non-temporal data types, we should not get to here
- return MYSQL_TYPE_DATETIME;
- }
- }
bool get_seconds(ulonglong *sec, ulong *sec_part);
virtual bool get_date_result(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ return get_date(ltime,fuzzydate); }
@@ -1604,7 +1604,7 @@ public:
virtual Item **this_item_addr(THD *thd, Item **addr_arg) { return addr_arg; }
// Row emulation
- virtual uint cols() { return 1; }
+ virtual uint cols() const { return 1; }
virtual Item* element_index(uint i) { return this; }
virtual bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const
{
@@ -1690,6 +1690,14 @@ public:
delete this;
}
+ virtual Load_data_out_param *get_load_data_out_param() { return 0; }
+ Load_data_out_param *get_load_data_out_param_or_error()
+ {
+ Load_data_out_param *res= get_load_data_out_param();
+ if (!res)
+ my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), full_name());
+ return res;
+ }
virtual Item_splocal *get_item_splocal() { return 0; }
virtual Rewritable_query_parameter *get_rewritable_query_parameter()
{ return 0; }
@@ -2222,13 +2230,7 @@ public:
inline enum Type type() const;
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
- uint cols() { return this_item()->cols(); }
+ uint cols() const { return this_item()->cols(); }
Item* element_index(uint i) { return this_item()->element_index(i); }
Item** addr(uint i) { return this_item()->addr(i); }
bool check_cols(uint c);
@@ -2385,8 +2387,7 @@ public:
Item **this_item_addr(THD *thd, Item **);
inline enum Type type() const;
- inline Item_result result_type() const;
- enum_field_types field_type() const { return this_item()->field_type(); }
+ const Type_handler *type_handler() const { return this_item()->type_handler(); }
public:
/*
@@ -2410,12 +2411,6 @@ inline enum Item::Type Item_case_expr::type() const
return this_item()->type();
}
-inline Item_result Item_case_expr::result_type() const
-{
- return this_item()->result_type();
-}
-
-
/*
NAME_CONST(given_name, const_value).
This 'function' has all properties of the supplied const_value (which is
@@ -2448,14 +2443,9 @@ public:
bool is_null();
virtual void print(String *str, enum_query_type query_type);
- enum_field_types field_type() const
- {
- return value_item->field_type();
- }
-
- Item_result result_type() const
+ const Type_handler *type_handler() const
{
- return value_item->result_type();
+ return value_item->type_handler();
}
bool const_item() const
@@ -2608,7 +2598,11 @@ public:
String *val_str(String *str) { return field->val_str(str); }
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
void make_field(THD *thd, Send_field *tmp_field);
- enum_field_types field_type() const { return field->type(); }
+ const Type_handler *type_handler() const
+ {
+ const Type_handler *handler= field->type_handler();
+ return handler->type_handler_for_item_field();
+ }
Item* get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_ident_for_show>(thd, mem_root, this); }
};
@@ -2675,18 +2669,10 @@ public:
const Type_handler *handler= field->type_handler();
return handler->type_handler_for_item_field();
}
- enum Item_result result_type () const
- {
- return field->result_type();
- }
const Type_handler *cast_to_int_type_handler() const
{
return field->type_handler()->cast_to_int_type_handler();
}
- enum_field_types field_type() const
- {
- return field->type();
- }
const Type_handler *real_type_handler() const
{
if (field->is_created_from_null_item)
@@ -2826,9 +2812,7 @@ public:
{ return get_item_copy<Item_field_row>(thd, mem_root, this); }
const Type_handler *type_handler() const { return &type_handler_row; }
- Item_result result_type() const{ return ROW_RESULT ; }
- Item_result cmp_type() const { return ROW_RESULT; }
- uint cols() { return arg_count; }
+ uint cols() const { return arg_count; }
bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const;
Item* element_index(uint i) { return arg_count ? args[i] : this; }
Item** addr(uint i) { return arg_count ? args + i : NULL; }
@@ -2906,8 +2890,7 @@ public:
int save_in_field(Field *field, bool no_conversions);
int save_safe_in_field(Field *field);
bool send(Protocol *protocol, st_value *buffer);
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
+ const Type_handler *type_handler() const { return &type_handler_null; }
bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd);
bool is_null() { return 1; }
@@ -3086,12 +3069,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg);
@@ -3226,11 +3203,6 @@ public:
}
Item_int(THD *thd, const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const
- {
- return Item_int::type_handler()->field_type();
- }
const Type_handler *type_handler() const
{
// The same condition is repeated in Item::create_tmp_field()
@@ -3322,8 +3294,7 @@ public:
Item_decimal(THD *thd, const uchar *bin, int precision, int scale);
enum Type type() const { return DECIMAL_ITEM; }
- enum Item_result result_type () const { return DECIMAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
+ const Type_handler *type_handler() const { return &type_handler_newdecimal; }
longlong val_int();
double val_real();
String *val_str(String*);
@@ -3364,7 +3335,7 @@ public:
}
int save_in_field(Field *field, bool no_conversions);
enum Type type() const { return REAL_ITEM; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
double val_real() { DBUG_ASSERT(fixed == 1); return value; }
longlong val_int()
{
@@ -3503,8 +3474,7 @@ public:
}
my_decimal *val_decimal(my_decimal *);
int save_in_field(Field *field, bool no_conversions);
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
+ const Type_handler *type_handler() const { return &type_handler_varchar; }
bool basic_const_item() const { return 1; }
bool eq(const Item *item, bool binary_cmp) const
{
@@ -3689,7 +3659,10 @@ public:
Item_partition_func_safe_string(thd, name_arg, length_arg, &my_charset_bin),
date_time_field_type(field_type_arg)
{ decimals= 0; }
- enum_field_types field_type() const { return date_time_field_type; }
+ const Type_handler *type_handler() const
+ {
+ return Type_handler::get_handler_by_field_type(date_time_field_type);
+ }
};
@@ -3700,10 +3673,6 @@ public:
Item_partition_func_safe_string(thd, name_arg, safe_strlen(name_arg), &my_charset_bin)
{ max_length= length; }
enum Type type() const { return TYPE_HOLDER; }
- enum_field_types field_type() const
- {
- return Item_blob::type_handler()->field_type();
- }
const Type_handler *type_handler() const
{
return Type_handler::blob_type_handler(max_length);
@@ -3751,7 +3720,6 @@ public:
{
unsigned_flag=1;
}
- enum_field_types field_type() const { return int_field_type; }
const Type_handler *type_handler() const
{
return Type_handler::get_handler_by_field_type(int_field_type);
@@ -3777,8 +3745,7 @@ public:
hex_string_init(thd, str, str_length);
}
enum Type type() const { return VARBIN_ITEM; }
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
+ const Type_handler *type_handler() const { return &type_handler_varchar; }
virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
return const_charset_converter(thd, tocs, true);
@@ -3914,8 +3881,6 @@ public:
bool const_item() const { return true; }
enum Type type() const { return DATE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
- enum Item_result result_type () const { return STRING_RESULT; }
- Item_result cmp_type() const { return TIME_RESULT; }
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -3955,7 +3920,7 @@ public:
*/
maybe_null= !ltime->month || !ltime->day;
}
- enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
+ const Type_handler *type_handler() const { return &type_handler_newdate; }
void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
@@ -3976,7 +3941,7 @@ public:
max_length= MIN_TIME_WIDTH + (decimals ? decimals + 1 : 0);
fixed= 1;
}
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
+ const Type_handler *type_handler() const { return &type_handler_time2; }
void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
@@ -3999,7 +3964,7 @@ public:
// See the comment on maybe_null in Item_date_literal
maybe_null= !ltime->month || !ltime->day;
}
- enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
+ const Type_handler *type_handler() const { return &type_handler_datetime2; }
void print(String *str, enum_query_type query_type);
Item *clone_item(THD *thd);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
@@ -4313,8 +4278,7 @@ public:
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
fast_field_copier setup_fast_field_copier(Field *field)
{ return (*ref)->setup_fast_field_copier(field); }
- enum Item_result result_type () const { return (*ref)->result_type(); }
- enum_field_types field_type() const { return (*ref)->field_type(); }
+ const Type_handler *type_handler() const { return (*ref)->type_handler(); }
const Type_handler *real_type_handler() const
{ return (*ref)->real_type_handler(); }
Field *get_tmp_table_field()
@@ -4382,7 +4346,7 @@ public:
virtual Ref_Type ref_type() { return REF; }
// Row emulation: forwarding of ROW-related calls to ref
- uint cols()
+ uint cols() const
{
return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
}
@@ -4610,8 +4574,7 @@ public:
orig_item->fix_after_pullout(new_parent, &orig_item);
}
int save_in_field(Field *to, bool no_conversions);
- enum Item_result result_type () const { return orig_item->result_type(); }
- enum_field_types field_type() const { return orig_item->field_type(); }
+ const Type_handler *type_handler() const { return orig_item->type_handler(); }
table_map used_tables() const { return orig_item->used_tables(); }
void update_used_tables()
{
@@ -4630,7 +4593,7 @@ public:
{ return orig_item->field_for_view_update(); }
/* Row emulation: forwarding of ROW-related calls to orig_item */
- uint cols()
+ uint cols() const
{ return result_type() == ROW_RESULT ? orig_item->cols() : 1; }
Item* element_index(uint i)
{ return result_type() == ROW_RESULT ? orig_item->element_index(i) : this; }
@@ -5003,7 +4966,7 @@ protected:
null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item);
name= item->name;
- set_handler_by_field_type(item->field_type());
+ set_handler(item->type_handler());
fixed= item->fixed;
}
@@ -5031,12 +4994,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); }
table_map used_tables() const { return (table_map) 1L; }
@@ -5529,7 +5486,7 @@ protected:
public:
Item_cache(THD *thd):
Item_basic_constant(thd),
- Type_handler_hybrid_field_type(MYSQL_TYPE_STRING),
+ Type_handler_hybrid_field_type(&type_handler_string),
example(0), cached_field(0),
value_cached(0)
{
@@ -5538,9 +5495,9 @@ public:
null_value= 1;
}
protected:
- Item_cache(THD *thd, enum_field_types field_type_arg):
+ Item_cache(THD *thd, const Type_handler *handler):
Item_basic_constant(thd),
- Type_handler_hybrid_field_type(field_type_arg),
+ Type_handler_hybrid_field_type(handler),
example(0), cached_field(0),
value_cached(0)
{
@@ -5563,12 +5520,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
virtual void keep_array() {}
virtual void print(String *str, enum_query_type query_type);
@@ -5586,17 +5537,16 @@ public:
{
Item::vcol_func_processor_result *res= (Item::vcol_func_processor_result*)arg;
example->check_vcol_func_processor(arg);
+ /*
+ Item_cache of a non-deterministic function requires re-fixing
+ even if the function itself doesn't (e.g. CURRENT_TIMESTAMP)
+ */
if (res->errors & VCOL_NOT_STRICTLY_DETERMINISTIC)
res->errors|= VCOL_SESSION_FUNC;
return false;
}
return mark_unsupported_function("cache", arg, VCOL_IMPOSSIBLE);
}
- bool cleanup_excluding_fields_processor(void* arg)
- {
- cleanup();
- return 0;
- }
void cleanup()
{
clear();
@@ -5661,16 +5611,15 @@ class Item_cache_int: public Item_cache
protected:
longlong value;
public:
- Item_cache_int(THD *thd): Item_cache(thd, MYSQL_TYPE_LONGLONG),
+ Item_cache_int(THD *thd): Item_cache(thd, &type_handler_longlong),
value(0) {}
- Item_cache_int(THD *thd, enum_field_types field_type_arg):
- Item_cache(thd, field_type_arg), value(0) {}
+ Item_cache_int(THD *thd, const Type_handler *handler):
+ Item_cache(thd, handler), value(0) {}
double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return INT_RESULT; }
bool cache_value();
int save_in_field(Field *field, bool no_conversions);
Item *convert_to_basic_const_item(THD *thd);
@@ -5682,7 +5631,7 @@ public:
class Item_cache_temporal: public Item_cache_int
{
public:
- Item_cache_temporal(THD *thd, enum_field_types field_type_arg);
+ Item_cache_temporal(THD *thd, const Type_handler *handler);
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
longlong val_int();
@@ -5692,7 +5641,6 @@ public:
bool cache_value();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
int save_in_field(Field *field, bool no_conversions);
- Item_result cmp_type() const { return TIME_RESULT; }
void store_packed(longlong val_arg, Item *example);
/*
Having a clone_item method tells optimizer that this object
@@ -5710,14 +5658,13 @@ class Item_cache_real: public Item_cache
{
double value;
public:
- Item_cache_real(THD *thd): Item_cache(thd, MYSQL_TYPE_DOUBLE),
+ Item_cache_real(THD *thd): Item_cache(thd, &type_handler_double),
value(0) {}
double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return REAL_RESULT; }
bool cache_value();
Item *convert_to_basic_const_item(THD *thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -5730,13 +5677,12 @@ class Item_cache_decimal: public Item_cache
protected:
my_decimal decimal_value;
public:
- Item_cache_decimal(THD *thd): Item_cache(thd, MYSQL_TYPE_NEWDECIMAL) {}
+ Item_cache_decimal(THD *thd): Item_cache(thd, &type_handler_newdecimal) {}
double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return DECIMAL_RESULT; }
bool cache_value();
Item *convert_to_basic_const_item(THD *thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -5752,7 +5698,7 @@ class Item_cache_str: public Item_cache
public:
Item_cache_str(THD *thd, const Item *item):
- Item_cache(thd, item->field_type()), value(0),
+ Item_cache(thd, item->type_handler()), value(0),
is_varbinary(item->type() == FIELD_ITEM &&
Item_cache_str::field_type() == MYSQL_TYPE_VARCHAR &&
!((const Item_field *) item)->field->has_charset())
@@ -5763,7 +5709,6 @@ public:
longlong val_int();
String* val_str(String *);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return STRING_RESULT; }
CHARSET_INFO *charset() const { return value->charset(); };
int save_in_field(Field *field, bool no_conversions);
bool cache_value();
@@ -5845,9 +5790,7 @@ public:
return 0;
};
- enum Item_result result_type() const { return ROW_RESULT; }
-
- uint cols() { return item_count; }
+ uint cols() const { return item_count; }
Item *element_index(uint i) { return values[i]; }
Item **addr(uint i) { return (Item **) (values + i); }
bool check_cols(uint c);
@@ -5896,24 +5839,6 @@ public:
const Type_handler *handler= Type_handler_hybrid_field_type::type_handler();
return handler->type_handler_for_item_field();
}
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- {
- /*
- In 10.1 Item_type_holder::result_type() returned
- Field::result_merge_type(field_type()), which returned STRING_RESULT
- for the BIT data type. In 10.2 it returns INT_RESULT, similar
- to what Field_bit::result_type() does. This should not be
- important because Item_type_holder is a limited purpose Item
- and its result_type() should not be called from outside of
- Item_type_holder. It's called only internally from decimal_int_part()
- from join_types(), to calculate "decimals" of the result data type.
- As soon as we get BIT as one of the joined types, the result field
- type cannot be numeric: it's either BIT, or VARBINARY.
- */
- return Type_handler_hybrid_field_type::result_type();
- }
const Type_handler *real_type_handler() const
{
return Type_handler_hybrid_field_type::type_handler();
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index faf8f23ffa1..891a0c0f594 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -552,20 +552,20 @@ bool Arg_comparator::set_cmp_func_string()
}
-bool Arg_comparator::set_cmp_func_temporal()
+bool Arg_comparator::set_cmp_func_time()
{
- enum_field_types f_type= a[0]->field_type_for_temporal_comparison(b[0]);
m_compare_collation= &my_charset_numeric;
- if (f_type == MYSQL_TYPE_TIME)
- {
- func= is_owner_equal_func() ? &Arg_comparator::compare_e_time :
- &Arg_comparator::compare_time;
- }
- else
- {
- func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :
- &Arg_comparator::compare_datetime;
- }
+ func= is_owner_equal_func() ? &Arg_comparator::compare_e_time :
+ &Arg_comparator::compare_time;
+ return false;
+}
+
+
+bool Arg_comparator::set_cmp_func_datetime()
+{
+ m_compare_collation= &my_charset_numeric;
+ func= is_owner_equal_func() ? &Arg_comparator::compare_e_datetime :
+ &Arg_comparator::compare_datetime;
return false;
}
@@ -735,8 +735,8 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
{
if (!thd)
thd= current_thd;
-
- Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, f_type);
+ const Type_handler *h= Type_handler::get_handler_by_field_type(f_type);
+ Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, h);
cache->store_packed(value, item);
*cache_arg= cache;
*item_arg= cache_arg;
@@ -2082,7 +2082,7 @@ longlong Item_func_between::val_int_cmp_temporal()
bool value_is_null, a_is_null, b_is_null;
ptr= &args[0];
- enum_field_types f_type= m_comparator.field_type();
+ enum_field_types f_type= m_comparator.type_handler()->field_type();
value= get_datetime_value(thd, &ptr, &cache, f_type, &value_is_null);
if (ptr != &args[0])
thd->change_item_tree(&args[0], *ptr);
@@ -2791,7 +2791,7 @@ Item_func_case::Item_func_case(THD *thd, List<Item> &list,
Item_func_case_expression(thd),
Predicant_to_list_comparator(thd, list.elements/*QQ*/),
first_expr_num(-1), else_expr_num(-1),
- left_cmp_type(INT_RESULT), m_found_types(0)
+ m_found_types(0)
{
ncases= list.elements;
if (first_expr_arg)
@@ -3057,7 +3057,6 @@ void Item_func_case::fix_length_and_dec()
}
agg[0]= args[first_expr_num];
- left_cmp_type= agg[0]->cmp_type();
/*
As the first expression and WHEN expressions
@@ -3119,6 +3118,7 @@ void Item_func_case::fix_length_and_dec()
Item* Item_func_case::propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
{
+ const Type_handler *first_expr_cmp_handler;
if (first_expr_num == -1)
{
// None of the arguments are in a comparison context
@@ -3126,6 +3126,7 @@ Item* Item_func_case::propagate_equal_fields(THD *thd, const Context &ctx, COND_
return this;
}
+ first_expr_cmp_handler= args[first_expr_num]->type_handler_for_comparison();
for (uint i= 0; i < arg_count; i++)
{
/*
@@ -3164,11 +3165,11 @@ Item* Item_func_case::propagate_equal_fields(THD *thd, const Context &ctx, COND_
WHEN 'str2' THEN TRUE
ELSE FALSE END;
*/
- if (m_found_types == (1UL << left_cmp_type))
+ if (m_found_types == (1UL << first_expr_cmp_handler->cmp_type()))
new_item= args[i]->propagate_equal_fields(thd,
Context(
ANY_SUBST,
- left_cmp_type,
+ first_expr_cmp_handler,
cmp_collation.collation),
cond);
}
@@ -3181,13 +3182,14 @@ Item* Item_func_case::propagate_equal_fields(THD *thd, const Context &ctx, COND_
replaced to zero-filled constants (only IDENTITY_SUBST allows this).
Such a change for WHEN arguments would require rebuilding cmp_items.
*/
- Item_result tmp_cmp_type= item_cmp_type(args[first_expr_num], args[i]);
- new_item= args[i]->propagate_equal_fields(thd,
- Context(
- ANY_SUBST,
- tmp_cmp_type,
- cmp_collation.collation),
- cond);
+ Type_handler_hybrid_field_type tmp(first_expr_cmp_handler);
+ if (!tmp.aggregate_for_comparison(args[i]->type_handler_for_comparison()))
+ new_item= args[i]->propagate_equal_fields(thd,
+ Context(
+ ANY_SUBST,
+ tmp.type_handler(),
+ cmp_collation.collation),
+ cond);
}
else // THEN and ELSE arguments (they are not in comparison)
{
@@ -6019,10 +6021,11 @@ Item *Item_bool_rowready_func2::negated_item(THD *thd)
of the type Item_field or Item_direct_view_ref(Item_field).
*/
-Item_equal::Item_equal(THD *thd, Item *f1, Item *f2, bool with_const_item):
+Item_equal::Item_equal(THD *thd, const Type_handler *handler,
+ Item *f1, Item *f2, bool with_const_item):
Item_bool_func(thd), eval_item(0), cond_false(0), cond_true(0),
context_field(NULL), link_equal_fields(FALSE),
- m_compare_type(item_cmp_type(f1, f2)),
+ m_compare_handler(handler),
m_compare_collation(f2->collation.collation)
{
const_item_cache= 0;
@@ -6048,7 +6051,7 @@ Item_equal::Item_equal(THD *thd, Item *f1, Item *f2, bool with_const_item):
Item_equal::Item_equal(THD *thd, Item_equal *item_equal):
Item_bool_func(thd), eval_item(0), cond_false(0), cond_true(0),
context_field(NULL), link_equal_fields(FALSE),
- m_compare_type(item_equal->m_compare_type),
+ m_compare_handler(item_equal->m_compare_handler),
m_compare_collation(item_equal->m_compare_collation)
{
const_item_cache= 0;
@@ -6091,7 +6094,7 @@ void Item_equal::add_const(THD *thd, Item *c)
return;
}
Item *const_item= get_const();
- switch (Item_equal::compare_type()) {
+ switch (Item_equal::compare_type_handler()->cmp_type()) {
case TIME_RESULT:
{
enum_field_types f_type= context_field->field_type();
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index db2f0cf02b4..affba859725 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -82,7 +82,8 @@ public:
bool set_cmp_func_for_row_arguments();
bool set_cmp_func_row();
bool set_cmp_func_string();
- bool set_cmp_func_temporal();
+ bool set_cmp_func_time();
+ bool set_cmp_func_datetime();
bool set_cmp_func_int();
bool set_cmp_func_real();
bool set_cmp_func_decimal();
@@ -496,7 +497,7 @@ public:
{
Item_args::propagate_equal_fields(thd,
Context(ANY_SUBST,
- cmp.compare_type(),
+ cmp.compare_type_handler(),
compare_collation()),
cond);
return this;
@@ -902,7 +903,7 @@ public:
{
Item_args::propagate_equal_fields(thd,
Context(ANY_SUBST,
- m_comparator.cmp_type(),
+ m_comparator.type_handler(),
compare_collation()),
cond);
return this;
@@ -1013,7 +1014,7 @@ protected:
void cache_type_info(const Item *source, bool maybe_null_arg)
{
Type_std_attributes::set(source);
- set_handler_by_field_type(source->field_type());
+ set_handler(source->type_handler());
maybe_null= maybe_null_arg;
}
@@ -1025,7 +1026,7 @@ protected:
cache_type_info(items[1], true);
// If both arguments are NULL, make resulting type BINARY(0).
if (items[1]->type() == NULL_ITEM)
- set_handler_by_field_type(MYSQL_TYPE_STRING);
+ set_handler(&type_handler_string);
}
else if (items[1]->type() == NULL_ITEM)
{
@@ -1228,7 +1229,8 @@ public:
bool is_null();
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
{
- Context cmpctx(ANY_SUBST, cmp.compare_type(), cmp.compare_collation());
+ Context cmpctx(ANY_SUBST, cmp.compare_type_handler(),
+ cmp.compare_collation());
const Item *old0= args[0];
args[0]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
cond, &args[0]);
@@ -2038,7 +2040,6 @@ class Item_func_case :public Item_func_case_expression,
public Predicant_to_list_comparator
{
int first_expr_num, else_expr_num;
- enum Item_result left_cmp_type;
String tmp_value;
uint ncases;
DTCollation cmp_collation;
@@ -2215,14 +2216,14 @@ public:
*/
if (arg_types_compatible)
{
- Context cmpctx(ANY_SUBST, m_comparator.cmp_type(),
+ Context cmpctx(ANY_SUBST, m_comparator.type_handler(),
Item_func_in::compare_collation());
args[0]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
cond, &args[0]);
}
for (uint i= 0; i < comparator_count(); i++)
{
- Context cmpctx(ANY_SUBST, get_comparator_type_handler(i)->cmp_type(),
+ Context cmpctx(ANY_SUBST, get_comparator_type_handler(i),
Item_func_in::compare_collation());
uint idx= get_comparator_arg_index(i);
args[idx]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
@@ -2532,7 +2533,7 @@ public:
if ((flags & MY_CS_NOPAD) && !(flags & MY_CS_NON1TO1))
Item_args::propagate_equal_fields(thd,
Context(ANY_SUBST,
- STRING_RESULT,
+ &type_handler_long_blob,
compare_collation()),
cond);
return this;
@@ -2766,7 +2767,6 @@ public:
Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
void neg_arguments(THD *thd);
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
Item* propagate_equal_fields(THD *, const Context &, COND_EQUAL *);
Item *compile(THD *thd, Item_analyzer analyzer, uchar **arg_p,
Item_transformer transformer, uchar *arg_t);
@@ -2899,14 +2899,15 @@ class Item_equal: public Item_bool_func
bool link_equal_fields;
- Item_result m_compare_type;
+ const Type_handler *m_compare_handler;
CHARSET_INFO *m_compare_collation;
String cmp_value1, cmp_value2;
public:
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
- Item_equal(THD *thd, Item *f1, Item *f2, bool with_const_item);
+ Item_equal(THD *thd, const Type_handler *handler,
+ Item *f1, Item *f2, bool with_const_item);
Item_equal(THD *thd, Item_equal *item_equal);
/* Currently the const item is always the first in the list of equal items */
inline Item* get_const() { return with_const ? equal_items.head() : NULL; }
@@ -2939,7 +2940,7 @@ public:
bool walk(Item_processor processor, bool walk_subquery, void *arg);
Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
virtual void print(String *str, enum_query_type query_type);
- Item_result compare_type() const { return m_compare_type; }
+ const Type_handler *compare_type_handler() const { return m_compare_handler; }
CHARSET_INFO *compare_collation() const { return m_compare_collation; }
void set_context_field(Item_field *ctx_field) { context_field= ctx_field; }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 24b1018fe60..0fddc65a66b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4426,7 +4426,10 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
for (derived= unit->derived;
derived;
derived= derived->select_lex->master_unit()->derived)
+ {
derived->set_materialized_derived();
+ derived->prohibit_cond_pushdown= true;
+ }
}
return FALSE;
@@ -4743,7 +4746,7 @@ Item_func_set_user_var::check(bool use_result_field)
if (use_result_field && !result_field)
use_result_field= FALSE;
- switch (Item_func_set_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
{
save_result.vreal= use_result_field ? result_field->val_real() :
@@ -4836,7 +4839,7 @@ Item_func_set_user_var::update()
bool res= 0;
DBUG_ENTER("Item_func_set_user_var::update");
- switch (Item_func_set_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
{
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
@@ -5306,7 +5309,7 @@ void Item_func_get_user_var::fix_length_and_dec()
max_length= m_var_entry->length;
collation.set(m_var_entry->charset(), DERIVATION_IMPLICIT);
set_handler_by_result_type(m_var_entry->type);
- switch (Item_func_get_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
fix_char_length(DBL_DIG + 8);
break;
@@ -5316,7 +5319,7 @@ void Item_func_get_user_var::fix_length_and_dec()
break;
case STRING_RESULT:
max_length= MAX_BLOB_WIDTH - 1;
- set_handler_by_field_type(MYSQL_TYPE_MEDIUM_BLOB);
+ set_handler(&type_handler_medium_blob);
break;
case DECIMAL_RESULT:
fix_char_length(DECIMAL_MAX_STR_LENGTH);
@@ -5332,7 +5335,7 @@ void Item_func_get_user_var::fix_length_and_dec()
{
collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
null_value= 1;
- set_handler_by_field_type(MYSQL_TYPE_LONG_BLOB);
+ set_handler(&type_handler_long_blob);
max_length= MAX_BLOB_WIDTH;
}
}
@@ -5401,14 +5404,15 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
}
-void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs)
+void Item_user_var_as_out_param::load_data_set_null_value(CHARSET_INFO* cs)
{
::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, 0 /* unsigned_arg */);
}
-void Item_user_var_as_out_param::set_value(const char *str, uint length,
- CHARSET_INFO* cs)
+void Item_user_var_as_out_param::load_data_set_value(const char *str,
+ uint length,
+ CHARSET_INFO* cs)
{
::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs,
0 /* unsigned_arg */);
@@ -5443,7 +5447,7 @@ my_decimal* Item_user_var_as_out_param::val_decimal(my_decimal *decimal_buffer)
}
-void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
+void Item_user_var_as_out_param::load_data_print(THD *thd, String *str)
{
str->append('@');
append_identifier(thd, str, name.str, name.length);
@@ -5582,34 +5586,8 @@ bool Item_func_get_system_var::check_vcol_func_processor(void *arg)
return mark_unsupported_function("@@", var->name.str, arg, VCOL_SESSION_FUNC);
}
-enum Item_result Item_func_get_system_var::result_type() const
-{
- switch (var->show_type())
- {
- case SHOW_BOOL:
- case SHOW_MY_BOOL:
- case SHOW_SINT:
- case SHOW_SLONG:
- case SHOW_SLONGLONG:
- case SHOW_UINT:
- case SHOW_ULONG:
- case SHOW_ULONGLONG:
- case SHOW_HA_ROWS:
- return INT_RESULT;
- case SHOW_CHAR:
- case SHOW_CHAR_PTR:
- case SHOW_LEX_STRING:
- return STRING_RESULT;
- case SHOW_DOUBLE:
- return REAL_RESULT;
- default:
- my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str);
- return STRING_RESULT; // keep the compiler happy
- }
-}
-
-enum_field_types Item_func_get_system_var::field_type() const
+const Type_handler *Item_func_get_system_var::type_handler() const
{
switch (var->show_type())
{
@@ -5622,16 +5600,16 @@ enum_field_types Item_func_get_system_var::field_type() const
case SHOW_ULONG:
case SHOW_ULONGLONG:
case SHOW_HA_ROWS:
- return MYSQL_TYPE_LONGLONG;
+ return &type_handler_longlong;
case SHOW_CHAR:
case SHOW_CHAR_PTR:
case SHOW_LEX_STRING:
- return MYSQL_TYPE_VARCHAR;
+ return &type_handler_varchar;
case SHOW_DOUBLE:
- return MYSQL_TYPE_DOUBLE;
+ return &type_handler_double;
default:
my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str);
- return MYSQL_TYPE_VARCHAR; // keep the compiler happy
+ return &type_handler_varchar; // keep the compiler happy
}
}
@@ -6447,23 +6425,17 @@ Item_func_sp::make_field(THD *thd, Send_field *tmp_field)
}
-enum enum_field_types
-Item_func_sp::field_type() const
+const Type_handler *Item_func_sp::type_handler() const
{
- DBUG_ENTER("Item_func_sp::field_type");
- DBUG_ASSERT(sp_result_field);
- DBUG_RETURN(sp_result_field->type());
-}
-
-Item_result
-Item_func_sp::result_type() const
-{
- DBUG_ENTER("Item_func_sp::result_type");
+ DBUG_ENTER("Item_func_sp::type_handler");
DBUG_PRINT("info", ("m_sp = %p", (void *) m_sp));
DBUG_ASSERT(sp_result_field);
- DBUG_RETURN(sp_result_field->result_type());
+ // This converts ENUM/SET to STRING
+ const Type_handler *handler= sp_result_field->type_handler();
+ DBUG_RETURN(handler->type_handler_for_item_field());
}
+
longlong Item_func_found_rows::val_int()
{
DBUG_ASSERT(fixed == 1);
diff --git a/sql/item_func.h b/sql/item_func.h
index 33726cd2d84..74c986545cd 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -370,8 +370,7 @@ public:
my_decimal *val_decimal(my_decimal *decimal_value);
longlong val_int()
{ DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
- enum Item_result result_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
};
@@ -397,12 +396,6 @@ public:
:Item_func(thd, item), Type_handler_hybrid_field_type(item) { }
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
Field::geometry_type get_geometry_type() const
{ return Type_geometry_attributes::get_geometry_type(); };
};
@@ -735,8 +728,7 @@ public:
{ collation.set_numeric(); }
double val_real();
String *val_str(String*str);
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() {}
};
@@ -907,8 +899,7 @@ public:
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal*);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
+ const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec_generic() {}
void fix_length_and_dec()
{
@@ -932,7 +923,6 @@ public:
max_length= (uint32) len;
}
double val_real();
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
void fix_length_and_dec_generic() { maybe_null= 1; }
void fix_length_and_dec()
{
@@ -1544,8 +1534,7 @@ public:
my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); }
const char *func_name() const { return "rollup_const"; }
bool const_item() const { return 0; }
- Item_result result_type() const { return args[0]->result_type(); }
- enum_field_types field_type() const { return args[0]->field_type(); }
+ const Type_handler *type_handler() const { return args[0]->type_handler(); }
void fix_length_and_dec()
{
collation= args[0]->collation;
@@ -1918,7 +1907,6 @@ public:
}
}
void cleanup();
- Item_result result_type () const { return udf.result_type(); }
table_map not_null_tables() const { return 0; }
bool is_expensive() { return 1; }
virtual void print(String *str, enum_query_type query_type);
@@ -1952,7 +1940,7 @@ class Item_func_udf_float :public Item_udf_func
}
double val_real();
String *val_str(String *str);
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_float>(thd, mem_root, this); }
@@ -1970,8 +1958,7 @@ public:
longlong val_int();
double val_real() { return (double) Item_func_udf_int::val_int(); }
String *val_str(String *str);
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals= 0; max_length= 21; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_int>(thd, mem_root, this); }
@@ -1989,8 +1976,7 @@ public:
double val_real();
my_decimal *val_decimal(my_decimal *);
String *val_str(String *str);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
+ const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_decimal>(thd, mem_root, this); }
@@ -2029,8 +2015,7 @@ public:
string2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
return dec_buf;
}
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return string_field_type(); }
+ const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec();
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_udf_str>(thd, mem_root, this); }
@@ -2082,7 +2067,6 @@ public:
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { maybe_null=1; max_length=0; }
};
@@ -2301,7 +2285,7 @@ public:
void fix_length_and_dec();
Field *create_field_for_create_select(TABLE *table)
{
- return cmp_type() == STRING_RESULT ?
+ return Type_handler_hybrid_field_type::cmp_type() == STRING_RESULT ?
type_handler_long_blob.make_and_init_table_field(&(Item::name),
Record_addr(maybe_null),
*this, table) :
@@ -2339,7 +2323,8 @@ public:
in List<Item> and desire to place this code somewhere near other functions
working with user variables.
*/
-class Item_user_var_as_out_param :public Item
+class Item_user_var_as_out_param :public Item,
+ public Load_data_out_param
{
LEX_CSTRING name;
user_var_entry *entry;
@@ -2355,10 +2340,11 @@ public:
my_decimal *val_decimal(my_decimal *decimal_buffer);
/* fix_fields() binds variable name with its entry structure */
bool fix_fields(THD *thd, Item **ref);
- void print_for_load(THD *thd, String *str);
- void set_null_value(CHARSET_INFO* cs);
- void set_value(const char *str, uint length, CHARSET_INFO* cs);
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ Load_data_out_param *get_load_data_out_param() { return this; }
+ void load_data_print(THD *thd, String *str);
+ void load_data_set_null_value(CHARSET_INFO* cs);
+ void load_data_set_value(const char *str, uint length, CHARSET_INFO* cs);
+ const Type_handler *type_handler() const { return &type_handler_double; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_user_var_as_out_param>(thd, mem_root, this); }
};
@@ -2393,8 +2379,7 @@ public:
void print(String *str, enum_query_type query_type);
bool const_item() const { return true; }
table_map used_tables() const { return 0; }
- enum Item_result result_type() const;
- enum_field_types field_type() const;
+ const Type_handler *type_handler() const;
double val_real();
longlong val_int();
String* val_str(String*);
@@ -2654,7 +2639,7 @@ public:
const char *func_name() const;
- enum enum_field_types field_type() const;
+ const Type_handler *type_handler() const;
Field *create_field_for_create_select(TABLE *table)
{
@@ -2664,8 +2649,6 @@ public:
}
void make_field(THD *thd, Send_field *tmp_field);
- Item_result result_type() const;
-
longlong val_int()
{
if (execute())
@@ -2837,10 +2820,9 @@ public:
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
void fix_length_and_dec();
- enum Item_result result_type () const { return last_value->result_type(); }
const char *func_name() const { return "last_value"; }
table_map not_null_tables() const { return 0; }
- enum_field_types field_type() const { return last_value->field_type(); }
+ const Type_handler *type_handler() const { return last_value->type_handler(); }
bool const_item() const { return 0; }
void evaluate_sideeffects();
void update_used_tables()
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 8a61ab583c9..f2162e08323 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -1063,11 +1063,11 @@ Item_func_spatial_rel::get_mm_leaf(RANGE_OPT_PARAM *param,
tree->max_flag= NO_MAX_RANGE;
break;
case SP_WITHIN_FUNC:
- tree->min_flag= GEOM_FLAG | HA_READ_MBR_WITHIN;// NEAR_MIN;//512;
+ tree->min_flag= GEOM_FLAG | HA_READ_MBR_CONTAIN;// NEAR_MIN;//512;
tree->max_flag= NO_MAX_RANGE;
break;
case SP_CONTAINS_FUNC:
- tree->min_flag= GEOM_FLAG | HA_READ_MBR_CONTAIN;// NEAR_MIN;//512;
+ tree->min_flag= GEOM_FLAG | HA_READ_MBR_WITHIN;// NEAR_MIN;//512;
tree->max_flag= NO_MAX_RANGE;
break;
case SP_OVERLAPS_FUNC:
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index b6a49a38743..cf6d9bb1360 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -39,7 +39,7 @@ public:
Item_str_func(thd, a, b, c) {}
Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
void fix_length_and_dec();
- enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
+ const Type_handler *type_handler() const { return &type_handler_geometry; }
};
class Item_func_geometry_from_text: public Item_geometry_func
@@ -100,7 +100,7 @@ public:
Item_func_as_wkb(THD *thd, Item *a): Item_geometry_func(thd, a) {}
const char *func_name() const { return "st_aswkb"; }
String *val_str(String *);
- enum_field_types field_type() const { return MYSQL_TYPE_LONG_BLOB; }
+ const Type_handler *type_handler() const { return &type_handler_long_blob; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_as_wkb>(thd, mem_root, this); }
};
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index b8471dc8244..c7639bc2513 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -444,6 +444,7 @@ void Item_func_json_value::fix_length_and_dec()
collation.set(args[0]->collation);
max_length= args[0]->max_length;
path.set_constant_flag(args[1]->const_item());
+ maybe_null= 1;
}
@@ -582,6 +583,7 @@ void Item_func_json_unquote::fix_length_and_dec()
{
collation.set(&my_charset_utf8_general_ci);
max_length= args[0]->max_length;
+ maybe_null= 1;
}
@@ -683,6 +685,7 @@ void Item_func_json_extract::fix_length_and_dec()
max_length= args[0]->max_length * (arg_count - 1);
mark_constant_paths(paths, args+1, arg_count-1);
+ maybe_null= 1;
}
@@ -884,6 +887,7 @@ void Item_func_json_contains::fix_length_and_dec()
{
a2_constant= args[1]->const_item();
a2_parsed= FALSE;
+ maybe_null= 1;
if (arg_count > 2)
path.set_constant_flag(args[2]->const_item());
Item_int_func::fix_length_and_dec();
@@ -1129,6 +1133,7 @@ void Item_func_json_contains_path::fix_length_and_dec()
{
ooa_constant= args[1]->const_item();
ooa_parsed= FALSE;
+ maybe_null= 1;
mark_constant_paths(paths, args+2, arg_count-2);
Item_int_func::fix_length_and_dec();
}
@@ -2042,6 +2047,7 @@ void Item_func_json_length::fix_length_and_dec()
{
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
+ maybe_null= 1;
}
@@ -2178,6 +2184,7 @@ void Item_func_json_type::fix_length_and_dec()
{
collation.set(&my_charset_utf8_general_ci);
max_length= 12;
+ maybe_null= 1;
}
@@ -2245,6 +2252,7 @@ void Item_func_json_insert::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
+ maybe_null= 1;
}
@@ -2491,6 +2499,7 @@ void Item_func_json_remove::fix_length_and_dec()
max_length= args[0]->max_length;
mark_constant_paths(paths, args+1, arg_count-1);
+ maybe_null= 1;
}
@@ -2674,6 +2683,7 @@ void Item_func_json_keys::fix_length_and_dec()
{
collation.set(args[0]->collation);
max_length= args[0]->max_length;
+ maybe_null= 1;
if (arg_count > 1)
path.set_constant_flag(args[1]->const_item());
}
@@ -2815,6 +2825,7 @@ void Item_func_json_search::fix_length_and_dec()
if (arg_count > 4)
mark_constant_paths(paths, args+4, arg_count-4);
+ maybe_null= 1;
}
@@ -2898,7 +2909,7 @@ String *Item_func_json_search::val_str(String *str)
json_path_with_flags *c_path= paths + n_arg - 4;
if (!c_path->parsed)
{
- String *s_p= args[n_arg]->val_str(tmp_paths + (n_arg-1));
+ String *s_p= args[n_arg]->val_str(tmp_paths + (n_arg-4));
if (s_p &&
json_path_setup(&c_path->p,s_p->charset(),(const uchar *) s_p->ptr(),
(const uchar *) s_p->ptr() + s_p->length()))
@@ -2996,6 +3007,7 @@ void Item_func_json_format::fix_length_and_dec()
{
decimals= 0;
max_length= args[0]->max_length;
+ maybe_null= 1;
}
diff --git a/sql/item_row.h b/sql/item_row.h
index 5084f042473..83ceb80a359 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -90,13 +90,6 @@ public:
List<Item> &fields, uint flags);
table_map used_tables() const { return used_tables_cache; };
bool const_item() const { return const_item_cache; };
- enum Item_result result_type() const { return ROW_RESULT; }
- Item_result cmp_type() const { return ROW_RESULT; }
- enum_field_types field_type() const
- {
- DBUG_ASSERT(0);
- return MYSQL_TYPE_DOUBLE;
- }
void update_used_tables()
{
used_tables_and_const_cache_init();
@@ -114,7 +107,7 @@ public:
Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
bool eval_not_null_tables(void *opt_arg);
- uint cols() { return arg_count; }
+ uint cols() const { return arg_count; }
Item* element_index(uint i) { return args[i]; }
Item** addr(uint i) { return args + i; }
bool check_cols(uint c);
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 177835d6239..267408187f3 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -64,8 +64,7 @@ public:
longlong val_int();
double val_real();
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return string_field_type(); }
+ const Type_handler *type_handler() const { return string_type_handler(); }
void left_right_max_length();
bool fix_fields(THD *thd, Item **ref);
void update_null_value()
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 9b74ed06965..09fbf3e239c 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1172,30 +1172,11 @@ void Item_singlerow_subselect::store(uint i, Item *item)
row[i]->cache_value();
}
-enum Item_result Item_singlerow_subselect::result_type() const
-{
- return engine->result_type();
-}
-
-enum Item_result Item_singlerow_subselect::cmp_type() const
-{
- return engine->cmp_type();
-}
-
const Type_handler *Item_singlerow_subselect::type_handler() const
{
return engine->type_handler();
}
-/*
- Don't rely on the result type to calculate field type.
- Ask the engine instead.
-*/
-enum_field_types Item_singlerow_subselect::field_type() const
-{
- return engine->field_type();
-}
-
void Item_singlerow_subselect::fix_length_and_dec()
{
if ((max_columns= engine->cols()) == 1)
@@ -1264,7 +1245,7 @@ Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd,
}
-uint Item_singlerow_subselect::cols()
+uint Item_singlerow_subselect::cols() const
{
return engine->cols();
}
@@ -2396,7 +2377,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
&list_ref));
Item *col_item= new (thd->mem_root)
Item_cond_or(thd, item_eq, item_isnull);
- if (!abort_on_null && left_expr->element_index(i)->maybe_null)
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ get_cond_guard(i))
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(col_item= new (thd->mem_root)
@@ -2414,7 +2396,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
ref_pointer_array[i],
(char *)"<no matter>",
&list_ref));
- if (!abort_on_null && left_expr->element_index(i)->maybe_null)
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ get_cond_guard(i) )
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(item_nnull_test=
@@ -2474,7 +2457,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(char *)"<no matter>",
&list_ref));
item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
- if (left_expr->element_index(i)->maybe_null)
+ if (left_expr->element_index(i)->maybe_null && get_cond_guard(i))
{
disable_cond_guard_for_const_null_left_expr(i);
if (!(item= new (thd->mem_root)
@@ -2486,7 +2469,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
}
*having_item= and_items(thd, *having_item, having_col_item);
}
- if (!abort_on_null && left_expr->element_index(i)->maybe_null)
+ if (!abort_on_null && left_expr->element_index(i)->maybe_null &&
+ get_cond_guard(i))
{
if (!(item= new (thd->mem_root)
Item_func_trig_cond(thd, item, get_cond_guard(i))))
@@ -4260,7 +4244,7 @@ int subselect_indexsubquery_engine::exec()
}
-uint subselect_single_select_engine::cols()
+uint subselect_single_select_engine::cols() const
{
//psergey-sj-backport: the following assert was gone in 6.0:
//DBUG_ASSERT(select_lex->join != 0); // should be called after fix_fields()
@@ -4269,7 +4253,7 @@ uint subselect_single_select_engine::cols()
}
-uint subselect_union_engine::cols()
+uint subselect_union_engine::cols() const
{
DBUG_ASSERT(unit->is_prepared()); // should be called after fix_fields()
return unit->types.elements;
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 4c4af25edf5..5d9e2e7c0cd 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -303,13 +303,10 @@ public:
my_decimal *val_decimal(my_decimal *);
bool val_bool();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
- enum Item_result result_type() const;
- enum Item_result cmp_type() const;
- enum_field_types field_type() const;
const Type_handler *type_handler() const;
void fix_length_and_dec();
- uint cols();
+ uint cols() const;
Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); }
Item** addr(uint i) { return (Item**)row + i; }
bool check_cols(uint c);
@@ -396,8 +393,7 @@ public:
}
void no_rows_in_result();
- enum Item_result result_type() const { return INT_RESULT;}
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
longlong val_int();
double val_real();
String *val_str(String*);
@@ -819,7 +815,7 @@ public:
caller should call exec() again for the new engine.
*/
virtual int exec()= 0;
- virtual uint cols()= 0; /* return number of columns in select */
+ virtual uint cols() const= 0; /* return number of columns in select */
virtual uint8 uncacheable()= 0; /* query is uncacheable */
virtual void exclude()= 0;
virtual bool may_be_null() { return maybe_null; };
@@ -856,7 +852,7 @@ public:
int prepare(THD *thd);
void fix_length_and_dec(Item_cache** row);
int exec();
- uint cols();
+ uint cols() const;
uint8 uncacheable();
void exclude();
table_map upper_select_const_tables();
@@ -891,7 +887,7 @@ public:
int prepare(THD *);
void fix_length_and_dec(Item_cache** row);
int exec();
- uint cols();
+ uint cols() const;
uint8 uncacheable();
void exclude();
table_map upper_select_const_tables();
@@ -949,7 +945,7 @@ public:
int prepare(THD *);
void fix_length_and_dec(Item_cache** row);
int exec();
- uint cols() { return 1; }
+ uint cols() const { return 1; }
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT_INJECTED; }
void exclude();
table_map upper_select_const_tables() { return 0; }
@@ -1087,7 +1083,7 @@ public:
int prepare(THD *);
int exec();
void print(String *str, enum_query_type query_type);
- uint cols() { return materialize_engine->cols(); }
+ uint cols() const { return materialize_engine->cols(); }
uint8 uncacheable() { return materialize_engine->uncacheable(); }
table_map upper_select_const_tables() { return 0; }
bool no_rows() { return !tmp_table->file->stats.records; }
@@ -1370,7 +1366,7 @@ public:
int prepare(THD *thd_arg) { set_thd(thd_arg); return 0; }
int exec();
void fix_length_and_dec(Item_cache**) {}
- uint cols() { /* TODO: what is the correct value? */ return 1; }
+ uint cols() const { /* TODO: what is the correct value? */ return 1; }
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
void exclude() {}
table_map upper_select_const_tables() { return 0; }
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 6d510253259..6dccd67316f 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1229,7 +1229,7 @@ Item_sum_sum::Item_sum_sum(THD *thd, Item_sum_sum *item)
count(item->count)
{
/* TODO: check if the following assignments are really needed */
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal2decimal(item->dec_buffs, dec_buffs);
my_decimal2decimal(item->dec_buffs + 1, dec_buffs + 1);
@@ -1249,7 +1249,7 @@ void Item_sum_sum::clear()
DBUG_ENTER("Item_sum_sum::clear");
null_value=1;
count= 0;
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
curr_dec_buff= 0;
my_decimal_set_zero(dec_buffs);
@@ -1304,7 +1304,7 @@ void Item_sum_sum::add_helper(bool perform_removal)
{
DBUG_ENTER("Item_sum_sum::add_helper");
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value;
const my_decimal *val= aggr->arg_val_decimal(&value);
@@ -1361,7 +1361,7 @@ longlong Item_sum_sum::val_int()
DBUG_ASSERT(fixed == 1);
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
longlong result;
my_decimal2int(E_DEC_FATAL_ERROR, dec_buffs + curr_dec_buff, unsigned_flag,
@@ -1377,7 +1377,7 @@ double Item_sum_sum::val_real()
DBUG_ASSERT(fixed == 1);
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
my_decimal2double(E_DEC_FATAL_ERROR, dec_buffs + curr_dec_buff, &sum);
return sum;
}
@@ -1387,7 +1387,7 @@ String *Item_sum_sum::val_str(String *str)
{
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return val_string_from_decimal(str);
return val_string_from_real(str);
}
@@ -1397,7 +1397,7 @@ my_decimal *Item_sum_sum::val_decimal(my_decimal *val)
{
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return null_value ? NULL : (dec_buffs + curr_dec_buff);
return val_decimal_from_real(val);
}
@@ -1642,7 +1642,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table)
and unpack on access.
*/
Field *field= new (table->in_use->mem_root)
- Field_string(((Item_sum_avg::result_type() == DECIMAL_RESULT) ?
+ Field_string(((result_type() == DECIMAL_RESULT) ?
dec_bin_size : sizeof(double)) + sizeof(longlong),
0, &name, &my_charset_bin);
if (field)
@@ -1710,7 +1710,7 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val)
For non-DECIMAL result_type() the division will be done in
Item_sum_avg::val_real().
*/
- if (Item_sum_avg::result_type() != DECIMAL_RESULT)
+ if (result_type() != DECIMAL_RESULT)
return val_decimal_from_real(val);
sum_dec= dec_buffs + curr_dec_buff;
@@ -1724,7 +1724,7 @@ String *Item_sum_avg::val_str(String *str)
{
if (aggr)
aggr->endup();
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return val_string_from_decimal(str);
return val_string_from_real(str);
}
@@ -2307,7 +2307,7 @@ void Item_sum_num::reset_field()
void Item_sum_hybrid::reset_field()
{
- switch(Item_sum_hybrid::result_type()) {
+ switch(result_type()) {
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
@@ -2390,7 +2390,7 @@ void Item_sum_hybrid::reset_field()
void Item_sum_sum::reset_field()
{
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!arg_val) // Null
@@ -2426,7 +2426,7 @@ void Item_sum_avg::reset_field()
{
uchar *res=result_field->ptr;
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
longlong tmp;
my_decimal value, *arg_dec= args[0]->val_decimal(&value);
@@ -2484,7 +2484,7 @@ void Item_sum_bit::update_field()
void Item_sum_sum::update_field()
{
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!args[0]->null_value)
@@ -2539,7 +2539,7 @@ void Item_sum_avg::update_field()
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!args[0]->null_value)
@@ -2578,7 +2578,7 @@ void Item_sum_avg::update_field()
Item *Item_sum_avg::result_item(THD *thd, Field *field)
{
return
- Item_sum_avg::result_type() == DECIMAL_RESULT ?
+ result_type() == DECIMAL_RESULT ?
(Item_avg_field*) new (thd->mem_root) Item_avg_field_decimal(thd, this) :
(Item_avg_field*) new (thd->mem_root) Item_avg_field_double(thd, this);
}
@@ -2586,7 +2586,7 @@ Item *Item_sum_avg::result_item(THD *thd, Field *field)
void Item_sum_hybrid::update_field()
{
- switch (Item_sum_hybrid::result_type()) {
+ switch (result_type()) {
case STRING_RESULT:
min_max_update_str_field();
break;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 33ee83f147b..dee480ccf0a 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -748,8 +748,7 @@ public:
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; }
};
@@ -783,12 +782,6 @@ public:
my_decimal *val_decimal(my_decimal *);
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
void fix_length_and_dec_double();
void fix_length_and_dec_decimal();
void reset_field();
@@ -980,8 +973,7 @@ public:
{ return sample ? "var_samp(" : "variance("; }
Item *copy_or_same(THD* thd);
Field *create_tmp_field(bool group, TABLE *table);
- enum Item_result result_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE;}
+ const Type_handler *type_handler() const { return &type_handler_double; }
void cleanup()
{
count= 0;
@@ -1027,7 +1019,7 @@ protected:
public:
Item_sum_hybrid(THD *thd, Item *item_par,int sign):
Item_sum(thd, item_par),
- Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
+ Type_handler_hybrid_field_type(&type_handler_longlong),
value(0), arg_cache(0), cmp(0),
cmp_sign(sign), was_values(TRUE)
{ collation.set(&my_charset_bin); }
@@ -1052,12 +1044,6 @@ protected:
}
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type () const
- { return Type_handler_hybrid_field_type::cmp_type(); }
- enum enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
void update_field();
void min_max_update_str_field();
void min_max_update_real_field();
@@ -1263,8 +1249,7 @@ public:
Item_avg_field_double(THD *thd, Item_sum_avg *item)
:Item_avg_field(thd, item)
{ }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
- enum Item_result result_type () const { return REAL_RESULT; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
longlong val_int() { return val_int_from_real(); }
my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_real(dec); }
String *val_str(String *str) { return val_string_from_real(str); }
@@ -1284,8 +1269,7 @@ public:
f_scale(item->f_scale),
dec_bin_size(item->dec_bin_size)
{ }
- enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
- enum Item_result result_type () const { return DECIMAL_RESULT; }
+ const Type_handler *type_handler() const { return &type_handler_newdecimal; }
double val_real() { return val_real_from_decimal(); }
longlong val_int() { return val_int_from_decimal(); }
String *val_str(String *str) { return val_string_from_decimal(str); }
@@ -1310,8 +1294,7 @@ public:
my_decimal *val_decimal(my_decimal *dec_buf)
{ return val_decimal_from_real(dec_buf); }
bool is_null() { update_null_value(); return null_value; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
- enum Item_result result_type () const { return REAL_RESULT; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_variance_field>(thd, mem_root, this); }
};
@@ -1409,9 +1392,7 @@ class Item_sum_udf_float :public Item_udf_sum
double val_real();
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return REAL_RESULT; }
- enum Item_result cmp_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1433,8 +1414,7 @@ public:
{ DBUG_ASSERT(fixed == 1); return (double) Item_sum_udf_int::val_int(); }
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals=0; max_length=21; }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1475,8 +1455,7 @@ public:
return cs->cset->strtoll10(cs, res->ptr(), &end, &err_not_used);
}
my_decimal *val_decimal(my_decimal *dec);
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return string_field_type(); }
+ const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec();
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1497,8 +1476,7 @@ public:
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
+ const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1573,7 +1551,6 @@ public:
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { maybe_null=1; max_length=0; }
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {}
@@ -1647,14 +1624,11 @@ public:
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat("; }
- virtual Item_result result_type () const { return STRING_RESULT; }
- virtual Item_result cmp_type () const { return STRING_RESULT; }
- enum_field_types field_type() const
+ const Type_handler *type_handler() const
{
if (too_big_for_varchar())
- return MYSQL_TYPE_BLOB;
- else
- return MYSQL_TYPE_VARCHAR;
+ return &type_handler_blob;
+ return &type_handler_varchar;
}
void clear();
bool add();
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index d52eeba1f15..ced4bf4b31e 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -155,8 +155,7 @@ public:
return str;
}
const char *func_name() const { return "month"; }
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{
decimals= 0;
@@ -405,8 +404,7 @@ public:
{
return (odbc_type ? "dayofweek" : "weekday");
}
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{
decimals= 0;
@@ -430,8 +428,7 @@ class Item_func_dayname :public Item_func_weekday
Item_func_dayname(THD *thd, Item *a): Item_func_weekday(thd, a, 0) {}
const char *func_name() const { return "dayname"; }
String *val_str(String *str);
- enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
+ const Type_handler *type_handler() const { return &type_handler_varchar; }
void fix_length_and_dec();
bool check_partition_func_processor(void *int_arg) {return TRUE;}
bool check_vcol_func_processor(void *arg)
@@ -527,8 +524,6 @@ public:
Item_temporal_func(THD *thd, Item *a): Item_func(thd, a) {}
Item_temporal_func(THD *thd, Item *a, Item *b): Item_func(thd, a, b) {}
Item_temporal_func(THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b, c) {}
- enum Item_result result_type () const { return STRING_RESULT; }
- Item_result cmp_type() const { return TIME_RESULT; }
String *val_str(String *str);
longlong val_int() { return val_int_from_date(); }
double val_real() { return val_real_from_date(); }
@@ -585,7 +580,7 @@ public:
Item_datefunc(THD *thd): Item_temporal_func(thd) { }
Item_datefunc(THD *thd, Item *a): Item_temporal_func(thd, a) { }
Item_datefunc(THD *thd, Item *a, Item *b): Item_temporal_func(thd, a, b) { }
- enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
+ const Type_handler *type_handler() const { return &type_handler_newdate; }
void fix_length_and_dec()
{
fix_attributes_date();
@@ -602,7 +597,7 @@ public:
Item_timefunc(THD *thd, Item *a, Item *b): Item_temporal_func(thd, a, b) {}
Item_timefunc(THD *thd, Item *a, Item *b, Item *c):
Item_temporal_func(thd, a, b ,c) {}
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
+ const Type_handler *type_handler() const { return &type_handler_time2; }
};
@@ -613,7 +608,7 @@ public:
Item_datetimefunc(THD *thd, Item *a): Item_temporal_func(thd, a) {}
Item_datetimefunc(THD *thd, Item *a, Item *b, Item *c):
Item_temporal_func(thd, a, b ,c) {}
- enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
+ const Type_handler *type_handler() const { return &type_handler_datetime2; }
};
@@ -937,7 +932,7 @@ class Item_extract :public Item_int_func
const interval_type int_type; // keep it public
Item_extract(THD *thd, interval_type type_arg, Item *a):
Item_int_func(thd, a), int_type(type_arg) {}
- enum_field_types field_type() const
+ const Type_handler *type_handler() const
{
switch (int_type) {
case INTERVAL_YEAR:
@@ -957,16 +952,16 @@ class Item_extract :public Item_int_func
case INTERVAL_SECOND:
case INTERVAL_MICROSECOND:
case INTERVAL_SECOND_MICROSECOND:
- return MYSQL_TYPE_LONG;
+ return &type_handler_long;
case INTERVAL_DAY_MICROSECOND:
case INTERVAL_HOUR_MICROSECOND:
case INTERVAL_MINUTE_MICROSECOND:
- return MYSQL_TYPE_LONGLONG;
+ return &type_handler_longlong;
case INTERVAL_LAST:
break;
}
DBUG_ASSERT(0);
- return MYSQL_TYPE_LONGLONG;
+ return &type_handler_longlong;
}
longlong val_int();
enum Functype functype() const { return EXTRACT_FUNC; }
@@ -1073,7 +1068,7 @@ public:
const char *func_name() const { return "cast_as_date"; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *cast_type() const { return "date"; }
- enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
+ const Type_handler *type_handler() const { return &type_handler_newdate; }
void fix_length_and_dec()
{
args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this);
@@ -1091,7 +1086,7 @@ public:
const char *func_name() const { return "cast_as_time"; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *cast_type() const { return "time"; }
- enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
+ const Type_handler *type_handler() const { return &type_handler_time2; }
void fix_length_and_dec()
{
args[0]->type_handler()->Item_time_typecast_fix_length_and_dec(this);
@@ -1108,7 +1103,7 @@ public:
Item_temporal_typecast(thd, a) { decimals= dec_arg; }
const char *func_name() const { return "cast_as_datetime"; }
const char *cast_type() const { return "datetime"; }
- enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
+ const Type_handler *type_handler() const { return &type_handler_datetime2; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
void fix_length_and_dec()
{
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 01b591e7919..6ab903a81bb 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -243,14 +243,14 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
Item *item2= args[0]->real_item();
if (item2->type() == Item::FIELD_ITEM)
- set_handler_by_field_type(((Item_field*) item2)->field->type());
+ set_handler(item2->type_handler());
else if (args[0]->cmp_type() == TIME_RESULT)
- set_handler_by_field_type(item2->field_type());
+ set_handler(item2->type_handler());
else
set_handler_by_result_type(item2->result_type(),
max_length, collation.collation);
- switch (Item_sum_hybrid_simple::result_type()) {
+ switch (result_type()) {
case INT_RESULT:
case DECIMAL_RESULT:
case STRING_RESULT:
@@ -352,7 +352,7 @@ Field *Item_sum_hybrid_simple::create_tmp_field(bool group, TABLE *table)
void Item_sum_hybrid_simple::reset_field()
{
- switch(Item_sum_hybrid_simple::result_type()) {
+ switch(result_type()) {
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 1690d147b26..77cbd556e60 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -285,13 +285,13 @@ class Item_sum_hybrid_simple : public Item_sum,
public:
Item_sum_hybrid_simple(THD *thd, Item *arg):
Item_sum(thd, arg),
- Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
+ Type_handler_hybrid_field_type(&type_handler_longlong),
value(NULL)
{ collation.set(&my_charset_bin); }
Item_sum_hybrid_simple(THD *thd, Item *arg1, Item *arg2):
Item_sum(thd, arg1, arg2),
- Type_handler_hybrid_field_type(MYSQL_TYPE_LONGLONG),
+ Type_handler_hybrid_field_type(&type_handler_longlong),
value(NULL)
{ collation.set(&my_charset_bin); }
@@ -303,12 +303,8 @@ class Item_sum_hybrid_simple : public Item_sum,
my_decimal *val_decimal(my_decimal *);
void reset_field();
String *val_str(String *);
- enum Item_result result_type() const
- { return Type_handler_hybrid_field_type::result_type(); }
- enum Item_result cmp_type() const
- { return Type_handler_hybrid_field_type::cmp_type(); }
- enum enum_field_types field_type() const
- { return Type_handler_hybrid_field_type::field_type(); }
+ const Type_handler *type_handler() const
+ { return Type_handler_hybrid_field_type::type_handler(); }
void update_field();
Field *create_tmp_field(bool group, TABLE *table);
void clear()
@@ -511,8 +507,7 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
row_number= 0;
}
bool add();
- enum Item_result result_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
{
@@ -597,8 +592,7 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
}
void update_field() {}
- enum Item_result result_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
{
@@ -674,8 +668,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
void update_field() {}
- enum Item_result result_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_sum_ntile>(thd, mem_root, this); }
@@ -800,9 +793,9 @@ public:
*/
void setup_partition_border_check(THD *thd);
- enum_field_types field_type() const
- {
- return ((Item_sum *) args[0])->field_type();
+ const Type_handler *type_handler() const
+ {
+ return ((Item_sum *) args[0])->type_handler();
}
enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; }
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 1dca656ee08..383972d1a54 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -8403,6 +8403,11 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi)
Record any GTID in the same transaction, so slave state is transactionally
consistent.
*/
+#ifdef WITH_WSREP
+ /*Set wsrep_affected_rows = 0 */
+ thd->wsrep_affected_rows= 0;
+#endif
+
if (rgi->gtid_pending)
{
sub_id= rgi->gtid_sub_id;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 915387d6ba9..065f4d83367 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -9445,14 +9445,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
between options, setting of multiple variables, etc.
Do them here.
*/
-
- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
- opt_log_slow_slave_statements) &&
- !global_system_variables.sql_log_slow)
- sql_print_information("options --log-slow-admin-statements, "
- "--log-queries-not-using-indexes and "
- "--log-slow-slave-statements have no "
- "effect if --log-slow-queries is not set");
if (global_system_variables.net_buffer_length >
global_system_variables.max_allowed_packet)
{
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index b7b06080121..87cb16c96fe 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8030,33 +8030,53 @@ Item_bool_func::get_mm_leaf(RANGE_OPT_PARAM *param,
field->type_handler() == &type_handler_set)
{
if (type == EQ_FUNC || type == EQUAL_FUNC)
- {
- tree= new (alloc) SEL_ARG(field, 0, 0);
- tree->type= SEL_ARG::IMPOSSIBLE;
- }
+ tree= new (alloc) SEL_ARG_IMPOSSIBLE(field);
goto end;
}
if (err == 2 && field->cmp_type() == STRING_RESULT)
{
if (type == EQ_FUNC || type == EQUAL_FUNC)
- {
- tree= new (alloc) SEL_ARG(field, 0, 0);
- tree->type= SEL_ARG::IMPOSSIBLE;
- }
+ tree= new (alloc) SEL_ARG_IMPOSSIBLE(field);
else
tree= NULL; /* Cannot infer anything */
goto end;
}
- if (field->cmp_type() != value->result_type())
+ if (err == 3 && field->type() == FIELD_TYPE_DATE)
+ {
+ /*
+ We were saving DATETIME into a DATE column, the conversion went ok
+ but a non-zero time part was cut off.
+
+ In MySQL's SQL dialect, DATE and DATETIME are compared as datetime
+ values. Index over a DATE column uses DATE comparison. Changing
+ from one comparison to the other is possible:
+
+ datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10'
+ datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10'
+
+ datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10'
+ datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10'
+
+ but we'll need to convert '>' to '>=' and '<' to '<='. This will
+ be done together with other types at the end of this function
+ (grep for stored_field_cmp_to_item)
+ */
+ if (type == EQ_FUNC || type == EQUAL_FUNC)
+ {
+ tree= new (alloc) SEL_ARG_IMPOSSIBLE(field);
+ goto end;
+ }
+ // Continue with processing non-equality ranges
+ }
+ else if (field->cmp_type() != value->result_type())
{
if ((type == EQ_FUNC || type == EQUAL_FUNC) &&
value->result_type() == item_cmp_type(field->result_type(),
value->result_type()))
{
- tree= new (alloc) SEL_ARG(field, 0, 0);
- tree->type= SEL_ARG::IMPOSSIBLE;
+ tree= new (alloc) SEL_ARG_IMPOSSIBLE(field);
goto end;
}
else
@@ -8066,31 +8086,7 @@ Item_bool_func::get_mm_leaf(RANGE_OPT_PARAM *param,
for the cases like int_field > 999999999999999999999999 as well.
*/
tree= 0;
- if (err == 3 && field->type() == FIELD_TYPE_DATE &&
- (type == GT_FUNC || type == GE_FUNC ||
- type == LT_FUNC || type == LE_FUNC) )
- {
- /*
- We were saving DATETIME into a DATE column, the conversion went ok
- but a non-zero time part was cut off.
-
- In MySQL's SQL dialect, DATE and DATETIME are compared as datetime
- values. Index over a DATE column uses DATE comparison. Changing
- from one comparison to the other is possible:
-
- datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10'
- datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10'
-
- datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10'
- datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10'
-
- but we'll need to convert '>' to '>=' and '<' to '<='. This will
- be done together with other types at the end of this function
- (grep for stored_field_cmp_to_item)
- */
- }
- else
- goto end;
+ goto end;
}
}
diff --git a/sql/opt_range.h b/sql/opt_range.h
index c1f7079ce7f..95e231433d2 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -594,6 +594,17 @@ public:
};
+class SEL_ARG_IMPOSSIBLE: public SEL_ARG
+{
+public:
+ SEL_ARG_IMPOSSIBLE(Field *field)
+ :SEL_ARG(field, 0, 0)
+ {
+ type= SEL_ARG::IMPOSSIBLE;
+ }
+};
+
+
class RANGE_OPT_PARAM
{
public:
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index e7bf4658d5c..9bc21ab3ac3 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -461,7 +461,7 @@ int opt_sum_query(THD *thd,
{
if (recalc_const_item)
item->update_used_tables();
- if (!item->const_item())
+ if (!item->const_item() && item->type() != Item::WINDOW_FUNC_ITEM)
const_result= 0;
}
}
diff --git a/sql/procedure.h b/sql/procedure.h
index 4c087bfb3b2..a1c9b95f20b 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -47,7 +47,7 @@ public:
virtual void set(double nr)=0;
virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0;
virtual void set(longlong nr)=0;
- virtual enum_field_types field_type() const=0;
+ const Type_handler *type_handler() const=0;
void set(const char *str) { set(str,(uint) strlen(str), default_charset()); }
void make_field(THD *thd, Send_field *tmp_field)
{
@@ -71,9 +71,7 @@ public:
{
decimals=dec; max_length=float_length(dec);
}
- enum Item_result result_type () const { return REAL_RESULT; }
- enum Item_result cmp_type () const { return REAL_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ const Type_handler *type_handler() const { return &type_handler_double; }
void set(double nr) { value=nr; }
void set(longlong nr) { value=(double) nr; }
void set(const char *str,uint length,CHARSET_INFO *cs)
@@ -99,9 +97,7 @@ class Item_proc_int :public Item_proc
public:
Item_proc_int(THD *thd, const char *name_par): Item_proc(thd, name_par)
{ max_length=11; }
- enum Item_result result_type () const { return INT_RESULT; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
+ const Type_handler *type_handler() const { return &type_handler_longlong; }
void set(double nr) { value=(longlong) nr; }
void set(longlong nr) { value=nr; }
void set(const char *str,uint length, CHARSET_INFO *cs)
@@ -119,9 +115,7 @@ class Item_proc_string :public Item_proc
public:
Item_proc_string(THD *thd, const char *name_par, uint length):
Item_proc(thd, name_par) { this->max_length=length; }
- enum Item_result result_type () const { return STRING_RESULT; }
- enum Item_result cmp_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
+ const Type_handler *type_handler() const { return &type_handler_varchar; }
void set(double nr) { str_value.set_real(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, default_charset()); }
void set(const char *str, uint length, CHARSET_INFO *cs)
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 6788f422cbd..aaa72da29db 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -1164,7 +1164,8 @@ handle_rpl_parallel_thread(void *arg)
thd->wait_for_commit_ptr= &rgi->commit_orderer;
- if (opt_gtid_ignore_duplicates)
+ if (opt_gtid_ignore_duplicates &&
+ rgi->rli->mi->using_gtid != Master_info::USE_GTID_NO)
{
int res=
rpl_global_gtid_slave_state->check_duplicate_gtid(&rgi->current_gtid,
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index b2e895b0775..97a6421ec5c 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7453,6 +7453,8 @@ ER_JSON_PATH_EMPTY
eng "Path expression '$' is not allowed in argument %d to function '%s'."
ER_SLAVE_SAME_ID
eng "A slave with the same server_uuid/server_id as this slave has connected to the master"
+ER_FLASHBACK_NOT_SUPPORTED
+ eng "Flashback does not support %s %s"
ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
eng "Illegal parameter data types %s and %s for operation '%s'"
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
diff --git a/sql/slave.cc b/sql/slave.cc
index 3ebd1b2ec46..b28bc1d8dc5 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3977,7 +3977,8 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
DBUG_RETURN(1);
}
- if (opt_gtid_ignore_duplicates)
+ if (opt_gtid_ignore_duplicates &&
+ rli->mi->using_gtid != Master_info::USE_GTID_NO)
{
int res= rpl_global_gtid_slave_state->check_duplicate_gtid
(&serial_rgi->current_gtid, serial_rgi);
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 5d1e1e9feb2..c163044547f 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -141,7 +141,7 @@ bool With_clause::check_dependencies()
/*
Mark those elements where tables are defined with direct or indirect
- make recursion.
+ recursion.
*/
for (With_element *with_elem= with_list.first;
with_elem;
@@ -342,6 +342,8 @@ void With_element::check_dependencies_in_select(st_select_lex *sl,
tbl->with_internal_reference_map= get_elem_map();
if (in_subq)
sq_dep_map|= tbl->with->get_elem_map();
+ else
+ top_level_dep_map|= tbl->with->get_elem_map();
}
}
/* Now look for the dependencies in the subqueries of sl */
@@ -353,6 +355,53 @@ void With_element::check_dependencies_in_select(st_select_lex *sl,
/**
@brief
+ Find a recursive reference to this with element in subqueries of a select
+
+ @param sel The select in whose subqueries the reference
+ to be looked for
+
+ @details
+ The function looks for a recursive reference to this with element in
+ subqueries of select sl. When the first such reference is found
+ it is returned as the result.
+ The function assumes that the identification of all CTE references
+ has been performed earlier.
+
+ @retval
+ Pointer to the found recursive reference if the search succeeded
+ NULL - otherwise
+*/
+
+TABLE_LIST *With_element::find_first_sq_rec_ref_in_select(st_select_lex *sel)
+{
+ TABLE_LIST *rec_ref= NULL;
+ st_select_lex_unit *inner_unit= sel->first_inner_unit();
+ for (; inner_unit; inner_unit= inner_unit->next_unit())
+ {
+ st_select_lex *sl= inner_unit->first_select();
+ for (; sl; sl= sl->next_select())
+ {
+ for (TABLE_LIST *tbl= sl->table_list.first; tbl; tbl= tbl->next_local)
+ {
+ if (tbl->derived || tbl->nested_join)
+ continue;
+ if (tbl->with && tbl->with->owner== this->owner &&
+ (tbl->with_internal_reference_map & mutually_recursive))
+ {
+ rec_ref= tbl;
+ return rec_ref;
+ }
+ }
+ if ((rec_ref= find_first_sq_rec_ref_in_select(sl)))
+ return rec_ref;
+ }
+ }
+ return 0;
+}
+
+
+/**
+ @brief
Find the dependencies of this element on its siblings in a unit
@param unit The unit where to look for the dependencies
@@ -602,6 +651,10 @@ void With_clause::move_anchors_ahead()
@details
If the specification of this with element contains anchors the method
moves them at the very beginning of the specification.
+ Additionally for the other selects of the specification if none of them
+ contains a recursive reference to this with element or a mutually recursive
+ one the method looks for the first such reference in the first recursive
+ select and set a pointer to it in this->sq_rec_ref.
*/
void With_element::move_anchors_ahead()
@@ -618,6 +671,11 @@ void With_element::move_anchors_ahead()
sl->move_node(new_pos);
new_pos= sl->next_select();
}
+ else if (!sq_rec_ref && no_rec_ref_on_top_level())
+ {
+ sq_rec_ref= find_first_sq_rec_ref_in_select(sl);
+ DBUG_ASSERT(sq_rec_ref != NULL);
+ }
last_sl= sl;
}
if (spec->union_distinct)
@@ -967,6 +1025,17 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
bool TABLE_LIST::set_as_with_table(THD *thd, With_element *with_elem)
{
+ if (table)
+ {
+ /*
+ This table was prematurely identified as a temporary table.
+ We correct it here, but it's not a nice solution in the case
+ when the temporary table with this name is not used anywhere
+ else in the query.
+ */
+ thd->mark_tmp_table_as_free_for_reuse(table);
+ table= 0;
+ }
with= with_elem;
if (!with_elem->is_referenced() || with_elem->is_recursive)
derived= with_elem->spec;
diff --git a/sql/sql_cte.h b/sql/sql_cte.h
index 0e6f36cdb90..85676df9d39 100644
--- a/sql/sql_cte.h
+++ b/sql/sql_cte.h
@@ -46,6 +46,16 @@ private:
/* Dependency map of with elements mutually recursive with this with element */
table_map mutually_recursive;
/*
+ Dependency map built only for the top level references i.e. for those that
+ are encountered in from lists of the selects of the specification unit
+ */
+ table_map top_level_dep_map;
+ /*
+ Points to a recursive reference in subqueries.
+ Used only for specifications without recursive references on the top level.
+ */
+ TABLE_LIST *sq_rec_ref;
+ /*
The next with element from the circular chain of the with elements
mutually recursive with this with element.
(If This element is simply recursive than next_mutually_recursive contains
@@ -118,7 +128,7 @@ public:
stage and is used at the execution stage.
*/
select_union_recursive *rec_result;
-
+
/* List of Item_subselects containing recursive references to this CTE */
SQL_I_List<Item_subselect> sq_with_rec_ref;
@@ -127,6 +137,7 @@ public:
st_select_lex_unit *unit)
: next(NULL), base_dep_map(0), derived_dep_map(0),
sq_dep_map(0), work_dep_map(0), mutually_recursive(0),
+ top_level_dep_map(0), sq_rec_ref(NULL),
next_mutually_recursive(NULL), references(0),
query_name(name), column_list(list), spec(unit),
is_recursive(false), with_anchor(false),
@@ -154,6 +165,8 @@ public:
bool check_dependency_on(With_element *with_elem)
{ return base_dep_map & with_elem->get_elem_map(); }
+ TABLE_LIST *find_first_sq_rec_ref_in_select(st_select_lex *sel);
+
bool set_unparsed_spec(THD *thd, char *spec_start, char *spec_end);
st_select_lex_unit *clone_parsed_spec(THD *thd, TABLE_LIST *with_table);
@@ -177,11 +190,16 @@ public:
bool contains_sq_with_recursive_reference()
{ return sq_dep_map & mutually_recursive; }
+ bool no_rec_ref_on_top_level()
+ { return !(top_level_dep_map & mutually_recursive); }
+
table_map get_mutually_recursive() { return mutually_recursive; }
With_element *get_next_mutually_recursive()
{ return next_mutually_recursive; }
+ TABLE_LIST *get_sq_rec_ref() { return sq_rec_ref; }
+
bool is_anchor(st_select_lex *sel);
void move_anchors_ahead();
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 827fb21edf4..cd8540eb072 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -646,6 +646,23 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
SELECT_LEX *first_select= unit->first_select();
+ if (derived->is_recursive_with_table() &&
+ !derived->is_with_table_recursive_reference() &&
+ !derived->with->rec_result && derived->with->get_sq_rec_ref())
+ {
+ /*
+ This is a non-recursive reference to a recursive CTE whose
+ specification unit has not been prepared at the regular processing of
+ derived table references. This can happen only in the case when
+ the specification unit has no recursive references at the top level.
+ Force the preparation of the specification unit. Use a recursive
+ table reference from a subquery for this.
+ */
+ DBUG_ASSERT(derived->with->get_sq_rec_ref());
+ if (mysql_derived_prepare(lex->thd, lex, derived->with->get_sq_rec_ref()))
+ DBUG_RETURN(TRUE);
+ }
+
if (unit->prepared && derived->is_recursive_with_table() &&
!derived->table)
{
@@ -1148,6 +1165,9 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
st_select_lex_unit *unit= derived->get_unit();
st_select_lex *sl= unit->first_select();
+ if (derived->prohibit_cond_pushdown)
+ DBUG_RETURN(false);
+
/* Do not push conditions into constant derived */
if (unit->executed)
DBUG_RETURN(false);
diff --git a/sql/sql_derived.h b/sql/sql_derived.h
index c451e423032..f098cf39083 100644
--- a/sql/sql_derived.h
+++ b/sql/sql_derived.h
@@ -39,10 +39,6 @@ bool mysql_derived_cleanup(THD *thd, LEX *lex, TABLE_LIST *derived);
Item *delete_not_needed_parts(THD *thd, Item *cond);
-#if 0
-bool pushdown_cond_for_derived(THD *thd, Item **cond, TABLE_LIST *derived);
-#else
bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived);
-#endif
#endif /* SQL_DERIVED_INCLUDED */
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index b430aea4c0b..1a5fac30536 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -431,7 +431,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
tot_length+= field->field_length;
}
- else if (item->type() == Item::STRING_ITEM)
+ else if (item->get_load_data_out_param())
use_vars= 1;
}
if (use_blobs && !ex->line_term->length() && !field_term->length())
@@ -814,11 +814,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
if (item->real_type() == Item::FIELD_ITEM)
append_identifier(thd, &query_str, item->name.str, item->name.length);
else
- {
- /* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */
- DBUG_ASSERT(item->type() == Item::STRING_ITEM);
- ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
- }
+ item->get_load_data_out_param()->load_data_print(thd, &query_str);
}
query_str.append(")");
}
@@ -1062,6 +1058,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
uint length;
uchar *pos;
Item *real_item;
+ Load_data_out_param *out_param;
if (read_info.read_field())
break;
@@ -1104,18 +1101,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
}
/* Do not auto-update this field. */
field->set_has_explicit_value();
- }
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
}
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_null_value(read_info.read_charset);
else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
DBUG_RETURN(1);
- }
-
continue;
}
@@ -1129,16 +1119,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
field->store((char*) pos, length, read_info.read_charset);
field->set_has_explicit_value();
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
- read_info.read_charset);
- }
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_value((const char *) pos, length,
+ read_info.read_charset);
else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
DBUG_RETURN(1);
- }
}
if (thd->is_error())
@@ -1158,6 +1143,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
break;
for (; item ; item= it++)
{
+ Load_data_out_param *out_param;
Item *real_item= item->real_item();
if (real_item->type() == Item::FIELD_ITEM)
{
@@ -1183,16 +1169,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
ER_THD(thd, ER_WARN_TOO_FEW_RECORDS),
thd->get_stmt_da()->current_row_for_warning());
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
- }
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_null_value(read_info.read_charset);
else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
DBUG_RETURN(1);
- }
}
}
@@ -1288,6 +1268,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
while ((item= it++))
{
+ Load_data_out_param *out_param;
/* If this line is to be skipped we don't want to fill field or var */
if (skip_lines)
continue;
@@ -1319,14 +1300,15 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
/* Do not auto-update this field. */
field->set_has_explicit_value();
}
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_null_value(cs);
else
- ((Item_user_var_as_out_param *) item)->set_null_value(cs);
+ DBUG_RETURN(1);
continue;
}
if (item->type() == Item::FIELD_ITEM)
{
-
Field *field= ((Item_field *)item)->field;
field->set_notnull();
if (field == table->next_number_field)
@@ -1334,10 +1316,12 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
field->store((char *) tag->value.ptr(), tag->value.length(), cs);
field->set_has_explicit_value();
}
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_value((const char *) tag->value.ptr(),
+ tag->value.length(), cs);
else
- ((Item_user_var_as_out_param *) item)->set_value(
- (char *) tag->value.ptr(),
- tag->value.length(), cs);
+ DBUG_RETURN(1);
+
}
if (read_info.error)
@@ -1357,6 +1341,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
for ( ; item; item= it++)
{
+ Load_data_out_param *out_param;
if (item->type() == Item::FIELD_ITEM)
{
/*
@@ -1371,8 +1356,10 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
ER_THD(thd, ER_WARN_TOO_FEW_RECORDS),
thd->get_stmt_da()->current_row_for_warning());
}
+ else if ((out_param= item->get_load_data_out_param_or_error()))
+ out_param->load_data_set_null_value(cs);
else
- ((Item_user_var_as_out_param *)item)->set_null_value(cs);
+ DBUG_RETURN(1);
}
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2239c917cd5..a71d5240593 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1092,7 +1092,7 @@ int JOIN::optimize()
!skip_sort_order && !no_order && (order || group_list),
select_distinct);
uint select_nr= select_lex->select_number;
- JOIN_TAB *curr_tab= join_tab + top_join_tab_count;
+ JOIN_TAB *curr_tab= join_tab + exec_join_tab_cnt();
for (uint i= 0; i < aggr_tables; i++, curr_tab++)
{
if (select_nr == INT_MAX)
@@ -1446,7 +1446,8 @@ JOIN::optimize_inner()
}
DBUG_PRINT("info",("Select tables optimized away"));
- zero_result_cause= "Select tables optimized away";
+ if (!select_lex->have_window_funcs())
+ zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved
const_tables= top_join_tab_count= table_count;
/*
@@ -2239,13 +2240,14 @@ bool JOIN::make_aggr_tables_info()
bool implicit_grouping_with_window_funcs= implicit_grouping &&
select_lex->have_window_funcs();
-
+ bool implicit_grouping_without_tables= implicit_grouping &&
+ !tables_list;
/*
Setup last table to provide fields and all_fields lists to the next
node in the plan.
*/
- if (join_tab && top_join_tab_count)
+ if (join_tab && top_join_tab_count && tables_list)
{
join_tab[top_join_tab_count - 1].fields= &fields_list;
join_tab[top_join_tab_count - 1].all_fields= &all_fields;
@@ -2291,7 +2293,7 @@ bool JOIN::make_aggr_tables_info()
order= query.order_by;
aggr_tables++;
- curr_tab= join_tab + top_join_tab_count;
+ curr_tab= join_tab + exec_join_tab_cnt();
bzero(curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
curr_tab->join= this;
@@ -2369,7 +2371,7 @@ bool JOIN::make_aggr_tables_info()
single table queries, thus it is sufficient to test only the first
join_tab element of the plan for its access method.
*/
- if (join_tab && top_join_tab_count &&
+ if (join_tab && top_join_tab_count && tables_list &&
join_tab->is_using_loose_index_scan())
tmp_table_param.precomputed_group_by=
!join_tab->is_using_agg_loose_index_scan();
@@ -2379,7 +2381,7 @@ bool JOIN::make_aggr_tables_info()
if (need_tmp)
{
aggr_tables++;
- curr_tab= join_tab + top_join_tab_count;
+ curr_tab= join_tab + exec_join_tab_cnt();
bzero(curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
if (only_const_tables())
@@ -2438,8 +2440,9 @@ bool JOIN::make_aggr_tables_info()
/* Change sum_fields reference to calculated fields in tmp_table */
items1= ref_ptr_array_slice(2);
- if (sort_and_group || curr_tab->table->group ||
- tmp_table_param.precomputed_group_by)
+ if ((sort_and_group || curr_tab->table->group ||
+ tmp_table_param.precomputed_group_by) &&
+ !implicit_grouping_without_tables)
{
if (change_to_use_tmp_fields(thd, items1,
tmp_fields_list1, tmp_all_fields1,
@@ -2779,7 +2782,7 @@ bool JOIN::make_aggr_tables_info()
- duplicate value removal
Both of these operations are done after window function computation step.
*/
- curr_tab= join_tab + top_join_tab_count + aggr_tables - 1;
+ curr_tab= join_tab + exec_join_tab_cnt() + aggr_tables - 1;
if (select_lex->window_funcs.elements)
{
curr_tab->window_funcs_step= new Window_funcs_computation;
@@ -2794,7 +2797,7 @@ bool JOIN::make_aggr_tables_info()
// Reset before execution
set_items_ref_array(items0);
if (join_tab)
- join_tab[top_join_tab_count + aggr_tables - 1].next_select=
+ join_tab[exec_join_tab_cnt() + aggr_tables - 1].next_select=
setup_end_select_func(this, NULL);
group= has_group_by;
@@ -2835,7 +2838,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
tmp_table_param.using_outer_summary_function=
tab->tmp_table_param->using_outer_summary_function;
tab->join= this;
- DBUG_ASSERT(tab > join_tab || select_lex->have_window_funcs());
+ DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count || !tables_list);
if (tab > join_tab)
(tab - 1)->next_select= sub_select_postjoin_aggr;
tab->aggr= new (thd->mem_root) AGGR_OP(tab);
@@ -2862,7 +2865,8 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
if (make_sum_func_list(all_fields, fields_list, true))
goto err;
if (prepare_sum_aggregators(sum_funcs,
- !join_tab->is_using_agg_loose_index_scan()))
+ !(tables_list &&
+ join_tab->is_using_agg_loose_index_scan())))
goto err;
if (setup_sum_funcs(thd, sum_funcs))
goto err;
@@ -3123,7 +3127,7 @@ JOIN::reinit()
if (aggr_tables)
{
- JOIN_TAB *curr_tab= join_tab + top_join_tab_count;
+ JOIN_TAB *curr_tab= join_tab + exec_join_tab_cnt();
JOIN_TAB *end_tab= curr_tab + aggr_tables;
for ( ; curr_tab < end_tab; curr_tab++)
{
@@ -3250,7 +3254,7 @@ void JOIN::save_explain_data(Explain_query *output, bool can_overwrite,
Explain_union *eu= output->get_union(nr);
explain= &eu->fake_select_lex_explain;
join_tab[0].tracker= eu->get_fake_select_lex_tracker();
- for (uint i=0 ; i < top_join_tab_count + aggr_tables; i++)
+ for (uint i=0 ; i < exec_join_tab_cnt() + aggr_tables; i++)
{
if (join_tab[i].filesort)
{
@@ -3319,7 +3323,8 @@ void JOIN::exec_inner()
if (result->prepare2())
DBUG_VOID_RETURN;
- if (!tables_list && (table_count || !select_lex->with_sum_func))
+ if (!tables_list && (table_count || !select_lex->with_sum_func) &&
+ !select_lex->have_window_funcs())
{ // Only test of functions
if (select_options & SELECT_DESCRIBE)
select_describe(this, FALSE, FALSE, FALSE,
@@ -12011,7 +12016,7 @@ void JOIN::cleanup(bool full)
w/o tables: they don't have some members initialized and
WALK_OPTIMIZATION_TABS may not work correctly for them.
*/
- if (table_count)
+ if (top_join_tab_count && tables_list)
{
for (tab= first_breadth_first_tab(); tab;
tab= next_breadth_first_tab(first_breadth_first_tab(),
@@ -12025,7 +12030,7 @@ void JOIN::cleanup(bool full)
cleaned= true;
//psergey2: added (Q: why not in the above loop?)
{
- JOIN_TAB *curr_tab= join_tab + top_join_tab_count;
+ JOIN_TAB *curr_tab= join_tab + exec_join_tab_cnt();
for (uint i= 0; i < aggr_tables; i++, curr_tab++)
{
if (curr_tab->aggr)
@@ -12824,10 +12829,15 @@ static bool check_simple_equality(THD *thd, const Item::Context &ctx,
else
{
/* None of the fields was found in multiple equalities */
- Item_equal *item_equal= new (thd->mem_root) Item_equal(thd,
- orig_left_item,
- orig_right_item,
- FALSE);
+ Type_handler_hybrid_field_type
+ tmp(orig_left_item->type_handler_for_comparison());
+ if (tmp.aggregate_for_comparison(orig_right_item->
+ type_handler_for_comparison()))
+ return false;
+ Item_equal *item_equal=
+ new (thd->mem_root) Item_equal(thd, tmp.type_handler(),
+ orig_left_item, orig_right_item,
+ false);
item_equal->set_context_field((Item_field*)left_item);
cond_equal->current_level.push_back(item_equal, thd->mem_root);
}
@@ -12912,8 +12922,14 @@ static bool check_simple_equality(THD *thd, const Item::Context &ctx,
}
else
{
- item_equal= new (thd->mem_root) Item_equal(thd, const_item2,
- orig_field_item, TRUE);
+ Type_handler_hybrid_field_type
+ tmp(orig_left_item->type_handler_for_comparison());
+ if (tmp.aggregate_for_comparison(orig_right_item->
+ type_handler_for_comparison()))
+ return false;
+ item_equal= new (thd->mem_root) Item_equal(thd, tmp.type_handler(),
+ const_item2,
+ orig_field_item, true);
item_equal->set_context_field(field_item);
cond_equal->current_level.push_back(item_equal, thd->mem_root);
}
@@ -12982,7 +12998,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators,
const Arg_comparator *tmp= &comparators[i];
is_converted= check_simple_equality(thd,
Item::Context(Item::ANY_SUBST,
- tmp->compare_type(),
+ tmp->compare_type_handler(),
tmp->compare_collation()),
left_item, right_item,
cond_equal);
@@ -13058,7 +13074,7 @@ bool Item_func_eq::check_equality(THD *thd, COND_EQUAL *cond_equal,
}
return check_simple_equality(thd,
Context(ANY_SUBST,
- compare_type_handler()->cmp_type(),
+ compare_type_handler(),
compare_collation()),
left_item, right_item, cond_equal);
}
@@ -17786,7 +17802,7 @@ void set_postjoin_aggr_write_func(JOIN_TAB *tab)
}
}
else if (join->sort_and_group && !tmp_tbl->precomputed_group_by &&
- !join->sort_and_group_aggr_tab)
+ !join->sort_and_group_aggr_tab && join->tables_list)
{
DBUG_PRINT("info",("Using end_write_group"));
aggr->set_write_func(end_write_group);
@@ -17878,7 +17894,8 @@ do_select(JOIN *join, Procedure *procedure)
if (join->pushdown_query->store_data_in_temp_table)
{
- JOIN_TAB *last_tab= join->join_tab + join->table_count;
+ JOIN_TAB *last_tab= join->join_tab + join->table_count -
+ join->exec_join_tab_cnt();
last_tab->next_select= end_send;
enum_nested_loop_state state= last_tab->aggr->end_send();
@@ -17949,7 +17966,8 @@ do_select(JOIN *join, Procedure *procedure)
dbug_serve_apcs(join->thd, 1);
);
- JOIN_TAB *join_tab= join->join_tab + join->const_tables;
+ JOIN_TAB *join_tab= join->join_tab +
+ (join->tables_list ? join->const_tables : 0);
if (join->outer_ref_cond && !join->outer_ref_cond->val_int())
error= NESTED_LOOP_NO_MORE_ROWS;
else
@@ -23193,8 +23211,11 @@ change_refs_to_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
uint i, border= all_fields.elements - elements;
for (i= 0; (item= it++); i++)
{
- res_all_fields.push_back(new_item= item->get_tmp_table_item(thd),
- thd->mem_root);
+ if (item->type() == Item::SUM_FUNC_ITEM && item->const_item())
+ new_item= item;
+ else
+ new_item= item->get_tmp_table_item(thd);
+ res_all_fields.push_back(new_item, thd->mem_root);
ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=
new_item;
}
@@ -24449,7 +24470,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta,
void save_agg_explain_data(JOIN *join, Explain_select *xpl_sel)
{
- JOIN_TAB *join_tab=join->join_tab + join->top_join_tab_count;
+ JOIN_TAB *join_tab=join->join_tab + join->exec_join_tab_cnt();
Explain_aggr_node *prev_node;
Explain_aggr_node *node= xpl_sel->aggr_tree;
bool is_analyze= join->thd->lex->analyze_stmt;
@@ -24541,6 +24562,7 @@ int JOIN::save_explain_data_intern(Explain_query *output,
if (select_lex->master_unit()->derived)
explain->connection_type= Explain_node::EXPLAIN_NODE_DERIVED;
+ save_agg_explain_data(this, explain);
output->add_node(explain);
}
else if (pushdown_query)
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 86b8a56fb43..96764fd7f00 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1492,6 +1492,8 @@ public:
/* True if the plan guarantees that it will be returned zero or one row */
bool only_const_tables() { return const_tables == table_count; }
+ /* Number of tables actually joined at the top level */
+ uint exec_join_tab_cnt() { return tables_list ? top_join_tab_count : 0; }
int prepare(TABLE_LIST *tables, uint wind_num,
COND *conds, uint og_num, ORDER *order, bool skip_order_by,
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index abf0b77481e..7d0bd9004da 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -457,7 +457,19 @@ const Type_handler *Type_handler_time_common::type_handler_for_comparison() cons
return &type_handler_time;
}
-const Type_handler *Type_handler_temporal_with_date::type_handler_for_comparison() const
+const Type_handler *Type_handler_date_common::type_handler_for_comparison() const
+{
+ return &type_handler_newdate;
+}
+
+
+const Type_handler *Type_handler_datetime_common::type_handler_for_comparison() const
+{
+ return &type_handler_datetime;
+}
+
+
+const Type_handler *Type_handler_timestamp_common::type_handler_for_comparison() const
{
return &type_handler_datetime;
}
@@ -652,9 +664,14 @@ Type_handler_hybrid_field_type::aggregate_for_comparison(const Type_handler *h)
{
/*
We're here if both m_type_handler and h are temporal data types.
+ - If both data types are TIME, we preserve TIME.
+ - If both data types are DATE, we preserve DATE.
+ Preserving DATE is needed for EXPLAIN FORMAT=JSON,
+ to print DATE constants using proper format:
+ 'YYYY-MM-DD' rather than 'YYYY-MM-DD 00:00:00'.
*/
- if (field_type() != MYSQL_TYPE_TIME || h->field_type() != MYSQL_TYPE_TIME)
- m_type_handler= &type_handler_datetime; // DATETIME bits TIME
+ if (m_type_handler->field_type() != h->field_type())
+ m_type_handler= &type_handler_datetime;
}
}
else if ((a == INT_RESULT || a == DECIMAL_RESULT) &&
@@ -1917,9 +1934,15 @@ bool Type_handler_string_result::set_comparator_func(Arg_comparator *cmp) const
return cmp->set_cmp_func_string();
}
-bool Type_handler_temporal_result::set_comparator_func(Arg_comparator *cmp) const
+bool Type_handler_time_common::set_comparator_func(Arg_comparator *cmp) const
{
- return cmp->set_cmp_func_temporal();
+ return cmp->set_cmp_func_time();
+}
+
+bool
+Type_handler_temporal_with_date::set_comparator_func(Arg_comparator *cmp) const
+{
+ return cmp->set_cmp_func_datetime();
}
@@ -2027,7 +2050,7 @@ Type_handler_row::Item_get_cache(THD *thd, const Item *item) const
Item_cache *
Type_handler_int_result::Item_get_cache(THD *thd, const Item *item) const
{
- return new (thd->mem_root) Item_cache_int(thd, item->field_type());
+ return new (thd->mem_root) Item_cache_int(thd, item->type_handler());
}
Item_cache *
@@ -2051,7 +2074,7 @@ Type_handler_string_result::Item_get_cache(THD *thd, const Item *item) const
Item_cache *
Type_handler_temporal_result::Item_get_cache(THD *thd, const Item *item) const
{
- return new (thd->mem_root) Item_cache_temporal(thd, item->field_type());
+ return new (thd->mem_root) Item_cache_temporal(thd, item->type_handler());
}
/*************************************************************************/
@@ -2218,7 +2241,7 @@ bool Type_handler_numeric::
/* MIN/MAX can return NULL for empty set indepedent of the used column */
func->maybe_null= func->null_value= true;
if (item2->type() == Item::FIELD_ITEM)
- func->set_handler_by_field_type(item2->field_type());
+ func->set_handler(item2->type_handler());
else
func->set_handler(handler);
return false;
@@ -2269,7 +2292,7 @@ bool Type_handler_string_result::
if (item2->type() == Item::FIELD_ITEM)
{
// Fields: convert ENUM/SET to CHAR, preserve the type otherwise.
- func->set_handler_by_field_type(item->field_type());
+ func->set_handler(item->type_handler());
}
else
{
@@ -4211,3 +4234,113 @@ bool Type_handler::
}
/***************************************************************************/
+
+Item *Type_handler_int_result::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ longlong result= item->val_int();
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ return new (thd->mem_root) Item_int(thd, item->name.str, result,
+ item->max_length);
+}
+
+
+Item *Type_handler_real_result::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ double result= item->val_real();
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ return new (thd->mem_root) Item_float(thd, item->name.str, result,
+ item->decimals, item->max_length);
+}
+
+
+Item *Type_handler_decimal_result::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ my_decimal decimal_value;
+ my_decimal *result= item->val_decimal(&decimal_value);
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ return new (thd->mem_root) Item_decimal(thd, item->name.str, result,
+ item->max_length, item->decimals);
+}
+
+
+Item *Type_handler_string_result::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ StringBuffer<MAX_FIELD_WIDTH> tmp;
+ String *result= item->val_str(&tmp);
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ uint length= result->length();
+ char *tmp_str= thd->strmake(result->ptr(), length);
+ return new (thd->mem_root) Item_string(thd, item->name.str,
+ tmp_str, length, result->charset());
+}
+
+
+Item *Type_handler_time_common::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ Item_cache_temporal *cache;
+ longlong value= item->val_time_packed();
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ cache= new (thd->mem_root) Item_cache_temporal(thd, this);
+ if (cache)
+ cache->store_packed(value, item);
+ return cache;
+}
+
+
+Item *Type_handler_temporal_with_date::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ Item_cache_temporal *cache;
+ longlong value= item->val_datetime_packed();
+ if (item->null_value)
+ return new (thd->mem_root) Item_null(thd, item->name.str);
+ cache= new (thd->mem_root) Item_cache_temporal(thd, this);
+ if (cache)
+ cache->store_packed(value, item);
+ return cache;
+}
+
+
+Item *Type_handler_row::
+ make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
+{
+ if (item->type() == Item::ROW_ITEM && cmp->type() == Item::ROW_ITEM)
+ {
+ /*
+ Substitute constants only in Item_row's. Don't affect other Items
+ with ROW_RESULT (eg Item_singlerow_subselect).
+
+ For such Items more optimal is to detect if it is constant and replace
+ it with Item_row. This would optimize queries like this:
+ SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1);
+ */
+ Item_row *item_row= (Item_row*) item;
+ Item_row *comp_item_row= (Item_row*) cmp;
+ uint col;
+ /*
+ If item and comp_item are both Item_row's and have same number of cols
+ then process items in Item_row one by one.
+ We can't ignore NULL values here as this item may be used with <=>, in
+ which case NULL's are significant.
+ */
+ DBUG_ASSERT(item->result_type() == cmp->result_type());
+ DBUG_ASSERT(item_row->cols() == comp_item_row->cols());
+ col= item_row->cols();
+ while (col-- > 0)
+ resolve_const_item(thd, item_row->addr(col),
+ comp_item_row->element_index(col));
+ }
+ return NULL;
+}
+
+/***************************************************************************/
diff --git a/sql/sql_type.h b/sql/sql_type.h
index b4564b293dd..c741e2117ec 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -746,6 +746,26 @@ public:
virtual bool
subquery_type_allows_materialization(const Item *inner,
const Item *outer) const= 0;
+ /**
+ Make a simple constant replacement item for a constant "src",
+ so the new item can futher be used for comparison with "cmp", e.g.:
+ src = cmp -> replacement = cmp
+
+ "this" is the type handler that is used to compare "src" and "cmp".
+
+ @param thd - current thread, for mem_root
+ @param src - The item that we want to replace. It's a const item,
+ but it can be complex enough to calculate on every row.
+ @param cmp - The src's comparand.
+ @retval - a pointer to the created replacement Item
+ @retval - NULL, if could not create a replacement (e.g. on EOM).
+ NULL is also returned for ROWs, because instead of replacing
+ a Item_row to a new Item_row, Type_handler_row just replaces
+ its elements.
+ */
+ virtual Item *make_const_item_for_comparison(THD *thd,
+ Item *src,
+ const Item *cmp) const= 0;
virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0;
virtual bool set_comparator_func(Arg_comparator *cmp) const= 0;
virtual bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -935,6 +955,7 @@ public:
DBUG_ASSERT(0);
return false;
}
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -1137,6 +1158,7 @@ public:
SORT_FIELD_ATTR *attr) const;
bool Item_save_in_value(Item *item, st_value *value) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -1201,6 +1223,7 @@ public:
return Item_send_str(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -1257,6 +1280,7 @@ public:
SORT_FIELD_ATTR *attr) const;
bool Item_save_in_value(Item *item, st_value *value) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -1318,7 +1342,6 @@ public:
bool subquery_type_allows_materialization(const Item *inner,
const Item *outer) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
- bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const;
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const;
@@ -1401,6 +1424,7 @@ public:
Item *source_expr, Item *source_const) const;
bool subquery_type_allows_materialization(const Item *inner,
const Item *outer) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@@ -1693,6 +1717,8 @@ public:
String *print_item_value(THD *thd, Item *item, String *str) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
Item **items, uint nitems) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
+ bool set_comparator_func(Arg_comparator *cmp) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
};
@@ -1729,13 +1755,14 @@ class Type_handler_temporal_with_date: public Type_handler_temporal_result
{
public:
virtual ~Type_handler_temporal_with_date() {}
- const Type_handler *type_handler_for_comparison() const;
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_date(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
+ bool set_comparator_func(Arg_comparator *cmp) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
};
@@ -1747,6 +1774,7 @@ class Type_handler_date_common: public Type_handler_temporal_with_date
public:
virtual ~Type_handler_date_common() {}
const Name name() const { return m_name_date; }
+ const Type_handler *type_handler_for_comparison() const;
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
enum_mysql_timestamp_type mysql_timestamp_type() const
{
@@ -1790,6 +1818,7 @@ class Type_handler_datetime_common: public Type_handler_temporal_with_date
public:
virtual ~Type_handler_datetime_common() {}
const Name name() const { return m_name_datetime; }
+ const Type_handler *type_handler_for_comparison() const;
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
enum_mysql_timestamp_type mysql_timestamp_type() const
{
@@ -1846,6 +1875,7 @@ class Type_handler_timestamp_common: public Type_handler_temporal_with_date
public:
virtual ~Type_handler_timestamp_common() {}
const Name name() const { return m_name_timestamp; }
+ const Type_handler *type_handler_for_comparison() const;
enum_field_types field_type() const { return MYSQL_TYPE_TIMESTAMP; }
enum_mysql_timestamp_type mysql_timestamp_type() const
{
@@ -2169,7 +2199,7 @@ public:
bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *) const;
};
-extern Type_handler_geometry type_handler_geometry;
+extern MYSQL_PLUGIN_IMPORT Type_handler_geometry type_handler_geometry;
#endif
@@ -2229,19 +2259,14 @@ public:
Type_handler_hybrid_field_type(const Type_handler *handler)
:m_type_handler(handler)
{ }
- Type_handler_hybrid_field_type(enum_field_types type)
- :m_type_handler(Type_handler::get_handler_by_field_type(type))
- { }
Type_handler_hybrid_field_type(const Type_handler_hybrid_field_type *other)
:m_type_handler(other->m_type_handler)
{ }
const Type_handler *type_handler() const { return m_type_handler; }
- enum_field_types field_type() const { return m_type_handler->field_type(); }
enum_field_types real_field_type() const
{
return m_type_handler->real_field_type();
}
- Item_result result_type() const { return m_type_handler->result_type(); }
Item_result cmp_type() const { return m_type_handler->cmp_type(); }
enum_mysql_timestamp_type mysql_timestamp_type() const
{
@@ -2294,49 +2319,49 @@ public:
};
-extern Type_handler_row type_handler_row;
-extern Type_handler_null type_handler_null;
+extern MYSQL_PLUGIN_IMPORT Type_handler_row type_handler_row;
+extern MYSQL_PLUGIN_IMPORT Type_handler_null type_handler_null;
-extern Type_handler_float type_handler_float;
-extern Type_handler_double type_handler_double;
+extern MYSQL_PLUGIN_IMPORT Type_handler_float type_handler_float;
+extern MYSQL_PLUGIN_IMPORT Type_handler_double type_handler_double;
-extern Type_handler_bit type_handler_bit;
+extern MYSQL_PLUGIN_IMPORT Type_handler_bit type_handler_bit;
-extern Type_handler_enum type_handler_enum;
-extern Type_handler_set type_handler_set;
+extern MYSQL_PLUGIN_IMPORT Type_handler_enum type_handler_enum;
+extern MYSQL_PLUGIN_IMPORT Type_handler_set type_handler_set;
-extern Type_handler_string type_handler_string;
-extern Type_handler_var_string type_handler_var_string;
-extern Type_handler_varchar type_handler_varchar;
+extern MYSQL_PLUGIN_IMPORT Type_handler_string type_handler_string;
+extern MYSQL_PLUGIN_IMPORT Type_handler_var_string type_handler_var_string;
+extern MYSQL_PLUGIN_IMPORT Type_handler_varchar type_handler_varchar;
-extern Type_handler_tiny_blob type_handler_tiny_blob;
-extern Type_handler_medium_blob type_handler_medium_blob;
-extern Type_handler_long_blob type_handler_long_blob;
-extern Type_handler_blob type_handler_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_tiny_blob type_handler_tiny_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_medium_blob type_handler_medium_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_long_blob type_handler_long_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_blob type_handler_blob;
-extern Type_handler_tiny type_handler_tiny;
-extern Type_handler_short type_handler_short;
-extern Type_handler_int24 type_handler_int24;
-extern Type_handler_long type_handler_long;
-extern Type_handler_longlong type_handler_longlong;
+extern MYSQL_PLUGIN_IMPORT Type_handler_tiny type_handler_tiny;
+extern MYSQL_PLUGIN_IMPORT Type_handler_short type_handler_short;
+extern MYSQL_PLUGIN_IMPORT Type_handler_int24 type_handler_int24;
+extern MYSQL_PLUGIN_IMPORT Type_handler_long type_handler_long;
+extern MYSQL_PLUGIN_IMPORT Type_handler_longlong type_handler_longlong;
-extern Type_handler_newdecimal type_handler_newdecimal;
-extern Type_handler_olddecimal type_handler_olddecimal;
+extern MYSQL_PLUGIN_IMPORT Type_handler_newdecimal type_handler_newdecimal;
+extern MYSQL_PLUGIN_IMPORT Type_handler_olddecimal type_handler_olddecimal;
-extern Type_handler_year type_handler_year;
-extern Type_handler_newdate type_handler_newdate;
-extern Type_handler_date type_handler_date;
-extern Type_handler_time type_handler_time;
-extern Type_handler_time2 type_handler_time2;
-extern Type_handler_datetime type_handler_datetime;
-extern Type_handler_datetime2 type_handler_datetime2;
-extern Type_handler_timestamp type_handler_timestamp;
-extern Type_handler_timestamp2 type_handler_timestamp2;
+extern MYSQL_PLUGIN_IMPORT Type_handler_year type_handler_year;
+extern MYSQL_PLUGIN_IMPORT Type_handler_newdate type_handler_newdate;
+extern MYSQL_PLUGIN_IMPORT Type_handler_date type_handler_date;
+extern MYSQL_PLUGIN_IMPORT Type_handler_time type_handler_time;
+extern MYSQL_PLUGIN_IMPORT Type_handler_time2 type_handler_time2;
+extern MYSQL_PLUGIN_IMPORT Type_handler_datetime type_handler_datetime;
+extern MYSQL_PLUGIN_IMPORT Type_handler_datetime2 type_handler_datetime2;
+extern MYSQL_PLUGIN_IMPORT Type_handler_timestamp type_handler_timestamp;
+extern MYSQL_PLUGIN_IMPORT Type_handler_timestamp2 type_handler_timestamp2;
-extern Type_handler_tiny_blob type_handler_tiny_blob;
-extern Type_handler_blob type_handler_blob;
-extern Type_handler_medium_blob type_handler_medium_blob;
-extern Type_handler_long_blob type_handler_long_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_tiny_blob type_handler_tiny_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_blob type_handler_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_medium_blob type_handler_medium_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_long_blob type_handler_long_blob;
class Type_aggregator
{
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 243bc5c989f..bf25c0be74e 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -302,7 +302,8 @@ int select_union_recursive::send_data(List<Item> &values)
{
int rc= select_unit::send_data(values);
- if (write_err != HA_ERR_FOUND_DUPP_KEY)
+ if (write_err != HA_ERR_FOUND_DUPP_KEY &&
+ write_err != HA_ERR_FOUND_DUPP_UNIQUE)
{
int err;
if ((err= incr_table->file->ha_write_tmp_row(table->record[0])))
@@ -1538,7 +1539,7 @@ bool st_select_lex_unit::exec_recursive()
!is_unrestricted);
if (!with_element->rec_result->first_rec_table_to_update)
with_element->rec_result->first_rec_table_to_update= rec_table;
- if (with_element->level == 1)
+ if (with_element->level == 1 && rec_table->reginfo.join_tab)
rec_table->reginfo.join_tab->preread_init_done= true;
}
for (Item_subselect *sq= with_element->sq_with_rec_ref.first;
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index ac70d3d0f32..74e1ad25183 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -2761,7 +2761,7 @@ bool Window_func_runner::exec(THD *thd, TABLE *tbl, SORT_INFO *filesort_result)
bool Window_funcs_sort::exec(JOIN *join)
{
THD *thd= join->thd;
- JOIN_TAB *join_tab= &join->join_tab[join->top_join_tab_count];
+ JOIN_TAB *join_tab= join->join_tab + join->exec_join_tab_cnt();
/* Sort the table based on the most specific sorting criteria of
the window functions. */
@@ -2841,11 +2841,6 @@ bool Window_funcs_sort::setup(THD *thd, SQL_SELECT *sel,
sort_order= order;
}
filesort= new (thd->mem_root) Filesort(sort_order, HA_POS_ERROR, true, NULL);
- if (!join_tab->join->top_join_tab_count)
- {
- filesort->tracker=
- new (thd->mem_root) Filesort_tracker(thd->lex->analyze_stmt);
- }
/* Apply the same condition that the subsequent sort has. */
filesort->select= sel;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index bbd5777fa15..c2a5e183187 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -456,11 +456,22 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"MariaDB Galera and flashback do not support binlog format: %s",
binlog_format_names[var->save_result.ulonglong_value]);
+ /*
+ We allow setting up binlog_format other then ROW for session scope when
+ wsrep/flasback is enabled.This is done because of 2 reasons
+ 1. User might want to run pt-table-checksum.
+ 2. SuperUser knows what is doing :-)
+ For refrence:- MDEV-7322
+ */
if (var->type == OPT_GLOBAL)
{
- WSREP_ERROR("MariaDB Galera and flashback do not support binlog format: %s",
- binlog_format_names[var->save_result.ulonglong_value]);
+ if (WSREP(thd))
+ WSREP_ERROR("MariaDB Galera does not support binlog format: %s",
+ binlog_format_names[var->save_result.ulonglong_value]);
+ else
+ my_error(ER_FLASHBACK_NOT_SUPPORTED,MYF(0),"binlog_format",
+ binlog_format_names[var->save_result.ulonglong_value]);
return true;
}
}
diff --git a/sql/table.cc b/sql/table.cc
index 11e821da1f6..fa8ed3c2587 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2390,7 +2390,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
vcol_screen_pos+= FRM_VCOL_NEW_HEADER_SIZE;
vcol_info->set_vcol_type((enum_vcol_info_type) type);
- vcol_info->name.length= name_length;
if (name_length)
{
vcol_info->name.str= strmake_root(&share->mem_root,
diff --git a/sql/table.h b/sql/table.h
index 36b3c34884d..478b65efec5 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2154,6 +2154,8 @@ struct TABLE_LIST
/* I_S: Flags to open_table (e.g. OPEN_TABLE_ONLY or OPEN_VIEW_ONLY) */
uint i_s_requested_object;
+ bool prohibit_cond_pushdown;
+
/*
I_S: how to read the tables (SKIP_OPEN_TABLE/OPEN_FRM_ONLY/OPEN_FULL_TABLE)
*/
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index 0ccd533eac1..1121bb65fe3 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -323,7 +323,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
DBUG_ENTER("wsrep_run_wsrep_commit");
if (thd->get_stmt_da()->is_error()) {
- WSREP_ERROR("commit issue, error: %d %s",
+ WSREP_DEBUG("commit issue, error: %d %s",
thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
}
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index c553b4ba27e..7eae366df7a 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -51,6 +51,7 @@ struct wsrep_thd_shadow {
char *db;
size_t db_length;
my_hrtime_t user_time;
+ longlong row_count_func;
};
// Global wsrep parameters
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index a2d3b4923ab..4acf8a3bf1e 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -167,6 +167,7 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow)
shadow->db = thd->db;
shadow->db_length = thd->db_length;
shadow->user_time = thd->user_time;
+ shadow->row_count_func= thd->get_row_count_func();
thd->reset_db(NULL, 0);
}
@@ -187,6 +188,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow)
thd->wsrep_rgi->cleanup_after_session();
delete thd->wsrep_rgi;
thd->wsrep_rgi = NULL;
+ thd->set_row_count_func(shadow->row_count_func);
}
void wsrep_replay_transaction(THD *thd)
@@ -201,12 +203,31 @@ void wsrep_replay_transaction(THD *thd)
WSREP_ERROR("replay issue, thd has reported status already");
}
+
/*
PS reprepare observer should have been removed already.
open_table() will fail if we have dangling observer here.
*/
DBUG_ASSERT(thd->m_reprepare_observer == NULL);
+ struct da_shadow
+ {
+ enum Diagnostics_area::enum_diagnostics_status status;
+ ulonglong affected_rows;
+ ulonglong last_insert_id;
+ char message[MYSQL_ERRMSG_SIZE];
+ };
+ struct da_shadow da_status;
+ da_status.status= thd->get_stmt_da()->status();
+ if (da_status.status == Diagnostics_area::DA_OK)
+ {
+ da_status.affected_rows= thd->get_stmt_da()->affected_rows();
+ da_status.last_insert_id= thd->get_stmt_da()->last_insert_id();
+ strmake(da_status.message,
+ thd->get_stmt_da()->message(),
+ sizeof(da_status.message)-1);
+ }
+
thd->get_stmt_da()->reset_diagnostics_area();
thd->wsrep_conflict_state= REPLAYING;
@@ -274,7 +295,17 @@ void wsrep_replay_transaction(THD *thd)
}
else
{
- my_ok(thd);
+ if (da_status.status == Diagnostics_area::DA_OK)
+ {
+ my_ok(thd,
+ da_status.affected_rows,
+ da_status.last_insert_id,
+ da_status.message);
+ }
+ else
+ {
+ my_ok(thd);
+ }
}
break;
case WSREP_TRX_FAIL:
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 39d6508adf3..773b03775be 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -3683,6 +3683,8 @@ btr_cur_update_in_place(
btr_search_x_lock(index);
}
+
+ assert_block_ahi_valid(block);
#endif /* BTR_CUR_HASH_ADAPT */
row_upd_rec_in_place(rec, index, offsets, update, page_zip);
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index f7a430591ac..3ae9e95819a 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -611,6 +611,7 @@ btr_search_update_hash_ref(
|| rw_lock_own(&(block->lock), RW_LOCK_X));
ut_ad(page_align(btr_cur_get_rec(cursor))
== buf_block_get_frame(block));
+ assert_block_ahi_valid(block);
index = block->index;
@@ -1122,14 +1123,13 @@ btr_search_drop_page_hash_index(buf_block_t* block)
rw_lock_t* latch;
btr_search_t* info;
- if (!btr_search_enabled) {
- return;
- }
-
retry:
/* Do a dirty check on block->index, return if the block is
not in the adaptive hash index. */
index = block->index;
+ /* This debug check uses a dirty read that could theoretically cause
+ false positives while buf_pool_clear_hash_index() is executing. */
+ assert_block_ahi_valid(block);
if (index == NULL) {
return;
@@ -1156,6 +1156,7 @@ retry:
ut_ad(!btr_search_own_any(RW_LOCK_X));
rw_lock_s_lock(latch);
+ assert_block_ahi_valid(block);
if (block->index == NULL) {
rw_lock_s_unlock(latch);
@@ -1172,6 +1173,7 @@ retry:
#ifdef MYSQL_INDEX_DISABLE_AHI
ut_ad(!index->disable_ahi);
#endif
+ ut_ad(btr_search_enabled);
ut_ad(block->page.id.space() == index->space);
ut_a(index_id == index->id);
@@ -1290,23 +1292,8 @@ next_rec:
MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_REMOVED, n_cached);
cleanup:
-#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
- if (UNIV_UNLIKELY(block->n_pointers)) {
- /* Corruption */
- ib::error() << "Corruption of adaptive hash index."
- << " After dropping, the hash index to a page of "
- << index->name
- << ", still " << block->n_pointers
- << " hash nodes remain.";
- rw_lock_x_unlock(latch);
-
- ut_ad(btr_search_validate());
- } else {
- rw_lock_x_unlock(latch);
- }
-#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+ assert_block_ahi_valid(block);
rw_lock_x_unlock(latch);
-#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_free(folds);
}
@@ -1533,6 +1520,7 @@ btr_search_build_page_hash_index(
have to take care not to increment the counter in that
case. */
if (!block->index) {
+ assert_block_ahi_empty(block);
index->search_info->ref_count++;
}
@@ -1551,6 +1539,7 @@ btr_search_build_page_hash_index(
MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_ADDED);
MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_ADDED, n_cached);
exit_func:
+ assert_block_ahi_valid(block);
btr_search_x_unlock(index);
ut_free(folds);
@@ -1590,6 +1579,8 @@ btr_search_move_or_delete_hash_entries(
ut_a(!block->index || block->index == index);
ut_a(!(new_block->index || block->index)
|| !dict_index_is_ibuf(index));
+ assert_block_ahi_valid(block);
+ assert_block_ahi_valid(new_block);
if (new_block->index) {
@@ -1650,6 +1641,7 @@ btr_search_update_hash_on_delete(btr_cur_t* cursor)
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_X));
+ assert_block_ahi_valid(block);
index = block->index;
if (!index) {
@@ -1674,6 +1666,7 @@ btr_search_update_hash_on_delete(btr_cur_t* cursor)
}
btr_search_x_lock(index);
+ assert_block_ahi_valid(block);
if (block->index) {
ut_a(block->index == index);
@@ -1684,6 +1677,8 @@ btr_search_update_hash_on_delete(btr_cur_t* cursor)
MONITOR_INC(
MONITOR_ADAPTIVE_HASH_ROW_REMOVE_NOT_FOUND);
}
+
+ assert_block_ahi_valid(block);
}
btr_search_x_unlock(index);
@@ -1747,6 +1742,7 @@ btr_search_update_hash_node_on_insert(btr_cur_t* cursor)
}
func_exit:
+ assert_block_ahi_valid(block);
btr_search_x_unlock(index);
} else {
btr_search_x_unlock(index);
@@ -1791,6 +1787,7 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor)
block = btr_cur_get_block(cursor);
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_X));
+ assert_block_ahi_valid(block);
index = block->index;
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index d2902580924..754b2cd1c25 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -347,7 +347,7 @@ typedef std::map<
const byte*,
buf_chunk_t*,
std::less<const byte*>,
- ut_allocator<std::pair<const byte*, buf_chunk_t*> > >
+ ut_allocator<std::pair<const byte* const, buf_chunk_t*> > >
buf_pool_chunk_map_t;
static buf_pool_chunk_map_t* buf_chunk_map_reg;
@@ -405,10 +405,22 @@ buf_pool_register_chunk(
/** Decrypt a page.
@param[in,out] bpage Page control block
+@param[in,out] space tablespace
@return whether the operation was successful */
static
bool
-buf_page_decrypt_after_read(buf_page_t* bpage);
+buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space)
+ MY_ATTRIBUTE((nonnull));
+
+/** Check if page is maybe compressed, encrypted or both when we encounter
+corrupted page. Note that we can't be 100% sure if page is corrupted
+or decrypt/decompress just failed.
+@param[in,out] bpage Page
+@return true if page corrupted, false if not */
+static
+bool
+buf_page_check_corrupt(buf_page_t* bpage)
+ MY_ATTRIBUTE((nonnull, warn_unused_result));
/* prototypes for new functions added to ha_innodb.cc */
trx_t* innobase_get_trx();
@@ -600,10 +612,6 @@ buf_page_is_zeroes(
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@param[in] use_legacy_big_endian use legacy big endian algorithm
@return true if the page is in crc32 checksum format. */
bool
@@ -611,24 +619,18 @@ buf_page_is_checksum_valid_crc32(
const byte* read_buf,
ulint checksum_field1,
ulint checksum_field2,
-#ifdef UNIV_INNOCHECKSUM
- uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo,
-#endif /* UNIV_INNOCHECKSUM */
bool use_legacy_big_endian)
{
const uint32_t crc32 = buf_calc_page_crc32(read_buf,
use_legacy_big_endian);
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled
- && curr_algo == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
+ if (log_file
+ && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
fprintf(log_file, "page::%lu;"
" crc32 calculated = %u;"
" recorded checksum field1 = %lu recorded"
- " checksum field2 =%lu\n", page_no,
+ " checksum field2 =%lu\n", cur_page_num,
crc32, checksum_field1, checksum_field2);
}
#endif /* UNIV_INNOCHECKSUM */
@@ -659,23 +661,12 @@ invalid:
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@return true if the page is in innodb checksum format. */
bool
buf_page_is_checksum_valid_innodb(
const byte* read_buf,
ulint checksum_field1,
- ulint checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )
+ ulint checksum_field2)
{
/* There are 2 valid formulas for
checksum_field2 (old checksum field) which algo=innodb could have
@@ -691,31 +682,31 @@ buf_page_is_checksum_valid_innodb(
ulint new_checksum = buf_calc_page_new_checksum(read_buf);
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled
- && curr_algo == SRV_CHECKSUM_ALGORITHM_INNODB) {
+ if (log_file
+ && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) {
fprintf(log_file, "page::%lu;"
" old style: calculated ="
" %lu; recorded = %lu\n",
- page_no, old_checksum,
+ cur_page_num, old_checksum,
checksum_field2);
fprintf(log_file, "page::%lu;"
" new style: calculated ="
" %lu; crc32 = %u; recorded = %lu\n",
- page_no, new_checksum,
+ cur_page_num, new_checksum,
buf_calc_page_crc32(read_buf), checksum_field1);
}
- if (is_log_enabled
- && curr_algo == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
+ if (log_file
+ && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
fprintf(log_file, "page::%lu;"
" old style: calculated ="
" %lu; recorded checksum = %lu\n",
- page_no, old_checksum,
+ cur_page_num, old_checksum,
checksum_field2);
fprintf(log_file, "page::%lu;"
" new style: calculated ="
" %lu; recorded checksum = %lu\n",
- page_no, new_checksum,
+ cur_page_num, new_checksum,
checksum_field1);
}
#endif /* UNIV_INNOCHECKSUM */
@@ -755,23 +746,12 @@ buf_page_is_checksum_valid_innodb(
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@return true if the page is in none checksum format. */
bool
buf_page_is_checksum_valid_none(
const byte* read_buf,
ulint checksum_field1,
- ulint checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )
+ ulint checksum_field2)
{
#ifndef DBUG_OFF
if (checksum_field1 != checksum_field2
@@ -787,13 +767,13 @@ buf_page_is_checksum_valid_none(
#endif /* DBUG_OFF */
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled
- && curr_algo == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) {
+ if (log_file
+ && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) {
fprintf(log_file,
"page::%lu; none checksum: calculated"
" = %lu; recorded checksum_field1 = %lu"
" recorded checksum_field2 = %lu\n",
- page_no, BUF_NO_CHECKSUM_MAGIC,
+ cur_page_num, BUF_NO_CHECKSUM_MAGIC,
checksum_field1, checksum_field2);
}
#endif /* UNIV_INNOCHECKSUM */
@@ -808,10 +788,6 @@ the LSN
@param[in] read_buf database page
@param[in] page_size page size
@param[in] space tablespace
-@param[in] page_no page number of given read_buf
-@param[in] strict_check true if strict-check option is enabled
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
@return TRUE if corrupted */
bool
buf_page_is_corrupted(
@@ -819,12 +795,6 @@ buf_page_is_corrupted(
const byte* read_buf,
const page_size_t& page_size,
const fil_space_t* space
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no,
- bool strict_check,
- bool is_log_enabled,
- FILE* log_file
-#endif /* UNIV_INNOCHECKSUM */
)
{
ulint checksum_field1;
@@ -914,15 +884,8 @@ buf_page_is_corrupted(
}
if (page_size.is_compressed()) {
-#ifdef UNIV_INNOCHECKSUM
- return(!page_zip_verify_checksum(read_buf,
- page_size.physical(),
- page_no, strict_check,
- is_log_enabled, log_file));
-#else
return(!page_zip_verify_checksum(read_buf,
page_size.physical()));
-#endif /* UNIV_INNOCHECKSUM */
}
checksum_field1 = mach_read_from_4(
@@ -964,10 +927,10 @@ buf_page_is_corrupted(
}
#ifdef UNIV_INNOCHECKSUM
if (i >= page_size.logical()) {
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "Page::%lu"
" is empty and uncorrupted\n",
- page_no);
+ cur_page_num);
}
return(false);
}
@@ -993,20 +956,13 @@ buf_page_is_corrupted(
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
if (buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
-#ifdef UNIV_INNOCHECKSUM
- page_no, is_log_enabled, log_file, curr_algo,
-#endif /* UNIV_INNOCHECKSUM */
- false)) {
+ checksum_field1, checksum_field2, false)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo)) {
-#else /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
+#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
@@ -1014,20 +970,20 @@ buf_page_is_corrupted(
SRV_CHECKSUM_ALGORITHM_NONE,
page_id);
}
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "page::%lu;"
" old style: calculated = " ULINTPF ";"
- " recorded = " ULINTPF "\n", page_no,
+ " recorded = " ULINTPF "\n", cur_page_num,
buf_calc_page_old_checksum(read_buf),
checksum_field2);
fprintf(log_file, "page::%lu;"
" new style: calculated = " ULINTPF ";"
" crc32 = %u; recorded = " ULINTPF "\n",
- page_no,
+ cur_page_num,
buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf),
checksum_field1);
@@ -1043,11 +999,7 @@ buf_page_is_corrupted(
Otherwise we check innodb checksum first. */
if (legacy_big_endian_checksum) {
if (buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
-#ifdef UNIV_INNOCHECKSUM
- page_no, is_log_enabled, log_file, curr_algo,
-#endif /* UNIV_INNOCHECKSUM */
- true)) {
+ checksum_field1, checksum_field2, true)) {
return(false);
}
@@ -1055,11 +1007,8 @@ buf_page_is_corrupted(
}
if (buf_page_is_checksum_valid_innodb(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo)) {
-#else /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
+#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
@@ -1067,27 +1016,23 @@ buf_page_is_corrupted(
SRV_CHECKSUM_ALGORITHM_INNODB,
page_id);
}
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
return(false);
}
/* If legacy checksum is not checked, do it now. */
if (!legacy_checksum_checked && buf_page_is_checksum_valid_crc32(
- read_buf, checksum_field1, checksum_field2,
-#ifdef UNIV_INNOCHECKSUM
- page_no, is_log_enabled, log_file, curr_algo,
-#endif /* UNIV_INNOCHECKSUM */
- true)) {
+ read_buf, checksum_field1, checksum_field2, true)) {
legacy_big_endian_checksum = true;
return(false);
}
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "Fail; page %lu"
" invalid (fails crc32 checksum)\n",
- page_no);
+ cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
@@ -1096,20 +1041,13 @@ buf_page_is_corrupted(
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
if (buf_page_is_checksum_valid_innodb(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo)) {
-#else /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
+#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
@@ -1117,19 +1055,19 @@ buf_page_is_corrupted(
SRV_CHECKSUM_ALGORITHM_NONE,
page_id);
}
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "page::%lu;"
" old style: calculated = %lu;"
- " recorded = %lu\n", page_no,
+ " recorded = %lu\n", cur_page_num,
buf_calc_page_old_checksum(read_buf),
checksum_field2);
fprintf(log_file, "page::%lu;"
" new style: calculated = %lu;"
" crc32 = %u; recorded = %lu\n",
- page_no,
+ cur_page_num,
buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf),
checksum_field1);
@@ -1138,19 +1076,11 @@ buf_page_is_corrupted(
return(false);
}
-#ifdef UNIV_INNOCHECKSUM
- if (buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
- page_no, is_log_enabled, log_file, curr_algo, false)
- || buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
- page_no, is_log_enabled, log_file, curr_algo, true)) {
-#else /* UNIV_INNOCHECKSUM */
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2, false)
|| buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2, true)) {
-
+#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
@@ -1158,16 +1088,16 @@ buf_page_is_corrupted(
SRV_CHECKSUM_ALGORITHM_CRC32,
page_id);
}
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
return(false);
}
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "Fail; page %lu"
" invalid (fails innodb checksum)\n",
- page_no);
+ cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
@@ -1175,54 +1105,39 @@ buf_page_is_corrupted(
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
if (buf_page_is_checksum_valid_none(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
return(false);
}
-#ifdef UNIV_INNOCHECKSUM
- if (buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
- page_no, is_log_enabled, log_file, curr_algo, false)
- || buf_page_is_checksum_valid_crc32(read_buf,
- checksum_field1, checksum_field2,
- page_no, is_log_enabled, log_file, curr_algo, true)) {
-#else /* UNIV_INNOCHECKSUM */
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2, false)
|| buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2, true)) {
-
+#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
page_id);
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
return(false);
}
if (buf_page_is_checksum_valid_innodb(read_buf,
- checksum_field1, checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- , page_no, is_log_enabled, log_file, curr_algo)) {
-#else /* UNIV_INNOCHECKSUM */
- )) {
+ checksum_field1, checksum_field2)) {
+#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
page_id);
-#endif /* UNIV_INNOCHECKSUM */
+#endif /* !UNIV_INNOCHECKSUM */
return(false);
}
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "Fail; page %lu"
" invalid (fails none checksum)\n",
- page_no);
+ cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
@@ -1496,6 +1411,10 @@ buf_block_init(
{
UNIV_MEM_DESC(frame, UNIV_PAGE_SIZE);
+ /* This function should only be executed at database startup or by
+ buf_pool_resize(). Either way, adaptive hash index must not exist. */
+ assert_block_ahi_empty_on_init(block);
+
block->frame = frame;
block->page.buf_pool_index = buf_pool_index(buf_pool);
@@ -1526,11 +1445,6 @@ buf_block_init(
ut_d(block->in_unzip_LRU_list = FALSE);
ut_d(block->in_withdraw_list = FALSE);
-#ifdef BTR_CUR_HASH_ADAPT
-# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
- block->n_pointers = 0;
-# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
page_zip_des_init(&block->page.zip);
mutex_create(LATCH_ID_BUF_BLOCK_MUTEX, &block->mutex);
@@ -1763,7 +1677,9 @@ buf_chunk_not_freed(
== block->page.newest_modification);
ut_ad(block->page.oldest_modification == 0
|| block->page.oldest_modification
- == recv_sys->recovered_lsn);
+ == recv_sys->recovered_lsn
+ || srv_force_recovery
+ == SRV_FORCE_NO_LOG_REDO);
ut_ad(block->page.buf_fix_count == 0);
ut_ad(block->page.io_fix == BUF_IO_NONE);
break;
@@ -2244,6 +2160,10 @@ buf_page_realloc(
/* set other flags of buf_block_t */
#ifdef BTR_CUR_HASH_ADAPT
+ /* This code should only be executed by buf_pool_resize(),
+ while the adaptive hash index is disabled. */
+ assert_block_ahi_empty(block);
+ assert_block_ahi_empty_on_init(new_block);
ut_ad(!block->index);
new_block->index = NULL;
new_block->n_hash_helps = 0;
@@ -3210,20 +3130,23 @@ buf_pool_clear_hash_index()
for (; i--; block++) {
dict_index_t* index = block->index;
+ assert_block_ahi_valid(block);
/* We can set block->index = NULL
- when we have an x-latch on search latch;
- see the comment in buf0buf.h */
+ and block->n_pointers = 0
+ when btr_search_own_all(RW_LOCK_X);
+ see the comments in buf0buf.h */
if (!index) {
- /* Not hashed */
continue;
}
- block->index = NULL;
+ ut_ad(buf_block_get_state(block)
+ == BUF_BLOCK_FILE_PAGE);
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers = 0;
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+ block->index = NULL;
}
}
}
@@ -3915,6 +3838,9 @@ buf_block_init_low(
{
block->skip_flush_check = false;
#ifdef BTR_CUR_HASH_ADAPT
+ /* No adaptive hash index entries may point to a previously
+ unused (and now freshly allocated) block. */
+ assert_block_ahi_empty_on_init(block);
block->index = NULL;
block->n_hash_helps = 0;
@@ -5833,16 +5759,14 @@ buf_mark_space_corrupt(
return(ret);
}
-/********************************************************************//**
-Check if page is maybe compressed, encrypted or both when we encounter
+/** Check if page is maybe compressed, encrypted or both when we encounter
corrupted page. Note that we can't be 100% sure if page is corrupted
or decrypt/decompress just failed.
@param[in,out] bpage Page
@return true if page corrupted, false if not */
-UNIV_INTERN
+static
bool
-buf_page_check_corrupt(
- buf_page_t* bpage)
+buf_page_check_corrupt(buf_page_t* bpage)
{
byte* dst_frame = (bpage->zip.data) ? bpage->zip.data :
((buf_block_t*) bpage)->frame;
@@ -5945,8 +5869,13 @@ buf_page_io_complete(
ulint read_space_id;
ut_ad(bpage->zip.data != NULL || ((buf_block_t*)bpage)->frame != NULL);
+ fil_space_t* space = fil_space_acquire_for_io(
+ bpage->id.space());
+ if (!space) {
+ return false;
+ }
- buf_page_decrypt_after_read(bpage);
+ buf_page_decrypt_after_read(bpage, space);
if (bpage->size.is_compressed()) {
frame = bpage->zip.data;
@@ -6020,21 +5949,17 @@ database_corrupted:
&& buf_mark_space_corrupt(bpage)) {
ib::info() << "Simulated IMPORT "
"corruption";
+ fil_space_release_for_io(space);
return(true);
}
goto page_not_corrupt;
);
if (!bpage->encrypted) {
- fil_system_enter();
- fil_space_t* space = fil_space_get_by_id(bpage->id.space());
- fil_system_exit();
-
ib::error()
<< "Database page corruption on disk"
" or a failed file read of tablespace "
- << (space->name ? space->name : "NULL")
- << " page " << bpage->id
+ << space->name << " page " << bpage->id
<< ". You may have to recover from "
<< "a backup.";
@@ -6063,6 +5988,7 @@ database_corrupted:
if (bpage->id.space() > TRX_SYS_SPACE
&& buf_mark_space_corrupt(bpage)) {
+ fil_space_release_for_io(space);
return(false);
} else {
if (!bpage->encrypted) {
@@ -6088,6 +6014,7 @@ database_corrupted:
ut_error;
}
+ fil_space_release_for_io(space);
return(false);
}
}
@@ -6131,6 +6058,8 @@ database_corrupted:
}
}
+
+ fil_space_release_for_io(space);
} else {
/* io_type == BUF_IO_WRITE */
if (bpage->slot) {
@@ -7398,7 +7327,7 @@ buf_page_encrypt_before_write(
ut_ad(bpage->key_version == 0);
return src_frame;
case TRX_SYS_PAGE_NO:
- if (bpage->id.space() == 0) {
+ if (bpage->id.space() == TRX_SYS_SPACE) {
/* don't encrypt/compress page as it contains
address to dblwr buffer */
bpage->key_version = 0;
@@ -7491,11 +7420,15 @@ buf_page_encrypt_before_write(
/** Decrypt a page.
@param[in,out] bpage Page control block
+@param[in,out] space tablespace
@return whether the operation was successful */
static
bool
-buf_page_decrypt_after_read(buf_page_t* bpage)
+buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space)
{
+ ut_ad(space->n_pending_ios > 0);
+ ut_ad(space->id == bpage->id.space());
+
bool compressed = bpage->size.is_compressed();
const page_size_t& size = bpage->size;
byte* dst_frame = compressed ? bpage->zip.data :
@@ -7514,12 +7447,10 @@ buf_page_decrypt_after_read(buf_page_t* bpage)
return (true);
}
- FilSpace space(bpage->id.space(), true);
-
/* Page is encrypted if encryption information is found from
tablespace and page contains used key_version. This is true
also for pages first compressed and then encrypted. */
- if (!space() || !space()->crypt_data) {
+ if (!space->crypt_data) {
key_version = 0;
}
@@ -7591,6 +7522,7 @@ buf_page_decrypt_after_read(buf_page_t* bpage)
}
}
+ ut_ad(space->n_pending_ios > 0);
return (success);
}
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index 6a0179f36ad..f99fc6434de 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -168,8 +168,7 @@ doublewrite buffer is placed on the trx system header page.
@return true if successful, false if not. */
MY_ATTRIBUTE((warn_unused_result))
bool
-buf_dblwr_create(void)
-/*==================*/
+buf_dblwr_create()
{
buf_block_t* block2;
buf_block_t* new_block;
@@ -510,7 +509,7 @@ buf_dblwr_init_or_load_pages(
/** Process and remove the double write buffer pages for all tablespaces. */
void
-buf_dblwr_process(void)
+buf_dblwr_process()
{
ulint page_no_dblwr = 0;
byte* read_buf;
@@ -527,9 +526,7 @@ buf_dblwr_process(void)
i != recv_dblwr.pages.end();
++i, ++page_no_dblwr) {
byte* page = *i;
- ulint page_no = page_get_page_no(page);
ulint space_id = page_get_space_id(page);
-
fil_space_t* space = fil_space_get(space_id);
if (space == NULL) {
@@ -540,6 +537,7 @@ buf_dblwr_process(void)
fil_space_open_if_needed(space);
+ const ulint page_no = page_get_page_no(page);
const page_id_t page_id(space_id, page_no);
if (page_no >= space->size) {
@@ -676,8 +674,7 @@ buf_dblwr_process(void)
/****************************************************************//**
Frees doublewrite buffer. */
void
-buf_dblwr_free(void)
-/*================*/
+buf_dblwr_free()
{
/* Free the double write data structures. */
ut_a(buf_dblwr != NULL);
@@ -932,8 +929,7 @@ important to call this function after a batch of writes has been posted,
and also when we may have to wait for a page latch! Otherwise a deadlock
of threads can occur. */
void
-buf_dblwr_flush_buffered_writes(void)
-/*=================================*/
+buf_dblwr_flush_buffered_writes()
{
byte* write_buf;
ulint first_free;
diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc
index 9b86b1c16da..ce7488e3d1f 100644
--- a/storage/innobase/buf/buf0dump.cc
+++ b/storage/innobase/buf/buf0dump.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
-Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -796,6 +796,7 @@ extern "C"
os_thread_ret_t
DECLARE_THREAD(buf_dump_thread)(void*)
{
+ my_thread_init();
ut_ad(!srv_read_only_mode);
/* JAN: TODO: MySQL 5.7 PSI
#ifdef UNIV_PFS_THREAD
@@ -836,6 +837,7 @@ DECLARE_THREAD(buf_dump_thread)(void*)
srv_buf_dump_thread_active = false;
+ my_thread_end();
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */
os_thread_exit();
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 366e92a7112..d0c0316bf13 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -1006,7 +1006,7 @@ buf_flush_write_block_low(
buf_flush_t flush_type, /*!< in: type of flush */
bool sync) /*!< in: true if sync IO request */
{
- fil_space_t* space = fil_space_acquire(bpage->id.space(), true);
+ fil_space_t* space = fil_space_acquire_for_io(bpage->id.space());
if (!space) {
return;
}
@@ -1121,10 +1121,16 @@ buf_flush_write_block_low(
/* true means we want to evict this page from the
LRU list as well. */
+ /* The tablespace could already have been dropped,
+ because fil_io(request, sync) would already have
+ decremented the node->n_pending. However,
+ buf_page_io_complete() only needs to look up the
+ tablespace during read requests, not during writes. */
+ ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_WRITE);
buf_page_io_complete(bpage, true);
}
- fil_space_release(space);
+ fil_space_release_for_io(space);
/* Increment the counter of I/O operations used
for selecting LRU policy. */
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index c492ec60494..10a8561d38d 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -295,21 +295,29 @@ next_page:
continue;
}
- mutex_enter(&((buf_block_t*) bpage)->mutex);
+ buf_block_t* block = reinterpret_cast<buf_block_t*>(bpage);
- {
- bool skip = bpage->buf_fix_count > 0
- || !((buf_block_t*) bpage)->index;
+ mutex_enter(&block->mutex);
- mutex_exit(&((buf_block_t*) bpage)->mutex);
+ /* This debug check uses a dirty read that could
+ theoretically cause false positives while
+ buf_pool_clear_hash_index() is executing.
+ (Other conflicting access paths to the adaptive hash
+ index should not be possible, because when a
+ tablespace is being discarded or dropped, there must
+ be no concurrect access to the contained tables.) */
+ assert_block_ahi_valid(block);
- if (skip) {
- /* Skip this block, because there are
- no adaptive hash index entries
- pointing to it, or because we cannot
- drop them due to the buffer-fix. */
- goto next_page;
- }
+ bool skip = bpage->buf_fix_count > 0 || !block->index;
+
+ mutex_exit(&block->mutex);
+
+ if (skip) {
+ /* Skip this block, because there are
+ no adaptive hash index entries
+ pointing to it, or because we cannot
+ drop them due to the buffer-fix. */
+ goto next_page;
}
/* Store the page number so that we can drop the hash
@@ -800,6 +808,17 @@ scan_again:
bpage->id, bpage->size);
goto scan_again;
+ } else {
+ /* This debug check uses a dirty read that could
+ theoretically cause false positives while
+ buf_pool_clear_hash_index() is executing,
+ if the writes to block->index=NULL and
+ block->n_pointers=0 are reordered.
+ (Other conflicting access paths to the adaptive hash
+ index should not be possible, because when a
+ tablespace is being discarded or dropped, there must
+ be no concurrect access to the contained tables.) */
+ assert_block_ahi_empty((buf_block_t*) bpage);
}
#endif /* BTR_CUR_HASH_ADAPT */
@@ -1156,6 +1175,9 @@ buf_LRU_get_free_only(
|| !buf_block_will_withdrawn(buf_pool, block)) {
/* found valid free block */
buf_page_mutex_enter(block);
+ /* No adaptive hash index entries may point to
+ a free block. */
+ assert_block_ahi_empty(block);
buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE);
@@ -2030,17 +2052,10 @@ buf_LRU_block_free_non_file_page(
case BUF_BLOCK_READY_FOR_USE:
break;
default:
- ib::error() << "Block:" << block
- << " incorrect state:" << buf_get_state_name(block)
- << " in buf_LRU_block_free_non_file_page";
- return; /* Continue */
+ ut_error;
}
-#ifdef BTR_CUR_HASH_ADAPT
-# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
- ut_a(block->n_pointers == 0);
-# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
-#endif /* BTR_CUR_HASH_ADAPT */
+ assert_block_ahi_empty(block);
ut_ad(!block->page.in_free_list);
ut_ad(!block->page.in_flush_list);
ut_ad(!block->page.in_LRU_list);
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index 4d68ad5ac51..f5bd088ce5c 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -290,6 +290,24 @@ buf_read_ahead_random(
below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we
do not try to read outside the bounds of the tablespace! */
if (fil_space_t* space = fil_space_acquire(page_id.space())) {
+
+#ifdef UNIV_DEBUG
+ if (srv_file_per_table) {
+ ulint size = 0;
+
+ for (const fil_node_t* node =
+ UT_LIST_GET_FIRST(space->chain);
+ node != NULL;
+ node = UT_LIST_GET_NEXT(chain, node)) {
+
+ size += os_file_get_size(node->handle)
+ / page_size.physical();
+ }
+
+ ut_ad(size == space->size);
+ }
+#endif /* UNIV_DEBUG */
+
if (high > space->size) {
high = space->size;
}
@@ -896,4 +914,3 @@ buf_read_recv_pages(
DBUG_PRINT("ib_buf", ("recovery read-ahead (%u pages)",
unsigned(n_stored)));
}
-
diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc
index 8d5bde4e0e2..3ae6639cd73 100644
--- a/storage/innobase/dict/dict0boot.cc
+++ b/storage/innobase/dict/dict0boot.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -488,7 +488,9 @@ dict_boot(void)
err = ibuf_init_at_db_start();
if (err == DB_SUCCESS) {
- if (srv_read_only_mode && !ibuf_is_empty()) {
+ if (srv_read_only_mode
+ && srv_force_recovery != SRV_FORCE_NO_LOG_REDO
+ && !ibuf_is_empty()) {
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
ib::error() << "Change buffer must be empty when"
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index 13db213259c..7a6f09569a6 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -810,7 +810,12 @@ dict_mem_fill_vcol_from_v_indexes(
index;
index = dict_table_get_next_index(index)) {
- if (!dict_index_has_virtual(index)) {
+ /* Skip if the index have newly added
+ virtual column because field name is NULL.
+ Later virtual column set will be
+ refreshed during loading of table. */
+ if (!dict_index_has_virtual(index)
+ || index->has_new_v_col) {
continue;
}
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 47bab4141de..537a70c2069 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -139,7 +139,7 @@ then we would store 5,7,10,11,12 in the array. */
typedef std::vector<ib_uint64_t, ut_allocator<ib_uint64_t> > boundaries_t;
/** Allocator type used for index_map_t. */
-typedef ut_allocator<std::pair<const char*, dict_index_t*> >
+typedef ut_allocator<std::pair<const char* const, dict_index_t*> >
index_map_t_allocator;
/** Auxiliary map used for sorting indexes by name in dict_stats_save(). */
@@ -1152,10 +1152,11 @@ dict_stats_analyze_index_level(
them away) which brings non-determinism. We skip only
leaf-level delete marks because delete marks on
non-leaf level do not make sense. */
- if (level == 0 &&
+
+ if (level == 0 && (srv_stats_include_delete_marked ? 0:
rec_get_deleted_flag(
rec,
- page_is_comp(btr_pcur_get_page(&pcur)))) {
+ page_is_comp(btr_pcur_get_page(&pcur))))) {
if (rec_is_last_on_page
&& !prev_rec_is_copied
@@ -1176,7 +1177,6 @@ dict_stats_analyze_index_level(
continue;
}
-
rec_offsets = rec_get_offsets(
rec, index, rec_offsets, n_uniq, &heap);
@@ -1334,8 +1334,12 @@ enum page_scan_method_t {
the given page and count the number of
distinct ones, also ignore delete marked
records */
- QUIT_ON_FIRST_NON_BORING/* quit when the first record that differs
+ QUIT_ON_FIRST_NON_BORING,/* quit when the first record that differs
from its right neighbor is found */
+ COUNT_ALL_NON_BORING_INCLUDE_DEL_MARKED/* scan all records on
+ the given page and count the number of
+ distinct ones, include delete marked
+ records */
};
/* @} */
@@ -1608,6 +1612,8 @@ dict_stats_analyze_index_below_cur(
offsets_rec = dict_stats_scan_page(
&rec, offsets1, offsets2, index, page, n_prefix,
+ srv_stats_include_delete_marked ?
+ COUNT_ALL_NON_BORING_INCLUDE_DEL_MARKED:
COUNT_ALL_NON_BORING_AND_SKIP_DEL_MARKED, n_diff,
n_external_pages);
diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc
index 4ffee160c9f..876d1bcb342 100644
--- a/storage/innobase/dict/dict0stats_bg.cc
+++ b/storage/innobase/dict/dict0stats_bg.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
-Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -31,6 +31,7 @@ Created Apr 25, 2012 Vasil Dimov
#include "row0mysql.h"
#include "srv0start.h"
#include "ut0new.h"
+#include "fil0fil.h"
#include <vector>
@@ -318,8 +319,9 @@ dict_stats_process_entry_from_recalc_pool()
return;
}
- /* Check whether table is corrupted */
- if (table->corrupted) {
+ ut_ad(!dict_table_is_temporary(table));
+
+ if (!fil_table_accessible(table)) {
dict_table_close(table, TRUE, FALSE);
mutex_exit(&dict_sys->mutex);
return;
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 016b7c3d24e..b031a77baa8 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -629,7 +629,7 @@ fil_space_encrypt(
fil_space_crypt_t* crypt_data = space->crypt_data;
const page_size_t page_size(space->flags);
- ut_ad(space->n_pending_ops);
+ ut_ad(space->n_pending_ios > 0);
byte* tmp = fil_encrypt_buf(crypt_data, space->id, offset, lsn,
src_frame, page_size, dst_frame);
@@ -821,7 +821,7 @@ fil_space_decrypt(
*decrypted = false;
ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted());
- ut_ad(space->n_pending_ops > 0);
+ ut_ad(space->n_pending_ios > 0);
bool encrypted = fil_space_decrypt(space->crypt_data, tmp_frame,
page_size, src_frame, &err);
@@ -2492,10 +2492,6 @@ bool
fil_space_verify_crypt_checksum(
byte* page,
const page_size_t& page_size,
-#ifdef UNIV_INNOCHECKSUM
- bool strict_check, /*!< --strict-check */
- FILE* log_file, /*!< --log */
-#endif /* UNIV_INNOCHECKSUM */
ulint space,
ulint offset)
{
@@ -2541,14 +2537,7 @@ fil_space_verify_crypt_checksum(
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
bool valid = page_zip_verify_checksum(page,
- page_size.physical()
-#ifdef UNIV_INNOCHECKSUM
- , offset,
- strict_check,
- log_file != NULL,
- log_file
-#endif
- );
+ page_size.physical());
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, old);
@@ -2594,19 +2583,11 @@ fil_space_verify_crypt_checksum(
ulint checksum2 = mach_read_from_4(
page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
-#ifdef UNIV_INNOCHECKSUM
-# define CKARGS page, checksum1, checksum2, \
- offset, log_file != NULL, log_file, algorithm
-#else
-# define CKARGS page, checksum1, checksum2
-#endif
-
bool valid = buf_page_is_checksum_valid_crc32(
- CKARGS, false
+ page, checksum1, checksum2, false
/* FIXME: also try the original crc32 that was
buggy on big-endian architectures? */)
- || buf_page_is_checksum_valid_innodb(CKARGS);
-#undef CKARGS
+ || buf_page_is_checksum_valid_innodb(page, checksum1, checksum2);
if (encrypted && valid) {
/* If page is encrypted and traditional checksums match,
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index d91ab3530a1..7a169c0bf2c 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -30,6 +30,7 @@ Created 10/25/1995 Heikki Tuuri
#include "fil0crypt.h"
#include "btr0btr.h"
+#include "btr0sea.h"
#include "buf0buf.h"
#include "dict0boot.h"
#include "dict0dict.h"
@@ -39,6 +40,7 @@ Created 10/25/1995 Heikki Tuuri
#include "fsp0space.h"
#include "fsp0sysspace.h"
#include "hash0hash.h"
+#include "log0log.h"
#include "log0recv.h"
#include "mach0data.h"
#include "mem0mem.h"
@@ -55,9 +57,6 @@ Created 10/25/1995 Heikki Tuuri
#include "os0event.h"
#include "sync0sync.h"
#include "buf0flu.h"
-#include "srv0start.h"
-#include "trx0purge.h"
-#include "ut0new.h"
#include "os0api.h"
/** Tries to close a file in the LRU list. The caller must hold the fil_sys
@@ -1507,6 +1506,13 @@ fil_space_free_low(
ut_ad(srv_fast_shutdown == 2 || !srv_was_started
|| space->max_lsn == 0);
+ /* Wait for fil_space_release_for_io(); after
+ fil_space_detach(), the tablespace cannot be found, so
+ fil_space_acquire_for_io() would return NULL */
+ while (space->n_pending_ios) {
+ os_thread_sleep(100);
+ }
+
for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain);
node != NULL; ) {
ut_d(space->size -= node->size);
@@ -2268,13 +2274,11 @@ Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
@param[in] silent whether to silently ignore missing tablespaces
-@param[in] for_io whether to look up the tablespace while performing I/O
- (possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
inline
fil_space_t*
-fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
+fil_space_acquire_low(ulint id, bool silent)
{
fil_space_t* space;
@@ -2287,7 +2291,7 @@ fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
ib::warn() << "Trying to access missing"
" tablespace " << id;
}
- } else if (!for_io && space->is_stopping()) {
+ } else if (space->is_stopping()) {
space = NULL;
} else {
space->n_pending_ops++;
@@ -2302,14 +2306,12 @@ fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
-@param[in] for_io whether to look up the tablespace while performing I/O
- (possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
-fil_space_acquire(ulint id, bool for_io)
+fil_space_acquire(ulint id)
{
- return(fil_space_acquire_low(id, false, for_io));
+ return(fil_space_acquire_low(id, false));
}
/** Acquire a tablespace that may not exist.
@@ -2336,6 +2338,39 @@ fil_space_release(fil_space_t* space)
mutex_exit(&fil_system->mutex);
}
+/** Acquire a tablespace for reading or writing a block,
+when it could be dropped concurrently.
+@param[in] id tablespace ID
+@return the tablespace
+@retval NULL if missing */
+fil_space_t*
+fil_space_acquire_for_io(ulint id)
+{
+ mutex_enter(&fil_system->mutex);
+
+ fil_space_t* space = fil_space_get_by_id(id);
+
+ if (space) {
+ space->n_pending_ios++;
+ }
+
+ mutex_exit(&fil_system->mutex);
+
+ return(space);
+}
+
+/** Release a tablespace acquired with fil_space_acquire_for_io().
+@param[in,out] space tablespace to release */
+void
+fil_space_release_for_io(fil_space_t* space)
+{
+ mutex_enter(&fil_system->mutex);
+ ut_ad(space->magic_n == FIL_SPACE_MAGIC_N);
+ ut_ad(space->n_pending_ios > 0);
+ space->n_pending_ios--;
+ mutex_exit(&fil_system->mutex);
+}
+
/********************************************************//**
Creates the database directory for a table if it does not exist yet. */
void
@@ -2837,15 +2872,15 @@ enum fil_operation_t {
@return 0 if no operations else count + 1. */
static
ulint
-fil_check_pending_ops(
- fil_space_t* space,
- ulint count)
+fil_check_pending_ops(const fil_space_t* space, ulint count)
{
ut_ad(mutex_own(&fil_system->mutex));
- const ulint n_pending_ops = space ? space->n_pending_ops : 0;
+ if (space == NULL) {
+ return 0;
+ }
- if (n_pending_ops) {
+ if (ulint n_pending_ops = space->n_pending_ops) {
if (count > 5000) {
ib::warn() << "Trying to close/delete/truncate"
@@ -3057,6 +3092,32 @@ fil_close_tablespace(
return(err);
}
+/** Determine whether a table can be accessed in operations that are
+not (necessarily) protected by meta-data locks.
+(Rollback would generally be protected, but rollback of
+FOREIGN KEY CASCADE/SET NULL is not protected by meta-data locks
+but only by InnoDB table locks, which may be broken by TRUNCATE TABLE.)
+@param[in] table persistent table
+checked @return whether the table is accessible */
+bool
+fil_table_accessible(const dict_table_t* table)
+{
+ if (UNIV_UNLIKELY(table->ibd_file_missing || table->corrupted)) {
+ return(false);
+ }
+
+ if (fil_space_t* space = fil_space_acquire(table->space)) {
+ bool accessible = !space->is_stopping();
+ fil_space_release(space);
+ ut_ad(accessible || dict_table_is_file_per_table(table));
+ return(accessible);
+ } else {
+ /* The tablespace may momentarily be missing during
+ TRUNCATE TABLE. */
+ return(false);
+ }
+}
+
/** Deletes an IBD tablespace, either general or single-table.
The tablespace must be cached in the memory cache. This will delete the
datafile, fil_space_t & fil_node_t entries from the file_system_t cache.
@@ -3266,20 +3327,34 @@ fil_prepare_for_truncate(
return(err);
}
-/**********************************************************************//**
-Reinitialize the original tablespace header with the same space id
-for single tablespace */
+/** Reinitialize the original tablespace header with the same space id
+for single tablespace
+@param[in] id space id of the tablespace
+@param[in] size size in blocks
+@param[in] trx Transaction covering truncate */
void
fil_reinit_space_header(
-/*====================*/
- ulint id, /*!< in: space id */
- ulint size) /*!< in: size in blocks */
+ ulint id,
+ ulint size,
+ trx_t* trx)
{
ut_a(!is_system_tablespace(id));
/* Invalidate in the buffer pool all pages belonging
- to the tablespace */
+ to the tablespace. The buffer pool scan may take long
+ time to complete, therefore we release dict_sys->mutex
+ and the dict operation lock during the scan and aquire
+ it again after the buffer pool scan.*/
+
+ row_mysql_unlock_data_dictionary(trx);
+
+ /* Lock the search latch in shared mode to prevent user
+ from disabling AHI during the scan */
+ btr_search_s_lock_all();
+ DEBUG_SYNC_C("buffer_pool_scan");
buf_LRU_flush_or_remove_pages(id, BUF_REMOVE_ALL_NO_WRITE, 0);
+ btr_search_s_unlock_all();
+ row_mysql_lock_data_dictionary(trx);
/* Remove all insert buffer entries for the tablespace */
ibuf_delete_for_discarded_space(id);
@@ -5492,7 +5567,7 @@ fil_flush(
void
fil_flush(fil_space_t* space)
{
- ut_ad(space->n_pending_ops > 0);
+ ut_ad(space->n_pending_ios > 0);
ut_ad(space->purpose == FIL_TYPE_TABLESPACE
|| space->purpose == FIL_TYPE_IMPORT);
@@ -6498,6 +6573,12 @@ fil_names_clear(
bool do_write)
{
mtr_t mtr;
+ ulint mtr_checkpoint_size = LOG_CHECKPOINT_FREE_PER_THREAD;
+
+ DBUG_EXECUTE_IF(
+ "increase_mtr_checkpoint_size",
+ mtr_checkpoint_size = 75 * 1024;
+ );
ut_ad(log_mutex_own());
@@ -6531,11 +6612,24 @@ fil_names_clear(
fil_names_write(space, &mtr);
do_write = true;
+ const mtr_buf_t* mtr_log = mtr_get_log(&mtr);
+
+ /** If the mtr buffer size exceeds the size of
+ LOG_CHECKPOINT_FREE_PER_THREAD then commit the multi record
+ mini-transaction, start the new mini-transaction to
+ avoid the parsing buffer overflow error during recovery. */
+
+ if (mtr_log->size() > mtr_checkpoint_size) {
+ ut_ad(mtr_log->size() < (RECV_PARSING_BUF_SIZE / 2));
+ mtr.commit_checkpoint(lsn, false);
+ mtr.start();
+ }
+
space = next;
}
if (do_write) {
- mtr.commit_checkpoint(lsn);
+ mtr.commit_checkpoint(lsn, true);
} else {
ut_ad(!mtr.has_modifications());
}
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc
index 65c39eae89d..5f7ce530776 100644
--- a/storage/innobase/fil/fil0pagecompress.cc
+++ b/storage/innobase/fil/fil0pagecompress.cc
@@ -107,7 +107,7 @@ fil_compress_page(
/* page_compression does not apply to tables or tablespaces
that use ROW_FORMAT=COMPRESSED */
- ut_ad(!space || !page_size_t(space->flags).is_compressed());
+ ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags));
if (encrypted) {
header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE;
@@ -137,7 +137,6 @@ fil_compress_page(
case FIL_PAGE_TYPE_XDES:
case FIL_PAGE_PAGE_COMPRESSED:
*out_len = len;
-
goto err_exit;
}
@@ -323,7 +322,6 @@ fil_compress_page(
/* Actual write needs to be alligned on block size */
if (write_size % block_size) {
size_t tmp = write_size;
-
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
/* Clean up the end of buffer */
memset(out_buf+tmp, 0, write_size - tmp);
@@ -626,11 +624,11 @@ err_exit:
/* Note that as we have found the page is corrupted, so
all this could be incorrect. */
ulint space_id = mach_read_from_4(buf+FIL_PAGE_SPACE_ID);
- const FilSpace space(space_id, true);
+ fil_space_t* space = fil_space_acquire_for_io(space_id);
ib::error() << "Corruption: Page is marked as compressed"
<< " space: " << space_id << " name: "
- << (space() ? space()->name : "NULL")
+ << (space ? space->name : "NULL")
<< " but uncompress failed with error: " << err
<< " size: " << actual_size
<< " len: " << len
@@ -638,4 +636,5 @@ err_exit:
<< fil_get_compression_alg_name(compression_alg) << ".";
buf_page_print(buf, univ_page_size, 0);
+ fil_space_release_for_io(space);
}
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index dd0e036170c..79020fb4442 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -93,6 +93,7 @@ static const ulint FTS_DEADLOCK_RETRY_WAIT = 100000;
/** variable to record innodb_fts_internal_tbl_name for information
schema table INNODB_FTS_INSERTED etc. */
char* fts_internal_tbl_name = NULL;
+char* fts_internal_tbl_name2 = NULL;
/** InnoDB default stopword list:
There are different versions of stopwords, the stop words listed
@@ -6496,6 +6497,36 @@ fts_check_corrupt_index(
return(0);
}
+/* Get parent table name if it's a fts aux table
+@param[in] aux_table_name aux table name
+@param[in] aux_table_len aux table length
+@return parent table name, or NULL */
+char*
+fts_get_parent_table_name(
+ const char* aux_table_name,
+ ulint aux_table_len)
+{
+ fts_aux_table_t aux_table;
+ char* parent_table_name = NULL;
+
+ if (fts_is_aux_table_name(&aux_table, aux_table_name, aux_table_len)) {
+ dict_table_t* parent_table;
+
+ parent_table = dict_table_open_on_id(
+ aux_table.parent_id, TRUE, DICT_TABLE_OP_NORMAL);
+
+ if (parent_table != NULL) {
+ parent_table_name = mem_strdupl(
+ parent_table->name.m_name,
+ strlen(parent_table->name.m_name));
+
+ dict_table_close(parent_table, TRUE, FALSE);
+ }
+ }
+
+ return(parent_table_name);
+}
+
/** Check the validity of the parent table.
@param[in] aux_table auxiliary table
@return true if it is a valid table or false if it is not */
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index f1e717c353a..820e82dc600 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -578,9 +578,6 @@ fts_zip_read_word(
fts_zip_t* zip, /*!< in: Zip state + data */
fts_string_t* word) /*!< out: uncompressed word */
{
-#ifdef UNIV_DEBUG
- ulint i;
-#endif
short len = 0;
void* null = NULL;
byte* ptr = word->f_str;
@@ -656,10 +653,9 @@ fts_zip_read_word(
}
}
-#ifdef UNIV_DEBUG
/* All blocks must be freed at end of inflate. */
if (zip->status != Z_OK) {
- for (i = 0; i < ib_vector_size(zip->blocks); ++i) {
+ for (ulint i = 0; i < ib_vector_size(zip->blocks); ++i) {
if (ib_vector_getp(zip->blocks, i)) {
ut_free(ib_vector_getp(zip->blocks, i));
ib_vector_set(zip->blocks, i, &null);
@@ -670,7 +666,6 @@ fts_zip_read_word(
if (ptr != NULL) {
ut_ad(word->f_len == strlen((char*) ptr));
}
-#endif /* UNIV_DEBUG */
return(zip->status == Z_OK || zip->status == Z_STREAM_END ? ptr : NULL);
}
diff --git a/storage/innobase/ha/ha0ha.cc b/storage/innobase/ha/ha0ha.cc
index 5822bd6755c..f620db6f62e 100644
--- a/storage/innobase/ha/ha0ha.cc
+++ b/storage/innobase/ha/ha0ha.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -189,6 +190,12 @@ ha_clear(
}
#ifdef BTR_CUR_HASH_ADAPT
+# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+/** Maximum number of records in a page */
+static const lint MAX_N_POINTERS
+ = UNIV_PAGE_SIZE_MAX / REC_N_NEW_EXTRA_BYTES;
+# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+
/*************************************************************//**
Inserts an entry into a hash table. If an entry with the same fold number
is found, its node is updated to point to the new data, and no new node
@@ -235,9 +242,11 @@ ha_insert_for_fold_func(
buf_block_t* prev_block = prev_node->block;
ut_a(prev_block->frame
== page_align(prev_node->data));
- ut_a(prev_block->n_pointers > 0);
- prev_block->n_pointers--;
- block->n_pointers++;
+ ut_a(my_atomic_addlint(
+ &prev_block->n_pointers, -1)
+ < MAX_N_POINTERS);
+ ut_a(my_atomic_addlint(&block->n_pointers, 1)
+ < MAX_N_POINTERS);
}
prev_node->block = block;
@@ -268,7 +277,8 @@ ha_insert_for_fold_func(
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
- block->n_pointers++;
+ ut_a(my_atomic_addlint(&block->n_pointers, 1)
+ < MAX_N_POINTERS);
}
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
@@ -329,8 +339,8 @@ ha_delete_hash_node(
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
ut_a(del_node->block->frame = page_align(del_node->data));
- ut_a(del_node->block->n_pointers > 0);
- del_node->block->n_pointers--;
+ ut_a(my_atomic_addlint(&del_node->block->n_pointers, -1)
+ < MAX_N_POINTERS);
}
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
@@ -372,9 +382,10 @@ ha_search_and_update_if_found_func(
if (node) {
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
- ut_a(node->block->n_pointers > 0);
- node->block->n_pointers--;
- new_block->n_pointers++;
+ ut_a(my_atomic_addlint(&node->block->n_pointers, -1)
+ < MAX_N_POINTERS);
+ ut_a(my_atomic_addlint(&new_block->n_pointers, 1)
+ < MAX_N_POINTERS);
}
node->block = new_block;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 950aae729fd..72cf0418e81 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -215,45 +215,45 @@ static uint innobase_old_blocks_pct;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
-static char* innobase_data_home_dir = NULL;
-static char* innobase_data_file_path = NULL;
-static char* innobase_temp_data_file_path = NULL;
-static char* innobase_file_format_name = NULL;
-static char* innobase_change_buffering = NULL;
-static char* innobase_enable_monitor_counter = NULL;
-static char* innobase_disable_monitor_counter = NULL;
-static char* innobase_reset_monitor_counter = NULL;
-static char* innobase_reset_all_monitor_counter = NULL;
+static char* innobase_data_home_dir;
+static char* innobase_data_file_path;
+static char* innobase_temp_data_file_path;
+static char* innobase_file_format_name;
+static char* innobase_change_buffering;
+static char* innobase_enable_monitor_counter;
+static char* innobase_disable_monitor_counter;
+static char* innobase_reset_monitor_counter;
+static char* innobase_reset_all_monitor_counter;
/* The highest file format being used in the database. The value can be
set by user, however, it will be adjusted to the newer file format if
a table of such format is created/opened. */
-char* innobase_file_format_max = NULL;
+char* innobase_file_format_max;
/** Default value of innodb_file_format */
static const char* innodb_file_format_default = "Barracuda";
/** Default value of innodb_file_format_max */
static const char* innodb_file_format_max_default = "Antelope";
-static char* innobase_file_flush_method = NULL;
+static char* innobase_file_flush_method;
/* This variable can be set in the server configure file, specifying
stopword table to be used */
-static char* innobase_server_stopword_table = NULL;
+static char* innobase_server_stopword_table;
/* Below we have boolean-valued start-up parameters, and their default
values */
-static my_bool innobase_file_format_check = TRUE;
-static my_bool innobase_use_atomic_writes = TRUE;
-static my_bool innobase_use_doublewrite = TRUE;
-static my_bool innobase_use_checksums = TRUE;
-static my_bool innobase_locks_unsafe_for_binlog = FALSE;
-static my_bool innobase_rollback_on_timeout = FALSE;
-static my_bool innobase_create_status_file = FALSE;
-my_bool innobase_stats_on_metadata = TRUE;
-static my_bool innobase_large_prefix = FALSE;
-static my_bool innodb_optimize_fulltext_only = FALSE;
+static my_bool innobase_file_format_check;
+static my_bool innobase_use_atomic_writes;
+static my_bool innobase_use_doublewrite;
+static my_bool innobase_use_checksums;
+static my_bool innobase_locks_unsafe_for_binlog;
+static my_bool innobase_rollback_on_timeout;
+static my_bool innobase_create_status_file;
+my_bool innobase_stats_on_metadata;
+static my_bool innobase_large_prefix;
+static my_bool innodb_optimize_fulltext_only;
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
@@ -1322,15 +1322,11 @@ void
innobase_commit_concurrency_init_default();
/*=======================================*/
-/** @brief Initialize the default and max value of innodb_undo_logs.
-
-Once InnoDB is running, the default value and the max value of
-innodb_undo_logs must be equal to the available undo logs,
-given by srv_available_undo_logs. */
+/** @brief Adjust some InnoDB startup parameters based on file contents
+or innodb_page_size. */
static
void
-innobase_undo_logs_init_default_max();
-/*==================================*/
+innodb_params_adjust();
/************************************************************//**
Validate the file format name and return its corresponding id.
@@ -4235,6 +4231,11 @@ innobase_change_buffering_inited_ok:
if (UNIV_PAGE_SIZE_DEF != srv_page_size) {
ib::info() << "innodb_page_size=" << srv_page_size;
+
+ srv_max_undo_log_size = std::max(
+ srv_max_undo_log_size,
+ ulonglong(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES)
+ * srv_page_size);
}
if (srv_log_write_ahead_size > srv_page_size) {
@@ -4395,12 +4396,6 @@ innobase_change_buffering_inited_ok:
}
*/
- /* Since we in this module access directly the fields of a trx
- struct, and due to different headers and flags it might happen that
- ib_mutex_t has a different size in this module and in InnoDB
- modules, we check at run time that the size is the same in
- these compilation modules. */
-
err = innobase_start_or_create_for_mysql();
if (srv_buf_pool_size_org != 0) {
@@ -4425,9 +4420,8 @@ innobase_change_buffering_inited_ok:
os_thread_sleep(20);
}
- srv_was_started = TRUE;
- /* Adjust the innodb_undo_logs config object */
- innobase_undo_logs_init_default_max();
+ srv_was_started = true;
+ innodb_params_adjust();
innobase_old_blocks_pct = static_cast<uint>(
buf_LRU_old_ratio_update(innobase_old_blocks_pct, TRUE));
@@ -10415,13 +10409,7 @@ ha_innobase::rnd_init(
bool scan) /*!< in: true if table/index scan FALSE otherwise */
{
TrxInInnoDB trx_in_innodb(m_prebuilt->trx);
-
- if (trx_in_innodb.is_aborted()) {
-
- return(innobase_rollback(ht, m_user_thd, false));
- }
-
- int err;
+ int err;
/* Store the active index value so that we can restore the original
value after a scan */
@@ -13755,7 +13743,8 @@ ha_innobase::delete_table(
extension, in contrast to ::create */
normalize_table_name(norm_name, name);
- if (srv_read_only_mode) {
+ if (srv_read_only_mode
+ || srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
}
@@ -14188,116 +14177,6 @@ ha_innobase::rename_table(
}
/*********************************************************************//**
-Returns the exact number of records that this client can see using this
-handler object.
-@return Error code in case something goes wrong.
-These errors will abort the current query:
- case HA_ERR_LOCK_DEADLOCK:
- case HA_ERR_LOCK_TABLE_FULL:
- case HA_ERR_LOCK_WAIT_TIMEOUT:
- case HA_ERR_QUERY_INTERRUPTED:
-For other error codes, the server will fall back to counting records. */
-
-#ifdef MYSQL_57_SELECT_COUNT_OPTIMIZATION
-int
-ha_innobase::records(
-/*==================*/
- ha_rows* num_rows) /*!< out: number of rows */
-{
- DBUG_ENTER("ha_innobase::records()");
-
- dberr_t ret;
- ulint n_rows = 0; /* Record count in this view */
-
- update_thd();
-
- if (dict_table_is_discarded(m_prebuilt->table)) {
- ib_senderrf(
- m_user_thd,
- IB_LOG_LEVEL_ERROR,
- ER_TABLESPACE_DISCARDED,
- table->s->table_name.str);
-
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
-
- } else if (m_prebuilt->table->ibd_file_missing) {
- ib_senderrf(
- m_user_thd, IB_LOG_LEVEL_ERROR,
- ER_TABLESPACE_MISSING,
- table->s->table_name.str);
-
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_TABLESPACE_MISSING);
-
- } else if (m_prebuilt->table->corrupted) {
- ib_errf(m_user_thd, IB_LOG_LEVEL_WARN,
- ER_INNODB_INDEX_CORRUPT,
- "Table '%s' is corrupt.",
- table->s->table_name.str);
-
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
- }
-
- TrxInInnoDB trx_in_innodb(m_prebuilt->trx);
-
- m_prebuilt->trx->op_info = "counting records";
-
- dict_index_t* index = dict_table_get_first_index(m_prebuilt->table);
-
- ut_ad(dict_index_is_clust(index));
-
- m_prebuilt->index_usable = row_merge_is_index_usable(
- m_prebuilt->trx, index);
-
- if (!m_prebuilt->index_usable) {
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED);
- }
-
- /* (Re)Build the m_prebuilt->mysql_template if it is null to use
- the clustered index and just the key, no off-record data. */
- m_prebuilt->index = index;
- dtuple_set_n_fields(m_prebuilt->search_tuple, 0);
- m_prebuilt->read_just_key = 1;
- build_template(false);
-
- /* Count the records in the clustered index */
- ret = row_scan_index_for_mysql(m_prebuilt, index, false, &n_rows);
- reset_template();
- switch (ret) {
- case DB_SUCCESS:
- break;
- case DB_DEADLOCK:
- case DB_LOCK_TABLE_FULL:
- case DB_LOCK_WAIT_TIMEOUT:
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(convert_error_code_to_mysql(ret, 0, m_user_thd));
- case DB_INTERRUPTED:
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_QUERY_INTERRUPTED);
- default:
- /* No other error besides the three below is returned from
- row_scan_index_for_mysql(). Make a debug catch. */
- *num_rows = HA_POS_ERROR;
- ut_ad(0);
- DBUG_RETURN(-1);
- }
-
- m_prebuilt->trx->op_info = "";
-
- if (thd_killed(m_user_thd)) {
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(HA_ERR_QUERY_INTERRUPTED);
- }
-
- *num_rows= n_rows;
- DBUG_RETURN(0);
-}
-#endif /* MYSQL_57_SELECT_COUNT_OPTIMIZATION */
-
-/*********************************************************************//**
Estimates the number of index records in a range.
@return estimated number of rows */
@@ -15543,7 +15422,7 @@ ha_innobase::check(
ret = row_count_rtree_recs(m_prebuilt, &n_rows);
} else {
ret = row_scan_index_for_mysql(
- m_prebuilt, index, true, &n_rows);
+ m_prebuilt, index, &n_rows);
}
DBUG_EXECUTE_IF(
@@ -15821,6 +15700,28 @@ get_foreign_key_info(
f_key_info.update_method = FK_OPTION_RESTRICT;
}
+ /* Load referenced table to update FK referenced key name. */
+ if (foreign->referenced_table == NULL) {
+
+ dict_table_t* ref_table;
+
+ ut_ad(mutex_own(&dict_sys->mutex));
+ ref_table = dict_table_open_on_name(
+ foreign->referenced_table_name_lookup,
+ TRUE, FALSE, DICT_ERR_IGNORE_NONE);
+
+ if (ref_table == NULL) {
+
+ ib::info() << "Foreign Key referenced table "
+ << foreign->referenced_table_name
+ << " not found for foreign table "
+ << foreign->foreign_table_name;
+ } else {
+
+ dict_table_close(ref_table, TRUE, FALSE);
+ }
+ }
+
if (foreign->referenced_index
&& foreign->referenced_index->name != NULL) {
referenced_key_name = thd_make_lex_string(
@@ -17617,6 +17518,37 @@ ha_innobase::get_auto_increment(
whether we update the table autoinc counter or not. */
ulonglong col_max_value = innobase_get_int_col_max_value(table->next_number_field);
+ /** The following logic is needed to avoid duplicate key error
+ for autoincrement column.
+
+ (1) InnoDB gives the current autoincrement value with respect
+ to increment and offset value.
+
+ (2) Basically it does compute_next_insert_id() logic inside InnoDB
+ to avoid the current auto increment value changed by handler layer.
+
+ (3) It is restricted only for insert operations. */
+
+ if (increment > 1 && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE
+ && autoinc < col_max_value) {
+
+ ulonglong prev_auto_inc = autoinc;
+
+ autoinc = ((autoinc - 1) + increment - offset)/ increment;
+
+ autoinc = autoinc * increment + offset;
+
+ /* If autoinc exceeds the col_max_value then reset
+ to old autoinc value. Because in case of non-strict
+ sql mode, boundary value is not considered as error. */
+
+ if (autoinc >= col_max_value) {
+ autoinc = prev_auto_inc;
+ }
+
+ ut_ad(autoinc > 0);
+ }
+
/* Called for the first time ? */
if (trx->n_autoinc_rows == 0) {
@@ -18722,6 +18654,41 @@ innodb_internal_table_validate(
return(ret);
}
+/****************************************************************//**
+Update global variable "fts_internal_tbl_name" with the "saved"
+stopword table name value. This function is registered as a callback
+with MySQL. */
+static
+void
+innodb_internal_table_update(
+/*=========================*/
+ THD* thd, /*!< in: thread handle */
+ struct st_mysql_sys_var* var, /*!< in: pointer to
+ system variable */
+ void* var_ptr,/*!< out: where the
+ formal string goes */
+ const void* save) /*!< in: immediate result
+ from check function */
+{
+ const char* table_name;
+ char* old;
+
+ ut_a(save != NULL);
+ ut_a(var_ptr != NULL);
+
+ table_name = *static_cast<const char*const*>(save);
+ old = *(char**) var_ptr;
+ *(char**) var_ptr = table_name ? my_strdup(table_name, MYF(0)) : NULL;
+ my_free(old);
+
+ fts_internal_tbl_name2 = *(char**) var_ptr;
+ if (fts_internal_tbl_name2 == NULL) {
+ fts_internal_tbl_name = const_cast<char*>("default");
+ } else {
+ fts_internal_tbl_name = fts_internal_tbl_name2;
+ }
+}
+
#ifdef BTR_CUR_HASH_ADAPT
/****************************************************************//**
Update the system variable innodb_adaptive_hash_index using the "saved"
@@ -20610,6 +20577,12 @@ static MYSQL_SYSVAR_BOOL(use_atomic_writes, innobase_use_atomic_writes,
"the directFS filesystem or with Shannon cards using any file system.",
NULL, NULL, TRUE);
+static MYSQL_SYSVAR_BOOL(stats_include_delete_marked,
+ srv_stats_include_delete_marked,
+ PLUGIN_VAR_OPCMDARG,
+ "Include delete marked records when calculating persistent statistics",
+ NULL, NULL, FALSE);
+
static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
PLUGIN_VAR_RQCMDARG,
"Number of IOPs the server can do. Tunes the background IO rate",
@@ -21118,6 +21091,13 @@ static MYSQL_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
NULL, NULL, 5000L, 1L, ~0UL, 0);
+static MYSQL_SYSVAR_BOOL(deadlock_detect, innobase_deadlock_detect,
+ PLUGIN_VAR_NOCMDARG,
+ "Enable/disable InnoDB deadlock detector (default ON)."
+ " if set to OFF, deadlock detection is skipped,"
+ " and we rely on innodb_lock_wait_timeout in case of deadlock.",
+ NULL, NULL, TRUE);
+
static MYSQL_SYSVAR_LONG(fill_factor, innobase_fill_factor,
PLUGIN_VAR_RQCMDARG,
"Percentage of B-tree page filled during bulk insert",
@@ -21133,11 +21113,11 @@ static MYSQL_SYSVAR_BOOL(disable_sort_file_cache, srv_disable_sort_file_cache,
"Whether to disable OS system file cache for sort I/O",
NULL, NULL, FALSE);
-static MYSQL_SYSVAR_STR(ft_aux_table, fts_internal_tbl_name,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
+static MYSQL_SYSVAR_STR(ft_aux_table, fts_internal_tbl_name2,
+ PLUGIN_VAR_RQCMDARG,
"FTS internal auxiliary table to be checked",
innodb_internal_table_validate,
- NULL, NULL);
+ innodb_internal_table_update, NULL);
static MYSQL_SYSVAR_ULONG(ft_cache_size, fts_max_cache_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -21305,11 +21285,11 @@ static MYSQL_SYSVAR_STR(undo_directory, srv_undo_dir,
static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "Number of undo tablespaces to use. ",
+ "Number of undo tablespaces to use.",
NULL, NULL,
0L, /* Default seting */
0L, /* Minimum value */
- 95L, 0); /* Maximum value */
+ TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */
static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs,
PLUGIN_VAR_OPCMDARG,
@@ -21321,12 +21301,10 @@ static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs,
static MYSQL_SYSVAR_ULONGLONG(max_undo_log_size, srv_max_undo_log_size,
PLUGIN_VAR_OPCMDARG,
- "Maximum size of UNDO tablespace in MB (If UNDO tablespace grows"
- " beyond this size it will be truncated in due course). ",
+ "Desired maximum UNDO tablespace size in bytes",
NULL, NULL,
- 1024 * 1024 * 1024L,
- 10 * 1024 * 1024L,
- ~0ULL, 0);
+ 10 << 20, 10 << 20,
+ 1ULL << (32 + UNIV_PAGE_SIZE_SHIFT_MAX), 0);
static MYSQL_SYSVAR_ULONG(purge_rseg_truncate_frequency,
srv_purge_rseg_truncate_frequency,
@@ -21789,6 +21767,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(temp_data_file_path),
MYSQL_SYSVAR(data_home_dir),
MYSQL_SYSVAR(doublewrite),
+ MYSQL_SYSVAR(stats_include_delete_marked),
MYSQL_SYSVAR(use_atomic_writes),
MYSQL_SYSVAR(fast_shutdown),
MYSQL_SYSVAR(read_io_threads),
@@ -21815,6 +21794,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(lock_schedule_algorithm),
MYSQL_SYSVAR(locks_unsafe_for_binlog),
MYSQL_SYSVAR(lock_wait_timeout),
+ MYSQL_SYSVAR(deadlock_detect),
MYSQL_SYSVAR(page_size),
MYSQL_SYSVAR(log_buffer_size),
MYSQL_SYSVAR(log_file_size),
@@ -22034,19 +22014,25 @@ innobase_commit_concurrency_init_default()
= innobase_commit_concurrency;
}
-/** @brief Initialize the default and max value of innodb_undo_logs.
-
-Once InnoDB is running, the default value and the max value of
-innodb_undo_logs must be equal to the available undo logs,
-given by srv_available_undo_logs. */
+/** @brief Adjust some InnoDB startup parameters based on file contents
+or innodb_page_size. */
static
void
-innobase_undo_logs_init_default_max()
-/*=================================*/
+innodb_params_adjust()
{
+ /* The default value and the max value of
+ innodb_undo_logs must be equal to the available undo logs. */
MYSQL_SYSVAR_NAME(undo_logs).max_val
= MYSQL_SYSVAR_NAME(undo_logs).def_val
= srv_available_undo_logs;
+ MYSQL_SYSVAR_NAME(max_undo_log_size).max_val
+ = 1ULL << (32 + UNIV_PAGE_SIZE_SHIFT);
+ MYSQL_SYSVAR_NAME(max_undo_log_size).min_val
+ = MYSQL_SYSVAR_NAME(max_undo_log_size).def_val
+ = ulonglong(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES)
+ * srv_page_size;
+ MYSQL_SYSVAR_NAME(max_undo_log_size).max_val
+ = 1ULL << (32 + UNIV_PAGE_SIZE_SHIFT);
}
/****************************************************************************
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index 297b73ed02f..64147291338 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -219,9 +219,6 @@ public:
ha_rows estimate_rows_upper_bound();
- // JAN: TODO: MySQL 5.7
- // int records(ha_rows* num_rows);
-
void update_create_info(HA_CREATE_INFO* create_info);
int create(
diff --git a/storage/innobase/handler/ha_innopart.cc b/storage/innobase/handler/ha_innopart.cc
index 7abc1f29b60..1041871805e 100644
--- a/storage/innobase/handler/ha_innopart.cc
+++ b/storage/innobase/handler/ha_innopart.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2016, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -3004,41 +3004,6 @@ ha_innopart::truncate()
DBUG_RETURN(error);
}
-/** Total number of rows in all used partitions.
-Returns the exact number of records that this client can see using this
-handler object.
-@param[out] num_rows Number of rows.
-@return 0 or error number. */
-int
-ha_innopart::records(
- ha_rows* num_rows)
-{
- ha_rows n_rows;
- int err;
- DBUG_ENTER("ha_innopart::records()");
-
- *num_rows = 0;
-
- /* The index scan is probably so expensive, so the overhead
- of the rest of the function is neglectable for each partition.
- So no current reason for optimizing this further. */
-
- for (uint i = m_part_info->get_first_used_partition();
- i < m_tot_parts;
- i = m_part_info->get_next_used_partition(i)) {
-
- set_partition(i);
- err = ha_innobase::records(&n_rows);
- update_partition(i);
- if (err != 0) {
- *num_rows = HA_POS_ERROR;
- DBUG_RETURN(err);
- }
- *num_rows += n_rows;
- }
- DBUG_RETURN(0);
-}
-
/** Estimates the number of index records in a range.
@param[in] keynr Index number.
@param[in] min_key Start key value (or NULL).
diff --git a/storage/innobase/handler/ha_innopart.h b/storage/innobase/handler/ha_innopart.h
index 5f3f8eaa318..67db9e07150 100644
--- a/storage/innobase/handler/ha_innopart.h
+++ b/storage/innobase/handler/ha_innopart.h
@@ -1222,10 +1222,6 @@ protected:
uchar* pos);
int
- records(
- ha_rows* num_rows);
-
- int
index_next(
uchar* record)
{
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index f9791f5fa97..153484c9941 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -400,7 +400,10 @@ innobase_need_rebuild(
const Alter_inplace_info* ha_alter_info,
const TABLE* altered_table)
{
- if (ha_alter_info->handler_flags
+ Alter_inplace_info::HA_ALTER_FLAGS alter_inplace_flags =
+ ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE);
+
+ if (alter_inplace_flags
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !(ha_alter_info->create_info->used_fields
& (HA_CREATE_USED_ROW_FORMAT
@@ -1293,7 +1296,6 @@ innobase_find_fk_index(
while (index != NULL) {
if (!(index->type & DICT_FTS)
- && !dict_index_has_virtual(index)
&& dict_foreign_qualify_index(
table, col_names, columns, n_cols,
index, NULL, true, 0,
@@ -2466,6 +2468,7 @@ innobase_fts_check_doc_id_index_in_def(
return(FTS_NOT_EXIST_DOC_ID_INDEX);
}
+
/*******************************************************************//**
Create an index table where indexes are ordered as follows:
@@ -2534,35 +2537,16 @@ innobase_create_key_defs(
(only prefix/part of the column is indexed), MySQL will treat the
index as a PRIMARY KEY unless the table already has one. */
- if (n_add > 0 && !new_primary && got_default_clust
- && (key_info[*add].flags & HA_NOSAME)
- && !(key_info[*add].flags & HA_KEY_HAS_PART_KEY_SEG)) {
- uint key_part = key_info[*add].user_defined_key_parts;
-
- new_primary = true;
-
- while (key_part--) {
- const uint maybe_null
- = key_info[*add].key_part[key_part].key_type
- & FIELDFLAG_MAYBE_NULL;
- bool is_v
- = innobase_is_v_fld(
- key_info[*add].key_part[key_part].field);
- DBUG_ASSERT(!maybe_null
- == !key_info[*add].key_part[key_part].
- field->real_maybe_null());
-
- if (maybe_null || is_v) {
- new_primary = false;
- break;
- }
- }
+ ut_ad(altered_table->s->primary_key == 0
+ || altered_table->s->primary_key == MAX_KEY);
+
+ if (got_default_clust && !new_primary) {
+ new_primary = (altered_table->s->primary_key != MAX_KEY);
}
const bool rebuild = new_primary || add_fts_doc_id
|| innobase_need_rebuild(ha_alter_info, table);
-
/* Reserve one more space if new_primary is true, and we might
need to add the FTS_DOC_ID_INDEX */
indexdef = indexdefs = static_cast<index_def_t*>(
@@ -2576,8 +2560,14 @@ innobase_create_key_defs(
ulint primary_key_number;
if (new_primary) {
- DBUG_ASSERT(n_add > 0);
- primary_key_number = *add;
+ if (n_add == 0) {
+ DBUG_ASSERT(got_default_clust);
+ DBUG_ASSERT(altered_table->s->primary_key
+ == 0);
+ primary_key_number = 0;
+ } else {
+ primary_key_number = *add;
+ }
} else if (got_default_clust) {
/* Create the GEN_CLUST_INDEX */
index_def_t* index = indexdef++;
@@ -4782,6 +4772,8 @@ new_clustered_failed:
ctx->add_cols = add_cols;
} else {
DBUG_ASSERT(!innobase_need_rebuild(ha_alter_info, old_table));
+ DBUG_ASSERT(old_table->s->primary_key
+ == altered_table->s->primary_key);
for (dict_index_t* index
= dict_table_get_first_index(user_table);
@@ -6082,7 +6074,7 @@ err_exit:
}
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
- || (ha_alter_info->handler_flags
+ || ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !innobase_need_rebuild(ha_alter_info, table))) {
@@ -6306,6 +6298,26 @@ alter_templ_needs_rebuild(
return(false);
}
+/** Get the name of an erroneous key.
+@param[in] error_key_num InnoDB number of the erroneus key
+@param[in] ha_alter_info changes that were being performed
+@param[in] table InnoDB table
+@return the name of the erroneous key */
+static
+const char*
+get_error_key_name(
+ ulint error_key_num,
+ const Alter_inplace_info* ha_alter_info,
+ const dict_table_t* table)
+{
+ if (error_key_num == ULINT_UNDEFINED) {
+ return(FTS_DOC_ID_INDEX_NAME);
+ } else if (ha_alter_info->key_count == 0) {
+ return(dict_table_get_first_index(table)->name);
+ } else {
+ return(ha_alter_info->key_info_buffer[error_key_num].name);
+ }
+}
/** Alter the table structure in-place with operations
specified using Alter_inplace_info.
@@ -6346,7 +6358,7 @@ ok_exit:
DBUG_RETURN(false);
}
- if (ha_alter_info->handler_flags
+ if ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !innobase_need_rebuild(ha_alter_info, table)) {
goto ok_exit;
@@ -6443,15 +6455,6 @@ ok_exit:
ctx->add_autoinc, ctx->sequence, ctx->skip_pk_sort,
ctx->m_stage, add_v, eval_table);
- if (s_templ) {
- ut_ad(ctx->need_rebuild() || ctx->num_to_add_vcol > 0
- || rebuild_templ);
- dict_free_vc_templ(s_templ);
- UT_DELETE(s_templ);
-
- ctx->new_table->vc_templ = old_templ;
- }
-
#ifndef DBUG_OFF
oom:
#endif /* !DBUG_OFF */
@@ -6467,6 +6470,15 @@ oom:
onlineddl_rowlog_pct_used = 0;
onlineddl_pct_progress = 0;
+ if (s_templ) {
+ ut_ad(ctx->need_rebuild() || ctx->num_to_add_vcol > 0
+ || rebuild_templ);
+ dict_free_vc_templ(s_templ);
+ UT_DELETE(s_templ);
+
+ ctx->new_table->vc_templ = old_templ;
+ }
+
DEBUG_SYNC_C("inplace_after_index_build");
DBUG_EXECUTE_IF("create_index_fail",
@@ -6506,17 +6518,13 @@ oom:
case DB_ONLINE_LOG_TOO_BIG:
DBUG_ASSERT(ctx->online);
my_error(ER_INNODB_ONLINE_LOG_TOO_BIG, MYF(0),
- (m_prebuilt->trx->error_key_num == ULINT_UNDEFINED)
- ? FTS_DOC_ID_INDEX_NAME
- : ha_alter_info->key_info_buffer[
- m_prebuilt->trx->error_key_num].name);
+ get_error_key_name(m_prebuilt->trx->error_key_num,
+ ha_alter_info, m_prebuilt->table));
break;
case DB_INDEX_CORRUPT:
my_error(ER_INDEX_CORRUPT, MYF(0),
- (m_prebuilt->trx->error_key_num == ULINT_UNDEFINED)
- ? FTS_DOC_ID_INDEX_NAME
- : ha_alter_info->key_info_buffer[
- m_prebuilt->trx->error_key_num].name);
+ get_error_key_name(m_prebuilt->trx->error_key_num,
+ ha_alter_info, m_prebuilt->table));
break;
case DB_DECRYPTION_FAILED: {
String str;
@@ -7724,11 +7732,31 @@ commit_try_rebuild(
if (ctx->online) {
DEBUG_SYNC_C("row_log_table_apply2_before");
+ dict_vcol_templ_t* s_templ = NULL;
+
+ if (ctx->new_table->n_v_cols > 0) {
+ s_templ = UT_NEW_NOKEY(
+ dict_vcol_templ_t());
+ s_templ->vtempl = NULL;
+
+ innobase_build_v_templ(
+ altered_table, ctx->new_table, s_templ,
+ NULL, true);
+ ctx->new_table->vc_templ = s_templ;
+ }
+
error = row_log_table_apply(
ctx->thr, user_table, altered_table,
static_cast<ha_innobase_inplace_ctx*>(
ha_alter_info->handler_ctx)->m_stage);
+ if (s_templ) {
+ ut_ad(ctx->need_rebuild());
+ dict_free_vc_templ(s_templ);
+ UT_DELETE(s_templ);
+ ctx->new_table->vc_templ = NULL;
+ }
+
ulint err_key = thr_get_trx(ctx->thr)->error_key_num;
switch (error) {
@@ -7750,14 +7778,13 @@ commit_try_rebuild(
DBUG_RETURN(true);
case DB_ONLINE_LOG_TOO_BIG:
my_error(ER_INNODB_ONLINE_LOG_TOO_BIG, MYF(0),
- ha_alter_info->key_info_buffer[0].name);
+ get_error_key_name(err_key, ha_alter_info,
+ rebuilt_table));
DBUG_RETURN(true);
case DB_INDEX_CORRUPT:
my_error(ER_INDEX_CORRUPT, MYF(0),
- (err_key == ULINT_UNDEFINED)
- ? FTS_DOC_ID_INDEX_NAME
- : ha_alter_info->key_info_buffer[err_key]
- .name);
+ get_error_key_name(err_key, ha_alter_info,
+ rebuilt_table));
DBUG_RETURN(true);
default:
my_error_innodb(error, table_name, user_table->flags);
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 6bf16573efd..3d764ef6e7a 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -3955,6 +3955,8 @@ i_s_fts_config_fill(
DBUG_RETURN(0);
}
+ DEBUG_SYNC_C("i_s_fts_config_fille_check");
+
fields = table->field;
/* Prevent DDL to drop fts aux tables. */
@@ -5147,6 +5149,10 @@ i_s_innodb_buffer_page_get_info(
block = reinterpret_cast<const buf_block_t*>(bpage);
frame = block->frame;
#ifdef BTR_CUR_HASH_ADAPT
+ /* Note: this may be a false positive, that
+ is, block->index will not always be set to
+ NULL when the last adaptive hash index
+ reference is dropped. */
page_info->hashed = (block->index != NULL);
#endif /* BTR_CUR_HASH_ADAPT */
} else {
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 7a4dc610694..c7ffecd00c1 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -3953,7 +3953,11 @@ ibuf_insert_to_index_page(
ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
#ifdef BTR_CUR_HASH_ADAPT
+ /* A change buffer merge must occur before users are granted
+ any access to the page. No adaptive hash index entries may
+ point to a freshly read page. */
ut_ad(!block->index);
+ assert_block_ahi_empty(block);
#endif /* BTR_CUR_HASH_ADAPT */
ut_ad(mtr->is_named_space(block->page.id.space()));
diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
index 8887a3f81ad..fad0dac93c4 100644
--- a/storage/innobase/include/btr0sea.h
+++ b/storage/innobase/include/btr0sea.h
@@ -247,6 +247,8 @@ btr_get_search_table(const dict_index_t* index);
# define btr_search_drop_page_hash_index(block)
# define btr_search_s_lock(index)
# define btr_search_s_unlock(index)
+# define btr_search_s_lock_all(index)
+# define btr_search_s_unlock_all(index)
# define btr_search_x_lock(index)
# define btr_search_x_unlock(index)
# define btr_search_info_update(index, cursor)
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index c0b635ab8c9..7dee52d8f74 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -769,10 +769,6 @@ buf_block_unfix(
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@param[in] use_legacy_big_endian use legacy big endian algorithm
@return true if the page is in crc32 checksum format. */
bool
@@ -780,12 +776,6 @@ buf_page_is_checksum_valid_crc32(
const byte* read_buf,
ulint checksum_field1,
ulint checksum_field2,
-#ifdef UNIV_INNOCHECKSUM
- uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo,
-#endif /* UNIV_INNOCHECKSUM */
bool use_legacy_big_endian)
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
@@ -793,59 +783,26 @@ buf_page_is_checksum_valid_crc32(
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@return true if the page is in innodb checksum format. */
bool
buf_page_is_checksum_valid_innodb(
const byte* read_buf,
ulint checksum_field1,
- ulint checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )
+ ulint checksum_field2)
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/** Checks if the page is in none checksum format.
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
-@param[in] page_no page number of given read_buf
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
-@param[in] curr_algo current checksum algorithm
@return true if the page is in none checksum format. */
bool
buf_page_is_checksum_valid_none(
const byte* read_buf,
ulint checksum_field1,
- ulint checksum_field2
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no,
- bool is_log_enabled,
- FILE* log_file,
- const srv_checksum_algorithm_t curr_algo
-#endif /* UNIV_INNOCHECKSUM */
- )
+ ulint checksum_field2)
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
-/********************************************************************//**
-Check if page is maybe compressed, encrypted or both when we encounter
-corrupted page. Note that we can't be 100% sure if page is corrupted
-or decrypt/decompress just failed.
-@param[in] bpage Page
-@return true if page corrupted, false if not */
-bool
-buf_page_check_corrupt(
- buf_page_t* bpage) /*!< in/out: buffer page read from disk */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
-
/** Checks if a page contains only zeroes.
@param[in] read_buf database page
@param[in] page_size page size
@@ -861,10 +818,6 @@ the LSN
@param[in] read_buf database page
@param[in] page_size page size
@param[in] space tablespace
-@param[in] page_no page number of given read_buf
-@param[in] strict_check true if strict-check option is enabled
-@param[in] is_log_enabled true if log option is enabled
-@param[in] log_file file pointer to log_file
@return whether the page is corrupted */
bool
buf_page_is_corrupted(
@@ -872,12 +825,6 @@ buf_page_is_corrupted(
const byte* read_buf,
const page_size_t& page_size,
const fil_space_t* space = NULL
-#ifdef UNIV_INNOCHECKSUM
- ,uintmax_t page_no = 0,
- bool strict_check = false,
- bool is_log_enabled = false,
- FILE* log_file = NULL
-#endif /* UNIV_INNOCHECKSUM */
) MY_ATTRIBUTE((warn_unused_result));
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
@@ -1836,23 +1783,58 @@ struct buf_block_t{
/* @} */
/** @name Hash search fields
- These 5 fields may only be modified when we have
- an x-latch on search system AND
- - we are holding an s-latch or x-latch on buf_block_t::lock or
- - we know that buf_block_t::buf_fix_count == 0.
+ These 5 fields may only be modified when:
+ we are holding the appropriate x-latch in btr_search_latches[], and
+ one of the following holds:
+ (1) the block state is BUF_BLOCK_FILE_PAGE, and
+ we are holding an s-latch or x-latch on buf_block_t::lock, or
+ (2) buf_block_t::buf_fix_count == 0, or
+ (3) the block state is BUF_BLOCK_REMOVE_HASH.
An exception to this is when we init or create a page
in the buffer pool in buf0buf.cc.
- Another exception is that assigning block->index = NULL
- is allowed whenever holding an x-latch on search system. */
+ Another exception for buf_pool_clear_hash_index() is that
+ assigning block->index = NULL (and block->n_pointers = 0)
+ is allowed whenever btr_search_own_all(RW_LOCK_X).
+
+ Another exception is that ha_insert_for_fold_func() may
+ decrement n_pointers without holding the appropriate latch
+ in btr_search_latches[]. Thus, n_pointers must be
+ protected by atomic memory access.
+
+ This implies that the fields may be read without race
+ condition whenever any of the following hold:
+ - the btr_search_latches[] s-latch or x-latch is being held, or
+ - the block state is not BUF_BLOCK_FILE_PAGE or BUF_BLOCK_REMOVE_HASH,
+ and holding some latch prevents the state from changing to that.
+
+ Some use of assert_block_ahi_empty() or assert_block_ahi_valid()
+ is prone to race conditions while buf_pool_clear_hash_index() is
+ executing (the adaptive hash index is being disabled). Such use
+ is explicitly commented. */
/* @{ */
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ulint n_pointers; /*!< used in debugging: the number of
pointers in the adaptive hash index
- pointing to this frame */
+ pointing to this frame;
+ protected by atomic memory access
+ or btr_search_own_all(). */
+# define assert_block_ahi_empty(block) \
+ ut_a(my_atomic_addlint(&(block)->n_pointers, 0) == 0)
+# define assert_block_ahi_empty_on_init(block) do { \
+ UNIV_MEM_VALID(&(block)->n_pointers, sizeof (block)->n_pointers); \
+ assert_block_ahi_empty(block); \
+} while (0)
+# define assert_block_ahi_valid(block) \
+ ut_a((block)->index \
+ || my_atomic_addlint(&(block)->n_pointers, 0) == 0)
+# else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+# define assert_block_ahi_empty(block) /* nothing */
+# define assert_block_ahi_empty_on_init(block) /* nothing */
+# define assert_block_ahi_valid(block) /* nothing */
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
unsigned curr_n_fields:10;/*!< prefix length for hash indexing:
number of full fields */
@@ -1868,11 +1850,15 @@ struct buf_block_t{
complete, though: there may
have been hash collisions,
record deletions, etc. */
+ /* @} */
+#else /* BTR_CUR_HASH_ADAPT */
+# define assert_block_ahi_empty(block) /* nothing */
+# define assert_block_ahi_empty_on_init(block) /* nothing */
+# define assert_block_ahi_valid(block) /* nothing */
#endif /* BTR_CUR_HASH_ADAPT */
bool skip_flush_check;
/*!< Skip check in buf_dblwr_check_block
during bulk load, protected by lock.*/
- /* @} */
# ifdef UNIV_DEBUG
/** @name Debug fields */
/* @{ */
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index 429c7fd3ba6..f22dcc48a01 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -920,6 +920,7 @@ buf_block_modify_clock_inc(
RW_LOCK_FLAG_X | RW_LOCK_FLAG_SX));
}
#endif /* UNIV_DEBUG */
+ assert_block_ahi_valid(block);
block->modify_clock++;
}
diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h
index bf2bf6ab32b..e1ecb6baf56 100644
--- a/storage/innobase/include/buf0dblwr.h
+++ b/storage/innobase/include/buf0dblwr.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -44,8 +44,7 @@ doublewrite buffer is placed on the trx system header page.
@return true if successful, false if not. */
MY_ATTRIBUTE((warn_unused_result))
bool
-buf_dblwr_create(void);
-/*==================*/
+buf_dblwr_create();
/****************************************************************//**
At a database startup initializes the doublewrite buffer memory structure if
@@ -61,13 +60,13 @@ buf_dblwr_init_or_load_pages(
/** Process and remove the double write buffer pages for all tablespaces. */
void
-buf_dblwr_process(void);
+buf_dblwr_process();
/****************************************************************//**
frees doublewrite buffer. */
void
-buf_dblwr_free(void);
-/*================*/
+buf_dblwr_free();
+
/********************************************************************//**
Updates the doublewrite buffer when an IO request is completed. */
void
@@ -105,8 +104,8 @@ important to call this function after a batch of writes has been posted,
and also when we may have to wait for a page latch! Otherwise a deadlock
of threads can occur. */
void
-buf_dblwr_flush_buffered_writes(void);
-/*=================================*/
+buf_dblwr_flush_buffered_writes();
+
/********************************************************************//**
Writes a page to the doublewrite buffer on disk, sync it, then write
the page to the datafile and sync the datafile. This function is used
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index de4a983ba81..8849be1206d 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -793,7 +793,8 @@ dict_sys_tables_type_validate(
} else if (zip_ssize) {
/* Antelope does not support COMPRESSED format. */
ib::error()
- << "SYS_TABLES::TYPE=" << type << "zip_ssize:" << zip_ssize;
+ << "SYS_TABLES::TYPE=" << type
+ << ", zip_ssize:" << zip_ssize;
return(ULINT_UNDEFINED);
}
@@ -805,16 +806,16 @@ dict_sys_tables_type_validate(
low_order_bit and DICT_N_COLS_COMPACT flags. */
if (!atomic_blobs) {
ib::error() << "SYS_TABLES::TYPE=" << type
- << " zip_ssize:" << zip_ssize
- << " atomic_blobs:" << atomic_blobs;
+ << ", zip_ssize:" << zip_ssize
+ << ", atomic_blobs:" << atomic_blobs;
return(ULINT_UNDEFINED);
}
/* Validate that the number is within allowed range. */
if (zip_ssize > PAGE_ZIP_SSIZE_MAX) {
ib::error() << "SYS_TABLES::TYPE=" << type
- << " zip_ssize:" << zip_ssize
- << " max:" << PAGE_ZIP_SSIZE_MAX;
+ << ", zip_ssize:" << zip_ssize
+ << " > " << PAGE_ZIP_SSIZE_MAX;
return(ULINT_UNDEFINED);
}
}
diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h
index 831d61445d8..ca65df21402 100644
--- a/storage/innobase/include/fil0crypt.h
+++ b/storage/innobase/include/fil0crypt.h
@@ -116,10 +116,10 @@ struct fil_space_crypt_t : st_encryption_scheme
min_key_version(new_min_key_version),
page0_offset(0),
encryption(new_encryption),
- key_found(),
+ mutex(),
+ key_found(new_min_key_version),
rotate_state()
{
- key_found = new_min_key_version;
key_id = new_key_id;
my_random_bytes(iv, sizeof(iv));
mutex_create(LATCH_ID_FIL_CRYPT_DATA_MUTEX, &mutex);
@@ -492,10 +492,6 @@ bool
fil_space_verify_crypt_checksum(
byte* page,
const page_size_t& page_size,
-#ifdef UNIV_INNOCHECKSUM
- bool strict_check, /*!< --strict-check */
- FILE* log_file, /*!< --log */
-#endif /* UNIV_INNOCHECKSUM */
ulint space,
ulint offset)
MY_ATTRIBUTE((warn_unused_result));
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 4583b81c983..cef5b578a4a 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -142,14 +142,21 @@ struct fil_space_t {
ulint n_pending_flushes; /*!< this is positive when flushing
the tablespace to disk; dropping of the
tablespace is forbidden if this is positive */
- ulint n_pending_ops;/*!< this is positive when we
- have pending operations against this
- tablespace. The pending operations can
- be ibuf merges or lock validation code
- trying to read a block.
- Dropping of the tablespace is forbidden
- if this is positive.
- Protected by fil_system->mutex. */
+ /** Number of pending buffer pool operations accessing the tablespace
+ without holding a table lock or dict_operation_lock S-latch
+ that would prevent the table (and tablespace) from being
+ dropped. An example is change buffer merge.
+ The tablespace cannot be dropped while this is nonzero,
+ or while fil_node_t::n_pending is nonzero.
+ Protected by fil_system->mutex. */
+ ulint n_pending_ops;
+ /** Number of pending block read or write operations
+ (when a write is imminent or a read has recently completed).
+ The tablespace object cannot be freed while this is nonzero,
+ but it can be detached from fil_system.
+ Note that fil_node_t::n_pending tracks actual pending I/O requests.
+ Protected by fil_system->mutex. */
+ ulint n_pending_ios;
hash_node_t hash; /*!< hash chain node */
hash_node_t name_hash;/*!< hash chain the name_hash table */
rw_lock_t latch; /*!< latch protecting the file space storage
@@ -552,15 +559,6 @@ void
fil_space_set_imported(
ulint id);
-#ifdef UNIV_DEBUG
-/** Determine if a tablespace is temporary.
-@param[in] id tablespace identifier
-@return whether it is a temporary tablespace */
-bool
-fsp_is_temporary(ulint id)
-MY_ATTRIBUTE((warn_unused_result, pure));
-#endif /* UNIV_DEBUG */
-
/** Append a file to the chain of files of a space.
@param[in] name file name of a file that is not open
@param[in] size file size in entire database blocks
@@ -735,12 +733,10 @@ MY_ATTRIBUTE((warn_unused_result));
Used by background threads that do not necessarily hold proper locks
for concurrency control.
@param[in] id tablespace ID
-@param[in] for_io whether to look up the tablespace while performing I/O
- (possibly executing TRUNCATE)
@return the tablespace
@retval NULL if missing or being deleted or truncated */
fil_space_t*
-fil_space_acquire(ulint id, bool for_io = false)
+fil_space_acquire(ulint id)
MY_ATTRIBUTE((warn_unused_result));
/** Acquire a tablespace that may not exist.
@@ -758,6 +754,19 @@ fil_space_acquire_silent(ulint id)
void
fil_space_release(fil_space_t* space);
+/** Acquire a tablespace for reading or writing a block,
+when it could be dropped concurrently.
+@param[in] id tablespace ID
+@return the tablespace
+@retval NULL if missing */
+fil_space_t*
+fil_space_acquire_for_io(ulint id);
+
+/** Release a tablespace acquired with fil_space_acquire_for_io().
+@param[in,out] space tablespace to release */
+void
+fil_space_release_for_io(fil_space_t* space);
+
/** Return the next fil_space_t.
Once started, the caller must keep calling this until it returns NULL.
fil_space_acquire() and fil_space_release() are invoked here which
@@ -794,12 +803,9 @@ public:
/** Constructor: Look up the tablespace and increment the
reference count if found.
- @param[in] space_id tablespace ID
- @param[in] for_io whether to look up the tablespace
- while performing I/O
- (possibly executing TRUNCATE) */
- explicit FilSpace(ulint space_id, bool for_io = false)
- : m_space(fil_space_acquire(space_id, for_io)) {}
+ @param[in] space_id tablespace ID */
+ explicit FilSpace(ulint space_id)
+ : m_space(fil_space_acquire(space_id)) {}
/** Assignment operator: This assumes that fil_space_acquire()
has already been done for the fil_space_t. The caller must
@@ -892,6 +898,17 @@ fil_op_replay_rename(
const char* new_name)
MY_ATTRIBUTE((warn_unused_result));
+/** Determine whether a table can be accessed in operations that are
+not (necessarily) protected by meta-data locks.
+(Rollback would generally be protected, but rollback of
+FOREIGN KEY CASCADE/SET NULL is not protected by meta-data locks
+but only by InnoDB table locks, which may be broken by TRUNCATE TABLE.)
+@param[in] table persistent table
+checked @return whether the table is accessible */
+bool
+fil_table_accessible(const dict_table_t* table)
+ MY_ATTRIBUTE((warn_unused_result, nonnull));
+
/** Deletes an IBD tablespace, either general or single-table.
The tablespace must be cached in the memory cache. This will delete the
datafile, fil_space_t & fil_node_t entries from the file_system_t cache.
@@ -923,14 +940,18 @@ dberr_t
fil_prepare_for_truncate(
/*=====================*/
ulint id); /*!< in: space id */
-/**********************************************************************//**
-Reinitialize the original tablespace header with the same space id
-for single tablespace */
+
+/** Reinitialize the original tablespace header with the same space id
+for single tablespace
+@param[in] id space id of the tablespace
+@param[in] size size in blocks
+@param[in] trx Transaction covering truncate */
void
fil_reinit_space_header(
-/*====================*/
- ulint id, /*!< in: space id */
- ulint size); /*!< in: size in blocks */
+ ulint id,
+ ulint size,
+ trx_t* trx);
+
/*******************************************************************//**
Closes a single-table tablespace. The tablespace must be cached in the
memory cache. Free all pages used by the tablespace.
@@ -1479,7 +1500,7 @@ fil_mtr_rename_log(
const dict_table_t* new_table,
const char* tmp_name,
mtr_t* mtr)
- MY_ATTRIBUTE((warn_unused_result));
+ MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Acquire the fil_system mutex. */
#define fil_system_enter() mutex_enter(&fil_system->mutex)
@@ -1586,7 +1607,6 @@ fil_names_clear(
void test_make_filepath();
#endif /* UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH */
-
/** Determine the block size of the data file.
@param[in] space tablespace
@param[in] offset page number
@@ -1594,22 +1614,6 @@ void test_make_filepath();
UNIV_INTERN
ulint
fil_space_get_block_size(const fil_space_t* space, unsigned offset);
-/*******************************************************************//**
-Increments the count of pending operation, if space is not being deleted.
-@return TRUE if being deleted, and operation should be skipped */
-UNIV_INTERN
-ibool
-fil_inc_pending_ops(
-/*================*/
- ulint id, /*!< in: space id */
- ibool print_err); /*!< in: need to print error or not */
-/*******************************************************************//**
-Decrements the count of pending operations. */
-UNIV_INTERN
-void
-fil_decr_pending_ops(
-/*=================*/
- ulint id); /*!< in: space id */
#include "fil0fil.ic"
#endif /* UNIV_INNOCHECKSUM */
diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h
index 21354b1b605..f1d53165cdd 100644
--- a/storage/innobase/include/fts0fts.h
+++ b/storage/innobase/include/fts0fts.h
@@ -409,6 +409,7 @@ extern bool fts_need_sync;
/** Variable specifying the table that has Fulltext index to display its
content through information schema table */
extern char* fts_internal_tbl_name;
+extern char* fts_internal_tbl_name2;
#define fts_que_graph_free(graph) \
do { \
@@ -842,6 +843,15 @@ fts_init_doc_id(
/*============*/
const dict_table_t* table); /*!< in: table */
+/* Get parent table name if it's a fts aux table
+@param[in] aux_table_name aux table name
+@param[in] aux_table_len aux table length
+@return parent table name, or NULL */
+char*
+fts_get_parent_table_name(
+ const char* aux_table_name,
+ ulint aux_table_len);
+
/******************************************************************//**
compare two character string according to their charset. */
extern
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index 6992f4a6689..7b3726b1fef 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -38,7 +38,6 @@ simple headers.
class THD;
// JAN: TODO missing features:
-#undef MYSQL_57_SELECT_COUNT_OPTIMIZATION
#undef MYSQL_FT_INIT_EXT
#undef MYSQL_INNODB_PARTITIONING
#undef MYSQL_PFS
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index e9ec01f6eb2..b3de1bf27f2 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -55,6 +55,9 @@ extern ulong innodb_lock_schedule_algorithm;
// Forward declaration
class ReadView;
+/** The value of innodb_deadlock_detect */
+extern my_bool innobase_deadlock_detect;
+
/*********************************************************************//**
Gets the size of a lock struct.
@return size in bytes */
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index 35a94513632..d1aae64227e 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2009, Google Inc.
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
@@ -46,6 +46,12 @@ struct log_group_t;
/** Magic value to use instead of log checksums when they are disabled */
#define LOG_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
+/* Margin for the free space in the smallest log group, before a new query
+step which modifies the database, is started */
+
+#define LOG_CHECKPOINT_FREE_PER_THREAD (4 * UNIV_PAGE_SIZE)
+#define LOG_CHECKPOINT_EXTRA_FREE (8 * UNIV_PAGE_SIZE)
+
typedef ulint (*log_checksum_func_t)(const byte* log_block);
/** Pointer to the log checksum calculation function. Protected with
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index a02333109cc..045a14221a3 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2017, MariaDB Corporation
@@ -269,8 +269,12 @@ struct mtr_t {
MLOG_FILE_NAME records and a MLOG_CHECKPOINT marker.
The caller must invoke log_mutex_enter() and log_mutex_exit().
This is to be used at log_checkpoint().
- @param[in] checkpoint_lsn the LSN of the log checkpoint */
- void commit_checkpoint(lsn_t checkpoint_lsn);
+ @param[in] checkpoint_lsn the LSN of the log checkpoint
+ @param[in] write_mlog_checkpoint Write MLOG_CHECKPOINT marker
+ if it is enabled. */
+ void commit_checkpoint(
+ lsn_t checkpoint_lsn,
+ bool write_mlog_checkpoint);
/** Return current size of the buffer.
@return savepoint */
diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h
index 7aea976a37e..6f521b5a2ec 100644
--- a/storage/innobase/include/os0thread.h
+++ b/storage/innobase/include/os0thread.h
@@ -118,9 +118,19 @@ os_thread_create_func(
os_thread_id_t* thread_id); /*!< out: id of the created
thread, or NULL */
-/** Exits the current thread. */
+/** Waits until the specified thread completes and joins it.
+Its return value is ignored.
+@param[in,out] thread thread to join */
void
-os_thread_exit()
+os_thread_join(
+ os_thread_id_t thread);
+
+/** Exits the current thread.
+@param[in] detach if true, the thread will be detached right before
+exiting. If false, another thread is responsible for joining this thread */
+void
+os_thread_exit(
+ bool detach = true)
UNIV_COLD MY_ATTRIBUTE((noreturn));
/*****************************************************************//**
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h
index e1062c00a6f..c1d5443d9e5 100644
--- a/storage/innobase/include/page0zip.h
+++ b/storage/innobase/include/page0zip.h
@@ -512,19 +512,7 @@ ibool
page_zip_verify_checksum(
/*=====================*/
const void* data, /*!< in: compressed page */
- ulint size /*!< in: size of compressed page */
-#ifdef UNIV_INNOCHECKSUM
- /* these variables are used only for innochecksum tool. */
- ,uintmax_t page_no, /*!< in: page number of
- given read_buf */
- bool strict_check, /*!< in: true if strict-check
- option is enable */
- bool is_log_enabled, /*!< in: true if log option is
- enable */
- FILE* log_file /*!< in: file pointer to
- log_file */
-#endif /* UNIV_INNOCHECKSUM */
-);
+ ulint size); /*!< in: size of compressed page */
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index 59bd786d25c..0557b585ae1 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -540,9 +540,6 @@ row_scan_index_for_mysql(
row_prebuilt_t* prebuilt, /*!< in: prebuilt struct
in MySQL handle */
const dict_index_t* index, /*!< in: index */
- bool check_keys, /*!< in: true=check for mis-
- ordered or duplicate records,
- false=count the rows only */
ulint* n_rows) /*!< out: number of entries
seen in the consistent read */
MY_ATTRIBUTE((warn_unused_result));
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 994800794a8..799bef58a72 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -298,6 +298,9 @@ extern long srv_mtflush_threads;
/* If this flag is TRUE, then we will use multi threaded flush. */
extern my_bool srv_use_mtflush;
+/** TRUE if the server was successfully started */
+extern bool srv_was_started;
+
/** Server undo tablespaces directory, can be absolute path. */
extern char* srv_undo_dir;
@@ -469,6 +472,7 @@ extern unsigned long long srv_stats_transient_sample_pages;
extern my_bool srv_stats_persistent;
extern unsigned long long srv_stats_persistent_sample_pages;
extern my_bool srv_stats_auto_recalc;
+extern my_bool srv_stats_include_delete_marked;
extern unsigned long long srv_stats_modified_counter;
extern my_bool srv_stats_sample_traditional;
@@ -509,7 +513,6 @@ extern ulong srv_n_spin_wait_rounds;
extern ulong srv_n_free_tickets_to_enter;
extern ulong srv_thread_sleep_delay;
extern uint srv_spin_wait_delay;
-extern ibool srv_priority_boost;
extern ulint srv_truncated_status_writes;
/** Number of initialized rollback segments for persistent undo log */
@@ -743,36 +746,24 @@ srv_set_io_thread_op_info(
Resets the info describing an i/o thread current state. */
void
srv_reset_io_thread_op_info();
-/*=========================*/
-/*******************************************************************//**
-Tells the purge thread that there has been activity in the database
-and wakes up the purge thread if it is suspended (not sleeping). Note
-that there is a small chance that the purge thread stays suspended
-(we do not protect our operation with the srv_sys_t:mutex, for
-performance reasons). */
+
+/** Wake up the purge threads if there is work to do. */
void
-srv_wake_purge_thread_if_not_active(void);
-/*=====================================*/
-/*******************************************************************//**
-Tells the Innobase server that there has been activity in the database
-and wakes up the master thread if it is suspended (not sleeping). Used
-in the MySQL interface. Note that there is a small chance that the master
-thread stays suspended (we do not protect our operation with the kernel
-mutex, for performace reasons). */
+srv_wake_purge_thread_if_not_active();
+/** Wake up the InnoDB master thread if it was suspended (not sleeping). */
void
-srv_active_wake_master_thread_low(void);
-/*===================================*/
+srv_active_wake_master_thread_low();
+
#define srv_active_wake_master_thread() \
do { \
if (!srv_read_only_mode) { \
srv_active_wake_master_thread_low(); \
} \
} while (0)
-/*******************************************************************//**
-Wakes up the master thread if it is suspended or being suspended. */
+/** Wake up the master thread if it is suspended or being suspended. */
void
-srv_wake_master_thread(void);
-/*========================*/
+srv_wake_master_thread();
+
/******************************************************************//**
Outputs to a file the output of the InnoDB Monitor.
@return FALSE if not all information printed
diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h
index d7a5922c954..4f2f4a312ff 100644
--- a/storage/innobase/include/srv0start.h
+++ b/storage/innobase/include/srv0start.h
@@ -121,8 +121,6 @@ extern lsn_t srv_start_lsn;
extern bool srv_is_being_started;
/** TRUE if SYS_TABLESPACES is available for lookups */
extern bool srv_sys_tablespaces_open;
-/** TRUE if the server was successfully started */
-extern ibool srv_was_started;
/** TRUE if the server is being started, before rolling back any
incomplete transactions */
extern bool srv_startup_is_before_trx_rollback_phase;
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index 736c5454711..1d11bfa7811 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -505,14 +505,32 @@ private:
};
#ifdef UNIV_PFS_MUTEX
-/** Latch element
+/** Latch element.
+Used for mutexes which have PFS keys defined under UNIV_PFS_MUTEX.
@param[in] id Latch id
@param[in] level Latch level
@param[in] key PFS key */
-# define LATCH_ADD(id, level, key) latch_meta[LATCH_ID_ ## id] = \
+# define LATCH_ADD_MUTEX(id, level, key) latch_meta[LATCH_ID_ ## id] =\
+ UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level, key))
+
+#ifdef UNIV_PFS_RWLOCK
+/** Latch element.
+Used for rwlocks which have PFS keys defined under UNIV_PFS_RWLOCK.
+@param[in] id Latch id
+@param[in] level Latch level
+@param[in] key PFS key */
+# define LATCH_ADD_RWLOCK(id, level, key) latch_meta[LATCH_ID_ ## id] =\
UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level, key))
#else
-# define LATCH_ADD(id, level, key) latch_meta[LATCH_ID_ ## id] = \
+# define LATCH_ADD_RWLOCK(id, level, key) latch_meta[LATCH_ID_ ## id] =\
+ UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level, \
+ PSI_NOT_INSTRUMENTED))
+#endif /* UNIV_PFS_RWLOCK */
+
+#else
+# define LATCH_ADD_MUTEX(id, level, key) latch_meta[LATCH_ID_ ## id] =\
+ UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level))
+# define LATCH_ADD_RWLOCK(id, level, key) latch_meta[LATCH_ID_ ## id] =\
UT_NEW_NOKEY(latch_meta_t(LATCH_ID_ ## id, #id, level, #level))
#endif /* UNIV_PFS_MUTEX */
@@ -919,7 +937,7 @@ sync_latch_get_level(latch_id_t id)
return(meta.get_level());
}
-#ifdef HAVE_PSI_INTERFACE
+#ifdef UNIV_PFS_MUTEX
/** Get the latch PFS key from the latch ID
@param[in] id Latch ID
@return the PFS key */
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index 95774cbf476..4c162526384 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -200,7 +200,10 @@ struct trx_rseg_t {
bool is_persistent() const
{
ut_ad(space == SRV_TMP_SPACE_ID
- || space <= srv_undo_tablespaces);
+ || space <= TRX_SYS_MAX_UNDO_SPACES);
+ ut_ad(space == SRV_TMP_SPACE_ID
+ || space <= srv_undo_tablespaces_active
+ || !srv_was_started);
return(space != SRV_TMP_SPACE_ID);
}
};
diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic
index 0a33c747668..45ee3ef8d66 100644
--- a/storage/innobase/include/trx0rseg.ic
+++ b/storage/innobase/include/trx0rseg.ic
@@ -42,7 +42,9 @@ trx_rsegf_get(
buf_block_t* block;
trx_rsegf_t* header;
- ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID);
+ ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID
+ || !srv_was_started);
+ ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
block = buf_page_get(
page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr);
@@ -69,7 +71,9 @@ trx_rsegf_get_new(
buf_block_t* block;
trx_rsegf_t* header;
- ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID);
+ ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID
+ || !srv_was_started);
+ ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
block = buf_page_get(
page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr);
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
index b867600653d..bf8cf2481eb 100644
--- a/storage/innobase/include/trx0sys.h
+++ b/storage/innobase/include/trx0sys.h
@@ -403,10 +403,8 @@ byte, therefore 128; each slot is currently 8 bytes in size. If you want
to raise the level to 256 then you will need to fix some assertions that
impose the 7 bit restriction. e.g., mach_write_to_3() */
#define TRX_SYS_N_RSEGS 128
-/* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
-rollback segment. It initialized some arrays with this number of entries.
-We must remember this limit in order to keep file compatibility. */
-#define TRX_SYS_OLD_N_RSEGS 256
+/** Maximum number of undo tablespaces (not counting the system tablespace) */
+#define TRX_SYS_MAX_UNDO_SPACES (TRX_SYS_N_RSEGS - 1)
/** Maximum length of MySQL binlog file name, in bytes. */
#define TRX_SYS_MYSQL_LOG_NAME_LEN 512
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index b08148578dc..446e619abb9 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -386,6 +386,22 @@ trx_print_latched(
ulint max_query_len); /*!< in: max query length to print,
or 0 to use the default max length */
+#ifdef WITH_WSREP
+/**********************************************************************//**
+Prints info about a transaction.
+Transaction information may be retrieved without having trx_sys->mutex acquired
+so it may not be completely accurate. The caller must own lock_sys->mutex
+and the trx must have some locks to make sure that it does not escape
+without locking lock_sys->mutex. */
+UNIV_INTERN
+void
+wsrep_trx_print_locking(
+ FILE* f, /*!< in: output stream */
+ const trx_t* trx, /*!< in: transaction */
+ ulint max_query_len) /*!< in: max query length to print,
+ or 0 to use the default max length */
+ MY_ATTRIBUTE((nonnull));
+#endif /* WITH_WSREP */
/**********************************************************************//**
Prints info about a transaction.
Acquires and releases lock_sys->mutex and trx_sys->mutex. */
@@ -1468,10 +1484,30 @@ private:
return;
}
- /* Avoid excessive mutex acquire/release */
-
ut_ad(!is_async_rollback(trx));
+ /* If it hasn't already been marked for async rollback.
+ and it will be committed/rolled back. */
+ if (disable) {
+
+ trx_mutex_enter(trx);
+ if (!is_forced_rollback(trx)
+ && is_started(trx)
+ && !trx_is_autocommit_non_locking(trx)) {
+
+ ut_ad(trx->killed_by == 0);
+
+ /* This transaction has crossed the point of
+ no return and cannot be rolled back
+ asynchronously now. It must commit or rollback
+ synhronously. */
+
+ trx->in_innodb |= TRX_FORCE_ROLLBACK_DISABLE;
+ }
+ trx_mutex_exit(trx);
+ }
+
+ /* Avoid excessive mutex acquire/release */
++trx->in_depth;
/* If trx->in_depth is greater than 1 then
@@ -1489,25 +1525,7 @@ private:
wait(trx);
- ut_ad((trx->in_innodb & TRX_FORCE_ROLLBACK_MASK)
- < (TRX_FORCE_ROLLBACK_MASK - 1));
-
- /* If it hasn't already been marked for async rollback.
- and it will be committed/rolled back. */
-
- if (!is_forced_rollback(trx)
- && disable
- && is_started(trx)
- && !trx_is_autocommit_non_locking(trx)) {
-
- ut_ad(trx->killed_by == 0);
-
- /* This transaction has crossed the point of no
- return and cannot be rolled back asynchronously
- now. It must commit or rollback synhronously. */
-
- trx->in_innodb |= TRX_FORCE_ROLLBACK_DISABLE;
- }
+ ut_ad((trx->in_innodb & TRX_FORCE_ROLLBACK_MASK) == 0);
++trx->in_innodb;
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index faf5387a5d1..ee759534301 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -108,6 +108,12 @@ support cross-platform development and expose comonly used SQL names. */
#include <unistd.h>
#endif
+#ifdef UNIV_INNOCHECKSUM
+extern bool strict_verify;
+extern FILE* log_file;
+extern uintmax_t cur_page_num;
+#endif /* UNIV_INNOCHECKSUM */
+
#include "my_pthread.h"
/* Following defines are to enable performance schema
instrumentation in each of five InnoDB modules if
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index c3574913c7c..295833cb1d6 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -56,6 +56,9 @@ Created 5/7/1996 Heikki Tuuri
/** Lock scheduling algorithm */
ulong innodb_lock_schedule_algorithm = INNODB_LOCK_SCHEDULE_ALGORITHM_FCFS;
+/** The value of innodb_deadlock_detect */
+my_bool innobase_deadlock_detect;
+
/** Total number of cached record locks */
static const ulint REC_LOCK_CACHE = 8;
@@ -124,7 +127,7 @@ public:
@return id of transaction chosen as victim or 0 */
static const trx_t* check_and_resolve(
const lock_t* lock,
- const trx_t* trx);
+ trx_t* trx);
private:
/** Do a shallow copy. Default destructor OK.
@@ -1378,24 +1381,20 @@ wsrep_kill_victim(
is in the queue*/
} else if (lock->trx != trx) {
if (wsrep_log_conflicts) {
- mutex_enter(&trx_sys->mutex);
if (bf_this) {
ib::info() << "*** Priority TRANSACTION:";
} else {
ib::info() << "*** Victim TRANSACTION:";
}
- trx_print_latched(stderr, trx, 3000);
+ wsrep_trx_print_locking(stderr, trx, 3000);
if (bf_other) {
ib::info() << "*** Priority TRANSACTION:";
} else {
ib::info() << "*** Victim TRANSACTION:";
}
-
- trx_print_latched(stderr, lock->trx, 3000);
-
- mutex_exit(&trx_sys->mutex);
+ wsrep_trx_print_locking(stderr, lock->trx, 3000);
ib::info() << "*** WAITING FOR THIS LOCK TO BE GRANTED:";
@@ -2136,25 +2135,8 @@ RecLock::deadlock_check(lock_t* lock)
ut_ad(lock->trx == m_trx);
ut_ad(trx_mutex_own(m_trx));
- bool async_rollback = m_trx->in_innodb & TRX_FORCE_ROLLBACK_ASYNC;
-
- /* This is safe, because DeadlockChecker::check_and_resolve()
- is invoked when a lock wait is enqueued for the currently
- running transaction. Because m_trx is a running transaction
- (it is not currently suspended because of a lock wait),
- its state can only be changed by this thread, which is
- currently associated with the transaction. */
-
- trx_mutex_exit(m_trx);
-
- /* If transaction is marked for ASYNC rollback then we should
- not allow it to wait for another lock causing possible deadlock.
- We return current transaction as deadlock victim here. */
-
- const trx_t* victim_trx = async_rollback ? m_trx
- : DeadlockChecker::check_and_resolve(lock, m_trx);
-
- trx_mutex_enter(m_trx);
+ const trx_t* victim_trx =
+ DeadlockChecker::check_and_resolve(lock, m_trx);
/* Check the outcome of the deadlock test. It is possible that
the transaction that blocked our lock was rolled back and we
@@ -4658,25 +4640,8 @@ lock_table_enqueue_waiting(
/* Enqueue the lock request that will wait to be granted */
lock = lock_table_create(c_lock, table, mode | LOCK_WAIT, trx);
- bool async_rollback = trx->in_innodb & TRX_FORCE_ROLLBACK_ASYNC;
- /* Release the mutex to obey the latching order.
- This is safe, because DeadlockChecker::check_and_resolve()
- is invoked when a lock wait is enqueued for the currently
- running transaction. Because trx is a running transaction
- (it is not currently suspended because of a lock wait),
- its state can only be changed by this thread, which is
- currently associated with the transaction. */
-
- trx_mutex_exit(trx);
-
- /* If transaction is marked for ASYNC rollback then we should
- not allow it to wait for another lock causing possible deadlock.
- We return current transaction as deadlock victim here. */
-
- const trx_t* victim_trx = async_rollback ? trx
- : DeadlockChecker::check_and_resolve(lock, trx);
-
- trx_mutex_enter(trx);
+ const trx_t* victim_trx =
+ DeadlockChecker::check_and_resolve(lock, trx);
if (victim_trx != 0) {
ut_ad(victim_trx == trx);
@@ -8446,17 +8411,37 @@ and rolling it back. It will attempt to resolve all deadlocks. The returned
transaction id will be the joining transaction instance or NULL if some other
transaction was chosen as a victim and rolled back or no deadlock found.
-@param lock lock the transaction is requesting
-@param trx transaction requesting the lock
+@param[in] lock lock the transaction is requesting
+@param[in,out] trx transaction requesting the lock
@return transaction instanace chosen as victim or 0 */
const trx_t*
-DeadlockChecker::check_and_resolve(const lock_t* lock, const trx_t* trx)
+DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx)
{
ut_ad(lock_mutex_own());
+ ut_ad(trx_mutex_own(trx));
check_trx_state(trx);
ut_ad(!srv_read_only_mode);
+ /* If transaction is marked for ASYNC rollback then we should
+ not allow it to wait for another lock causing possible deadlock.
+ We return current transaction as deadlock victim here. */
+ if (trx->in_innodb & TRX_FORCE_ROLLBACK_ASYNC) {
+ return(trx);
+ } else if (!innobase_deadlock_detect) {
+ return(NULL);
+ }
+
+ /* Release the mutex to obey the latching order.
+ This is safe, because DeadlockChecker::check_and_resolve()
+ is invoked when a lock wait is enqueued for the currently
+ running transaction. Because m_trx is a running transaction
+ (it is not currently suspended because of a lock wait),
+ its state can only be changed by this thread, which is
+ currently associated with the transaction. */
+
+ trx_mutex_exit(trx);
+
const trx_t* victim_trx;
THD* start_mysql_thd;
bool report_waits = false;
@@ -8496,7 +8481,7 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, const trx_t* trx)
break;
- } else if (victim_trx != 0 && victim_trx != trx) {
+ } else if (victim_trx != NULL && victim_trx != trx) {
ut_ad(victim_trx == checker.m_wait_lock->trx);
@@ -8517,6 +8502,8 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, const trx_t* trx)
lock_deadlock_found = true;
}
+ trx_mutex_enter(trx);
+
return(victim_trx);
}
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index c96260ca1ac..7d4e0459610 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Copyright (c) 2014, 2017, MariaDB Corporation.
@@ -106,12 +106,6 @@ static time_t log_last_margine_warning_time;
#define LOG_BUF_FLUSH_RATIO 2
#define LOG_BUF_FLUSH_MARGIN (LOG_BUF_WRITE_MARGIN + 4 * UNIV_PAGE_SIZE)
-/* Margin for the free space in the smallest log group, before a new query
-step which modifies the database, is started */
-
-#define LOG_CHECKPOINT_FREE_PER_THREAD (4 * UNIV_PAGE_SIZE)
-#define LOG_CHECKPOINT_EXTRA_FREE (8 * UNIV_PAGE_SIZE)
-
/* This parameter controls asynchronous making of a new checkpoint; the value
should be bigger than LOG_POOL_PREFLUSH_RATIO_SYNC */
@@ -2178,7 +2172,8 @@ wait_suspend_loop:
bool freed = buf_all_freed();
ut_a(freed);
- ut_a(lsn == log_sys->lsn);
+ ut_a(lsn == log_sys->lsn
+ || srv_force_recovery == SRV_FORCE_NO_LOG_REDO);
if (lsn < srv_start_lsn) {
ib::error() << "Shutdown LSN=" << lsn
@@ -2204,7 +2199,8 @@ wait_suspend_loop:
freed = buf_all_freed();
ut_a(freed);
- ut_a(lsn == log_sys->lsn);
+ ut_a(lsn == log_sys->lsn
+ || srv_force_recovery == SRV_FORCE_NO_LOG_REDO);
}
/******************************************************//**
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index adf2d3aca0a..0b46c92f00a 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
@@ -532,6 +532,7 @@ DECLARE_THREAD(recv_writer_thread)(
/*!< in: a dummy parameter required by
os_thread_create */
{
+ my_thread_init();
ut_ad(!srv_read_only_mode);
#ifdef UNIV_PFS_THREAD
@@ -568,6 +569,7 @@ DECLARE_THREAD(recv_writer_thread)(
recv_writer_thread_active = false;
+ my_thread_end();
/* We count the number of threads in os_thread_exit().
A created thread should always use that to exit and not
use return() to exit. */
@@ -2480,6 +2482,8 @@ loop:
ulint total_len = 0;
ulint n_recs = 0;
+ bool only_mlog_file = true;
+ ulint mlog_rec_len = 0;
for (;;) {
len = recv_parse_log_rec(
@@ -2508,6 +2512,22 @@ loop:
= recv_sys->recovered_offset + total_len;
recv_previous_parsed_rec_is_multi = 1;
+ /* MLOG_FILE_NAME redo log records doesn't make changes
+ to persistent data. If only MLOG_FILE_NAME redo
+ log record exists then reset the parsing buffer pointer
+ by changing recovered_lsn and recovered_offset. */
+ if (type != MLOG_FILE_NAME && only_mlog_file == true) {
+ only_mlog_file = false;
+ }
+
+ if (only_mlog_file) {
+ new_recovered_lsn = recv_calc_lsn_on_data_add(
+ recv_sys->recovered_lsn, len);
+ mlog_rec_len += len;
+ recv_sys->recovered_offset += len;
+ recv_sys->recovered_lsn = new_recovered_lsn;
+ }
+
total_len += len;
n_recs++;
@@ -2521,6 +2541,7 @@ loop:
" n=" ULINTPF,
recv_sys->recovered_lsn,
total_len, n_recs));
+ total_len -= mlog_rec_len;
break;
}
@@ -2740,6 +2761,7 @@ recv_scan_log_recs(
ulint data_len;
bool more_data = false;
bool apply = recv_sys->mlog_checkpoint_lsn != 0;
+ ulint recv_parsing_buf_size = RECV_PARSING_BUF_SIZE;
ut_ad(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(end_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
@@ -2812,8 +2834,14 @@ recv_scan_log_recs(
parsing buffer if parse_start_lsn is already
non-zero */
+ DBUG_EXECUTE_IF(
+ "reduce_recv_parsing_buf",
+ recv_parsing_buf_size
+ = (70 * 1024);
+ );
+
if (recv_sys->len + 4 * OS_FILE_LOG_BLOCK_SIZE
- >= RECV_PARSING_BUF_SIZE) {
+ >= recv_parsing_buf_size) {
ib::error() << "Log parsing buffer overflow."
" Recovery may have failed!";
@@ -2863,7 +2891,7 @@ recv_scan_log_recs(
*store_to_hash = STORE_NO;
}
- if (recv_sys->recovered_offset > RECV_PARSING_BUF_SIZE / 4) {
+ if (recv_sys->recovered_offset > recv_parsing_buf_size / 4) {
/* Move parsing buffer data to the buffer start */
recv_sys_justify_left_parsing_buf();
@@ -2986,7 +3014,7 @@ recv_init_missing_space(dberr_t err, const recv_spaces_t::const_iterator& i)
@return error code or DB_SUCCESS */
static MY_ATTRIBUTE((warn_unused_result))
dberr_t
-recv_init_crash_recovery_spaces(void)
+recv_init_crash_recovery_spaces()
{
typedef std::set<ulint> space_set_t;
bool flag_deleted = false;
diff --git a/storage/innobase/mach/mach0data.cc b/storage/innobase/mach/mach0data.cc
index b22da00c0f1..6cb33715898 100644
--- a/storage/innobase/mach/mach0data.cc
+++ b/storage/innobase/mach/mach0data.cc
@@ -49,7 +49,22 @@ mach_parse_compressed(
/* 0nnnnnnn (7 bits) */
++*ptr;
return(static_cast<ib_uint32_t>(val));
- } else if (val < 0xC0) {
+ }
+
+ /* Workaround GCC bug
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77673:
+ the compiler moves mach_read_from_4 right to the beginning of the
+ function, causing and out-of-bounds read if we are reading a short
+ integer close to the end of buffer. */
+#if defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__clang__)
+#define DEPLOY_FENCE
+#endif
+
+#ifdef DEPLOY_FENCE
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+#endif
+
+ if (val < 0xC0) {
/* 10nnnnnn nnnnnnnn (14 bits) */
if (end_ptr >= *ptr + 2) {
val = mach_read_from_2(*ptr) & 0x3FFF;
@@ -57,7 +72,15 @@ mach_parse_compressed(
*ptr += 2;
return(static_cast<ib_uint32_t>(val));
}
- } else if (val < 0xE0) {
+ *ptr = NULL;
+ return(0);
+ }
+
+#ifdef DEPLOY_FENCE
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+#endif
+
+ if (val < 0xE0) {
/* 110nnnnn nnnnnnnn nnnnnnnn (21 bits) */
if (end_ptr >= *ptr + 3) {
val = mach_read_from_3(*ptr) & 0x1FFFFF;
@@ -65,7 +88,15 @@ mach_parse_compressed(
*ptr += 3;
return(static_cast<ib_uint32_t>(val));
}
- } else if (val < 0xF0) {
+ *ptr = NULL;
+ return(0);
+ }
+
+#ifdef DEPLOY_FENCE
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+#endif
+
+ if (val < 0xF0) {
/* 1110nnnn nnnnnnnn nnnnnnnn nnnnnnnn (28 bits) */
if (end_ptr >= *ptr + 4) {
val = mach_read_from_4(*ptr) & 0xFFFFFFF;
@@ -73,16 +104,24 @@ mach_parse_compressed(
*ptr += 4;
return(static_cast<ib_uint32_t>(val));
}
- } else {
- ut_ad(val == 0xF0);
-
- /* 11110000 nnnnnnnn nnnnnnnn nnnnnnnn nnnnnnnn (32 bits) */
- if (end_ptr >= *ptr + 5) {
- val = mach_read_from_4(*ptr + 1);
- ut_ad(val > 0xFFFFFFF);
- *ptr += 5;
- return(static_cast<ib_uint32_t>(val));
- }
+ *ptr = NULL;
+ return(0);
+ }
+
+#ifdef DEPLOY_FENCE
+ __atomic_thread_fence(__ATOMIC_ACQUIRE);
+#endif
+
+#undef DEPLOY_FENCE
+
+ ut_ad(val == 0xF0);
+
+ /* 11110000 nnnnnnnn nnnnnnnn nnnnnnnn nnnnnnnn (32 bits) */
+ if (end_ptr >= *ptr + 5) {
+ val = mach_read_from_4(*ptr + 1);
+ ut_ad(val > 0xFFFFFFF);
+ *ptr += 5;
+ return(static_cast<ib_uint32_t>(val));
}
*ptr = NULL;
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index c626937b0d8..d8c7d59fe27 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -580,9 +580,13 @@ but generated some redo log on a higher level, such as
MLOG_FILE_NAME records and a MLOG_CHECKPOINT marker.
The caller must invoke log_mutex_enter() and log_mutex_exit().
This is to be used at log_checkpoint().
-@param[in] checkpoint_lsn the LSN of the log checkpoint */
+@param[in] checkpoint_lsn the LSN of the log checkpoint
+@param[in] write_mlog_checkpoint Write MLOG_CHECKPOINT marker
+ if it is enabled. */
void
-mtr_t::commit_checkpoint(lsn_t checkpoint_lsn)
+mtr_t::commit_checkpoint(
+ lsn_t checkpoint_lsn,
+ bool write_mlog_checkpoint)
{
ut_ad(log_mutex_own());
ut_ad(is_active());
@@ -593,6 +597,7 @@ mtr_t::commit_checkpoint(lsn_t checkpoint_lsn)
ut_ad(m_impl.m_memo.size() == 0);
ut_ad(!srv_read_only_mode);
ut_d(m_impl.m_state = MTR_STATE_COMMITTING);
+ ut_ad(write_mlog_checkpoint || m_impl.m_n_log_recs > 1);
/* This is a dirty read, for debugging. */
ut_ad(!recv_no_log_write);
@@ -608,20 +613,24 @@ mtr_t::commit_checkpoint(lsn_t checkpoint_lsn)
&m_impl.m_log, MLOG_MULTI_REC_END, MLOG_1BYTE);
}
- byte* ptr = m_impl.m_log.push<byte*>(SIZE_OF_MLOG_CHECKPOINT);
+ if (write_mlog_checkpoint) {
+ byte* ptr = m_impl.m_log.push<byte*>(SIZE_OF_MLOG_CHECKPOINT);
#if SIZE_OF_MLOG_CHECKPOINT != 9
# error SIZE_OF_MLOG_CHECKPOINT != 9
#endif
- *ptr = MLOG_CHECKPOINT;
- mach_write_to_8(ptr + 1, checkpoint_lsn);
+ *ptr = MLOG_CHECKPOINT;
+ mach_write_to_8(ptr + 1, checkpoint_lsn);
+ }
Command cmd(this);
cmd.finish_write(m_impl.m_log.size());
cmd.release_resources();
- DBUG_PRINT("ib_log",
- ("MLOG_CHECKPOINT(" LSN_PF ") written at " LSN_PF,
- checkpoint_lsn, log_sys->lsn));
+ if (write_mlog_checkpoint) {
+ DBUG_PRINT("ib_log",
+ ("MLOG_CHECKPOINT(" LSN_PF ") written at " LSN_PF,
+ checkpoint_lsn, log_sys->lsn));
+ }
}
#ifdef UNIV_DEBUG
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index f5c42abf365..76ae46827ea 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -3496,7 +3496,8 @@ SyncFileIO::execute(Slot* slot)
/* Wait for async io to complete */
ret = GetOverlappedResult(slot->file, &slot->control, &slot->n_bytes, TRUE);
}
- return(ret ? slot->n_bytes : -1);
+
+ return(ret ? static_cast<ssize_t>(slot->n_bytes) : -1);
}
/* Startup/shutdown */
diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc
index 4012c281f8d..72199b4cf0b 100644
--- a/storage/innobase/os/os0thread.cc
+++ b/storage/innobase/os/os0thread.cc
@@ -161,9 +161,32 @@ os_thread_create_func(
return((os_thread_t)new_thread_id);
}
-/** Exits the current thread. */
+/** Waits until the specified thread completes and joins it.
+Its return value is ignored.
+@param[in,out] thread thread to join */
void
-os_thread_exit()
+os_thread_join(
+ os_thread_id_t thread)
+{
+#ifdef _WIN32
+ /* Do nothing. */
+#else
+#ifdef UNIV_DEBUG
+ const int ret =
+#endif /* UNIV_DEBUG */
+ pthread_join(thread, NULL);
+
+ /* Waiting on already-quit threads is allowed. */
+ ut_ad(ret == 0 || ret == ESRCH);
+#endif /* _WIN32 */
+}
+
+/** Exits the current thread.
+@param[in] detach if true, the thread will be detached right before
+exiting. If false, another thread is responsible for joining this thread */
+void
+os_thread_exit(
+ bool detach)
{
#ifdef UNIV_DEBUG_THREAD_CREATION
ib::info() << "Thread exits, id "
@@ -184,7 +207,9 @@ os_thread_exit()
ExitThread(0);
#else
mutex_exit(&thread_mutex);
- pthread_detach(pthread_self());
+ if (detach) {
+ pthread_detach(pthread_self());
+ }
pthread_exit(NULL);
#endif
}
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 88c5a425818..e718081ed63 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -4973,19 +4973,7 @@ ibool
page_zip_verify_checksum(
/*=====================*/
const void* data, /*!< in: compressed page */
- ulint size /*!< in: size of compressed page */
-#ifdef UNIV_INNOCHECKSUM
- /* these variables are used only for innochecksum tool. */
- ,uintmax_t page_no, /*!< in: page number of
- given read_buf */
- bool strict_check, /*!< in: true if strict-check
- option is enable */
- bool is_log_enabled, /*!< in: true if log option is
- enabled */
- FILE* log_file /*!< in: file pointer to
- log_file */
-#endif /* UNIV_INNOCHECKSUM */
-)
+ ulint size) /*!< in: size of compressed page */
{
const unsigned char* p = static_cast<const unsigned char*>(data)
+ FIL_PAGE_SPACE_OR_CHKSUM;
@@ -5023,9 +5011,9 @@ page_zip_verify_checksum(
break;
}
if (i >= size) {
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "Page::%lu is empty and"
- " uncorrupted\n", page_no);
+ " uncorrupted\n", cur_page_num);
}
return(TRUE);
@@ -5061,28 +5049,28 @@ page_zip_verify_checksum(
const uint32_t calc = page_zip_calc_checksum(data, size, curr_algo);
#ifdef UNIV_INNOCHECKSUM
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "page::%lu;"
" %s checksum: calculated = %u;"
- " recorded = %u\n", page_no,
+ " recorded = %u\n", cur_page_num,
buf_checksum_algorithm_name(
static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)),
calc, stored);
}
- if (!strict_check) {
+ if (!strict_verify) {
const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
- if (is_log_enabled) {
+ if (log_file) {
fprintf(log_file, "page::%lu: crc32 checksum:"
" calculated = %u; recorded = %u\n",
- page_no, crc32, stored);
+ cur_page_num, crc32, stored);
fprintf(log_file, "page::%lu: none checksum:"
" calculated = %lu; recorded = %u\n",
- page_no, BUF_NO_CHECKSUM_MAGIC, stored);
+ cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored);
}
}
#endif /* UNIV_INNOCHECKSUM */
diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc
index 6d974e7accb..26bb12e8a03 100644
--- a/storage/innobase/rem/rem0rec.cc
+++ b/storage/innobase/rem/rem0rec.cc
@@ -1652,6 +1652,7 @@ rec_copy_prefix_to_buf(
ulint prefix_len;
ulint null_mask;
ulint status;
+ bool is_rtr_node_ptr = false;
UNIV_PREFETCH_RW(*buf);
@@ -1673,6 +1674,7 @@ rec_copy_prefix_to_buf(
/* For R-tree, we need to copy the child page number field. */
if (dict_index_is_spatial(index)) {
ut_ad(n_fields == DICT_INDEX_SPATIAL_NODEPTR_SIZE + 1);
+ is_rtr_node_ptr = true;
} else {
/* it doesn't make sense to copy the child page number
field */
@@ -1717,7 +1719,11 @@ rec_copy_prefix_to_buf(
null_mask <<= 1;
}
- if (field->fixed_len) {
+ if (is_rtr_node_ptr && i == 1) {
+ /* For rtree node ptr rec, we need to
+ copy the page no field with 4 bytes len. */
+ prefix_len += 4;
+ } else if (field->fixed_len) {
prefix_len += field->fixed_len;
} else {
ulint len = *lens--;
diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc
index 2adf32b79d9..fca6ae5a1bf 100644
--- a/storage/innobase/row/row0ftsort.cc
+++ b/storage/innobase/row/row0ftsort.cc
@@ -1144,7 +1144,7 @@ fts_parallel_merge(
os_event_set(psort_info->psort_common->merge_event);
psort_info->child_status = FTS_CHILD_EXITING;
- os_thread_exit();
+ os_thread_exit(false);
OS_THREAD_DUMMY_RETURN;
}
@@ -1157,15 +1157,16 @@ row_fts_start_parallel_merge(
fts_psort_t* merge_info) /*!< in: parallel sort info */
{
int i = 0;
- os_thread_id_t thd_id;
/* Kick off merge/insert threads */
for (i = 0; i < FTS_NUM_AUX_INDEX; i++) {
merge_info[i].psort_id = i;
merge_info[i].child_status = 0;
- merge_info[i].thread_hdl = os_thread_create(fts_parallel_merge,
- (void*) &merge_info[i], &thd_id);
+ merge_info[i].thread_hdl = os_thread_create(
+ fts_parallel_merge,
+ (void*) &merge_info[i],
+ &merge_info[i].thread_hdl);
}
}
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index f596f3d8f27..5152d499bad 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -1596,6 +1596,10 @@ row_ins_check_foreign_constraint(
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
+ bool skip_gap_lock;
+
+ skip_gap_lock = (trx->isolation_level <= TRX_ISO_READ_COMMITTED);
+
DBUG_ENTER("row_ins_check_foreign_constraint");
rec_offs_init(offsets_);
@@ -1725,6 +1729,11 @@ row_ins_check_foreign_constraint(
if (page_rec_is_supremum(rec)) {
+ if (skip_gap_lock) {
+
+ continue;
+ }
+
err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, block,
rec, check_index,
offsets, thr);
@@ -1740,10 +1749,17 @@ row_ins_check_foreign_constraint(
cmp = cmp_dtuple_rec(entry, rec, offsets);
if (cmp == 0) {
+
+ ulint lock_type;
+
+ lock_type = skip_gap_lock
+ ? LOCK_REC_NOT_GAP
+ : LOCK_ORDINARY;
+
if (rec_get_deleted_flag(rec,
rec_offs_comp(offsets))) {
err = row_ins_set_shared_rec_lock(
- LOCK_ORDINARY, block,
+ lock_type, block,
rec, check_index, offsets, thr);
switch (err) {
case DB_SUCCESS_LOCKED_REC:
@@ -1824,9 +1840,13 @@ row_ins_check_foreign_constraint(
} else {
ut_a(cmp < 0);
- err = row_ins_set_shared_rec_lock(
- LOCK_GAP, block,
- rec, check_index, offsets, thr);
+ err = DB_SUCCESS;
+
+ if (!skip_gap_lock) {
+ err = row_ins_set_shared_rec_lock(
+ LOCK_GAP, block,
+ rec, check_index, offsets, thr);
+ }
switch (err) {
case DB_SUCCESS_LOCKED_REC:
@@ -1878,6 +1898,8 @@ do_possible_lock_wait:
my_atomic_addlint(
&check_table->n_foreign_key_checks_running, 1);
+ trx_kill_blocking(trx);
+
lock_wait_suspend_thread(thr);
thr->lock_state = QUE_THR_LOCK_NOLOCK;
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index 7e6975a67f1..36ad6cdd3d9 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -649,7 +649,7 @@ row_log_table_delete(
&old_pk_extra_size);
ut_ad(old_pk_extra_size < 0x100);
- mrec_size = 4 + old_pk_size;
+ mrec_size = 6 + old_pk_size;
/* Log enough prefix of the BLOB unless both the
old and new table are in COMPACT or REDUNDANT format,
@@ -686,8 +686,8 @@ row_log_table_delete(
*b++ = static_cast<byte>(old_pk_extra_size);
/* Log the size of external prefix we saved */
- mach_write_to_2(b, ext_size);
- b += 2;
+ mach_write_to_4(b, ext_size);
+ b += 4;
rec_convert_dtuple_to_temp(
b + old_pk_extra_size, new_index,
@@ -820,12 +820,9 @@ row_log_table_low_redundant(
mrec_size = ROW_LOG_HEADER_SIZE + size + (extra_size >= 0x80);
- if (ventry && ventry->n_v_fields > 0) {
- ulint v_extra = 0;
- mrec_size += rec_get_converted_size_temp(
- index, NULL, 0, ventry, &v_extra);
-
+ if (num_v) {
if (o_ventry) {
+ ulint v_extra = 0;
mrec_size += rec_get_converted_size_temp(
index, NULL, 0, o_ventry, &v_extra);
}
@@ -878,11 +875,7 @@ row_log_table_low_redundant(
ventry);
b += size;
- if (ventry && ventry->n_v_fields > 0) {
- rec_convert_dtuple_to_temp(
- b, new_index, NULL, 0, ventry);
- b += mach_read_from_2(b);
-
+ if (num_v) {
if (o_ventry) {
rec_convert_dtuple_to_temp(
b, new_index, NULL, 0, o_ventry);
@@ -943,6 +936,13 @@ row_log_table_low(
ut_ad(fil_page_get_type(page_align(rec)) == FIL_PAGE_INDEX);
ut_ad(page_is_leaf(page_align(rec)));
ut_ad(!page_is_comp(page_align(rec)) == !rec_offs_comp(offsets));
+ /* old_pk=row_log_table_get_pk() [not needed in INSERT] is a prefix
+ of the clustered index record (PRIMARY KEY,DB_TRX_ID,DB_ROLL_PTR),
+ with no information on virtual columns */
+ ut_ad(!old_pk || !insert);
+ ut_ad(!old_pk || old_pk->n_v_fields == 0);
+ ut_ad(!o_ventry || !insert);
+ ut_ad(!o_ventry || ventry);
if (dict_index_is_corrupted(index)
|| !dict_index_is_online_ddl(index)
@@ -996,7 +996,7 @@ row_log_table_low(
old_pk_size = rec_get_converted_size_temp(
new_index, old_pk->fields, old_pk->n_fields,
- old_pk, &old_pk_extra_size);
+ NULL, &old_pk_extra_size);
ut_ad(old_pk_extra_size < 0x100);
mrec_size += 1/*old_pk_extra_size*/ + old_pk_size;
}
@@ -2195,8 +2195,9 @@ func_exit_committed:
goto func_exit_committed;
}
- dtuple_t* entry = row_build_index_entry(
- row, NULL, index, heap);
+ /** It allows to create tuple with virtual column information. */
+ dtuple_t* entry = row_build_index_entry_low(
+ row, NULL, index, heap, ROW_BUILD_FOR_INSERT);
upd_t* update = row_upd_build_difference_binary(
index, entry, btr_pcur_get_rec(&pcur), cur_offsets,
false, NULL, heap, dup->table);
@@ -2441,14 +2442,14 @@ row_log_table_apply_op(
break;
case ROW_T_DELETE:
- /* 1 (extra_size) + 2 (ext_size) + at least 1 (payload) */
- if (mrec + 4 >= mrec_end) {
+ /* 1 (extra_size) + 4 (ext_size) + at least 1 (payload) */
+ if (mrec + 6 >= mrec_end) {
return(NULL);
}
extra_size = *mrec++;
- ext_size = mach_read_from_2(mrec);
- mrec += 2;
+ ext_size = mach_read_from_4(mrec);
+ mrec += 4;
ut_ad(mrec < mrec_end);
/* We assume extra_size < 0x100 for the PRIMARY KEY prefix.
@@ -2459,6 +2460,10 @@ row_log_table_apply_op(
rec_init_offsets_temp(mrec, new_index, offsets);
next_mrec = mrec + rec_offs_data_size(offsets) + ext_size;
if (log->table->n_v_cols) {
+ if (next_mrec + 2 >= mrec_end) {
+ return(NULL);
+ }
+
next_mrec += mach_read_from_2(next_mrec);
}
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 85f0ce2c9e6..aeff27c31eb 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2014, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -26,6 +26,7 @@ Completed by Sunny Bains and Marko Makela
*******************************************************/
#include <my_config.h>
#include <log.h>
+#include <sql_class.h>
#include <math.h>
@@ -3300,7 +3301,11 @@ row_merge_sort(
}
#endif /* UNIV_SOLARIS */
- sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : merge-sorting"
+ " has estimated " ULINTPF " runs",
+ num_runs);
+ }
/* Merge the runs until we have one big run */
do {
@@ -4765,9 +4770,11 @@ row_merge_build_indexes(
duplicate keys. */
innobase_rec_reset(table);
- sql_print_information("InnoDB: Online DDL : Start");
- sql_print_information("InnoDB: Online DDL : Start reading clustered "
- "index of the table and create temporary files");
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : Start reading"
+ " clustered index of the table"
+ " and create temporary files");
+ }
pct_cost = COST_READ_CLUSTERED_INDEX * 100 / (total_static_cost + total_dynamic_cost);
@@ -4795,8 +4802,11 @@ row_merge_build_indexes(
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : End of reading "
- "clustered index of the table and create temporary files");
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : End of reading "
+ "clustered index of the table"
+ " and create temporary files");
+ }
for (i = 0; i < n_indexes; i++) {
total_index_blocks += merge_files[i].offset;
@@ -4875,6 +4885,13 @@ wait_again:
" threads exited when creating"
" FTS index '"
<< indexes[i]->name << "'";
+ } else {
+ for (j = 0; j < FTS_NUM_AUX_INDEX;
+ j++) {
+
+ os_thread_join(merge_info[j]
+ .thread_hdl);
+ }
}
} else {
/* This cannot report duplicates; an
@@ -4888,8 +4905,7 @@ wait_again:
DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n");
#endif
} else if (merge_files[i].fd >= 0) {
- char buf[3 * NAME_LEN];
- char *bufend;
+ char buf[NAME_LEN + 1];
row_merge_dup_t dup = {
sort_idx, table, col_map, 0};
@@ -4898,17 +4914,24 @@ wait_again:
total_index_blocks)) /
(total_static_cost + total_dynamic_cost)
* PCT_COST_MERGESORT_INDEX * 100;
-
- bufend = innobase_convert_name(
+ char* bufend = innobase_convert_name(
buf, sizeof buf,
- indexes[i]->name, strlen(indexes[i]->name),
+ indexes[i]->name,
+ strlen(indexes[i]->name),
trx->mysql_thd);
-
buf[bufend - buf]='\0';
- sql_print_information("InnoDB: Online DDL : Start merge-sorting"
- " index %s (%lu / %lu), estimated cost : %2.4f",
- buf, (i+1), n_indexes, pct_cost);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL :"
+ " Start merge-sorting"
+ " index %s"
+ " (" ULINTPF
+ " / " ULINTPF "),"
+ " estimated cost :"
+ " %2.4f",
+ buf, i + 1, n_indexes,
+ pct_cost);
+ }
error = row_merge_sort(
trx, &dup, &merge_files[i],
@@ -4918,9 +4941,14 @@ wait_again:
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : End of "
- " merge-sorting index %s (%lu / %lu)",
- buf, (i+1), n_indexes);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL :"
+ " End of "
+ " merge-sorting index %s"
+ " (" ULINTPF
+ " / " ULINTPF ")",
+ buf, i + 1, n_indexes);
+ }
DBUG_EXECUTE_IF(
"ib_merge_wait_after_sort",
@@ -4937,10 +4965,15 @@ wait_again:
(total_static_cost + total_dynamic_cost) *
PCT_COST_INSERT_INDEX * 100;
- sql_print_information("InnoDB: Online DDL : Start "
- "building index %s (%lu / %lu), estimated "
- "cost : %2.4f", buf, (i+1),
- n_indexes, pct_cost);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : Start "
+ "building index %s"
+ " (" ULINTPF
+ " / " ULINTPF "), estimated "
+ "cost : %2.4f", buf, i + 1,
+ n_indexes, pct_cost);
+ }
error = row_merge_insert_index_tuples(
trx->id, sort_idx, old_table,
@@ -4953,9 +4986,13 @@ wait_again:
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : "
- "End of building index %s (%lu / %lu)",
- buf, (i+1), n_indexes);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : "
+ "End of building index %s"
+ " (" ULINTPF " / " ULINTPF ")",
+ buf, i + 1, n_indexes);
+ }
}
}
@@ -4973,19 +5010,19 @@ wait_again:
== ONLINE_INDEX_COMPLETE);
} else {
ut_ad(need_flush_observer);
- sql_print_information("InnoDB: Online DDL : Start applying row log");
-
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : Applying"
+ " log to index");
+ }
flush_observer->flush();
row_merge_write_redo(indexes[i]);
DEBUG_SYNC_C("row_log_apply_before");
error = row_log_apply(trx, sort_idx, table, stage);
DEBUG_SYNC_C("row_log_apply_after");
- sql_print_information("InnoDB: Online DDL : End of applying row log");
}
- sql_print_information("InnoDB: Online DDL : Completed");
-
if (error != DB_SUCCESS) {
trx->error_key_num = key_numbers[i];
goto func_exit;
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 7d8c1a683e2..aed59070396 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -1505,6 +1505,8 @@ run_again:
row_ins_step(thr);
+ DEBUG_SYNC_C("ib_after_row_insert_step");
+
err = trx->error_state;
if (err != DB_SUCCESS) {
@@ -2888,6 +2890,10 @@ loop:
return(n_tables + n_tables_dropped);
}
+ DBUG_EXECUTE_IF("row_drop_tables_in_background_sleep",
+ os_thread_sleep(5000000);
+ );
+
table = dict_table_open_on_name(drop->table_name, FALSE, FALSE,
DICT_ERR_IGNORE_NONE);
@@ -2898,6 +2904,16 @@ loop:
goto already_dropped;
}
+ if (!table->to_be_dropped) {
+ /* There is a scenario: the old table is dropped
+ just after it's added into drop list, and new
+ table with the same name is created, then we try
+ to drop the new table in background. */
+ dict_table_close(table, FALSE, FALSE);
+
+ goto already_dropped;
+ }
+
ut_a(!table->can_be_evicted);
dict_table_close(table, FALSE, FALSE);
@@ -3766,6 +3782,13 @@ row_drop_table_for_mysql(
}
}
+
+ DBUG_EXECUTE_IF("row_drop_table_add_to_background",
+ row_add_table_to_background_drop_list(table->name.m_name);
+ err = DB_SUCCESS;
+ goto funct_exit;
+ );
+
/* TODO: could we replace the counter n_foreign_key_checks_running
with lock checks on the table? Acquire here an exclusive lock on the
table, and rewrite lock0lock.cc and the lock wait in srv0srv.cc so that
@@ -4272,6 +4295,19 @@ loop:
row_mysql_lock_data_dictionary(trx);
while ((table_name = dict_get_first_table_name_in_db(name))) {
+ /* Drop parent table if it is a fts aux table, to
+ avoid accessing dropped fts aux tables in information
+ scheam when parent table still exists.
+ Note: Drop parent table will drop fts aux tables. */
+ char* parent_table_name;
+ parent_table_name = fts_get_parent_table_name(
+ table_name, strlen(table_name));
+
+ if (parent_table_name != NULL) {
+ ut_free(table_name);
+ table_name = parent_table_name;
+ }
+
ut_a(memcmp(table_name, name, namelen) == 0);
table = dict_table_open_on_name(
@@ -5010,9 +5046,6 @@ row_scan_index_for_mysql(
row_prebuilt_t* prebuilt, /*!< in: prebuilt struct
in MySQL handle */
const dict_index_t* index, /*!< in: index */
- bool check_keys, /*!< in: true=check for mis-
- ordered or duplicate records,
- false=count the rows only */
ulint* n_rows) /*!< out: number of entries
seen in the consistent read */
{
@@ -5079,7 +5112,7 @@ loop:
goto func_exit;
default:
{
- const char* doing = check_keys? "CHECK TABLE" : "COUNT(*)";
+ const char* doing = "CHECK TABLE";
ib::warn() << doing << " on index " << index->name << " of"
" table " << index->table->name << " returned " << ret;
/* fall through (this error is ignored by CHECK TABLE) */
@@ -5095,9 +5128,6 @@ func_exit:
*n_rows = *n_rows + 1;
- if (!check_keys) {
- goto next_rec;
- }
/* else this code is doing handler::check() for CHECK TABLE */
/* row_search... returns the index record in buf, record origin offset
@@ -5179,7 +5209,6 @@ not_ok:
}
}
-next_rec:
ret = row_search_for_mysql(
buf, PAGE_CUR_G, prebuilt, 0, ROW_SEL_NEXT);
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index 2a13203b747..492d864ec96 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -43,6 +43,7 @@ Created 3/14/1997 Heikki Tuuri
#include "srv0start.h"
#include "handler.h"
#include "ha_innodb.h"
+#include "fil0fil.h"
/*************************************************************************
IMPORTANT NOTE: Any operation that generates redo MUST check that there
@@ -852,8 +853,15 @@ try_again:
/* The table has been dropped: no need to do purge */
goto err_exit;
}
+
ut_ad(!dict_table_is_temporary(node->table));
+ if (!fil_table_accessible(node->table)) {
+ dict_table_close(node->table, FALSE, FALSE);
+ node->table = NULL;
+ goto err_exit;
+ }
+
if (node->table->n_v_cols && !node->table->vc_templ
&& dict_table_has_indexed_v_cols(node->table)) {
/* Need server fully up for virtual column computation */
@@ -872,16 +880,6 @@ try_again:
innobase_init_vc_templ(node->table);
}
- if (node->table->ibd_file_missing) {
- /* We skip purge of missing .ibd files */
-
- dict_table_close(node->table, FALSE, FALSE);
-
- node->table = NULL;
-
- goto err_exit;
- }
-
clust_index = dict_table_get_first_index(node->table);
if (clust_index == NULL
diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc
index 46cff288059..1fc30e714f4 100644
--- a/storage/innobase/row/row0trunc.cc
+++ b/storage/innobase/row/row0trunc.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -2000,9 +2000,22 @@ row_truncate_table_for_mysql(
}
if (is_file_per_table && fsp_flags != ULINT_UNDEFINED) {
- fil_reinit_space_header(
- table->space,
- table->indexes.count + FIL_IBD_FILE_INITIAL_SIZE + 1);
+ /* A single-table tablespace has initially
+ FIL_IBD_FILE_INITIAL_SIZE number of pages allocated and an
+ extra page is allocated for each of the indexes present. But in
+ the case of clust index 2 pages are allocated and as one is
+ covered in the calculation as part of table->indexes.count we
+ take care of the other page by adding 1. */
+ ulint space_size = table->indexes.count +
+ FIL_IBD_FILE_INITIAL_SIZE + 1;
+
+ if (has_internal_doc_id) {
+ /* Since aux tables are created for fts indexes and
+ they use seperate tablespaces. */
+ space_size -= ib_vector_size(table->fts->indexes);
+ }
+
+ fil_reinit_space_header(table->space, space_size, trx);
}
DBUG_EXECUTE_IF("ib_trunc_crash_with_intermediate_log_checkpoint",
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index 25504e32087..9288adb21a4 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -41,6 +41,7 @@ Created 2/25/1997 Heikki Tuuri
#include "que0que.h"
#include "ibuf0ibuf.h"
#include "log0log.h"
+#include "fil0fil.h"
/*************************************************************************
IMPORTANT NOTE: Any operation that generates redo MUST check that there
@@ -345,8 +346,20 @@ row_undo_ins_parse_undo_rec(
/* Skip the UNDO if we can't find the table or the .ibd file. */
if (UNIV_UNLIKELY(node->table == NULL)) {
- } else if (UNIV_UNLIKELY(node->table->ibd_file_missing)) {
+ return;
+ }
+
+ if (UNIV_UNLIKELY(!fil_table_accessible(node->table))) {
close_table:
+ /* Normally, tables should not disappear or become
+ unaccessible during ROLLBACK, because they should be
+ protected by InnoDB table locks. TRUNCATE TABLE
+ or table corruption could be valid exceptions.
+
+ FIXME: When running out of temporary tablespace, it
+ would probably be better to just drop all temporary
+ tables (and temporary undo log records) of the current
+ connection, instead of doing this rollback. */
dict_table_close(node->table, dict_locked, FALSE);
node->table = NULL;
} else {
@@ -357,6 +370,9 @@ close_table:
ptr, clust_index, &node->ref, node->heap);
if (!row_undo_search_clust_to_pcur(node)) {
+ /* An error probably occurred during
+ an insert into the clustered index,
+ after we wrote the undo log record. */
goto close_table;
}
if (node->table->n_v_cols) {
diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc
index 378cad00b93..ba072a72aa1 100644
--- a/storage/innobase/row/row0umod.cc
+++ b/storage/innobase/row/row0umod.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1139,12 +1139,19 @@ row_undo_mod_parse_undo_rec(
return;
}
- if (node->table->ibd_file_missing) {
+ if (UNIV_UNLIKELY(!fil_table_accessible(node->table))) {
+close_table:
+ /* Normally, tables should not disappear or become
+ unaccessible during ROLLBACK, because they should be
+ protected by InnoDB table locks. TRUNCATE TABLE
+ or table corruption could be valid exceptions.
+
+ FIXME: When running out of temporary tablespace, it
+ would probably be better to just drop all temporary
+ tables (and temporary undo log records) of the current
+ connection, instead of doing this rollback. */
dict_table_close(node->table, dict_locked, FALSE);
-
- /* We skip undo operations to missing .ibd files */
node->table = NULL;
-
return;
}
@@ -1162,15 +1169,21 @@ row_undo_mod_parse_undo_rec(
node->new_trx_id = trx_id;
node->cmpl_info = cmpl_info;
- if (!row_undo_search_clust_to_pcur(node)) {
-
- dict_table_close(node->table, dict_locked, FALSE);
-
- node->table = NULL;
+ if (UNIV_UNLIKELY(!row_undo_search_clust_to_pcur(node))) {
+ /* This should never occur. As long as this
+ rolling-back transaction exists, the PRIMARY KEY value
+ pointed to by the undo log record must exist.
+ btr_cur_upd_lock_and_undo() only writes the undo log
+ record after successfully acquiring an exclusive lock
+ on the the clustered index record. That lock will not
+ be released before the transaction is committed or
+ fully rolled back. */
+ ut_ad(0);
+ goto close_table;
}
/* Extract indexed virtual columns from undo log */
- if (node->table && node->table->n_v_cols) {
+ if (node->table->n_v_cols) {
row_upd_replace_vcol(node->row, node->table,
node->update, false, node->undo_row,
(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 95f17fa68d0..f3595308363 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -87,7 +87,7 @@ UNIV_INTERN ulong srv_fatal_semaphore_wait_threshold = DEFAULT_SRV_FATAL_SEMAPH
/* How much data manipulation language (DML) statements need to be delayed,
in microseconds, in order to reduce the lagging of the purge thread. */
-ulint srv_dml_needed_delay = 0;
+ulint srv_dml_needed_delay;
bool srv_monitor_active;
bool srv_error_monitor_active;
@@ -107,34 +107,34 @@ const char srv_mysql50_table_name_prefix[10] = "#mysql50#";
/* The following three are dir paths which are catenated before file
names, where the file name itself may also contain a path */
-char* srv_data_home = NULL;
+char* srv_data_home;
/** Rollback files directory, can be absolute. */
-char* srv_undo_dir = NULL;
+char* srv_undo_dir;
/** The number of tablespaces to use for rollback segments. */
-ulong srv_undo_tablespaces = 0;
+ulong srv_undo_tablespaces;
/** The number of UNDO tablespaces that are open and ready to use. */
-ulint srv_undo_tablespaces_open = 0;
+ulint srv_undo_tablespaces_open;
/** The number of UNDO tablespaces that are active (hosting some rollback
segment). It is quite possible that some of the tablespaces doesn't host
any of the rollback-segment based on configuration used. */
-ulint srv_undo_tablespaces_active = 0;
+ulint srv_undo_tablespaces_active;
/* The number of rollback segments to use */
-ulong srv_undo_logs = 1;
+ulong srv_undo_logs;
/** Rate at which UNDO records should be purged. */
-ulong srv_purge_rseg_truncate_frequency = 128;
+ulong srv_purge_rseg_truncate_frequency;
/** Enable or Disable Truncate of UNDO tablespace.
Note: If enabled then UNDO tablespace will be selected for truncate.
While Server waits for undo-tablespace to truncate if user disables
it, truncate action is completed but no new tablespace is marked
for truncate (action is never aborted). */
-my_bool srv_undo_log_truncate = FALSE;
+my_bool srv_undo_log_truncate;
/** Maximum size of undo tablespace. */
unsigned long long srv_max_undo_log_size;
@@ -151,7 +151,7 @@ my_bool srv_read_only_mode;
dictionary tables are in the system tablespace 0 */
my_bool srv_file_per_table;
/** The file format to use on new *.ibd files. */
-ulint srv_file_format = 0;
+ulint srv_file_format;
/** Whether to check file format during startup. A value of
UNIV_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
set it to the highest format we support. */
@@ -166,9 +166,9 @@ my_bool high_level_read_only;
/** Place locks to records only i.e. do not use next-key locking except
on duplicate key checking and foreign key checking */
-ibool srv_locks_unsafe_for_binlog = FALSE;
+ibool srv_locks_unsafe_for_binlog;
/** Sort buffer size in index creation */
-ulong srv_sort_buf_size = 1048576;
+ulong srv_sort_buf_size;
/** Maximum modification log file size for online index creation */
unsigned long long srv_online_max_size;
@@ -176,16 +176,16 @@ unsigned long long srv_online_max_size;
OS (provided we compiled Innobase with it in), otherwise we will
use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
-my_bool srv_use_native_aio = TRUE;
-my_bool srv_numa_interleave = FALSE;
-/* If this flag is TRUE, then we disable doublewrite buffer */
-UNIV_INTERN my_bool srv_use_atomic_writes = FALSE;
-/* If this flag IS TRUE, then we use this algorithm for page compressing the pages */
-UNIV_INTERN ulong innodb_compression_algorithm = PAGE_ZLIB_ALGORITHM;
-/* Number of threads used for multi-threaded flush */
-UNIV_INTERN long srv_mtflush_threads = MTFLUSH_DEFAULT_WORKER;
-/* If this flag is TRUE, then we will use multi threaded flush. */
-UNIV_INTERN my_bool srv_use_mtflush = FALSE;
+my_bool srv_use_native_aio;
+my_bool srv_numa_interleave;
+/** copy of innodb_use_atomic_writes; @see innobase_init() */
+my_bool srv_use_atomic_writes;
+/** innodb_compression_algorithm; used with page compression */
+ulong innodb_compression_algorithm;
+/** innodb_mtflush_threads; number of threads used for multi-threaded flush */
+long srv_mtflush_threads;
+/** innodb_use_mtflush; whether to use multi threaded flush. */
+my_bool srv_use_mtflush;
#ifdef UNIV_DEBUG
/** Used by SET GLOBAL innodb_master_thread_disabled_debug = X. */
@@ -212,22 +212,27 @@ During startup, this is in bytes, and later converted to pages. */
ib_uint64_t srv_log_file_size;
/** The value of the startup parameter innodb_log_file_size */
ib_uint64_t srv_log_file_size_requested;
-/* size in database pages */
-ulint srv_log_buffer_size = ULINT_MAX;
-ulong srv_flush_log_at_trx_commit = 1;
-uint srv_flush_log_at_timeout = 1;
-ulong srv_page_size = UNIV_PAGE_SIZE_DEF;
-ulong srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_DEF;
-ulong srv_log_write_ahead_size = 0;
+/** copy of innodb_log_buffer_size, but in database pages */
+ulint srv_log_buffer_size;
+/** innodb_flush_log_at_trx_commit */
+ulong srv_flush_log_at_trx_commit;
+/** innodb_flush_log_at_timeout */
+uint srv_flush_log_at_timeout;
+/** innodb_page_size */
+ulong srv_page_size;
+/** log2 of innodb_page_size; @see innobase_init() */
+ulong srv_page_size_shift;
+/** innodb_log_write_ahead_size */
+ulong srv_log_write_ahead_size;
page_size_t univ_page_size(0, 0, false);
-/* Try to flush dirty pages so as to avoid IO bursts at
-the checkpoints. */
-char srv_adaptive_flushing = TRUE;
+/** innodb_adaptive_flushing; try to flush dirty pages so as to avoid
+IO bursts at the checkpoints. */
+my_bool srv_adaptive_flushing;
-/* Allow IO bursts at the checkpoints ignoring io_capacity setting. */
-my_bool srv_flush_sync = TRUE;
+/** innodb_flush_sync; whether to ignore io_capacity at log checkpoints */
+my_bool srv_flush_sync;
/** Maximum number of times allowed to conditionally acquire
mutex before switching to blocking wait on the mutex */
@@ -243,93 +248,100 @@ with mutex_enter(), which will wait until it gets the mutex. */
UNIV_INTERN os_event_t srv_allow_writes_event;
#endif /* WITH_INNODB_DISALLOW_WRITES */
-/** Requested size in bytes */
-ulint srv_buf_pool_size = ULINT_MAX;
+/** copy of innodb_buffer_pool_size */
+ulint srv_buf_pool_size;
const ulint srv_buf_pool_min_size = 5 * 1024 * 1024;
/** Default pool size in bytes */
const ulint srv_buf_pool_def_size = 128 * 1024 * 1024;
/** Requested buffer pool chunk size. Each buffer pool instance consists
of one or more chunks. */
ulong srv_buf_pool_chunk_unit;
-/** Requested number of buffer pool instances */
+/** innodb_buffer_pool_instances (0 is interpreted as 1) */
ulong srv_buf_pool_instances;
-/** Default number of buffer pool instances */
+/** Default value of innodb_buffer_pool_instances */
const ulong srv_buf_pool_instances_default = 0;
-/** Number of locks to protect buf_pool->page_hash */
+/** innodb_page_hash_locks (a debug-only parameter);
+number of locks to protect buf_pool->page_hash */
ulong srv_n_page_hash_locks = 16;
-/** Scan depth for LRU flush batch i.e.: number of blocks scanned*/
-ulong srv_LRU_scan_depth = 1024;
-/** Whether or not to flush neighbors of a block */
-ulong srv_flush_neighbors = 1;
+/** innodb_lru_scan_depth; number of blocks scanned in LRU flush batch */
+ulong srv_LRU_scan_depth;
+/** innodb_flush_neighbors; whether or not to flush neighbors of a block */
+ulong srv_flush_neighbors;
/** Previously requested size */
-ulint srv_buf_pool_old_size = 0;
+ulint srv_buf_pool_old_size;
/** Current size as scaling factor for the other components */
-ulint srv_buf_pool_base_size = 0;
+ulint srv_buf_pool_base_size;
/** Current size in bytes */
-ulint srv_buf_pool_curr_size = 0;
+ulint srv_buf_pool_curr_size;
/** Dump this % of each buffer pool during BP dump */
ulong srv_buf_pool_dump_pct;
/** Lock table size in bytes */
ulint srv_lock_table_size = ULINT_MAX;
-UNIV_INTERN ulong srv_idle_flush_pct = 100;
+/** innodb_idle_flush_pct */
+ulong srv_idle_flush_pct;
-/* This parameter is deprecated. Use srv_n_io_[read|write]_threads
-instead. */
-ulint srv_n_read_io_threads = ULINT_MAX;
-ulint srv_n_write_io_threads = ULINT_MAX;
+/** copy of innodb_read_io_threads */
+ulint srv_n_read_io_threads;
+/** copy of innodb_write_io_threads */
+ulint srv_n_write_io_threads;
-/* Switch to enable random read ahead. */
-my_bool srv_random_read_ahead = FALSE;
-/* User settable value of the number of pages that must be present
+/** innodb_random_read_ahead */
+my_bool srv_random_read_ahead;
+/** innodb_read_ahead_threshold; the number of pages that must be present
in the buffer cache and accessed sequentially for InnoDB to trigger a
readahead request. */
-ulong srv_read_ahead_threshold = 56;
+ulong srv_read_ahead_threshold;
-/** Maximum on-disk size of change buffer in terms of percentage
-of the buffer pool. */
-uint srv_change_buffer_max_size = CHANGE_BUFFER_DEFAULT_SIZE;
+/** innodb_change_buffer_max_size; maximum on-disk size of change
+buffer in terms of percentage of the buffer pool. */
+uint srv_change_buffer_max_size;
-char* srv_file_flush_method_str = NULL;
+char* srv_file_flush_method_str;
enum srv_flush_t srv_file_flush_method = IF_WIN(SRV_ALL_O_DIRECT_FSYNC,SRV_FSYNC);
-ulint srv_max_n_open_files = 300;
+/** copy of innodb_open_files, initialized by innobase_init() */
+ulint srv_max_n_open_files;
-/* Number of IO operations per second the server can do */
-ulong srv_io_capacity = 200;
-ulong srv_max_io_capacity = 400;
+/** innodb_io_capacity */
+ulong srv_io_capacity;
+/** innodb_io_capacity_max */
+ulong srv_max_io_capacity;
-/* The number of page cleaner threads to use.*/
-ulong srv_n_page_cleaners = 4;
+/** innodb_page_cleaners; the number of page cleaner threads */
+ulong srv_n_page_cleaners;
/* The InnoDB main thread tries to keep the ratio of modified pages
in the buffer pool to all database pages in the buffer pool smaller than
the following number. But it is not guaranteed that the value stays below
that during a time of heavy update/insert activity. */
-double srv_max_buf_pool_modified_pct = 75.0;
-double srv_max_dirty_pages_pct_lwm = 0.0;
+/** innodb_max_dirty_pages_pct */
+double srv_max_buf_pool_modified_pct;
+/** innodb_max_dirty_pages_pct_lwm */
+double srv_max_dirty_pages_pct_lwm;
-/* This is the percentage of log capacity at which adaptive flushing,
-if enabled, will kick in. */
-UNIV_INTERN double srv_adaptive_flushing_lwm = 10.0;
+/** innodb_adaptive_flushing_lwm; the percentage of log capacity at
+which adaptive flushing, if enabled, will kick in. */
+double srv_adaptive_flushing_lwm;
-/* Number of iterations over which adaptive flushing is averaged. */
-ulong srv_flushing_avg_loops = 30;
+/** innodb_flushing_avg_loops; number of iterations over which
+adaptive flushing is averaged */
+ulong srv_flushing_avg_loops;
-/* The number of purge threads to use.*/
-ulong srv_n_purge_threads = 4;
+/** innodb_purge_threads; the number of purge threads to use */
+ulong srv_n_purge_threads;
-/* the number of pages to purge in one batch */
-ulong srv_purge_batch_size = 20;
+/** innodb_purge_batch_size, in pages */
+ulong srv_purge_batch_size;
-/* Internal setting for "innodb_stats_method". Decides how InnoDB treats
+/** innodb_stats_method decides how InnoDB treats
NULL value when collecting statistics. By default, it is set to
SRV_STATS_NULLS_EQUAL(0), ie. all NULL value are treated equal */
-ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL;
+ulong srv_innodb_stats_method;
srv_stats_t srv_stats;
@@ -342,59 +354,67 @@ by SELECT or mysqldump. When this is nonzero, we do not allow any user
modifications to the data. */
ulong srv_force_recovery;
-/** Print all user-level transactions deadlocks to mysqld stderr */
+/** innodb_print_all_deadlocks; whether to print all user-level
+transactions deadlocks to the error log */
+my_bool srv_print_all_deadlocks;
-my_bool srv_print_all_deadlocks = FALSE;
+/** innodb_cmp_per_index_enabled; enable
+INFORMATION_SCHEMA.innodb_cmp_per_index */
+my_bool srv_cmp_per_index_enabled;
-/** Enable INFORMATION_SCHEMA.innodb_cmp_per_index */
-my_bool srv_cmp_per_index_enabled = FALSE;
-
-/* If the following is set to 1 then we do not run purge and insert buffer
+/** innodb_fast_shutdown; if 1 then we do not run purge and insert buffer
merge to completion before shutdown. If it is set to 2, do not even flush the
buffer pool to data files at the shutdown: we effectively 'crash'
InnoDB (but lose no committed transactions). */
uint srv_fast_shutdown;
-/* Generate a innodb_status.<pid> file */
-ibool srv_innodb_status = FALSE;
+/** copy of innodb_status_file; generate a innodb_status.<pid> file */
+ibool srv_innodb_status;
-/* Optimize prefix index queries to skip cluster index lookup when possible */
-/* Enables or disables this prefix optimization. Disabled by default. */
-UNIV_INTERN my_bool srv_prefix_index_cluster_optimization = 0;
+/** innodb_prefix_index_cluster_optimization; whether to optimize
+prefix index queries to skip cluster index lookup when possible */
+my_bool srv_prefix_index_cluster_optimization;
-/* When estimating number of different key values in an index, sample
+/** innodb_stats_transient_sample_pages;
+When estimating number of different key values in an index, sample
this many index pages, there are 2 ways to calculate statistics:
* persistent stats that are calculated by ANALYZE TABLE and saved
in the innodb database.
* quick transient stats, that are used if persistent stats for the given
table/index are not found in the innodb database */
-unsigned long long srv_stats_transient_sample_pages = 8;
-my_bool srv_stats_persistent = TRUE;
-unsigned long long srv_stats_persistent_sample_pages = 20;
-my_bool srv_stats_auto_recalc = TRUE;
-
-/* The number of rows modified before we calculate new statistics (default 0
-= current limits) */
-UNIV_INTERN unsigned long long srv_stats_modified_counter = 0;
-
-/* Enable traditional statistic calculation based on number of configured
-pages default true. */
-UNIV_INTERN my_bool srv_stats_sample_traditional = TRUE;
-
-ibool srv_use_doublewrite_buf = TRUE;
-
-/** doublewrite buffer is 1MB is size i.e.: it can hold 128 16K pages.
-The following parameter is the size of the buffer that is used for
-batch flushing i.e.: LRU flushing and flush_list flushing. The rest
-of the pages are used for single page flushing. */
-ulong srv_doublewrite_batch_size = 120;
-
-ulong srv_replication_delay = 0;
-
-/*-------------------------------------------*/
-UNIV_INTERN ulong srv_n_spin_wait_rounds = 15;
+unsigned long long srv_stats_transient_sample_pages;
+/** innodb_stats_persistent */
+my_bool srv_stats_persistent;
+/** innodb_stats_include_delete_marked */
+my_bool srv_stats_include_delete_marked;
+/** innodb_stats_persistent_sample_pages */
+unsigned long long srv_stats_persistent_sample_pages;
+/** innodb_stats_auto_recalc */
+my_bool srv_stats_auto_recalc;
+
+/** innodb_stats_modified_counter; The number of rows modified before
+we calculate new statistics (default 0 = current limits) */
+unsigned long long srv_stats_modified_counter;
+
+/** innodb_stats_traditional; enable traditional statistic calculation
+based on number of configured pages */
+my_bool srv_stats_sample_traditional;
+
+/** copy of innodb_doublewrite */
+ibool srv_use_doublewrite_buf;
+
+/** innodb_doublewrite_batch_size (a debug parameter) specifies the
+number of pages to use in LRU and flush_list batch flushing.
+The rest of the doublewrite buffer is used for single-page flushing. */
+ulong srv_doublewrite_batch_size = 120;
+
+/** innodb_replication_delay */
+ulong srv_replication_delay;
+
+/** innodb_sync_spin_loops */
+ulong srv_n_spin_wait_rounds;
+/** innodb_spin_wait_delay */
uint srv_spin_wait_delay;
-ibool srv_priority_boost = TRUE;
static ulint srv_n_rows_inserted_old;
static ulint srv_n_rows_updated_old;
@@ -421,23 +441,29 @@ UNIV_INTERN ib_uint64_t srv_index_page_decompressed;
/* Defragmentation */
UNIV_INTERN my_bool srv_defragment;
-UNIV_INTERN uint srv_defragment_n_pages = 7;
+/** innodb_defragment_n_pages */
+UNIV_INTERN uint srv_defragment_n_pages;
UNIV_INTERN uint srv_defragment_stats_accuracy;
-UNIV_INTERN uint srv_defragment_fill_factor_n_recs = 20;
-UNIV_INTERN double srv_defragment_fill_factor = 0.9;
-UNIV_INTERN uint srv_defragment_frequency =
- SRV_DEFRAGMENT_FREQUENCY_DEFAULT;
+/** innodb_defragment_fill_factor_n_recs */
+UNIV_INTERN uint srv_defragment_fill_factor_n_recs;
+/** innodb_defragment_fill_factor */
+UNIV_INTERN double srv_defragment_fill_factor;
+/** innodb_defragment_frequency */
+UNIV_INTERN uint srv_defragment_frequency;
+/** derived from innodb_defragment_frequency;
+@see innodb_defragment_frequency_update() */
UNIV_INTERN ulonglong srv_defragment_interval;
/* Set the following to 0 if you want InnoDB to write messages on
-stderr on startup/shutdown. */
-ibool srv_print_verbose_log = TRUE;
-my_bool srv_print_innodb_monitor = FALSE;
-my_bool srv_print_innodb_lock_monitor = FALSE;
-my_bool srv_print_innodb_tablespace_monitor = FALSE;
-my_bool srv_print_innodb_table_monitor = FALSE;
-/** If this flag is set tables without primary key are not allowed */
-my_bool srv_force_primary_key = FALSE;
+stderr on startup/shutdown. Not enabled on the embedded server. */
+ibool srv_print_verbose_log;
+my_bool srv_print_innodb_monitor;
+my_bool srv_print_innodb_lock_monitor;
+my_bool srv_print_innodb_tablespace_monitor;
+my_bool srv_print_innodb_table_monitor;
+/** innodb_force_primary_key; whether to disallow CREATE TABLE without
+PRIMARY KEY */
+my_bool srv_force_primary_key;
/* Array of English strings describing the current state of an
i/o handler thread */
@@ -470,19 +496,19 @@ ib_mutex_t srv_misc_tmpfile_mutex;
/** Temporary file for miscellanous diagnostic output */
FILE* srv_misc_tmpfile;
-static ulint srv_main_thread_process_no = 0;
-static ulint srv_main_thread_id = 0;
+static ulint srv_main_thread_process_no;
+static ulint srv_main_thread_id;
/* The following counts are used by the srv_master_thread. */
/** Iterations of the loop bounded by 'srv_active' label. */
-static ulint srv_main_active_loops = 0;
+static ulint srv_main_active_loops;
/** Iterations of the loop bounded by the 'srv_idle' label. */
-static ulint srv_main_idle_loops = 0;
+static ulint srv_main_idle_loops;
/** Iterations of the loop bounded by the 'srv_shutdown' label. */
-static ulint srv_main_shutdown_loops = 0;
+static ulint srv_main_shutdown_loops;
/** Log writes involving flush. */
-static ulint srv_log_writes_and_flush = 0;
+static ulint srv_log_writes_and_flush;
/* This is only ever touched by the master thread. It records the
time when the last flush of log file has happened. The master
@@ -503,10 +529,10 @@ current_time % 5 != 0. */
# define SRV_MASTER_DICT_LRU_INTERVAL (47)
/** Simulate compression failures. */
-UNIV_INTERN uint srv_simulate_comp_failures = 0;
+UNIV_INTERN uint srv_simulate_comp_failures;
/** Buffer pool dump status frequence in percentages */
-UNIV_INTERN ulong srv_buf_dump_status_frequency = 0;
+UNIV_INTERN ulong srv_buf_dump_status_frequency;
/** Acquire the system_mutex. */
#define srv_sys_mutex_enter() do { \
@@ -614,14 +640,16 @@ struct srv_sys_t{
ulint n_threads_active[SRV_MASTER + 1];
/*!< number of threads active
- in a thread class */
+ in a thread class; protected
+ by both my_atomic_addlint()
+ and mutex */
srv_stats_t::ulint_ctr_1_t
activity_count; /*!< For tracking server
activity */
};
-static srv_sys_t* srv_sys = NULL;
+static srv_sys_t* srv_sys;
/** Event to signal srv_monitor_thread. Not protected by a mutex.
Set after setting srv_print_innodb_monitor. */
@@ -819,7 +847,7 @@ srv_reserve_slot(
ut_ad(srv_slot_get_type(slot) == type);
- ++srv_sys->n_threads_active[type];
+ my_atomic_addlint(&srv_sys->n_threads_active[type], 1);
srv_sys_mutex_exit();
@@ -860,16 +888,15 @@ srv_suspend_thread_low(
case SRV_WORKER:
ut_a(srv_n_purge_threads > 1);
- ut_a(srv_sys->n_threads_active[type] > 0);
break;
}
ut_a(!slot->suspended);
slot->suspended = TRUE;
- ut_a(srv_sys->n_threads_active[type] > 0);
-
- srv_sys->n_threads_active[type]--;
+ if (my_atomic_addlint(&srv_sys->n_threads_active[type], -1) < 0) {
+ ut_error;
+ }
return(os_event_reset(slot->event));
}
@@ -924,7 +951,7 @@ srv_resume_thread(srv_slot_t* slot, int64_t sig_count = 0, bool wait = true,
ut_ad(slot->suspended);
slot->suspended = FALSE;
- ++srv_sys->n_threads_active[slot->type];
+ my_atomic_addlint(&srv_sys->n_threads_active[slot->type], 1);
srv_sys_mutex_exit();
return(timeout);
}
@@ -1476,7 +1503,7 @@ srv_export_innodb_status(void)
ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS));
export_vars.innodb_data_pending_writes =
- ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS));
+ ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
export_vars.innodb_data_pending_fsyncs =
fil_n_pending_log_flushes
@@ -2032,22 +2059,16 @@ srv_get_active_thread_type(void)
return(ret);
}
-/*******************************************************************//**
-Tells the InnoDB server that there has been activity in the database
-and wakes up the master thread if it is suspended (not sleeping). Used
-in the MySQL interface. Note that there is a small chance that the master
-thread stays suspended (we do not protect our operation with the
-srv_sys_t->mutex, for performance reasons). */
+/** Wake up the InnoDB master thread if it was suspended (not sleeping). */
void
srv_active_wake_master_thread_low()
-/*===============================*/
{
ut_ad(!srv_read_only_mode);
ut_ad(!srv_sys_mutex_own());
srv_inc_activity_count();
- if (srv_sys->n_threads_active[SRV_MASTER] == 0) {
+ if (my_atomic_loadlint(&srv_sys->n_threads_active[SRV_MASTER]) == 0) {
srv_slot_t* slot;
srv_sys_mutex_enter();
@@ -2065,35 +2086,25 @@ srv_active_wake_master_thread_low()
}
}
-/*******************************************************************//**
-Tells the purge thread that there has been activity in the database
-and wakes up the purge thread if it is suspended (not sleeping). Note
-that there is a small chance that the purge thread stays suspended
-(we do not protect our check with the srv_sys_t:mutex and the
-purge_sys->latch, for performance reasons). */
+/** Wake up the purge threads if there is work to do. */
void
-srv_wake_purge_thread_if_not_active(void)
-/*=====================================*/
+srv_wake_purge_thread_if_not_active()
{
ut_ad(!srv_sys_mutex_own());
if (purge_sys->state == PURGE_STATE_RUN
- && srv_sys->n_threads_active[SRV_PURGE] == 0) {
+ && !my_atomic_loadlint(&srv_sys->n_threads_active[SRV_PURGE])
+ && my_atomic_loadlint(&trx_sys->rseg_history_len)) {
srv_release_threads(SRV_PURGE, 1);
}
}
-/*******************************************************************//**
-Wakes up the master thread if it is suspended or being suspended. */
+/** Wake up the master thread if it is suspended or being suspended. */
void
-srv_wake_master_thread(void)
-/*========================*/
+srv_wake_master_thread()
{
- ut_ad(!srv_sys_mutex_own());
-
srv_inc_activity_count();
-
srv_release_threads(SRV_MASTER, 1);
}
@@ -2679,12 +2690,8 @@ DECLARE_THREAD(srv_worker_thread)(
slot = srv_reserve_slot(SRV_WORKER);
ut_a(srv_n_purge_threads > 1);
-
- srv_sys_mutex_enter();
-
- ut_a(srv_sys->n_threads_active[SRV_WORKER] < srv_n_purge_threads);
-
- srv_sys_mutex_exit();
+ ut_a(my_atomic_loadlint(&srv_sys->n_threads_active[SRV_WORKER])
+ < static_cast<lint>(srv_n_purge_threads));
/* We need to ensure that the worker threads exit after the
purge coordinator thread. Otherwise the purge coordinator can
@@ -2957,14 +2964,9 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
ut_a(srv_purge_should_exit(thd, n_total_purged));
- ulint n_pages_purged = ULINT_MAX;
-
- /* Ensure that all records are purged if it is not a fast shutdown.
- This covers the case where a record can be added after we exit the
- loop above. */
- while (srv_fast_shutdown == 0 && n_pages_purged > 0) {
- n_pages_purged = trx_purge(1, srv_purge_batch_size, false);
- }
+ /* Ensure that all records are purged on slow shutdown. */
+ while (srv_fast_shutdown == 0
+ && trx_purge(1, srv_purge_batch_size, false));
#ifdef UNIV_DEBUG
if (srv_fast_shutdown == 0) {
@@ -2978,12 +2980,10 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
delay in shutdown ,so reducing the batch size to magic number 20
(which was default in 5.5), which we hope will be sufficient to
remove all the undo records */
- const uint temp_batch_size = 20;
- n_pages_purged = trx_purge(1, srv_purge_batch_size <= temp_batch_size
- ? srv_purge_batch_size : temp_batch_size,
- true);
- ut_a(n_pages_purged == 0 || srv_fast_shutdown != 0);
+ if (trx_purge(1, std::min(srv_purge_batch_size, 20UL), true)) {
+ ut_a(srv_fast_shutdown);
+ }
/* The task queue should always be empty, independent of fast
shutdown state. */
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 9e89dfda833..6d153ff1bc6 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -121,22 +121,22 @@ lsn_t srv_start_lsn;
lsn_t srv_shutdown_lsn;
/** TRUE if a raw partition is in use */
-ibool srv_start_raw_disk_in_use = FALSE;
+ibool srv_start_raw_disk_in_use;
/** Number of IO threads to use */
-ulint srv_n_file_io_threads = 0;
+ulint srv_n_file_io_threads;
/** TRUE if the server is being started, before rolling back any
incomplete transactions */
-bool srv_startup_is_before_trx_rollback_phase = false;
+bool srv_startup_is_before_trx_rollback_phase;
/** TRUE if the server is being started */
-bool srv_is_being_started = false;
+bool srv_is_being_started;
/** TRUE if SYS_TABLESPACES is available for lookups */
-bool srv_sys_tablespaces_open = false;
+bool srv_sys_tablespaces_open;
/** TRUE if the server was successfully started */
-ibool srv_was_started = FALSE;
+bool srv_was_started;
/** TRUE if innobase_start_or_create_for_mysql() has been called */
-static ibool srv_start_has_been_called = FALSE;
+static bool srv_start_has_been_called;
#ifdef UNIV_DEBUG
/** InnoDB system tablespace to set during recovery */
UNIV_INTERN uint srv_sys_space_size_debug;
@@ -894,6 +894,7 @@ srv_undo_tablespaces_init(bool create_new_db)
}
}
} else {
+ srv_undo_tablespaces_active = srv_undo_tablespaces;
n_undo_tablespaces = srv_undo_tablespaces;
for (i = 1; i <= n_undo_tablespaces; ++i) {
@@ -975,12 +976,10 @@ srv_undo_tablespaces_init(bool create_new_db)
return(err != DB_SUCCESS ? err : DB_ERROR);
- } else if (n_undo_tablespaces > 0) {
+ } else if (n_undo_tablespaces > 0) {
ib::info() << "Opened " << n_undo_tablespaces
- << " undo tablespaces ("
- << srv_undo_tablespaces_active
- << " active)";
+ << " undo tablespaces";
if (srv_undo_tablespaces == 0) {
ib::warn() << "innodb_undo_tablespaces=0 disables"
@@ -1443,6 +1442,10 @@ innobase_start_or_create_for_mysql(void)
size_t dirnamelen;
unsigned i = 0;
+ if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) {
+ srv_read_only_mode = true;
+ }
+
high_level_read_only = srv_read_only_mode
|| srv_force_recovery > SRV_FORCE_NO_TRX_UNDO;
@@ -1519,7 +1522,7 @@ innobase_start_or_create_for_mysql(void)
" once during the process lifetime.";
}
- srv_start_has_been_called = TRUE;
+ srv_start_has_been_called = true;
srv_is_being_started = true;
@@ -2889,8 +2892,8 @@ innodb_shutdown()
}
srv_start_state = SRV_START_STATE_NONE;
- srv_was_started = FALSE;
- srv_start_has_been_called = FALSE;
+ srv_was_started = false;
+ srv_start_has_been_called = false;
}
#if 0 // TODO: Enable this in WL#6608
diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc
index 956511a7f59..75919043731 100644
--- a/storage/innobase/sync/sync0arr.cc
+++ b/storage/innobase/sync/sync0arr.cc
@@ -514,17 +514,17 @@ sync_array_cell_print(
if (mutex) {
fprintf(file,
- "Mutex at %p, %s, lock var %lu\n"
+ "Mutex at %p, %s, lock var %x\n"
#ifdef UNIV_DEBUG
- "Last time reserved in file %s line %lu"
+ "Last time reserved in file %s line %u"
#endif /* UNIV_DEBUG */
"\n",
(void*) mutex,
policy.to_string().c_str(),
- (ulong) mutex->state()
+ mutex->state()
#ifdef UNIV_DEBUG
,name,
- (ulong) policy.get_enter_line()
+ policy.get_enter_line()
#endif /* UNIV_DEBUG */
);
}
@@ -569,18 +569,18 @@ sync_array_cell_print(
if (rwlock) {
fprintf(file,
- " RW-latch at %p created in file %s line %lu\n",
+ " RW-latch at %p created in file %s line %u\n",
(void*) rwlock, innobase_basename(rwlock->cfile_name),
- (ulong) rwlock->cline);
+ rwlock->cline);
writer = rw_lock_get_writer(rwlock);
if (writer != RW_LOCK_NOT_LOCKED) {
fprintf(file,
- "a writer (thread id %lu) has"
+ "a writer (thread id " ULINTPF ") has"
" reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
+ os_thread_pf(rwlock->writer_thread),
writer == RW_LOCK_X ? " exclusive\n"
: writer == RW_LOCK_SX ? " SX\n"
: " wait exclusive\n");
@@ -591,21 +591,25 @@ sync_array_cell_print(
", waiters flag %u, "
"lock_word: " ULINTPFx "\n"
"Last time read locked in file %s line %u\n"
- "Last time write locked in file %s line %u\n",
+ "Last time write locked in file %s line %u"
+#if 0 /* JAN: TODO: FIX LATER */
+ "\nHolder thread " ULINTPF
+ " file %s line " ULINTPF
+#endif
+ "\n",
rw_lock_get_reader_count(rwlock),
rwlock->waiters,
rwlock->lock_word,
innobase_basename(rwlock->last_s_file_name),
rwlock->last_s_line,
- rwlock->last_x_file_name,
- rwlock->last_x_line);
-
- /* JAN: TODO: FIX LATER
- fprintf(file,
- "Holder thread %lu file %s line %lu\n",
- rwlock->thread_id, rwlock->file_name,
- rwlock->line);
- */
+ innobase_basename(rwlock->last_x_file_name),
+ rwlock->last_x_line
+#if 0 /* JAN: TODO: FIX LATER */
+ , os_thread_pf(rwlock->thread_id),
+ innobase_basename(rwlock->file_name),
+ rwlock->line
+#endif
+ );
}
} else {
diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc
index 135c84ad0d8..4fff24a77f1 100644
--- a/storage/innobase/sync/sync0debug.cc
+++ b/storage/innobase/sync/sync0debug.cc
@@ -130,7 +130,7 @@ struct LatchDebug {
os_thread_id_t,
Latches*,
os_thread_id_less,
- ut_allocator<std::pair<const std::string, latch_meta_t> > >
+ ut_allocator<std::pair<const os_thread_id_t, Latches*> > >
ThreadMap;
/** Constructor */
@@ -425,7 +425,7 @@ private:
latch_level_t,
std::string,
latch_level_less,
- ut_allocator<std::pair<latch_level_t, std::string> > >
+ ut_allocator<std::pair<const latch_level_t, std::string> > >
Levels;
/** Mutex protecting the deadlock detector data structures. */
@@ -1342,219 +1342,249 @@ sync_latch_meta_init()
/* The latches should be ordered on latch_id_t. So that we can
index directly into the vector to update and fetch meta-data. */
- LATCH_ADD(AUTOINC, SYNC_DICT_AUTOINC_MUTEX, autoinc_mutex_key);
+ LATCH_ADD_MUTEX(AUTOINC, SYNC_DICT_AUTOINC_MUTEX, autoinc_mutex_key);
#if defined PFS_SKIP_BUFFER_MUTEX_RWLOCK || defined PFS_GROUP_BUFFER_SYNC
- LATCH_ADD(BUF_BLOCK_MUTEX, SYNC_BUF_BLOCK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(BUF_BLOCK_MUTEX, SYNC_BUF_BLOCK, PFS_NOT_INSTRUMENTED);
#else
- LATCH_ADD(BUF_BLOCK_MUTEX, SYNC_BUF_BLOCK, buffer_block_mutex_key);
+ LATCH_ADD_MUTEX(BUF_BLOCK_MUTEX, SYNC_BUF_BLOCK,
+ buffer_block_mutex_key);
#endif /* PFS_SKIP_BUFFER_MUTEX_RWLOCK || PFS_GROUP_BUFFER_SYNC */
- LATCH_ADD(BUF_POOL, SYNC_BUF_POOL, buf_pool_mutex_key);
+ LATCH_ADD_MUTEX(BUF_POOL, SYNC_BUF_POOL, buf_pool_mutex_key);
- LATCH_ADD(BUF_POOL_ZIP, SYNC_BUF_BLOCK, buf_pool_zip_mutex_key);
+ LATCH_ADD_MUTEX(BUF_POOL_ZIP, SYNC_BUF_BLOCK, buf_pool_zip_mutex_key);
- LATCH_ADD(CACHE_LAST_READ, SYNC_TRX_I_S_LAST_READ,
- cache_last_read_mutex_key);
+ LATCH_ADD_MUTEX(CACHE_LAST_READ, SYNC_TRX_I_S_LAST_READ,
+ cache_last_read_mutex_key);
- LATCH_ADD(DICT_FOREIGN_ERR, SYNC_NO_ORDER_CHECK,
- dict_foreign_err_mutex_key);
+ LATCH_ADD_MUTEX(DICT_FOREIGN_ERR, SYNC_NO_ORDER_CHECK,
+ dict_foreign_err_mutex_key);
- LATCH_ADD(DICT_SYS, SYNC_DICT, dict_sys_mutex_key);
+ LATCH_ADD_MUTEX(DICT_SYS, SYNC_DICT, dict_sys_mutex_key);
- LATCH_ADD(FILE_FORMAT_MAX, SYNC_FILE_FORMAT_TAG,
- file_format_max_mutex_key);
+ LATCH_ADD_MUTEX(FILE_FORMAT_MAX, SYNC_FILE_FORMAT_TAG,
+ file_format_max_mutex_key);
- LATCH_ADD(FIL_SYSTEM, SYNC_ANY_LATCH, fil_system_mutex_key);
+ LATCH_ADD_MUTEX(FIL_SYSTEM, SYNC_ANY_LATCH, fil_system_mutex_key);
- LATCH_ADD(FLUSH_LIST, SYNC_BUF_FLUSH_LIST, flush_list_mutex_key);
+ LATCH_ADD_MUTEX(FLUSH_LIST, SYNC_BUF_FLUSH_LIST, flush_list_mutex_key);
- LATCH_ADD(FTS_BG_THREADS, SYNC_FTS_BG_THREADS,
- fts_bg_threads_mutex_key);
+ LATCH_ADD_MUTEX(FTS_BG_THREADS, SYNC_FTS_BG_THREADS,
+ fts_bg_threads_mutex_key);
- LATCH_ADD(FTS_DELETE, SYNC_FTS_OPTIMIZE, fts_delete_mutex_key);
+ LATCH_ADD_MUTEX(FTS_DELETE, SYNC_FTS_OPTIMIZE, fts_delete_mutex_key);
- LATCH_ADD(FTS_OPTIMIZE, SYNC_FTS_OPTIMIZE, fts_optimize_mutex_key);
+ LATCH_ADD_MUTEX(FTS_OPTIMIZE, SYNC_FTS_OPTIMIZE,
+ fts_optimize_mutex_key);
- LATCH_ADD(FTS_DOC_ID, SYNC_FTS_OPTIMIZE, fts_doc_id_mutex_key);
+ LATCH_ADD_MUTEX(FTS_DOC_ID, SYNC_FTS_OPTIMIZE, fts_doc_id_mutex_key);
- LATCH_ADD(FTS_PLL_TOKENIZE, SYNC_FTS_TOKENIZE,
- fts_pll_tokenize_mutex_key);
+ LATCH_ADD_MUTEX(FTS_PLL_TOKENIZE, SYNC_FTS_TOKENIZE,
+ fts_pll_tokenize_mutex_key);
- LATCH_ADD(HASH_TABLE_MUTEX, SYNC_BUF_PAGE_HASH, hash_table_mutex_key);
+ LATCH_ADD_MUTEX(HASH_TABLE_MUTEX, SYNC_BUF_PAGE_HASH,
+ hash_table_mutex_key);
- LATCH_ADD(IBUF_BITMAP, SYNC_IBUF_BITMAP_MUTEX, ibuf_bitmap_mutex_key);
+ LATCH_ADD_MUTEX(IBUF_BITMAP, SYNC_IBUF_BITMAP_MUTEX,
+ ibuf_bitmap_mutex_key);
- LATCH_ADD(IBUF, SYNC_IBUF_MUTEX, ibuf_mutex_key);
+ LATCH_ADD_MUTEX(IBUF, SYNC_IBUF_MUTEX, ibuf_mutex_key);
- LATCH_ADD(IBUF_PESSIMISTIC_INSERT, SYNC_IBUF_PESS_INSERT_MUTEX,
- ibuf_pessimistic_insert_mutex_key);
+ LATCH_ADD_MUTEX(IBUF_PESSIMISTIC_INSERT, SYNC_IBUF_PESS_INSERT_MUTEX,
+ ibuf_pessimistic_insert_mutex_key);
- LATCH_ADD(LOG_SYS, SYNC_LOG, log_sys_mutex_key);
+ LATCH_ADD_MUTEX(LOG_SYS, SYNC_LOG, log_sys_mutex_key);
- LATCH_ADD(LOG_WRITE, SYNC_LOG_WRITE, log_sys_write_mutex_key);
+ LATCH_ADD_MUTEX(LOG_WRITE, SYNC_LOG_WRITE, log_sys_write_mutex_key);
- LATCH_ADD(LOG_FLUSH_ORDER, SYNC_LOG_FLUSH_ORDER,
- log_flush_order_mutex_key);
+ LATCH_ADD_MUTEX(LOG_FLUSH_ORDER, SYNC_LOG_FLUSH_ORDER,
+ log_flush_order_mutex_key);
- LATCH_ADD(MUTEX_LIST, SYNC_NO_ORDER_CHECK, mutex_list_mutex_key);
+ LATCH_ADD_MUTEX(MUTEX_LIST, SYNC_NO_ORDER_CHECK, mutex_list_mutex_key);
- LATCH_ADD(PAGE_CLEANER, SYNC_PAGE_CLEANER, page_cleaner_mutex_key);
+ LATCH_ADD_MUTEX(PAGE_CLEANER, SYNC_PAGE_CLEANER,
+ page_cleaner_mutex_key);
- LATCH_ADD(PURGE_SYS_PQ, SYNC_PURGE_QUEUE, purge_sys_pq_mutex_key);
+ LATCH_ADD_MUTEX(PURGE_SYS_PQ, SYNC_PURGE_QUEUE,
+ purge_sys_pq_mutex_key);
- LATCH_ADD(RECALC_POOL, SYNC_STATS_AUTO_RECALC,
- recalc_pool_mutex_key);
+ LATCH_ADD_MUTEX(RECALC_POOL, SYNC_STATS_AUTO_RECALC,
+ recalc_pool_mutex_key);
- LATCH_ADD(RECV_SYS, SYNC_RECV, recv_sys_mutex_key);
+ LATCH_ADD_MUTEX(RECV_SYS, SYNC_RECV, recv_sys_mutex_key);
- LATCH_ADD(RECV_WRITER, SYNC_RECV_WRITER, recv_writer_mutex_key);
+ LATCH_ADD_MUTEX(RECV_WRITER, SYNC_RECV_WRITER, recv_writer_mutex_key);
- LATCH_ADD(REDO_RSEG, SYNC_REDO_RSEG, redo_rseg_mutex_key);
+ LATCH_ADD_MUTEX(REDO_RSEG, SYNC_REDO_RSEG, redo_rseg_mutex_key);
- LATCH_ADD(NOREDO_RSEG, SYNC_NOREDO_RSEG, noredo_rseg_mutex_key);
+ LATCH_ADD_MUTEX(NOREDO_RSEG, SYNC_NOREDO_RSEG, noredo_rseg_mutex_key);
#ifdef UNIV_DEBUG
/* Mutex names starting with '.' are not tracked. They are assumed
to be diagnostic mutexes used in debugging. */
latch_meta[LATCH_ID_RW_LOCK_DEBUG] =
- LATCH_ADD(RW_LOCK_DEBUG,
+ LATCH_ADD_MUTEX(RW_LOCK_DEBUG,
SYNC_NO_ORDER_CHECK,
rw_lock_debug_mutex_key);
#endif /* UNIV_DEBUG */
- LATCH_ADD(RTR_SSN_MUTEX, SYNC_ANY_LATCH, rtr_ssn_mutex_key);
+ LATCH_ADD_MUTEX(RTR_SSN_MUTEX, SYNC_ANY_LATCH, rtr_ssn_mutex_key);
- LATCH_ADD(RTR_ACTIVE_MUTEX, SYNC_ANY_LATCH, rtr_active_mutex_key);
+ LATCH_ADD_MUTEX(RTR_ACTIVE_MUTEX, SYNC_ANY_LATCH,
+ rtr_active_mutex_key);
- LATCH_ADD(RTR_MATCH_MUTEX, SYNC_ANY_LATCH, rtr_match_mutex_key);
+ LATCH_ADD_MUTEX(RTR_MATCH_MUTEX, SYNC_ANY_LATCH, rtr_match_mutex_key);
- LATCH_ADD(RTR_PATH_MUTEX, SYNC_ANY_LATCH, rtr_path_mutex_key);
+ LATCH_ADD_MUTEX(RTR_PATH_MUTEX, SYNC_ANY_LATCH, rtr_path_mutex_key);
- LATCH_ADD(RW_LOCK_LIST, SYNC_NO_ORDER_CHECK, rw_lock_list_mutex_key);
+ LATCH_ADD_MUTEX(RW_LOCK_LIST, SYNC_NO_ORDER_CHECK,
+ rw_lock_list_mutex_key);
- LATCH_ADD(RW_LOCK_MUTEX, SYNC_NO_ORDER_CHECK, rw_lock_mutex_key);
+ LATCH_ADD_MUTEX(RW_LOCK_MUTEX, SYNC_NO_ORDER_CHECK, rw_lock_mutex_key);
- LATCH_ADD(SRV_DICT_TMPFILE, SYNC_DICT_OPERATION,
- srv_dict_tmpfile_mutex_key);
+ LATCH_ADD_MUTEX(SRV_DICT_TMPFILE, SYNC_DICT_OPERATION,
+ srv_dict_tmpfile_mutex_key);
- LATCH_ADD(SRV_INNODB_MONITOR, SYNC_NO_ORDER_CHECK,
- srv_innodb_monitor_mutex_key);
+ LATCH_ADD_MUTEX(SRV_INNODB_MONITOR, SYNC_NO_ORDER_CHECK,
+ srv_innodb_monitor_mutex_key);
- LATCH_ADD(SRV_MISC_TMPFILE, SYNC_ANY_LATCH,
- srv_misc_tmpfile_mutex_key);
+ LATCH_ADD_MUTEX(SRV_MISC_TMPFILE, SYNC_ANY_LATCH,
+ srv_misc_tmpfile_mutex_key);
- LATCH_ADD(SRV_MONITOR_FILE, SYNC_NO_ORDER_CHECK,
- srv_monitor_file_mutex_key);
+ LATCH_ADD_MUTEX(SRV_MONITOR_FILE, SYNC_NO_ORDER_CHECK,
+ srv_monitor_file_mutex_key);
#ifdef UNIV_DEBUG
- LATCH_ADD(SYNC_THREAD, SYNC_NO_ORDER_CHECK, sync_thread_mutex_key);
+ LATCH_ADD_MUTEX(SYNC_THREAD, SYNC_NO_ORDER_CHECK,
+ sync_thread_mutex_key);
#endif /* UNIV_DEBUG */
- LATCH_ADD(BUF_DBLWR, SYNC_DOUBLEWRITE, buf_dblwr_mutex_key);
+ LATCH_ADD_MUTEX(BUF_DBLWR, SYNC_DOUBLEWRITE, buf_dblwr_mutex_key);
- LATCH_ADD(TRX_UNDO, SYNC_TRX_UNDO, trx_undo_mutex_key);
+ LATCH_ADD_MUTEX(TRX_UNDO, SYNC_TRX_UNDO, trx_undo_mutex_key);
- LATCH_ADD(TRX_POOL, SYNC_POOL, trx_pool_mutex_key);
+ LATCH_ADD_MUTEX(TRX_POOL, SYNC_POOL, trx_pool_mutex_key);
- LATCH_ADD(TRX_POOL_MANAGER, SYNC_POOL_MANAGER,
- trx_pool_manager_mutex_key);
+ LATCH_ADD_MUTEX(TRX_POOL_MANAGER, SYNC_POOL_MANAGER,
+ trx_pool_manager_mutex_key);
- LATCH_ADD(TRX, SYNC_TRX, trx_mutex_key);
+ LATCH_ADD_MUTEX(TRX, SYNC_TRX, trx_mutex_key);
- LATCH_ADD(LOCK_SYS, SYNC_LOCK_SYS, lock_mutex_key);
+ LATCH_ADD_MUTEX(LOCK_SYS, SYNC_LOCK_SYS, lock_mutex_key);
- LATCH_ADD(LOCK_SYS_WAIT, SYNC_LOCK_WAIT_SYS, lock_wait_mutex_key);
+ LATCH_ADD_MUTEX(LOCK_SYS_WAIT, SYNC_LOCK_WAIT_SYS,
+ lock_wait_mutex_key);
- LATCH_ADD(TRX_SYS, SYNC_TRX_SYS, trx_sys_mutex_key);
+ LATCH_ADD_MUTEX(TRX_SYS, SYNC_TRX_SYS, trx_sys_mutex_key);
- LATCH_ADD(SRV_SYS, SYNC_THREADS, srv_sys_mutex_key);
+ LATCH_ADD_MUTEX(SRV_SYS, SYNC_THREADS, srv_sys_mutex_key);
- LATCH_ADD(SRV_SYS_TASKS, SYNC_ANY_LATCH, srv_threads_mutex_key);
+ LATCH_ADD_MUTEX(SRV_SYS_TASKS, SYNC_ANY_LATCH, srv_threads_mutex_key);
- LATCH_ADD(PAGE_ZIP_STAT_PER_INDEX, SYNC_ANY_LATCH,
- page_zip_stat_per_index_mutex_key);
+ LATCH_ADD_MUTEX(PAGE_ZIP_STAT_PER_INDEX, SYNC_ANY_LATCH,
+ page_zip_stat_per_index_mutex_key);
#ifndef PFS_SKIP_EVENT_MUTEX
- LATCH_ADD(EVENT_MANAGER, SYNC_NO_ORDER_CHECK, event_manager_mutex_key);
+ LATCH_ADD_MUTEX(EVENT_MANAGER, SYNC_NO_ORDER_CHECK,
+ event_manager_mutex_key);
#else
- LATCH_ADD(EVENT_MANAGER, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(EVENT_MANAGER, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
#endif /* !PFS_SKIP_EVENT_MUTEX */
- LATCH_ADD(EVENT_MUTEX, SYNC_NO_ORDER_CHECK, event_mutex_key);
+ LATCH_ADD_MUTEX(EVENT_MUTEX, SYNC_NO_ORDER_CHECK, event_mutex_key);
- LATCH_ADD(SYNC_ARRAY_MUTEX, SYNC_NO_ORDER_CHECK,
- sync_array_mutex_key);
+ LATCH_ADD_MUTEX(SYNC_ARRAY_MUTEX, SYNC_NO_ORDER_CHECK,
+ sync_array_mutex_key);
- LATCH_ADD(THREAD_MUTEX, SYNC_NO_ORDER_CHECK, thread_mutex_key);
+ LATCH_ADD_MUTEX(THREAD_MUTEX, SYNC_NO_ORDER_CHECK, thread_mutex_key);
- LATCH_ADD(ZIP_PAD_MUTEX, SYNC_NO_ORDER_CHECK, zip_pad_mutex_key);
+ LATCH_ADD_MUTEX(ZIP_PAD_MUTEX, SYNC_NO_ORDER_CHECK, zip_pad_mutex_key);
- LATCH_ADD(OS_AIO_READ_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(OS_AIO_READ_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
- LATCH_ADD(OS_AIO_WRITE_MUTEX, SYNC_NO_ORDER_CHECK,
- PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(OS_AIO_WRITE_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
- LATCH_ADD(OS_AIO_LOG_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(OS_AIO_LOG_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
- LATCH_ADD(OS_AIO_IBUF_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(OS_AIO_IBUF_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
- LATCH_ADD(OS_AIO_SYNC_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(OS_AIO_SYNC_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
- LATCH_ADD(ROW_DROP_LIST, SYNC_NO_ORDER_CHECK, row_drop_list_mutex_key);
+ LATCH_ADD_MUTEX(ROW_DROP_LIST, SYNC_NO_ORDER_CHECK,
+ row_drop_list_mutex_key);
- LATCH_ADD(INDEX_ONLINE_LOG, SYNC_INDEX_ONLINE_LOG,
- index_online_log_key);
+ LATCH_ADD_MUTEX(INDEX_ONLINE_LOG, SYNC_INDEX_ONLINE_LOG,
+ index_online_log_key);
- LATCH_ADD(WORK_QUEUE, SYNC_WORK_QUEUE, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(WORK_QUEUE, SYNC_WORK_QUEUE, PFS_NOT_INSTRUMENTED);
// Add the RW locks
- LATCH_ADD(BTR_SEARCH, SYNC_SEARCH_SYS, btr_search_latch_key);
+ LATCH_ADD_RWLOCK(BTR_SEARCH, SYNC_SEARCH_SYS, btr_search_latch_key);
- LATCH_ADD(BUF_BLOCK_LOCK, SYNC_LEVEL_VARYING, buf_block_lock_key);
+ LATCH_ADD_RWLOCK(BUF_BLOCK_LOCK, SYNC_LEVEL_VARYING,
+ buf_block_lock_key);
#ifdef UNIV_DEBUG
- LATCH_ADD(BUF_BLOCK_DEBUG, SYNC_NO_ORDER_CHECK,
- buf_block_debug_latch_key);
+ LATCH_ADD_RWLOCK(BUF_BLOCK_DEBUG, SYNC_NO_ORDER_CHECK,
+ buf_block_debug_latch_key);
#endif /* UNIV_DEBUG */
- LATCH_ADD(DICT_OPERATION, SYNC_DICT, dict_operation_lock_key);
+ LATCH_ADD_RWLOCK(DICT_OPERATION, SYNC_DICT, dict_operation_lock_key);
- LATCH_ADD(CHECKPOINT, SYNC_NO_ORDER_CHECK, checkpoint_lock_key);
+ LATCH_ADD_RWLOCK(CHECKPOINT, SYNC_NO_ORDER_CHECK, checkpoint_lock_key);
- LATCH_ADD(FIL_SPACE, SYNC_FSP, fil_space_latch_key);
+ LATCH_ADD_RWLOCK(FIL_SPACE, SYNC_FSP, fil_space_latch_key);
- LATCH_ADD(FTS_CACHE, SYNC_FTS_CACHE, fts_cache_rw_lock_key);
+ LATCH_ADD_RWLOCK(FTS_CACHE, SYNC_FTS_CACHE, fts_cache_rw_lock_key);
- LATCH_ADD(FTS_CACHE_INIT, SYNC_FTS_CACHE_INIT,
- fts_cache_init_rw_lock_key);
+ LATCH_ADD_RWLOCK(FTS_CACHE_INIT, SYNC_FTS_CACHE_INIT,
+ fts_cache_init_rw_lock_key);
- LATCH_ADD(TRX_I_S_CACHE, SYNC_TRX_I_S_RWLOCK, trx_i_s_cache_lock_key);
+ LATCH_ADD_RWLOCK(TRX_I_S_CACHE, SYNC_TRX_I_S_RWLOCK,
+ trx_i_s_cache_lock_key);
- LATCH_ADD(TRX_PURGE, SYNC_PURGE_LATCH, trx_purge_latch_key);
+ LATCH_ADD_RWLOCK(TRX_PURGE, SYNC_PURGE_LATCH, trx_purge_latch_key);
- LATCH_ADD(IBUF_INDEX_TREE, SYNC_IBUF_INDEX_TREE,
- index_tree_rw_lock_key);
+ LATCH_ADD_RWLOCK(IBUF_INDEX_TREE, SYNC_IBUF_INDEX_TREE,
+ index_tree_rw_lock_key);
- LATCH_ADD(INDEX_TREE, SYNC_INDEX_TREE, index_tree_rw_lock_key);
+ LATCH_ADD_RWLOCK(INDEX_TREE, SYNC_INDEX_TREE, index_tree_rw_lock_key);
- LATCH_ADD(DICT_TABLE_STATS, SYNC_INDEX_TREE, dict_table_stats_key);
+ LATCH_ADD_RWLOCK(DICT_TABLE_STATS, SYNC_INDEX_TREE,
+ dict_table_stats_key);
- LATCH_ADD(HASH_TABLE_RW_LOCK, SYNC_BUF_PAGE_HASH,
+ LATCH_ADD_RWLOCK(HASH_TABLE_RW_LOCK, SYNC_BUF_PAGE_HASH,
hash_table_locks_key);
- LATCH_ADD(SYNC_DEBUG_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(SYNC_DEBUG_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
/* JAN: TODO: Add PFS instrumentation */
- LATCH_ADD(SCRUB_STAT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(DEFRAGMENT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(BTR_DEFRAGMENT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(MTFLUSH_THREAD_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(MTFLUSH_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(FIL_CRYPT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(FIL_CRYPT_STAT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(FIL_CRYPT_DATA_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
- LATCH_ADD(FIL_CRYPT_THREADS_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(SCRUB_STAT_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(DEFRAGMENT_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(BTR_DEFRAGMENT_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(MTFLUSH_THREAD_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(MTFLUSH_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(FIL_CRYPT_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(FIL_CRYPT_STAT_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(FIL_CRYPT_DATA_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
+ LATCH_ADD_MUTEX(FIL_CRYPT_THREADS_MUTEX, SYNC_NO_ORDER_CHECK,
+ PFS_NOT_INSTRUMENTED);
latch_id_t id = LATCH_ID_NONE;
@@ -1717,7 +1747,7 @@ private:
const void*,
File,
std::less<const void*>,
- ut_allocator<std::pair<const void*, File> > >
+ ut_allocator<std::pair<const void* const, File> > >
Files;
typedef OSMutex Mutex;
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index f83d9377852..b21ec75c3a6 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -291,7 +291,6 @@ trx_purge_add_update_undo_to_history(
undo_header + TRX_UNDO_HISTORY_NODE, mtr);
my_atomic_addlint(&trx_sys->rseg_history_len, 1);
- srv_wake_purge_thread_if_not_active();
/* Write the trx number to the undo log header */
mlog_write_ull(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
@@ -987,27 +986,20 @@ trx_purge_initiate_truncate(
initiate truncate.
d. Execute actual truncate
e. Remove the DDL log. */
- DBUG_EXECUTE_IF("ib_undo_trunc_before_checkpoint",
- ib::info() << "ib_undo_trunc_before_checkpoint";
- DBUG_SUICIDE(););
/* After truncate if server crashes then redo logging done for this
undo tablespace might not stand valid as tablespace has been
truncated. */
log_make_checkpoint_at(LSN_MAX, TRUE);
- ib::info() << "Truncating UNDO tablespace with space identifier "
- << undo_trunc->get_marked_space_id();
+ const ulint space_id = undo_trunc->get_marked_space_id();
- DBUG_EXECUTE_IF("ib_undo_trunc_before_ddl_log_start",
- ib::info() << "ib_undo_trunc_before_ddl_log_start";
- DBUG_SUICIDE(););
+ ib::info() << "Truncating UNDO tablespace " << space_id;
#ifdef UNIV_DEBUG
dberr_t err =
#endif /* UNIV_DEBUG */
- undo_trunc->start_logging(
- undo_trunc->get_marked_space_id());
+ undo_trunc->start_logging(space_id);
ut_ad(err == DB_SUCCESS);
DBUG_EXECUTE_IF("ib_undo_trunc_before_truncate",
@@ -1016,14 +1008,12 @@ trx_purge_initiate_truncate(
trx_purge_cleanse_purge_queue(undo_trunc);
- bool success = trx_undo_truncate_tablespace(undo_trunc);
- if (!success) {
+ if (!trx_undo_truncate_tablespace(undo_trunc)) {
/* Note: In case of error we don't enable the rsegs
and neither unmark the tablespace so the tablespace
continue to remain inactive. */
- ib::error() << "Failed to truncate UNDO tablespace with"
- " space identifier "
- << undo_trunc->get_marked_space_id();
+ ib::error() << "Failed to truncate UNDO tablespace "
+ << space_id;
return;
}
@@ -1046,7 +1036,7 @@ trx_purge_initiate_truncate(
log_make_checkpoint_at(LSN_MAX, TRUE);
- undo_trunc->done_logging(undo_trunc->get_marked_space_id());
+ undo_trunc->done_logging(space_id);
/* Completed truncate. Now it is safe to re-use the tablespace. */
for (ulint i = 0; i < undo_trunc->rsegs_size(); ++i) {
@@ -1054,8 +1044,7 @@ trx_purge_initiate_truncate(
rseg->skip_allocation = false;
}
- ib::info() << "Completed truncate of UNDO tablespace with space"
- " identifier " << undo_trunc->get_marked_space_id();
+ ib::info() << "Truncated UNDO tablespace " << space_id;
undo_trunc->reset();
undo::Truncate::clear_trunc_list();
@@ -1075,7 +1064,7 @@ trx_purge_truncate_history(
purge_iter_t* limit, /*!< in: truncate limit */
const ReadView* view) /*!< in: purge view */
{
- ulint i;
+ ut_ad(trx_purge_check_limit());
/* We play safe and set the truncate limit at most to the purge view
low_limit number, though this is not necessary */
@@ -1088,7 +1077,7 @@ trx_purge_truncate_history(
ut_ad(limit->trx_no <= purge_sys->view.low_limit_no());
- for (i = 0; i < TRX_SYS_N_RSEGS; ++i) {
+ for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) {
trx_rseg_t* rseg = trx_sys->rseg_array[i];
if (rseg != NULL) {
@@ -1100,8 +1089,7 @@ trx_purge_truncate_history(
/* UNDO tablespace truncate. We will try to truncate as much as we
can (greedy approach). This will ensure when the server is idle we
try and truncate all the UNDO tablespaces. */
- ulint nchances = srv_undo_tablespaces_active;
- for (i = 0; i < nchances; i++) {
+ for (ulint i = srv_undo_tablespaces_active; i--; ) {
trx_purge_mark_undo_for_truncate(&purge_sys->undo_trunc);
trx_purge_initiate_truncate(limit, &purge_sys->undo_trunc);
}
@@ -1638,22 +1626,6 @@ trx_purge_wait_for_workers_to_complete(
ut_a(srv_get_task_queue_length() == 0);
}
-/******************************************************************//**
-Remove old historical changes from the rollback segments. */
-static
-void
-trx_purge_truncate(void)
-/*====================*/
-{
- ut_ad(trx_purge_check_limit());
-
- if (purge_sys->limit.trx_no == 0) {
- trx_purge_truncate_history(&purge_sys->iter, &purge_sys->view);
- } else {
- trx_purge_truncate_history(&purge_sys->limit, &purge_sys->view);
- }
-}
-
/*******************************************************************//**
This function runs a purge batch.
@return number of undo log pages handled in the batch */
@@ -1742,7 +1714,11 @@ run_synchronously:
#endif /* UNIV_DEBUG */
if (truncate) {
- trx_purge_truncate();
+ trx_purge_truncate_history(
+ purge_sys->limit.trx_no
+ ? &purge_sys->limit
+ : &purge_sys->iter,
+ &purge_sys->view);
}
MONITOR_INC_VALUE(MONITOR_PURGE_INVOKED, 1);
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index ec723375fe9..69f01e64b59 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -868,6 +868,8 @@ DECLARE_THREAD(trx_rollback_or_clean_all_recovered)(
/*!< in: a dummy parameter required by
os_thread_create */
{
+ my_thread_init();
+
ut_ad(!srv_read_only_mode);
#ifdef UNIV_PFS_THREAD
@@ -878,6 +880,7 @@ DECLARE_THREAD(trx_rollback_or_clean_all_recovered)(
trx_rollback_or_clean_is_active = false;
+ my_thread_end();
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */
diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc
index 3393a0464a8..663566cf26f 100644
--- a/storage/innobase/trx/trx0rseg.cc
+++ b/storage/innobase/trx/trx0rseg.cc
@@ -204,7 +204,7 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, mtr_t* mtr)
len = flst_get_len(rseg_header + TRX_RSEG_HISTORY);
if (len > 0) {
- trx_sys->rseg_history_len += len;
+ my_atomic_addlint(&trx_sys->rseg_history_len, len);
node_addr = trx_purge_get_log_from_hist(
flst_get_last(rseg_header + TRX_RSEG_HISTORY, mtr));
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index 19d4a228eda..47f30138ceb 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -446,7 +446,6 @@ trx_sysf_create(
page_t* page;
ulint page_no;
byte* ptr;
- ulint len;
ut_ad(mtr);
@@ -481,13 +480,12 @@ trx_sysf_create(
mach_write_to_8(sys_header + TRX_SYS_TRX_ID_STORE, 1);
/* Reset the rollback segment slots. Old versions of InnoDB
- define TRX_SYS_N_RSEGS as 256 (TRX_SYS_OLD_N_RSEGS) and expect
+ (before MySQL 5.5) define TRX_SYS_N_RSEGS as 256 and expect
that the whole array is initialized. */
ptr = TRX_SYS_RSEGS + sys_header;
- len = ut_max(TRX_SYS_OLD_N_RSEGS, TRX_SYS_N_RSEGS)
- * TRX_SYS_RSEG_SLOT_SIZE;
- memset(ptr, 0xff, len);
- ptr += len;
+ compile_time_assert(256 >= TRX_SYS_N_RSEGS);
+ memset(ptr, 0xff, 256 * TRX_SYS_RSEG_SLOT_SIZE);
+ ptr += 256 * TRX_SYS_RSEG_SLOT_SIZE;
ut_a(ptr <= page + (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END));
/* Initialize all of the page. This part used to be uninitialized. */
@@ -881,7 +879,7 @@ trx_sys_create_rsegs()
srv_undo_logs determines how many of the
srv_available_undo_logs rollback segments may be used for
logging new transactions. */
- ut_ad(srv_undo_tablespaces < TRX_SYS_N_RSEGS);
+ ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES);
ut_ad(srv_undo_logs <= TRX_SYS_N_RSEGS);
if (srv_read_only_mode) {
@@ -923,13 +921,28 @@ trx_sys_create_rsegs()
" requested innodb_undo_logs";
return(false);
}
+
+ /* Increase the number of active undo
+ tablespace in case new rollback segment
+ assigned to new undo tablespace. */
+ if (space > srv_undo_tablespaces_active) {
+ srv_undo_tablespaces_active++;
+
+ ut_ad(srv_undo_tablespaces_active == space);
+ }
}
}
ut_ad(srv_undo_logs <= srv_available_undo_logs);
- ib::info() << srv_undo_logs << " out of " << srv_available_undo_logs
- << " rollback segments are active.";
+ ib::info info;
+ info << srv_undo_logs << " out of " << srv_available_undo_logs;
+ if (srv_undo_tablespaces_active) {
+ info << " rollback segments in " << srv_undo_tablespaces_active
+ << " undo tablespaces are active.";
+ } else {
+ info << " rollback segments are active.";
+ }
return(true);
}
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 36324c43970..a6cfcf0910b 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1908,6 +1908,7 @@ trx_commit_in_memory(
trx_mutex_exit(trx);
ut_a(trx->error_state == DB_SUCCESS);
+ srv_wake_purge_thread_if_not_active();
}
/****************************************************************//**
@@ -2455,6 +2456,121 @@ trx_print_latched(
mem_heap_get_size(trx->lock.lock_heap));
}
+#ifdef WITH_WSREP
+/**********************************************************************//**
+Prints info about a transaction.
+Transaction information may be retrieved without having trx_sys->mutex acquired
+so it may not be completely accurate. The caller must own lock_sys->mutex
+and the trx must have some locks to make sure that it does not escape
+without locking lock_sys->mutex. */
+UNIV_INTERN
+void
+wsrep_trx_print_locking(
+ FILE* f,
+ /*!< in: output stream */
+ const trx_t* trx,
+ /*!< in: transaction */
+ ulint max_query_len)
+ /*!< in: max query length to print,
+ or 0 to use the default max length */
+{
+ ibool newline;
+ const char* op_info;
+
+ ut_ad(lock_mutex_own());
+ ut_ad(trx->lock.trx_locks.count > 0);
+
+ fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id);
+
+ /* trx->state may change since trx_sys->mutex is not required */
+ switch (trx->state) {
+ case TRX_STATE_NOT_STARTED:
+ fputs(", not started", f);
+ goto state_ok;
+ case TRX_STATE_ACTIVE:
+ fprintf(f, ", ACTIVE %lu sec",
+ (ulong) difftime(time(NULL), trx->start_time));
+ goto state_ok;
+ case TRX_STATE_FORCED_ROLLBACK:
+ fprintf(f, ", FORCED ROLLBACK, %lu sec",
+ (ulong) difftime(time(NULL), trx->start_time));
+ goto state_ok;
+ case TRX_STATE_PREPARED:
+ fprintf(f, ", ACTIVE (PREPARED) %lu sec",
+ (ulong) difftime(time(NULL), trx->start_time));
+ goto state_ok;
+ case TRX_STATE_COMMITTED_IN_MEMORY:
+ fputs(", COMMITTED IN MEMORY", f);
+ goto state_ok;
+ }
+ fprintf(f, ", state %lu", (ulong) trx->state);
+ ut_ad(0);
+state_ok:
+
+ /* prevent a race condition */
+ op_info = trx->op_info;
+
+ if (*op_info) {
+ putc(' ', f);
+ fputs(op_info, f);
+ }
+
+ if (trx->is_recovered) {
+ fputs(" recovered trx", f);
+ }
+
+ if (trx->declared_to_be_inside_innodb) {
+ fprintf(f, ", thread declared inside InnoDB %lu",
+ (ulong) trx->n_tickets_to_enter_innodb);
+ }
+
+ putc('\n', f);
+
+ if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) {
+ fprintf(f, "mysql tables in use %lu, locked %lu\n",
+ (ulong) trx->n_mysql_tables_in_use,
+ (ulong) trx->mysql_n_tables_locked);
+ }
+
+ newline = TRUE;
+
+ /* trx->lock.que_state of an ACTIVE transaction may change
+ while we are not holding trx->mutex. We perform a dirty read
+ for performance reasons. */
+
+ switch (trx->lock.que_state) {
+ case TRX_QUE_RUNNING:
+ newline = FALSE; break;
+ case TRX_QUE_LOCK_WAIT:
+ fputs("LOCK WAIT ", f); break;
+ case TRX_QUE_ROLLING_BACK:
+ fputs("ROLLING BACK ", f); break;
+ case TRX_QUE_COMMITTING:
+ fputs("COMMITTING ", f); break;
+ default:
+ fprintf(f, "que state %lu ", (ulong) trx->lock.que_state);
+ }
+
+ if (trx->has_search_latch) {
+ newline = TRUE;
+ fputs(", holds adaptive hash latch", f);
+ }
+
+ if (trx->undo_no != 0) {
+ newline = TRUE;
+ fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no);
+ }
+
+ if (newline) {
+ putc('\n', f);
+ }
+
+ if (trx->mysql_thd != NULL) {
+ innobase_mysql_print_thd(
+ f, trx->mysql_thd, static_cast<uint>(max_query_len));
+ }
+}
+#endif /* WITH_WSREP */
/**********************************************************************//**
Prints info about a transaction.
Acquires and releases lock_sys->mutex and trx_sys->mutex. */
diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt
index 3223e084709..d72b4e54e43 100644
--- a/storage/rocksdb/CMakeLists.txt
+++ b/storage/rocksdb/CMakeLists.txt
@@ -22,6 +22,13 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i[36]86")
SKIP_ROCKSDB_PLUGIN("Intel 32 bit not supported.")
ENDIF()
+# Due to retrieved data being incorrect endian
+include(TestBigEndian)
+test_big_endian(BIG_ENDIAN)
+if(BIG_ENDIAN)
+ SKIP_ROCKSDB_PLUGIN("Big Endian not supported.")
+endif()
+
#
# Also, disable building on 32-bit Windows
#
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index a87abfb8073..7ed8661cc74 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -2109,6 +2109,7 @@ int ha_spider::index_read_map_internal(
result_list.desc_flg = FALSE;
result_list.sorted = TRUE;
result_list.key_info = &table->key_info[active_index];
+ check_distinct_key_query();
result_list.limit_num =
result_list.internal_limit >= result_list.split_read ?
result_list.split_read : result_list.internal_limit;
@@ -2624,6 +2625,7 @@ int ha_spider::index_read_last_map_internal(
result_list.desc_flg = TRUE;
result_list.sorted = TRUE;
result_list.key_info = &table->key_info[active_index];
+ check_distinct_key_query();
result_list.limit_num =
result_list.internal_limit >= result_list.split_read ?
result_list.split_read : result_list.internal_limit;
@@ -3089,6 +3091,7 @@ int ha_spider::index_first_internal(
result_list.sorted = TRUE;
result_list.key_info = &table->key_info[active_index];
result_list.key_order = 0;
+ check_distinct_key_query();
result_list.limit_num =
result_list.internal_limit >= result_list.split_read ?
result_list.split_read : result_list.internal_limit;
@@ -3472,6 +3475,7 @@ int ha_spider::index_last_internal(
result_list.sorted = TRUE;
result_list.key_info = &table->key_info[active_index];
result_list.key_order = 0;
+ check_distinct_key_query();
result_list.limit_num =
result_list.internal_limit >= result_list.split_read ?
result_list.split_read : result_list.internal_limit;
@@ -3914,6 +3918,7 @@ int ha_spider::read_range_first_internal(
result_list.desc_flg = FALSE;
result_list.sorted = sorted;
result_list.key_info = &table->key_info[active_index];
+ check_distinct_key_query();
result_list.limit_num =
result_list.internal_limit >= result_list.split_read ?
result_list.split_read : result_list.internal_limit;
@@ -12078,6 +12083,81 @@ void ha_spider::check_direct_order_limit()
DBUG_VOID_RETURN;
}
+/********************************************************************
+ * Check whether the current query is a SELECT DISTINCT using an
+ * index in a non-partitioned Spider configuration, with a
+ * projection list that consists solely of the first key prefix
+ * column.
+ *
+ * For a SELECT DISTINCT query using an index in a non-partitioned
+ * Spider configuration, with a projection list that consists
+ * solely of the first key prefix, set the internal row retrieval
+ * limit to avoid visiting each row multiple times.
+ ********************************************************************/
+void ha_spider::check_distinct_key_query()
+{
+ DBUG_ENTER( "ha_spider::check_distinct_key_query" );
+
+ if ( result_list.direct_distinct && !partition_handler_share->handlers &&
+ result_list.keyread && result_list.check_direct_order_limit )
+ {
+ // SELECT DISTINCT query using an index in a non-partitioned configuration
+ KEY_PART_INFO* key_part = result_list.key_info->key_part;
+ Field* key_field = key_part->field;
+
+ if ( is_sole_projection_field( key_field->field_index ) )
+ {
+ // Projection list consists solely of the first key prefix column
+
+ // Set the internal row retrieval limit to avoid visiting each row
+ // multiple times. This fixes a Spider performance bug that
+ // caused each row to be visited multiple times.
+ result_list.internal_limit = 1;
+ }
+ }
+
+ DBUG_VOID_RETURN;
+}
+
+/********************************************************************
+ * Determine whether the current query's projection list
+ * consists solely of the specified column.
+ *
+ * Params IN - field_index:
+ * Field index of the column of interest within
+ * its table.
+ *
+ * Returns TRUE - if the query's projection list consists
+ * solely of the specified column.
+ * FALSE - otherwise.
+ ********************************************************************/
+bool ha_spider::is_sole_projection_field( uint16 field_index )
+{
+ // NOTE: It is assumed that spider_db_append_select_columns() has already been called
+ // to build the bitmap of projection fields
+ bool is_ha_sole_projection_field;
+ uint loop_index, dbton_id;
+ spider_db_handler* dbton_hdl;
+ DBUG_ENTER( "ha_spider::is_sole_projection_field" );
+
+ for ( loop_index = 0; loop_index < share->use_sql_dbton_count; loop_index++ )
+ {
+ dbton_id = share->use_sql_dbton_ids[ loop_index ];
+ dbton_hdl = dbton_handler[ dbton_id ];
+
+ if ( dbton_hdl->first_link_idx >= 0 )
+ {
+ is_ha_sole_projection_field = dbton_hdl->is_sole_projection_field( field_index );
+ if ( !is_ha_sole_projection_field )
+ {
+ DBUG_RETURN( FALSE );
+ }
+ }
+ }
+
+ DBUG_RETURN( TRUE );
+}
+
int ha_spider::check_ha_range_eof()
{
DBUG_ENTER("ha_spider::check_ha_range_eof");
diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h
index bd02e34043d..87c6afaa89f 100644
--- a/storage/spider/ha_spider.h
+++ b/storage/spider/ha_spider.h
@@ -751,6 +751,8 @@ public:
);
uint check_partitioned();
void check_direct_order_limit();
+ void check_distinct_key_query();
+ bool is_sole_projection_field( uint16 field_index );
int check_ha_range_eof();
int drop_tmp_tables();
bool handler_opened(
diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc
index 8f031acdbde..51b1d1f1752 100644
--- a/storage/spider/spd_db_handlersocket.cc
+++ b/storage/spider/spd_db_handlersocket.cc
@@ -4994,6 +4994,15 @@ int spider_handlersocket_handler::append_explain_select_part(
DBUG_RETURN(0);
}
+int spider_handlersocket_handler::is_sole_projection_field(
+ uint16 field_index
+) {
+ DBUG_ENTER("spider_handlersocket_handler::is_sole_projection_field");
+ DBUG_PRINT("info", ("spider this=%p", this));
+ DBUG_ASSERT(0);
+ DBUG_RETURN(0);
+}
+
bool spider_handlersocket_handler::is_bulk_insert_exec_period(
bool bulk_end
) {
diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h
index d3fdf5564b7..a3955aea044 100644
--- a/storage/spider/spd_db_handlersocket.h
+++ b/storage/spider/spd_db_handlersocket.h
@@ -776,6 +776,9 @@ public:
ulong sql_type,
int link_idx
);
+ bool is_sole_projection_field(
+ uint16 field_index
+ );
bool is_bulk_insert_exec_period(
bool bulk_end
);
diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h
index 936951d3860..56bc2ccad42 100644
--- a/storage/spider/spd_db_include.h
+++ b/storage/spider/spd_db_include.h
@@ -1279,6 +1279,9 @@ public:
ulong sql_type,
int link_idx
) = 0;
+ virtual bool is_sole_projection_field(
+ uint16 field_index
+ ) = 0;
virtual bool is_bulk_insert_exec_period(
bool bulk_end
) = 0;
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index f902508e9c4..385b122c274 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -9516,6 +9516,65 @@ int spider_mysql_handler::append_explain_select(
DBUG_RETURN(0);
}
+/********************************************************************
+ * Determine whether the current query's projection list
+ * consists solely of the specified column.
+ *
+ * Params IN - field_index:
+ * Field index of the column of interest within
+ * its table.
+ *
+ * Returns TRUE - if the query's projection list consists
+ * solely of the specified column.
+ * FALSE - otherwise.
+ ********************************************************************/
+bool spider_mysql_handler::is_sole_projection_field( uint16 field_index )
+{
+ // Determine whether the projection list consists solely of the field of interest
+ bool is_field_in_projection_list = FALSE;
+ TABLE* table = spider->get_table();
+ uint16 projection_field_count = 0;
+ uint16 projection_field_index;
+ Field** field;
+ DBUG_ENTER( "spider_mysql_handler::is_sole_projection_field" );
+
+ for ( field = table->field; *field ; field++ )
+ {
+ projection_field_index = ( *field )->field_index;
+
+ if ( !( minimum_select_bit_is_set( projection_field_index ) ) )
+ {
+ // Current field is not in the projection list
+ continue;
+ }
+
+ projection_field_count++;
+
+ if ( !is_field_in_projection_list )
+ {
+ if ( field_index == projection_field_index )
+ {
+ // Field of interest is in the projection list
+ is_field_in_projection_list = TRUE;
+ }
+ }
+
+ if ( is_field_in_projection_list && ( projection_field_count != 1 ) )
+ {
+ // Field of interest is not the sole column in the projection list
+ DBUG_RETURN( FALSE );
+ }
+ }
+
+ if ( is_field_in_projection_list && ( projection_field_count == 1 ) )
+ {
+ // Field of interest is the only column in the projection list
+ DBUG_RETURN( TRUE );
+ }
+
+ DBUG_RETURN( FALSE );
+}
+
bool spider_mysql_handler::is_bulk_insert_exec_period(
bool bulk_end
) {
diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h
index 9a4f08ade98..482289d1d68 100644
--- a/storage/spider/spd_db_mysql.h
+++ b/storage/spider/spd_db_mysql.h
@@ -1128,6 +1128,9 @@ public:
ulong sql_type,
int link_idx
);
+ bool is_sole_projection_field(
+ uint16 field_index
+ );
bool is_bulk_insert_exec_period(
bool bulk_end
);
diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc
index 5e6c89b10d0..5b322b9c4d7 100644
--- a/storage/spider/spd_db_oracle.cc
+++ b/storage/spider/spd_db_oracle.cc
@@ -9571,6 +9571,65 @@ int spider_oracle_handler::append_explain_select(
DBUG_RETURN(0);
}
+/********************************************************************
+ * Determine whether the current query's projection list
+ * consists solely of the specified column.
+ *
+ * Params IN - field_index:
+ * Field index of the column of interest within
+ * its table.
+ *
+ * Returns TRUE - if the query's projection list consists
+ * solely of the specified column.
+ * FALSE - otherwise.
+ ********************************************************************/
+bool spider_oracle_handler::is_sole_projection_field( uint16 field_index )
+{
+ // Determine whether the projection list consists solely of the field of interest
+ bool is_field_in_projection_list = FALSE;
+ TABLE* table = spider->get_table();
+ uint16 projection_field_count = 0;
+ uint16 projection_field_index;
+ Field** field;
+ DBUG_ENTER( "spider_oracle_handler::is_sole_projection_field" );
+
+ for ( field = table->field; *field; field++ )
+ {
+ projection_field_index = ( *field )->field_index;
+
+ if ( !( minimum_select_bit_is_set( projection_field_index ) ) )
+ {
+ // Current field is not in the projection list
+ continue;
+ }
+
+ projection_field_count++;
+
+ if ( !is_field_in_projection_list )
+ {
+ if (field_index == projection_field_index)
+ {
+ // Field of interest is in the projection list
+ is_field_in_projection_list = TRUE;
+ }
+ }
+
+ if ( is_field_in_projection_list && ( projection_field_count != 1 ) )
+ {
+ // Field of interest is not the sole column in the projection list
+ DBUG_RETURN( FALSE );
+ }
+ }
+
+ if ( is_field_in_projection_list && ( projection_field_count == 1 ) )
+ {
+ // Field of interest is the only column in the projection list
+ DBUG_RETURN( TRUE );
+ }
+
+ DBUG_RETURN( FALSE );
+}
+
bool spider_oracle_handler::is_bulk_insert_exec_period(
bool bulk_end
) {
diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h
index 0e84435d9be..7a070f498da 100644
--- a/storage/spider/spd_db_oracle.h
+++ b/storage/spider/spd_db_oracle.h
@@ -1208,6 +1208,9 @@ public:
ulong sql_type,
int link_idx
);
+ bool is_sole_projection_field(
+ uint16 field_index
+ );
bool is_bulk_insert_exec_period(
bool bulk_end
);
diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc
index 417eeb2c367..48411b6ff6a 100644
--- a/storage/xtradb/btr/btr0btr.cc
+++ b/storage/xtradb/btr/btr0btr.cc
@@ -3277,7 +3277,7 @@ func_start:
btr_page_create(new_block, new_page_zip, cursor->index,
btr_page_get_level(page, mtr), mtr);
/* Only record the leaf level page splits. */
- if (btr_page_get_level(page, mtr) == 0) {
+ if (page_is_leaf(page)) {
cursor->index->stat_defrag_n_page_split ++;
cursor->index->stat_defrag_modified_counter ++;
btr_defragment_save_defrag_stats_if_needed(cursor->index);
diff --git a/storage/xtradb/btr/btr0defragment.cc b/storage/xtradb/btr/btr0defragment.cc
index 8de85e746ca..3f4185341a6 100644
--- a/storage/xtradb/btr/btr0defragment.cc
+++ b/storage/xtradb/btr/btr0defragment.cc
@@ -233,7 +233,7 @@ btr_defragment_add_index(
return NULL;
}
- if (btr_page_get_level(page, &mtr) == 0) {
+ if (page_is_leaf(page)) {
// Index root is a leaf page, no need to defragment.
mtr_commit(&mtr);
return NULL;
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index 70cd9610b18..78ebbb7902b 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -5931,23 +5931,22 @@ buf_print_io_instance(
pool_info->pages_written_rate);
if (pool_info->n_page_get_delta) {
- double hit_rate = ((1000 * pool_info->page_read_delta)
- / pool_info->n_page_get_delta);
+ double hit_rate = double(pool_info->page_read_delta)
+ / pool_info->n_page_get_delta;
- if (hit_rate > 1000) {
- hit_rate = 1000;
+ if (hit_rate > 1) {
+ hit_rate = 1;
}
- hit_rate = 1000 - hit_rate;
-
fprintf(file,
- "Buffer pool hit rate %lu / 1000,"
- " young-making rate %lu / 1000 not %lu / 1000\n",
- (ulint) hit_rate,
- (ulint) (1000 * pool_info->young_making_delta
- / pool_info->n_page_get_delta),
- (ulint) (1000 * pool_info->not_young_making_delta
- / pool_info->n_page_get_delta));
+ "Buffer pool hit rate " ULINTPF " / 1000,"
+ " young-making rate " ULINTPF " / 1000 not "
+ ULINTPF " / 1000\n",
+ ulint(1000 * (1 - hit_rate)),
+ ulint(1000 * double(pool_info->young_making_delta)
+ / pool_info->n_page_get_delta),
+ ulint(1000 * double(pool_info->not_young_making_delta)
+ / pool_info->n_page_get_delta));
} else {
fputs("No buffer pool page gets since the last printout\n",
file);
@@ -6245,70 +6244,54 @@ buf_pool_reserve_tmp_slot(
return (free_slot);
}
-/********************************************************************//**
-Encrypts a buffer page right before it's flushed to disk
-@param[in,out] bpage Page control block
-@param[in,out] src_frame Source page
-@param[in] space_id Tablespace id
-@return either unencrypted source page or decrypted page.
-*/
+/** Encryption and page_compression hook that is called just before
+a page is written to disk.
+@param[in,out] space tablespace
+@param[in,out] bpage buffer page
+@param[in] src_frame physical page frame that is being encrypted
+@return page frame to be written to file
+(may be src_frame or an encrypted/compressed copy of it) */
+UNIV_INTERN
byte*
buf_page_encrypt_before_write(
+ fil_space_t* space,
buf_page_t* bpage,
- byte* src_frame,
- ulint space_id)
+ byte* src_frame)
{
+ ut_ad(space->id == bpage->space);
bpage->real_size = UNIV_PAGE_SIZE;
fil_page_type_validate(src_frame);
- if (bpage->offset == 0) {
+ switch (bpage->offset) {
+ case 0:
/* Page 0 of a tablespace is not encrypted/compressed */
ut_ad(bpage->key_version == 0);
return src_frame;
- }
-
- if (bpage->space == TRX_SYS_SPACE && bpage->offset == TRX_SYS_PAGE_NO) {
- /* don't encrypt/compress page as it contains address to dblwr buffer */
- bpage->key_version = 0;
- return src_frame;
- }
-
- fil_space_t* space = fil_space_acquire_silent(space_id);
-
- /* Tablespace must exist during write operation */
- if (!space) {
- /* This could be true on discard if we have injected a error
- case e.g. in innodb.innodb-wl5522-debug-zip so that space
- is already marked as stop_new_ops = true. */
- return src_frame;
+ case TRX_SYS_PAGE_NO:
+ if (bpage->space == TRX_SYS_SPACE) {
+ /* don't encrypt/compress page as it contains
+ address to dblwr buffer */
+ bpage->key_version = 0;
+ return src_frame;
+ }
}
fil_space_crypt_t* crypt_data = space->crypt_data;
- bool encrypted = true;
+ const bool encrypted = crypt_data
+ && !crypt_data->not_encrypted()
+ && crypt_data->type != CRYPT_SCHEME_UNENCRYPTED
+ && (!crypt_data->is_default_encryption()
+ || srv_encrypt_tables);
- if (space->crypt_data != NULL && space->crypt_data->not_encrypted()) {
- /* Encryption is disabled */
- encrypted = false;
- }
-
- if (!srv_encrypt_tables && (crypt_data == NULL || crypt_data->is_default_encryption())) {
- /* Encryption is disabled */
- encrypted = false;
- }
-
- /* Is encryption needed? */
- if (crypt_data == NULL || crypt_data->type == CRYPT_SCHEME_UNENCRYPTED) {
- /* An unencrypted table */
+ if (!encrypted) {
bpage->key_version = 0;
- encrypted = false;
}
- bool page_compressed = fil_space_is_page_compressed(bpage->space);
+ bool page_compressed = FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags);
if (!encrypted && !page_compressed) {
/* No need to encrypt or page compress the page */
- fil_space_release(space);
return src_frame;
}
@@ -6336,25 +6319,21 @@ buf_page_encrypt_before_write(
bpage->real_size = page_size;
slot->out_buf = dst_frame = tmp;
-#ifdef UNIV_DEBUG
- fil_page_type_validate(tmp);
-#endif
-
+ ut_d(fil_page_type_validate(tmp));
} else {
/* First we compress the page content */
ulint out_len = 0;
- ulint block_size = fil_space_get_block_size(bpage->space, bpage->offset, page_size);
-
- byte *tmp = fil_compress_page(bpage->space,
- (byte *)src_frame,
- slot->comp_buf,
- page_size,
- fil_space_get_page_compression_level(bpage->space),
- block_size,
- encrypted,
- &out_len,
- IF_LZO(slot->lzo_mem, NULL)
- );
+
+ byte *tmp = fil_compress_page(
+ space,
+ (byte *)src_frame,
+ slot->comp_buf,
+ page_size,
+ fsp_flags_get_page_compression_level(space->flags),
+ fil_space_get_block_size(space, bpage->offset),
+ encrypted,
+ &out_len,
+ IF_LZO(slot->lzo_mem, NULL));
bpage->real_size = out_len;
@@ -6379,7 +6358,6 @@ buf_page_encrypt_before_write(
fil_page_type_validate(dst_frame);
#endif
- fil_space_release(space);
// return dst_frame which will be written
return dst_frame;
}
@@ -6433,9 +6411,9 @@ buf_page_decrypt_after_read(
/* decompress using comp_buf to dst_frame */
fil_decompress_page(slot->comp_buf,
- dst_frame,
- size,
- &bpage->write_size);
+ dst_frame,
+ ulong(size),
+ &bpage->write_size);
/* Mark this slot as free */
slot->reserved = false;
@@ -6487,13 +6465,10 @@ buf_page_decrypt_after_read(
#endif
/* decompress using comp_buf to dst_frame */
fil_decompress_page(slot->comp_buf,
- dst_frame,
- size,
- &bpage->write_size);
-
-#ifdef UNIV_DEBUG
- fil_page_type_validate(dst_frame);
-#endif
+ dst_frame,
+ ulong(size),
+ &bpage->write_size);
+ ut_d(fil_page_type_validate(dst_frame));
}
/* Mark this slot as free */
diff --git a/storage/xtradb/buf/buf0dblwr.cc b/storage/xtradb/buf/buf0dblwr.cc
index b11c32064bf..55c5e4d543a 100644
--- a/storage/xtradb/buf/buf0dblwr.cc
+++ b/storage/xtradb/buf/buf0dblwr.cc
@@ -538,7 +538,7 @@ buf_dblwr_process()
/* Decompress the page before
validating the checksum. */
fil_decompress_page(
- NULL, read_buf, UNIV_PAGE_SIZE,
+ NULL, read_buf, srv_page_size,
NULL, true);
}
@@ -565,7 +565,7 @@ buf_dblwr_process()
/* Decompress the page before
validating the checksum. */
fil_decompress_page(
- NULL, page, UNIV_PAGE_SIZE, NULL, true);
+ NULL, page, srv_page_size, NULL, true);
}
if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, page_no)
@@ -1001,7 +1001,7 @@ flush:
srv_stats.dblwr_writes.inc();
/* Now flush the doublewrite buffer data to disk */
- fil_flush(TRX_SYS_SPACE);
+ fil_flush(ulint(TRX_SYS_SPACE));
/* We know that the writes have been flushed to disk now
and in recovery we will find them in the doublewrite buffer
@@ -1249,7 +1249,7 @@ retry:
}
/* Now flush the doublewrite buffer data to disk */
- fil_flush(TRX_SYS_SPACE);
+ fil_flush(ulint(TRX_SYS_SPACE));
/* We know that the write has been flushed to disk now
and during recovery we will find it in the doublewrite buffer
diff --git a/storage/xtradb/buf/buf0flu.cc b/storage/xtradb/buf/buf0flu.cc
index e7ed7204920..ffd40157c30 100644
--- a/storage/xtradb/buf/buf0flu.cc
+++ b/storage/xtradb/buf/buf0flu.cc
@@ -873,11 +873,12 @@ buf_flush_write_block_low(
buf_flush_t flush_type, /*!< in: type of flush */
bool sync) /*!< in: true if sync IO request */
{
+ fil_space_t* space = fil_space_acquire(bpage->space, true);
+ if (!space) {
+ return;
+ }
ulint zip_size = buf_page_get_zip_size(bpage);
page_t* frame = NULL;
- ulint space_id = buf_page_get_space(bpage);
- atomic_writes_t awrites = fil_space_get_atomic_writes(space_id);
-
#ifdef UNIV_DEBUG
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
ut_ad(!mutex_own(&buf_pool->LRU_list_mutex));
@@ -947,7 +948,7 @@ buf_flush_write_block_low(
break;
}
- frame = buf_page_encrypt_before_write(bpage, frame, space_id);
+ frame = buf_page_encrypt_before_write(space, bpage, frame);
if (!srv_use_doublewrite_buf || !buf_dblwr) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
@@ -968,7 +969,8 @@ buf_flush_write_block_low(
atomic writes should be used, no doublewrite buffer
is used. */
- if (awrites == ATOMIC_WRITES_ON) {
+ if (fsp_flags_get_atomic_writes(space->flags)
+ == ATOMIC_WRITES_ON) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE,
buf_page_get_space(bpage),
@@ -991,10 +993,12 @@ buf_flush_write_block_low(
are working on. */
if (sync) {
ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE);
- fil_flush(buf_page_get_space(bpage));
+ fil_flush(space);
buf_page_io_complete(bpage);
}
+ fil_space_release(space);
+
/* Increment the counter of I/O operations used
for selecting LRU policy. */
buf_LRU_stat_inc_io();
diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc
index 15465699726..be2ee56504b 100644
--- a/storage/xtradb/buf/buf0rea.cc
+++ b/storage/xtradb/buf/buf0rea.cc
@@ -998,15 +998,11 @@ not_to_recover:
count++;
if (count > 1000) {
- fprintf(stderr,
- "InnoDB: Error: InnoDB has waited for"
- " 10 seconds for pending\n"
- "InnoDB: reads to the buffer pool to"
- " be finished.\n"
- "InnoDB: Number of pending reads %lu,"
- " pending pread calls %lu\n",
- (ulong) buf_pool->n_pend_reads,
- (ulong) os_file_n_pending_preads);
+ ib_logf(IB_LOG_LEVEL_ERROR,
+ "waited for 10 seconds for " ULINTPF
+ " pending reads to the buffer pool to"
+ " be finished",
+ buf_pool->n_pend_reads);
os_aio_print_debug = TRUE;
}
diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc
index 6a28f3cdf8f..33b6c2e23e0 100644
--- a/storage/xtradb/dict/dict0stats.cc
+++ b/storage/xtradb/dict/dict0stats.cc
@@ -1576,7 +1576,7 @@ dict_stats_analyze_index_below_cur(
page = buf_block_get_frame(block);
- if (btr_page_get_level(page, mtr) == 0) {
+ if (page_is_leaf(page)) {
/* leaf level */
break;
}
@@ -1620,7 +1620,7 @@ dict_stats_analyze_index_below_cur(
}
/* make sure we got a leaf page as a result from the above loop */
- ut_ad(btr_page_get_level(page, &mtr) == 0);
+ ut_ad(page_is_leaf(page));
/* scan the leaf page and find the number of distinct keys,
when looking only at the first n_prefix columns; also estimate
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index aa95de7efea..f37d5e19ad6 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -694,7 +694,8 @@ fil_space_encrypt(
comp_mem = (byte *)malloc(UNIV_PAGE_SIZE);
uncomp_mem = (byte *)malloc(UNIV_PAGE_SIZE);
memcpy(comp_mem, src_frame, UNIV_PAGE_SIZE);
- fil_decompress_page(uncomp_mem, comp_mem, UNIV_PAGE_SIZE, NULL);
+ fil_decompress_page(uncomp_mem, comp_mem,
+ srv_page_size, NULL);
src = uncomp_mem;
}
@@ -704,7 +705,8 @@ fil_space_encrypt(
/* Need to decompress the page if it was also compressed */
if (page_compressed_encrypted) {
memcpy(comp_mem, tmp_mem, UNIV_PAGE_SIZE);
- fil_decompress_page(tmp_mem, comp_mem, UNIV_PAGE_SIZE, NULL);
+ fil_decompress_page(tmp_mem, comp_mem,
+ srv_page_size, NULL);
}
bool corrupted = buf_page_is_corrupted(true, tmp_mem, zip_size, space);
@@ -1492,20 +1494,21 @@ fil_crypt_realloc_iops(
if (10 * state->cnt_waited > state->batch) {
/* if we waited more than 10% re-estimate max_iops */
- uint avg_wait_time_us =
+ ulint avg_wait_time_us =
state->sum_waited_us / state->cnt_waited;
+ if (avg_wait_time_us == 0) {
+ avg_wait_time_us = 1; // prevent division by zero
+ }
+
DBUG_PRINT("ib_crypt",
- ("thr_no: %u - update estimated_max_iops from %u to %u.",
+ ("thr_no: %u - update estimated_max_iops from %u to "
+ ULINTPF ".",
state->thread_no,
state->estimated_max_iops,
1000000 / avg_wait_time_us));
- if (avg_wait_time_us == 0) {
- avg_wait_time_us = 1; // prevent division by zero
- }
-
- state->estimated_max_iops = 1000000 / avg_wait_time_us;
+ state->estimated_max_iops = uint(1000000 / avg_wait_time_us);
state->cnt_waited = 0;
state->sum_waited_us = 0;
} else {
@@ -1739,33 +1742,27 @@ fil_crypt_find_page_to_rotate(
fil_space_crypt_t *crypt_data = space->crypt_data;
- /* Space might already be dropped */
- if (crypt_data) {
- mutex_enter(&crypt_data->mutex);
- ut_ad(key_state->key_id == crypt_data->key_id);
-
- if (crypt_data->rotate_state.next_offset <
- crypt_data->rotate_state.max_offset) {
+ mutex_enter(&crypt_data->mutex);
+ ut_ad(key_state->key_id == crypt_data->key_id);
- state->offset = crypt_data->rotate_state.next_offset;
- ulint remaining = crypt_data->rotate_state.max_offset -
- crypt_data->rotate_state.next_offset;
+ bool found = crypt_data->rotate_state.max_offset >=
+ crypt_data->rotate_state.next_offset;
- if (batch <= remaining) {
- state->batch = batch;
- } else {
- state->batch = remaining;
- }
+ if (found) {
+ state->offset = crypt_data->rotate_state.next_offset;
+ ulint remaining = crypt_data->rotate_state.max_offset -
+ crypt_data->rotate_state.next_offset;
- crypt_data->rotate_state.next_offset += batch;
- mutex_exit(&crypt_data->mutex);
- return true;
+ if (batch <= remaining) {
+ state->batch = batch;
+ } else {
+ state->batch = remaining;
}
-
- mutex_exit(&crypt_data->mutex);
}
- return false;
+ crypt_data->rotate_state.next_offset += batch;
+ mutex_exit(&crypt_data->mutex);
+ return found;
}
/***********************************************************************
@@ -2343,7 +2340,7 @@ DECLARE_THREAD(fil_crypt_thread)(
fil_crypt_start_rotate_space(&new_state, &thr);
/* iterate all pages (cooperativly with other threads) */
- while (!thr.should_shutdown() && thr.space &&
+ while (!thr.should_shutdown() &&
fil_crypt_find_page_to_rotate(&new_state, &thr)) {
/* rotate a (set) of pages */
@@ -2352,6 +2349,8 @@ DECLARE_THREAD(fil_crypt_thread)(
/* If space is marked as stopping, release
space and stop rotation. */
if (thr.space->is_stopping()) {
+ fil_crypt_complete_rotate_space(
+ &new_state, &thr);
fil_space_release(thr.space);
thr.space = NULL;
break;
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index e7244d719c8..e504ab3947e 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -5993,31 +5993,34 @@ fil_space_get_node(
return (node);
}
-/********************************************************************//**
-Return block size of node in file space
-@return file block size */
+
+/** Determine the block size of the data file.
+@param[in] space tablespace
+@param[in] offset page number
+@return block size */
UNIV_INTERN
ulint
-fil_space_get_block_size(
-/*=====================*/
- ulint space_id,
- ulint block_offset,
- ulint len)
+fil_space_get_block_size(const fil_space_t* space, unsigned offset)
{
- ulint block_size = 512;
- ut_ad(!mutex_own(&fil_system->mutex));
-
- mutex_enter(&fil_system->mutex);
- fil_space_t* space = fil_space_get_space(space_id);
+ ut_ad(space->n_pending_ops > 0);
- if (space) {
- fil_node_t* node = fil_space_get_node(space, space_id, &block_offset, 0, len);
+ ulint block_size = 512;
- if (node) {
- block_size = node->file_block_size;
+ for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain);
+ node != NULL;
+ node = UT_LIST_GET_NEXT(chain, node)) {
+ block_size = node->file_block_size;
+ if (node->size > offset) {
+ break;
}
+ offset -= node->size;
+ }
+
+ /* Currently supporting block size up to 4K,
+ fall back to default if bigger requested. */
+ if (block_size > 4096) {
+ block_size = 512;
}
- mutex_exit(&fil_system->mutex);
return block_size;
}
@@ -6398,14 +6401,29 @@ fil_flush(
mutex_exit(&fil_system->mutex);
}
-/**********************************************************************//**
-Flushes to disk the writes in file spaces of the given type possibly cached by
-the OS. */
+/** Flush a tablespace.
+@param[in,out] space tablespace to flush */
UNIV_INTERN
void
-fil_flush_file_spaces(
-/*==================*/
- ulint purpose) /*!< in: FIL_TABLESPACE, FIL_LOG */
+fil_flush(fil_space_t* space)
+{
+ ut_ad(space->n_pending_ops > 0);
+
+ if (!space->is_stopping()) {
+ mutex_enter(&fil_system->mutex);
+ if (!space->is_stopping()) {
+ fil_flush_low(space);
+ }
+ mutex_exit(&fil_system->mutex);
+ }
+}
+
+/** Flush to disk the writes in file spaces of the given type
+possibly cached by the OS.
+@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */
+UNIV_INTERN
+void
+fil_flush_file_spaces(ulint purpose)
{
fil_space_t* space;
ulint* space_ids;
@@ -6772,7 +6790,8 @@ fil_iterate(
/* If the original page is page_compressed, we need
to decompress page before we can update it. */
if (page_compressed) {
- fil_decompress_page(NULL, dst, size, NULL);
+ fil_decompress_page(NULL, dst, ulong(size),
+ NULL);
updated = true;
}
@@ -6832,12 +6851,14 @@ fil_iterate(
if (page_compressed) {
ulint len = 0;
- fil_compress_page(space_id,
+
+ fil_compress_page(
+ NULL,
src,
NULL,
size,
- fil_space_get_page_compression_level(space_id),
- fil_space_get_block_size(space_id, offset, size),
+ 0,/* FIXME: compression level */
+ 512,/* FIXME: use proper block size */
encrypted,
&len,
NULL);
@@ -6848,6 +6869,8 @@ fil_iterate(
/* If tablespace is encrypted, encrypt page before we
write it back. Note that we should not encrypt the
buffer that is in buffer pool. */
+ /* NOTE: At this stage of IMPORT the
+ buffer pool is not being used at all! */
if (decrypted && encrypted) {
byte *dest = writeptr + (i * size);
ulint space = mach_read_from_4(
@@ -7401,7 +7424,6 @@ fil_space_acquire_low(ulint id, bool silent, bool for_io = false)
if (!silent) {
ib_logf(IB_LOG_LEVEL_WARN, "Trying to access missing"
" tablespace " ULINTPF ".", id);
- ut_error;
}
} else if (!for_io && space->is_stopping()) {
space = NULL;
diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc
index 303ab5102fb..8b2449983df 100644
--- a/storage/xtradb/fil/fil0pagecompress.cc
+++ b/storage/xtradb/fil/fil0pagecompress.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (C) 2013, 2016, MariaDB Corporation. All Rights Reserved.
+Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -91,8 +91,7 @@ UNIV_INTERN
byte*
fil_compress_page(
/*==============*/
- ulint space_id, /*!< in: tablespace id of the
- table. */
+ fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */
byte* buf, /*!< in: buffer from which to write; in aio
this must be appropriately aligned */
byte* out_buf, /*!< out: compressed buffer */
@@ -110,9 +109,12 @@ fil_compress_page(
ulint write_size=0;
/* Cache to avoid change during function execution */
ulint comp_method = innodb_compression_algorithm;
- ulint orig_page_type;
bool allocated=false;
+ /* page_compression does not apply to tables or tablespaces
+ that use ROW_FORMAT=COMPRESSED */
+ ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags));
+
if (encrypted) {
header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE;
}
@@ -133,21 +135,14 @@ fil_compress_page(
ut_ad(len);
ut_ad(out_len);
- /* read original page type */
- orig_page_type = mach_read_from_2(buf + FIL_PAGE_TYPE);
-
- fil_system_enter();
- fil_space_t* space = fil_space_get_by_id(space_id);
- fil_system_exit();
-
/* Let's not compress file space header or
extent descriptor */
- if (orig_page_type == 0 ||
- orig_page_type == FIL_PAGE_TYPE_FSP_HDR ||
- orig_page_type == FIL_PAGE_TYPE_XDES ||
- orig_page_type == FIL_PAGE_PAGE_COMPRESSED) {
+ switch (fil_page_get_type(buf)) {
+ case 0:
+ case FIL_PAGE_TYPE_FSP_HDR:
+ case FIL_PAGE_TYPE_XDES:
+ case FIL_PAGE_PAGE_COMPRESSED:
*out_len = len;
-
goto err_exit;
}
@@ -157,11 +152,11 @@ fil_compress_page(
comp_level = page_zip_level;
}
-#ifdef UNIV_PAGECOMPRESS_DEBUG
- ib_logf(IB_LOG_LEVEL_INFO,
- "Preparing for compress for space %lu name %s len %lu.",
- space_id, fil_space_name(space), len);
-#endif /* UNIV_PAGECOMPRESS_DEBUG */
+ DBUG_PRINT("compress",
+ ("Preparing for space " ULINTPF " '%s' len " ULINTPF,
+ space ? space->id : 0,
+ space ? space->name : "(import)",
+ len));
write_size = UNIV_PAGE_SIZE - header_len;
@@ -176,12 +171,15 @@ fil_compress_page(
/* If error we leave the actual page as it was */
#ifndef UNIV_PAGECOMPRESS_DEBUG
- if (space->printed_compression_failure == false) {
+ if (space && !space->printed_compression_failure) {
+ space->printed_compression_failure = true;
#endif
ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu rt %d write %lu.",
- space_id, fil_space_name(space), len, err, write_size);
- space->printed_compression_failure = true;
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " err %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ err, write_size);
#ifndef UNIV_PAGECOMPRESS_DEBUG
}
#endif
@@ -197,11 +195,14 @@ fil_compress_page(
buf, len, out_buf+header_len, &write_size, lzo_mem);
if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) {
- if (space->printed_compression_failure == false) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu err %d write_size %lu.",
- space_id, fil_space_name(space), len, err, write_size);
+ if (space && !space->printed_compression_failure) {
space->printed_compression_failure = true;
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " err %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ err, write_size);
}
srv_stats.pages_page_compression_error.inc();
@@ -226,11 +227,14 @@ fil_compress_page(
(size_t)write_size);
if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) {
- if (space->printed_compression_failure == false) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu err %d write_size %lu",
- space_id, fil_space_name(space), len, err, out_pos);
+ if (space && !space->printed_compression_failure) {
space->printed_compression_failure = true;
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " err %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ err, out_pos);
}
srv_stats.pages_page_compression_error.inc();
@@ -257,11 +261,14 @@ fil_compress_page(
0);
if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) {
- if (space->printed_compression_failure == false) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu err %d write_size %lu.",
- space_id, fil_space_name(space), len, err, write_size);
+ if (space && !space->printed_compression_failure) {
space->printed_compression_failure = true;
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " err %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ err, write_size);
}
srv_stats.pages_page_compression_error.inc();
@@ -284,11 +291,14 @@ fil_compress_page(
(size_t*)&write_size);
if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) {
- if (space->printed_compression_failure == false) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu err %d write_size %lu.",
- space_id, fil_space_name(space), len, (int)cstatus, write_size);
+ if (space && !space->printed_compression_failure) {
space->printed_compression_failure = true;
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " err %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ (int)cstatus, write_size);
}
srv_stats.pages_page_compression_error.inc();
@@ -300,16 +310,20 @@ fil_compress_page(
#endif /* HAVE_SNAPPY */
case PAGE_ZLIB_ALGORITHM:
- err = compress2(out_buf+header_len, (ulong*)&write_size, buf, len, comp_level);
+ err = compress2(out_buf+header_len, (ulong*)&write_size, buf,
+ uLong(len), comp_level);
if (err != Z_OK) {
/* If error we leave the actual page as it was */
- if (space->printed_compression_failure == false) {
- ib_logf(IB_LOG_LEVEL_WARN,
- "Compression failed for space %lu name %s len %lu rt %d write %lu.",
- space_id, fil_space_name(space), len, err, write_size);
+ if (space && !space->printed_compression_failure) {
space->printed_compression_failure = true;
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Compression failed for space " ULINTPF
+ " name %s len " ULINTPF
+ " rt %d write_size " ULINTPF ".",
+ space->id, space->name, len,
+ err, write_size);
}
srv_stats.pages_page_compression_error.inc();
@@ -364,11 +378,10 @@ fil_compress_page(
uncomp_page = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE));
memcpy(comp_page, out_buf, UNIV_PAGE_SIZE);
- fil_decompress_page(uncomp_page, comp_page, len, NULL);
+ fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL);
- if(buf_page_is_corrupted(false, uncomp_page, 0, space)) {
- buf_page_print(uncomp_page, 0, BUF_PAGE_PRINT_NO_CRASH);
- ut_error;
+ if (buf_page_is_corrupted(false, uncomp_page, 0, space)) {
+ buf_page_print(uncomp_page, 0, 0);
}
ut_free(comp_page);
@@ -396,11 +409,12 @@ fil_compress_page(
#endif
}
-#ifdef UNIV_PAGECOMPRESS_DEBUG
- ib_logf(IB_LOG_LEVEL_INFO,
- "Compression succeeded for space %lu name %s len %lu out_len %lu.",
- space_id, fil_space_name(space), len, write_size);
-#endif /* UNIV_PAGECOMPRESS_DEBUG */
+ DBUG_PRINT("compress",
+ ("Succeeded for space " ULINTPF
+ " '%s' len " ULINTPF " out_len " ULINTPF,
+ space ? space->id : 0,
+ space ? space->name : "(import)",
+ len, write_size));
srv_stats.page_compression_saved.add((len - write_size));
srv_stats.pages_page_compressed.inc();
diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h
index 1774d9445ff..4a632e2345f 100644
--- a/storage/xtradb/include/buf0buf.h
+++ b/storage/xtradb/include/buf0buf.h
@@ -1534,17 +1534,19 @@ buf_own_zip_mutex_for_page(
MY_ATTRIBUTE((nonnull,warn_unused_result));
#endif /* UNIV_DEBUG */
-/********************************************************************//**
-The hook that is called just before a page is written to disk.
-The function encrypts the content of the page and returns a pointer
-to a frame that will be written instead of the real frame. */
+/** Encryption and page_compression hook that is called just before
+a page is written to disk.
+@param[in,out] space tablespace
+@param[in,out] bpage buffer page
+@param[in] src_frame physical page frame that is being encrypted
+@return page frame to be written to file
+(may be src_frame or an encrypted/compressed copy of it) */
UNIV_INTERN
byte*
buf_page_encrypt_before_write(
-/*==========================*/
- buf_page_t* page, /*!< in/out: buffer page to be flushed */
- byte* frame, /*!< in: src frame */
- ulint space_id); /*!< in: space id */
+ fil_space_t* space,
+ buf_page_t* bpage,
+ byte* src_frame);
/**********************************************************************
The hook that is called after page is written to disk.
diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic
index 81da2fa5580..e3de7a33123 100644
--- a/storage/xtradb/include/dict0dict.ic
+++ b/storage/xtradb/include/dict0dict.ic
@@ -540,15 +540,16 @@ dict_tf_is_valid(
/* Make sure there are no bits that we do not know about. */
if (unused != 0) {
-
fprintf(stderr,
- "InnoDB: Error: table unused flags are %ld"
+ "InnoDB: Error: table unused flags are " ULINTPF
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF
+ "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF
+ " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
unused,
compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
@@ -564,17 +565,20 @@ dict_tf_is_valid(
if (!compact) {
fprintf(stderr,
- "InnoDB: Error: table compact flags are %ld"
+ "InnoDB: Error: table compact flags are "
+ ULINTPF
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF
+ " atomic_blobs " ULINTPF "\n"
+ "InnoDB: unused " ULINTPF
+ " data_dir " ULINTPF " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
compact, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
-
return(false);
}
@@ -582,17 +586,18 @@ dict_tf_is_valid(
/* Antelope does not support COMPRESSED row format. */
fprintf(stderr,
- "InnoDB: Error: table flags are %ld"
+ "InnoDB: Error: table flags are " ULINTPF
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF " atomic_blobs " ULINTPF
+ "\nInnoDB: unused " ULINTPF " data_dir " ULINTPF
+ " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
flags, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
-
return(false);
}
@@ -606,12 +611,17 @@ dict_tf_is_valid(
|| zip_ssize > PAGE_ZIP_SSIZE_MAX) {
fprintf(stderr,
- "InnoDB: Error: table compact flags are %ld in the data dictionary and are corrupted\n"
+ "InnoDB: Error: table compact flags are "
+ ULINTPF
+ " in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF
+ " atomic_blobs " ULINTPF "\n"
+ "InnoDB: unused " ULINTPF
+ " data_dir " ULINTPF " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
flags,
compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
@@ -630,16 +640,19 @@ dict_tf_is_valid(
|| !atomic_blobs) {
fprintf(stderr,
- "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n"
+ "InnoDB: Error: table flags are " ULINTPF
+ " in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF
+ " atomic_blobs " ULINTPF "\n"
+ "InnoDB: unused " ULINTPF
+ " data_dir " ULINTPF " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
flags, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
-
return(false);
}
}
@@ -649,12 +662,16 @@ dict_tf_is_valid(
if(atomic_writes > ATOMIC_WRITES_OFF) {
fprintf(stderr,
- "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n"
+ "InnoDB: Error: table flags are " ULINTPF
+ " in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
- "InnoDB: compact %ld atomic_blobs %ld\n"
- "InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
- "InnoDB: page_compression %ld page_compression_level %ld\n"
- "InnoDB: atomic_writes %ld\n",
+ "InnoDB: compact " ULINTPF
+ " atomic_blobs " ULINTPF "\n"
+ "InnoDB: unused " ULINTPF
+ " data_dir " ULINTPF " zip_ssize " ULINTPF
+ "\nInnoDB: page_compression " ULINTPF
+ " page_compression_level " ULINTPF
+ "\nInnoDB: atomic_writes " ULINTPF "\n",
flags, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
@@ -699,7 +716,7 @@ dict_sys_tables_type_validate(
if (redundant) {
if (zip_ssize || atomic_blobs) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize %lu atomic_blobs %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=Redundant, zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n",
zip_ssize, atomic_blobs);
return(ULINT_UNDEFINED);
}
@@ -707,7 +724,7 @@ dict_sys_tables_type_validate(
/* Make sure there are no bits that we do not know about. */
if (unused) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, unused %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", unused " ULINTPF "\n",
type, unused);
return(ULINT_UNDEFINED);
}
@@ -723,7 +740,7 @@ dict_sys_tables_type_validate(
} else if (zip_ssize) {
/* Antelope does not support COMPRESSED format. */
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF "\n",
type, zip_ssize);
return(ULINT_UNDEFINED);
}
@@ -734,14 +751,14 @@ dict_sys_tables_type_validate(
should be in N_COLS, but we already know about the
low_order_bit and DICT_N_COLS_COMPACT flags. */
if (!atomic_blobs) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu atomic_blobs %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " atomic_blobs " ULINTPF "\n",
type, zip_ssize, atomic_blobs);
return(ULINT_UNDEFINED);
}
/* Validate that the number is within allowed range. */
if (zip_ssize > PAGE_ZIP_SSIZE_MAX) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, zip_ssize %lu max %d\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", zip_ssize " ULINTPF " max %d\n",
type, zip_ssize, PAGE_ZIP_SSIZE_MAX);
return(ULINT_UNDEFINED);
}
@@ -759,8 +776,8 @@ dict_sys_tables_type_validate(
low_order_bit and DICT_N_COLS_COMPACT flags. */
if (!atomic_blobs || !page_compression) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, page_compression %lu page_compression_level %lu\n"
- "InnoDB: Error: atomic_blobs %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", page_compression " ULINTPF " page_compression_level " ULINTPF "\n"
+ "InnoDB: Error: atomic_blobs " ULINTPF "\n",
type, page_compression, page_compression_level, atomic_blobs);
return(ULINT_UNDEFINED);
}
@@ -768,7 +785,7 @@ dict_sys_tables_type_validate(
/* Validate that the atomic writes number is within allowed range. */
if (atomic_writes > ATOMIC_WRITES_OFF) {
- fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n",
+ fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=" ULINTPF ", atomic_writes " ULINTPF "\n",
type, atomic_writes);
return(ULINT_UNDEFINED);
}
diff --git a/storage/xtradb/include/fil0crypt.h b/storage/xtradb/include/fil0crypt.h
index cfc2d850883..e7e9676aa3a 100644
--- a/storage/xtradb/include/fil0crypt.h
+++ b/storage/xtradb/include/fil0crypt.h
@@ -109,7 +109,7 @@ struct fil_space_crypt_t : st_encryption_scheme
The object is expected to be placed in a buffer that
has been zero-initialized. */
fil_space_crypt_t(
- ulint new_type,
+ uint new_type,
uint new_min_key_version,
uint new_key_id,
fil_encryption_t new_encryption)
@@ -117,10 +117,10 @@ struct fil_space_crypt_t : st_encryption_scheme
min_key_version(new_min_key_version),
page0_offset(0),
encryption(new_encryption),
- key_found(),
+ mutex(),
+ key_found(new_min_key_version),
rotate_state()
{
- key_found = new_min_key_version;
key_id = new_key_id;
my_random_bytes(iv, sizeof(iv));
mutex_create(fil_crypt_data_mutex_key,
diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h
index 698039afede..d73a68d9d34 100644
--- a/storage/xtradb/include/fil0fil.h
+++ b/storage/xtradb/include/fil0fil.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1120,16 +1120,13 @@ _fil_io(
#define fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, write_size) \
_fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, write_size, NULL)
-/*******************************************************************//**
-Returns the block size of the file space
+/** Determine the block size of the data file.
+@param[in] space tablespace
+@param[in] offset page number
@return block size */
UNIV_INTERN
ulint
-fil_space_get_block_size(
-/*=====================*/
- ulint id, /*!< in: space id */
- ulint offset, /*!< in: page offset */
- ulint len); /*!< in: page len */
+fil_space_get_block_size(const fil_space_t* space, unsigned offset);
/**********************************************************************//**
Waits for an aio operation to complete. This function is used to write the
@@ -1151,14 +1148,18 @@ fil_flush(
/*======*/
ulint space_id); /*!< in: file space id (this can be a group of
log files or a tablespace of the database) */
-/**********************************************************************//**
-Flushes to disk writes in file spaces of the given type possibly cached by
-the OS. */
+/** Flush a tablespace.
+@param[in,out] space tablespace to flush */
UNIV_INTERN
void
-fil_flush_file_spaces(
-/*==================*/
- ulint purpose); /*!< in: FIL_TABLESPACE, FIL_LOG */
+fil_flush(fil_space_t* space);
+
+/** Flush to disk the writes in file spaces of the given type
+possibly cached by the OS.
+@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG */
+UNIV_INTERN
+void
+fil_flush_file_spaces(ulint purpose);
/******************************************************************//**
Checks the consistency of the tablespace cache.
@return TRUE if ok */
@@ -1459,14 +1460,6 @@ fil_get_next_space_safe(
#endif /* UNIV_INNOCHECKSUM */
-/*******************************************************************//**
-Return space flags */
-UNIV_INLINE
-ulint
-fil_space_flags(
-/*===========*/
- fil_space_t* space); /*!< in: space */
-
/****************************************************************//**
Does error handling when a file operation fails.
@return TRUE if we should retry the operation */
diff --git a/storage/xtradb/include/fil0fil.ic b/storage/xtradb/include/fil0fil.ic
index 1179eea8b8e..6c2504c9f8c 100644
--- a/storage/xtradb/include/fil0fil.ic
+++ b/storage/xtradb/include/fil0fil.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2015, MariaDB Corporation.
+Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -27,28 +27,6 @@ Created 31/03/2015 Jan Lindström
#define fil0fil_ic
/*******************************************************************//**
-Return space name */
-UNIV_INLINE
-char*
-fil_space_name(
-/*===========*/
- fil_space_t* space) /*!< in: space */
-{
- return (space->name);
-}
-
-/*******************************************************************//**
-Return space flags */
-UNIV_INLINE
-ulint
-fil_space_flags(
-/*===========*/
- fil_space_t* space) /*!< in: space */
-{
- return (space->flags);
-}
-
-/*******************************************************************//**
Return page type name */
UNIV_INLINE
const char*
@@ -137,7 +115,7 @@ fil_page_type_validate(
page_type == FIL_PAGE_TYPE_ZBLOB2 ||
page_type == FIL_PAGE_TYPE_COMPRESSED))) {
- uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
+ ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED);
bool page_compressed_encrypted = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
ulint space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
@@ -148,30 +126,18 @@ fil_page_type_validate(
fil_space_t* rspace = fil_space_get_by_id(space);
fil_system_exit();
-
/* Dump out the page info */
- fprintf(stderr, "InnoDB: Space %lu offset %lu name %s page_type %lu page_type_name %s\n"
- "InnoDB: key_version %u page_compressed %d page_compressed_encrypted %d lsn %llu compressed_len %lu\n",
- space, offset, rspace->name, page_type, fil_get_page_type_name(page_type),
- key_version, page_compressed, page_compressed_encrypted, (ulonglong)lsn, compressed_len);
- fflush(stderr);
-
- ut_ad(page_type == FIL_PAGE_PAGE_COMPRESSED ||
- page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED ||
- page_type == FIL_PAGE_INDEX ||
- page_type == FIL_PAGE_UNDO_LOG ||
- page_type == FIL_PAGE_INODE ||
- page_type == FIL_PAGE_IBUF_FREE_LIST ||
- page_type == FIL_PAGE_TYPE_ALLOCATED ||
- page_type == FIL_PAGE_IBUF_BITMAP ||
- page_type == FIL_PAGE_TYPE_SYS ||
- page_type == FIL_PAGE_TYPE_TRX_SYS ||
- page_type == FIL_PAGE_TYPE_FSP_HDR ||
- page_type == FIL_PAGE_TYPE_XDES ||
- page_type == FIL_PAGE_TYPE_BLOB ||
- page_type == FIL_PAGE_TYPE_ZBLOB ||
- page_type == FIL_PAGE_TYPE_ZBLOB2 ||
- page_type == FIL_PAGE_TYPE_COMPRESSED);
+ fprintf(stderr, "InnoDB: Page " ULINTPF ":" ULINTPF
+ " name %s page_type " ULINTPF " page_type_name %s\n"
+ "InnoDB: key_version " ULINTPF
+ " page_compressed %d page_compressed_encrypted %d lsn "
+ LSN_PF " compressed_len " ULINTPF "\n",
+ space, offset, rspace->name, page_type,
+ fil_get_page_type_name(page_type),
+ key_version,
+ page_compressed, page_compressed_encrypted,
+ lsn, compressed_len);
+ ut_error;
return false;
}
diff --git a/storage/xtradb/include/fil0pagecompress.h b/storage/xtradb/include/fil0pagecompress.h
index 1fe5cb66bf6..73667c5420e 100644
--- a/storage/xtradb/include/fil0pagecompress.h
+++ b/storage/xtradb/include/fil0pagecompress.h
@@ -31,33 +31,6 @@ Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/*******************************************************************//**
-Returns the page compression level flag of the space, or 0 if the space
-is not compressed. The tablespace must be cached in the memory cache.
-@return page compression level if page compressed, ULINT_UNDEFINED if space not found */
-UNIV_INLINE
-ulint
-fil_space_get_page_compression_level(
-/*=================================*/
- ulint id); /*!< in: space id */
-/*******************************************************************//**
-Returns the page compression flag of the space, or false if the space
-is not compressed. The tablespace must be cached in the memory cache.
-@return true if page compressed, false if not or space not found */
-UNIV_INLINE
-bool
-fil_space_is_page_compressed(
-/*=========================*/
- ulint id); /*!< in: space id */
-/*******************************************************************//**
-Returns the atomic writes flag of the space, or false if the space
-is not using atomic writes. The tablespace must be cached in the memory cache.
-@return atomic write table option value */
-UNIV_INLINE
-atomic_writes_t
-fil_space_get_atomic_writes(
-/*=========================*/
- ulint id); /*!< in: space id */
-/*******************************************************************//**
Find out wheather the page is index page or not
@return true if page type index page, false if not */
UNIV_INLINE
@@ -84,8 +57,7 @@ UNIV_INTERN
byte*
fil_compress_page(
/*==============*/
- ulint space_id, /*!< in: tablespace id of the
- table. */
+ fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */
byte* buf, /*!< in: buffer from which to write; in aio
this must be appropriately aligned */
byte* out_buf, /*!< out: compressed buffer */
diff --git a/storage/xtradb/include/fsp0pagecompress.ic b/storage/xtradb/include/fsp0pagecompress.ic
index 48163277feb..14f968e319e 100644
--- a/storage/xtradb/include/fsp0pagecompress.ic
+++ b/storage/xtradb/include/fsp0pagecompress.ic
@@ -85,47 +85,6 @@ fil_page_is_compressed_encrypted(
return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
}
-#ifndef UNIV_INNOCHECKSUM
-/*******************************************************************//**
-Returns the page compression level of the space, or 0 if the space
-is not compressed. The tablespace must be cached in the memory cache.
-@return page compression level, 0 if space not found */
-UNIV_INLINE
-ulint
-fil_space_get_page_compression_level(
-/*=================================*/
- ulint id) /*!< in: space id */
-{
- ulint flags;
-
- flags = fil_space_get_flags(id);
-
- if (flags && flags != ULINT_UNDEFINED) {
-
- return(fsp_flags_get_page_compression_level(flags));
- }
-
- return(0);
-}
-
-/*******************************************************************//**
-Extract the page compression from space.
-@return true if space is page compressed, false if space is not found
-or space is not page compressed. */
-UNIV_INLINE
-bool
-fil_space_is_page_compressed(
-/*=========================*/
- ulint id) /*!< in: space id */
-{
- ulint flags = fil_space_get_flags(id);
-
- return(flags != ULINT_UNDEFINED
- && FSP_FLAGS_HAS_PAGE_COMPRESSION(flags));
-}
-
-#endif /* UNIV_INNOCHECKSUM */
-
/****************************************************************//**
Get the name of the compression algorithm used for page
compression.
@@ -166,28 +125,6 @@ fil_get_compression_alg_name(
#ifndef UNIV_INNOCHECKSUM
/*******************************************************************//**
-Returns the atomic writes flag of the space, or false if the space
-is not using atomic writes. The tablespace must be cached in the memory cache.
-@return atomic writes table option value */
-UNIV_INLINE
-atomic_writes_t
-fil_space_get_atomic_writes(
-/*========================*/
- ulint id) /*!< in: space id */
-{
- ulint flags;
-
- flags = fil_space_get_flags(id);
-
- if (flags && flags != ULINT_UNDEFINED) {
-
- return((atomic_writes_t)fsp_flags_get_atomic_writes(flags));
- }
-
- return((atomic_writes_t)0);
-}
-
-/*******************************************************************//**
Find out wheather the page is page compressed with lzo method
@return true if page is page compressed with lzo method, false if not */
UNIV_INLINE
diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h
index d6f0ecfb69c..06bb6a6fbac 100644
--- a/storage/xtradb/include/os0file.h
+++ b/storage/xtradb/include/os0file.h
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
@@ -52,16 +52,6 @@ extern ibool os_has_said_disk_full;
/** Flag: enable debug printout for asynchronous i/o */
extern ibool os_aio_print_debug;
-/** Number of pending os_file_pread() operations */
-extern ulint os_file_n_pending_preads;
-/** Number of pending os_file_pwrite() operations */
-extern ulint os_file_n_pending_pwrites;
-
-/** Number of pending read operations */
-extern ulint os_n_pending_reads;
-/** Number of pending write operations */
-extern ulint os_n_pending_writes;
-
#ifdef __WIN__
/** We define always WIN_ASYNC_IO, and check at run-time whether
diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h
index f6207555f1a..48c56a73369 100644
--- a/storage/xtradb/include/os0sync.h
+++ b/storage/xtradb/include/os0sync.h
@@ -718,10 +718,7 @@ os_atomic_clear(volatile lock_word_t* ptr)
# define HAVE_ATOMIC_BUILTINS
# define HAVE_ATOMIC_BUILTINS_BYTE
-
-# ifndef _WIN32
-# define HAVE_ATOMIC_BUILTINS_64
-# endif
+# define HAVE_ATOMIC_BUILTINS_64
/**********************************************************//**
Atomic compare and exchange of signed integers (both 32 and 64 bit).
diff --git a/storage/xtradb/include/srv0mon.h b/storage/xtradb/include/srv0mon.h
index 3b030d56d29..63fd449ee18 100644
--- a/storage/xtradb/include/srv0mon.h
+++ b/storage/xtradb/include/srv0mon.h
@@ -2,7 +2,7 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2016, MariaDB Corporation.
+Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -571,22 +571,30 @@ on the counters */
/** Increment a monitor counter under mutex protection.
Use MONITOR_INC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
@param monitor monitor to be incremented by 1
-@param mutex mutex to acquire and relese */
-# define MONITOR_MUTEX_INC(mutex, monitor) \
+@param enabled whether the monitor is enabled */
+#define MONITOR_MUTEX_INC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \
- if (MONITOR_IS_ON(monitor)) { \
+ if (enabled) { \
mutex_enter(mutex); \
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \
mutex_exit(mutex); \
}
+/** Increment a monitor counter under mutex protection.
+Use MONITOR_INC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
+@param monitor monitor to be incremented by 1 */
+#define MONITOR_MUTEX_INC(mutex, monitor) \
+ MONITOR_MUTEX_INC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
/** Decrement a monitor counter under mutex protection.
Use MONITOR_DEC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
@param monitor monitor to be decremented by 1
-@param mutex mutex to acquire and relese */
-# define MONITOR_MUTEX_DEC(mutex, monitor) \
+@param enabled whether the monitor is enabled */
+#define MONITOR_MUTEX_DEC_LOW(mutex, monitor, enabled) \
ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \
@@ -595,13 +603,20 @@ Use MONITOR_DEC if appropriate mutex protection already exists.
} \
mutex_exit(mutex); \
}
+/** Decrement a monitor counter under mutex protection.
+Use MONITOR_DEC if appropriate mutex protection already exists.
+@param mutex mutex to acquire and release
+@param monitor monitor to be decremented by 1 */
+#define MONITOR_MUTEX_DEC(mutex, monitor) \
+ MONITOR_MUTEX_DEC_LOW(mutex, monitor, MONITOR_IS_ON(monitor))
#if defined HAVE_ATOMIC_BUILTINS_64
/** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists.
-@param monitor monitor to be incremented by 1 */
-# define MONITOR_ATOMIC_INC(monitor) \
- if (MONITOR_IS_ON(monitor)) { \
+@param monitor monitor to be incremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
+ if (enabled) { \
ib_uint64_t value; \
value = os_atomic_increment_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
@@ -614,9 +629,10 @@ Use MONITOR_INC if appropriate mutex protection exists.
/** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists.
-@param monitor monitor to be decremented by 1 */
-# define MONITOR_ATOMIC_DEC(monitor) \
- if (MONITOR_IS_ON(monitor)) { \
+@param monitor monitor to be decremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
+ if (enabled) { \
ib_uint64_t value; \
value = os_atomic_decrement_uint64( \
(ib_uint64_t*) &MONITOR_VALUE(monitor), 1); \
@@ -647,14 +663,29 @@ srv_mon_free(void);
/** Atomically increment a monitor counter.
Use MONITOR_INC if appropriate mutex protection exists.
-@param monitor monitor to be incremented by 1 */
-# define MONITOR_ATOMIC_INC(monitor) MONITOR_MUTEX_INC(&monitor_mutex, monitor)
+@param monitor monitor to be incremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_INC_LOW(monitor, enabled) \
+ MONITOR_MUTEX_INC_LOW(&monitor_mutex, monitor, enabled)
/** Atomically decrement a monitor counter.
Use MONITOR_DEC if appropriate mutex protection exists.
-@param monitor monitor to be decremented by 1 */
-# define MONITOR_ATOMIC_DEC(monitor) MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
+@param monitor monitor to be decremented by 1
+@param enabled whether the monitor is enabled */
+# define MONITOR_ATOMIC_DEC_LOW(monitor, enabled) \
+ MONITOR_MUTEX_DEC_LOW(&monitor_mutex, monitor, enabled)
#endif /* HAVE_ATOMIC_BUILTINS_64 */
+/** Atomically increment a monitor counter if it is enabled.
+Use MONITOR_INC if appropriate mutex protection exists.
+@param monitor monitor to be incremented by 1 */
+#define MONITOR_ATOMIC_INC(monitor) \
+ MONITOR_ATOMIC_INC_LOW(monitor, MONITOR_IS_ON(monitor))
+/** Atomically decrement a monitor counter if it is enabled.
+Use MONITOR_DEC if appropriate mutex protection exists.
+@param monitor monitor to be decremented by 1 */
+#define MONITOR_ATOMIC_DEC(monitor) \
+ MONITOR_ATOMIC_DEC_LOW(monitor, MONITOR_IS_ON(monitor))
+
#define MONITOR_DEC(monitor) \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)--; \
diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h
index e621d4226a7..766d61039b4 100644
--- a/storage/xtradb/include/trx0trx.h
+++ b/storage/xtradb/include/trx0trx.h
@@ -348,6 +348,23 @@ trx_print_latched(
or 0 to use the default max length */
MY_ATTRIBUTE((nonnull));
+#ifdef WITH_WSREP
+/**********************************************************************//**
+Prints info about a transaction.
+Transaction information may be retrieved without having trx_sys->mutex acquired
+so it may not be completely accurate. The caller must own lock_sys->mutex
+and the trx must have some locks to make sure that it does not escape
+without locking lock_sys->mutex. */
+UNIV_INTERN
+void
+wsrep_trx_print_locking(
+/*==============*/
+ FILE* f, /*!< in: output stream */
+ const trx_t* trx, /*!< in: transaction */
+ ulint max_query_len) /*!< in: max query length to print,
+ or 0 to use the default max length */
+ MY_ATTRIBUTE((nonnull));
+#endif /* WITH_WSREP */
/**********************************************************************//**
Prints info about a transaction.
Acquires and releases lock_sys->mutex and trx_sys->mutex. */
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index 1e375ba2c09..e698f08f15b 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -304,22 +304,12 @@ definitions: */
#endif /* !UNIV_MUST_NOT_INLINE */
-#ifdef _WIN32
-#define UNIV_WORD_SIZE 4
-#elif defined(_WIN64)
-#define UNIV_WORD_SIZE 8
-#else
-/** MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
-#define UNIV_WORD_SIZE SIZEOF_LONG
-#endif
+#define UNIV_WORD_SIZE SIZEOF_SIZE_T
/** The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8
-/** The following alignment is used in aligning lints etc. */
-#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
-
/*
DATABASE VERSION CONTROL
========================
@@ -478,13 +468,12 @@ the word size of the machine, that is on a 32-bit platform 32 bits, and on a
macro ULINTPF. */
-#ifdef __WIN__
+#ifdef _WIN32
/* Use the integer types and formatting strings defined in Visual Studio. */
-# define UINT32PF "%I32u"
-# define INT64PF "%I64d"
-# define UINT64PF "%I64u"
-# define UINT64PFx "%016I64x"
-# define DBUG_LSN_PF "%llu"
+# define UINT32PF "%u"
+# define INT64PF "%lld"
+# define UINT64PF "%llu"
+# define UINT64PFx "%016llx"
typedef __int64 ib_int64_t;
typedef unsigned __int64 ib_uint64_t;
typedef unsigned __int32 ib_uint32_t;
@@ -494,13 +483,12 @@ typedef unsigned __int32 ib_uint32_t;
# define INT64PF "%" PRId64
# define UINT64PF "%" PRIu64
# define UINT64PFx "%016" PRIx64
-# define DBUG_LSN_PF UINT64PF
typedef int64_t ib_int64_t;
typedef uint64_t ib_uint64_t;
typedef uint32_t ib_uint32_t;
-# endif /* __WIN__ */
+#endif
-# define IB_ID_FMT UINT64PF
+#define IB_ID_FMT UINT64PF
/* Type used for all log sequence number storage and arithmetics */
typedef ib_uint64_t lsn_t;
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 0d555ed2dd7..717fbf02536 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -1762,7 +1762,6 @@ wsrep_kill_victim(
is in the queue*/
} else if (lock->trx != trx) {
if (wsrep_log_conflicts) {
- mutex_enter(&trx_sys->mutex);
if (bf_this) {
fputs("\n*** Priority TRANSACTION:\n",
stderr);
@@ -1771,7 +1770,7 @@ wsrep_kill_victim(
stderr);
}
- trx_print_latched(stderr, trx, 3000);
+ wsrep_trx_print_locking(stderr, trx, 3000);
if (bf_other) {
fputs("\n*** Priority TRANSACTION:\n",
@@ -1780,10 +1779,7 @@ wsrep_kill_victim(
fputs("\n*** Victim TRANSACTION:\n",
stderr);
}
-
- trx_print_latched(stderr, lock->trx, 3000);
-
- mutex_exit(&trx_sys->mutex);
+ wsrep_trx_print_locking(stderr, lock->trx, 3000);
fputs("*** WAITING FOR THIS LOCK TO BE GRANTED:\n",
stderr);
diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc
index 6b7c8d77824..120f1432ccf 100644
--- a/storage/xtradb/log/log0recv.cc
+++ b/storage/xtradb/log/log0recv.cc
@@ -1728,7 +1728,7 @@ recv_recover_page_func(
}
DBUG_PRINT("ib_log",
- ("apply " DBUG_LSN_PF ": %u len %u "
+ ("apply " LSN_PF ": %u len %u "
"page %u:%u", recv->start_lsn,
(unsigned) recv->type,
(unsigned) recv->len,
@@ -2391,7 +2391,7 @@ loop:
recv_sys->recovered_lsn = new_recovered_lsn;
DBUG_PRINT("ib_log",
- ("scan " DBUG_LSN_PF ": log rec %u len %u "
+ ("scan " LSN_PF ": log rec %u len %u "
"page %u:%u", old_lsn,
(unsigned) type, (unsigned) len,
(unsigned) space, (unsigned) page_no));
@@ -2483,7 +2483,7 @@ loop:
#endif /* UNIV_LOG_DEBUG */
DBUG_PRINT("ib_log",
- ("scan " DBUG_LSN_PF ": multi-log rec %u "
+ ("scan " LSN_PF ": multi-log rec %u "
"len %u page %u:%u",
recv_sys->recovered_lsn,
(unsigned) type, (unsigned) len,
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index ed84834e6ea..03200fee80b 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
@@ -339,21 +339,6 @@ UNIV_INTERN time_t os_last_printout;
UNIV_INTERN ibool os_has_said_disk_full = FALSE;
-#if !defined(UNIV_HOTBACKUP) \
- && (!defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8)
-/** The mutex protecting the following counts of pending I/O operations */
-static os_ib_mutex_t os_file_count_mutex;
-#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */
-
-/** Number of pending os_file_pread() operations */
-UNIV_INTERN ulint os_file_n_pending_preads;
-/** Number of pending os_file_pwrite() operations */
-UNIV_INTERN ulint os_file_n_pending_pwrites;
-/** Number of pending write operations */
-UNIV_INTERN ulint os_n_pending_writes;
-/** Number of pending read operations */
-UNIV_INTERN ulint os_n_pending_reads;
-
#if defined(WIN_ASYNC_IO) || defined(LINUX_NATIVE_AIO)
/** After first fallocate failure we will disable os_file_trim */
static bool os_fallocate_failed;
@@ -1021,10 +1006,6 @@ void
os_io_init_simple(void)
/*===================*/
{
-#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
- os_file_count_mutex = os_mutex_create();
-#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */
-
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
os_file_seek_mutexes[i] = os_mutex_create();
}
@@ -2811,10 +2792,6 @@ os_file_pread(
trx_t* trx)
{
off_t offs;
-#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- ssize_t n_bytes;
- ssize_t n_read;
-#endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
ulint sec;
ulint ms;
ib_uint64_t start_time;
@@ -2844,22 +2821,16 @@ os_file_pread(
} else {
start_time = 0;
}
-#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
-#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
- (void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
- (void) os_atomic_increment_ulint(&os_file_n_pending_preads, 1);
- MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
-#else
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
- os_n_pending_reads++;
- MONITOR_INC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
-#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
+
+ const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
+#ifdef HAVE_PREAD
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
+
+ ssize_t n_bytes;
/* Handle partial reads and signal interruptions correctly */
for (n_bytes = 0; n_bytes < (ssize_t) n; ) {
- n_read = pread(file, buf, (ssize_t)n - n_bytes, offs);
+ ssize_t n_read = pread(file, buf, (ssize_t)n - n_bytes, offs);
if (n_read > 0) {
n_bytes += n_read;
offs += n_read;
@@ -2871,17 +2842,7 @@ os_file_pread(
}
}
-#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
- (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
- (void) os_atomic_decrement_ulint(&os_file_n_pending_preads, 1);
- MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_READS);
-#else
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads--;
- os_n_pending_reads--;
- MONITOR_DEC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
-#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD == 8 */
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
if (UNIV_UNLIKELY(start_time != 0))
{
@@ -2900,15 +2861,7 @@ os_file_pread(
ulint i;
#endif /* !UNIV_HOTBACKUP */
-#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
- (void) os_atomic_increment_ulint(&os_n_pending_reads, 1);
- MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_READS);
-#else
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads++;
- MONITOR_INC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
-#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD == 8 */
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
#ifndef UNIV_HOTBACKUP
/* Protect the seek / read operation with a mutex */
i = ((ulint) file) % OS_FILE_N_SEEK_MUTEXES;
@@ -2938,15 +2891,7 @@ os_file_pread(
os_mutex_exit(os_file_seek_mutexes[i]);
#endif /* !UNIV_HOTBACKUP */
-#if defined(HAVE_ATOMIC_BUILTINS) && UNIV_WORD_SIZE == 8
- (void) os_atomic_decrement_ulint(&os_n_pending_reads, 1);
- MONITOR_ATOIC_DEC(MONITOR_OS_PENDING_READS);
-#else
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- MONITOR_DEC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
-#endif /* HAVE_ATOMIC_BUILTINS && UNIV_WORD_SIZE == 8 */
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
if (UNIV_UNLIKELY(start_time != 0)
{
@@ -2992,18 +2937,9 @@ os_file_pwrite(
os_n_file_writes++;
-#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD)
-#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_pwrites++;
- os_n_pending_writes++;
- MONITOR_INC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
-#else
- (void) os_atomic_increment_ulint(&os_n_pending_writes, 1);
- (void) os_atomic_increment_ulint(&os_file_n_pending_pwrites, 1);
- MONITOR_ATOMIC_INC(MONITOR_OS_PENDING_WRITES);
-#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
+ const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
+#ifdef HAVE_PWRITE
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
/* Handle partial writes and signal interruptions correctly */
for (ret = 0; ret < (ssize_t) n; ) {
@@ -3022,17 +2958,7 @@ os_file_pwrite(
}
}
-#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_pwrites--;
- os_n_pending_writes--;
- MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
-#else
- (void) os_atomic_decrement_ulint(&os_n_pending_writes, 1);
- (void) os_atomic_decrement_ulint(&os_file_n_pending_pwrites, 1);
- MONITOR_ATOMIC_DEC(MONITOR_OS_PENDING_WRITES);
-#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD < 8 */
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
return(ret);
#else
@@ -3042,10 +2968,7 @@ os_file_pwrite(
ulint i;
# endif /* !UNIV_HOTBACKUP */
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_writes++;
- MONITOR_INC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
# ifndef UNIV_HOTBACKUP
/* Protect the seek / write operation with a mutex */
@@ -3079,14 +3002,10 @@ func_exit:
os_mutex_exit(os_file_seek_mutexes[i]);
# endif /* !UNIV_HOTBACKUP */
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_writes--;
- MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
-
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
return(ret);
}
-#endif /* !UNIV_HOTBACKUP */
+#endif /* HAVE_PWRITE */
}
#endif
@@ -3118,15 +3037,13 @@ os_file_read_func(
os_n_file_reads++;
os_bytes_read_since_printout += n;
+ const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
try_again:
ut_ad(buf);
ut_ad(n > 0);
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads++;
- MONITOR_INC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
memset (&overlapped, 0, sizeof (overlapped));
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
@@ -3139,10 +3056,7 @@ try_again:
else if(GetLastError() == ERROR_IO_PENDING) {
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
}
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- MONITOR_DEC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
if (ret && len == n) {
return(TRUE);
@@ -3226,15 +3140,13 @@ os_file_read_no_error_handling_func(
os_n_file_reads++;
os_bytes_read_since_printout += n;
+ const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_READS);
try_again:
ut_ad(buf);
ut_ad(n > 0);
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads++;
- MONITOR_INC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_READS, monitor);
memset (&overlapped, 0, sizeof (overlapped));
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
@@ -3247,10 +3159,7 @@ try_again:
else if(GetLastError() == ERROR_IO_PENDING) {
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
}
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- MONITOR_DEC(MONITOR_OS_PENDING_READS);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor);
if (ret && len == n) {
return(TRUE);
@@ -3344,13 +3253,10 @@ os_file_write_func(
ut_ad(buf);
ut_ad(n > 0);
-
+ const bool monitor = MONITOR_IS_ON(MONITOR_OS_PENDING_WRITES);
retry:
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_writes++;
- MONITOR_INC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_INC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
memset (&overlapped, 0, sizeof (overlapped));
overlapped.Offset = (DWORD)(offset & 0xFFFFFFFF);
@@ -3365,10 +3271,7 @@ retry:
ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE);
}
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_writes--;
- MONITOR_DEC(MONITOR_OS_PENDING_WRITES);
- os_mutex_exit(os_file_count_mutex);
+ MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor);
if (ret && len == n) {
@@ -4463,10 +4366,6 @@ os_aio_free(void)
}
}
-#if !defined(HAVE_ATOMIC_BUILTINS) || UNIV_WORD_SIZE < 8
- os_mutex_free(os_file_count_mutex);
-#endif /* !HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8 */
-
for (ulint i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
os_mutex_free(os_file_seek_mutexes[i]);
}
@@ -6192,19 +6091,24 @@ os_aio_print(
time_elapsed = 0.001 + difftime(current_time, os_last_printout);
fprintf(file,
- "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
- "%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n",
- (ulong) fil_n_pending_log_flushes,
- (ulong) fil_n_pending_tablespace_flushes,
- (ulong) os_n_file_reads,
- (ulong) os_n_file_writes,
- (ulong) os_n_fsyncs);
-
- if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) {
+ "Pending flushes (fsync) log: " ULINTPF
+ "; buffer pool: " ULINTPF "\n"
+ ULINTPF " OS file reads, "
+ ULINTPF " OS file writes, "
+ ULINTPF " OS fsyncs\n",
+ fil_n_pending_log_flushes,
+ fil_n_pending_tablespace_flushes,
+ os_n_file_reads,
+ os_n_file_writes,
+ os_n_fsyncs);
+
+ const ulint n_reads = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS));
+ const ulint n_writes = ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
+
+ if (n_reads != 0 || n_writes != 0) {
fprintf(file,
- "%lu pending preads, %lu pending pwrites\n",
- (ulong) os_file_n_pending_preads,
- (ulong) os_file_n_pending_pwrites);
+ ULINTPF " pending reads, " ULINTPF " pending writes\n",
+ n_reads, n_writes);
}
if (os_n_file_reads == os_n_file_reads_old) {
diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc
index 29ddffd2587..4542aa31a6c 100644
--- a/storage/xtradb/row/row0ftsort.cc
+++ b/storage/xtradb/row/row0ftsort.cc
@@ -1320,10 +1320,9 @@ row_fts_build_sel_tree_level(
int child_left;
int child_right;
ulint i;
- ulint num_item;
+ ulint num_item = ulint(1) << level;
- start = static_cast<ulint>((1 << level) - 1);
- num_item = static_cast<ulint>(1 << level);
+ start = num_item - 1;
for (i = 0; i < num_item; i++) {
child_left = sel_tree[(start + i) * 2 + 1];
@@ -1392,7 +1391,7 @@ row_fts_build_sel_tree(
treelevel++;
}
- start = (1 << treelevel) - 1;
+ start = (ulint(1) << treelevel) - 1;
for (i = 0; i < (int) fts_sort_pll_degree; i++) {
sel_tree[i + start] = i;
diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc
index 6dc01907710..baa7bcbea09 100644
--- a/storage/xtradb/row/row0import.cc
+++ b/storage/xtradb/row/row0import.cc
@@ -583,8 +583,8 @@ AbstractCallback::init(
} else if (!is_compressed_table() && m_page_size != UNIV_PAGE_SIZE) {
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page size %lu of ibd file is not the same "
- "as the server page size %lu",
+ "Page size " ULINTPF " of ibd file is not the same "
+ "as the server page size " ULINTPF,
m_page_size, UNIV_PAGE_SIZE);
return(DB_CORRUPTION);
@@ -593,8 +593,8 @@ AbstractCallback::init(
ib_logf(IB_LOG_LEVEL_ERROR,
"File size " UINT64PF " is not a multiple "
- "of the page size %lu",
- (ib_uint64_t) file_size, (ulong) m_page_size);
+ "of the page size " ULINTPF,
+ (ib_uint64_t) file_size, m_page_size);
return(DB_CORRUPTION);
}
@@ -695,8 +695,8 @@ FetchIndexRootPages::operator() (
if (block->page.offset * m_page_size != offset) {
ib_logf(IB_LOG_LEVEL_ERROR,
"Page offset doesn't match file offset: "
- "page offset: %lu, file offset: %lu",
- (ulint) block->page.offset,
+ "page offset: %u, file offset: " ULINTPF,
+ block->page.offset,
(ulint) (offset / m_page_size));
err = DB_CORRUPTION;
@@ -1134,10 +1134,9 @@ row_import::match_index_columns(
ib_errf(thd, IB_LOG_LEVEL_ERROR,
ER_TABLE_SCHEMA_MISMATCH,
- "Index field count %lu doesn't match"
- " tablespace metadata file value %lu",
- (ulong) index->n_fields,
- (ulong) cfg_index->m_n_fields);
+ "Index field count %u doesn't match"
+ " tablespace metadata file value " ULINTPF,
+ index->n_fields, cfg_index->m_n_fields);
return(DB_ERROR);
}
@@ -1154,34 +1153,31 @@ row_import::match_index_columns(
ER_TABLE_SCHEMA_MISMATCH,
"Index field name %s doesn't match"
" tablespace metadata field name %s"
- " for field position %lu",
- field->name, cfg_field->name, (ulong) i);
+ " for field position " ULINTPF,
+ field->name, cfg_field->name, i);
err = DB_ERROR;
}
if (cfg_field->prefix_len != field->prefix_len) {
ib_errf(thd, IB_LOG_LEVEL_ERROR,
- ER_TABLE_SCHEMA_MISMATCH,
- "Index %s field %s prefix len %lu"
- " doesn't match metadata file value"
- " %lu",
- index->name, field->name,
- (ulong) field->prefix_len,
- (ulong) cfg_field->prefix_len);
+ ER_TABLE_SCHEMA_MISMATCH,
+ "Index %s field %s prefix len %u"
+ " doesn't match metadata file value %u",
+ index->name, field->name,
+ field->prefix_len, cfg_field->prefix_len);
err = DB_ERROR;
}
if (cfg_field->fixed_len != field->fixed_len) {
ib_errf(thd, IB_LOG_LEVEL_ERROR,
- ER_TABLE_SCHEMA_MISMATCH,
- "Index %s field %s fixed len %lu"
- " doesn't match metadata file value"
- " %lu",
- index->name, field->name,
- (ulong) field->fixed_len,
- (ulong) cfg_field->fixed_len);
+ ER_TABLE_SCHEMA_MISMATCH,
+ "Index %s field %s fixed len %u"
+ " doesn't match metadata file value %u",
+ index->name, field->name,
+ field->fixed_len,
+ cfg_field->fixed_len);
err = DB_ERROR;
}
@@ -1223,12 +1219,11 @@ row_import::match_table_columns(
} else if (cfg_col_index != col->ind) {
ib_errf(thd, IB_LOG_LEVEL_ERROR,
- ER_TABLE_SCHEMA_MISMATCH,
- "Column %s ordinal value mismatch, it's at "
- "%lu in the table and %lu in the tablespace "
- "meta-data file",
- col_name,
- (ulong) col->ind, (ulong) cfg_col_index);
+ ER_TABLE_SCHEMA_MISMATCH,
+ "Column %s ordinal value mismatch, it's at %u"
+ " in the table and " ULINTPF
+ " in the tablespace meta-data file",
+ col_name, col->ind, cfg_col_index);
err = DB_ERROR;
} else {
@@ -1310,23 +1305,20 @@ row_import::match_schema(
THD* thd) UNIV_NOTHROW
{
/* Do some simple checks. */
- const unsigned relevant_flags = m_flags & ~DICT_TF_MASK_DATA_DIR;
- const unsigned relevant_table_flags
- = m_table->flags & ~DICT_TF_MASK_DATA_DIR;
- if (relevant_flags != relevant_table_flags) {
+ if ((m_table->flags ^ m_flags) & ~DICT_TF_MASK_DATA_DIR) {
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH,
- "Table flags don't match, server table has 0x%x "
- "and the meta-data file has 0x%x",
- relevant_table_flags, relevant_flags);
+ "Table flags don't match, server table has 0x%x"
+ " and the meta-data file has 0x%lx",
+ m_table->flags, ulong(m_flags));
return(DB_ERROR);
} else if (m_table->n_cols != m_n_cols) {
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH,
- "Number of columns don't match, table has %lu "
- "columns but the tablespace meta-data file has "
- "%lu columns",
- (ulong) m_table->n_cols, (ulong) m_n_cols);
+ "Number of columns don't match, table has %u "
+ "columns but the tablespace meta-data file has "
+ ULINTPF " columns",
+ m_table->n_cols, m_n_cols);
return(DB_ERROR);
} else if (UT_LIST_GET_LEN(m_table->indexes) != m_n_indexes) {
@@ -1336,11 +1328,10 @@ row_import::match_schema(
table matching the IMPORT definition. */
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH,
- "Number of indexes don't match, table has %lu "
- "indexes but the tablespace meta-data file has "
- "%lu indexes",
- (ulong) UT_LIST_GET_LEN(m_table->indexes),
- (ulong) m_n_indexes);
+ "Number of indexes don't match, table has " ULINTPF
+ " indexes but the tablespace meta-data file has "
+ ULINTPF " indexes",
+ UT_LIST_GET_LEN(m_table->indexes), m_n_indexes);
return(DB_ERROR);
}
@@ -1416,8 +1407,8 @@ row_import::set_root_by_heuristic() UNIV_NOTHROW
table_name, sizeof(table_name), m_table->name, FALSE);
ib_logf(IB_LOG_LEVEL_WARN,
- "Table %s should have %lu indexes but the tablespace "
- "has %lu indexes",
+ "Table %s should have " ULINTPF
+ " indexes but the tablespace has " ULINTPF " indexes",
table_name,
UT_LIST_GET_LEN(m_table->indexes),
m_n_indexes);
@@ -1655,9 +1646,10 @@ PageConverter::adjust_cluster_index_blob_column(
ib_errf(m_trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_INNODB_INDEX_CORRUPT,
- "Externally stored column(%lu) has a reference "
- "length of %lu in the cluster index %s",
- (ulong) i, (ulong) len, index_name);
+ "Externally stored column(" ULINTPF
+ ") has a reference length of " ULINTPF
+ " in the cluster index %s",
+ i, len, index_name);
return(DB_CORRUPTION);
}
@@ -2021,7 +2013,8 @@ PageConverter::update_page(
return(err);
}
- ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (%lu)", page_type);
+ ib_logf(IB_LOG_LEVEL_WARN, "Unknown page type (" ULINTPF ")",
+ page_type);
return(DB_CORRUPTION);
}
@@ -2058,7 +2051,8 @@ PageConverter::validate(
if (checksum != 0) {
/* Checksum check passed in buf_page_is_corrupted(). */
ib_logf(IB_LOG_LEVEL_WARN,
- "%s: Page %lu checksum %lu should be zero.",
+ "%s: Page %lu checksum " ULINTPF
+ " should be zero.",
m_filepath, (ulong) (offset / m_page_size),
checksum);
}
@@ -2372,11 +2366,10 @@ row_import_adjust_root_pages_of_secondary_indexes(
ib_errf(trx->mysql_thd,
IB_LOG_LEVEL_WARN,
ER_INNODB_INDEX_CORRUPT,
- "Index '%s' contains %lu entries, "
- "should be %lu, you should recreate "
+ "Index '%s' contains " ULINTPF " entries, "
+ "should be " ULINTPF ", you should recreate "
"this index.", index_name,
- (ulong) purge.get_n_rows(),
- (ulong) n_rows_in_table);
+ purge.get_n_rows(), n_rows_in_table);
index->type |= DICT_CORRUPT;
@@ -2727,7 +2720,7 @@ row_import_read_index_data(
if (len > OS_FILE_MAX_PATH) {
ib_errf(thd, IB_LOG_LEVEL_ERROR,
ER_INNODB_INDEX_CORRUPT,
- "Index name length (%lu) is too long, "
+ "Index name length (" ULINTPF ") is too long, "
"the meta-data is corrupt", len);
return(DB_CORRUPTION);
@@ -2808,8 +2801,8 @@ row_import_read_indexes(
} else if (cfg->m_n_indexes > 1024) {
// FIXME: What is the upper limit? */
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR,
- "Number of indexes in meta-data file is too high: %lu",
- (ulong) cfg->m_n_indexes);
+ "Number of indexes in meta-data file is too high: "
+ ULINTPF, cfg->m_n_indexes);
cfg->m_n_indexes = 0;
return(DB_CORRUPTION);
@@ -2907,8 +2900,8 @@ row_import_read_columns(
if (len == 0 || len > 128) {
ib_errf(thd, IB_LOG_LEVEL_ERROR,
ER_IO_READ_ERROR,
- "Column name length %lu, is invalid",
- (ulong) len);
+ "Column name length " ULINTPF ", is invalid",
+ len);
return(DB_CORRUPTION);
}
@@ -3079,8 +3072,9 @@ row_import_read_v1(
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH,
"Tablespace to be imported has a different "
"page size than this server. Server page size "
- "is %lu, whereas tablespace page size is %lu",
- UNIV_PAGE_SIZE, (ulong) cfg->m_page_size);
+ "is " ULINTPF ", whereas tablespace page size is "
+ ULINTPF,
+ UNIV_PAGE_SIZE, cfg->m_page_size);
return(DB_ERROR);
}
@@ -3145,8 +3139,8 @@ row_import_read_meta_data(
return(row_import_read_v1(file, thd, &cfg));
default:
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR,
- "Unsupported meta-data version number (%lu), "
- "file ignored", (ulong) cfg.m_version);
+ "Unsupported meta-data version number (" ULINTPF "), "
+ "file ignored", cfg.m_version);
}
return(DB_ERROR);
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index 72be305d481..24cd9687a47 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2014, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -26,6 +26,7 @@ Completed by Sunny Bains and Marko Makela
*******************************************************/
#include <my_config.h>
#include <log.h>
+#include <sql_class.h>
#include "row0merge.h"
#include "row0ext.h"
@@ -188,7 +189,8 @@ row_merge_tuple_print(
}
ut_print_buf(f, dfield_get_data(field), len);
if (len != field_len) {
- fprintf(f, " (total %lu bytes)", field_len);
+ fprintf(f, " (total " ULINTPF " bytes)",
+ field_len);
}
}
}
@@ -881,9 +883,9 @@ row_merge_buf_write(
ut_ad(b < &block[srv_sort_buf_size]);
#ifdef UNIV_DEBUG
if (row_merge_print_write) {
- fprintf(stderr, "row_merge_buf_write %p,%d,%lu %lu",
- (void*) b, of->fd, (ulong) of->offset,
- (ulong) i);
+ fprintf(stderr, "row_merge_buf_write %p,%d,"
+ ULINTPF " " ULINTPF,
+ (void*) b, of->fd, of->offset, i);
row_merge_tuple_print(stderr, entry, n_fields);
}
#endif /* UNIV_DEBUG */
@@ -900,8 +902,8 @@ row_merge_buf_write(
#endif /* UNIV_DEBUG_VALGRIND */
#ifdef UNIV_DEBUG
if (row_merge_print_write) {
- fprintf(stderr, "row_merge_buf_write %p,%d,%lu EOF\n",
- (void*) b, of->fd, (ulong) of->offset);
+ fprintf(stderr, "row_merge_buf_write %p,%d," ULINTPF " EOF\n",
+ (void*) b, of->fd, of->offset);
}
#endif /* UNIV_DEBUG */
}
@@ -960,15 +962,8 @@ row_merge_read(
#ifdef UNIV_DEBUG
if (row_merge_print_block_read) {
- fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n",
- fd, (ulong) offset);
- }
-#endif /* UNIV_DEBUG */
-
-#ifdef UNIV_DEBUG
- if (row_merge_print_block_read) {
- fprintf(stderr, "row_merge_read fd=%d ofs=%lu\n",
- fd, (ulong) offset);
+ fprintf(stderr, "row_merge_read fd=%d ofs=" ULINTPF "\n",
+ fd, offset);
}
#endif /* UNIV_DEBUG */
@@ -1032,8 +1027,8 @@ row_merge_write(
#ifdef UNIV_DEBUG
if (row_merge_print_block_write) {
- fprintf(stderr, "row_merge_write fd=%d ofs=%lu\n",
- fd, (ulong) offset);
+ fprintf(stderr, "row_merge_write fd=%d ofs=" ULINTPF "\n",
+ fd, offset);
}
#endif /* UNIV_DEBUG */
@@ -1088,9 +1083,10 @@ row_merge_read_rec(
*mrec = NULL;
#ifdef UNIV_DEBUG
if (row_merge_print_read) {
- fprintf(stderr, "row_merge_read %p,%p,%d,%lu EOF\n",
+ fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF
+ " EOF\n",
(const void*) b, (const void*) block,
- fd, (ulong) *foffs);
+ fd, *foffs);
}
#endif /* UNIV_DEBUG */
return(NULL);
@@ -1208,9 +1204,9 @@ err_exit:
func_exit:
#ifdef UNIV_DEBUG
if (row_merge_print_read) {
- fprintf(stderr, "row_merge_read %p,%p,%d,%lu ",
+ fprintf(stderr, "row_merge_read %p,%p,%d," ULINTPF " ",
(const void*) b, (const void*) block,
- fd, (ulong) *foffs);
+ fd, *foffs);
rec_print_comp(stderr, *mrec, offsets);
putc('\n', stderr);
}
@@ -1244,8 +1240,8 @@ row_merge_write_rec_low(
ut_ad(e == rec_offs_extra_size(offsets) + 1);
if (row_merge_print_write) {
- fprintf(stderr, "row_merge_write %p,%d,%lu ",
- (void*) b, fd, (ulong) foffs);
+ fprintf(stderr, "row_merge_write %p,%d," ULINTPF " ",
+ (void*) b, fd, foffs);
rec_print_comp(stderr, mrec, offsets);
putc('\n', stderr);
}
@@ -1358,8 +1354,8 @@ row_merge_write_eof(
ut_ad(foffs);
#ifdef UNIV_DEBUG
if (row_merge_print_write) {
- fprintf(stderr, "row_merge_write %p,%p,%d,%lu EOF\n",
- (void*) b, (void*) block, fd, (ulong) *foffs);
+ fprintf(stderr, "row_merge_write %p,%p,%d," ULINTPF " EOF\n",
+ (void*) b, (void*) block, fd, *foffs);
}
#endif /* UNIV_DEBUG */
@@ -2258,11 +2254,12 @@ row_merge_blocks(
#ifdef UNIV_DEBUG
if (row_merge_print_block) {
fprintf(stderr,
- "row_merge_blocks fd=%d ofs=%lu + fd=%d ofs=%lu"
- " = fd=%d ofs=%lu\n",
- file->fd, (ulong) *foffs0,
- file->fd, (ulong) *foffs1,
- of->fd, (ulong) of->offset);
+ "row_merge_blocks fd=%d ofs=" ULINTPF
+ " + fd=%d ofs=" ULINTPF
+ " = fd=%d ofs=" ULINTPF "\n",
+ file->fd, *foffs0,
+ file->fd, *foffs1,
+ of->fd, of->offset);
}
#endif /* UNIV_DEBUG */
@@ -2373,10 +2370,10 @@ row_merge_blocks_copy(
#ifdef UNIV_DEBUG
if (row_merge_print_block) {
fprintf(stderr,
- "row_merge_blocks_copy fd=%d ofs=%lu"
- " = fd=%d ofs=%lu\n",
- file->fd, (ulong) foffs0,
- of->fd, (ulong) of->offset);
+ "row_merge_blocks_copy fd=%d ofs=" ULINTPF
+ " = fd=%d ofs=" ULINTPF "\n",
+ file->fd, *foffs0,
+ of->fd, of->offset);
}
#endif /* UNIV_DEBUG */
@@ -2635,7 +2632,11 @@ row_merge_sort(
thd_progress_init(trx->mysql_thd, 1);
}
- sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : merge-sorting"
+ " has estimated " ULINTPF " runs",
+ num_runs);
+ }
/* Merge the runs until we have one big run */
do {
@@ -4060,9 +4061,11 @@ row_merge_build_indexes(
duplicate keys. */
innobase_rec_reset(table);
- sql_print_information("InnoDB: Online DDL : Start");
- sql_print_information("InnoDB: Online DDL : Start reading clustered "
- "index of the table and create temporary files");
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : Start reading"
+ " clustered index of the table"
+ " and create temporary files");
+ }
pct_cost = COST_READ_CLUSTERED_INDEX * 100 / (total_static_cost + total_dynamic_cost);
@@ -4089,8 +4092,11 @@ row_merge_build_indexes(
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : End of reading "
- "clustered index of the table and create temporary files");
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL : End of reading "
+ "clustered index of the table"
+ " and create temporary files");
+ }
for (i = 0; i < n_indexes; i++) {
total_index_blocks += merge_files[i].offset;
@@ -4186,8 +4192,7 @@ wait_again:
DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n");
#endif
} else if (merge_files[i].fd != -1) {
- char buf[3 * NAME_LEN];
- char *bufend;
+ char buf[NAME_LEN + 1];
row_merge_dup_t dup = {
sort_idx, table, col_map, 0};
@@ -4196,18 +4201,25 @@ wait_again:
total_index_blocks)) /
(total_static_cost + total_dynamic_cost)
* PCT_COST_MERGESORT_INDEX * 100;
-
- bufend = innobase_convert_name(
+ char* bufend = innobase_convert_name(
buf, sizeof buf,
- indexes[i]->name, strlen(indexes[i]->name),
+ indexes[i]->name,
+ strlen(indexes[i]->name),
trx->mysql_thd,
FALSE);
-
buf[bufend - buf]='\0';
- sql_print_information("InnoDB: Online DDL : Start merge-sorting"
- " index %s (%lu / %lu), estimated cost : %2.4f",
- buf, (i+1), n_indexes, pct_cost);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL :"
+ " Start merge-sorting"
+ " index %s"
+ " (" ULINTPF
+ " / " ULINTPF "),"
+ " estimated cost :"
+ " %2.4f",
+ buf, i + 1, n_indexes,
+ pct_cost);
+ }
error = row_merge_sort(
trx, &dup, &merge_files[i],
@@ -4217,9 +4229,14 @@ wait_again:
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : End of "
- " merge-sorting index %s (%lu / %lu)",
- buf, (i+1), n_indexes);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information("InnoDB: Online DDL :"
+ " End of "
+ " merge-sorting index %s"
+ " (" ULINTPF
+ " / " ULINTPF ")",
+ buf, i + 1, n_indexes);
+ }
DBUG_EXECUTE_IF(
"ib_merge_wait_after_sort",
@@ -4232,10 +4249,15 @@ wait_again:
(total_static_cost + total_dynamic_cost) *
PCT_COST_INSERT_INDEX * 100;
- sql_print_information("InnoDB: Online DDL : Start "
- "building index %s (%lu / %lu), estimated "
- "cost : %2.4f", buf, (i+1),
- n_indexes, pct_cost);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : Start "
+ "building index %s"
+ " (" ULINTPF
+ " / " ULINTPF "), estimated "
+ "cost : %2.4f", buf, i + 1,
+ n_indexes, pct_cost);
+ }
error = row_merge_insert_index_tuples(
trx->id, sort_idx, old_table,
@@ -4244,9 +4266,13 @@ wait_again:
crypt_data, crypt_block, new_table->space);
pct_progress += pct_cost;
- sql_print_information("InnoDB: Online DDL : "
- "End of building index %s (%lu / %lu)",
- buf, (i+1), n_indexes);
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : "
+ "End of building index %s"
+ " (" ULINTPF " / " ULINTPF ")",
+ buf, i + 1, n_indexes);
+ }
}
}
@@ -4263,15 +4289,16 @@ wait_again:
ut_ad(sort_idx->online_status
== ONLINE_INDEX_COMPLETE);
} else {
- sql_print_information("InnoDB: Online DDL : Start applying row log");
+ if (global_system_variables.log_warnings > 2) {
+ sql_print_information(
+ "InnoDB: Online DDL : Applying"
+ " log to index");
+ }
DEBUG_SYNC_C("row_log_apply_before");
error = row_log_apply(trx, sort_idx, table);
DEBUG_SYNC_C("row_log_apply_after");
- sql_print_information("InnoDB: Online DDL : End of applying row log");
}
- sql_print_information("InnoDB: Online DDL : Completed");
-
if (error != DB_SUCCESS) {
trx->error_key_num = key_numbers[i];
goto func_exit;
diff --git a/storage/xtradb/srv/srv0mon.cc b/storage/xtradb/srv/srv0mon.cc
index 7c2e549e188..47abae66192 100644
--- a/storage/xtradb/srv/srv0mon.cc
+++ b/storage/xtradb/srv/srv0mon.cc
@@ -2,7 +2,7 @@
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2016, MariaDB Corporation.
+Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -690,11 +690,11 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
{"os_pending_reads", "os", "Number of reads pending",
- MONITOR_NONE,
+ MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
{"os_pending_writes", "os", "Number of writes pending",
- MONITOR_NONE,
+ MONITOR_DEFAULT_ON,
MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
{"os_log_bytes_written", "os",
diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc
index f8c8c330f0c..1c40baee04b 100644
--- a/storage/xtradb/srv/srv0srv.cc
+++ b/storage/xtradb/srv/srv0srv.cc
@@ -1814,10 +1814,10 @@ srv_export_innodb_status(void)
mutex_enter(&srv_innodb_monitor_mutex);
export_vars.innodb_data_pending_reads =
- os_n_pending_reads;
+ ulint(MONITOR_VALUE(MONITOR_OS_PENDING_READS));
export_vars.innodb_data_pending_writes =
- os_n_pending_writes;
+ ulint(MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
export_vars.innodb_data_pending_fsyncs =
fil_n_pending_log_flushes
diff --git a/storage/xtradb/sync/sync0arr.cc b/storage/xtradb/sync/sync0arr.cc
index c311d2cbd7d..134d16ae58e 100644
--- a/storage/xtradb/sync/sync0arr.cc
+++ b/storage/xtradb/sync/sync0arr.cc
@@ -522,13 +522,14 @@ sync_array_cell_print(
if (mutex) {
fprintf(file,
"Mutex at %p '%s', lock var %lu\n"
- "Last time reserved by thread %lu in file %s line %lu, "
- "waiters flag %lu\n",
+ "Last time reserved by thread " ULINTPF
+ " in file %s line " ULINTPF ", "
+ "waiters flag " ULINTPF "\n",
(void*) mutex, mutex->cmutex_name,
(ulong) mutex->lock_word,
- mutex->thread_id,
- mutex->file_name, (ulong) mutex->line,
- (ulong) mutex->waiters);
+ os_thread_pf(mutex->thread_id),
+ mutex->file_name, mutex->line,
+ mutex->waiters);
}
/* If stacktrace feature is enabled we will send a SIGUSR2
@@ -582,9 +583,9 @@ sync_array_cell_print(
if (writer && writer != RW_LOCK_NOT_LOCKED) {
fprintf(file,
- "a writer (thread id %lu) has"
+ "a writer (thread id " ULINTPF ") has"
" reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
+ os_thread_pf(rwlock->writer_thread),
writer == RW_LOCK_EX
? " exclusive\n"
: " wait exclusive\n");
@@ -593,21 +594,23 @@ sync_array_cell_print(
}
fprintf(file,
- "number of readers %lu, waiters flag %lu, "
+ "number of readers " ULINTPF
+ ", waiters flag " ULINTPF ", "
"lock_word: %lx\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rw_lock_get_reader_count(rwlock),
- (ulong) rwlock->waiters,
+ "Last time read locked in file %s line %u\n"
+ "Last time write locked in file %s line %u\n"
+ "Holder thread " ULINTPF
+ " file %s line " ULINTPF "\n",
+ rw_lock_get_reader_count(rwlock),
+ rwlock->waiters,
rwlock->lock_word,
innobase_basename(rwlock->last_s_file_name),
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
- (ulong) rwlock->last_x_line);
-
- fprintf(file,
- "Holder thread %lu file %s line %lu\n",
- rwlock->thread_id, rwlock->file_name, rwlock->line);
+ rwlock->last_s_line,
+ innobase_basename(rwlock->last_x_file_name),
+ rwlock->last_x_line,
+ os_thread_pf(rwlock->thread_id),
+ innobase_basename(rwlock->file_name),
+ rwlock->line);
/* If stacktrace feature is enabled we will send a SIGUSR2
signal to thread that has locked RW-latch with write mode.
@@ -1175,9 +1178,10 @@ sync_array_print_long_waits(
now the values of pending calls of these. */
fprintf(stderr,
- "InnoDB: Pending preads %lu, pwrites %lu\n",
- (ulong) os_file_n_pending_preads,
- (ulong) os_file_n_pending_pwrites);
+ "InnoDB: Pending reads " UINT64PF
+ ", writes " UINT64PF "\n",
+ MONITOR_VALUE(MONITOR_OS_PENDING_READS),
+ MONITOR_VALUE(MONITOR_OS_PENDING_WRITES));
srv_print_innodb_monitor = TRUE;
os_event_set(srv_monitor_event);
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index 439897a5b96..92d7525ea84 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -2161,6 +2161,118 @@ trx_print_latched(
mem_heap_get_size(trx->lock.lock_heap));
}
+#ifdef WITH_WSREP
+/**********************************************************************//**
+Prints info about a transaction.
+Transaction information may be retrieved without having trx_sys->mutex acquired
+so it may not be completely accurate. The caller must own lock_sys->mutex
+and the trx must have some locks to make sure that it does not escape
+without locking lock_sys->mutex. */
+UNIV_INTERN
+void
+wsrep_trx_print_locking(
+/*==========*/
+ FILE* f,
+ /*!< in: output stream */
+ const trx_t* trx,
+ /*!< in: transaction */
+ ulint max_query_len)
+ /*!< in: max query length to print,
+ or 0 to use the default max length */
+{
+ ibool newline;
+ const char* op_info;
+
+ ut_ad(lock_mutex_own());
+ ut_ad(trx->lock.trx_locks.count > 0);
+
+ fprintf(f, "TRANSACTION " TRX_ID_FMT, trx->id);
+
+ /* trx->state may change since trx_sys->mutex is not required */
+ switch (trx->state) {
+ case TRX_STATE_NOT_STARTED:
+ fputs(", not started", f);
+ goto state_ok;
+ case TRX_STATE_ACTIVE:
+ fprintf(f, ", ACTIVE %lu sec",
+ (ulong) difftime(time(NULL), trx->start_time));
+ goto state_ok;
+ case TRX_STATE_PREPARED:
+ fprintf(f, ", ACTIVE (PREPARED) %lu sec",
+ (ulong) difftime(time(NULL), trx->start_time));
+ goto state_ok;
+ case TRX_STATE_COMMITTED_IN_MEMORY:
+ fputs(", COMMITTED IN MEMORY", f);
+ goto state_ok;
+ }
+ fprintf(f, ", state %lu", (ulong) trx->state);
+ ut_ad(0);
+state_ok:
+
+ /* prevent a race condition */
+ op_info = trx->op_info;
+
+ if (*op_info) {
+ putc(' ', f);
+ fputs(op_info, f);
+ }
+
+ if (trx->is_recovered) {
+ fputs(" recovered trx", f);
+ }
+
+ if (trx->declared_to_be_inside_innodb) {
+ fprintf(f, ", thread declared inside InnoDB %lu",
+ (ulong) trx->n_tickets_to_enter_innodb);
+ }
+
+ putc('\n', f);
+
+ if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) {
+ fprintf(f, "mysql tables in use %lu, locked %lu\n",
+ (ulong) trx->n_mysql_tables_in_use,
+ (ulong) trx->mysql_n_tables_locked);
+ }
+
+ newline = TRUE;
+
+ /* trx->lock.que_state of an ACTIVE transaction may change
+ while we are not holding trx->mutex. We perform a dirty read
+ for performance reasons. */
+
+ switch (trx->lock.que_state) {
+ case TRX_QUE_RUNNING:
+ newline = FALSE; break;
+ case TRX_QUE_LOCK_WAIT:
+ fputs("LOCK WAIT ", f); break;
+ case TRX_QUE_ROLLING_BACK:
+ fputs("ROLLING BACK ", f); break;
+ case TRX_QUE_COMMITTING:
+ fputs("COMMITTING ", f); break;
+ default:
+ fprintf(f, "que state %lu ", (ulong) trx->lock.que_state);
+ }
+
+ if (trx->has_search_latch) {
+ newline = TRUE;
+ fputs(", holds adaptive hash latch", f);
+ }
+
+ if (trx->undo_no != 0) {
+ newline = TRUE;
+ fprintf(f, ", undo log entries " TRX_ID_FMT, trx->undo_no);
+ }
+
+ if (newline) {
+ putc('\n', f);
+ }
+
+ if (trx->mysql_thd != NULL) {
+ innobase_mysql_print_thd(
+ f, trx->mysql_thd, static_cast<uint>(max_query_len));
+ }
+}
+#endif /* WITH_WSREP */
/**********************************************************************//**
Prints info about a transaction.
Acquires and releases lock_sys->mutex and trx_sys->mutex. */
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 5eda81d96c5..0e2a17b0ae0 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1248,6 +1248,7 @@ static int handle_match(json_engine_t *je, json_path_t *p,
if (++next_step > p->last_step)
{
je->s.c_str= je->value_begin;
+ je->stack_p--;
return 1;
}
} while (next_step->type == JSON_PATH_ARRAY && next_step->n_item == 0);