summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzr-mysql/default.conf2
-rw-r--r--.bzrignore1
-rw-r--r--BUILD/FINISH.sh1
-rw-r--r--BUILD/Makefile.am2
-rwxr-xr-xBUILD/SETUP.sh30
-rwxr-xr-xBUILD/autorun.sh4
-rw-r--r--BUILD/cmake_configure.sh (renamed from BUILD/choose_configure.sh)0
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile.am2
-rw-r--r--client/Makefile.am1
-rw-r--r--client/mysql.cc4
-rw-r--r--client/mysqltest.cc13
-rw-r--r--cmake/os/WindowsCache.cmake12
-rw-r--r--config.h.cmake39
-rw-r--r--config/ac-macros/character_sets.m43
-rw-r--r--configure.cmake45
-rw-r--r--configure.in9
-rw-r--r--extra/replace.c7
-rw-r--r--extra/resolve_stack_dump.c1
-rw-r--r--extra/yassl/CMakeLists.txt7
-rw-r--r--extra/yassl/taocrypt/CMakeLists.txt6
-rw-r--r--include/Makefile.am6
-rw-r--r--include/atomic/gcc_builtins.h5
-rw-r--r--include/atomic/nolock.h17
-rw-r--r--include/atomic/solaris.h8
-rw-r--r--include/atomic/x86-gcc.h41
-rw-r--r--include/config-win.h441
-rw-r--r--include/lf.h5
-rw-r--r--include/m_string.h38
-rw-r--r--include/my_atomic.h35
-rw-r--r--include/my_attribute.h6
-rw-r--r--include/my_bit.h21
-rw-r--r--include/my_bitmap.h22
-rw-r--r--include/my_global.h257
-rw-r--r--include/my_net.h7
-rw-r--r--include/my_nosys.h2
-rw-r--r--include/my_sys.h23
-rw-r--r--include/my_trie.h141
-rw-r--r--include/my_vle.h38
-rw-r--r--include/myisam.h5
-rw-r--r--include/mysql_embed.h2
-rw-r--r--include/thr_lock.h19
-rw-r--r--libmysql/Makefile.am8
-rw-r--r--libmysql/Makefile.shared7
-rw-r--r--libmysql/dll.c107
-rw-r--r--libmysql/errmsg.c134
-rw-r--r--libmysql/libmysql.c7
-rw-r--r--libmysql_r/Makefile.am3
-rw-r--r--libmysqld/CMakeLists.txt2
-rw-r--r--libmysqld/Makefile.am2
-rw-r--r--mysql-test/collections/default.experimental2
-rw-r--r--mysql-test/include/handler.inc32
-rwxr-xr-xmysql-test/lib/v1/mysql-test-run.pl1
-rw-r--r--mysql-test/r/alter_table.result13
-rw-r--r--mysql-test/r/archive.result26
-rw-r--r--mysql-test/r/handler_innodb.result20
-rw-r--r--mysql-test/r/handler_myisam.result20
-rw-r--r--mysql-test/r/heap_hash.result11
-rw-r--r--mysql-test/r/innodb_mysql_lock.result32
-rw-r--r--mysql-test/r/innodb_mysql_sync.result18
-rw-r--r--mysql-test/r/mdl_sync.result237
-rw-r--r--mysql-test/r/merge.result840
-rw-r--r--mysql-test/r/merge_mmap.result190
-rw-r--r--mysql-test/r/partition_debug_sync.result2
-rw-r--r--mysql-test/r/raid.result208
-rw-r--r--mysql-test/r/schema.result51
-rw-r--r--mysql-test/r/show_check.result48
-rw-r--r--mysql-test/r/signal.result41
-rw-r--r--mysql-test/r/signal_demo3.result18
-rw-r--r--mysql-test/r/sp-big.result2
-rw-r--r--mysql-test/r/sp-bugs.result2
-rw-r--r--mysql-test/r/sp-code.result57
-rw-r--r--mysql-test/r/sp-error.result247
-rw-r--r--mysql-test/r/sp.result176
-rw-r--r--mysql-test/r/sp_trans.result4
-rw-r--r--mysql-test/r/strict.result2
-rw-r--r--mysql-test/r/temp_table.result12
-rw-r--r--mysql-test/r/variables.result22
-rw-r--r--mysql-test/r/view.result8
-rw-r--r--mysql-test/suite/federated/federated_server.result8
-rw-r--r--mysql-test/suite/federated/federated_server.test8
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_storedproc_02.result44
-rw-r--r--mysql-test/suite/funcs_1/r/memory_storedproc_02.result44
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_storedproc_02.result44
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result76
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug52199.result5
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug54679.result88
-rw-r--r--mysql-test/suite/innodb/r/innodb_information_schema.result16
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug52199.test7
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug54679.test101
-rw-r--r--mysql-test/suite/perfschema/include/upgrade_check.inc29
-rw-r--r--mysql-test/suite/perfschema/r/query_cache.result1
-rw-r--r--mysql-test/suite/perfschema/r/selects.result15
-rw-r--r--mysql-test/suite/perfschema/r/server_init.result12
-rw-r--r--mysql-test/suite/perfschema/t/bad_option_1.test12
-rw-r--r--mysql-test/suite/perfschema/t/bad_option_2.test12
-rw-r--r--mysql-test/suite/perfschema/t/global_read_lock.test1
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade.test53
-rw-r--r--mysql-test/suite/perfschema/t/privilege.test4
-rw-r--r--mysql-test/suite/perfschema/t/query_cache.test8
-rw-r--r--mysql-test/suite/perfschema/t/read_only.test1
-rw-r--r--mysql-test/suite/perfschema/t/selects-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/selects.test43
-rw-r--r--mysql-test/suite/perfschema/t/server_init.test9
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_sp005.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_trig003.result6
-rw-r--r--mysql-test/suite/rpl/t/rpl_sync-slave.opt2
-rw-r--r--mysql-test/t/alter_table.test16
-rw-r--r--mysql-test/t/archive.test21
-rw-r--r--mysql-test/t/heap_hash.test17
-rw-r--r--mysql-test/t/innodb_mysql_lock.test68
-rw-r--r--mysql-test/t/innodb_mysql_sync.test26
-rw-r--r--mysql-test/t/mdl_sync.test475
-rw-r--r--mysql-test/t/merge-big.test4
-rw-r--r--mysql-test/t/merge.test454
-rw-r--r--mysql-test/t/merge_mmap-master.opt1
-rw-r--r--mysql-test/t/merge_mmap.test151
-rw-r--r--mysql-test/t/partition_debug_sync.test2
-rw-r--r--mysql-test/t/schema.test99
-rw-r--r--mysql-test/t/show_check.test81
-rw-r--r--mysql-test/t/signal.test5
-rw-r--r--mysql-test/t/sp-code.test53
-rw-r--r--mysql-test/t/sp-error.test270
-rw-r--r--mysql-test/t/sp.test35
-rw-r--r--mysql-test/t/temp_table.test15
-rw-r--r--mysql-test/t/variables.test26
-rw-r--r--mysys/CMakeLists.txt25
-rw-r--r--mysys/Makefile.am18
-rw-r--r--mysys/checksum.c7
-rw-r--r--mysys/default.c2
-rw-r--r--mysys/default_modify.c252
-rw-r--r--mysys/lf_alloc-pin.c6
-rw-r--r--mysys/lf_hash.c2
-rw-r--r--mysys/make-conf.c71
-rw-r--r--mysys/mf_iocache.c53
-rw-r--r--mysys/mf_iocache2.c11
-rw-r--r--mysys/mf_keycache.c15
-rw-r--r--mysys/mf_wfile.c123
-rw-r--r--mysys/my_append.c64
-rw-r--r--mysys/my_atomic.c7
-rw-r--r--mysys/my_bit.c7
-rw-r--r--mysys/my_bitmap.c186
-rw-r--r--mysys/my_clock.c32
-rw-r--r--mysys/my_dup.c41
-rw-r--r--mysys/my_handler.c2
-rw-r--r--mysys/my_init.c6
-rw-r--r--mysys/my_net.c42
-rw-r--r--mysys/my_pthread.c6
-rw-r--r--mysys/my_static.c3
-rw-r--r--mysys/my_static.h6
-rw-r--r--mysys/my_vle.c109
-rw-r--r--mysys/rijndael.c16
-rw-r--r--mysys/test_charset.c10
-rw-r--r--mysys/test_fn.c69
-rw-r--r--mysys/thr_alarm.c5
-rw-r--r--mysys/thr_lock.c51
-rw-r--r--mysys/trie.c236
-rw-r--r--packaging/Makefile.am14
-rw-r--r--packaging/WiX/CMakeLists.txt42
-rw-r--r--packaging/WiX/CPackWixConfig.cmake2
-rw-r--r--packaging/WiX/create_msi.cmake.in24
-rw-r--r--packaging/WiX/custom_ui.wxs81
-rw-r--r--packaging/WiX/extra.wxs.in6
-rw-r--r--packaging/WiX/mysql_server.wxs.in59
-rw-r--r--regex/regcomp.c72
-rw-r--r--regex/regcomp.ih5
-rwxr-xr-xscripts/make_win_bin_dist1
-rw-r--r--sql/CMakeLists.txt17
-rw-r--r--sql/Makefile.am7
-rw-r--r--sql/event_data_objects.cc18
-rw-r--r--sql/event_db_repository.cc74
-rw-r--r--sql/event_db_repository.h5
-rw-r--r--sql/events.cc14
-rw-r--r--sql/field.cc93
-rw-r--r--sql/field.h11
-rw-r--r--sql/field_conv.cc2
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/gen_lex_hash.cc85
-rw-r--r--sql/ha_ndbcluster.cc4
-rw-r--r--sql/ha_ndbcluster_binlog.cc20
-rw-r--r--sql/ha_partition.cc18
-rw-r--r--sql/ha_partition.h3
-rw-r--r--sql/handler.cc17
-rw-r--r--sql/handler.h5
-rw-r--r--sql/hostname.cc4
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--sql/item_cmpfunc.h23
-rw-r--r--sql/item_geofunc.cc2
-rw-r--r--sql/item_subselect.h2
-rw-r--r--sql/lock.cc173
-rw-r--r--sql/lock.h5
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log.h1
-rw-r--r--sql/log_event.cc67
-rw-r--r--sql/mdl.cc227
-rw-r--r--sql/mdl.h21
-rw-r--r--sql/mysqld.cc49
-rw-r--r--sql/mysqld.h17
-rw-r--r--sql/nt_servc.cc23
-rw-r--r--sql/protocol.cc33
-rw-r--r--sql/repl_failsafe.cc99
-rw-r--r--sql/repl_failsafe.h2
-rw-r--r--sql/rpl_record.cc3
-rw-r--r--sql/rpl_rli.cc16
-rw-r--r--sql/set_var.cc1
-rw-r--r--sql/set_var.h1
-rw-r--r--sql/slave.cc13
-rw-r--r--sql/sp.cc16
-rw-r--r--sql/sp_head.cc240
-rw-r--r--sql/sp_head.h2
-rw-r--r--sql/sp_pcontext.h7
-rw-r--r--sql/sp_rcontext.cc242
-rw-r--r--sql/sp_rcontext.h69
-rw-r--r--sql/sql_acl.cc145
-rw-r--r--sql/sql_base.cc644
-rw-r--r--sql/sql_base.h15
-rw-r--r--sql/sql_class.cc111
-rw-r--r--sql/sql_class.h35
-rw-r--r--sql/sql_cursor.cc378
-rw-r--r--sql/sql_cursor.h16
-rw-r--r--sql/sql_db.cc325
-rw-r--r--sql/sql_db.h7
-rw-r--r--sql/sql_delete.cc4
-rw-r--r--sql/sql_do.cc5
-rw-r--r--sql/sql_error.cc21
-rw-r--r--sql/sql_error.h16
-rw-r--r--sql/sql_handler.cc25
-rw-r--r--sql/sql_help.cc23
-rw-r--r--sql/sql_hset.h97
-rw-r--r--sql/sql_insert.cc44
-rw-r--r--sql/sql_lex.cc4
-rw-r--r--sql/sql_lex.h6
-rw-r--r--sql/sql_map.cc144
-rw-r--r--sql/sql_map.h70
-rw-r--r--sql/sql_olap.cc188
-rw-r--r--sql/sql_parse.cc279
-rw-r--r--sql/sql_parse.h1
-rw-r--r--sql/sql_partition.cc3
-rw-r--r--sql/sql_plugin.cc62
-rw-r--r--sql/sql_prepare.cc48
-rw-r--r--sql/sql_priv.h12
-rw-r--r--sql/sql_rename.cc10
-rw-r--r--sql/sql_select.cc150
-rw-r--r--sql/sql_select.h6
-rw-r--r--sql/sql_servers.cc17
-rw-r--r--sql/sql_show.cc116
-rw-r--r--sql/sql_signal.cc12
-rw-r--r--sql/sql_table.cc126
-rw-r--r--sql/sql_table.h1
-rw-r--r--sql/sql_trigger.cc27
-rw-r--r--sql/sql_truncate.cc42
-rw-r--r--sql/sql_udf.cc4
-rw-r--r--sql/sql_union.cc3
-rw-r--r--sql/sql_update.cc4
-rw-r--r--sql/sql_view.cc7
-rw-r--r--sql/sql_yacc.yy16
-rw-r--r--sql/sys_vars.cc23
-rw-r--r--sql/table.cc6
-rw-r--r--sql/transaction.cc27
-rw-r--r--sql/tztime.cc12
-rw-r--r--sql/udf_example.c3
-rw-r--r--storage/archive/azio.c22
-rw-r--r--storage/archive/ha_archive.cc37
-rw-r--r--storage/archive/ha_archive.h1
-rw-r--r--storage/csv/ha_tina.cc6
-rw-r--r--storage/federated/ha_federated.cc10
-rw-r--r--storage/heap/ha_heap.cc4
-rw-r--r--storage/heap/hp_test2.c5
-rw-r--r--storage/innobase/CMakeLists.txt12
-rw-r--r--storage/innobase/btr/btr0btr.c6
-rw-r--r--storage/innobase/btr/btr0cur.c26
-rw-r--r--storage/innobase/btr/btr0sea.c58
-rw-r--r--storage/innobase/buf/buf0buf.c31
-rw-r--r--storage/innobase/buf/buf0flu.c26
-rw-r--r--storage/innobase/buf/buf0lru.c10
-rw-r--r--storage/innobase/data/data0data.c28
-rw-r--r--storage/innobase/data/data0type.c11
-rw-r--r--storage/innobase/dict/dict0boot.c47
-rw-r--r--storage/innobase/dict/dict0crea.c13
-rw-r--r--storage/innobase/dict/dict0dict.c94
-rw-r--r--storage/innobase/dict/dict0load.c49
-rw-r--r--storage/innobase/dict/dict0mem.c35
-rw-r--r--storage/innobase/fil/fil0fil.c12
-rw-r--r--storage/innobase/fsp/fsp0fsp.c141
-rw-r--r--storage/innobase/ha/ha0ha.c15
-rw-r--r--storage/innobase/handler/ha_innodb.cc207
-rw-r--r--storage/innobase/handler/handler0alter.cc6
-rw-r--r--storage/innobase/handler/i_s.cc175
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.c4
-rw-r--r--storage/innobase/include/btr0btr.h4
-rw-r--r--storage/innobase/include/btr0btr.ic7
-rw-r--r--storage/innobase/include/btr0cur.h2
-rw-r--r--storage/innobase/include/btr0sea.h8
-rw-r--r--storage/innobase/include/buf0buf.h3
-rw-r--r--storage/innobase/include/data0data.h2
-rw-r--r--storage/innobase/include/data0data.ic4
-rw-r--r--storage/innobase/include/data0type.h49
-rw-r--r--storage/innobase/include/data0type.ic75
-rw-r--r--storage/innobase/include/dict0boot.h31
-rw-r--r--storage/innobase/include/dict0boot.ic16
-rw-r--r--storage/innobase/include/dict0dict.h45
-rw-r--r--storage/innobase/include/dict0dict.ic56
-rw-r--r--storage/innobase/include/dict0load.h15
-rw-r--r--storage/innobase/include/dict0mem.h23
-rw-r--r--storage/innobase/include/dict0mem.ic32
-rw-r--r--storage/innobase/include/dict0types.h3
-rw-r--r--storage/innobase/include/fil0fil.h1
-rw-r--r--storage/innobase/include/lock0lock.h4
-rw-r--r--storage/innobase/include/log0log.ic5
-rw-r--r--storage/innobase/include/mach0data.h112
-rw-r--r--storage/innobase/include/mach0data.ic229
-rw-r--r--storage/innobase/include/mtr0log.h22
-rw-r--r--storage/innobase/include/mtr0log.ic12
-rw-r--r--storage/innobase/include/mtr0mtr.h9
-rw-r--r--storage/innobase/include/os0file.h10
-rw-r--r--storage/innobase/include/os0sync.h73
-rw-r--r--storage/innobase/include/os0sync.ic11
-rw-r--r--storage/innobase/include/page0page.h2
-rw-r--r--storage/innobase/include/page0page.ic5
-rw-r--r--storage/innobase/include/pars0pars.h25
-rw-r--r--storage/innobase/include/que0que.h3
-rw-r--r--storage/innobase/include/read0read.h10
-rw-r--r--storage/innobase/include/read0read.ic14
-rw-r--r--storage/innobase/include/rem0rec.h2
-rw-r--r--storage/innobase/include/rem0rec.ic4
-rw-r--r--storage/innobase/include/row0mysql.h17
-rw-r--r--storage/innobase/include/row0upd.h2
-rw-r--r--storage/innobase/include/srv0srv.h9
-rw-r--r--storage/innobase/include/sync0sync.h2
-rw-r--r--storage/innobase/include/trx0i_s.h13
-rw-r--r--storage/innobase/include/trx0rec.h4
-rw-r--r--storage/innobase/include/trx0rec.ic4
-rw-r--r--storage/innobase/include/trx0sys.h7
-rw-r--r--storage/innobase/include/trx0sys.ic13
-rw-r--r--storage/innobase/include/trx0trx.h24
-rw-r--r--storage/innobase/include/trx0trx.ic12
-rw-r--r--storage/innobase/include/trx0types.h13
-rw-r--r--storage/innobase/include/trx0undo.h2
-rw-r--r--storage/innobase/include/trx0undo.ic39
-rw-r--r--storage/innobase/include/univ.i15
-rw-r--r--storage/innobase/include/ut0byte.h169
-rw-r--r--storage/innobase/include/ut0byte.ic254
-rw-r--r--storage/innobase/include/ut0rnd.h8
-rw-r--r--storage/innobase/include/ut0rnd.ic12
-rw-r--r--storage/innobase/lock/lock0lock.c77
-rw-r--r--storage/innobase/log/log0log.c22
-rw-r--r--storage/innobase/log/log0recv.c40
-rw-r--r--storage/innobase/mach/mach0data.c40
-rw-r--r--storage/innobase/mtr/mtr0log.c22
-rw-r--r--storage/innobase/mtr/mtr0mtr.c26
-rw-r--r--storage/innobase/os/os0file.c72
-rw-r--r--storage/innobase/os/os0sync.c426
-rw-r--r--storage/innobase/os/os0thread.c2
-rw-r--r--storage/innobase/page/page0page.c6
-rw-r--r--storage/innobase/page/page0zip.c5
-rw-r--r--storage/innobase/pars/pars0pars.c29
-rw-r--r--storage/innobase/read/read0read.c42
-rw-r--r--storage/innobase/row/row0ins.c80
-rw-r--r--storage/innobase/row/row0merge.c35
-rw-r--r--storage/innobase/row/row0mysql.c79
-rw-r--r--storage/innobase/row/row0purge.c20
-rw-r--r--storage/innobase/row/row0row.c16
-rw-r--r--storage/innobase/row/row0sel.c164
-rw-r--r--storage/innobase/row/row0uins.c17
-rw-r--r--storage/innobase/row/row0umod.c22
-rw-r--r--storage/innobase/row/row0undo.c27
-rw-r--r--storage/innobase/row/row0upd.c44
-rw-r--r--storage/innobase/row/row0vers.c12
-rw-r--r--storage/innobase/srv/srv0srv.c27
-rw-r--r--storage/innobase/srv/srv0start.c45
-rw-r--r--storage/innobase/sync/sync0arr.c2
-rw-r--r--storage/innobase/sync/sync0sync.c25
-rw-r--r--storage/innobase/trx/trx0i_s.c6
-rw-r--r--storage/innobase/trx/trx0purge.c106
-rw-r--r--storage/innobase/trx/trx0rec.c64
-rw-r--r--storage/innobase/trx/trx0roll.c77
-rw-r--r--storage/innobase/trx/trx0rseg.c4
-rw-r--r--storage/innobase/trx/trx0sys.c67
-rw-r--r--storage/innobase/trx/trx0trx.c98
-rw-r--r--storage/innobase/trx/trx0undo.c29
-rw-r--r--storage/innobase/ut/ut0byte.c25
-rw-r--r--storage/myisam/ft_boolean_search.c2
-rw-r--r--storage/myisam/ft_nlq_search.c3
-rw-r--r--storage/myisam/ft_parser.c2
-rw-r--r--storage/myisam/ft_update.c3
-rw-r--r--storage/myisam/mi_check.c92
-rw-r--r--storage/myisam/mi_create.c20
-rw-r--r--storage/myisam/mi_delete_table.c33
-rw-r--r--storage/myisam/mi_dynrec.c20
-rw-r--r--storage/myisam/mi_key.c2
-rw-r--r--storage/myisam/mi_log.c2
-rw-r--r--storage/myisam/mi_open.c57
-rw-r--r--storage/myisam/mi_packrec.c3
-rw-r--r--storage/myisam/mi_rename.c21
-rw-r--r--storage/myisam/mi_static.c1
-rw-r--r--storage/myisam/mi_statrec.c20
-rw-r--r--storage/myisam/mi_test1.c12
-rw-r--r--storage/myisam/mi_test2.c2
-rw-r--r--storage/myisam/mi_test3.c2
-rw-r--r--storage/myisam/mi_unique.c6
-rw-r--r--storage/myisam/mi_write.c5
-rw-r--r--storage/myisam/myisam_ftdump.c2
-rw-r--r--storage/myisam/myisamchk.c41
-rw-r--r--storage/myisam/myisamdef.h12
-rw-r--r--storage/myisam/myisamlog.c4
-rw-r--r--storage/myisam/myisampack.c9
-rw-r--r--storage/myisam/rt_test.c43
-rw-r--r--storage/myisam/sp_key.c2
-rw-r--r--storage/myisam/sp_test.c85
-rw-r--r--storage/myisammrg/ha_myisammrg.cc27
-rw-r--r--storage/ndb/include/kernel/signaldata/FsOpenReq.hpp8
-rw-r--r--storage/ndb/include/util/ndb_opts.h22
-rw-r--r--storage/ndb/src/cw/cpcd/main.cpp12
-rw-r--r--storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp4
-rw-r--r--storage/ndb/src/kernel/vm/Configuration.cpp16
-rw-r--r--storage/ndb/src/mgmclient/main.cpp4
-rw-r--r--storage/ndb/src/mgmsrv/main.cpp14
-rw-r--r--storage/ndb/src/ndbapi/TransporterFacade.hpp4
-rw-r--r--storage/ndb/test/ndbapi/testIndexStat.cpp26
-rw-r--r--storage/ndb/test/ndbapi/test_event_merge.cpp34
-rw-r--r--storage/ndb/test/ndbapi/test_event_multi_table.cpp2
-rw-r--r--storage/ndb/test/run-test/main.cpp36
-rw-r--r--storage/ndb/test/src/NDBT_Test.cpp20
-rw-r--r--storage/ndb/test/tools/connect.cpp6
-rw-r--r--storage/ndb/tools/delete_all.cpp8
-rw-r--r--storage/ndb/tools/desc.cpp8
-rw-r--r--storage/ndb/tools/drop_index.cpp2
-rw-r--r--storage/ndb/tools/drop_tab.cpp2
-rw-r--r--storage/ndb/tools/listTables.cpp12
-rw-r--r--storage/ndb/tools/ndb_config.cpp22
-rw-r--r--storage/ndb/tools/restore/restore_main.cpp56
-rw-r--r--storage/ndb/tools/select_all.cpp26
-rw-r--r--storage/ndb/tools/select_count.cpp6
-rw-r--r--storage/ndb/tools/waiter.cpp8
-rw-r--r--storage/perfschema/pfs_events_waits.cc6
-rw-r--r--strings/CMakeLists.txt12
-rw-r--r--strings/Makefile.am16
-rw-r--r--strings/bfill.c57
-rw-r--r--strings/bmove.c34
-rw-r--r--strings/bmove512.c125
-rw-r--r--strings/bmove_upp-sparc.s40
-rw-r--r--strings/bmove_upp.c18
-rw-r--r--strings/ctype-simple.c108
-rw-r--r--strings/ctype-ucs2.c20
-rw-r--r--strings/do_ctype.c4
-rw-r--r--strings/r_strinstr.c50
-rw-r--r--strings/str_test.c2
-rw-r--r--strings/strappend-sparc.s49
-rw-r--r--strings/strcend.c18
-rw-r--r--strings/strend-sparc.s35
-rw-r--r--strings/strend.c13
-rw-r--r--strings/string.doc5
-rw-r--r--strings/strings-not-used.h41
-rw-r--r--strings/strings-x86.s23
-rw-r--r--strings/strinstr-sparc.s43
-rw-r--r--strings/strinstr.c48
-rw-r--r--strings/strmake-sparc.s43
-rw-r--r--strings/strmov-sparc.s36
-rw-r--r--strings/strmov.c16
-rw-r--r--strings/strnmov-sparc.s43
-rw-r--r--strings/strstr-sparc.s72
-rw-r--r--strings/strxmov-sparc.s54
-rw-r--r--tests/mysql_client_test.c209
-rw-r--r--tests/thread_test.c28
-rw-r--r--unittest/mysys/my_atomic-t.c19
-rw-r--r--unittest/mytap/tap.c6
468 files changed, 9039 insertions, 10992 deletions
diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf
index 658c8ba845b..6678383eebd 100644
--- a/.bzr-mysql/default.conf
+++ b/.bzr-mysql/default.conf
@@ -1,4 +1,4 @@
[MYSQL]
post_commit_to = "commits@lists.mysql.com"
post_push_to = "commits@lists.mysql.com"
-tree_name = "mysql-trunk-merge"
+tree_name = "mysql-5.5-merge"
diff --git a/.bzrignore b/.bzrignore
index f5f678ca360..a17b1dec6cb 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -3101,3 +3101,4 @@ libmysqld/merge_archives_mysqlserver.cmake
libmysqld/mysqlserver_depends.c
libmysqld/examples/mysql_embedded
sql/.empty
+mysys/thr_lock
diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh
index 142ff7eb08e..b7f7a1db77e 100644
--- a/BUILD/FINISH.sh
+++ b/BUILD/FINISH.sh
@@ -6,6 +6,7 @@ configure="./configure $base_configs $extra_configs"
commands="\
$make -k maintainer-clean || true
/bin/rm -rf */.deps/*.P configure config.cache storage/*/configure storage/*/config.cache autom4te.cache storage/*/autom4te.cache;
+/bin/rm -rf CMakeCache.txt CMakeFiles/
path=`dirname $0`
. \"$path/autorun.sh\""
diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am
index c7bf813c9fe..c5732d43fbf 100644
--- a/BUILD/Makefile.am
+++ b/BUILD/Makefile.am
@@ -20,7 +20,7 @@
EXTRA_DIST = FINISH.sh \
SETUP.sh \
autorun.sh \
- choose_configure.sh \
+ cmake_configure.sh \
build_mccge.sh \
check-cpu \
cleanup \
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh
index b5f1c7b200e..afb8eca08f2 100755
--- a/BUILD/SETUP.sh
+++ b/BUILD/SETUP.sh
@@ -15,7 +15,7 @@ Usage: $0 [-h|-n] [configure-options]
-n, --just-print Don't actually run any commands; just print them.
-c, --just-configure Stop after running configure.
--with-debug=full Build with full debug.
- --warning-mode=[old|pedantic]
+ --warning-mode=[old|pedantic|maintainer]
Influences the debug flags. Old is default.
--prefix=path Build with prefix 'path'.
@@ -62,6 +62,7 @@ just_print=
just_configure=
full_debug=
warning_mode=
+maintainer_mode=
parse_options "$@"
@@ -88,7 +89,21 @@ AM_MAKEFLAGS="-j 6"
# Ex --with-ssl=/usr
SSL_LIBRARY=--with-ssl
-if [ "x$warning_mode" != "xpedantic" ]; then
+if [ "x$warning_mode" = "xpedantic" ]; then
+ warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
+ c_warnings="$warnings"
+ cxx_warnings="$warnings -std=c++98"
+# NOTE: warning mode should not influence optimize/debug mode.
+# Please feel free to add a separate option if you don't feel it's an overkill.
+ debug_extra_cflags="-O0"
+# Reset CPU flags (-mtune), they don't work in -pedantic mode
+ check_cpu_cflags=""
+elif [ "x$warning_mode" = "xmaintainer" ]; then
+ c_warnings="-Wall -Wextra"
+ cxx_warnings="$c_warnings -Wno-unused-parameter"
+ maintainer_mode="--enable-mysql-maintainer-mode"
+ debug_extra_cflags="-g3"
+else
# Both C and C++ warnings
warnings="-Wall -Wextra -Wunused -Wwrite-strings"
@@ -103,15 +118,6 @@ if [ "x$warning_mode" != "xpedantic" ]; then
cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"
# Added unless --with-debug=full
debug_extra_cflags="-O0 -g3 -gdwarf-2"
-else
- warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
- c_warnings="$warnings"
- cxx_warnings="$warnings -std=c++98"
-# NOTE: warning mode should not influence optimize/debug mode.
-# Please feel free to add a separate option if you don't feel it's an overkill.
- debug_extra_cflags="-O0"
-# Reset CPU flags (-mtune), they don't work in -pedantic mode
- check_cpu_cflags=""
fi
# Set flags for various build configurations.
@@ -147,7 +153,7 @@ fi
base_configs="--prefix=$prefix --enable-assembler "
base_configs="$base_configs --with-extra-charsets=complex "
base_configs="$base_configs --enable-thread-safe-client "
-base_configs="$base_configs --with-big-tables"
+base_configs="$base_configs --with-big-tables $maintainer_mode"
if test -d "$path/../cmd-line-utils/readline"
then
diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh
index f45b1f7d08c..f4508ab12b6 100755
--- a/BUILD/autorun.sh
+++ b/BUILD/autorun.sh
@@ -31,8 +31,8 @@ $LIBTOOLIZE --automake --force --copy || die "Can't execute libtoolize"
automake --add-missing --force --copy || die "Can't execute automake"
autoconf || die "Can't execute autoconf"
# Do not use autotools generated configure directly. Instead, use a script
-# that will either call CMake or original configure shell script at build
+# that will either call CMake or original configure shell script at build
# time (CMake is preferred if installed).
mv configure configure.am
-cp BUILD/choose_configure.sh configure
+cp BUILD/cmake_configure.sh configure
chmod a+x configure
diff --git a/BUILD/choose_configure.sh b/BUILD/cmake_configure.sh
index 80423205274..80423205274 100644
--- a/BUILD/choose_configure.sh
+++ b/BUILD/cmake_configure.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e50e24d0fa5..fed3d61be8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -148,6 +148,9 @@ OPTION(ENABLED_PROFILING "Enable profiling" ON)
OPTION(CYBOZU "" OFF)
OPTION(BACKUP_TEST "" OFF)
OPTION(WITHOUT_SERVER OFF)
+IF(UNIX)
+ OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF)
+ENDIF()
OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED)
diff --git a/Makefile.am b/Makefile.am
index a736a61fb59..7ab9a9aa061 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,6 +30,7 @@ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@libmysqld_dirs@ \
mysql-test support-files sql-bench \
win \
+ packaging \
cmake
DIST_SUBDIRS = . include Docs zlib \
cmd-line-utils sql-common scripts \
@@ -40,6 +41,7 @@ DIST_SUBDIRS = . include Docs zlib \
mysql-test support-files sql-bench \
win \
cmake \
+ packaging \
BUILD
DISTCLEANFILES = ac_available_languages_fragment
diff --git a/client/Makefile.am b/client/Makefile.am
index 04f0ac39b0e..393573a061e 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -62,7 +62,6 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc \
$(top_srcdir)/mysys/my_new.cc \
$(top_srcdir)/mysys/my_bit.c \
$(top_srcdir)/mysys/my_bitmap.c \
- $(top_srcdir)/mysys/my_vle.c \
$(top_srcdir)/mysys/base64.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
diff --git a/client/mysql.cc b/client/mysql.cc
index c99886d28d3..01a786c13af 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -627,10 +627,6 @@ static COMMANDS commands[] = {
{ "QUARTER", 0, 0, 0, ""},
{ "QUERY", 0, 0, 0, ""},
{ "QUICK", 0, 0, 0, ""},
- { "RAID0", 0, 0, 0, ""},
- { "RAID_CHUNKS", 0, 0, 0, ""},
- { "RAID_CHUNKSIZE", 0, 0, 0, ""},
- { "RAID_TYPE", 0, 0, 0, ""},
{ "READ", 0, 0, 0, ""},
{ "READS", 0, 0, 0, ""},
{ "REAL", 0, 0, 0, ""},
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index c8ec6c981ef..20f0f6d3164 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -5954,8 +5954,8 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"result-format-version", OPT_RESULT_FORMAT_VERSION,
"Version of the result file format to use",
- (uchar**) &opt_result_format_version,
- (uchar**) &opt_result_format_version, 0,
+ &opt_result_format_version,
+ &opt_result_format_version, 0,
GET_INT, REQUIRED_ARG, 1, 1, 2, 0, 0, 0},
{"server-arg", 'A', "Send option value to embedded server as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -5998,8 +5998,7 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT,
"Number of seconds before connection timeout.",
- (uchar**) &opt_connect_timeout,
- (uchar**) &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG,
+ &opt_connect_timeout, &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG,
120, 0, 3600 * 12, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -8513,7 +8512,7 @@ void free_replace_column()
typedef struct st_pointer_array { /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */
uchar *str; /* Strings is here */
- int7 *flag; /* Flag about each var. */
+ uint8 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
@@ -9644,7 +9643,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
}
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
sizeof(*pa->flag));
- pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
+ pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count);
pa->length=0;
pa->max_length=PS_MALLOC-MALLOC_OVERHEAD;
pa->array_allocs=1;
@@ -9680,7 +9679,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
pa->typelib.type_names=new_array;
old_count=pa->max_count;
pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag));
- pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
+ pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count);
memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count),
old_count*sizeof(*pa->flag));
}
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
index 81942a8c053..732f5d74181 100644
--- a/cmake/os/WindowsCache.cmake
+++ b/cmake/os/WindowsCache.cmake
@@ -339,4 +339,16 @@ SET(C_HAS_inline CACHE INTERNAL "")
SET(C_HAS___inline 1 CACHE INTERNAL "")
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
+SET(HAVE_CXXABI_H CACHE INTERNAL "")
+SET(HAVE_NDIR_H CACHE INTERNAL "")
+SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
+SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
+SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
+SET(HAVE_TERMBITS_H CACHE INTERNAL "")
+SET(HAVE_VIS_H CACHE INTERNAL "")
+SET(HAVE_WCHAR_H 1 CACHE INTERNAL "")
+SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "")
+SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "")
+SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
+SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
ENDIF()
diff --git a/config.h.cmake b/config.h.cmake
index 0800e191aa9..c484edb65a5 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -103,7 +103,6 @@
#cmakedefine HAVE_SYS_UTIME_H 1
#cmakedefine HAVE_SYS_WAIT_H 1
#cmakedefine HAVE_SYS_PARAM_H 1
-#cmakedefine HAVE_XFS_XFS_H 1
/* Libraries */
#cmakedefine HAVE_LIBPTHREAD 1
@@ -252,15 +251,6 @@
#cmakedefine HAVE_SIGWAIT 1
#cmakedefine HAVE_SLEEP 1
#cmakedefine HAVE_SNPRINTF 1
-/* Some that currently are not real defines, internal to CMake setup */
-/* #cmakedefine HAVE_FCNTL_NONBLOCK 1 */
-/* #cmakedefine HAVE_FINITE_IN_MATH_H 1 */
-/* #cmakedefine HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 */
-/* #cmakedefine HAVE_SOCKADDR_STORAGE___SS_FAMILY 1 */
-/* #cmakedefine HAVE_SOCKET_SIZE_T_AS_int 1 */
-/* #cmakedefine HAVE_SOCKET_SIZE_T_AS_size_t 1 */
-/* #cmakedefine HAVE_SOCKET_SIZE_T_AS_socklen_t */
-/* #cmakedefine HAVE_SOCKET_TIMEOUT */
#cmakedefine HAVE_STPCPY 1
#cmakedefine HAVE_STRERROR 1
#cmakedefine HAVE_STRCOLL 1
@@ -318,7 +308,7 @@
#define USE_MB 1
#define USE_MB_IDENT 1
-
+#cmakedefine HAVE_VALGRIND
/* Types we may use */
#ifdef __APPLE__
@@ -343,13 +333,13 @@
#endif
#cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@
-#cmakedefine HAVE_CHAR 1
-#cmakedefine HAVE_LONG 1
-#cmakedefine HAVE_CHARP 1
+#define HAVE_CHAR 1
+#define HAVE_LONG 1
+#define HAVE_CHARP 1
#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
-#cmakedefine HAVE_SHORT 1
+#define HAVE_SHORT 1
#cmakedefine SIZEOF_INT @SIZEOF_INT@
-#cmakedefine HAVE_INT 1
+#define HAVE_INT 1
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
#cmakedefine HAVE_LONG_LONG 1
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
@@ -581,23 +571,6 @@
#cmakedefine HAVE_UCA_COLLATIONS 1
#cmakedefine HAVE_COMPRESS 1
-/*
- Hard coded platform settings
-*/
-
-/* This is ugly, but we need lots of tweaks for HP-UX */
-#cmakedefine HPUX11 1
-#cmakedefine DO_NOT_REMOVE_THREAD_WRAPPERS 1
-#cmakedefine HAVE_BROKEN_PREAD 1
-#cmakedefine HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT 1
-#cmakedefine SNPRINTF_RETURN_TRUNC 1
-#cmakedefine _INCLUDE_LONGLONG 1
-
-/* Mac OS X */
-#cmakedefine SIGNALS_DONT_BREAK_READ 1
-#cmakedefine IGNORE_SIGHUP_SIGQUIT 1
-#cmakedefine _P1003_1B_VISIBLE 1
-#cmakedefine DONT_DECLARE_CXA_PURE_VIRTUAL 1
/*
Stuff that always need to be defined (compile breaks without it)
diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4
index 81967d383ec..c49e4f89316 100644
--- a/config/ac-macros/character_sets.m4
+++ b/config/ac-macros/character_sets.m4
@@ -5,9 +5,6 @@ dnl you must also create strings/ctype-$charset_name.c
AC_DIVERT_PUSH(0)
-# Any changes to the available character sets must also go into
-# include/config-win.h
-
define(CHARSETS_AVAILABLE0,binary)
define(CHARSETS_AVAILABLE1,armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257)
define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8)
diff --git a/configure.cmake b/configure.cmake
index f6276a054c3..c2e1dc4647b 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -257,7 +257,6 @@ CHECK_INCLUDE_FILES ("stdlib.h;sys/un.h" HAVE_SYS_UN_H)
CHECK_INCLUDE_FILES (vis.h HAVE_VIS_H)
CHECK_INCLUDE_FILES (wchar.h HAVE_WCHAR_H)
CHECK_INCLUDE_FILES (wctype.h HAVE_WCTYPE_H)
-CHECK_INCLUDE_FILES (xfs/xfs.h HAVE_XFS_XFS_H)
IF(HAVE_SYS_STREAM_H)
# Needs sys/stream.h on Solaris
@@ -502,14 +501,17 @@ IF(HAVE_STDINT_H)
SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
ENDIF(HAVE_STDINT_H)
-# These first four SIZE_* values are not really used on Mac OS X,
-# as we only know at comile time what architecture to build for,
-# see "config.h.cmake". But as same macro MY_CHECK_TYPE_SIZE also
-# sets HAVE_* macros, we run the check here, doesn't hurt.
+SET(HAVE_VOIDP 1)
+SET(HAVE_CHARP 1)
+SET(HAVE_LONG 1)
+SET(HAVE_SIZE_T 1)
+
+IF(NOT APPLE)
MY_CHECK_TYPE_SIZE("void *" VOIDP)
MY_CHECK_TYPE_SIZE("char *" CHARP)
MY_CHECK_TYPE_SIZE(long LONG)
MY_CHECK_TYPE_SIZE(size_t SIZE_T)
+ENDIF()
MY_CHECK_TYPE_SIZE(char CHAR)
MY_CHECK_TYPE_SIZE(short SHORT)
@@ -803,7 +805,7 @@ ENDIF(NOT HAVE_POSIX_SIGNALS)
# Assume regular sprintf
SET(SPRINTFS_RETURNS_INT 1)
-IF(CMAKE_COMPILER_IS_GNUXX AND HAVE_CXXABI_H)
+IF(CMAKE_COMPILER_IS_GNUCXX AND HAVE_CXXABI_H)
CHECK_CXX_SOURCE_COMPILES("
#include <cxxabi.h>
int main(int argc, char **argv)
@@ -992,6 +994,14 @@ configuration. By default gcc built-in sync functions are used,
if available and 'smp' configuration otherwise.")
MARK_AS_ADVANCED(WITH_ATOMIC_LOCKS MY_ATOMIC_MODE_RWLOCK MY_ATOMIC_MODE_DUMMY)
+IF(WITH_VALGRIND)
+ CHECK_INCLUDE_FILES("valgrind/memcheck.h;valgrind/valgrind.h"
+ HAVE_VALGRIND_HEADERS)
+ IF(HAVE_VALGRIND_HEADERS)
+ SET(HAVE_VALGRIND 1)
+ ENDIF()
+ENDIF()
+
#--------------------------------------------------------------------
# Check for IPv6 support
#--------------------------------------------------------------------
@@ -1046,26 +1056,3 @@ SET(CMAKE_EXTRA_INCLUDE_FILES)
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_ino "dirent.h" STRUCT_DIRENT_HAS_D_INO)
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN)
SET(SPRINTF_RETURNS_INT 1)
-
-#--------------------------------------------------------------------
-# Hard coded platform settings
-#--------------------------------------------------------------------
-
-# This is ugly, but we need lots of tweaks for HP-UX
-IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
- SET(HPUX11 1)
- SET(DO_NOT_REMOVE_THREAD_WRAPPERS 1)
- SET(HAVE_BROKEN_PREAD 1)
- SET(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT 1)
- SET(NO_FCNTL_NONBLOCK 1) # Set conditionally in code above
- SET(SNPRINTF_RETURN_TRUNC 1)
- SET(_INCLUDE_LONGLONG 1)
-ENDIF()
-
-IF(APPLE)
- SET(DONT_DECLARE_CXA_PURE_VIRTUAL 1)
- SET(IGNORE_SIGHUP_SIGQUIT 1)
- SET(SIGNALS_DONT_BREAK_READ 1)
- SET(SIGNAL_WITH_VIO_CLOSE 1) # FIXME better handled in mysql-trunk
- SET(_P1003_1B_VISIBLE 1)
-ENDIF()
diff --git a/configure.in b/configure.in
index b65418957ea..7121a521f87 100644
--- a/configure.in
+++ b/configure.in
@@ -672,9 +672,8 @@ AC_ARG_ENABLE(assembler,
AC_MSG_CHECKING(if we should use assembler functions)
# For now we only support assembler on i386 and sparc systems
AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $AS strings/strings-x86.s -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
-AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9")
-AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "")
+AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "")
if test "$ASSEMBLER_TRUE" = ""
then
@@ -1201,7 +1200,6 @@ case $SYSTEM_TYPE in
# Fixes for HPUX 11.0 compiler
if test "$ac_cv_prog_gcc" = "no"
then
- CFLAGS="$CFLAGS -DHAVE_BROKEN_INLINE"
# set working flags first in line, letting override it (i. e. for debug):
CXXFLAGS="+O2 $CXXFLAGS"
MAX_C_OPTIMIZE=""
@@ -1988,6 +1986,9 @@ fi
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
+AS_IF([test "x$ac_cv_c_inline" = "xno"],
+ [AC_MSG_WARN([The C compiler does not support inline. Beware that unused
+ functions might not be eliminated the object files.])])
AC_TYPE_OFF_T
AC_STRUCT_ST_RDEV
AC_HEADER_TIME
@@ -3049,7 +3050,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
libmysqld/Makefile libmysqld/examples/Makefile dnl
mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl
sql-bench/Makefile include/mysql_version.h plugin/Makefile win/Makefile dnl
- cmake/Makefile
+ cmake/Makefile packaging/Makefile
)
AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)
diff --git a/extra/replace.c b/extra/replace.c
index bbe70ba586e..2ce374726eb 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -39,7 +39,6 @@
fill_buffer_retaining() is taken from gnu-grep and modified.
*/
-#define DONT_USE_RAID
#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
@@ -52,7 +51,7 @@
typedef struct st_pointer_array { /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */
uchar *str; /* Strings is here */
- int7 *flag; /* Flag about each var. */
+ uint8 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
@@ -267,7 +266,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
}
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
sizeof(*pa->flag));
- pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
+ pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count);
pa->length=0;
pa->max_length=PS_MALLOC-MALLOC_OVERHEAD;
pa->array_allocs=1;
@@ -304,7 +303,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
pa->typelib.type_names=new_array;
old_count=pa->max_count;
pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag));
- pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
+ pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count);
memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count),
old_count*sizeof(*pa->flag));
}
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index 432a207f424..6ea818c601b 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -17,7 +17,6 @@
versions into symbolic names. By Sasha Pachev <sasha@mysql.com>
*/
-#define DONT_USE_RAID
#include <my_global.h>
#include <m_ctype.h>
#include <my_sys.h>
diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt
index 63eabb45824..ea991fee8dc 100644
--- a/extra/yassl/CMakeLists.txt
+++ b/extra/yassl/CMakeLists.txt
@@ -28,7 +28,12 @@ ${CMAKE_CXX_FLAGS})
ENDIF()
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
- src/yassl_imp.cpp src/yassl_int.cpp src/template_instnt.cpp)
+ src/yassl_imp.cpp src/yassl_int.cpp)
+
+IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
+ SET(YASSL_SOURCES ${YASSL_SOURCES} src/template_instnt.cpp)
+ENDIF()
+
ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES})
RESTRICT_SYMBOL_EXPORTS(yassl)
diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt
index 9417dda4095..1781ea6f2fa 100644
--- a/extra/yassl/taocrypt/CMakeLists.txt
+++ b/extra/yassl/taocrypt/CMakeLists.txt
@@ -21,12 +21,16 @@ ADD_DEFINITIONS(${SSL_DEFINES})
SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp
src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp
src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp
- src/template_instnt.cpp
include/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp
include/coding.hpp include/des.hpp include/dh.hpp include/dsa.hpp include/dsa.hpp
include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
+
+IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
+ SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp)
+ENDIF()
+
ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
RESTRICT_SYMBOL_EXPORTS(taocrypt)
diff --git a/include/Makefile.am b/include/Makefile.am
index ad023083829..e30588de065 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -33,16 +33,16 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
$(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h
-noinst_HEADERS = config-win.h lf.h my_bit.h \
+noinst_HEADERS = lf.h my_bit.h \
heap.h my_bitmap.h my_uctype.h password.h \
myisam.h myisampack.h myisammrg.h ft_global.h\
mysys_err.h my_base.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h sha2.h \
- my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
+ my_aes.h my_tree.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
my_handler.h my_time.h service_versions.h \
my_rdtsc.h mysql/psi/psi_abi_v1.h mysql/psi/psi_abi_v2.h \
- my_vle.h my_user.h my_atomic.h atomic/nolock.h \
+ my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
atomic/solaris.h mysql/innodb_priv.h my_compiler.h
diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h
index 100ff80cacd..d03d28f572e 100644
--- a/include/atomic/gcc_builtins.h
+++ b/include/atomic/gcc_builtins.h
@@ -22,8 +22,9 @@
v= __sync_lock_test_and_set(a, v);
#define make_atomic_cas_body(S) \
int ## S sav; \
- sav= __sync_val_compare_and_swap(a, *cmp, set); \
- if (!(ret= (sav == *cmp))) *cmp= sav;
+ int ## S cmp_val= *cmp; \
+ sav= __sync_val_compare_and_swap(a, cmp_val, set);\
+ if (!(ret= (sav == cmp_val))) *cmp= sav
#ifdef MY_ATOMIC_MODE_DUMMY
#define make_atomic_load_body(S) ret= *a
diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h
index 5a0c41d9078..4c871473b60 100644
--- a/include/atomic/nolock.h
+++ b/include/atomic/nolock.h
@@ -29,21 +29,22 @@
We choose implementation as follows:
------------------------------------
On Windows using Visual C++ the native implementation should be
- preferrable. When using gcc we prefer the native x86 implementation,
- we prefer the Solaris implementation before the gcc because of
- stability preference, we choose gcc implementation if nothing else
- works on gcc. If neither Visual C++ or gcc we still choose the
- Solaris implementation on Solaris (mainly for SunStudio compiles.
+ preferrable. When using gcc we prefer the Solaris implementation
+ before the gcc because of stability preference, we choose gcc
+ builtins if available, otherwise we choose the somewhat broken
+ native x86 implementation. If neither Visual C++ or gcc we still
+ choose the Solaris implementation on Solaris (mainly for SunStudio
+ compilers).
*/
# if defined(_MSV_VER)
# include "generic-msvc.h"
# elif __GNUC__
-# if defined(__i386__) || defined(__x86_64__)
-# include "x86-gcc.h"
-# elif defined(HAVE_SOLARIS_ATOMIC)
+# if defined(HAVE_SOLARIS_ATOMIC)
# include "solaris.h"
# elif defined(HAVE_GCC_ATOMIC_BUILTINS)
# include "gcc_builtins.h"
+# elif defined(__i386__) || defined(__x86_64__)
+# include "x86-gcc.h"
# endif
# elif defined(HAVE_SOLARIS_ATOMIC)
# include "solaris.h"
diff --git a/include/atomic/solaris.h b/include/atomic/solaris.h
index fc9f369c707..5643f878cd2 100644
--- a/include/atomic/solaris.h
+++ b/include/atomic/solaris.h
@@ -20,11 +20,17 @@
#define MY_ATOMIC_MODE "solaris-atomic"
+#if defined(__GNUC__)
+#define atomic_typeof(T,V) __typeof__(V)
+#else
+#define atomic_typeof(T,V) T
+#endif
+
#define uintptr_t void *
#define atomic_or_ptr_nv(X,Y) (void *)atomic_or_ulong_nv((volatile ulong_t *)X, Y)
#define make_atomic_cas_body(S) \
- uint ## S ## _t sav; \
+ atomic_typeof(uint ## S ## _t, *cmp) sav; \
sav = atomic_cas_ ## S( \
(volatile uint ## S ## _t *)a, \
(uint ## S ## _t)*cmp, \
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
index 61b94a48568..8baa84e110e 100644
--- a/include/atomic/x86-gcc.h
+++ b/include/atomic/x86-gcc.h
@@ -53,18 +53,29 @@
#endif
#define make_atomic_add_body32 \
- asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
+ asm volatile (LOCK_prefix "; xadd %0, %1;" \
+ : "+r" (v), "=m" (*a) \
+ : "m" (*a) \
+ : "memory")
#define make_atomic_cas_body32 \
+ __typeof__(*cmp) sav; \
asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
- : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
+ : "=m" (*a), "=a" (sav), "=q" (ret) \
+ : "r" (set), "m" (*a), "a" (*cmp) \
+ : "memory"); \
+ if (!ret) \
+ *cmp= sav
#ifdef __x86_64__
#define make_atomic_add_body64 make_atomic_add_body32
#define make_atomic_cas_body64 make_atomic_cas_body32
-#define make_atomic_fas_body(S) \
- asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
+#define make_atomic_fas_body(S) \
+ asm volatile ("xchg %0, %1;" \
+ : "+r" (v), "=m" (*a) \
+ : "m" (*a) \
+ : "memory")
/*
Actually 32-bit reads/writes are always atomic on x86
@@ -73,9 +84,14 @@
#define make_atomic_load_body(S) \
ret=0; \
asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
- : "+m" (*a), "+a" (ret): "r" (ret))
+ : "=m" (*a), "=a" (ret) \
+ : "r" (ret), "m" (*a) \
+ : "memory")
#define make_atomic_store_body(S) \
- asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
+ asm volatile ("; xchg %0, %1;" \
+ : "=m" (*a), "+r" (v) \
+ : "m" (*a) \
+ : "memory")
#else
/*
@@ -104,12 +120,13 @@
platforms the much simpler make_atomic_cas_body32 will work
fine.
*/
-#define make_atomic_cas_body64 \
- int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \
- asm volatile ("push %%ebx; movl %3, %%ebx;" \
- LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx"\
- : "+m" (*a), "+A" (*cmp), "=c" (ret) \
- :"m" (ebx), "c" (ecx))
+#define make_atomic_cas_body64 \
+ int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \
+ asm volatile ("push %%ebx; movl %3, %%ebx;" \
+ LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx" \
+ : "=m" (*a), "+A" (*cmp), "=c" (ret) \
+ : "m" (ebx), "c" (ecx), "m" (*a) \
+ : "memory", "esp")
#endif
/*
diff --git a/include/config-win.h b/include/config-win.h
deleted file mode 100644
index 9e8bb19c12d..00000000000
--- a/include/config-win.h
+++ /dev/null
@@ -1,441 +0,0 @@
-#ifndef CONFIG_WIN_INCLUDED
-#define CONFIG_WIN_INCLUDED
-
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Defines for Win32 to make it compatible for MySQL */
-
-#define BIG_TABLES
-
-/*
- Minimal version of Windows we should be able to run on.
- Currently Windows XP.
-*/
-#define _WIN32_WINNT 0x0501
-
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-/* Avoid endless warnings about sprintf() etc. being unsafe. */
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-#include <sys/locking.h>
-#include <winsock2.h>
-#include <Ws2tcpip.h>
-#include <fcntl.h>
-#include <io.h>
-#include <malloc.h>
-#include <sys/stat.h>
-#include <process.h> /* getpid()*/
-
-
-#define HAVE_SMEM 1
-
-#if defined(_WIN64) || defined(WIN64)
-#define SYSTEM_TYPE "Win64"
-#elif defined(_WIN32) || defined(WIN32)
-#define SYSTEM_TYPE "Win32"
-#else
-#define SYSTEM_TYPE "Windows"
-#endif
-
-#if defined(_M_IA64)
-#define MACHINE_TYPE "ia64"
-#elif defined(_M_IX86)
-#define MACHINE_TYPE "ia32"
-#elif defined(_M_ALPHA)
-#define MACHINE_TYPE "axp"
-#else
-#define MACHINE_TYPE "unknown" /* Define to machine type name */
-#endif
-
-#if !(defined(_WIN64) || defined(WIN64))
-#ifndef _WIN32
-#define _WIN32 /* Compatible with old source */
-#endif
-#ifndef __WIN32__
-#define __WIN32__
-#endif
-#endif /* _WIN64 */
-#ifndef __WIN__
-#define __WIN__ /* To make it easier in VC++ */
-#endif
-
-#ifndef MAX_INDEXES
-#define MAX_INDEXES 64
-#endif
-
-/* File and lock constants */
-#ifdef __BORLANDC__
-#define F_RDLCK LK_NBLCK /* read lock */
-#define F_WRLCK LK_NBRLCK /* write lock */
-#define F_UNLCK LK_UNLCK /* remove lock(s) */
-#else
-#define F_RDLCK _LK_NBLCK /* read lock */
-#define F_WRLCK _LK_NBRLCK /* write lock */
-#define F_UNLCK _LK_UNLCK /* remove lock(s) */
-#endif
-
-#define F_EXCLUSIVE 1 /* We have only exclusive locking */
-#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
-#define F_OK 0 /* parameter to access() */
-#define W_OK 2
-
-#define S_IROTH S_IREAD /* for my_lib */
-
-/* Winsock2 constant (Vista SDK and later)*/
-#define IPPROTO_IPV6 41
-#ifndef IPV6_V6ONLY
-#define IPV6_V6ONLY 27
-#endif
-
-#ifdef __BORLANDC__
-#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
-#define O_TEMPORARY 0
-#define O_SHORT_LIVED 0
-#define SH_DENYNO _SH_DENYNO
-#else
-#define O_BINARY _O_BINARY /* compability with older style names */
-#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
-#define O_TEMPORARY _O_TEMPORARY
-#define O_SHORT_LIVED _O_SHORT_LIVED
-#define SH_DENYNO _SH_DENYNO
-#endif
-#define NO_OPEN_3 /* For my_create() */
-
-#define SIGQUIT SIGTERM /* No SIGQUIT */
-
-#undef _REENTRANT /* Crashes something for win32 */
-#undef SAFE_MUTEX /* Can't be used on windows */
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310
-#define LL(A) A##ll
-#define ULL(A) A##ull
-#else
-#define LL(A) ((__int64) A)
-#define ULL(A) ((unsigned __int64) A)
-#endif
-
-#define LONGLONG_MIN LL(0x8000000000000000)
-#define LONGLONG_MAX LL(0x7FFFFFFFFFFFFFFF)
-#define ULONGLONG_MAX ULL(0xFFFFFFFFFFFFFFFF)
-
-/* Type information */
-
-#if !defined(HAVE_UINT)
-#undef HAVE_UINT
-#define HAVE_UINT
-typedef unsigned short ushort;
-typedef unsigned int uint;
-#endif /* !defined(HAVE_UINT) */
-
-typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
-typedef __int64 longlong;
-#ifndef HAVE_SIGSET_T
-typedef int sigset_t;
-#endif
-#define longlong_defined
-/*
- off_t should not be __int64 because of conflicts in header files;
- Use my_off_t or os_off_t instead
-*/
-#ifndef HAVE_OFF_T
-typedef long off_t;
-#endif
-typedef __int64 os_off_t;
-#ifdef _WIN64
-typedef UINT_PTR rf_SetTimer;
-#else
-typedef uint rf_SetTimer;
-#endif
-
-#ifndef HAVE_SIZE_T
-#ifndef _SIZE_T_DEFINED
-typedef SIZE_T size_t;
-#define _SIZE_T_DEFINED
-#endif
-#endif
-
-#ifndef HAVE_SSIZE_T
-#ifndef _SSIZE_T_DEFINED
-typedef SSIZE_T ssize_t;
-#define _SSIZE_T_DEFINED
-#endif
-#endif
-
-#define Socket_defined
-#define my_socket SOCKET
-#define SIGPIPE SIGINT
-#define RETQSORTTYPE void
-#define QSORT_TYPE_IS_VOID
-#define RETSIGTYPE void
-#define SOCKET_SIZE_TYPE int
-#define my_socket_defined
-#define byte_defined
-#define STDCALL __stdcall /* Used by libmysql.dll */
-#define isnan(X) _isnan(X)
-#define finite(X) _finite(X)
-
-#ifndef MYSQL_CLIENT_NO_THREADS
-#define THREAD
-#endif
-#define VOID_SIGHANDLER
-#define SIZEOF_CHAR 1
-#define SIZEOF_INT 4
-#define SIZEOF_LONG 4
-#define SIZEOF_LONG_LONG 8
-#define SIZEOF_OFF_T 8
-#ifdef _WIN64
-#define SIZEOF_CHARP 8
-#else
-#define SIZEOF_CHARP 4
-#endif
-#define HAVE_BROKEN_NETINET_INCLUDES
-#ifdef _WIN32
-#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
-#endif
-
-/* ERROR is defined in wingdi.h */
-#undef ERROR
-
-/* We need to close files to break connections on shutdown */
-#ifndef SIGNAL_WITH_VIO_CLOSE
-#define SIGNAL_WITH_VIO_CLOSE
-#endif
-
-/* All windows servers should support .sym files */
-#undef USE_SYMDIR
-#define USE_SYMDIR
-
-/* If LOAD DATA LOCAL INFILE should be enabled by default */
-#define ENABLED_LOCAL_INFILE 1
-
-/* If query profiling should be enabled by default */
-#define ENABLED_PROFILING 1
-
-/* Convert some simple functions to Posix */
-
-#define my_sigset(A,B) signal((A),(B))
-#define finite(A) _finite(A)
-#define sleep(A) Sleep((A)*1000)
-#define popen(A,B) _popen((A),(B))
-#define pclose(A) _pclose(A)
-
-#ifndef __BORLANDC__
-#define access(A,B) _access(A,B)
-#endif
-
-#if !defined(__cplusplus)
-#define inline __inline
-#endif /* __cplusplus */
-
-#ifdef _WIN64
-#define ulonglong2double(A) ((double) (ulonglong) (A))
-#define my_off_t2double(A) ((double) (my_off_t) (A))
-
-#else
-inline double ulonglong2double(ulonglong value)
-{
- longlong nr=(longlong) value;
- if (nr >= 0)
- return (double) nr;
- return (18446744073709551616.0 + (double) nr);
-}
-#define my_off_t2double(A) ulonglong2double(A)
-#endif /* _WIN64 */
-
-inline ulonglong double2ulonglong(double d)
-{
- double t= d - (double) 0x8000000000000000ULL;
-
- if (t >= 0)
- return ((ulonglong) t) + 0x8000000000000000ULL;
- return (ulonglong) d;
-}
-
-#if SIZEOF_OFF_T > 4
-#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
-#define tell(A) _telli64(A)
-#endif
-
-#define STACK_DIRECTION -1
-
-/* Difference between GetSystemTimeAsFileTime() and now() */
-#define OFFSET_TO_EPOCH ULL(116444736000000000)
-
-#define HAVE_PERROR
-#define HAVE_VFPRINT
-#define HAVE_RENAME /* Have rename() as function */
-#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
-#define HAVE_LONG_JMP /* Have long jump function */
-#define HAVE_LOCKING /* have locking() call */
-#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
-#define HAVE_STDLIB /* everything is include in this file */
-#define HAVE_MEMCPY
-#define HAVE_MEMMOVE
-#define HAVE_GETCWD
-#define HAVE_TELL
-#define HAVE_TZNAME
-#define HAVE_PUTENV
-#define HAVE_SELECT
-#define HAVE_SETLOCALE
-#define HAVE_SOCKET /* Giangi */
-#define HAVE_FLOAT_H
-#define HAVE_LIMITS_H
-#define HAVE_STDDEF_H
-#define NO_FCNTL_NONBLOCK /* No FCNTL */
-#define HAVE_ALLOCA
-#define HAVE_STRPBRK
-#define HAVE_STRSTR
-#define HAVE_COMPRESS
-#define HAVE_CREATESEMAPHORE
-#define HAVE_ISNAN
-#define HAVE_FINITE
-#define HAVE_QUERY_CACHE
-#define SPRINTF_RETURNS_INT
-#define HAVE_SETFILEPOINTER
-#define HAVE_VIO_READ_BUFF
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-/* strnlen() appeared in Studio 2005 */
-#define HAVE_STRNLEN
-#endif
-#define HAVE_WINSOCK2
-
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-
-#define HAVE_SNPRINTF 1
-#define snprintf _snprintf
-
-#define HAVE_SETENV 1
-#define setenv(VAR,VAL,X) _putenv_s(VAR,VAL)
-
-#ifdef _MSC_VER
-#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
-#define HAVE_ANSI_INCLUDE
-#define HAVE_SYS_UTIME_H
-#define HAVE_STRTOUL
-#endif
-#define my_reinterpret_cast(A) reinterpret_cast <A>
-#define my_const_cast(A) const_cast<A>
-
-
-/* MYSQL OPTIONS */
-
-#ifdef _CUSTOMCONFIG_
-#include <custom_conf.h>
-#else
-#ifndef CMAKE_CONFIGD
-#define DEFAULT_MYSQL_HOME "c:\\mysql"
-#define MYSQL_DATADIR "c:\\mysql\\data"
-#define PACKAGE "mysql"
-#define DEFAULT_BASEDIR "C:\\"
-#define SHAREDIR "share"
-#define DEFAULT_CHARSET_HOME "C:/mysql/"
-#endif
-#endif
-#ifndef DEFAULT_HOME_ENV
-#define DEFAULT_HOME_ENV MYSQL_HOME
-#endif
-#ifndef DEFAULT_GROUP_SUFFIX_ENV
-#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
-#endif
-
-/* File name handling */
-
-#define FN_LIBCHAR '\\'
-#define FN_ROOTDIR "\\"
-#define FN_DEVCHAR ':'
-#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
-#define FN_NO_CASE_SENSE /* Files are not case-sensitive */
-#define OS_FILE_LIMIT UINT_MAX /* No limit*/
-
-#define DO_NOT_REMOVE_THREAD_WRAPPERS
-#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
-#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
-/* The following is only used for statistics, so it should be good enough */
-#ifdef _WIN32
-#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
-#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
-#endif
-
-#define shared_memory_buffer_length 16000
-#define default_shared_memory_base_name "MYSQL"
-
-#define HAVE_SPATIAL 1
-#define HAVE_RTREE_KEYS 1
-
-#define HAVE_OPENSSL 1
-#define HAVE_YASSL 1
-
-#define ENABLED_PROFILING 1
-
-/*
- Our Windows binaries include all character sets which MySQL supports.
- Any changes to the available character sets must also go into
- config/ac-macros/character_sets.m4
-*/
-
-#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
-#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
-
-#define USE_MB 1
-#define USE_MB_IDENT 1
-#define USE_STRCOLL 1
-
-#define HAVE_CHARSET_armscii8
-#define HAVE_CHARSET_ascii
-#define HAVE_CHARSET_big5 1
-#define HAVE_CHARSET_cp1250 1
-#define HAVE_CHARSET_cp1251
-#define HAVE_CHARSET_cp1256
-#define HAVE_CHARSET_cp1257
-#define HAVE_CHARSET_cp850
-#define HAVE_CHARSET_cp852
-#define HAVE_CHARSET_cp866
-#define HAVE_CHARSET_cp932 1
-#define HAVE_CHARSET_dec8
-#define HAVE_CHARSET_eucjpms 1
-#define HAVE_CHARSET_euckr 1
-#define HAVE_CHARSET_gb2312 1
-#define HAVE_CHARSET_gbk 1
-#define HAVE_CHARSET_geostd8
-#define HAVE_CHARSET_greek
-#define HAVE_CHARSET_hebrew
-#define HAVE_CHARSET_hp8
-#define HAVE_CHARSET_keybcs2
-#define HAVE_CHARSET_koi8r
-#define HAVE_CHARSET_koi8u
-#define HAVE_CHARSET_latin1 1
-#define HAVE_CHARSET_latin2 1
-#define HAVE_CHARSET_latin5
-#define HAVE_CHARSET_latin7
-#define HAVE_CHARSET_macce
-#define HAVE_CHARSET_macroman
-#define HAVE_CHARSET_sjis 1
-#define HAVE_CHARSET_swe7
-#define HAVE_CHARSET_tis620 1
-#define HAVE_CHARSET_ucs2 1
-#define HAVE_CHARSET_ujis 1
-#define HAVE_CHARSET_utf8 1
-#define HAVE_CHARSET_utf8mb4 1
-#define HAVE_CHARSET_utf16 1
-#define HAVE_CHARSET_utf32 1
-
-#define HAVE_UCA_COLLATIONS 1
-#define HAVE_BOOL 1
-
-#endif /* CONFIG_WIN_INCLUDED */
diff --git a/include/lf.h b/include/lf.h
index d1f592d1047..e9fb094493f 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -187,8 +187,6 @@ typedef struct st_lf_allocator {
uchar * volatile top;
uint element_size;
uint32 volatile mallocs;
- void (*constructor)(uchar *); /* called, when an object is malloc()'ed */
- void (*destructor)(uchar *); /* called, when an object is free()'d */
} LF_ALLOCATOR;
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
@@ -222,8 +220,7 @@ C_MODE_START
#define LF_HASH_UNIQUE 1
-/* lf_hash overhead per element (that is, sizeof(LF_SLIST) */
-extern const int LF_HASH_OVERHEAD;
+/* lf_hash overhead per element is sizeof(LF_SLIST). */
typedef struct {
LF_DYNARRAY array; /* hash itself */
diff --git a/include/m_string.h b/include/m_string.h
index c2779c63941..2ec4eb64c8e 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -92,26 +92,12 @@ extern char _dig_vec_lower[];
#define strmake_overlapp(A,B,C) strmake(A,B,C)
#endif
-#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
-#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
-#else
-#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
-#endif
-
-#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
-#define bmove512(A,B,C) memcpy(A,B,C)
-#endif
-
/* Prototypes for string functions */
#if !defined(bfill) && !defined(HAVE_BFILL)
extern void bfill(uchar *dst,size_t len,pchar fill);
#endif
-#ifndef bmove512
-extern void bmove512(uchar *dst,const uchar *src,size_t len);
-#endif
-
#if !defined(HAVE_BMOVE) && !defined(bmove)
extern void bmove(uuchar *dst, const uchar *src,size_t len);
#endif
@@ -122,12 +108,7 @@ extern void bchange(uchar *dst,size_t old_len,const uchar *src,
extern void strappend(char *s,size_t len,pchar fill);
extern char *strend(const char *s);
extern char *strcend(const char *, pchar);
-extern char *strfield(char *src,int fields,int chars,int blanks,
- int tabch);
extern char *strfill(char * s,size_t len,pchar fill);
-extern size_t strinstr(const char *str,const char *search);
-extern size_t r_strinstr(const char *str, size_t from, const char *search);
-extern char *strkey(char *dst,char *head,char *tail,char *flags);
extern char *strmake(char *dst,const char *src,size_t length);
#ifndef strmov
@@ -136,35 +117,16 @@ extern char *strmov(char *dst,const char *src);
extern char *strmov_overlapp(char *dst,const char *src);
#endif
extern char *strnmov(char *dst, const char *src, size_t n);
-extern char *strsuff(const char *src, const char *suffix);
extern char *strcont(const char *src, const char *set);
-extern char *strxcat(char *dst, const char *src, ...);
extern char *strxmov(char *dst, const char *src, ...);
-extern char *strxcpy(char *dst, const char *src, ...);
-extern char *strxncat(char *dst, size_t len, const char *src, ...);
extern char *strxnmov(char *dst, size_t len, const char *src, ...);
-extern char *strxncpy(char *dst, size_t len, const char *src, ...);
/* Prototypes of normal stringfunctions (with may ours) */
-
-#ifdef WANT_STRING_PROTOTYPES
-extern char *strcat(char *, const char *);
-extern char *strchr(const char *, pchar);
-extern char *strrchr(const char *, pchar);
-extern char *strcpy(char *, const char *);
-extern int strcmp(const char *, const char *);
-#ifndef __GNUC__
-extern size_t strlen(const char *);
-#endif
-#endif
#ifndef HAVE_STRNLEN
extern size_t strnlen(const char *s, size_t n);
#endif
#if !defined(__cplusplus)
-#ifndef HAVE_STRPBRK
-extern char *strpbrk(const char *, const char *);
-#endif
#ifndef HAVE_STRSTR
extern char *strstr(const char *, const char *);
#endif
diff --git a/include/my_atomic.h b/include/my_atomic.h
index 8ba3e201730..c2d514012d9 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -20,6 +20,7 @@
This header defines five atomic operations:
my_atomic_add#(&var, what)
+ 'Fetch and Add'
add 'what' to *var, and return the old value of *var
my_atomic_fas#(&var, what)
@@ -27,9 +28,10 @@
store 'what' in *var, and return the old value of *var
my_atomic_cas#(&var, &old, new)
- 'Compare And Swap'
+ An odd variation of 'Compare And Set/Swap'
if *var is equal to *old, then store 'new' in *var, and return TRUE
otherwise store *var in *old, and return FALSE
+ Usually, &old should not be accessed if the operation is successful.
my_atomic_load#(&var)
return *var
@@ -153,10 +155,8 @@ make_transparent_unions(ptr)
#define U_set set
#endif /* __GCC__ transparent_union magic */
-#ifdef HAVE_INLINE
-
#define make_atomic_cas(S) \
-STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
+static inline int my_atomic_cas ## S(Uv_ ## S U_a, \
Uv_ ## S U_cmp, U_ ## S U_set) \
{ \
int8 ret; \
@@ -165,7 +165,7 @@ STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
}
#define make_atomic_add(S) \
-STATIC_INLINE int ## S my_atomic_add ## S( \
+static inline int ## S my_atomic_add ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_add_body(S); \
@@ -173,7 +173,7 @@ STATIC_INLINE int ## S my_atomic_add ## S( \
}
#define make_atomic_fas(S) \
-STATIC_INLINE int ## S my_atomic_fas ## S( \
+static inline int ## S my_atomic_fas ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_fas_body(S); \
@@ -181,7 +181,7 @@ STATIC_INLINE int ## S my_atomic_fas ## S( \
}
#define make_atomic_load(S) \
-STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
+static inline int ## S my_atomic_load ## S(Uv_ ## S U_a) \
{ \
int ## S ret; \
make_atomic_load_body(S); \
@@ -189,31 +189,12 @@ STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
}
#define make_atomic_store(S) \
-STATIC_INLINE void my_atomic_store ## S( \
+static inline void my_atomic_store ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_store_body(S); \
}
-#else /* no inline functions */
-
-#define make_atomic_add(S) \
-extern int ## S my_atomic_add ## S(Uv_ ## S U_a, U_ ## S U_v);
-
-#define make_atomic_fas(S) \
-extern int ## S my_atomic_fas ## S(Uv_ ## S U_a, U_ ## S U_v);
-
-#define make_atomic_cas(S) \
-extern int my_atomic_cas ## S(Uv_ ## S U_a, Uv_ ## S U_cmp, U_ ## S U_set);
-
-#define make_atomic_load(S) \
-extern int ## S my_atomic_load ## S(Uv_ ## S U_a);
-
-#define make_atomic_store(S) \
-extern void my_atomic_store ## S(Uv_ ## S U_a, U_ ## S U_v);
-
-#endif /* HAVE_INLINE */
-
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_cas(8)
make_atomic_cas(16)
diff --git a/include/my_attribute.h b/include/my_attribute.h
index 8309d85f20a..d35b3013bdd 100644
--- a/include/my_attribute.h
+++ b/include/my_attribute.h
@@ -21,6 +21,12 @@
#ifndef _my_attribute_h
#define _my_attribute_h
+#if defined(__GNUC__)
+# ifndef GCC_VERSION
+# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+# endif
+#endif
+
/*
Disable __attribute__() on gcc < 2.7, g++ < 3.4, and non-gcc compilers.
Some forms of __attribute__ are actually supported in earlier versions of
diff --git a/include/my_bit.h b/include/my_bit.h
index 5cbf4f8b83e..b396b84b0d8 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -6,7 +6,6 @@
*/
C_MODE_START
-#ifdef HAVE_INLINE
extern const char _my_bits_nbits[256];
extern const uchar _my_bits_reverse_table[256];
@@ -16,14 +15,14 @@ extern const uchar _my_bits_reverse_table[256];
This can be used to divide a number with value by doing a shift instead
*/
-STATIC_INLINE uint my_bit_log2(ulong value)
+static inline uint my_bit_log2(ulong value)
{
uint bit;
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
return bit;
}
-STATIC_INLINE uint my_count_bits(ulonglong v)
+static inline uint my_count_bits(ulonglong v)
{
#if SIZEOF_LONG_LONG > 4
/* The following code is a bit faster on 16 bit machines than if we would
@@ -45,7 +44,7 @@ STATIC_INLINE uint my_count_bits(ulonglong v)
#endif
}
-STATIC_INLINE uint my_count_bits_ushort(ushort v)
+static inline uint my_count_bits_ushort(ushort v)
{
return _my_bits_nbits[v];
}
@@ -70,7 +69,7 @@ STATIC_INLINE uint my_count_bits_ushort(ushort v)
Comments shows how this works with 01100000000000000000000000001011
*/
-STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
+static inline uint32 my_round_up_to_next_power(uint32 v)
{
v--; /* 01100000000000000000000000001010 */
v|= v >> 1; /* 01110000000000000000000000001111 */
@@ -81,7 +80,7 @@ STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
return v+1; /* 10000000000000000000000000000000 */
}
-STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
+static inline uint32 my_clear_highest_bit(uint32 v)
{
uint32 w=v >> 1;
w|= w >> 1;
@@ -92,7 +91,7 @@ STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
return v & w;
}
-STATIC_INLINE uint32 my_reverse_bits(uint32 key)
+static inline uint32 my_reverse_bits(uint32 key)
{
return
(_my_bits_reverse_table[ key & 255] << 24) |
@@ -101,14 +100,6 @@ STATIC_INLINE uint32 my_reverse_bits(uint32 key)
_my_bits_reverse_table[(key>>24) ];
}
-#else /* HAVE_INLINE */
-extern uint my_bit_log2(ulong value);
-extern uint32 my_round_up_to_next_power(uint32 v);
-uint32 my_clear_highest_bit(uint32 v);
-uint32 my_reverse_bits(uint32 key);
-extern uint my_count_bits(ulonglong v);
-extern uint my_count_bits_ushort(ushort v);
-#endif /* HAVE_INLINE */
C_MODE_END
#endif /* MY_BIT_INCLUDED */
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index 0caf2da12d0..548eec14d6e 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -69,28 +69,6 @@ extern void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2);
extern uint bitmap_lock_set_next(MY_BITMAP *map);
extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit);
-#ifdef NOT_USED
-extern uint bitmap_lock_bits_set(const MY_BITMAP *map);
-extern my_bool bitmap_lock_is_set_all(const MY_BITMAP *map);
-extern uint bitmap_lock_get_first(const MY_BITMAP *map);
-extern uint bitmap_lock_get_first_set(const MY_BITMAP *map);
-extern my_bool bitmap_lock_is_subset(const MY_BITMAP *map1,
- const MY_BITMAP *map2);
-extern my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size);
-extern my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit);
-extern my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map);
-extern my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2);
-extern void bitmap_lock_set_all(MY_BITMAP *map);
-extern void bitmap_lock_clear_all(MY_BITMAP *map);
-extern void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit);
-extern void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit);
-extern void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size);
-extern void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
-extern void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
-extern void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2);
-extern void bitmap_lock_xor(MY_BITMAP *map, const MY_BITMAP *map2);
-extern void bitmap_lock_invert(MY_BITMAP *map);
-#endif
/* Fast, not thread safe, bitmap functions */
#define bitmap_buffer_size(bits) (((bits)+31)/32)*4
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
diff --git a/include/my_global.h b/include/my_global.h
index b0db017c565..1c615cc5ca2 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -86,24 +86,12 @@
#define IF_WIN(A,B) B
#endif
-#ifndef DBUG_OFF
-#define IF_DBUG(A,B) A
-#else
-#define IF_DBUG(A,B) B
-#endif
-
#ifdef HAVE_purify
#define IF_PURIFY(A,B) A
#else
#define IF_PURIFY(A,B) B
#endif
-#ifdef DISABLE_GRANT_OPTIONS
-#define IF_DISABLE_GRANT_OPTIONS(A,B) A
-#else
-#define IF_DISABLE_GRANT_OPTIONS(A,B) B
-#endif
-
#ifndef EMBEDDED_LIBRARY
#ifdef WITH_NDB_BINLOG
#define HAVE_NDB_BINLOG 1
@@ -210,110 +198,6 @@
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
-
-/*
- The macros below are useful in optimising places where it has been
- discovered that cache misses stall the process and where a prefetch
- of the cache line can improve matters. This is available in GCC 3.1.1
- and later versions.
- PREFETCH_READ says that addr is going to be used for reading and that
- it is to be kept in caches if possible for a while
- PREFETCH_WRITE also says that the item to be cached is likely to be
- updated.
- The *LOCALITY scripts are also available for experimentation purposes
- mostly and should only be used if they are verified to improve matters.
- For more input see GCC manual (available in GCC 3.1.1 and later)
-*/
-
-#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
-#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3)
-#define PREFETCH_WRITE(addr) \
- __builtin_prefetch(addr, 1, 3)
-#define PREFETCH_READ_LOCALITY(addr, locality) \
- __builtin_prefetch(addr, 0, locality)
-#define PREFETCH_WRITE_LOCALITY(addr, locality) \
- __builtin_prefetch(addr, 1, locality)
-#else
-#define PREFETCH_READ(addr)
-#define PREFETCH_READ_LOCALITY(addr, locality)
-#define PREFETCH_WRITE(addr)
-#define PREFETCH_WRITE_LOCALITY(addr, locality)
-#endif
-
-/*
- The following macro is used to ensure that code often used in most
- SQL statements and definitely for parts of the SQL processing are
- kept in a code segment by itself. This has the advantage that the
- risk of common code being overlapping in caches of the CPU is less.
- This can be a cause of big performance problems.
- Routines should be put in this category with care and when they are
- put there one should also strive to make as much of the error handling
- as possible (or uncommon code of the routine) to execute in a
- separate method to avoid moving to much code to this code segment.
-
- It is very easy to use, simply add HOT_METHOD at the end of the
- function declaration.
- For more input see GCC manual (available in GCC 2.95 and later)
-*/
-
-#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94)
-#define HOT_METHOD \
- __attribute__ ((section ("hot_code_section")))
-#else
-#define HOT_METHOD
-#endif
-
-/*
- The following macro is used to ensure that popular global variables
- are located next to each other to avoid that they contend for the
- same cache lines.
-
- It is very easy to use, simply add HOT_DATA at the end of the declaration
- of the variable, the variable must be initialised because of the way
- that linker works so a declaration using HOT_DATA should look like:
- uint global_hot_data HOT_DATA = 0;
- For more input see GCC manual (available in GCC 2.95 and later)
-*/
-
-#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94)
-#define HOT_DATA \
- __attribute__ ((section ("hot_data_section")))
-#else
-#define HOT_DATA
-#endif
-
-/*
- now let's figure out if inline functions are supported
- autoconf defines 'inline' to be empty, if not
-*/
-#define inline_test_1(X) X ## 1
-#define inline_test_2(X) inline_test_1(X)
-#if inline_test_2(inline) != 1
-#define HAVE_INLINE
-#else
-#warning No "inline" support in C, all "static inline" functions will be instantiated in every .o file!!!
-#endif
-#undef inline_test_2
-#undef inline_test_1
-/* helper macro for "instantiating" inline functions */
-#define STATIC_INLINE static inline
-
-/*
- The following macros are used to control inlining a bit more than
- usual. These macros are used to ensure that inlining always or
- never occurs (independent of compilation mode).
- For more input see GCC manual (available in GCC 3.1.1 and later)
-*/
-
-#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10)
-#define ALWAYS_INLINE __attribute__ ((always_inline))
-#define NEVER_INLINE __attribute__ ((noinline))
-#else
-#define ALWAYS_INLINE
-#define NEVER_INLINE
-#endif
-
-
/* Fix problem with S_ISLNK() on Linux */
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE
@@ -423,10 +307,6 @@ C_MODE_END
#undef HAVE_PREAD
#undef HAVE_PWRITE
#endif
-#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
-#undef inline
-#define inline
-#endif
#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */
#undef HAVE_GETHOSTBYNAME_R
@@ -441,18 +321,6 @@ C_MODE_END
#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
#endif
-
-/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
-#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8)
-#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */
-#define __LONG_MAX__ 2147483647
-#endif
-
-/* egcs 1.1.2 has a problem with memcpy on Alpha */
-#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
-#define BAD_MEMCPY
-#endif
-
#if defined(_lint) && !defined(lint)
#define lint
#endif
@@ -557,16 +425,6 @@ C_MODE_END
extern "C" int madvise(void *addr, size_t len, int behav);
#endif
-/* We can not live without the following defines */
-
-#define USE_MYFUNC 1 /* Must use syscall indirection */
-#define MASTER 1 /* Compile without unireg */
-#define ENGLISH 1 /* Messages in English */
-#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */
-#define USE_REGEX 1 /* We want the use the regex library */
-/* Do not define for ultra sparcs */
-#define USE_BMOVE512 1 /* Use this unless system bmove is faster */
-
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
@@ -608,12 +466,6 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define UNINIT_VAR(x) x= x
#endif
-/* Define some useful general macros */
-#if !defined(max)
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
#if !defined(HAVE_UINT)
#undef HAVE_UINT
#define HAVE_UINT
@@ -621,8 +473,6 @@ typedef unsigned int uint;
typedef unsigned short ushort;
#endif
-#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
-#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
#define test(a) ((a) ? 1 : 0)
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
@@ -636,18 +486,6 @@ typedef unsigned short ushort;
#define FALSE (0) /* Logical false */
#endif
-#if defined(__GNUC__)
-#define function_volatile volatile
-#define my_reinterpret_cast(A) reinterpret_cast<A>
-#define my_const_cast(A) const_cast<A>
-# ifndef GCC_VERSION
-# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
-# endif
-#elif !defined(my_reinterpret_cast)
-#define my_reinterpret_cast(A) (A)
-#define my_const_cast(A) (A)
-#endif
-
#include <my_compiler.h>
/*
@@ -674,9 +512,6 @@ C_MODE_END
# endif
#endif
-#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
-#define ASCII_BITS_USED 8 /* Bit char used */
-
/* Some types that is different between systems */
typedef int File; /* File descriptor */
@@ -753,14 +588,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#endif /* __WIN__ */
-/* #define USE_RECORD_LOCK */
-
- /* Unsigned types supported by the compiler */
-#define UNSINT8 /* unsigned int8 (char) */
-#define UNSINT16 /* unsigned int16 */
-#define UNSINT32 /* unsigned int32 */
-
- /* General constants */
+/* General constants */
#define FN_LEN 256 /* Max file name len */
#define FN_HEADLEN 253 /* Max length of filepart of file name */
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
@@ -821,10 +649,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define OS_FILE_LIMIT UINT_MAX
#endif
-/* #define EXT_IN_LIBNAME */
-/* #define FN_NO_CASE_SENSE */
-/* #define FN_UPPER_CASE TRUE */
-
/*
Io buffer size; Must be a power of 2 and a multiple of 512. May be
smaller what the disk page size. This influences the speed of the
@@ -849,7 +673,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
/* Some things that this system doesn't have */
-#define NO_HASH /* Not needed anymore */
#ifdef _WIN32
#define NO_DIR_LIBRARY /* Not standard dir-library */
#endif
@@ -896,7 +719,6 @@ inline unsigned long long my_double2ulonglong(double d)
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#define ulong_to_double(X) ((double) (ulong) (X))
-#define SET_STACK_SIZE(X) /* Not needed on real machines */
#ifndef STACK_DIRECTION
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
@@ -915,7 +737,6 @@ inline unsigned long long my_double2ulonglong(double d)
/*
Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
- Also on Windows we define these constants by hand in config-win.h.
*/
#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
@@ -1013,9 +834,6 @@ typedef long long my_ptrdiff_t;
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
/* Size to make adressable obj. */
-#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
- /* Offset of field f in structure t */
-#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
@@ -1126,22 +944,6 @@ typedef long long intptr;
#define MY_ERRPTR ((void*)(intptr)1)
-#ifdef USE_RAID
-/*
- The following is done with a if to not get problems with pre-processors
- with late define evaluation
-*/
-#if SIZEOF_OFF_T == 4
-#define SYSTEM_SIZEOF_OFF_T 4
-#else
-#define SYSTEM_SIZEOF_OFF_T 8
-#endif
-#undef SIZEOF_OFF_T
-#define SIZEOF_OFF_T 8
-#else
-#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
-#endif /* USE_RAID */
-
#if defined(_WIN32)
typedef unsigned long long my_off_t;
typedef unsigned long long os_off_t;
@@ -1182,14 +984,10 @@ typedef ulong nesting_map; /* Used for flags of nesting constructs */
#define SOCKET_EMFILE EMFILE
#endif
-typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
-typedef short int15; /* Most effective integer 0 <= x <= 32767 */
typedef int myf; /* Type of MyFlags in my_funcs */
typedef char my_bool; /* Small bool */
- /* Macros for converting *constants* to the right type */
-#define INT8(v) (int8) (v)
-#define INT16(v) (int16) (v)
-#define INT32(v) (int32) (v)
+
+/* Macros for converting *constants* to the right type */
#define MYF(v) (myf) (v)
#ifndef LL
@@ -1233,23 +1031,9 @@ typedef char my_bool; /* Small bool */
#include <my_dbug.h>
-/*
- Sometimes we want to make sure that the variable is not put into
- a register in debugging mode so we can see its value in the core
-*/
-
-#ifndef DBUG_OFF
-#define dbug_volatile volatile
-#else
-#define dbug_volatile
-#endif
-
/* Some helper macros */
#define YESNO(X) ((X) ? "yes" : "no")
-/* Defines for time function */
-#define SCALE_SEC 100
-#define SCALE_USEC 10000
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
@@ -1447,8 +1231,8 @@ do { doubleget_union _tmp; \
((uchar*) &def_temp)[7]=(M)[0];\
(V) = def_temp; } while(0)
#else
-#define float4get(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
-#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float))
+#define float4get(V,M) memcpy(&V, (M), sizeof(float))
+#define float4store(V,M) memcpy(V, (&M), sizeof(float))
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
@@ -1518,12 +1302,12 @@ do { doubleget_union _tmp; \
*(((char*)T)+1)=(((A) >> 16));\
*(((char*)T)+0)=(((A) >> 24)); } while(0)
-#define floatget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float))
-#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float))
-#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
-#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
-#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong))
+#define floatget(V,M) memcpy(&V, (M), sizeof(float))
+#define floatstore(T,V) memcpy((T), (void*) (&V), sizeof(float))
+#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
+#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
+#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
+#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
#else
@@ -1534,15 +1318,15 @@ do { doubleget_union _tmp; \
#define shortstore(T,V) int2store(T,V)
#define longstore(T,V) int4store(T,V)
#ifndef floatstore
-#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float))
-#define floatget(V,M) memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float))
+#define floatstore(T,V) memcpy((T), (void *) (&V), sizeof(float))
+#define floatget(V,M) memcpy(&V, (M), sizeof(float))
#endif
#ifndef doubleget
-#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double))
-#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double))
+#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
+#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
#endif /* doubleget */
-#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong))
+#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
+#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
#endif /* WORDS_BIGENDIAN */
@@ -1580,11 +1364,6 @@ do { doubleget_union _tmp; \
#endif
#endif
-/* FreeBSD 2.2.2 does not define RTLD_NOW) */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-
#ifndef HAVE_DLERROR
#define dlerror() ""
#endif
@@ -1700,8 +1479,6 @@ static inline double rint(double x)
#undef HAVE_SMEM /* No shared memory */
#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */
-#define DONT_USE_RAID
-
#endif /* EMBEDDED_LIBRARY */
#endif /* my_global_h */
diff --git a/include/my_net.h b/include/my_net.h
index 1b8425984ae..5762f5da06e 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -14,9 +14,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
- thread safe version of some common functions:
- my_inet_ntoa
-
This file is also used to make handling of sockets and ioctl()
portable accross systems.
@@ -76,10 +73,6 @@ C_MODE_START
#define in_addr_t uint32
#endif
-/* Thread safe or portable version of some functions */
-
-void my_inet_ntoa(struct in_addr in, char *buf);
-
/*
Handling of gethostbyname_r()
*/
diff --git a/include/my_nosys.h b/include/my_nosys.h
index ecb60333830..96ba6d4c464 100644
--- a/include/my_nosys.h
+++ b/include/my_nosys.h
@@ -30,7 +30,7 @@ extern "C" {
#include <malloc.h>
#endif
-#undef my_read /* Can be predefined in raid.h */
+#undef my_read
#undef my_write
#undef my_seek
#define my_read(a,b,c,d) my_quick_read(a,b,c,d)
diff --git a/include/my_sys.h b/include/my_sys.h
index c5702ec7395..95689535be5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -78,7 +78,7 @@ extern int my_errno; /* Last error in mysys */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */
-#define MY_RAID 64 /* Support for RAID */
+#define MY_UNUSED 64 /* Unused (was support for RAID) */
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
@@ -101,10 +101,6 @@ extern int my_errno; /* Last error in mysys */
#define MY_GIVE_INFO 2 /* Give time info about process*/
#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */
-#define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */
-#define MY_REMOVE_OPTION 1
-#define MY_REMOVE_SECTION 2
-
#define ME_HIGHBYTE 8 /* Shift for colours */
#define ME_NOCUR 1 /* Don't use curses message */
#define ME_OLDWIN 2 /* Use old window */
@@ -266,13 +262,6 @@ extern const char *my_defaults_file;
extern my_bool timed_mutexes;
-typedef struct wild_file_pack /* Struct to hold info when selecting files */
-{
- uint wilds; /* How many wildcards */
- uint not_pos; /* Start of not-theese-files */
- char * *wild; /* Pointer to wildcards */
-} WF_PACK;
-
enum loglevel {
ERROR_LEVEL,
WARNING_LEVEL,
@@ -568,7 +557,6 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name,
/* Prototypes for mysys and my_func functions */
extern int my_copy(const char *from,const char *to,myf MyFlags);
-extern int my_append(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags);
extern int my_getwd(char * buf,size_t size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags);
@@ -584,7 +572,6 @@ extern File my_register_filename(File fd, const char *FileName,
extern File my_create(const char *FileName,int CreateFlags,
int AccessFlags, myf MyFlags);
extern int my_close(File Filedes,myf MyFlags);
-extern File my_dup(File file, myf MyFlags);
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
extern int my_readlink(char *to, const char *filename, myf MyFlags);
extern int my_is_symlink(const char *filename);
@@ -713,9 +700,6 @@ extern char * my_load_path(char * to, const char *path,
const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr,
pbool str_is_pattern);
-extern WF_PACK *wf_comp(char * str);
-extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
-extern void wf_end(struct wild_file_pack *buffer);
extern my_bool array_append_string_unique(const char *str,
const char **array, size_t size);
extern void get_date(char * to,int timeflag,time_t use_time);
@@ -729,8 +713,6 @@ extern int end_record_cache(RECORD_CACHE *info);
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
const uchar *record,size_t length);
extern int flush_write_cache(RECORD_CACHE *info);
-extern long my_clock(void);
-extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void);
extern sig_handler my_set_alarm_variable(int signo);
@@ -852,9 +834,6 @@ extern int my_load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
-extern int modify_defaults_file(const char *file_location, const char *option,
- const char *option_value,
- const char *section_name, int remove_option);
extern int my_search_option_files(const char *conf_file, int *argc,
char ***argv, uint *args_used,
Process_option_func func, void *func_ctx,
diff --git a/include/my_trie.h b/include/my_trie.h
deleted file mode 100644
index 72dd485af04..00000000000
--- a/include/my_trie.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Copyright (C) 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef _trie_h
-#define _trie_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct st_trie_node
-{
- uint16 leaf; /* Depth from root node if match, 0 else */
- uchar c; /* Label on this edge */
- struct st_trie_node *next; /* Next label */
- struct st_trie_node *links; /* Array of edges leaving this node */
- struct st_trie_node *fail; /* AC failure function */
-} TRIE_NODE;
-
-typedef struct st_trie
-{
- TRIE_NODE root;
- MEM_ROOT mem_root;
- CHARSET_INFO *charset;
- uint32 nnodes;
- uint32 nwords;
-} TRIE;
-
-typedef struct st_ac_trie_state
-{
- TRIE *trie;
- TRIE_NODE *node;
-} AC_TRIE_STATE;
-
-extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset);
-extern void trie_free (TRIE *trie);
-extern my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen);
-extern my_bool ac_trie_prepare (TRIE *trie);
-extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state);
-
-
-/* `trie_goto' is internal function and shouldn't be used. */
-
-static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, uchar c)
-{
- TRIE_NODE *next;
- DBUG_ENTER("trie_goto");
- for (next= node->links; next; next= next->next)
- if (next->c == c)
- DBUG_RETURN(next);
- if (root == node)
- DBUG_RETURN(root);
- DBUG_RETURN(NULL);
-}
-
-
-/*
- SYNOPSIS
- int ac_trie_next (AC_TRIE_STATE *state, uchar *c);
- state - valid pointer to `AC_TRIE_STATE'
- c - character to lookup
-
- DESCRIPTION
- Implementation of search using Aho-Corasick automaton.
- Performs char-by-char search.
-
- RETURN VALUE
- `ac_trie_next' returns length of matched word or 0.
-*/
-
-static inline int ac_trie_next (AC_TRIE_STATE *state, uchar *c)
-{
- TRIE_NODE *root, *node;
- DBUG_ENTER("ac_trie_next");
- DBUG_ASSERT(state && c);
- root= &state->trie->root;
- node= state->node;
- while (! (state->node= trie_goto(root, node, *c)))
- node= node->fail;
- DBUG_RETURN(state->node->leaf);
-}
-
-
-/*
- SYNOPSIS
- my_bool trie_search (TRIE *trie, const uchar *key, uint keylen);
- trie - valid pointer to `TRIE'
- key - valid pointer to key to insert
- keylen - non-0 key length
-
- DESCRIPTION
- Performs key lookup in trie.
-
- RETURN VALUE
- `trie_search' returns `true' if key is in `trie'. Otherwise,
- `false' is returned.
-
- NOTES
- Consecutive search here is "best by test". arrays are very short, so
- binary search or hashing would add too much complexity that would
- overweight speed gain. Especially because compiler can optimize simple
- consecutive loop better (tested)
-*/
-
-static inline my_bool trie_search (TRIE *trie, const uchar *key, uint keylen)
-{
- TRIE_NODE *node;
- uint k;
- DBUG_ENTER("trie_search");
- DBUG_ASSERT(trie && key && keylen);
- node= &trie->root;
-
- for (k= 0; k < keylen; k++)
- {
- uchar p;
- if (! (node= node->links))
- DBUG_RETURN(FALSE);
- p= key[k];
- while (p != node->c)
- if (! (node= node->next))
- DBUG_RETURN(FALSE);
- }
-
- DBUG_RETURN(node->leaf > 0);
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/include/my_vle.h b/include/my_vle.h
deleted file mode 100644
index c09f82229c4..00000000000
--- a/include/my_vle.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef VLE_H
-#define VLE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "my_global.h"
-
-/*
- The size (in bytes) required to store the object ITEM, which can be
- either an expression or a type (since sizeof() is used on the item).
-*/
-#define my_vle_sizeof(ITEM) (((sizeof(ITEM) * CHAR_BIT) + 6) / 7)
-
-uchar *my_vle_encode(uchar *vle, size_t max, ulong value);
-uchar const *my_vle_decode(ulong *value_ptr, uchar const *vle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/myisam.h b/include/myisam.h
index 7547f6b475e..3efc65a900a 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -252,7 +252,7 @@ extern ulong myisam_block_size;
extern uint myisam_concurrent_insert;
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
extern my_off_t myisam_max_temp_length;
-extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
+extern ulong myisam_data_pointer_size;
/* usually used to check if a symlink points into the mysql data home */
/* which is normally forbidden */
@@ -481,8 +481,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
const char * name, int rep_quick);
int change_to_newfile(const char * filename, const char * old_ext,
- const char * new_ext, uint raid_chunks,
- myf myflags);
+ const char * new_ext, myf myflags);
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
const char *filetype, const char *filename);
void lock_memory(MI_CHECK *param);
diff --git a/include/mysql_embed.h b/include/mysql_embed.h
index b26b723381d..ae70b9723f8 100644
--- a/include/mysql_embed.h
+++ b/include/mysql_embed.h
@@ -28,7 +28,5 @@
#undef HAVE_SMEM /* No shared memory */
#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */
-#define DONT_USE_RAID
-
#endif /* EMBEDDED_LIBRARY */
#endif /* MYSQL_EMBED_INCLUDED */
diff --git a/include/thr_lock.h b/include/thr_lock.h
index 37dc37f8017..5626c067e5e 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -89,23 +89,11 @@ typedef struct st_thr_lock_info
{
pthread_t thread;
my_thread_id thread_id;
- ulong n_cursors;
} THR_LOCK_INFO;
-/*
- Lock owner identifier. Globally identifies the lock owner within the
- thread and among all the threads. The address of an instance of this
- structure is used as id.
-*/
-
-typedef struct st_thr_lock_owner
-{
- THR_LOCK_INFO *info;
-} THR_LOCK_OWNER;
-
typedef struct st_thr_lock_data {
- THR_LOCK_OWNER *owner;
+ THR_LOCK_INFO *owner;
struct st_thr_lock_data *next,**prev;
struct st_thr_lock *lock;
mysql_cond_t *cond;
@@ -141,19 +129,18 @@ extern LIST *thr_lock_thread_list;
extern mysql_mutex_t THR_LOCK_lock;
my_bool init_thr_lock(void); /* Must be called once/thread */
-#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
void thr_lock_info_init(THR_LOCK_INFO *info);
void thr_lock_init(THR_LOCK *lock);
void thr_lock_delete(THR_LOCK *lock);
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
void *status_param);
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
- THR_LOCK_OWNER *owner,
+ THR_LOCK_INFO *owner,
enum thr_lock_type lock_type,
ulong lock_wait_timeout);
void thr_unlock(THR_LOCK_DATA *data);
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
- uint count, THR_LOCK_OWNER *owner,
+ uint count, THR_LOCK_INFO *owner,
ulong lock_wait_timeout);
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
void
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 8aa1648c834..07f66c28ddb 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -21,8 +21,8 @@
# This file is public domain and comes with NO WARRANTY of any kind
target = libmysqlclient.la
-target_defs = -DMYSQL_CLIENT_NO_THREADS -DDONT_USE_RAID \
- -DDISABLE_MYSQL_THREAD_H @LIB_EXTRA_CCFLAGS@
+target_defs = -DMYSQL_CLIENT_NO_THREADS -DDISABLE_MYSQL_THREAD_H \
+ @LIB_EXTRA_CCFLAGS@
LIBS = @CLIENT_LIBS@
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
@@ -33,7 +33,7 @@ include $(srcdir)/Makefile.shared
libmysqlclient_la_SOURCES = $(target_sources)
libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_las)
libmysqlclient_la_LDFLAGS = $(target_ldflags)
-EXTRA_DIST = Makefile.shared libmysql.def dll.c CMakeLists.txt
+EXTRA_DIST = Makefile.shared libmysql.def CMakeLists.txt
noinst_HEADERS = client_settings.h
link_sources:
@@ -82,7 +82,7 @@ link_sources:
# keep only the stubs for debug.c
#
# A list of needed headers collected from the deps information 000213
-nh = my_global.h config-win32.h dbug.h errmsg.h \
+nh = my_global.h dbug.h errmsg.h \
m_ctype.h m_string.h password.h \
my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \
mysql.h mysql_com.h mysql_version.h mysqld_error.h \
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 53264f2e559..887af62229a 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -37,7 +37,7 @@ target_sources = libmysql.c password.c \
mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
strmake.lo strend.lo \
strnlen.lo strfill.lo is_prefix.lo \
- int2str.lo str2int.lo strinstr.lo strcont.lo \
+ int2str.lo str2int.lo strcont.lo \
strcend.lo ctype-latin1.lo \
bchange.lo bmove.lo bmove_upp.lo longlong2str.lo \
strtoull.lo strtoll.lo llstr.lo my_vsnprintf.lo \
@@ -61,9 +61,8 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo \
mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
- thr_mutex.lo mulalloc.lo string.lo \
- default.lo default_modify.lo \
- my_compress.lo array.lo my_once.lo list.lo my_net.lo \
+ thr_mutex.lo mulalloc.lo string.lo default.lo \
+ my_compress.lo array.lo my_once.lo list.lo \
charset.lo charset-def.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \
my_pread.lo mf_cache.lo md5.lo sha1.lo \
diff --git a/libmysql/dll.c b/libmysql/dll.c
deleted file mode 100644
index b5fcba13f91..00000000000
--- a/libmysql/dll.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright (C) 2000-2004 MySQL AB
-
- 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 Foundation.
-
- There are special exceptions to the terms and conditions of the GPL as it
- is applied to this software. View the full text of the exception in file
- EXCEPTIONS-CLIENT in the directory of this software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
-** Handling initialization of the dll library
-*/
-
-#include <my_global.h>
-#include <my_sys.h>
-#include <my_pthread.h>
-
-static my_bool libmysql_inited=0;
-
-void libmysql_init(void)
-{
- if (libmysql_inited)
- return;
- libmysql_inited=1;
- my_init();
- {
- DBUG_ENTER("libmysql_init");
-#ifdef LOG_ALL
- DBUG_PUSH("d:t:S:O,c::\\tmp\\libmysql.log");
-#else
- if (getenv("LIBMYSQL_LOG") != NULL)
- DBUG_PUSH(getenv("LIBMYSQL_LOG"));
-#endif
- DBUG_VOID_RETURN;
- }
-}
-
-#ifdef __WIN__
-
-static int inited=0,threads=0;
-HINSTANCE s_hModule; /* Saved module handle */
-DWORD main_thread;
-
-BOOL APIENTRY LibMain(HANDLE hInst,DWORD ul_reason_being_called,
- LPVOID lpReserved)
-{
- switch (ul_reason_being_called) {
- case DLL_PROCESS_ATTACH: /* case of libentry call in win 3.x */
- if (!inited++)
- {
- s_hModule=hInst;
- libmysql_init();
- main_thread=GetCurrentThreadId();
- }
- break;
- case DLL_THREAD_ATTACH:
- threads++;
- my_thread_init();
- break;
- case DLL_PROCESS_DETACH: /* case of wep call in win 3.x */
- if (!--inited) /* Safety */
- {
- /* my_thread_init() */ /* This may give extra safety */
- my_end(0);
- }
- break;
- case DLL_THREAD_DETACH:
- /* Main thread will free by my_end() */
- threads--;
- if (main_thread != GetCurrentThreadId())
- my_thread_end();
- break;
- default:
- break;
- } /* switch */
-
- return TRUE;
-
- UNREFERENCED_PARAMETER(lpReserved);
-} /* LibMain */
-
-
-static BOOL do_libmain;
-int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved)
-{
- /*
- Unless environment variable LIBMYSQL_DLLINIT is set, do nothing.
- The environment variable is checked once, during the first call to DllMain()
- (in DLL_PROCESS_ATTACH hook).
- */
- if (ul_reason_being_called == DLL_PROCESS_ATTACH)
- do_libmain = (getenv("LIBMYSQL_DLLINIT") != NULL);
- if (do_libmain)
- return LibMain(hInst,ul_reason_being_called,lpReserved);
- return TRUE;
-}
-
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index d0ed44bd7aa..febbded6af2 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -24,139 +24,6 @@
#include <my_sys.h>
#include "errmsg.h"
-#ifdef GERMAN
-const char *client_errors[]=
-{
- "Unbekannter MySQL Fehler",
- "Kann UNIX-Socket nicht anlegen (%d)",
- "Keine Verbindung zu lokalem MySQL Server, socket: '%-.100s' (%d)",
- "Keine Verbindung zu MySQL Server auf %-.100s (%d)",
- "Kann TCP/IP-Socket nicht anlegen (%d)",
- "Unbekannter MySQL Server Host (%-.100s) (%d)",
- "MySQL Server nicht vorhanden",
- "Protokolle ungleich; Server Version = %d, Client Version = %d",
- "MySQL client ran out of memory",
- "Wrong host info",
- "Localhost via UNIX socket",
- "%-.100s via TCP/IP",
- "Error in server handshake",
- "Lost connection to MySQL server during query",
- "Commands out of sync; you can't run this command now",
- "Verbindung ueber Named Pipe: %-.32s",
- "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)",
- "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
- "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
- "Can't initialize character set %-.32s (path: %-.100s)",
- "Got packet bigger than 'max_allowed_packet' bytes",
- "Embedded server",
- "Error on SHOW SLAVE STATUS:",
- "Error on SHOW SLAVE HOSTS:",
- "Error connecting to slave:",
- "Error connecting to master:",
- "SSL connection error",
- "Malformed packet",
- "This client library is licensed only for use with MySQL servers having '%s' license",
- "Invalid use of null pointer",
- "Statement not prepared",
- "No data supplied for parameters in prepared statement",
- "Data truncated",
- "No parameters exist in the statement",
- "Invalid parameter number",
- "Can't send long data for non-string/non-binary data types (parameter: %d)",
- "Using unsupported buffer type: %d (parameter: %d)",
- "Shared memory: %-.100s",
- "Can't open shared memory; client could not create request event (%lu)",
- "Can't open shared memory; no answer event received from server (%lu)",
- "Can't open shared memory; server could not allocate file mapping (%lu)",
- "Can't open shared memory; server could not get pointer to file mapping (%lu)",
- "Can't open shared memory; client could not allocate file mapping (%lu)",
- "Can't open shared memory; client could not get pointer to file mapping (%lu)",
- "Can't open shared memory; client could not create %s event (%lu)",
- "Can't open shared memory; no answer from server (%lu)",
- "Can't open shared memory; cannot send request event to server (%lu)",
- "Wrong or unknown protocol",
- "Invalid connection handle",
- "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)",
- "Row retrieval was canceled by mysql_stmt_close() call",
- "Attempt to read column without prior row fetch",
- "Prepared statement contains no metadata",
- "Attempt to read a row while there is no result set associated with the statement",
- "This feature is not implemented yet",
- "Lost connection to MySQL server at '%s', system error: %d",
- "Statement closed indirectly because of a preceeding %s() call",
- "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
- "This handle is already connected. Use a separate handle for each connection."
- ""
-};
-
-/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
-
-#elif defined PORTUGUESE
-const char *client_errors[]=
-{
- "Erro desconhecido do MySQL",
- "Não pode criar 'UNIX socket' (%d)",
- "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.100s' (%d)",
- "Não pode se conectar ao servidor MySQL em '%-.100s' (%d)",
- "Não pode criar 'socket TCP/IP' (%d)",
- "'Host' servidor MySQL '%-.100s' (%d) desconhecido",
- "Servidor MySQL desapareceu",
- "Incompatibilidade de protocolos; versão do servidor = %d, versão do cliente = %d",
- "Cliente do MySQL com falta de memória",
- "Informação inválida de 'host'",
- "Localhost via 'UNIX socket'",
- "%-.100s via 'TCP/IP'",
- "Erro na negociação de acesso ao servidor",
- "Conexão perdida com servidor MySQL durante 'query'",
- "Comandos fora de sincronismo; você não pode executar este comando agora",
- "Named pipe: %-.32s",
- "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
- "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
- "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
- "Não pode inicializar conjunto de caracteres %-.32s (caminho %-.100s)",
- "Obteve pacote maior do que 'max_allowed_packet' bytes",
- "Embedded server"
- "Error on SHOW SLAVE STATUS:",
- "Error on SHOW SLAVE HOSTS:",
- "Error connecting to slave:",
- "Error connecting to master:",
- "SSL connection error",
- "Malformed packet",
- "This client library is licensed only for use with MySQL servers having '%s' license",
- "Invalid use of null pointer",
- "Statement not prepared",
- "No data supplied for parameters in prepared statement",
- "Data truncated",
- "No parameters exist in the statement",
- "Invalid parameter number",
- "Can't send long data for non-string/non-binary data types (parameter: %d)",
- "Using unsupported buffer type: %d (parameter: %d)",
- "Shared memory: %-.100s",
- "Can't open shared memory; client could not create request event (%lu)",
- "Can't open shared memory; no answer event received from server (%lu)",
- "Can't open shared memory; server could not allocate file mapping (%lu)",
- "Can't open shared memory; server could not get pointer to file mapping (%lu)",
- "Can't open shared memory; client could not allocate file mapping (%lu)",
- "Can't open shared memory; client could not get pointer to file mapping (%lu)",
- "Can't open shared memory; client could not create %s event (%lu)",
- "Can't open shared memory; no answer from server (%lu)",
- "Can't open shared memory; cannot send request event to server (%lu)",
- "Wrong or unknown protocol",
- "Invalid connection handle",
- "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)",
- "Row retrieval was canceled by mysql_stmt_close() call",
- "Attempt to read column without prior row fetch",
- "Prepared statement contains no metadata",
- "Attempt to read a row while there is no result set associated with the statement",
- "This feature is not implemented yet",
- "Lost connection to MySQL server at '%s', system error: %d",
- "Statement closed indirectly because of a preceeding %s() call",
- "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
- "This handle is already connected. Use a separate handle for each connection."
- ""
-};
-
-#else /* ENGLISH */
const char *client_errors[]=
{
"Unknown MySQL error",
@@ -220,7 +87,6 @@ const char *client_errors[]=
"This handle is already connected. Use a separate handle for each connection."
""
};
-#endif
const char** get_client_errmsgs()
{
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 02ed93fa501..550b1b7b107 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -214,13 +214,6 @@ void STDCALL mysql_server_end()
}
mysql_client_init= org_my_init_done= 0;
-#ifdef EMBEDDED_SERVER
- if (stderror_file)
- {
- fclose(stderror_file);
- stderror_file= 0;
- }
-#endif
}
static MYSQL_PARAMETERS mysql_internal_parameters=
diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am
index dab45d93673..30aa2467dab 100644
--- a/libmysql_r/Makefile.am
+++ b/libmysql_r/Makefile.am
@@ -21,8 +21,7 @@
# This file is public domain and comes with NO WARRANTY of any kind
target = libmysqlclient_r.la
-target_defs = -DDISABLE_MYSQL_PRLOCK_H -DDONT_USE_RAID \
- -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
+target_defs = -DDISABLE_MYSQL_PRLOCK_H -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 6f553ef9c11..a7efcb024ec 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -67,7 +67,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/sql_truncate.cc
../sql/sql_lex.cc ../sql/keycaches.cc
../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc
- ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc
+ ../sql/sql_binlog.cc ../sql/sql_manager.cc
../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc
../sql/debug_sync.cc
../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 9d8c5edaa12..1ffa349bcfe 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -66,7 +66,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
sql_profile.cc sql_truncate.cc datadict.cc \
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
- sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
+ sql_lex.cc sql_list.cc sql_manager.cc \
scheduler.cc sql_connect.cc sql_parse.cc \
sql_prepare.cc sql_derived.cc sql_rename.cc \
sql_select.cc sql_do.cc sql_show.cc set_var.cc sys_vars.cc \
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index 47167f0bf96..800044242ac 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -14,6 +14,7 @@ main.information_schema # Bug#47449 2009-09-19 alik main.inform
main.lock_multi_bug38499 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
main.lock_multi_bug38691 @solaris # Bug#47792 2009-10-02 alik main.lock_multi_bug38691 times out sporadically on Solaris 10
main.log_tables # Bug#47924 2009-10-08 alik main.log_tables times out sporadically
+main.lowercase_table2 @darwin # Bug#55509 2010-07-26 alik main.lowercase_table2 fails on Mac OSX (again)
main.mysqlbinlog_row @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max
main.mysqlbinlog_row_innodb @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max
main.mysqlbinlog_row_myisam @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max
@@ -25,7 +26,6 @@ main.type_float @freebsd # Bug#38965 2010-05-04 alik test cases
main.wait_timeout @solaris # Bug#51244 2010-04-26 alik wait_timeout fails on OpenSolaris
parts.partition_alter4_innodb # Bug#45299 2010-06-28 alik Test "partition_alter4_innodb" is taking too long, timeout
-perfschema.pfs_upgrade # Bug#53102 2010-06-15 alik perfschema.pfs_upgrade fails on sol10 sparc64 max in parallel mode
rpl.rpl_heartbeat_basic # BUG#54820 2010-06-26 alik rpl.rpl_heartbeat_basic fails sporadically again
rpl.rpl_heartbeat_2slaves # BUG#43828 2009-10-22 luis fails sporadically
diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc
index 0031cb68647..98988ab55ba 100644
--- a/mysql-test/include/handler.inc
+++ b/mysql-test/include/handler.inc
@@ -1757,3 +1757,35 @@ disconnect con51355;
--echo # Connection default
connection default;
+
+--echo #
+--echo # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+ SELECT 1 FROM t2 INTO @a;
+ RETURN 1;
+END|
+delimiter ;|
+
+# Get f1() parsed and cached
+--error ER_NO_SUCH_TABLE
+SELECT f1();
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1);
+HANDLER t1 OPEN;
+# This used to cause the assert
+--error ER_NO_SUCH_TABLE
+HANDLER t1 READ FIRST WHERE f1() = 1;
+HANDLER t1 CLOSE;
+
+DROP FUNCTION f1;
+DROP TABLE t1;
diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl
index 489db060e99..5e785c86027 100755
--- a/mysql-test/lib/v1/mysql-test-run.pl
+++ b/mysql-test/lib/v1/mysql-test-run.pl
@@ -3113,7 +3113,6 @@ sub install_db ($$) {
mtr_add_arg($args, "--bootstrap");
mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
mtr_add_arg($args, "--datadir=%s", $data_dir);
- mtr_add_arg($args, "--loose-skip-innodb");
mtr_add_arg($args, "--loose-skip-ndbcluster");
mtr_add_arg($args, "--tmpdir=.");
mtr_add_arg($args, "--core-file");
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 90dde034e10..304f562d47d 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -1370,3 +1370,16 @@ CREATE TABLE t1 (id int);
INSERT INTO t1 VALUES (1), (2);
ALTER TABLE t1 ADD COLUMN (f1 INT), ADD COLUMN (f2 INT), ADD KEY f2k(f2);
DROP TABLE t1;
+#
+# Test for bug #53820 "ALTER a MEDIUMINT column table causes full
+# table copy".
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b MEDIUMINT);
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+# The below ALTER should not copy table and so no rows should
+# be shown as affected.
+ALTER TABLE t1 CHANGE a id INT;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+DROP TABLE t1;
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index 685e1e5ba4b..028c8b32f87 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -12775,3 +12775,29 @@ a
1
2
DROP TABLE t1;
+#
+# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int) ENGINE=ARCHIVE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+FLUSH TABLES;
+INSERT INTO t1 VALUES (2);
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result
index 08d2fc58e8a..121cfa89f1c 100644
--- a/mysql-test/r/handler_innodb.result
+++ b/mysql-test/r/handler_innodb.result
@@ -1710,3 +1710,23 @@ ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
# Connection con51355
# Connection default
+#
+# Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER
+#
+DROP TABLE IF EXISTS t1, t2;
+DROP FUNCTION IF EXISTS f1;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+SELECT 1 FROM t2 INTO @a;
+RETURN 1;
+END|
+SELECT f1();
+ERROR 42S02: Table 'test.t2' doesn't exist
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f1() = 1;
+ERROR 42S02: Table 'test.t2' doesn't exist
+HANDLER t1 CLOSE;
+DROP FUNCTION f1;
+DROP TABLE t1;
diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result
index 31bc828b0b9..fd08fd12f15 100644
--- a/mysql-test/r/handler_myisam.result
+++ b/mysql-test/r/handler_myisam.result
@@ -1707,6 +1707,26 @@ HANDLER t1 CLOSE;
# Connection con51355
# Connection default
#
+# Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER
+#
+DROP TABLE IF EXISTS t1, t2;
+DROP FUNCTION IF EXISTS f1;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+SELECT 1 FROM t2 INTO @a;
+RETURN 1;
+END|
+SELECT f1();
+ERROR 42S02: Table 'test.t2' doesn't exist
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f1() = 1;
+ERROR 42S02: Table 'test.t2' doesn't exist
+HANDLER t1 CLOSE;
+DROP FUNCTION f1;
+DROP TABLE t1;
+#
# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
#
CREATE TABLE t1 AS SELECT 1 AS f1;
diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result
index 7cc76611fb8..e3a3e0e9740 100644
--- a/mysql-test/r/heap_hash.result
+++ b/mysql-test/r/heap_hash.result
@@ -382,3 +382,14 @@ INSERT INTO t1 VALUES('A ', 'A ');
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
DROP TABLE t1;
End of 5.0 tests
+#
+# Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c
+# on DELETE statement
+#
+CREATE TABLE t1 (col_int_nokey INT,
+col_int_key INT,
+INDEX(col_int_key) USING HASH) ENGINE = HEAP;
+INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
+DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
+DROP TABLE t1;
+End of 5.5 tests
diff --git a/mysql-test/r/innodb_mysql_lock.result b/mysql-test/r/innodb_mysql_lock.result
index 95adf712cb4..bf1c3a89f40 100644
--- a/mysql-test/r/innodb_mysql_lock.result
+++ b/mysql-test/r/innodb_mysql_lock.result
@@ -116,3 +116,35 @@ Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
DROP TABLE t1;
+#
+# Bug#49891 View DDL breaks REPEATABLE READ
+#
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v2;
+CREATE TABLE t1 ( f1 INTEGER ) ENGINE = innodb;
+CREATE TABLE t2 ( f1 INTEGER );
+CREATE VIEW v1 AS SELECT 1 FROM t1;
+# Connection con3
+LOCK TABLE t1 WRITE;
+# Connection default
+START TRANSACTION;
+# Sending:
+SELECT * FROM v1;
+# Connection con2
+# Waiting for 'SELECT * FROM v1' to sync in.
+# Sending:
+ALTER VIEW v1 AS SELECT 2 FROM t2;
+# Connection con3
+# Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in.
+UNLOCK TABLES;
+# Connection default;
+# Reaping: SELECT * FROM v1
+1
+SELECT * FROM v1;
+1
+COMMIT;
+# Connection con2
+# Reaping: ALTER VIEW v1 AS SELECT 2 FROM t2
+# Connection default
+DROP TABLE t1, t2;
+DROP VIEW v1;
diff --git a/mysql-test/r/innodb_mysql_sync.result b/mysql-test/r/innodb_mysql_sync.result
index 0e75e62b13a..43a98829d4e 100644
--- a/mysql-test/r/innodb_mysql_sync.result
+++ b/mysql-test/r/innodb_mysql_sync.result
@@ -48,3 +48,21 @@ Warnings:
Error 1146 Table 'test.t1' doesn't exist
# Connection default
SET DEBUG_SYNC= "RESET";
+#
+# Bug#53757 assert in mysql_truncate_by_delete
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1(a INT) Engine=InnoDB;
+CREATE TABLE t2(id INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES(connection_id());
+SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
+# Sending: (not reaped since connection is killed later)
+TRUNCATE t1;
+SET DEBUG_SYNC= "now WAIT_FOR opening";
+SELECT ((@id := id) - id) FROM t2;
+((@id := id) - id)
+0
+KILL @id;
+SET DEBUG_SYNC= "now SIGNAL killed";
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result
index 67d778211dd..0fd408b0208 100644
--- a/mysql-test/r/mdl_sync.result
+++ b/mysql-test/r/mdl_sync.result
@@ -2527,3 +2527,240 @@ SET DEBUG_SYNC= "now SIGNAL completed";
Field Type Collation Null Key Default Extra Privileges Comment
a char(255) latin1_swedish_ci YES NULL #
DROP TABLE t1;
+#
+# Tests for schema-scope locks
+#
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+# Test 1:
+# CREATE DATABASE blocks database DDL on the same database, but
+# not database DDL on different databases. Tests X vs X lock.
+#
+# Connection default
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+CREATE DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+CREATE DATABASE db1;
+# Connection con3
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: CREATE DATABASE db1
+# Connection con2
+# Reaping: CREATE DATABASE db1
+ERROR HY000: Can't create database 'db1'; database exists
+# Test 2:
+# ALTER DATABASE blocks database DDL on the same database, but
+# not database DDL on different databases. Tests X vs X lock.
+#
+# Connection default
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
+# Connection con3
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+# Connection con2
+# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+# Connection default
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+DROP DATABASE db1;
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+# Connection con2
+# Reaping: DROP DATABASE db1
+CREATE DATABASE db1;
+# Test 3:
+# Two ALTER..UPGRADE of the same database are mutually exclusive, but
+# two ALTER..UPGRADE of different databases are not. Tests X vs X lock.
+#
+# Connection default
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+# Connection con3
+ALTER DATABASE `#mysql50#a-b-c-d` UPGRADE DATA DIRECTORY NAME;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+# Connection con2
+# Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+ERROR 42000: Unknown database '#mysql50#a-b-c'
+DROP DATABASE `a-b-c`;
+DROP DATABASE `a-b-c-d`;
+# Test 4:
+# DROP DATABASE blocks database DDL on the same database, but
+# not database DDL on different databases. Tests X vs X lock.
+#
+# Connection default
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+DROP DATABASE db1;
+# Connection con3
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: DROP DATABASE db1
+ERROR HY000: Can't drop database 'db1'; database doesn't exist
+# Connection default
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+Got one of the listed errors
+# Test 5:
+# Locked database name prevents CREATE of tables in that database.
+# Tests X vs IX lock.
+#
+# Connection default
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+CREATE TABLE db1.t1 (a INT);
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: CREATE TABLE db1.t1 (a INT)
+ERROR 42000: Unknown database 'db1'
+# Test 6:
+# Locked database name prevents RENAME of tables to/from that database.
+# Tests X vs IX lock.
+#
+# Connection default
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+RENAME TABLE db1.t1 TO test.t1;
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: RENAME TABLE db1.t1 TO test.t1
+Got one of the listed errors
+# Connection default
+CREATE DATABASE db1;
+CREATE TABLE test.t2 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+RENAME TABLE test.t2 TO db1.t2;
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: RENAME TABLE test.t2 TO db1.t2
+Got one of the listed errors
+DROP TABLE test.t2;
+# Test 7:
+# Locked database name prevents DROP of tables in that database.
+# Tests X vs IX lock.
+#
+# Connection default
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+# Sending:
+DROP TABLE db1.t1;
+# Connection con3
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+# Connection default
+# Reaping: DROP DATABASE db1
+# Connection con2
+# Reaping: DROP TABLE db1.t1
+ERROR 42S02: Unknown table 't1'
+# Connection default
+SET DEBUG_SYNC= 'RESET';
+#
+# End of tests for schema-scope locks
+#
+#
+# Tests of granted global S lock (FLUSH TABLE WITH READ LOCK)
+#
+CREATE DATABASE db1;
+CREATE TABLE db1.t1(a INT);
+# Connection default
+FLUSH TABLE WITH READ LOCK;
+# Connection con2
+CREATE TABLE db1.t2(a INT);
+# Connection default
+UNLOCK TABLES;
+# Connection con2
+# Reaping CREATE TABLE db1.t2(a INT)
+# Connection default
+FLUSH TABLE WITH READ LOCK;
+# Connection con2
+ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
+# Connection default
+UNLOCK TABLES;
+# Connection con2
+# Reaping ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+# Connection default
+FLUSH TABLE WITH READ LOCK;
+# Connection con2
+FLUSH TABLE WITH READ LOCK;
+UNLOCK TABLES;
+# Connection default
+UNLOCK TABLES;
+DROP DATABASE db1;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 87d4f75dc8d..f7f0cea3b19 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -1,3 +1,5 @@
+set global storage_engine=myisam;
+set session storage_engine=myisam;
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
create table t1 (a int not null primary key auto_increment, message char(20));
@@ -584,7 +586,9 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
SELECT * FROM t3;
-ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+c1
+1
+2
CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
INSERT INTO t4 VALUES (4);
@@ -613,7 +617,9 @@ ERROR HY000: Unable to open underlying table which is differently defined or of
drop table t3;
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
-ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+a
+1
+2
drop table t3, t2, t1;
# CREATE...SELECT is not implemented for MERGE tables.
CREATE TEMPORARY TABLE t1 (c1 INT NOT NULL);
@@ -1196,12 +1202,13 @@ ERROR HY000: Table 't4' was not locked with LOCK TABLES
# it can even be used.
CREATE TEMPORARY TABLE t4 LIKE t3;
SHOW CREATE TABLE t4;
-ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+Table Create Table
+t4 CREATE TEMPORARY TABLE `t4` (
+ `c1` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
INSERT INTO t4 VALUES (4);
-ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
UNLOCK TABLES;
INSERT INTO t4 VALUES (4);
-ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t4;
#
# Rename child.
@@ -1229,6 +1236,8 @@ c1
2
3
4
+4
+4
RENAME TABLE t2 TO t5;
SELECT * FROM t3 ORDER BY c1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
@@ -1239,6 +1248,8 @@ c1
2
3
4
+4
+4
#
# 3. Normal rename with locked tables.
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
@@ -1248,6 +1259,8 @@ c1
2
3
4
+4
+4
RENAME TABLE t2 TO t5;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@@ -1256,6 +1269,8 @@ c1
2
3
4
+4
+4
RENAME TABLE t5 TO t2;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@@ -1264,6 +1279,8 @@ c1
2
3
4
+4
+4
UNLOCK TABLES;
#
# 4. Alter table rename.
@@ -1277,6 +1294,8 @@ c1
2
3
4
+4
+4
#
# 5. Alter table rename with locked tables.
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
@@ -1293,6 +1312,8 @@ c1
2
3
4
+4
+4
#
# Rename parent.
#
@@ -1304,6 +1325,8 @@ c1
2
3
4
+4
+4
RENAME TABLE t3 TO t5;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@@ -1312,6 +1335,8 @@ c1
2
3
4
+4
+4
RENAME TABLE t5 TO t3;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@@ -1320,6 +1345,8 @@ c1
2
3
4
+4
+4
#
# 5. Alter table rename with locked tables.
ALTER TABLE t3 RENAME TO t5;
@@ -1335,6 +1362,8 @@ c1
2
3
4
+4
+4
DROP TABLE t1, t2, t3;
#
# Drop locked tables.
@@ -2650,6 +2679,705 @@ test.t1 optimize Error Unable to open underlying table which is differently defi
test.t1 optimize note The storage engine for the table doesn't support optimize
DROP TABLE t1;
#
+# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+# More tests with TEMPORARY MERGE table and permanent children.
+# First without locked tables.
+#
+DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2;
+#
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m1;
+c1 c2
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+#
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+#
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+ALTER TABLE m2 RENAME m1;
+ERROR 42S01: Table 'm1' already exists
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+#
+ALTER TABLE m1 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+c1 c2 c3
+111 121 NULL
+211 221 NULL
+212 222 232
+#
+ALTER TABLE m1 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+#
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+SELECT * FROM t3;
+c1 c2
+311 321
+#
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+411 421
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+SELECT * FROM t3;
+c1 c2
+311 321
+SELECT * FROM t4;
+c1 c2
+411 421
+#
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+411 421
+511 521
+#
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+#
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+c1 c2
+611 621
+211 221
+212 222
+213 223
+DROP TABLE t1;
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+#
+#
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+#
+CREATE TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST;
+SELECT * FROM m2;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+DROP TABLE m2;
+#
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST SELECT * FROM m1;
+ERROR HY000: 'test.m2' is not BASE TABLE
+#
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST SELECT * FROM m1;
+ERROR HY000: 'test.m2' is not BASE TABLE
+#
+CREATE TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1 c2
+311 321
+411 421
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+#
+#
+LOCK TABLE m1 WRITE, m2 WRITE;
+SELECT * FROM m1,m2 WHERE m1.c1=m2.c1;
+c1 c2 c1 c2
+111 121 111 121
+111 121 111 121
+111 121 111 121
+111 121 111 121
+211 221 211 221
+211 221 211 221
+211 221 211 221
+211 221 211 221
+212 222 212 222
+212 222 212 222
+212 222 212 222
+212 222 212 222
+213 223 213 223
+213 223 213 223
+213 223 213 223
+213 223 213 223
+111 121 111 121
+111 121 111 121
+111 121 111 121
+111 121 111 121
+211 221 211 221
+211 221 211 221
+211 221 211 221
+211 221 211 221
+212 222 212 222
+212 222 212 222
+212 222 212 222
+212 222 212 222
+213 223 213 223
+213 223 213 223
+213 223 213 223
+213 223 213 223
+111 121 111 121
+111 121 111 121
+111 121 111 121
+111 121 111 121
+211 221 211 221
+211 221 211 221
+211 221 211 221
+211 221 211 221
+212 222 212 222
+212 222 212 222
+212 222 212 222
+212 222 212 222
+213 223 213 223
+213 223 213 223
+213 223 213 223
+213 223 213 223
+111 121 111 121
+111 121 111 121
+111 121 111 121
+111 121 111 121
+211 221 211 221
+211 221 211 221
+211 221 211 221
+211 221 211 221
+212 222 212 222
+212 222 212 222
+212 222 212 222
+212 222 212 222
+213 223 213 223
+213 223 213 223
+213 223 213 223
+213 223 213 223
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, m1, m2;
+#
+# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+# More tests with TEMPORARY MERGE table and permanent children.
+# (continued) Now the same with locked table.
+#
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m1;
+c1 c2
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+#
+LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE;
+#
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+#
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+ALTER TABLE m2 RENAME m1;
+ERROR 42S01: Table 'm1' already exists
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+#
+ALTER TABLE m1 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+c1 c2 c3
+111 121 NULL
+211 221 NULL
+212 222 232
+#
+ALTER TABLE m1 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+#
+UNLOCK TABLES;
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+LOCK TABLE m1 WRITE;
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+SELECT * FROM t3;
+c1 c2
+311 321
+#
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+411 421
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+SELECT * FROM t3;
+c1 c2
+311 321
+SELECT * FROM t4;
+c1 c2
+411 421
+#
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+311 321
+411 421
+511 521
+#
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+SELECT * FROM t1;
+c1 c2
+111 121
+SELECT * FROM t2;
+c1 c2
+211 221
+212 222
+213 223
+#
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+c1 c2
+611 621
+211 221
+212 222
+213 223
+DROP TABLE t1;
+SELECT * FROM m1;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+#
+#
+SHOW CREATE TABLE m1;
+Table Create Table
+m1 CREATE TEMPORARY TABLE `m1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+CREATE TABLE m2 SELECT * FROM m1;
+ERROR HY000: Table 'm2' was not locked with LOCK TABLES
+#
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST;
+SELECT * FROM m2;
+c1 c2
+311 321
+411 421
+LOCK TABLE m1 WRITE, m2 WRITE;
+UNLOCK TABLES;
+DROP TABLE m2;
+LOCK TABLE m1 WRITE;
+#
+# ER_TABLE_NOT_LOCKED is returned in ps-protocol
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST SELECT * FROM m1;
+Got one of the listed errors
+#
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST SELECT * FROM m1;
+ERROR HY000: 'test.m2' is not BASE TABLE
+#
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+LOCK TABLE m1 WRITE, m2 WRITE;
+SHOW CREATE TABLE m2;
+Table Create Table
+m2 CREATE TEMPORARY TABLE `m2` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1 c2
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+DROP TABLE m2;
+#
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1 c2
+311 321
+411 421
+111 121
+211 221
+212 222
+213 223
+111 121
+211 221
+212 222
+213 223
+#
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, m1, m2;
+#
# Bug47098 assert in MDL_context::destroy on HANDLER
# <damaged merge table> OPEN
#
@@ -2745,4 +3473,106 @@ m2 CREATE TABLE `m2` (
`i` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`)
drop tables m1, m2, t1;
+#
+# Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()"
+# Check that unique_table() works correctly for merge tables.
+#
+drop table if exists t1, t2, t3, m1, m2;
+create table t1 (a int);
+create table t2 (a int);
+create table t3 (b int);
+create view v1 as select * from t3,t1;
+create table m1 (a int) engine=merge union (t1, t2) insert_method=last;
+create table m2 (a int) engine=merge union (t1, t2) insert_method=first;
+create temporary table tmp (b int);
+insert into tmp (b) values (1);
+insert into t1 (a) values (1);
+insert into t3 (b) values (1);
+insert into m1 (a) values ((select max(a) from m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t3, m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t3, m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t3, t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from t3, t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from tmp, m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from tmp, m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from tmp, t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from tmp, t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+insert into m1 (a) values ((select max(a) from v1));
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1'.
+insert into m1 (a) values ((select max(a) from tmp, v1));
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1'.
+update m1 set a = ((select max(a) from m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t3, m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t3, m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t3, t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from t3, t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from tmp, m1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from tmp, m2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from tmp, t1));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from tmp, t2));
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+update m1 set a = ((select max(a) from v1));
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'm1'.
+update m1 set a = ((select max(a) from tmp, v1));
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'm1'.
+delete from m1 where a = (select max(a) from m1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from m2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t3, m1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t3, m2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t3, t1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from t3, t2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from tmp, m1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from tmp, m2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from tmp, t1);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from tmp, t2);
+ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+delete from m1 where a = (select max(a) from v1);
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1'.
+delete from m1 where a = (select max(a) from tmp, v1);
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1'.
+drop view v1;
+drop temporary table tmp;
+drop table t1, t2, t3, m1, m2;
End of 6.0 tests
diff --git a/mysql-test/r/merge_mmap.result b/mysql-test/r/merge_mmap.result
new file mode 100644
index 00000000000..e8014259a4a
--- /dev/null
+++ b/mysql-test/r/merge_mmap.result
@@ -0,0 +1,190 @@
+SET GLOBAL storage_engine = MyISAM;
+SET SESSION storage_engine = MyISAM;
+DROP TABLE IF EXISTS t1, t2, m1, m2;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+SELECT * FROM t2;
+c1
+2
+3
+4
+1
+2
+3
+4
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+SELECT * FROM t2;
+c1
+2
+3
+4
+1
+2
+3
+4
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+c1
+1
+2
+3
+4
+1
+2
+3
+4
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+End of 6.0 tests
diff --git a/mysql-test/r/partition_debug_sync.result b/mysql-test/r/partition_debug_sync.result
index 5ab1044934b..0e3241cf88e 100644
--- a/mysql-test/r/partition_debug_sync.result
+++ b/mysql-test/r/partition_debug_sync.result
@@ -47,7 +47,7 @@ ENGINE = MYISAM
PARTITION p1 VALUES LESS THAN (20),
PARTITION p2 VALUES LESS THAN (100),
PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
-SET DEBUG_SYNC= 'open_tables_acquire_upgradable_mdl SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
+SET DEBUG_SYNC= 'alter_table_before_open_tables SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done';
ALTER TABLE t2 REMOVE PARTITIONING;
# Con default
diff --git a/mysql-test/r/raid.result b/mysql-test/r/raid.result
deleted file mode 100644
index 459da1cdf49..00000000000
--- a/mysql-test/r/raid.result
+++ /dev/null
@@ -1,208 +0,0 @@
-DROP TABLE IF EXISTS t1,t2;
-DROP DATABASE IF EXISTS test_$1;
-create database test_$1;
-create table test_$1.r1 (i int) raid_type=1;
-create table test_$1.r2 (i int) raid_type=1 raid_chunks=32;
-drop database test_$1;
-create database test_$1;
-create table test_$1.r2 (i int) raid_type=1 raid_chunks=257;
-show create table test_$1.r2;
-Table Create Table
-r2 CREATE TABLE `r2` (
- `i` int(11) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 RAID_TYPE=striped RAID_CHUNKS=255 RAID_CHUNKSIZE=256
-drop database test_$1;
-CREATE TABLE t1 (
-id int unsigned not null auto_increment primary key,
-c char(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123;
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from t1;
-count(*)
-450
-ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE t1 ADD KEY c (c);
-ALTER TABLE t1 DROP KEY c;
-ALTER TABLE t1 DROP COLUMN x;
-ALTER TABLE t1 RENAME t2;
-select count(*) from t2;
-count(*)
-450
-DROP TABLE t2;
-/* variable rows */
-CREATE TABLE t1 (
-id int unsigned not null auto_increment primary key,
-c varchar(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121;
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from t1;
-count(*)
-450
-ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE t1 ADD KEY c (c);
-ALTER TABLE t1 DROP KEY c;
-ALTER TABLE t1 DROP COLUMN x;
-ALTER TABLE t1 RENAME t2;
-ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL;
-select count(*) from t2;
-count(*)
-450
-DROP TABLE t2;
diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result
index 2919606d74a..853c3bcf575 100644
--- a/mysql-test/r/schema.result
+++ b/mysql-test/r/schema.result
@@ -16,19 +16,21 @@ drop schema foo;
# Bug #48940 MDL deadlocks against mysql_rm_db
#
DROP SCHEMA IF EXISTS schema1;
+DROP SCHEMA IF EXISTS schema2;
# Connection default
CREATE SCHEMA schema1;
+CREATE SCHEMA schema2;
CREATE TABLE schema1.t1 (a INT);
SET autocommit= FALSE;
INSERT INTO schema1.t1 VALUES (1);
# Connection 2
DROP SCHEMA schema1;
# Connection default
-ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
-Got one of the listed errors
+ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8;
SET autocommit= TRUE;
# Connection 2
# Connection default
+DROP SCHEMA schema2;
#
# Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache
#
@@ -48,3 +50,48 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
UNLOCK TABLES;
# Connection con2
# Connection default
+#
+# Bug#54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER
+#
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+INSERT INTO db1.t1 VALUES (1), (2);
+# Connection con1
+HANDLER db1.t1 OPEN;
+# Connection default
+# Sending:
+DROP DATABASE db1;
+# Connection con2
+# Connection con1
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+HANDLER t1 CLOSE;
+# Connection default
+# Reaping: DROP DATABASE db1
+#
+# Tests for increased CREATE/ALTER/DROP DATABASE concurrency with
+# database name locks.
+#
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+# Connection default
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (id INT);
+START TRANSACTION;
+INSERT INTO db1.t1 VALUES (1);
+# Connection 2
+# DROP DATABASE should block due to the active transaction
+# Sending:
+DROP DATABASE db1;
+# Connection 3
+# But it should still be possible to CREATE/ALTER/DROP other databases.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+# Connection default
+# End the transaction so DROP DATABASE db1 can continue
+COMMIT;
+# Connection 2
+# Reaping: DROP DATABASE db1
+# Connection default;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index ef2277fef38..c1a75281e0e 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -1466,3 +1466,51 @@ t1 CREATE TABLE `t1` (
# Switching to connection 'default'.
UNLOCK TABLES;
DROP TABLE t1;
+#
+# Bug#54905 Connection with WRITE lock cannot ALTER table due to
+# concurrent SHOW CREATE
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT);
+# Connection con1
+LOCK TABLE t1 WRITE;
+# Connection default
+START TRANSACTION;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+# Connection con1
+ALTER TABLE t1 CHARACTER SET = utf8;
+UNLOCK TABLES;
+# Connection default
+COMMIT;
+DROP TABLE t1;
+#
+# Bug#55498 SHOW CREATE TRIGGER takes wrong type of metadata lock.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1;
+# Test 1: SHOW CREATE TRIGGER with WRITE locked table.
+# Connection con1
+LOCK TABLE t1 WRITE;
+# Connection default
+SHOW CREATE TRIGGER t1_bi;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1 utf8 utf8_general_ci latin1_swedish_ci
+# Connection con1
+UNLOCK TABLES;
+# Test 2: ALTER TABLE with SHOW CREATE TRIGGER in transaction
+# Connection default
+START TRANSACTION;
+SHOW CREATE TRIGGER t1_bi;
+Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
+t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1 utf8 utf8_general_ci latin1_swedish_ci
+# Connection con1
+ALTER TABLE t1 CHARACTER SET = utf8;
+# Connection default
+COMMIT;
+DROP TRIGGER t1_bi;
+DROP TABLE t1;
diff --git a/mysql-test/r/signal.result b/mysql-test/r/signal.result
index 410abffcdf0..67bf9330451 100644
--- a/mysql-test/r/signal.result
+++ b/mysql-test/r/signal.result
@@ -1189,6 +1189,8 @@ end $$
call test_signal() $$
Caught by SQLSTATE
Caught by SQLSTATE
+Warnings:
+Warning 1012 Raising a warning
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1204,6 +1206,8 @@ end $$
call test_signal() $$
Caught by number
Caught by number
+Warnings:
+Warning 1012 Raising a warning
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1219,6 +1223,8 @@ end $$
call test_signal() $$
Caught by SQLWARNING
Caught by SQLWARNING
+Warnings:
+Warning 1012 Raising a warning
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1234,6 +1240,8 @@ end $$
call test_signal() $$
Caught by SQLSTATE
Caught by SQLSTATE
+Warnings:
+Error 1012 Raising a not found
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1249,6 +1257,8 @@ end $$
call test_signal() $$
Caught by number
Caught by number
+Warnings:
+Error 1012 Raising a not found
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1264,6 +1274,8 @@ end $$
call test_signal() $$
Caught by NOT FOUND
Caught by NOT FOUND
+Warnings:
+Error 1012 Raising a not found
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1279,6 +1291,8 @@ end $$
call test_signal() $$
Caught by SQLSTATE
Caught by SQLSTATE
+Warnings:
+Error 1012 Raising an error
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1294,6 +1308,8 @@ end $$
call test_signal() $$
Caught by number
Caught by number
+Warnings:
+Error 1012 Raising an error
drop procedure test_signal $$
create procedure test_signal()
begin
@@ -1309,6 +1325,8 @@ end $$
call test_signal() $$
Caught by SQLEXCEPTION
Caught by SQLEXCEPTION
+Warnings:
+Error 1012 Raising an error
drop procedure test_signal $$
#
# Test where SIGNAL can be used
@@ -1455,6 +1473,7 @@ after RESIGNAL
after RESIGNAL
Warnings:
Warning 1012 Raising a warning
+Warning 1012 Raising a warning
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1509,6 +1528,7 @@ after RESIGNAL
after RESIGNAL
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
+Warning 1264 Out of range value for column 'a' at row 1
drop procedure test_resignal $$
create procedure test_resignal()
begin
@@ -1565,6 +1585,7 @@ before RESIGNAL
after RESIGNAL
after RESIGNAL
Warnings:
+Warning 1012 Raising a warning
Warning 5555 RESIGNAL of a warning
drop procedure test_resignal $$
create procedure test_resignal()
@@ -1625,6 +1646,7 @@ before RESIGNAL
after RESIGNAL
after RESIGNAL
Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
Warning 5555 RESIGNAL of a warning
drop procedure test_resignal $$
create procedure test_resignal()
@@ -2126,6 +2148,9 @@ CALL peter_p2() $$
ERROR 42000: Hi, I am a useless error message
show warnings $$
Level Code Message
+Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 9999 Hi, I am a useless error message
drop procedure peter_p1 $$
drop procedure peter_p2 $$
@@ -2135,15 +2160,17 @@ DECLARE x CONDITION FOR SQLSTATE '42000';
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '2';
+SHOW WARNINGS;
RESIGNAL x SET MYSQL_ERRNO = 9999;
END;
BEGIN
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '1';
+SHOW WARNINGS;
RESIGNAL x SET
SCHEMA_NAME = 'test',
-MYSQL_ERRNO= 1231;
+MYSQL_ERRNO= 1232;
END;
/* Raises ER_WRONG_VALUE_FOR_VAR : 1231, SQLSTATE 42000 */
SET @@sql_mode=NULL;
@@ -2156,6 +2183,7 @@ DECLARE x CONDITION for SQLSTATE '42000';
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '3';
+SHOW WARNINGS;
RESIGNAL x SET
MESSAGE_TEXT = 'Hi, I am a useless error message',
MYSQL_ERRNO = 9999;
@@ -2166,15 +2194,24 @@ $$
CALL peter_p2() $$
1
1
+Level Code Message
+Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
2
2
+Level Code Message
+Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL'
3
3
+Level Code Message
+Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL'
ERROR 42000: Hi, I am a useless error message
show warnings $$
Level Code Message
Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
-Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL'
+Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL'
Error 9999 Hi, I am a useless error message
drop procedure peter_p1 $$
diff --git a/mysql-test/r/signal_demo3.result b/mysql-test/r/signal_demo3.result
index aa769659e51..a89ce703d20 100644
--- a/mysql-test/r/signal_demo3.result
+++ b/mysql-test/r/signal_demo3.result
@@ -95,11 +95,11 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
-Error 1644 Oops in proc_5
-Error 1644 Oops in proc_4
-Error 1644 Oops in proc_3
-Error 1644 Oops in proc_2
-Error 1644 Oops in proc_1
+Error 1051 Unknown table 'oops_it_is_not_here'
+Error 1644 Oops in proc_9
+Error 1644 Oops in proc_8
+Error 1644 Oops in proc_7
+Error 1644 Oops in proc_6
SET @@session.max_error_count = 7;
SELECT @@session.max_error_count;
@@session.max_error_count
@@ -108,13 +108,13 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
+Error 1051 Unknown table 'oops_it_is_not_here'
+Error 1644 Oops in proc_9
+Error 1644 Oops in proc_8
Error 1644 Oops in proc_7
Error 1644 Oops in proc_6
Error 1644 Oops in proc_5
Error 1644 Oops in proc_4
-Error 1644 Oops in proc_3
-Error 1644 Oops in proc_2
-Error 1644 Oops in proc_1
SET @@session.max_error_count = 9;
SELECT @@session.max_error_count;
@@session.max_error_count
@@ -123,6 +123,7 @@ call proc_1();
ERROR 45000: Oops in proc_1
show warnings;
Level Code Message
+Error 1051 Unknown table 'oops_it_is_not_here'
Error 1644 Oops in proc_9
Error 1644 Oops in proc_8
Error 1644 Oops in proc_7
@@ -131,7 +132,6 @@ Error 1644 Oops in proc_5
Error 1644 Oops in proc_4
Error 1644 Oops in proc_3
Error 1644 Oops in proc_2
-Error 1644 Oops in proc_1
drop database demo;
SET @@global.max_error_count = @start_global_value;
SELECT @@global.max_error_count;
diff --git a/mysql-test/r/sp-big.result b/mysql-test/r/sp-big.result
index 9765508859c..d28b7004330 100644
--- a/mysql-test/r/sp-big.result
+++ b/mysql-test/r/sp-big.result
@@ -46,6 +46,8 @@ end while;
close cur1;
end|
call p1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select count(*) from t1;
count(*)
256
diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result
index 2374b433fba..a88c89537e2 100644
--- a/mysql-test/r/sp-bugs.result
+++ b/mysql-test/r/sp-bugs.result
@@ -43,6 +43,8 @@ END|
SELECT f2 ();
f2 ()
NULL
+Warnings:
+Error 1305 FUNCTION testdb.f_not_exists does not exist
DROP SCHEMA testdb;
USE test;
#
diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result
index 0a0f620b80a..c7ea4cbb311 100644
--- a/mysql-test/r/sp-code.result
+++ b/mysql-test/r/sp-code.result
@@ -711,6 +711,8 @@ looping i
looping 1
looping i
looping 0
+Warnings:
+Error 1062 Duplicate entry '1' for key 'a'
call proc_26977_works(2);
do something
do something
@@ -730,6 +732,8 @@ looping i
looping 0
optimizer: keep hreturn
optimizer: keep hreturn
+Warnings:
+Error 1062 Duplicate entry '2' for key 'a'
drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
@@ -888,3 +892,56 @@ Pos Instruction
4 jump 6
5 error 1339
DROP PROCEDURE p1;
+#
+# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+#
+
+# - Case 4: check that "No Data trumps Warning".
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE c CURSOR FOR SELECT a FROM t1;
+OPEN c;
+BEGIN
+DECLARE v INT;
+DECLARE CONTINUE HANDLER FOR SQLWARNING
+BEGIN
+SELECT "Warning found!";
+SHOW WARNINGS;
+END;
+DECLARE EXIT HANDLER FOR NOT FOUND
+BEGIN
+SELECT "End of Result Set found!";
+SHOW WARNINGS;
+END;
+WHILE TRUE DO
+FETCH c INTO v;
+END WHILE;
+END;
+CLOSE c;
+SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+SET SESSION debug="+d,bug23032_emit_warning";
+CALL p1();
+Warning found!
+Warning found!
+Level Code Message
+Warning 1105 Unknown error
+Warning found!
+Warning found!
+Level Code Message
+Warning 1105 Unknown error
+Warning found!
+Warning found!
+Level Code Message
+Warning 1105 Unknown error
+End of Result Set found!
+End of Result Set found!
+Level Code Message
+Warning 1105 Unknown error
+Error 1329 No data - zero rows fetched, selected, or processed
+SET SESSION debug="-d,bug23032_emit_warning";
+DROP PROCEDURE p1;
+DROP TABLE t1;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 0f658ee831e..7b8364379df 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1344,6 +1344,8 @@ set @in_func := 0;
select func_20713_a();
func_20713_a()
NULL
+Warnings:
+Error 1146 Table 'test.bogus_table_20713' doesn't exist
select @in_func;
@in_func
2
@@ -1351,6 +1353,8 @@ set @in_func := 0;
select func_20713_b();
func_20713_b()
NULL
+Warnings:
+Error 1146 Table 'test.bogus_table_20713' doesn't exist
select @in_func;
@in_func
2
@@ -1714,3 +1718,246 @@ DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
End of 5.1 tests
+#
+# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+#
+
+# - Case 1
+
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+DROP PROCEDURE IF EXISTS p5;
+DROP PROCEDURE IF EXISTS p6;
+CREATE PROCEDURE p1()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+SELECT 1;
+CALL p2();
+END|
+CREATE PROCEDURE p2()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+END|
+CALL p1();
+CAST('10 ' as unsigned integer)
+10
+1
+1
+CAST('10 ' as unsigned integer)
+10
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+
+# - Case 2
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE c INT DEFAULT 0;
+DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+CALL p2();
+CALL p3();
+CALL p4();
+SELECT c;
+SELECT @@warning_count;
+SHOW WARNINGS;
+END|
+CREATE PROCEDURE p2()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+END|
+CREATE PROCEDURE p3()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+SELECT 1;
+END|
+CREATE PROCEDURE p4()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+CALL p2();
+END|
+CREATE PROCEDURE p5()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+SHOW WARNINGS;
+END|
+CREATE PROCEDURE P6()
+BEGIN
+DECLARE c INT DEFAULT 0;
+DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+CALL p5();
+SELECT c;
+END|
+CALL p1();
+CAST('10 ' as unsigned integer)
+10
+CAST('10 ' as unsigned integer)
+10
+1
+1
+CAST('10 ' as unsigned integer)
+10
+CAST('10 ' as unsigned integer)
+10
+c
+3
+@@warning_count
+1
+Level Code Message
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+CALL p6();
+CAST('10 ' as unsigned integer)
+10
+Level Code Message
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+c
+1
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP PROCEDURE p6;
+
+# - Case 3: check that "Exception trumps No Data".
+
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE c CURSOR FOR SELECT a FROM t1;
+OPEN c;
+BEGIN
+DECLARE v1 INT;
+DECLARE v2 INT;
+DECLARE EXIT HANDLER FOR SQLEXCEPTION
+SELECT "Error caught (expected)";
+DECLARE EXIT HANDLER FOR NOT FOUND
+SELECT "End of Result Set found!";
+WHILE TRUE DO
+FETCH c INTO v1, v2;
+END WHILE;
+END;
+CLOSE c;
+SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+CALL p1();
+Error caught (expected)
+Error caught (expected)
+DROP PROCEDURE p1;
+DROP TABLE t1;
+#
+# Bug#36185: Incorrect precedence for warning and exception handlers
+#
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
+INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL);
+END|
+CALL p1();
+exception
+exception
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '10 '
+Error 1048 Column 'b' cannot be null
+DROP TABLE t1;
+DROP PROCEDURE p1;
+#
+# Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
+#
+
+# - Case 1
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 2);
+CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
+BEGIN
+DECLARE EXIT HANDLER FOR SQLWARNING
+SET NEW.a = 10;
+SET NEW.a = 99999999999;
+END|
+UPDATE t1 SET b = 20;
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SHOW WARNINGS;
+Level Code Message
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT * FROM t1;
+a b
+10 20
+DROP TRIGGER t1_bu;
+DROP TABLE t1;
+
+# - Case 2
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(b CHAR(1));
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+INSERT INTO t2 VALUES('ab'); # Produces a warning.
+INSERT INTO t2 VALUES('b'); # Does not produce a warning,
+# previous warning should be cleared.
+END|
+INSERT INTO t1 VALUES(0);
+SHOW WARNINGS;
+Level Code Message
+SELECT * FROM t1;
+a
+0
+SELECT * FROM t2;
+b
+a
+b
+DROP TRIGGER t1_bi;
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# Bug#9857: Stored procedures: handler for sqlwarning ignored
+#
+SET @sql_mode_saved = @@sql_mode;
+SET sql_mode = traditional;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLWARNING
+SELECT 'warning caught (expected)';
+SELECT 5 / 0;
+END|
+CREATE PROCEDURE p2()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+SELECT 'error caught (unexpected)';
+SELECT 5 / 0;
+END|
+CALL p1();
+5 / 0
+NULL
+warning caught (expected)
+warning caught (expected)
+Warnings:
+Warning 1365 Division by 0
+SHOW WARNINGS;
+Level Code Message
+Warning 1365 Division by 0
+CALL p2();
+5 / 0
+NULL
+Warnings:
+Warning 1365 Division by 0
+SHOW WARNINGS;
+Level Code Message
+Warning 1365 Division by 0
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+SET sql_mode = @sql_mode_saved;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 76d4bf2dea0..243bfb6c07d 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -737,6 +737,8 @@ close c;
end|
insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)|
call cur1()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t1|
id data
foo 40
@@ -772,6 +774,8 @@ close c1;
close c2;
end|
call cur2()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t3 order by i,s|
s i
bar 3
@@ -861,6 +865,8 @@ end$
set @@sql_mode = ''|
set sql_select_limit = 1|
call modes(@c1, @c2)|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
set sql_select_limit = default|
select @c1, @c2|
@c1 @c2
@@ -1682,42 +1688,64 @@ end|
call h_ee()|
h_ee
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_es()|
h_es
Outer (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_en()|
h_en
Outer (good)
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
call h_ew()|
h_ew
Outer (good)
call h_ex()|
h_ex
Outer (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_se()|
h_se
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_ss()|
h_ss
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_sn()|
h_sn
Outer (good)
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
call h_sw()|
h_sw
Outer (good)
call h_sx()|
h_sx
Outer (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_ne()|
h_ne
Inner (good)
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
call h_ns()|
h_ns
Inner (good)
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
call h_nn()|
h_nn
Inner (good)
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
call h_we()|
h_we
Inner (good)
@@ -1730,12 +1758,18 @@ Inner (good)
call h_xe()|
h_xe
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_xs()|
h_xs
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
call h_xx()|
h_xx
Inner (good)
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
drop table t3|
drop procedure h_ee|
drop procedure h_es|
@@ -1884,6 +1918,8 @@ set @x2 = 2;
close c1;
end|
call bug2260()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select @x2|
@x2
2
@@ -2027,6 +2063,8 @@ insert into t3 values (123456789012);
insert into t3 values (0);
end|
call bug2780()|
+Warnings:
+Warning 1264 Out of range value for column 's1' at row 1
select @x|
@x
1
@@ -2449,6 +2487,8 @@ declare continue handler for sqlstate 'HY000' begin end;
select s1 from t3 union select s2 from t3;
end|
call bug4904()|
+Warnings:
+Error 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin2_general_ci,IMPLICIT) for operation 'UNION'
drop procedure bug4904|
drop table t3|
drop procedure if exists bug336|
@@ -2588,13 +2628,17 @@ select row_count()|
row_count()
1
call bug4905()|
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
select row_count()|
row_count()
-0
+-1
call bug4905()|
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
select row_count()|
row_count()
-0
+-1
select * from t3|
s1
1
@@ -2615,10 +2659,14 @@ insert into t3 values (1)|
call bug6029()|
sqlstate 23000
sqlstate 23000
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
delete from t3|
call bug6029()|
1136
1136
+Warnings:
+Error 1136 Column count doesn't match value count at row 1
drop procedure bug6029|
drop table t3|
drop procedure if exists bug8540|
@@ -2910,15 +2958,23 @@ end|
call bug6900()|
2
2
+Warnings:
+Error 1136 Column count doesn't match value count at row 1
call bug9074()|
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
call bug6900_9074(0)|
sqlexception
sqlexception
+Warnings:
+Error 1136 Column count doesn't match value count at row 1
call bug6900_9074(1)|
23000
23000
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
drop procedure bug6900|
drop procedure bug9074|
drop procedure bug6900_9074|
@@ -2961,9 +3017,13 @@ delete from t1|
call bug9856()|
16
16
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
call bug9856()|
16
16
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
drop procedure bug9856|
drop procedure if exists bug9674_1|
drop procedure if exists bug9674_2|
@@ -3194,6 +3254,8 @@ x
2
x
3
+Warnings:
+Error 1326 Cursor is not open
call bug10961()|
x
1
@@ -3201,6 +3263,8 @@ x
2
x
3
+Warnings:
+Error 1326 Cursor is not open
drop procedure bug10961|
DROP PROCEDURE IF EXISTS bug6866|
DROP VIEW IF EXISTS tv|
@@ -3316,7 +3380,11 @@ insert into t1 values
('Name4', 13),
('Name5', 14)|
call bug11529()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
call bug11529()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
delete from t1|
drop procedure bug11529|
set character set utf8|
@@ -3490,24 +3558,32 @@ end;
end if;
end|
call bug12168('a')|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t4|
a
1
3
truncate t4|
call bug12168('b')|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t4|
a
2
4
truncate t4|
call bug12168('a')|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t4|
a
1
3
truncate t4|
call bug12168('b')|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select * from t4|
a
2
@@ -3807,6 +3883,8 @@ end|
call bug7049_2()|
Result
Caught it
+Warnings:
+Error 1062 Duplicate entry '42' for key 'x'
select * from t3|
x
42
@@ -3814,12 +3892,16 @@ delete from t3|
call bug7049_4()|
Result
Caught it
+Warnings:
+Error 1062 Duplicate entry '42' for key 'x'
select * from t3|
x
42
select bug7049_2()|
bug7049_2()
1
+Warnings:
+Error 1062 Duplicate entry '42' for key 'x'
drop table t3|
drop procedure bug7049_1|
drop procedure bug7049_2|
@@ -3947,6 +4029,8 @@ end|
call bug14845()|
a
0
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
drop procedure bug14845|
drop procedure if exists bug13549_1|
drop procedure if exists bug13549_2|
@@ -4150,6 +4234,8 @@ end|
call bug13729()|
55
55
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
select * from t3|
s1
1
@@ -4186,11 +4272,15 @@ Handler
boo
v isnull(v)
NULL 1
+Warnings:
+Error 1054 Unknown column 'undefined_var' in 'field list'
call bug14643_2()|
Handler
boo
Handler
boo
+Warnings:
+Error 1054 Unknown column 'undefined_var' in 'field list'
drop procedure bug14643_1|
drop procedure bug14643_2|
drop procedure if exists bug14304|
@@ -4514,11 +4604,15 @@ Handler
error
End
done
+Warnings:
+Error 1054 Unknown column 'v' in 'field list'
call bug14498_2()|
Handler
error
End
done
+Warnings:
+Error 1054 Unknown column 'v' in 'field list'
call bug14498_3()|
v
maybe
@@ -4526,16 +4620,22 @@ Handler
error
End
done
+Warnings:
+Error 1054 Unknown column 'v' in 'field list'
call bug14498_4()|
Handler
error
End
done
+Warnings:
+Error 1054 Unknown column 'v' in 'field list'
call bug14498_5()|
Handler
error
End
done
+Warnings:
+Error 1054 Unknown column 'v' in 'field list'
drop procedure bug14498_1|
drop procedure bug14498_2|
drop procedure bug14498_3|
@@ -4546,6 +4646,8 @@ drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
+drop procedure if exists bug15231_5|
+drop procedure if exists bug15231_6|
create table t3 (id int not null)|
create procedure bug15231_1()
begin
@@ -4568,7 +4670,7 @@ end|
create procedure bug15231_3()
begin
declare exit handler for sqlwarning
-select 'Caught it (wrong)' as 'Result';
+select 'Caught it (correct)' as 'Result';
call bug15231_4();
end|
create procedure bug15231_4()
@@ -4576,6 +4678,20 @@ begin
declare x decimal(2,1);
set x = 'zap';
select 'Missed it (correct)' as 'Result';
+show warnings;
+end|
+create procedure bug15231_5()
+begin
+declare exit handler for sqlwarning
+select 'Caught it (wrong)' as 'Result';
+call bug15231_6();
+end|
+create procedure bug15231_6()
+begin
+declare x decimal(2,1);
+set x = 'zap';
+select 'Missed it (correct)' as 'Result';
+select id from t3;
end|
call bug15231_1()|
1
@@ -4583,19 +4699,29 @@ Before NOT FOUND condition is triggered
2
After NOT FOUND condtition is triggered
xid xdone
-1 0
+1 1
Warnings:
Warning 1329 No data - zero rows fetched, selected, or processed
call bug15231_3()|
Result
Missed it (correct)
+Level Code Message
+Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1
+Result
+Caught it (correct)
Warnings:
Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
+call bug15231_5()|
+Result
+Missed it (correct)
+id
+drop table t3|
+drop procedure bug15231_1|
+drop procedure bug15231_2|
+drop procedure bug15231_3|
+drop procedure bug15231_4|
+drop procedure bug15231_5|
+drop procedure bug15231_6|
drop procedure if exists bug15011|
create table t3 (c1 int primary key)|
insert into t3 values (1)|
@@ -4613,6 +4739,8 @@ end|
call bug15011()|
Handler
Inner
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
drop procedure bug15011|
drop table t3|
drop procedure if exists bug17476|
@@ -4688,6 +4816,8 @@ i
1
i
0
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
drop table t3|
drop procedure bug16887|
drop procedure if exists bug16474_1|
@@ -4760,6 +4890,8 @@ declare continue handler for sqlexception begin end;
select no_such_function();
end|
call bug18787()|
+Warnings:
+Error 1305 FUNCTION test.no_such_function does not exist
drop procedure bug18787|
create database bug18344_012345678901|
use bug18344_012345678901|
@@ -5133,6 +5265,8 @@ statement failed
statement failed
statement after update
statement after update
+Warnings:
+Error 1242 Subquery returns more than 1 row
select * from t3|
a
1
@@ -5144,6 +5278,8 @@ statement failed
statement failed
statement after update
statement after update
+Warnings:
+Error 1242 Subquery returns more than 1 row
select * from t3|
a
1
@@ -5176,6 +5312,8 @@ in continue handler
in continue handler
reachable code a2
reachable code a2
+Warnings:
+Error 1242 Subquery returns more than 1 row
select * from t3|
a
1
@@ -5191,6 +5329,8 @@ in continue handler
in continue handler
reachable code a2
reachable code a2
+Warnings:
+Error 1242 Subquery returns more than 1 row
select * from t3|
a
1
@@ -5224,6 +5364,8 @@ in continue handler
in continue handler
reachable code a2
reachable code a2
+Warnings:
+Error 1305 FUNCTION test.no_such_function does not exist
drop procedure bug8153_proc_a|
drop procedure bug8153_proc_b|
drop table t3|
@@ -5792,9 +5934,13 @@ end|
select func_8407_a()|
func_8407_a()
NULL
+Warnings:
+Error 1146 Table 'test.no_such_view' doesn't exist
select func_8407_b()|
func_8407_b()
1500
+Warnings:
+Error 1146 Table 'test.no_such_view' doesn't exist
drop function func_8407_a|
drop function func_8407_b|
drop table if exists table_26503|
@@ -5916,6 +6062,8 @@ looping i
looping 0
leaving handler
leaving handler
+Warnings:
+Error 1062 Duplicate entry '1' for key 'a'
call proc_26503_ok_2(2)|
do something
do something
@@ -5927,6 +6075,8 @@ looping i
looping 4
leaving handler
leaving handler
+Warnings:
+Error 1062 Duplicate entry '2' for key 'a'
call proc_26503_ok_3(3)|
do something
do something
@@ -5946,6 +6096,8 @@ looping i
looping 0
leaving handler
leaving handler
+Warnings:
+Error 1062 Duplicate entry '3' for key 'a'
call proc_26503_ok_4(4)|
do something
do something
@@ -5957,6 +6109,8 @@ looping i
looping 4
leaving handler
leaving handler
+Warnings:
+Error 1062 Duplicate entry '4' for key 'a'
drop table table_26503|
drop procedure proc_26503_ok_1|
drop procedure proc_26503_ok_2|
@@ -6670,6 +6824,8 @@ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run';
SELECT x FROM t1;
END|
CALL bug29770();
+Warnings:
+Error 1054 Unknown column 'x' in 'field list'
SELECT @state, @exception;
@state @exception
run NULL
@@ -6708,6 +6864,8 @@ end;
end while;
end//
call proc_33618(20);
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
drop table t_33618;
drop procedure proc_33618;
#
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index f55e535a293..4fa91121f50 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -99,6 +99,8 @@ return i;
end|
set @error_in_func:= 0|
insert into t1 values (bug10015_6(5)), (bug10015_6(6))|
+Warnings:
+Error 1062 Duplicate entry '1' for key 'PRIMARY'
select @error_in_func|
@error_in_func
1
@@ -524,6 +526,8 @@ until done end repeat;
close c;
end|
call bug14210()|
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
select count(*) from t4|
count(*)
256
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 4f259fc4d7d..79f8c20a150 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -1190,6 +1190,8 @@ select'a'; insert into t1 values (200); end;|
call t1();
a
a
+Warnings:
+Error 1264 Out of range value for column 'col1' at row 1
select * from t1;
col1
drop procedure t1;
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index ba6b9f81a2d..33f5c6b5165 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -210,4 +210,16 @@ UPDATE t1,t2 SET t1.a = t2.a;
INSERT INTO t2 SELECT f1();
DROP TABLE t1,t2,t3;
DROP FUNCTION f1;
+#
+# Bug #48067: A temp table with the same name as an existing table,
+# makes drop database fail.
+#
+DROP TEMPORARY TABLE IF EXISTS bug48067.t1;
+DROP DATABASE IF EXISTS bug48067;
+CREATE DATABASE bug48067;
+CREATE TABLE bug48067.t1 (c1 int);
+INSERT INTO bug48067.t1 values (1);
+CREATE TEMPORARY TABLE bug48067.t1 (c1 int);
+DROP DATABASE bug48067;
+DROP TEMPORARY table bug48067.t1;
End of 5.1 tests
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index b6ad1ff31bf..be81afe1a43 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1677,3 +1677,25 @@ SET @@sql_quote_show_create = @sql_quote_show_create_saved;
# End of Bug#34828.
+# Make sure we can manipulate with autocommit in the
+# along with other variables.
+drop table if exists t1;
+drop function if exists t1_max;
+drop function if exists t1_min;
+create table t1 (a int) engine=innodb;
+insert into t1(a) values (0), (1);
+create function t1_max() returns int return (select max(a) from t1);
+create function t1_min() returns int return (select min(a) from t1);
+select t1_min();
+t1_min()
+0
+select t1_max();
+t1_max()
+1
+set @@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+@@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+@@session.autocommit=t1_min(), @@session.autocommit=t1_max();
+# Cleanup.
+drop table t1;
+drop function t1_min;
+drop function t1_max;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index e1c1d6f4128..777ac9c258f 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -1955,15 +1955,15 @@ CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text
test.v1 check Error FUNCTION test.f1 does not exist
test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v1 check status Operation failed
+test.v1 check error Corrupt
test.v2 check status OK
test.v3 check Error FUNCTION test.f1 does not exist
test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v3 check status Operation failed
+test.v3 check error Corrupt
test.v4 check status OK
test.v5 check Error FUNCTION test.f1 does not exist
test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v5 check status Operation failed
+test.v5 check error Corrupt
test.v6 check status OK
create function f1 () returns int return (select max(col1) from t1);
DROP TABLE t1;
@@ -3946,6 +3946,8 @@ create view a as select 1;
end|
call p();
call p();
+Warnings:
+Error 1050 Table 'a' already exists
drop view a;
drop procedure p;
#
diff --git a/mysql-test/suite/federated/federated_server.result b/mysql-test/suite/federated/federated_server.result
index 5079a4dcfa0..e5cff2bb2bf 100644
--- a/mysql-test/suite/federated/federated_server.result
+++ b/mysql-test/suite/federated/federated_server.result
@@ -54,7 +54,7 @@ PASSWORD '',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');
-select * from mysql.servers;
+select * from mysql.servers order by Server_name;
Server_name Host Db Username Password Port Socket Wrapper Owner
server_one 127.0.0.1 first_db root SLAVE_PORT mysql root
server_two 127.0.0.1 second_db root SLAVE_PORT mysql root
@@ -154,7 +154,7 @@ id name
drop table federated.t1;
drop server 'server_one';
drop server 'server_two';
-select * from mysql.servers;
+select * from mysql.servers order by Server_name;
Server_name Host Db Username Password Port Socket Wrapper Owner
drop table first_db.t1;
drop table second_db.t1;
@@ -254,6 +254,8 @@ password '', socket '', owner '', port 3306);
drop server 's1';
# End of 5.1 tests
use test;
+create table t1(a int);
+insert into t1 values (1);
create procedure p1 ()
begin
DECLARE v INT DEFAULT 0;
@@ -268,11 +270,13 @@ ALTER SERVER s OPTIONS (USER 'Remote');
DROP SERVER s;
SET v = v + 1;
END WHILE;
+select a into @a from t1; # Just reset warnings
END//
use test;
call p1();
call p1();
drop procedure p1;
+drop table t1;
drop server if exists s;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
diff --git a/mysql-test/suite/federated/federated_server.test b/mysql-test/suite/federated/federated_server.test
index ec952d071f2..9e883743450 100644
--- a/mysql-test/suite/federated/federated_server.test
+++ b/mysql-test/suite/federated/federated_server.test
@@ -62,7 +62,7 @@ eval create server 'server_two' foreign data wrapper 'mysql' options
OWNER 'root');
--replace_result $SLAVE_MYPORT SLAVE_PORT
-eval select * from mysql.servers;
+eval select * from mysql.servers order by Server_name;
DROP TABLE IF EXISTS federated.old;
--replace_result $SLAVE_MYPORT SLAVE_PORT
@@ -147,7 +147,7 @@ drop table federated.t1;
drop server 'server_one';
drop server 'server_two';
-select * from mysql.servers;
+select * from mysql.servers order by Server_name;
connection slave;
drop table first_db.t1;
@@ -301,6 +301,8 @@ drop server 's1';
connect (other,localhost,root,,);
connection master;
use test;
+create table t1(a int);
+insert into t1 values (1);
delimiter //;
create procedure p1 ()
begin
@@ -316,6 +318,7 @@ begin
DROP SERVER s;
SET v = v + 1;
END WHILE;
+ select a into @a from t1; # Just reset warnings
END//
delimiter ;//
connection other;
@@ -326,6 +329,7 @@ call p1();
connection other;
reap;
drop procedure p1;
+drop table t1;
drop server if exists s;
diff --git a/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result b/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result
index 3e2d084aa0c..2bc9a75a13e 100644
--- a/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result
+++ b/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result
@@ -347,6 +347,8 @@ CALL h1();
-7- 1 1 1 1 1 1
END x1 x2 x3 x4 x5 x6
END 1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
DROP TABLE IF EXISTS tnull;
DROP PROCEDURE IF EXISTS sp1;
CREATE TABLE tnull(f1 int);
@@ -445,6 +447,8 @@ END//
CALL h2();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
SELECT * FROM res_t1;
w x
a b
@@ -550,6 +554,8 @@ exit handler 2
exit handler 2
exit handler 1
exit handler 1
+Warnings:
+Error 1146 Table 'db_storedproc.tqq' doesn't exist
create table res_t1(w char unique, x char);
insert into res_t1 values ('a', 'b');
CREATE PROCEDURE h1 ()
@@ -580,6 +586,8 @@ END//
CALL h1();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
This will fail, SQLSTATE 00000 is not allowed
CREATE PROCEDURE sp1()
begin1_label:BEGIN
@@ -623,6 +631,8 @@ CALL sp2();
NULL
@x2 @x
1 2
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -654,6 +664,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe
CALL sp2();
-1- @x2 @x
-1- 0 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
SELECT '-3-', @x2, @x;
-3- @x2 @x
-3- 1 1
@@ -696,6 +708,8 @@ CALL sp2();
-2- 1 20
-4- @x2 @x
-4- 11 22
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -762,21 +776,33 @@ SELECT @done, @x;
0 1
INSERT INTO temp VALUES('1', NULL);
CALL sp1();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('2', NULL);
CALL sp2();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('3', NULL);
CALL sp3();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
INSERT INTO temp VALUES('4', NULL);
CALL sp4();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
@@ -885,18 +911,26 @@ SELECT @done, @x;
@done @x
0 1
CALL sp1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp2();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp3();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
CALL sp4();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
@@ -1031,6 +1065,8 @@ SQLSTATE
21000
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-1-', @x;
-1- @x
-1- 6
@@ -1041,18 +1077,24 @@ SQLSTATE
SQLEXCEPTION
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-2-', @x;
-2- @x
-2- 6
CALL sp3();
SQLSTATE
20000
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-3-', @x;
-3- @x
-3- 1
CALL sp4();
SQLSTATE
SQLEXCEPTION
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-4-', @x;
-4- @x
-4- 1
@@ -1335,6 +1377,8 @@ CLOSE cur1;
CLOSE cur2;
END//
CALL sp_outer();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT * FROM temp1;
f0 cnt f1 f2 f3 f4
_sp_out_ 1 a` a` 1000-01-01 -5000
diff --git a/mysql-test/suite/funcs_1/r/memory_storedproc_02.result b/mysql-test/suite/funcs_1/r/memory_storedproc_02.result
index 16dde71400e..f18678e3896 100644
--- a/mysql-test/suite/funcs_1/r/memory_storedproc_02.result
+++ b/mysql-test/suite/funcs_1/r/memory_storedproc_02.result
@@ -348,6 +348,8 @@ CALL h1();
-7- 1 1 1 1 1 1
END x1 x2 x3 x4 x5 x6
END 1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
DROP TABLE IF EXISTS tnull;
DROP PROCEDURE IF EXISTS sp1;
CREATE TABLE tnull(f1 int);
@@ -446,6 +448,8 @@ END//
CALL h2();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
SELECT * FROM res_t1;
w x
a b
@@ -551,6 +555,8 @@ exit handler 2
exit handler 2
exit handler 1
exit handler 1
+Warnings:
+Error 1146 Table 'db_storedproc.tqq' doesn't exist
create table res_t1(w char unique, x char);
insert into res_t1 values ('a', 'b');
CREATE PROCEDURE h1 ()
@@ -581,6 +587,8 @@ END//
CALL h1();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
This will fail, SQLSTATE 00000 is not allowed
CREATE PROCEDURE sp1()
begin1_label:BEGIN
@@ -624,6 +632,8 @@ CALL sp2();
NULL
@x2 @x
1 2
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -655,6 +665,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe
CALL sp2();
-1- @x2 @x
-1- 0 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
SELECT '-3-', @x2, @x;
-3- @x2 @x
-3- 1 1
@@ -697,6 +709,8 @@ CALL sp2();
-2- 1 20
-4- @x2 @x
-4- 11 22
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -763,21 +777,33 @@ SELECT @done, @x;
0 1
INSERT INTO temp VALUES('1', NULL);
CALL sp1();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('2', NULL);
CALL sp2();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('3', NULL);
CALL sp3();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
INSERT INTO temp VALUES('4', NULL);
CALL sp4();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
@@ -886,18 +912,26 @@ SELECT @done, @x;
@done @x
0 1
CALL sp1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp2();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp3();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
CALL sp4();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
@@ -1032,6 +1066,8 @@ SQLSTATE
21000
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-1-', @x;
-1- @x
-1- 6
@@ -1042,18 +1078,24 @@ SQLSTATE
SQLEXCEPTION
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-2-', @x;
-2- @x
-2- 6
CALL sp3();
SQLSTATE
20000
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-3-', @x;
-3- @x
-3- 1
CALL sp4();
SQLSTATE
SQLEXCEPTION
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-4-', @x;
-4- @x
-4- 1
@@ -1336,6 +1378,8 @@ CLOSE cur1;
CLOSE cur2;
END//
CALL sp_outer();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT * FROM temp1;
f0 cnt f1 f2 f3 f4
_sp_out_ 1 a` a` 1000-01-01 -5000
diff --git a/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result b/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result
index 16dde71400e..f18678e3896 100644
--- a/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result
+++ b/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result
@@ -348,6 +348,8 @@ CALL h1();
-7- 1 1 1 1 1 1
END x1 x2 x3 x4 x5 x6
END 1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
DROP TABLE IF EXISTS tnull;
DROP PROCEDURE IF EXISTS sp1;
CREATE TABLE tnull(f1 int);
@@ -446,6 +448,8 @@ END//
CALL h2();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
SELECT * FROM res_t1;
w x
a b
@@ -551,6 +555,8 @@ exit handler 2
exit handler 2
exit handler 1
exit handler 1
+Warnings:
+Error 1146 Table 'db_storedproc.tqq' doesn't exist
create table res_t1(w char unique, x char);
insert into res_t1 values ('a', 'b');
CREATE PROCEDURE h1 ()
@@ -581,6 +587,8 @@ END//
CALL h1();
x1 x2 x3 x4 x5 x6
1 1 1 1 1 1
+Warnings:
+Error 1062 Duplicate entry 'a' for key 'w'
This will fail, SQLSTATE 00000 is not allowed
CREATE PROCEDURE sp1()
begin1_label:BEGIN
@@ -624,6 +632,8 @@ CALL sp2();
NULL
@x2 @x
1 2
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -655,6 +665,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe
CALL sp2();
-1- @x2 @x
-1- 0 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
SELECT '-3-', @x2, @x;
-3- @x2 @x
-3- 1 1
@@ -697,6 +709,8 @@ CALL sp2();
-2- 1 20
-4- @x2 @x
-4- 11 22
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
@@ -763,21 +777,33 @@ SELECT @done, @x;
0 1
INSERT INTO temp VALUES('1', NULL);
CALL sp1();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('2', NULL);
CALL sp2();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 1
INSERT INTO temp VALUES('3', NULL);
CALL sp3();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
INSERT INTO temp VALUES('4', NULL);
CALL sp4();
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+Warning 1265 Data truncated for column 'f2' at row 1
SELECT @done, @x;
@done @x
1 0
@@ -886,18 +912,26 @@ SELECT @done, @x;
@done @x
0 1
CALL sp1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp2();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 2
CALL sp3();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
CALL sp4();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT @done, @x;
@done @x
1 1
@@ -1032,6 +1066,8 @@ SQLSTATE
21000
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-1-', @x;
-1- @x
-1- 6
@@ -1042,18 +1078,24 @@ SQLSTATE
SQLEXCEPTION
SQLSTATE
24000
+Warnings:
+Error 1326 Cursor is not open
SELECT '-2-', @x;
-2- @x
-2- 6
CALL sp3();
SQLSTATE
20000
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-3-', @x;
-3- @x
-3- 1
CALL sp4();
SQLSTATE
SQLEXCEPTION
+Warnings:
+Error 1339 Case not found for CASE statement
SELECT '-4-', @x;
-4- @x
-4- 1
@@ -1336,6 +1378,8 @@ CLOSE cur1;
CLOSE cur2;
END//
CALL sp_outer();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT * FROM temp1;
f0 cnt f1 f2 f3 f4
_sp_out_ 1 a` a` 1000-01-01 -5000
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index 082da9938f7..bdb3b285189 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -9325,6 +9325,8 @@ insert into t2 values (1);
set @x = 3;
END//
CALL sp1();
+Warnings:
+Error 1136 Column count doesn't match value count at row 1
DROP PROCEDURE sp1;
DROP PROCEDURE IF EXISTS sp1;
Warnings:
@@ -13754,6 +13756,8 @@ END//
CALL sp1();
x y @x
NULL a 3
+Warnings:
+Error 1305 PROCEDURE db_storedproc.nonsexist does not exist
SELECT @v1, @v2;
@v1 @v2
4 a
@@ -14938,6 +14942,8 @@ NULL NULL
NULL NULL
@x @y
NULL NULL
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE sp1;
Testcase 4.2.63:
@@ -15097,6 +15103,8 @@ END;
fetch cur1 into newf1, newf2, newf4, newf3;
END//
CALL sp1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE sp1;
Testcase 4.2.70:
@@ -22447,6 +22455,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22464,6 +22474,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1305 PROCEDURE db_storedproc.sp1 does not exist
DROP PROCEDURE h1;
Testcase 4.11.3:
@@ -22483,6 +22495,8 @@ CALL sp1 (1);
set @x=0;
END//
CALL h1();
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
SELECT @x, @x2;
@x @x2
1 1
@@ -22501,6 +22515,8 @@ CALL sp1 (1);
set @x=0;
END//
CALL h1 ();
+Warnings:
+Error 1305 PROCEDURE db_storedproc.sp1 does not exist
SELECT @x, @x2;
@x @x2
1 1
@@ -22525,6 +22541,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22547,6 +22565,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22569,6 +22589,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22586,6 +22608,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1305 PROCEDURE db_storedproc.sp1 does not exist
DROP PROCEDURE h1;
Testcase 4.11.9:
@@ -22605,6 +22629,8 @@ CALL sp1 (1);
set @x=0;
END//
CALL h1();
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
SELECT @x, @x2;
@x @x2
1 1
@@ -22623,6 +22649,8 @@ CALL sp1 (1);
set @x=0;
END//
CALL h1 ();
+Warnings:
+Error 1305 PROCEDURE db_storedproc.sp1 does not exist
SELECT @x, @x2;
@x @x2
1 1
@@ -22647,6 +22675,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22669,6 +22699,8 @@ END//
CALL h1 ();
@x @x2
1 1
+Warnings:
+Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
DROP PROCEDURE h1;
DROP PROCEDURE sp1;
@@ -22704,6 +22736,8 @@ done
1
done
1
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22777,6 +22811,8 @@ done
0
done
1
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22814,6 +22850,8 @@ done
0
done
1
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22844,6 +22882,8 @@ done
0
done
1
+Warnings:
+Error 1328 Incorrect number of FETCH variables
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22874,6 +22914,8 @@ done
0
done
1
+Warnings:
+Error 1328 Incorrect number of FETCH variables
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22904,6 +22946,8 @@ END//
CALL h1();
done
0
+Warnings:
+Error 1328 Incorrect number of FETCH variables
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22934,6 +22978,8 @@ END//
CALL h1();
done
0
+Warnings:
+Error 1328 Incorrect number of FETCH variables
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22964,6 +23010,8 @@ done
0
done
1
+Warnings:
+Error 1325 Cursor is already open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -22995,6 +23043,8 @@ done
0
done @x
1 1
+Warnings:
+Error 1325 Cursor is already open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23025,6 +23075,8 @@ END//
CALL h1();
done
0
+Warnings:
+Error 1325 Cursor is already open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23055,6 +23107,8 @@ END//
CALL h1();
done
0
+Warnings:
+Error 1325 Cursor is already open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23082,6 +23136,8 @@ END//
CALL h1();
done @x
1 1
+Warnings:
+Error 1326 Cursor is not open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23109,6 +23165,8 @@ END//
CALL h1();
done @x
1 1
+Warnings:
+Error 1326 Cursor is not open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23134,6 +23192,8 @@ set @x=1;
SELECT done, @x;
END//
CALL h1();
+Warnings:
+Error 1326 Cursor is not open
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23159,6 +23219,8 @@ set @x=1;
SELECT done, @x;
END//
CALL h1();
+Warnings:
+Error 1326 Cursor is not open
DROP PROCEDURE IF EXISTS h1;
drop table IF EXISTS res_t1;
drop table IF EXISTS res_t2;
@@ -23189,6 +23251,8 @@ END//
CALL h1();
done @x
1 1
+Warnings:
+Error 1339 Case not found for CASE statement
DROP PROCEDURE IF EXISTS h1;
drop table IF EXISTS res_t1;
drop table IF EXISTS res_t2;
@@ -23219,6 +23283,8 @@ END//
CALL h1();
done @x
1 1
+Warnings:
+Error 1339 Case not found for CASE statement
DROP PROCEDURE IF EXISTS h1;
drop table IF EXISTS res_t1;
drop table IF EXISTS res_t2;
@@ -23247,6 +23313,8 @@ set @x=1;
SELECT done, @x;
END//
CALL h1();
+Warnings:
+Error 1339 Case not found for CASE statement
DROP PROCEDURE IF EXISTS h1;
drop table IF EXISTS res_t1;
drop table IF EXISTS res_t2;
@@ -23275,6 +23343,8 @@ set @x=1;
SELECT done, @x;
END//
CALL h1();
+Warnings:
+Error 1339 Case not found for CASE statement
DROP PROCEDURE IF EXISTS h1;
DROP TABLE IF EXISTS res_t1;
DROP TABLE IF EXISTS res_t2;
@@ -23423,6 +23493,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR);
INSERT INTO res_t1 VALUES('a', 'b');
INSERT INTO res_t1 VALUES('c', 'd');
CALL h1();
+Warnings:
+Warning 1265 Data truncated for column 'w' at row 1
+Warning 1265 Data truncated for column 'x' at row 1
SELECT @done, @x;
@done @x
1 1
@@ -23445,6 +23518,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR);
INSERT INTO res_t1 VALUES('a', 'b');
INSERT INTO res_t1 VALUES('c', 'd');
CALL h1();
+Warnings:
+Warning 1265 Data truncated for column 'w' at row 1
+Warning 1265 Data truncated for column 'x' at row 1
SELECT @done, @x;
@done @x
1 1
diff --git a/mysql-test/suite/innodb/r/innodb_bug52199.result b/mysql-test/suite/innodb/r/innodb_bug52199.result
new file mode 100644
index 00000000000..7e8c1ee46e0
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug52199.result
@@ -0,0 +1,5 @@
+CREATE TABLE bug52199 (a INT NOT NULL,
+b CHAR(125) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL
+)ENGINE=InnoDB;
+CREATE UNIQUE INDEX idx ON bug52199(a);
+DROP TABLE bug52199;
diff --git a/mysql-test/suite/innodb/r/innodb_bug54679.result b/mysql-test/suite/innodb/r/innodb_bug54679.result
new file mode 100644
index 00000000000..948696fb31d
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug54679.result
@@ -0,0 +1,88 @@
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+SET innodb_strict_mode=ON;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Compressed row_format=COMPRESSED
+ALTER TABLE bug54679 ADD COLUMN b INT;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Compressed row_format=COMPRESSED
+DROP TABLE bug54679;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Compact
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=1;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Compressed KEY_BLOCK_SIZE=1
+ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
+Error 1005 Can't create table '#sql-temporary' (errno: 1478)
+DROP TABLE bug54679;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Redundant row_format=REDUNDANT
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=2;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+TABLE_NAME ROW_FORMAT CREATE_OPTIONS
+bug54679 Compressed row_format=REDUNDANT KEY_BLOCK_SIZE=2
+SET GLOBAL innodb_file_format=Antelope;
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error 1005 Can't create table '#sql-temporary' (errno: 1478)
+ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
+Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
+Error 1005 Can't create table '#sql-temporary' (errno: 1478)
+DROP TABLE bug54679;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+ERROR HY000: Can't create table 'test.bug54679' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
+Error 1005 Can't create table 'test.bug54679' (errno: 1478)
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
+SET GLOBAL innodb_file_format=Barracuda;
+SET GLOBAL innodb_file_per_table=OFF;
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error 1005 Can't create table '#sql-temporary' (errno: 1478)
+ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
+Error 1005 Can't create table '#sql-temporary' (errno: 1478)
+DROP TABLE bug54679;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+ERROR HY000: Can't create table 'test.bug54679' (errno: 1478)
+SHOW WARNINGS;
+Level Code Message
+Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
+Error 1005 Can't create table 'test.bug54679' (errno: 1478)
+SET GLOBAL innodb_file_per_table=ON;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+DROP TABLE bug54679;
diff --git a/mysql-test/suite/innodb/r/innodb_information_schema.result b/mysql-test/suite/innodb/r/innodb_information_schema.result
index 1737dab2ff0..13de084bc09 100644
--- a/mysql-test/suite/innodb/r/innodb_information_schema.result
+++ b/mysql-test/suite/innodb/r/innodb_information_schema.result
@@ -42,21 +42,7 @@ trx_isolation_level varchar(16) NO
trx_unique_checks int(1) NO 0
trx_foreign_key_checks int(1) NO 0
trx_last_foreign_key_error varchar(256) YES NULL
-trx_apative_hash_latched int(1) NO 0
-trx_adaptive_hash_timeout bigint(21) unsigned NO 0
-trx_operation_state varchar(64) YES NULL
-trx_tables_in_use bigint(21) unsigned NO 0
-trx_tables_locked bigint(21) unsigned NO 0
-trx_lock_structs bigint(21) unsigned NO 0
-trx_lock_memory_bytes bigint(21) unsigned NO 0
-trx_rows_locked bigint(21) unsigned NO 0
-trx_rows_modified bigint(21) unsigned NO 0
-trx_concurrency_tickets bigint(21) unsigned NO 0
-trx_isolation_level varchar(16) NO
-trx_unique_checks int(1) NO 0
-trx_foreign_key_checks int(1) NO 0
-trx_last_foreign_key_error varchar(256) YES NULL
-trx_apative_hash_latched int(1) NO 0
+trx_adaptive_hash_latched int(1) NO 0
trx_adaptive_hash_timeout bigint(21) unsigned NO 0
trx_state trx_weight trx_tables_in_use trx_tables_locked trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks
RUNNING 4 0 0 7 1 0 REPEATABLE READ 1 1
diff --git a/mysql-test/suite/innodb/t/innodb_bug52199.test b/mysql-test/suite/innodb/t/innodb_bug52199.test
new file mode 100644
index 00000000000..0fec64ba243
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug52199.test
@@ -0,0 +1,7 @@
+-- source include/have_innodb.inc
+
+CREATE TABLE bug52199 (a INT NOT NULL,
+b CHAR(125) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL
+)ENGINE=InnoDB;
+CREATE UNIQUE INDEX idx ON bug52199(a);
+DROP TABLE bug52199;
diff --git a/mysql-test/suite/innodb/t/innodb_bug54679.test b/mysql-test/suite/innodb/t/innodb_bug54679.test
new file mode 100644
index 00000000000..c5e308acb5e
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug54679.test
@@ -0,0 +1,101 @@
+# Test Bug #54679 alter table causes compressed row_format to revert to compact
+
+--source include/have_innodb.inc
+
+let $file_format=`select @@innodb_file_format`;
+let $file_format_max=`select @@innodb_file_format_max`;
+let $file_per_table=`select @@innodb_file_per_table`;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+SET innodb_strict_mode=ON;
+
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+# The ROW_FORMAT of the table should be preserved when it is not specified
+# in ALTER TABLE.
+ALTER TABLE bug54679 ADD COLUMN b INT;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+DROP TABLE bug54679;
+
+# Check that the ROW_FORMAT conversion to/from COMPRESSED works.
+
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+# KEY_BLOCK_SIZE implies COMPRESSED.
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=1;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+DROP TABLE bug54679;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=2;
+SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables
+WHERE TABLE_NAME='bug54679';
+
+# This prevents other than REDUNDANT or COMPACT ROW_FORMAT for new tables.
+SET GLOBAL innodb_file_format=Antelope;
+
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+DROP TABLE bug54679;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB;
+
+SET GLOBAL innodb_file_format=Barracuda;
+# This will prevent ROW_FORMAT=COMPRESSED, because the system tablespace
+# cannot be compressed.
+SET GLOBAL innodb_file_per_table=OFF;
+
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE bug54679 KEY_BLOCK_SIZE=4;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+DROP TABLE bug54679;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+SHOW WARNINGS;
+SET GLOBAL innodb_file_per_table=ON;
+CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+DROP TABLE bug54679;
+
+# restore original values, quietly so the test does not fail if those
+# defaults are changed
+-- disable_query_log
+EVAL SET GLOBAL innodb_file_format=$file_format;
+EVAL SET GLOBAL innodb_file_format_max=$file_format_max;
+EVAL SET GLOBAL innodb_file_per_table=$file_per_table;
+-- enable_query_log
diff --git a/mysql-test/suite/perfschema/include/upgrade_check.inc b/mysql-test/suite/perfschema/include/upgrade_check.inc
new file mode 100644
index 00000000000..935a71ab065
--- /dev/null
+++ b/mysql-test/suite/perfschema/include/upgrade_check.inc
@@ -0,0 +1,29 @@
+# Copyright (C) 2010 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 Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Routine to be called by pfs_upgrade.test
+# $out_file and $err_file must be set within pfs_upgrade.test.
+#
+
+--error 1
+--exec $MYSQL_UPGRADE --skip-verbose > $out_file 2> $err_file
+
+# Verify that mysql_upgrade complained about the performance_schema
+--cat_file $err_file
+--error 0,1
+--remove_file $out_file
+--error 0,1
+--remove_file $err_file
+
diff --git a/mysql-test/suite/perfschema/r/query_cache.result b/mysql-test/suite/perfschema/r/query_cache.result
index f2fe8c727b2..a0aeac5a916 100644
--- a/mysql-test/suite/perfschema/r/query_cache.result
+++ b/mysql-test/suite/perfschema/r/query_cache.result
@@ -65,3 +65,4 @@ Variable_name Value
Qcache_hits 1
SET GLOBAL query_cache_size= default;
drop table t1;
+flush status;
diff --git a/mysql-test/suite/perfschema/r/selects.result b/mysql-test/suite/perfschema/r/selects.result
index b5bef207303..9b91c6f0fc8 100644
--- a/mysql-test/suite/perfschema/r/selects.result
+++ b/mysql-test/suite/perfschema/r/selects.result
@@ -55,14 +55,21 @@ THREAD_ID EVENT_ID
[THREAD_ID] [EVENT_ID]
[THREAD_ID] [EVENT_ID]
[THREAD_ID] [EVENT_ID]
+DROP TABLE IF EXISTS t_event;
+DROP EVENT IF EXISTS t_ps_event;
+CREATE TABLE t_event AS
+SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT
+WHERE 1 = 2;
CREATE EVENT t_ps_event
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
-DO SELECT DISTINCT EVENT_ID
+DO INSERT INTO t_event
+SELECT DISTINCT EVENT_ID
FROM performance_schema.EVENTS_WAITS_CURRENT
JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID)
ORDER BY EVENT_ID
LIMIT 1;
ALTER TABLE t1 ADD COLUMN c INT;
+DROP TRIGGER IF EXISTS t_ps_trigger;
CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1
FOR EACH ROW BEGIN
SET NEW.c = (SELECT MAX(EVENT_ID)
@@ -76,6 +83,7 @@ id c
12 [EVENT_ID]
13 [EVENT_ID]
DROP TRIGGER t_ps_trigger;
+DROP PROCEDURE IF EXISTS t_ps_proc;
CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT)
BEGIN
SELECT id FROM performance_schema.PROCESSLIST
@@ -83,6 +91,7 @@ WHERE THREAD_ID = tid INTO pid;
END;
|
CALL t_ps_proc(0, @p_id);
+DROP FUNCTION IF EXISTS t_ps_proc;
CREATE FUNCTION t_ps_func(tid INT) RETURNS int
BEGIN
return (SELECT id FROM performance_schema.PROCESSLIST
@@ -92,6 +101,10 @@ END;
SELECT t_ps_func(0) = @p_id;
t_ps_func(0) = @p_id
1
+SELECT * FROM t_event;
+EVENT_ID
+[EVENT_ID]
DROP PROCEDURE t_ps_proc;
DROP FUNCTION t_ps_func;
DROP TABLE t1;
+DROP TABLE t_event;
diff --git a/mysql-test/suite/perfschema/r/server_init.result b/mysql-test/suite/perfschema/r/server_init.result
index ac340f8eb67..8c35425029e 100644
--- a/mysql-test/suite/perfschema/r/server_init.result
+++ b/mysql-test/suite/perfschema/r/server_init.result
@@ -40,26 +40,14 @@ where name like "wait/synch/cond/mysys/THR_COND_threads";
count(name)
1
select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_mysql_create_db";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_open";
count(name)
1
select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_lock_db";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_thread_count";
count(name)
1
select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_mapped_file";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_status";
count(name)
1
diff --git a/mysql-test/suite/perfschema/t/bad_option_1.test b/mysql-test/suite/perfschema/t/bad_option_1.test
index 9962f327093..ee4f0d0d160 100644
--- a/mysql-test/suite/perfschema/t/bad_option_1.test
+++ b/mysql-test/suite/perfschema/t/bad_option_1.test
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2010, 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
@@ -10,8 +10,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
# Tests for PERFORMANCE_SCHEMA
# Check error handling for invalid server start options
@@ -19,8 +19,11 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
+let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_1.txt;
+--error 0,1
+--remove_file $outfile
--error 7
---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $MYSQLTEST_VARDIR/tmp/bad_option_1.txt 2>&1
+--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $outfile 2>&1
perl;
use strict;
@@ -42,4 +45,5 @@ perl;
}
close FILE;
EOF
+--remove_file $outfile
diff --git a/mysql-test/suite/perfschema/t/bad_option_2.test b/mysql-test/suite/perfschema/t/bad_option_2.test
index a8d15764864..b8f45be3cdf 100644
--- a/mysql-test/suite/perfschema/t/bad_option_2.test
+++ b/mysql-test/suite/perfschema/t/bad_option_2.test
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2010, 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
@@ -10,8 +10,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
# Tests for PERFORMANCE_SCHEMA
# Check error handling for ambiguous server start options
@@ -19,8 +19,11 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
+let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_2.txt;
+--error 0,1
+--remove_file $outfile
--error 3
---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $MYSQLTEST_VARDIR/tmp/bad_option_2.txt 2>&1
+--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $outfile 2>&1
perl;
use strict;
@@ -41,4 +44,5 @@ perl;
}
close FILE;
EOF
+--remove_file $outfile
diff --git a/mysql-test/suite/perfschema/t/global_read_lock.test b/mysql-test/suite/perfschema/t/global_read_lock.test
index 16971023cbb..b953ea32ce0 100644
--- a/mysql-test/suite/perfschema/t/global_read_lock.test
+++ b/mysql-test/suite/perfschema/t/global_read_lock.test
@@ -81,6 +81,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES';
unlock tables;
disconnect con1;
+--source include/wait_until_disconnected.inc
--echo connection default;
connection default;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade.test b/mysql-test/suite/perfschema/t/pfs_upgrade.test
index 4902dc73e8a..b8d25d4a66e 100644
--- a/mysql-test/suite/perfschema/t/pfs_upgrade.test
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade.test
@@ -22,6 +22,15 @@
--source include/have_perfschema.inc
--source include/have_lowercase0.inc
+# Some initial settings + Preemptive cleanup
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+let $err_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err;
+let $out_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out;
+--error 0,1
+--remove_file $out_file
+--error 0,1
+--remove_file $err_file
+
--disable_warnings
drop table if exists test.user_table;
drop procedure if exists test.user_proc;
@@ -29,22 +38,20 @@ drop function if exists test.user_func;
drop event if exists test.user_event;
--enable_warnings
+
--echo "Testing mysql_upgrade with TABLE performance_schema.user_table"
create table test.user_table(a int);
-let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--error 0,1
+--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm
--copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm
# Make sure the table is visible
use performance_schema;
show tables like "user_table";
---error 1
---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
-# Verify that mysql_upgrade complained about the performance_schema
---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+--source suite/perfschema/include/upgrade_check.inc
# Make sure the table is still visible
show tables like "user_table";
@@ -54,22 +61,20 @@ use test;
--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm
drop table test.user_table;
+
--echo "Testing mysql_upgrade with VIEW performance_schema.user_view"
create view test.user_view as select "Not supposed to be here";
-let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--error 0,1
+--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm
--copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm
# Make sure the view is visible
use performance_schema;
show tables like "user_view";
---error 1
---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
-# Verify that mysql_upgrade complained about the performance_schema
---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+--source suite/perfschema/include/upgrade_check.inc
# Make sure the view is still visible
show tables like "user_view";
@@ -79,6 +84,7 @@ use test;
--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm
drop view test.user_view;
+
--echo "Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
create procedure test.user_proc()
@@ -86,17 +92,14 @@ create procedure test.user_proc()
update mysql.proc set db='performance_schema' where name='user_proc';
---error 1
---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
-# Verify that mysql_upgrade complained about the performance_schema
---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+--source suite/perfschema/include/upgrade_check.inc
select name from mysql.proc where db='performance_schema';
update mysql.proc set db='test' where name='user_proc';
drop procedure test.user_proc;
+
--echo "Testing mysql_upgrade with FUNCTION performance_schema.user_func"
create function test.user_func() returns integer
@@ -104,17 +107,14 @@ create function test.user_func() returns integer
update mysql.proc set db='performance_schema' where name='user_func';
---error 1
---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
-# Verify that mysql_upgrade complained about the performance_schema
---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+--source suite/perfschema/include/upgrade_check.inc
select name from mysql.proc where db='performance_schema';
update mysql.proc set db='test' where name='user_func';
drop function test.user_func;
+
--echo "Testing mysql_upgrade with EVENT performance_schema.user_event"
create event test.user_event on schedule every 1 day do
@@ -122,17 +122,10 @@ create event test.user_event on schedule every 1 day do
update mysql.event set db='performance_schema' where name='user_event';
---error 1
---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
-# Verify that mysql_upgrade complained about the performance_schema
---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
+--source suite/perfschema/include/upgrade_check.inc
select name from mysql.event where db='performance_schema';
update mysql.event set db='test' where name='user_event';
drop event test.user_event;
---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out
---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err
-
diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test
index d2f3c2a9e6b..2d682de2870 100644
--- a/mysql-test/suite/perfschema/t/privilege.test
+++ b/mysql-test/suite/perfschema/t/privilege.test
@@ -350,9 +350,9 @@ TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY;
TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT;
--echo # Clean up
-
---connection default
--disconnect pfs_user_4
+--source include/wait_until_disconnected.inc
+--connection default
REVOKE ALL PRIVILEGES, GRANT OPTION FROM pfs_user_4;
DROP USER pfs_user_4;
flush privileges;
diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test
index 95f78d290ee..a48704dc9d6 100644
--- a/mysql-test/suite/perfschema/t/query_cache.test
+++ b/mysql-test/suite/perfschema/t/query_cache.test
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (C) 2009 Sun Microsystems, Inc
#
# 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
@@ -10,8 +10,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Tests for PERFORMANCE_SCHEMA
@@ -33,7 +33,6 @@ SET GLOBAL query_cache_size=1355776;
flush query cache;
reset query cache;
-# Reset Qcache_* to a known state
flush status;
select * from t1;
@@ -67,4 +66,5 @@ show status like "Qcache_hits";
SET GLOBAL query_cache_size= default;
drop table t1;
+flush status;
diff --git a/mysql-test/suite/perfschema/t/read_only.test b/mysql-test/suite/perfschema/t/read_only.test
index 62631fa048f..73150207f66 100644
--- a/mysql-test/suite/perfschema/t/read_only.test
+++ b/mysql-test/suite/perfschema/t/read_only.test
@@ -85,6 +85,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES';
--enable_result_log
disconnect con1;
+--source include/wait_until_disconnected.inc
--echo connection default;
connection default;
diff --git a/mysql-test/suite/perfschema/t/selects-master.opt b/mysql-test/suite/perfschema/t/selects-master.opt
new file mode 100644
index 00000000000..f93413a61e5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/selects-master.opt
@@ -0,0 +1 @@
+--event-scheduler
diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test
index d5268e8465c..a0c000b80c1 100644
--- a/mysql-test/suite/perfschema/t/selects.test
+++ b/mysql-test/suite/perfschema/t/selects.test
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# Copyright (c) 2008, 2010, 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
@@ -10,8 +10,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
--source include/not_embedded.inc
--source include/have_perfschema.inc
@@ -85,20 +85,32 @@ LIMIT 5;
# EVENT
+# Check that the event_scheduler is really running
+--source include/running_event_scheduler.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t_event;
+DROP EVENT IF EXISTS t_ps_event;
+--enable_warnings
+CREATE TABLE t_event AS
+SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT
+WHERE 1 = 2;
CREATE EVENT t_ps_event
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
-DO SELECT DISTINCT EVENT_ID
+DO INSERT INTO t_event
+ SELECT DISTINCT EVENT_ID
FROM performance_schema.EVENTS_WAITS_CURRENT
JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID)
ORDER BY EVENT_ID
LIMIT 1;
---sleep 2
-
# TRIGGER
ALTER TABLE t1 ADD COLUMN c INT;
+--disable_warnings
+DROP TRIGGER IF EXISTS t_ps_trigger;
+--enable_warnings
delimiter |;
CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1
@@ -119,6 +131,9 @@ DROP TRIGGER t_ps_trigger;
# PROCEDURE
+--disable_warnings
+DROP PROCEDURE IF EXISTS t_ps_proc;
+--enable_warnings
delimiter |;
CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT)
@@ -135,6 +150,9 @@ CALL t_ps_proc(0, @p_id);
# FUNCTION
+--disable_warnings
+DROP FUNCTION IF EXISTS t_ps_proc;
+--enable_warnings
delimiter |;
CREATE FUNCTION t_ps_func(tid INT) RETURNS int
@@ -149,8 +167,17 @@ delimiter ;|
SELECT t_ps_func(0) = @p_id;
-DROP PROCEDURE t_ps_proc;
-DROP FUNCTION t_ps_func;
+# We might reach this point too early which means the event scheduler has not
+# execute our "t_ps_event". Therefore we poll till the record was inserted
+# and run our test statement afterwards.
+let $wait_timeout= 20;
+let $wait_condition= SELECT COUNT(*) = 1 FROM t_event;
+--source include/wait_condition.inc
+--replace_column 1 [EVENT_ID]
+SELECT * FROM t_event;
# Clean up
+DROP PROCEDURE t_ps_proc;
+DROP FUNCTION t_ps_func;
DROP TABLE t1;
+DROP TABLE t_event;
diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test
index cd9357cce67..2e19d2c843a 100644
--- a/mysql-test/suite/perfschema/t/server_init.test
+++ b/mysql-test/suite/perfschema/t/server_init.test
@@ -69,21 +69,12 @@ select count(name) from COND_INSTANCES
# Verify that these global mutexes have been properly initilized in sql
select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOCK_mysql_create_db";
-
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_open";
select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOCK_lock_db";
-
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_thread_count";
select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOCK_mapped_file";
-
-select count(name) from MUTEX_INSTANCES
where name like "wait/synch/mutex/sql/LOCK_status";
select count(name) from MUTEX_INSTANCES
diff --git a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
index 896ba90b865..459dc83e01d 100644
--- a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
+++ b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
@@ -165,10 +165,6 @@ master-bin.000001 # Table_map # # table_id: # (test.tt_1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0'
-master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Table_map # # table_id: # (mysql.user)
-master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Query # # COMMIT
-e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
-b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
diff --git a/mysql-test/suite/rpl/r/rpl_row_sp005.result b/mysql-test/suite/rpl/r/rpl_row_sp005.result
index 01e1970e0df..58c53b394b2 100644
--- a/mysql-test/suite/rpl/r/rpl_row_sp005.result
+++ b/mysql-test/suite/rpl/r/rpl_row_sp005.result
@@ -77,6 +77,8 @@ id2
< ---- Master selects-- >
-------------------------
CALL test.p1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
SELECT * FROM test.t3 ORDER BY id3;
id3 c
1 MySQL
diff --git a/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result b/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result
index 6792a701577..079e750e2eb 100644
--- a/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result
+++ b/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result
@@ -38,6 +38,8 @@ INSERT INTO t1 VALUES ('MySQL','1993-02-04'),('ROCKS', '1990-08-27'),('Texas', '
END|
CALL p2();
CALL p1();
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE p1;
diff --git a/mysql-test/suite/rpl/r/rpl_row_trig003.result b/mysql-test/suite/rpl/r/rpl_row_trig003.result
index 43c2ecde2b4..131af933b41 100644
--- a/mysql-test/suite/rpl/r/rpl_row_trig003.result
+++ b/mysql-test/suite/rpl/r/rpl_row_trig003.result
@@ -69,9 +69,15 @@ INSERT INTO test.t2 VALUES(NULL,0,'Testing MySQL databases is a cool ', 'MySQL C
UPDATE test.t1 SET b1 = 0 WHERE b1 = 1;
INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW());
UPDATE test.t2 SET b1 = 0 WHERE b1 = 1;
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW());
DELETE FROM test.t1 WHERE id = 1;
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DELETE FROM test.t2 WHERE id = 1;
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
DROP TRIGGER test.t1_bi;
DROP TRIGGER test.t2_ai;
DROP TRIGGER test.t1_bu;
diff --git a/mysql-test/suite/rpl/t/rpl_sync-slave.opt b/mysql-test/suite/rpl/t/rpl_sync-slave.opt
index 7d6147ed59a..fba451a5b3e 100644
--- a/mysql-test/suite/rpl/t/rpl_sync-slave.opt
+++ b/mysql-test/suite/rpl/t/rpl_sync-slave.opt
@@ -1 +1 @@
---sync-relay-log-info=1 --relay-log-recovery=1 --innodb_file_format_check='ON' --default-storage-engine=MyISAM --innodb-file-per-table=0
+--sync-relay-log-info=1 --relay-log-recovery=1 --innodb_file_format_check=1 --default-storage-engine=MyISAM --innodb-file-per-table=0
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index d7f7a12cbf8..5b5fdf50c16 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -1128,3 +1128,19 @@ INSERT INTO t1 VALUES (1), (2);
ALTER TABLE t1 ADD COLUMN (f1 INT), ADD COLUMN (f2 INT), ADD KEY f2k(f2);
DROP TABLE t1;
+
+--echo #
+--echo # Test for bug #53820 "ALTER a MEDIUMINT column table causes full
+--echo # table copy".
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a INT, b MEDIUMINT);
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+--echo # The below ALTER should not copy table and so no rows should
+--echo # be shown as affected.
+--enable_info
+ALTER TABLE t1 CHANGE a id INT;
+--disable_info
+DROP TABLE t1;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index a3665e5f455..c3a080612a9 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1701,3 +1701,24 @@ SELECT * FROM t1;
REPAIR TABLE t1 EXTENDED;
SELECT * FROM t1;
DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a int) ENGINE=ARCHIVE;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.frm;
+FLUSH TABLES;
+INSERT INTO t1 VALUES (2);
+SELECT * FROM t1 ORDER BY a;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test
index 1e3491f89a9..748347021fc 100644
--- a/mysql-test/t/heap_hash.test
+++ b/mysql-test/t/heap_hash.test
@@ -284,3 +284,20 @@ INSERT INTO t1 VALUES('A ', 'A ');
DROP TABLE t1;
--echo End of 5.0 tests
+
+--echo #
+--echo # Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c
+--echo # on DELETE statement
+--echo #
+
+CREATE TABLE t1 (col_int_nokey INT,
+ col_int_key INT,
+ INDEX(col_int_key) USING HASH) ENGINE = HEAP;
+INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
+
+DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
+
+DROP TABLE t1;
+
+--echo End of 5.5 tests
+
diff --git a/mysql-test/t/innodb_mysql_lock.test b/mysql-test/t/innodb_mysql_lock.test
index 36d09b4c411..c8ece729b19 100644
--- a/mysql-test/t/innodb_mysql_lock.test
+++ b/mysql-test/t/innodb_mysql_lock.test
@@ -209,6 +209,74 @@ disconnect con1;
DROP TABLE t1;
+--echo #
+--echo # Bug#49891 View DDL breaks REPEATABLE READ
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v2;
+--enable_warnings
+
+CREATE TABLE t1 ( f1 INTEGER ) ENGINE = innodb;
+CREATE TABLE t2 ( f1 INTEGER );
+CREATE VIEW v1 AS SELECT 1 FROM t1;
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection con3
+connection con3;
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+# This should block due to t1 being locked.
+--echo # Sending:
+--send SELECT * FROM v1
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for 'SELECT * FROM v1' to sync in.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table" AND info = "SELECT * FROM v1";
+--source include/wait_condition.inc
+# This should block due to v1 being locked.
+--echo # Sending:
+--send ALTER VIEW v1 AS SELECT 2 FROM t2
+
+--echo # Connection con3
+connection con3;
+--echo # Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table" AND info = "ALTER VIEW v1 AS SELECT 2 FROM t2";
+--source include/wait_condition.inc
+# Unlock t1 allowing SELECT * FROM v1 to proceed.
+UNLOCK TABLES;
+
+--echo # Connection default;
+connection default;
+--echo # Reaping: SELECT * FROM v1
+--reap
+SELECT * FROM v1;
+COMMIT;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER VIEW v1 AS SELECT 2 FROM t2
+--reap
+
+--echo # Connection default
+connection default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
+disconnect con2;
+disconnect con3;
+
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/innodb_mysql_sync.test b/mysql-test/t/innodb_mysql_sync.test
index ee92ee9f52e..07f75afec40 100644
--- a/mysql-test/t/innodb_mysql_sync.test
+++ b/mysql-test/t/innodb_mysql_sync.test
@@ -80,6 +80,32 @@ disconnect con1;
SET DEBUG_SYNC= "RESET";
+--echo #
+--echo # Bug#53757 assert in mysql_truncate_by_delete
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1(a INT) Engine=InnoDB;
+CREATE TABLE t2(id INT);
+INSERT INTO t1 VALUES (1), (2);
+
+connect (con1, localhost, root);
+INSERT INTO t2 VALUES(connection_id());
+SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
+--echo # Sending: (not reaped since connection is killed later)
+--send TRUNCATE t1
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR opening";
+SELECT ((@id := id) - id) FROM t2;
+KILL @id;
+SET DEBUG_SYNC= "now SIGNAL killed";
+DROP TABLE t1, t2;
+
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test
index 19f9b396087..6b721ace07f 100644
--- a/mysql-test/t/mdl_sync.test
+++ b/mysql-test/t/mdl_sync.test
@@ -3705,6 +3705,481 @@ DROP TABLE t1;
disconnect con1;
+--echo #
+--echo # Tests for schema-scope locks
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+--enable_warnings
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Test 1:
+--echo # CREATE DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send CREATE DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send CREATE DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='CREATE DATABASE db1';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: CREATE DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: CREATE DATABASE db1
+--error ER_DB_CREATE_EXISTS
+--reap
+
+--echo # Test 2:
+--echo # ALTER DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should also block.
+--send DROP DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--reap
+# Recreate the database
+CREATE DATABASE db1;
+
+--echo # Test 3:
+--echo # Two ALTER..UPGRADE of the same database are mutually exclusive, but
+--echo # two ALTER..UPGRADE of different databases are not. Tests X vs X lock.
+--echo #
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+# Manually make a 5.0 database from the template
+--mkdir $MYSQLD_DATADIR/a-b-c
+--copy_file $MYSQLD_DATADIR/db1/db.opt $MYSQLD_DATADIR/a-b-c/db.opt
+--mkdir $MYSQLD_DATADIR/a-b-c-d
+--copy_file $MYSQLD_DATADIR/db1/db.opt $MYSQLD_DATADIR/a-b-c-d/db.opt
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table'
+ AND info='ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME';
+--source include/wait_condition.inc
+# This should not block.
+ALTER DATABASE `#mysql50#a-b-c-d` UPGRADE DATA DIRECTORY NAME;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+--error ER_BAD_DB_ERROR
+--reap
+DROP DATABASE `a-b-c`;
+DROP DATABASE `a-b-c-d`;
+
+--echo # Test 4:
+--echo # DROP DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send DROP DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--error ER_DB_DROP_EXISTS
+--reap
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should also block.
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--error 1,1 # Wrong error pending followup patch for bug#54360
+--reap
+
+
+--echo # Test 5:
+--echo # Locked database name prevents CREATE of tables in that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send CREATE TABLE db1.t1 (a INT)
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='CREATE TABLE db1.t1 (a INT)';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: CREATE TABLE db1.t1 (a INT)
+--error ER_BAD_DB_ERROR
+--reap
+
+--echo # Test 6:
+--echo # Locked database name prevents RENAME of tables to/from that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send RENAME TABLE db1.t1 TO test.t1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='RENAME TABLE db1.t1 TO test.t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: RENAME TABLE db1.t1 TO test.t1
+--error ER_FILE_NOT_FOUND, ER_FILE_NOT_FOUND
+--reap
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE test.t2 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send RENAME TABLE test.t2 TO db1.t2
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='RENAME TABLE test.t2 TO db1.t2';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: RENAME TABLE test.t2 TO db1.t2
+--error 7, 7 # Wrong error pending followup patch for bug#54360
+--reap
+DROP TABLE test.t2;
+
+
+--echo # Test 7:
+--echo # Locked database name prevents DROP of tables in that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send DROP TABLE db1.t1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='DROP TABLE db1.t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP TABLE db1.t1
+--error ER_BAD_TABLE_ERROR
+--reap
+
+--echo # Connection default
+connection default;
+disconnect con2;
+disconnect con3;
+SET DEBUG_SYNC= 'RESET';
+
+--echo #
+--echo # End of tests for schema-scope locks
+--echo #
+
+--echo #
+--echo # Tests of granted global S lock (FLUSH TABLE WITH READ LOCK)
+--echo #
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t1(a INT);
+connect(con2, localhost, root);
+connect(con3, localhost, root);
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# IX global lock should block
+--send CREATE TABLE db1.t2(a INT)
+
+--echo # Connection default
+connection default;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for release of readlock'
+ AND info='CREATE TABLE db1.t2(a INT)';
+--source include/wait_condition.inc
+UNLOCK TABLES;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping CREATE TABLE db1.t2(a INT)
+--reap
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# X global lock should block
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection default
+connection default;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for release of readlock'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+UNLOCK TABLES;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# S global lock should not block
+FLUSH TABLE WITH READ LOCK;
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+DROP DATABASE db1;
+disconnect con2;
+disconnect con3;
+
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/merge-big.test b/mysql-test/t/merge-big.test
index 33bd93791f1..509c7742dac 100644
--- a/mysql-test/t/merge-big.test
+++ b/mysql-test/t/merge-big.test
@@ -51,7 +51,7 @@ connection default;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE ID = $con1_id AND STATE = 'Table lock';
+ WHERE ID = $con1_id AND STATE = 'Waiting for table';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Kick INSERT out of thr_multi_lock().
@@ -61,7 +61,7 @@ FLUSH TABLES;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE ID = $con1_id AND STATE = 'Table lock';
+ WHERE ID = $con1_id AND STATE = 'Waiting for table';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Unlock and close table and wait for con1 to close too.
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index a06da03cbcd..31bc8a5e881 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -2,6 +2,12 @@
# Test of MERGE TABLES
#
+# MERGE tables require MyISAM tables
+let $default=`select @@global.storage_engine`;
+set global storage_engine=myisam;
+set session storage_engine=myisam;
+
+# Clean up resources used in this test case.
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
@@ -222,7 +228,6 @@ CREATE TABLE t2 (c1 INT NOT NULL);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
---error ER_WRONG_MRG_TABLE
SELECT * FROM t3;
CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
@@ -254,7 +259,6 @@ create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
drop table t3;
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
---error ER_WRONG_MRG_TABLE
select * from t3;
drop table t3, t2, t1;
--echo # CREATE...SELECT is not implemented for MERGE tables.
@@ -891,12 +895,9 @@ INSERT INTO t4 VALUES (4);
--echo # If the temporary MERGE table uses the locked children only,
--echo # it can even be used.
CREATE TEMPORARY TABLE t4 LIKE t3;
---error ER_WRONG_MRG_TABLE
SHOW CREATE TABLE t4;
---error ER_WRONG_MRG_TABLE
INSERT INTO t4 VALUES (4);
UNLOCK TABLES;
---error ER_WRONG_MRG_TABLE
INSERT INTO t4 VALUES (4);
DROP TABLE t4;
#
@@ -2117,6 +2118,325 @@ OPTIMIZE TABLE t1;
DROP TABLE t1;
--echo #
+--echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+--echo # More tests with TEMPORARY MERGE table and permanent children.
+--echo # First without locked tables.
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2;
+--enable_warnings
+#
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+--error ER_TABLE_EXISTS_ERROR
+ALTER TABLE m2 RENAME m1;
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ADD COLUMN c3 INT;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (212, 222, 232);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 DROP COLUMN c3;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (213, 223);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+#
+--echo #
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+#
+--echo #
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT * FROM t4;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+DROP TABLE t1;
+SELECT * FROM m1;
+#
+#
+--echo #
+--echo #
+SHOW CREATE TABLE m1;
+#
+--echo #
+CREATE TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+CREATE TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+#
+#
+--echo #
+--echo #
+LOCK TABLE m1 WRITE, m2 WRITE;
+SELECT * FROM m1,m2 WHERE m1.c1=m2.c1;
+UNLOCK TABLES;
+#
+DROP TABLE t1, t2, t3, t4, m1, m2;
+#
+#
+#
+--echo #
+--echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+--echo # More tests with TEMPORARY MERGE table and permanent children.
+--echo # (continued) Now the same with locked table.
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE;
+#
+--echo #
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+--error ER_TABLE_EXISTS_ERROR
+ALTER TABLE m2 RENAME m1;
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ADD COLUMN c3 INT;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (212, 222, 232);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 DROP COLUMN c3;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (213, 223);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+#
+--echo #
+UNLOCK TABLES;
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+LOCK TABLE m1 WRITE;
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+#
+--echo #
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT * FROM t4;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+DROP TABLE t1;
+SELECT * FROM m1;
+#
+#
+--echo #
+--echo #
+SHOW CREATE TABLE m1;
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE m2 SELECT * FROM m1;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+SELECT * FROM m2;
+LOCK TABLE m1 WRITE, m2 WRITE;
+UNLOCK TABLES;
+DROP TABLE m2;
+LOCK TABLE m1 WRITE;
+#
+--echo #
+--echo # ER_TABLE_NOT_LOCKED is returned in ps-protocol
+--error ER_WRONG_OBJECT, ER_TABLE_NOT_LOCKED
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+LOCK TABLE m1 WRITE, m2 WRITE;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+#
+--echo #
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, m1, m2;
+
+--echo #
--echo # Bug47098 assert in MDL_context::destroy on HANDLER
--echo # <damaged merge table> OPEN
--echo #
@@ -2225,6 +2545,130 @@ show create table m1;
show create table m2;
drop tables m1, m2, t1;
+--echo #
+--echo # Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()"
+--echo # Check that unique_table() works correctly for merge tables.
+--echo #
+--disable_warnings
+drop table if exists t1, t2, t3, m1, m2;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+create table t3 (b int);
+create view v1 as select * from t3,t1;
+create table m1 (a int) engine=merge union (t1, t2) insert_method=last;
+create table m2 (a int) engine=merge union (t1, t2) insert_method=first;
+create temporary table tmp (b int);
+insert into tmp (b) values (1);
+
+insert into t1 (a) values (1);
+insert into t3 (b) values (1);
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t2));
+
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, t2));
+
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, t2));
+
+--error ER_VIEW_PREVENT_UPDATE
+insert into m1 (a) values ((select max(a) from v1));
+--error ER_VIEW_PREVENT_UPDATE
+insert into m1 (a) values ((select max(a) from tmp, v1));
+
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t2));
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, t2));
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, t2));
+
+--error ER_VIEW_PREVENT_UPDATE
+update m1 set a = ((select max(a) from v1));
+--error ER_VIEW_PREVENT_UPDATE
+update m1 set a = ((select max(a) from tmp, v1));
+
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t2);
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, t2);
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, t2);
+
+--error ER_VIEW_PREVENT_UPDATE
+delete from m1 where a = (select max(a) from v1);
+--error ER_VIEW_PREVENT_UPDATE
+delete from m1 where a = (select max(a) from tmp, v1);
+
+drop view v1;
+drop temporary table tmp;
+drop table t1, t2, t3, m1, m2;
--echo End of 6.0 tests
+--disable_result_log
+--disable_query_log
+eval set global storage_engine=$default;
+--enable_result_log
+--enable_query_log
diff --git a/mysql-test/t/merge_mmap-master.opt b/mysql-test/t/merge_mmap-master.opt
new file mode 100644
index 00000000000..9606fb57187
--- /dev/null
+++ b/mysql-test/t/merge_mmap-master.opt
@@ -0,0 +1 @@
+--myisam-use-mmap
diff --git a/mysql-test/t/merge_mmap.test b/mysql-test/t/merge_mmap.test
new file mode 100644
index 00000000000..c97b029754d
--- /dev/null
+++ b/mysql-test/t/merge_mmap.test
@@ -0,0 +1,151 @@
+#
+# Test of MERGE TABLES with MyISAM memory mapping enabled (--myisam-use-mmap)
+#
+
+# MERGE tables require MyISAM tables
+--let $default=`SELECT @@global.storage_engine`
+SET GLOBAL storage_engine = MyISAM;
+SET SESSION storage_engine = MyISAM;
+
+# Clean up resources used in this test case.
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, m1, m2;
+--enable_warnings
+
+####################
+## No locked tables.
+####################
+#
+# INSERT-SELECT with no TEMPORARY table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+SELECT * FROM t2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY select table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY insert table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY both tables.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+
+####################
+## With LOCK TABLES.
+####################
+#
+# INSERT-SELECT with no TEMPORARY table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+SELECT * FROM t2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY select table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY insert table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY both tables.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+
+--echo End of 6.0 tests
+
+--disable_result_log
+--disable_query_log
+eval SET GLOBAL storage_engine = $default;
+--enable_result_log
+--enable_query_log
diff --git a/mysql-test/t/partition_debug_sync.test b/mysql-test/t/partition_debug_sync.test
index 9165006f537..cde94856ae6 100644
--- a/mysql-test/t/partition_debug_sync.test
+++ b/mysql-test/t/partition_debug_sync.test
@@ -65,7 +65,7 @@ ENGINE = MYISAM
PARTITION p1 VALUES LESS THAN (20),
PARTITION p2 VALUES LESS THAN (100),
PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
-SET DEBUG_SYNC= 'open_tables_acquire_upgradable_mdl SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
+SET DEBUG_SYNC= 'alter_table_before_open_tables SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done';
--send ALTER TABLE t2 REMOVE PARTITIONING
connection default;
diff --git a/mysql-test/t/schema.test b/mysql-test/t/schema.test
index f106b9e4865..ed3b98ec2f7 100644
--- a/mysql-test/t/schema.test
+++ b/mysql-test/t/schema.test
@@ -23,6 +23,7 @@ drop schema foo;
--disable_warnings
DROP SCHEMA IF EXISTS schema1;
+DROP SCHEMA IF EXISTS schema2;
--enable_warnings
connect(con2, localhost, root);
@@ -31,6 +32,7 @@ connect(con2, localhost, root);
connection default;
CREATE SCHEMA schema1;
+CREATE SCHEMA schema2;
CREATE TABLE schema1.t1 (a INT);
SET autocommit= FALSE;
@@ -46,9 +48,7 @@ let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table'
AND info='DROP SCHEMA schema1';
--source include/wait_condition.inc
-# Listing the error twice to prevent result diffences based on filename
---error 1,1
-ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
+ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8;
SET autocommit= TRUE;
--echo # Connection 2
@@ -57,6 +57,7 @@ connection con2;
--echo # Connection default
connection default;
+DROP SCHEMA schema2;
disconnect con2;
@@ -102,6 +103,98 @@ connection con2;
connection default;
disconnect con2;
+
+--echo #
+--echo # Bug#54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER
+--echo #
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+INSERT INTO db1.t1 VALUES (1), (2);
+
+--echo # Connection con1
+connect (con1, localhost, root);
+HANDLER db1.t1 OPEN;
+
+--echo # Connection default
+connection default;
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connect (con2, localhost, root);
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+
+--echo # Connection con1
+connection con1;
+# All these statements before resulted in deadlock.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+HANDLER t1 CLOSE;
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+disconnect con1;
+disconnect con2;
+
+
+--echo #
+--echo # Tests for increased CREATE/ALTER/DROP DATABASE concurrency with
+--echo # database name locks.
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+--enable_warnings
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (id INT);
+START TRANSACTION;
+INSERT INTO db1.t1 VALUES (1);
+
+--echo # Connection 2
+connection con2;
+--echo # DROP DATABASE should block due to the active transaction
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection 3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table' and info='DROP DATABASE db1';
+--source include/wait_condition.inc
+--echo # But it should still be possible to CREATE/ALTER/DROP other databases.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+
+--echo # Connection default
+connection default;
+--echo # End the transaction so DROP DATABASE db1 can continue
+COMMIT;
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection default;
+connection default;
+disconnect con2;
+disconnect con3;
+
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index fa003c2fe69..fa9dc7472fe 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -173,7 +173,7 @@ type_long_blob longblob,
index(type_short)
) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed CHARSET=latin1;
-# Not tested above: RAID_# UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY
+# Not tested above: UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY
show create table t1;
insert into t1 (type_timestamp) values ("2003-02-07 10:00:01");
select * from t1;
@@ -1246,6 +1246,85 @@ UNLOCK TABLES;
DROP TABLE t1;
+--echo #
+--echo # Bug#54905 Connection with WRITE lock cannot ALTER table due to
+--echo # concurrent SHOW CREATE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+
+--echo # Connection con1
+connect (con1,localhost,root);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+SHOW CREATE TABLE t1;
+
+--echo # Connection con1
+connection con1;
+# Used to block
+ALTER TABLE t1 CHARACTER SET = utf8;
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+COMMIT;
+disconnect con1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#55498 SHOW CREATE TRIGGER takes wrong type of metadata lock.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1;
+
+--echo # Test 1: SHOW CREATE TRIGGER with WRITE locked table.
+
+--echo # Connection con1
+connect (con1, localhost, root);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+# Should not block.
+SHOW CREATE TRIGGER t1_bi;
+
+--echo # Connection con1
+connection con1;
+UNLOCK TABLES;
+
+--echo # Test 2: ALTER TABLE with SHOW CREATE TRIGGER in transaction
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+SHOW CREATE TRIGGER t1_bi;
+
+--echo # Connection con1
+connection con1;
+# Should not block.
+ALTER TABLE t1 CHARACTER SET = utf8;
+
+--echo # Connection default
+connection default;
+COMMIT;
+DROP TRIGGER t1_bi;
+DROP TABLE t1;
+disconnect con1;
+
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/signal.test b/mysql-test/t/signal.test
index bdb6625ba32..4c8e6159371 100644
--- a/mysql-test/t/signal.test
+++ b/mysql-test/t/signal.test
@@ -2408,6 +2408,7 @@ BEGIN
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '2';
+ SHOW WARNINGS;
RESIGNAL x SET MYSQL_ERRNO = 9999;
END;
@@ -2415,9 +2416,10 @@ BEGIN
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '1';
+ SHOW WARNINGS;
RESIGNAL x SET
SCHEMA_NAME = 'test',
- MYSQL_ERRNO= 1231;
+ MYSQL_ERRNO= 1232;
END;
/* Raises ER_WRONG_VALUE_FOR_VAR : 1231, SQLSTATE 42000 */
SET @@sql_mode=NULL;
@@ -2431,6 +2433,7 @@ BEGIN
DECLARE EXIT HANDLER FOR x
BEGIN
SELECT '3';
+ SHOW WARNINGS;
RESIGNAL x SET
MESSAGE_TEXT = 'Hi, I am a useless error message',
MYSQL_ERRNO = 9999;
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 247c84fda39..90b4c18895a 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -649,3 +649,56 @@ END//
DELIMITER ;//
SHOW PROCEDURE CODE p1;
DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+--echo #
+
+--echo
+--echo # - Case 4: check that "No Data trumps Warning".
+--echo
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE c CURSOR FOR SELECT a FROM t1;
+
+ OPEN c;
+
+ BEGIN
+ DECLARE v INT;
+
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ SELECT "Warning found!";
+ SHOW WARNINGS;
+ END;
+
+ DECLARE EXIT HANDLER FOR NOT FOUND
+ BEGIN
+ SELECT "End of Result Set found!";
+ SHOW WARNINGS;
+ END;
+
+ WHILE TRUE DO
+ FETCH c INTO v;
+ END WHILE;
+ END;
+
+ CLOSE c;
+
+ SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+
+delimiter ;|
+
+SET SESSION debug="+d,bug23032_emit_warning";
+CALL p1();
+SET SESSION debug="-d,bug23032_emit_warning";
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index c8b2595e23d..13ca55a0127 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -2543,3 +2543,273 @@ DROP TABLE t1;
--echo End of 5.1 tests
+--echo #
+--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+--echo #
+
+--echo
+--echo # - Case 1
+--echo
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+DROP PROCEDURE IF EXISTS p5;
+DROP PROCEDURE IF EXISTS p6;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SELECT 1;
+ CALL p2();
+ END|
+
+CREATE PROCEDURE p2()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+
+--echo
+--echo # - Case 2
+--echo
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+ BEGIN
+ DECLARE c INT DEFAULT 0;
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+ CALL p2();
+ CALL p3();
+ CALL p4();
+ SELECT c;
+ SELECT @@warning_count;
+ SHOW WARNINGS;
+ END|
+
+CREATE PROCEDURE p2()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ END|
+
+CREATE PROCEDURE p3()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SELECT 1;
+ END|
+
+CREATE PROCEDURE p4()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ CALL p2();
+ END|
+
+CREATE PROCEDURE p5()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SHOW WARNINGS;
+ END|
+
+CREATE PROCEDURE P6()
+ BEGIN
+ DECLARE c INT DEFAULT 0;
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+ CALL p5();
+ SELECT c;
+ END|
+
+delimiter ;|
+
+CALL p1();
+CALL p6();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP PROCEDURE p6;
+
+--echo
+--echo # - Case 3: check that "Exception trumps No Data".
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE c CURSOR FOR SELECT a FROM t1;
+
+ OPEN c;
+
+ BEGIN
+ DECLARE v1 INT;
+ DECLARE v2 INT;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ SELECT "Error caught (expected)";
+
+ DECLARE EXIT HANDLER FOR NOT FOUND
+ SELECT "End of Result Set found!";
+
+ WHILE TRUE DO
+ FETCH c INTO v1, v2;
+ END WHILE;
+ END;
+
+ CLOSE c;
+
+ SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#36185: Incorrect precedence for warning and exception handlers
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
+ INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL);
+END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
+--echo #
+
+--echo
+--echo # - Case 1
+--echo
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 2);
+
+delimiter |;
+
+CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLWARNING
+ SET NEW.a = 10;
+
+ SET NEW.a = 99999999999;
+END|
+
+delimiter ;|
+
+UPDATE t1 SET b = 20;
+
+SHOW WARNINGS;
+
+SELECT * FROM t1;
+
+DROP TRIGGER t1_bu;
+DROP TABLE t1;
+
+--echo
+--echo # - Case 2
+--echo
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(b CHAR(1));
+
+delimiter |;
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ INSERT INTO t2 VALUES('ab'); # Produces a warning.
+
+ INSERT INTO t2 VALUES('b'); # Does not produce a warning,
+ # previous warning should be cleared.
+END|
+
+delimiter ;|
+
+INSERT INTO t1 VALUES(0);
+
+SHOW WARNINGS;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TRIGGER t1_bi;
+DROP TABLE t1;
+DROP TABLE t2;
+
+--echo #
+--echo # Bug#9857: Stored procedures: handler for sqlwarning ignored
+--echo #
+
+SET @sql_mode_saved = @@sql_mode;
+SET sql_mode = traditional;
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ SELECT 'warning caught (expected)';
+
+ SELECT 5 / 0;
+END|
+
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+ SELECT 'error caught (unexpected)';
+
+ SELECT 5 / 0;
+END|
+
+delimiter ;|
+
+CALL p1();
+SHOW WARNINGS;
+
+CALL p2();
+SHOW WARNINGS;
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+SET sql_mode = @sql_mode_saved;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index da949016a03..11edeaf9811 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5432,6 +5432,8 @@ drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
+drop procedure if exists bug15231_5|
+drop procedure if exists bug15231_6|
--enable_warnings
create table t3 (id int not null)|
@@ -5461,7 +5463,7 @@ end|
create procedure bug15231_3()
begin
declare exit handler for sqlwarning
- select 'Caught it (wrong)' as 'Result';
+ select 'Caught it (correct)' as 'Result';
call bug15231_4();
end|
@@ -5472,16 +5474,37 @@ begin
set x = 'zap';
select 'Missed it (correct)' as 'Result';
+ show warnings;
+end|
+
+create procedure bug15231_5()
+begin
+ declare exit handler for sqlwarning
+ select 'Caught it (wrong)' as 'Result';
+
+ call bug15231_6();
+end|
+
+create procedure bug15231_6()
+begin
+ declare x decimal(2,1);
+
+ set x = 'zap';
+ select 'Missed it (correct)' as 'Result';
+ select id from t3;
end|
call bug15231_1()|
call bug15231_3()|
+call bug15231_5()|
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
+drop table t3|
+drop procedure bug15231_1|
+drop procedure bug15231_2|
+drop procedure bug15231_3|
+drop procedure bug15231_4|
+drop procedure bug15231_5|
+drop procedure bug15231_6|
#
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 2bfa4936c91..92c22242cdb 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -235,4 +235,19 @@ INSERT INTO t2 SELECT f1();
DROP TABLE t1,t2,t3;
DROP FUNCTION f1;
+--echo #
+--echo # Bug #48067: A temp table with the same name as an existing table,
+--echo # makes drop database fail.
+--echo #
+--disable_warnings
+DROP TEMPORARY TABLE IF EXISTS bug48067.t1;
+DROP DATABASE IF EXISTS bug48067;
+--enable_warnings
+CREATE DATABASE bug48067;
+CREATE TABLE bug48067.t1 (c1 int);
+INSERT INTO bug48067.t1 values (1);
+CREATE TEMPORARY TABLE bug48067.t1 (c1 int);
+DROP DATABASE bug48067;
+DROP TEMPORARY table bug48067.t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index d865851841f..75099523062 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1405,4 +1405,30 @@ SET @@sql_quote_show_create = @sql_quote_show_create_saved;
--echo # End of Bug#34828.
--echo
+--echo # Make sure we can manipulate with autocommit in the
+--echo # along with other variables.
+
+
+--disable_warnings
+drop table if exists t1;
+drop function if exists t1_max;
+drop function if exists t1_min;
+--enable_warnings
+
+create table t1 (a int) engine=innodb;
+insert into t1(a) values (0), (1);
+create function t1_max() returns int return (select max(a) from t1);
+create function t1_min() returns int return (select min(a) from t1);
+select t1_min();
+select t1_max();
+set @@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+ @@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+ @@session.autocommit=t1_min(), @@session.autocommit=t1_max();
+
+--echo # Cleanup.
+drop table t1;
+drop function t1_min;
+drop function t1_max;
+
+
###########################################################################
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 83615c82e2a..ae41151a981 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -17,23 +17,23 @@
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
-SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c
- errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
+SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c
+ errors.c hash.c list.c md5.c mf_cache.c mf_dirname.c mf_fn_ext.c
mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c
- mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
- my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
- my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
+ mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c
+ my_aes.c my_alloc.c my_bit.c my_bitmap.c my_chsize.c
+ my_compress.c my_copy.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
- my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c
- my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
+ my_lib.c my_lock.c my_malloc.c my_mess.c
+ my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
- thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
+ thr_rwlock.c tree.c typelib.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c
my_rdtsc.c)
@@ -42,6 +42,10 @@ IF (WIN32)
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c)
ENDIF()
+IF(HAVE_ALARM)
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_alarm.c)
+ENDIF()
+
IF(NOT HAVE_CXX_NEW)
# gcc as C++ compiler does not have new/delete
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_new.cc)
@@ -58,10 +62,15 @@ IF(HAVE_LARGE_PAGES)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c)
ENDIF()
+IF(HAVE_MLOCK)
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_lockmem.c)
+ENDIF()
+
IF(UNIX)
# some workarounds
SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_port.c)
ENDIF()
+
ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY}
${LIBNSL} ${LIBM} ${LIBRT})
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index a9e3f16c548..357fa321da6 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -24,31 +24,29 @@ LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug
noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
+ my_open.c my_create.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \
mf_keycaches.c my_crc32.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_once.c mulalloc.c \
- my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \
+ my_alloc.c my_new.cc my_atomic.c lf_hash.c \
lf_dynarray.c lf_alloc-pin.c \
my_fopen.c my_fstream.c my_getsystime.c \
my_error.c errors.c my_div.c my_mess.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
mf_pack.c mf_unixpath.c mf_arr_appstr.c \
- mf_wcomp.c mf_wfile.c my_gethwaddr.c \
+ mf_wcomp.c my_gethwaddr.c \
mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c my_getncpus.c \
- tree.c trie.c list.c hash.c array.c string.c typelib.c \
- my_copy.c my_append.c my_lib.c \
+ tree.c list.c hash.c array.c string.c typelib.c \
+ my_copy.c my_lib.c \
my_delete.c my_rename.c my_redel.c \
- my_chsize.c my_clock.c \
- my_quick.c my_lockmem.c my_static.c \
+ my_chsize.c my_quick.c my_lockmem.c my_static.c \
my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
- my_compress.c checksum.c \
- my_net.c my_port.c my_sleep.c \
+ default.c my_compress.c checksum.c \
+ my_port.c my_sleep.c \
charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_largepage.c \
diff --git a/mysys/checksum.c b/mysys/checksum.c
index 1c7c9358d53..a96ea31ea0e 100644
--- a/mysys/checksum.c
+++ b/mysys/checksum.c
@@ -30,13 +30,6 @@
ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length)
{
-#ifdef NOT_USED
- const uchar *end=pos+length;
- for ( ; pos != end ; pos++)
- crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
- return crc;
-#else
return (ha_checksum)crc32((uint)crc, pos, (uint)length);
-#endif
}
diff --git a/mysys/default.c b/mysys/default.c
index 8002a1a0307..0e0883e1fcf 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -575,7 +575,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
void free_defaults(char **argv)
{
MEM_ROOT ptr;
- memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr));
+ memcpy(&ptr, ((char *) argv) - sizeof(ptr), sizeof(ptr));
free_root(&ptr,MYF(0));
}
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
deleted file mode 100644
index edf4907cd4b..00000000000
--- a/mysys/default_modify.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* Copyright (C) 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "my_global.h"
-#include "mysys_priv.h"
-#include "m_string.h"
-#include <my_dir.h>
-
-#define BUFF_SIZE 1024
-#define RESERVE 1024 /* Extend buffer with this extent */
-
-#ifdef _WIN32
-#define NEWLINE "\r\n"
-#define NEWLINE_LEN 2
-#else
-#define NEWLINE "\n"
-#define NEWLINE_LEN 1
-#endif
-
-static char *add_option(char *dst, const char *option_value,
- const char *option, int remove_option);
-
-
-/*
- Add/remove option to the option file section.
-
- SYNOPSYS
- modify_defaults_file()
- file_location The location of configuration file to edit
- option The name of the option to look for (can be NULL)
- option value The value of the option we would like to set (can be NULL)
- section_name The name of the section (must be NOT NULL)
- remove_option This defines what we want to remove:
- - MY_REMOVE_NONE -- nothing to remove;
- - MY_REMOVE_OPTION -- remove the specified option;
- - MY_REMOVE_SECTION -- remove the specified section;
- IMPLEMENTATION
- We open the option file first, then read the file line-by-line,
- looking for the section we need. At the same time we put these lines
- into a buffer. Then we look for the option within this section and
- change/remove it. In the end we get a buffer with modified version of the
- file. Then we write it to the file, truncate it if needed and close it.
- Note that there is a small time gap, when the file is incomplete,
- and this theoretically might introduce a problem.
-
- RETURN
- 0 - ok
- 1 - some error has occured. Probably due to the lack of resourses
- 2 - cannot open the file
-*/
-
-int modify_defaults_file(const char *file_location, const char *option,
- const char *option_value,
- const char *section_name, int remove_option)
-{
- FILE *cnf_file;
- MY_STAT file_stat;
- char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
- size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended;
- uint nr_newlines= 0, buffer_size;
- my_bool in_section= FALSE, opt_applied= 0;
- int reserve_occupied= 0;
- DBUG_ENTER("modify_defaults_file");
-
- if (!(cnf_file= my_fopen(file_location, O_RDWR | O_BINARY, MYF(0))))
- DBUG_RETURN(2);
-
- /* my_fstat doesn't use the flag parameter */
- if (my_fstat(my_fileno(cnf_file), &file_stat, MYF(0)))
- goto malloc_err;
-
- if (option && option_value)
- {
- opt_len= strlen(option);
- optval_len= strlen(option_value);
- }
-
- new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN;
-
- /* calculate the size of the buffer we need */
- reserve_extended= (opt_len +
- 1 + /* For '=' char */
- optval_len + /* Option value len */
- NEWLINE_LEN + /* Space for newline */
- RESERVE); /* Some additional space */
-
- buffer_size= (file_stat.st_size +
- 1); /* The ending zero */
-
- /*
- Reserve space to read the contents of the file and some more
- for the option we want to add.
- */
- if (!(file_buffer= (char*) my_malloc(buffer_size + reserve_extended,
- MYF(MY_WME))))
- goto malloc_err;
-
- sect_len= strlen(section_name);
-
- for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); )
- {
- /* Skip over whitespaces */
- for (src_ptr= linebuff; my_isspace(&my_charset_latin1, *src_ptr);
- src_ptr++)
- {}
-
- if (!*src_ptr) /* Empty line */
- {
- nr_newlines++;
- continue;
- }
-
- /* correct the option (if requested) */
- if (option && in_section && !strncmp(src_ptr, option, opt_len) &&
- (*(src_ptr + opt_len) == '=' ||
- my_isspace(&my_charset_latin1, *(src_ptr + opt_len)) ||
- *(src_ptr + opt_len) == '\0'))
- {
- char *old_src_ptr= src_ptr;
- src_ptr= strend(src_ptr+ opt_len); /* Find the end of the line */
-
- /* could be negative */
- reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr);
- if (reserve_occupied >= (int) reserve_extended)
- {
- reserve_extended= (uint) reserve_occupied + RESERVE;
- if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size +
- reserve_extended,
- MYF(MY_WME|MY_FREE_ON_ERROR))))
- goto malloc_err;
- }
- opt_applied= 1;
- dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
- }
- else
- {
- /*
- If we are going to the new group and have an option to apply, do
- it now. If we are removing a single option or the whole section
- this will only trigger opt_applied flag.
- */
-
- if (in_section && !opt_applied && *src_ptr == '[')
- {
- dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
- opt_applied= 1; /* set the flag to do write() later */
- reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN;
- }
-
- for (; nr_newlines; nr_newlines--)
- dst_ptr= strmov(dst_ptr, NEWLINE);
-
- /* Skip the section if MY_REMOVE_SECTION was given */
- if (!in_section || remove_option != MY_REMOVE_SECTION)
- dst_ptr= strmov(dst_ptr, linebuff);
- }
- /* Look for a section */
- if (*src_ptr == '[')
- {
- /* Copy the line to the buffer */
- if (!strncmp(++src_ptr, section_name, sect_len))
- {
- src_ptr+= sect_len;
- /* Skip over whitespaces. They are allowed after section name */
- for (; my_isspace(&my_charset_latin1, *src_ptr); src_ptr++)
- {}
-
- if (*src_ptr != ']')
- {
- in_section= FALSE;
- continue; /* Missing closing parenthesis. Assume this was no group */
- }
-
- if (remove_option == MY_REMOVE_SECTION)
- dst_ptr= dst_ptr - strlen(linebuff);
-
- in_section= TRUE;
- }
- else
- in_section= FALSE; /* mark that this section is of no interest to us */
- }
- }
-
- /*
- File ended. Apply an option or set opt_applied flag (in case of
- MY_REMOVE_SECTION) so that the changes are saved. Do not do anything
- if we are removing non-existent option.
- */
-
- if (!opt_applied && in_section && (remove_option != MY_REMOVE_OPTION))
- {
- /* New option still remains to apply at the end */
- if (!remove_option && *(dst_ptr - 1) != '\n')
- dst_ptr= strmov(dst_ptr, NEWLINE);
- dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
- opt_applied= 1;
- }
- for (; nr_newlines; nr_newlines--)
- dst_ptr= strmov(dst_ptr, NEWLINE);
-
- if (opt_applied)
- {
- /* Don't write the file if there are no changes to be made */
- if (my_chsize(my_fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
- MYF(MY_WME)) ||
- my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
- my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer),
- MYF(MY_NABP)))
- goto err;
- }
- if (my_fclose(cnf_file, MYF(MY_WME)))
- DBUG_RETURN(1);
-
- my_free(file_buffer);
- DBUG_RETURN(0);
-
-err:
- my_free(file_buffer);
-malloc_err:
- my_fclose(cnf_file, MYF(0));
- DBUG_RETURN(1); /* out of resources */
-}
-
-
-static char *add_option(char *dst, const char *option_value,
- const char *option, int remove_option)
-{
- if (!remove_option)
- {
- dst= strmov(dst, option);
- if (*option_value)
- {
- *dst++= '=';
- dst= strmov(dst, option_value);
- }
- /* add a newline */
- dst= strmov(dst, NEWLINE);
- }
- return dst;
-}
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index c264d3ac4c5..4ed01ac8083 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -448,8 +448,6 @@ void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset)
allocator->top= 0;
allocator->mallocs= 0;
allocator->element_size= size;
- allocator->constructor= 0;
- allocator->destructor= 0;
DBUG_ASSERT(size >= sizeof(void*) + free_ptr_offset);
}
@@ -470,8 +468,6 @@ void lf_alloc_destroy(LF_ALLOCATOR *allocator)
while (node)
{
uchar *tmp= anext_node(node);
- if (allocator->destructor)
- allocator->destructor(node);
my_free(node);
node= tmp;
}
@@ -500,8 +496,6 @@ void *_lf_alloc_new(LF_PINS *pins)
if (!node)
{
node= (void *)my_malloc(allocator->element_size, MYF(MY_WME));
- if (allocator->constructor)
- allocator->constructor(node);
#ifdef MY_LF_EXTRA_DEBUG
if (likely(node != 0))
my_atomic_add32(&allocator->mallocs, 1);
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 9c51ff1766e..e7bf82fc6ca 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -41,8 +41,6 @@ typedef struct {
*/
} LF_SLIST;
-const int LF_HASH_OVERHEAD= sizeof(LF_SLIST);
-
/*
a structure to pass the context (pointers two the three successive elements
in a list) from lfind to linsert/ldelete
diff --git a/mysys/make-conf.c b/mysys/make-conf.c
deleted file mode 100644
index 0dacde4dee0..00000000000
--- a/mysys/make-conf.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* make-conf.c
- * make a charset .conf file out of a ctype-charset.c file.
- */
-
-#ifndef CHARSET
-#error You must define the charset, e.g.: -DCHARSET=latin1
-#endif
-
-/* some pre-processor tricks to get us going */
-#define _STRINGIZE_HELPER(x) #x
-#define STRINGIZE(x) _STRINGIZE_HELPER(x)
-
-#define _JOIN_WORDS_HELPER(a, b) a ## b
-#define JOIN_WORDS(a, b) _JOIN_WORDS_HELPER(a, b)
-
-#define CH_SRC ctype- ## CHARSET ## .c
-#define CH_INCLUDE STRINGIZE(CH_SRC)
-
-/* aaaah, that's better */
-#include <my_my_global.h>
-#include CH_INCLUDE
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ROW_LEN 16
-
-void print_array(const char *name, const uchar *array, uint size);
-
-int main(void)
-{
- printf("# Configuration file for the "
- STRINGIZE(CHARSET)
- " character set.\n");
-
- print_array("ctype", JOIN_WORDS(ctype_, CHARSET), 257);
- print_array("to_lower", JOIN_WORDS(to_lower_, CHARSET), 256);
- print_array("to_upper", JOIN_WORDS(to_upper_, CHARSET), 256);
- print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256);
-
- exit(EXIT_SUCCESS);
-}
-
-void print_array(const char *name, const uchar *array, uint size)
-{
- uint i;
-
- printf("\n# The %s array must have %d elements.\n", name, size);
-
- for (i = 0; i < size; ++i) {
- printf(" %02X", array[i]);
-
- if ((i+1) % ROW_LEN == size % ROW_LEN)
- printf("\n");
- }
-}
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index d9b1bfcaa7f..173b678cdd1 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -47,7 +47,6 @@ TODO:
write buffer to the read buffer before we start to reuse it.
*/
-#define MAP_TO_USE_RAID
#include "mysys_priv.h"
#include <m_string.h>
#ifdef HAVE_AIOWAIT
@@ -455,7 +454,9 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
RETURN
0 we succeeded in reading all data
- 1 Error: can't read requested characters
+ 1 Error: couldn't read requested characters. In this case:
+ If info->error == -1, we got a read error.
+ Otherwise info->error contains the number of bytes in Buffer.
*/
int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
@@ -464,6 +465,7 @@ int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
my_off_t pos_in_file;
DBUG_ENTER("_my_b_read");
+ /* If the buffer is not empty yet, copy what is available. */
if ((left_length= (size_t) (info->read_end-info->read_pos)))
{
DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */
@@ -475,7 +477,7 @@ int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
/* pos_in_file always point on where info->buffer was read */
pos_in_file=info->pos_in_file+ (size_t) (info->read_end - info->buffer);
- /*
+ /*
Whenever a function which operates on IO_CACHE flushes/writes
some part of the IO_CACHE to disk it will set the property
"seek_not_done" to indicate this to other functions operating
@@ -502,19 +504,38 @@ int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
}
}
+ /*
+ Calculate, how much we are within a IO_SIZE block. Ideally this
+ should be zero.
+ */
diff_length= (size_t) (pos_in_file & (IO_SIZE-1));
+
+ /*
+ If more than a block plus the rest of the current block is wanted,
+ we do read directly, without filling the buffer.
+ */
if (Count >= (size_t) (IO_SIZE+(IO_SIZE-diff_length)))
{ /* Fill first intern buffer */
size_t read_length;
if (info->end_of_file <= pos_in_file)
- { /* End of file */
+ {
+ /* End of file. Return, what we did copy from the buffer. */
info->error= (int) left_length;
DBUG_RETURN(1);
}
+ /*
+ Crop the wanted count to a multiple of IO_SIZE and subtract,
+ what we did already read from a block. That way, the read will
+ end aligned with a block.
+ */
length=(Count & (size_t) ~(IO_SIZE-1))-diff_length;
if ((read_length= my_read(info->file,Buffer, length, info->myflags))
!= length)
{
+ /*
+ If we didn't get, what we wanted, we either return -1 for a read
+ error, or (it's end of file), how much we got in total.
+ */
info->error= (read_length == (size_t) -1 ? -1 :
(int) (read_length+left_length));
DBUG_RETURN(1);
@@ -526,15 +547,27 @@ int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
diff_length=0;
}
+ /*
+ At this point, we want less than one and a partial block.
+ We will read a full cache, minus the number of bytes, we are
+ within a block already. So we will reach new alignment.
+ */
max_length= info->read_length-diff_length;
+ /* We will not read past end of file. */
if (info->type != READ_FIFO &&
max_length > (info->end_of_file - pos_in_file))
max_length= (size_t) (info->end_of_file - pos_in_file);
+ /*
+ If there is nothing left to read,
+ we either are done, or we failed to fulfill the request.
+ Otherwise, we read max_length into the cache.
+ */
if (!max_length)
{
if (Count)
{
- info->error= left_length; /* We only got this many char */
+ /* We couldn't fulfil the request. Return, how much we got. */
+ info->error= left_length;
DBUG_RETURN(1);
}
length=0; /* Didn't read any chars */
@@ -543,13 +576,23 @@ int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
info->myflags)) < Count ||
length == (size_t) -1)
{
+ /*
+ We got an read error, or less than requested (end of file).
+ If not a read error, copy, what we got.
+ */
if (length != (size_t) -1)
memcpy(Buffer, info->buffer, length);
info->pos_in_file= pos_in_file;
+ /* For a read error, return -1, otherwise, what we got in total. */
info->error= length == (size_t) -1 ? -1 : (int) (length+left_length);
info->read_pos=info->read_end=info->buffer;
DBUG_RETURN(1);
}
+ /*
+ Count is the remaining number of bytes requested.
+ length is the amount of data in the cache.
+ Read Count bytes from the cache.
+ */
info->read_pos=info->buffer+Count;
info->read_end=info->buffer+length;
info->pos_in_file=pos_in_file;
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 5e34bff2b51..7a40ea8a86f 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -17,7 +17,6 @@
More functions to be used with IO_CACHE files
*/
-#define MAP_TO_USE_RAID
#include "mysys_priv.h"
#include <m_string.h>
#include <stdarg.h>
@@ -71,6 +70,16 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file)
my_off_t my_b_append_tell(IO_CACHE* info)
{
/*
+ Sometimes we want to make sure that the variable is not put into
+ a register in debugging mode so we can see its value in the core
+ */
+#ifndef DBUG_OFF
+# define dbug_volatile volatile
+#else
+# define dbug_volatile
+#endif
+
+ /*
Prevent optimizer from putting res in a register when debugging
we need this to be able to see the value of res when the assert fails
*/
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index c42c3d469e6..fc62d3d8a8e 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -2683,10 +2683,7 @@ uchar *key_cache_read(KEY_CACHE *keycache,
#endif
/* Copy data from the cache buffer */
- if (!(read_length & 511))
- bmove512(buff, block->buffer+offset, read_length);
- else
- memcpy(buff, block->buffer+offset, (size_t) read_length);
+ memcpy(buff, block->buffer+offset, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
keycache_pthread_mutex_lock(&keycache->cache_lock);
@@ -2920,10 +2917,7 @@ int key_cache_insert(KEY_CACHE *keycache,
#endif
/* Copy data from buff */
- if (!(read_length & 511))
- bmove512(block->buffer+offset, buff, read_length);
- else
- memcpy(block->buffer+offset, buff, (size_t) read_length);
+ memcpy(block->buffer+offset, buff, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
keycache_pthread_mutex_lock(&keycache->cache_lock);
@@ -3246,10 +3240,7 @@ int key_cache_write(KEY_CACHE *keycache,
#if !defined(SERIALIZED_READ_FROM_CACHE)
keycache_pthread_mutex_unlock(&keycache->cache_lock);
#endif
- if (!(read_length & 511))
- bmove512(block->buffer+offset, buff, read_length);
- else
- memcpy(block->buffer+offset, buff, (size_t) read_length);
+ memcpy(block->buffer+offset, buff, (size_t) read_length);
#if !defined(SERIALIZED_READ_FROM_CACHE)
keycache_pthread_mutex_lock(&keycache->cache_lock);
diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c
deleted file mode 100644
index 95c4c006b2c..00000000000
--- a/mysys/mf_wfile.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Functions for finding files with wildcards */
-
-/*
- The following file-name-test is supported:
- - "name [[,] name...] ; Matches any of used filenames.
- Each name can have "*" and/or "?"
- wild-cards.
- - [wildspec [,]] !wildspec2 ; File that matches wildspec and not
- wildspec2.
-*/
-
-#include "mysys_priv.h"
-#include <m_string.h>
-
- /* Store wildcard-string in a easyer format */
-
-WF_PACK *wf_comp(char * str)
-{
- uint ant;
- int not_pos;
- register char * pos;
- char * buffer;
- WF_PACK *ret;
- DBUG_ENTER("wf_comp");
-
- not_pos= -1; /* Skip space and '!' in front */
- while (*str == ' ')
- str++;
- if (*str == '!')
- {
- not_pos=0;
- while (*++str == ' ') {};
- }
- if (*str == 0) /* Empty == everything */
- DBUG_RETURN((WF_PACK *) NULL);
-
- ant=1; /* Count filespecs */
- for (pos=str ; *pos ; pos++)
- ant+= test(*pos == ' ' || *pos == ',');
-
- if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+
- sizeof(WF_PACK)+ (uint) strlen(str)+1,
- MYF(MY_WME)))
- == 0)
- DBUG_RETURN((WF_PACK *) NULL);
- ret->wild= (char **) (ret+1);
- buffer= (char *) (ret->wild+ant);
-
- ant=0;
- for (pos=str ; *pos ; str= pos)
- {
- ret->wild[ant++]=buffer;
- while (*pos != ' ' && *pos != ',' && *pos != '!' && *pos)
- *buffer++ = *pos++;
-
- *buffer++ = '\0';
- while (*pos == ' ' || *pos == ',' || *pos == '!' )
- if (*pos++ == '!' && not_pos <0)
- not_pos=(int) ant;
- }
-
- ret->wilds=ant;
- if (not_pos <0)
- ret->not_pos=ant;
- else
- ret->not_pos=(uint) not_pos;
-
- DBUG_PRINT("exit",("antal: %d not_pos: %d",ret->wilds,ret->not_pos));
- DBUG_RETURN(ret);
-} /* wf_comp */
-
-
- /* Test if a given filename is matched */
-
-int wf_test(register WF_PACK *wf_pack, register const char *name)
-{
- reg2 uint i;
- reg3 uint not_pos;
- DBUG_ENTER("wf_test");
-
- if (! wf_pack || wf_pack->wilds == 0)
- DBUG_RETURN(0); /* Everything goes */
-
- not_pos=wf_pack->not_pos;
- for (i=0 ; i < not_pos; i++)
- if (wild_compare(name,wf_pack->wild[i],0) == 0)
- goto found;
- if (i)
- DBUG_RETURN(1); /* No-match */
-
-found:
-/* Test that it isn't in not-list */
-
- for (i=not_pos ; i < wf_pack->wilds; i++)
- if (wild_compare(name,wf_pack->wild[i],0) == 0)
- DBUG_RETURN(1);
- DBUG_RETURN(0);
-} /* wf_test */
-
-
- /* We need this because program don't know with malloc we used */
-
-void wf_end(WF_PACK *buffer)
-{
- DBUG_ENTER("wf_end");
- my_free(buffer);
- DBUG_VOID_RETURN;
-} /* wf_end */
diff --git a/mysys/my_append.c b/mysys/my_append.c
deleted file mode 100644
index 1ef3905b6f5..00000000000
--- a/mysys/my_append.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "mysys_priv.h"
-#include <sys/stat.h>
-#include <m_string.h>
-#if defined(HAVE_UTIME_H)
-#include <utime.h>
-#elif defined(HAVE_SYS_UTIME_H)
-#include <sys/utime.h>
-#elif !defined(HPUX10)
-struct utimbuf {
- time_t actime;
- time_t modtime;
-};
-#endif
-
-/*
- Append a file to another
-
- NOTES
- Don't set MY_FNABP or MY_NABP bits on when calling this function
-*/
-
-int my_append(const char *from, const char *to, myf MyFlags)
-{
- size_t Count;
- File from_file,to_file;
- uchar buff[IO_SIZE];
- DBUG_ENTER("my_append");
- DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
-
- from_file= to_file= -1;
-
- if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0)
- {
- if ((to_file=my_open(to,O_APPEND | O_WRONLY,MyFlags)) >= 0)
- {
- while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0)
- if (Count == (uint) -1 ||
- my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
- goto err;
- if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
- DBUG_RETURN(-1); /* Error on close */
- DBUG_RETURN(0);
- }
- }
-err:
- if (from_file >= 0) (void) my_close(from_file,MyFlags);
- if (to_file >= 0) (void) my_close(to_file,MyFlags);
- DBUG_RETURN(-1);
-}
diff --git a/mysys/my_atomic.c b/mysys/my_atomic.c
index 6bc76f0de3c..7cbe15cfb74 100644
--- a/mysys/my_atomic.c
+++ b/mysys/my_atomic.c
@@ -16,13 +16,6 @@
#include <my_global.h>
#include <my_sys.h>
-#ifndef HAVE_INLINE
-/* the following will cause all inline functions to be instantiated */
-#define HAVE_INLINE
-#undef STATIC_INLINE
-#define STATIC_INLINE extern
-#endif
-
#include <my_atomic.h>
/*
diff --git a/mysys/my_bit.c b/mysys/my_bit.c
index 2881eb1ebd2..f072f243765 100644
--- a/mysys/my_bit.c
+++ b/mysys/my_bit.c
@@ -15,13 +15,6 @@
#include <my_global.h>
-#ifndef HAVE_INLINE
-/* the following will cause all inline functions to be instantiated */
-#define HAVE_INLINE
-#undef STATIC_INLINE
-#define STATIC_INLINE extern
-#endif
-
#include <my_bit.h>
const char _my_bits_nbits[256] = {
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 3de05fa8664..3401c7301e9 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -566,192 +566,6 @@ void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit)
bitmap_unlock(map);
}
-
-#ifdef NOT_USED
-my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size)
-{
- my_bool res;
- bitmap_lock((MY_BITMAP *)map);
- res= bitmap_is_prefix(map, prefix_size);
- bitmap_unlock((MY_BITMAP *)map);
- return res;
-}
-
-
-void bitmap_lock_set_all(MY_BITMAP *map)
-{
- bitmap_lock(map);
- bitmap_set_all(map);
- bitmap_unlock(map);
-}
-
-
-void bitmap_lock_clear_all(MY_BITMAP *map)
-{
- bitmap_lock(map);
- bitmap_clear_all(map);
- bitmap_unlock(map);
-}
-
-
-void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size)
-{
- bitmap_lock(map);
- bitmap_set_prefix(map, prefix_size);
- bitmap_unlock(map);
-}
-
-
-my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map)
-{
- uint res;
- bitmap_lock((MY_BITMAP *)map);
- res= bitmap_is_clear_all(map);
- bitmap_unlock((MY_BITMAP *)map);
- return res;
-}
-
-
-my_bool bitmap_lock_is_set_all(const MY_BITMAP *map)
-{
- uint res;
- bitmap_lock((MY_BITMAP *)map);
- res= bitmap_is_set_all(map);
- bitmap_unlock((MY_BITMAP *)map);
- return res;
-}
-
-
-my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit)
-{
- my_bool res;
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
- bitmap_lock((MY_BITMAP *)map);
- res= bitmap_is_set(map, bitmap_bit);
- bitmap_unlock((MY_BITMAP *)map);
- return res;
-}
-
-
-my_bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
-{
- uint res;
- bitmap_lock((MY_BITMAP *)map1);
- bitmap_lock((MY_BITMAP *)map2);
- res= bitmap_is_subset(map1, map2);
- bitmap_unlock((MY_BITMAP *)map2);
- bitmap_unlock((MY_BITMAP *)map1);
- return res;
-}
-
-
-my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
-{
- uint res;
-
- DBUG_ASSERT(map1->bitmap && map2->bitmap &&
- map1->n_bits==map2->n_bits);
- bitmap_lock((MY_BITMAP *)map1);
- bitmap_lock((MY_BITMAP *)map2);
- res= bitmap_cmp(map1, map2);
- bitmap_unlock((MY_BITMAP *)map2);
- bitmap_unlock((MY_BITMAP *)map1);
- return res;
-}
-
-
-void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2)
-{
- bitmap_lock(map);
- bitmap_lock((MY_BITMAP *)map2);
- bitmap_intersect(map, map2);
- bitmap_unlock((MY_BITMAP *)map2);
- bitmap_unlock(map);
-}
-
-
-void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2)
-{
- bitmap_lock(map);
- bitmap_lock((MY_BITMAP *)map2);
- bitmap_subtract(map, map2);
- bitmap_unlock((MY_BITMAP *)map2);
- bitmap_unlock(map);
-}
-
-
-void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2)
-{
- bitmap_lock(map);
- bitmap_lock((MY_BITMAP *)map2);
- bitmap_union(map, map2);
- bitmap_unlock((MY_BITMAP *)map2);
- bitmap_unlock(map);
-}
-
-
-/*
- SYNOPSIS
- bitmap_bits_set()
- map
- RETURN
- Number of set bits in the bitmap.
-*/
-uint bitmap_lock_bits_set(const MY_BITMAP *map)
-{
- uint res;
- bitmap_lock((MY_BITMAP *)map);
- DBUG_ASSERT(map->bitmap);
- res= bitmap_bits_set(map);
- bitmap_unlock((MY_BITMAP *)map);
- return res;
-}
-
-
-/*
- SYNOPSIS
- bitmap_get_first()
- map
- RETURN
- Number of first unset bit in the bitmap or MY_BIT_NONE if all bits are set.
-*/
-uint bitmap_lock_get_first(const MY_BITMAP *map)
-{
- uint res;
- bitmap_lock((MY_BITMAP*)map);
- res= bitmap_get_first(map);
- bitmap_unlock((MY_BITMAP*)map);
- return res;
-}
-
-
-uint bitmap_lock_get_first_set(const MY_BITMAP *map)
-{
- uint res;
- bitmap_lock((MY_BITMAP*)map);
- res= bitmap_get_first_set(map);
- bitmap_unlock((MY_BITMAP*)map);
- return res;
-}
-
-
-void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit)
-{
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
- bitmap_lock(map);
- bitmap_set_bit(map, bitmap_bit);
- bitmap_unlock(map);
-}
-
-
-void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit)
-{
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
- bitmap_lock(map);
- bitmap_flip_bit(map, bitmap_bit);
- bitmap_unlock(map);
-}
-#endif
#ifdef MAIN
uint get_rand_bit(uint bitsize)
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
deleted file mode 100644
index da04feb462f..00000000000
--- a/mysys/my_clock.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "my_global.h"
-
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
-#include "mysys_priv.h"
-#include <sys/times.h>
-#endif
-
-long my_clock(void)
-{
-#if !defined(__WIN__)
- struct tms tmsbuf;
- (void) times(&tmsbuf);
- return (tmsbuf.tms_utime + tmsbuf.tms_stime);
-#else
- return clock();
-#endif
-}
diff --git a/mysys/my_dup.c b/mysys/my_dup.c
deleted file mode 100644
index 5fdd6e9f364..00000000000
--- a/mysys/my_dup.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "mysys_priv.h"
-#include "mysys_err.h"
-#include <my_dir.h>
-#include <errno.h>
-#if defined(__WIN__)
-#include <share.h>
-#endif
-
- /* Open a file */
-
-File my_dup(File file, myf MyFlags)
-{
- File fd;
- const char *filename;
- DBUG_ENTER("my_dup");
- DBUG_PRINT("my",("file: %d MyFlags: %d", file, MyFlags));
-#ifdef _WIN32
- fd= my_win_dup(file);
-#else
- fd= dup(file);
-#endif
- filename= (((uint) file < my_file_limit) ?
- my_file_info[(int) file].name : "Unknown");
- DBUG_RETURN(my_register_filename(fd, filename, FILE_BY_DUP,
- EE_FILENOTFOUND, MyFlags));
-} /* my_open */
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index 48d100f2d3f..bd1e313d066 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -23,6 +23,8 @@
#include "my_handler_errors.h"
+#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
+
int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
uchar *b, uint b_length, my_bool part_key,
my_bool skip_end_space)
diff --git a/mysys/my_init.c b/mysys/my_init.c
index dbf1bfe761c..d2371278b0c 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -33,6 +33,9 @@ static my_bool win32_init_tcp_ip();
#define my_win_init()
#endif
+#define SCALE_SEC 100
+#define SCALE_USEC 10000
+
my_bool my_init_done= 0;
/** True if @c my_basic_init() has been called. */
my_bool my_basic_init_done= 0;
@@ -138,9 +141,6 @@ my_bool my_init(void)
#ifdef THREAD
if (my_thread_global_init())
return 1;
-#if !defined(__WIN__)
- sigfillset(&my_signals); /* signals blocked by mf_brkhant */
-#endif
#endif /* THREAD */
{
DBUG_ENTER("my_init");
diff --git a/mysys/my_net.c b/mysys/my_net.c
deleted file mode 100644
index e584e541175..00000000000
--- a/mysys/my_net.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* thread safe version of some common functions */
-
-#include "mysys_priv.h"
-#include <m_string.h>
-
-/* for thread safe my_inet_ntoa */
-#if !defined(__WIN__)
-#include <netdb.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#endif /* !defined(__WIN__) */
-
-void my_inet_ntoa(struct in_addr in, char *buf)
-{
- char *ptr;
- mysql_mutex_lock(&THR_LOCK_net);
- ptr=inet_ntoa(in);
- strmov(buf,ptr);
- mysql_mutex_unlock(&THR_LOCK_net);
-}
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index 270d13928e3..dee34d10b38 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -138,7 +138,7 @@ void sigwait_setup(sigset_t *set)
sact.sa_flags = 0;
sact.sa_handler = px_handle_sig;
- memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
+ memcpy(&sact.sa_mask, set, sizeof(*set)); /* handler isn't thread_safe */
sigemptyset(&unblock_mask);
pthread_sigmask(SIG_UNBLOCK,(sigset_t*) 0,&rev_sigwait_set);
@@ -164,7 +164,7 @@ void sigwait_setup(sigset_t *set)
}
}
}
- memcpy_fixed(&sigwait_set,set,sizeof(*set));
+ memcpy(&sigwait_set, set, sizeof(*set));
pthread_sigmask(SIG_BLOCK,(sigset_t*) set,(sigset_t*) 0);
pthread_sigmask(SIG_UNBLOCK,&unblock_mask,(sigset_t*) 0);
}
@@ -252,7 +252,7 @@ void *sigwait_thread(void *set_arg)
struct sigaction sact;
sact.sa_flags = 0;
sact.sa_handler = sigwait_handle_sig;
- memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */
+ memcpy(&sact.sa_mask, set, sizeof(*set)); /* handler isn't thread_safe */
sigemptyset(&pending_set);
for (i = 1; i <= sizeof(pending_set)*8; i++)
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 2869b43543a..d7354555f3d 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -43,9 +43,6 @@ struct st_my_file_info *my_file_info= my_file_info_default;
int my_dont_interrupt=0;
volatile int _my_signals=0;
struct st_remember _my_sig_remember[MAX_SIGNALS]={{0,0}};
-#ifdef THREAD
-sigset_t my_signals; /* signals blocked by mf_brkhant */
-#endif
/* from mf_reccache.c */
ulong my_default_record_cache_size=RECORD_CACHE_SIZE;
diff --git a/mysys/my_static.h b/mysys/my_static.h
index 2c9cef0f101..7fde15ff133 100644
--- a/mysys/my_static.h
+++ b/mysys/my_static.h
@@ -25,9 +25,6 @@ C_MODE_START
#include <signal.h>
#define MAX_SIGNALS 10 /* Max signals under a dont-allow */
-#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-#define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
-#define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
struct st_remember {
int number;
@@ -48,9 +45,6 @@ extern struct st_my_file_info my_file_info_default[MY_NFILE];
extern ulonglong query_performance_frequency, query_performance_offset;
-#if defined(THREAD) && !defined(__WIN__)
-extern sigset_t my_signals; /* signals blocked by mf_brkhant */
-#endif
C_MODE_END
#endif /* MYSYS_MY_STATIC_INCLUDED */
diff --git a/mysys/my_vle.c b/mysys/my_vle.c
deleted file mode 100644
index 09f297eb553..00000000000
--- a/mysys/my_vle.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Copyright (C) 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- Variable length encoding.
-
- A method to store an arbitrary-size non-negative integer. We let the
- most significant bit of the number indicate that the next byte
- should be contatenated to form the real number.
-*/
-
-#include "my_vle.h"
-
-/*
- Function to encode an unsigned long as VLE. The bytes for the VLE
- will be written to the location pointed to by 'out'. The maximum
- number of bytes written will be 'max'.
-
- PARAMETERS
-
- out Pointer to beginning of where to store VLE bytes.
- max Maximum number of bytes to write.
- n Number to encode.
-
- RETURN VALUE
- On success, one past the end of the array containing the VLE
- bytes. On failure, the 'out' pointer is returned.
-*/
-
-uchar*
-my_vle_encode(uchar* out, size_t max, ulong n)
-{
- uchar buf[my_vle_sizeof(n)];
- uchar *ptr= buf;
- size_t len;
-
- do
- {
- *ptr++= (uchar) (n & 0x7F);
- n>>= 7;
- }
- while (n > 0);
-
- len= ptr - buf;
-
- if (len <= max)
- {
- /*
- The bytes are stored in reverse order in 'buf'. Let's write them
- in correct order to the output buffer and set the MSB at the
- same time.
- */
- while (ptr-- > buf)
- {
- uchar v= *ptr;
- if (ptr > buf)
- v|= 0x80;
- *out++= v;
- }
- }
-
- return out;
-}
-
-/*
- Function to decode a VLE representation of an integral value.
-
-
- PARAMETERS
-
- result_ptr Pointer to an unsigned long where the value will be written.
- vle Pointer to the VLE bytes.
-
- RETURN VALUE
-
- One-past the end of the VLE bytes. The routine will never read
- more than sizeof(*result_ptr) + 1 bytes.
-*/
-
-uchar const*
-my_vle_decode(ulong *result_ptr, uchar const *vle)
-{
- ulong result= 0;
- size_t cnt= 1;
-
- do
- {
- result<<= 7;
- result|= (*vle & 0x7F);
- }
- while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1);
-
- if (cnt <= sizeof(*result_ptr) + 1)
- *result_ptr= result;
-
- return vle;
-}
diff --git a/mysys/rijndael.c b/mysys/rijndael.c
index 2b12753c4e5..2d622efad82 100644
--- a/mysys/rijndael.c
+++ b/mysys/rijndael.c
@@ -32,22 +32,6 @@
#define FULL_UNROLL
*/
-
-#ifdef NOT_USED
-Te0[x] = S [x].[02, 01, 01, 03];
-Te1[x] = S [x].[03, 02, 01, 01];
-Te2[x] = S [x].[01, 03, 02, 01];
-Te3[x] = S [x].[01, 01, 03, 02];
-Te4[x] = S [x].[01, 01, 01, 01];
-
-Td0[x] = Si[x].[0e, 09, 0d, 0b];
-Td1[x] = Si[x].[0b, 0e, 09, 0d];
-Td2[x] = Si[x].[0d, 0b, 0e, 09];
-Td3[x] = Si[x].[09, 0d, 0b, 0e];
-Td4[x] = Si[x].[01, 01, 01, 01];
-#endif
-
-
static const uint32 Te0[256]=
{
0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index 5b399071d11..39df1b02d7b 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -77,15 +77,5 @@ int main(int argc, char **argv) {
_print_csinfo(cs);
fflush(stdout);
-#ifdef NOT_USED_ANYMORE
- cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
- printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list);
- my_free(cs_list);
-
- cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED));
- printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list);
- my_free(cs_list);
-#endif
-
return 0;
}
diff --git a/mysys/test_fn.c b/mysys/test_fn.c
deleted file mode 100644
index 249cc878390..00000000000
--- a/mysys/test_fn.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include "mysys_priv.h"
-
-const char *test_names[]=
-{
- "/usr/my/include/srclib/myfunc/dbug/test",
- "test",
- "dbug/test",
- "/usr/my/srclib/myfunc/dbug/test",
- "/usr/monty/oldcopy/jazz/setupp.frm",
- "~/monty.tst",
- "~/dbug/monty.tst",
- "./hejsan",
- "./dbug/test",
- "../dbug/test",
- "../myfunc/test",
- "../../monty/rutedit",
- "/usr/monty//usr/monty/rutedit",
- "/usr/./monty/rutedit",
- "/usr/my/../monty/rutedit",
- "/usr/my/~/rutedit",
- "~/../my",
- "~/../my/srclib/myfunc/test",
- "~/../my/srclib/myfunc/./dbug/test",
- "/../usr/my/srclib/dbug",
- "c/../my",
- "/c/../my",
- NullS,
-};
-
-int main(int argc __attribute__((unused)), char **argv)
-{
- const char **pos;
- char buff[FN_REFLEN],buff2[FN_REFLEN];
- DBUG_ENTER ("main");
- DBUG_PROCESS (argv[0]);
- MY_INIT(argv[0]);
-
- if (argv[1] && argv[1][1] == '#')
- DBUG_PUSH(argv[1]+2);
-
- for (pos=test_names; *pos ; pos++)
- {
- printf("org : '%s'\n",*pos);
- printf("pack: '%s'\n",fn_format(buff,*pos,"","",8));
- printf("unpack: '%s'\n",fn_format(buff2,*pos,"","",4));
- unpack_filename(buff,buff);
- if (strcmp(buff,buff2) != 0)
- {
- printf("error on cmp: '%s' != '%s'\n",buff,buff2);
- }
- puts("");
- }
- DBUG_RETURN(0);
-}
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 9ca18eeaf1b..54eef693558 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -903,11 +903,6 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
sigaddset(&set,THR_SERVER_ALARM);
sigdelset(&set, thr_client_alarm);
(void) pthread_sigmask(SIG_SETMASK,&set,NULL);
-#ifdef NOT_USED
- sigemptyset(&set);
- sigaddset(&set, thr_client_alarm);
- pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0);
-#endif
pthread_attr_init(&thr_attr);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 9d10ba1fb01..7ba0490cb29 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -107,7 +107,7 @@ my_bool init_thr_lock()
}
static inline my_bool
-thr_lock_owner_equal(THR_LOCK_OWNER *rhs, THR_LOCK_OWNER *lhs)
+thr_lock_owner_equal(THR_LOCK_INFO *rhs, THR_LOCK_INFO *lhs)
{
return rhs == lhs;
}
@@ -122,7 +122,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
{
THR_LOCK_DATA *data,**prev;
uint count=0;
- THR_LOCK_OWNER *UNINIT_VAR(first_owner);
+ THR_LOCK_INFO *UNINIT_VAR(first_owner);
prev= &list->data;
if (list->data)
@@ -341,7 +341,6 @@ void thr_lock_info_init(THR_LOCK_INFO *info)
struct st_my_thread_var *tmp= my_thread_var;
info->thread= tmp->pthread_self;
info->thread_id= tmp->id;
- info->n_cursors= 0;
}
/* Initialize a lock instance */
@@ -357,7 +356,7 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param)
static inline my_bool
-has_old_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner)
+has_old_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner)
{
for ( ; data ; data=data->next)
{
@@ -506,13 +505,12 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
enum enum_thr_lock_result
-thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
+thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner,
enum thr_lock_type lock_type, ulong lock_wait_timeout)
{
THR_LOCK *lock=data->lock;
enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
struct st_lock_list *wait_queue;
- THR_LOCK_DATA *lock_owner;
DBUG_ENTER("thr_lock");
data->next=0;
@@ -521,7 +519,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
data->owner= owner; /* Must be reset ! */
mysql_mutex_lock(&lock->mutex);
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
- (long) data, data->owner->info->thread_id,
+ (long) data, data->owner->thread_id,
(long) lock, (int) lock_type));
check_locks(lock,(uint) lock_type <= (uint) TL_READ_NO_INSERT ?
"enter read_lock" : "enter write_lock",0);
@@ -558,7 +556,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
*/
DBUG_PRINT("lock",("write locked 1 by thread: 0x%lx",
- lock->write.data->owner->info->thread_id));
+ lock->write.data->owner->thread_id));
if (thr_lock_owner_equal(data->owner, lock->write.data->owner) ||
(lock->write.data->type <= TL_WRITE_DELAYED &&
(((int) lock_type <= (int) TL_READ_HIGH_PRIORITY) ||
@@ -707,7 +705,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
goto end;
}
DBUG_PRINT("lock",("write locked 2 by thread: 0x%lx",
- lock->write.data->owner->info->thread_id));
+ lock->write.data->owner->thread_id));
}
else
{
@@ -743,23 +741,10 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
}
}
DBUG_PRINT("lock",("write locked 3 by thread: 0x%lx type: %d",
- lock->read.data->owner->info->thread_id, data->type));
+ lock->read.data->owner->thread_id, data->type));
}
wait_queue= &lock->write_wait;
}
- /*
- Try to detect a trivial deadlock when using cursors: attempt to
- lock a table that is already locked by an open cursor within the
- same connection. lock_owner can be zero if we succumbed to a high
- priority writer in the write_wait queue.
- */
- lock_owner= lock->read.data ? lock->read.data : lock->write.data;
- if (lock_owner && lock_owner->owner->info == owner->info)
- {
- DBUG_PRINT("lock",("deadlock"));
- result= THR_LOCK_DEADLOCK;
- goto end;
- }
/* Can't get lock yet; Wait for it */
DBUG_RETURN(wait_for_lock(wait_queue, data, 0, lock_wait_timeout));
end:
@@ -807,7 +792,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
}
/* purecov: begin inspected */
DBUG_PRINT("lock",("giving read lock to thread: 0x%lx",
- data->owner->info->thread_id));
+ data->owner->thread_id));
/* purecov: end */
data->cond=0; /* Mark thread free */
mysql_cond_signal(cond);
@@ -826,7 +811,7 @@ void thr_unlock(THR_LOCK_DATA *data)
enum thr_lock_type lock_type=data->type;
DBUG_ENTER("thr_unlock");
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx",
- (long) data, data->owner->info->thread_id, (long) lock));
+ (long) data, data->owner->thread_id, (long) lock));
mysql_mutex_lock(&lock->mutex);
check_locks(lock,"start of release lock",0);
@@ -915,7 +900,7 @@ static void wake_up_waiters(THR_LOCK *lock)
data->type=TL_WRITE; /* Upgrade lock */
/* purecov: begin inspected */
DBUG_PRINT("lock",("giving write lock of type %d to thread: 0x%lx",
- data->type, data->owner->info->thread_id));
+ data->type, data->owner->thread_id));
/* purecov: end */
{
mysql_cond_t *cond= data->cond;
@@ -1020,7 +1005,7 @@ static void sort_locks(THR_LOCK_DATA **data,uint count)
enum enum_thr_lock_result
-thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_OWNER *owner,
+thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_INFO *owner,
ulong lock_wait_timeout)
{
THR_LOCK_DATA **pos,**end;
@@ -1144,7 +1129,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count)
else
{
DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: 0x%lx lock: 0x%lx",
- (long) *pos, (*pos)->owner->info->thread_id,
+ (long) *pos, (*pos)->owner->thread_id,
(long) (*pos)->lock));
}
}
@@ -1200,7 +1185,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
mysql_mutex_lock(&lock->mutex);
for (data= lock->read_wait.data; data ; data= data->next)
{
- if (data->owner->info->thread_id == thread_id) /* purecov: tested */
+ if (data->owner->thread_id == thread_id) /* purecov: tested */
{
DBUG_PRINT("info",("Aborting read-wait lock"));
data->type= TL_UNLOCK; /* Mark killed */
@@ -1217,7 +1202,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
}
for (data= lock->write_wait.data; data ; data= data->next)
{
- if (data->owner->info->thread_id == thread_id) /* purecov: tested */
+ if (data->owner->thread_id == thread_id) /* purecov: tested */
{
DBUG_PRINT("info",("Aborting write-wait lock"));
data->type= TL_UNLOCK;
@@ -1387,7 +1372,7 @@ static void thr_print_lock(const char* name,struct st_lock_list *list)
prev= &list->data;
for (data=list->data; data && count++ < MAX_LOCKS ; data=data->next)
{
- printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->info->thread_id,
+ printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->thread_id,
(int) data->type);
if (data->prev != prev)
printf("\nWarning: prev didn't point at previous lock\n");
@@ -1525,7 +1510,6 @@ static void *test_thread(void *arg)
{
int i,j,param=*((int*) arg);
THR_LOCK_DATA data[MAX_LOCK_COUNT];
- THR_LOCK_OWNER owner;
THR_LOCK_INFO lock_info;
THR_LOCK_DATA *multi_locks[MAX_LOCK_COUNT];
my_thread_init();
@@ -1534,7 +1518,6 @@ static void *test_thread(void *arg)
thr_lock_info_init(&lock_info);
- thr_lock_owner_init(&owner, &lock_info);
for (i=0; i < lock_counts[param] ; i++)
thr_lock_data_init(locks+tests[param][i].lock_nr,data+i,NULL);
for (j=1 ; j < 10 ; j++) /* try locking 10 times */
@@ -1544,7 +1527,7 @@ static void *test_thread(void *arg)
multi_locks[i]= &data[i];
data[i].type= tests[param][i].lock_type;
}
- thr_multi_lock(multi_locks, lock_counts[param], &owner, TEST_TIMEOUT);
+ thr_multi_lock(multi_locks, lock_counts[param], &lock_info, TEST_TIMEOUT);
mysql_mutex_lock(&LOCK_thread_count);
{
int tmp=rand() & 7; /* Do something from 0-2 sec */
diff --git a/mysys/trie.c b/mysys/trie.c
deleted file mode 100644
index b2e93fcceac..00000000000
--- a/mysys/trie.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/* Copyright (C) 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- Implementation of trie and Aho-Corasick automaton.
- Supports only charsets that can be compared byte-wise.
-
- TODO:
- Add character frequencies. Can increase lookup speed
- up to 30%.
- Implement character-wise comparision.
-*/
-
-
-#include "mysys_priv.h"
-#include <m_string.h>
-#include <my_trie.h>
-#include <my_base.h>
-
-
-/*
- SYNOPSIS
- TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset);
-
- DESCRIPTION
- Allocates or initializes a `TRIE' object. If `trie' is a `NULL'
- pointer, the function allocates, initializes, and returns a new
- object. Otherwise, the object is initialized and the address of
- the object is returned. If `trie_init()' allocates a new object,
- it will be freed when `trie_free()' is called.
-
- RETURN VALUE
- An initialized `TRIE*' object. `NULL' if there was insufficient
- memory to allocate a new object.
-*/
-
-TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset)
-{
- MEM_ROOT mem_root;
- DBUG_ENTER("trie_init");
- DBUG_ASSERT(charset);
- init_alloc_root(&mem_root,
- (sizeof(TRIE_NODE) * 128) + ALLOC_ROOT_MIN_BLOCK_SIZE,
- sizeof(TRIE_NODE) * 128);
- if (! trie)
- {
- if (! (trie= (TRIE *)alloc_root(&mem_root, sizeof(TRIE))))
- {
- free_root(&mem_root, MYF(0));
- DBUG_RETURN(NULL);
- }
- }
-
- memcpy(&trie->mem_root, &mem_root, sizeof(MEM_ROOT));
- trie->root.leaf= 0;
- trie->root.c= 0;
- trie->root.next= NULL;
- trie->root.links= NULL;
- trie->root.fail= NULL;
- trie->charset= charset;
- trie->nnodes= 0;
- trie->nwords= 0;
- DBUG_RETURN(trie);
-}
-
-
-/*
- SYNOPSIS
- void trie_free (TRIE *trie);
- trie - valid pointer to `TRIE'
-
- DESCRIPTION
- Frees the memory allocated for a `trie'.
-
- RETURN VALUE
- None.
-*/
-
-void trie_free (TRIE *trie)
-{
- MEM_ROOT mem_root;
- DBUG_ENTER("trie_free");
- DBUG_ASSERT(trie);
- memcpy(&mem_root, &trie->mem_root, sizeof(MEM_ROOT));
- free_root(&mem_root, MYF(0));
- DBUG_VOID_RETURN;
-}
-
-
-/*
- SYNOPSIS
- my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen);
- trie - valid pointer to `TRIE'
- key - valid pointer to key to insert
- keylen - non-0 key length
-
- DESCRIPTION
- Inserts new key into trie.
-
- RETURN VALUE
- Upon successful completion, `trie_insert' returns `FALSE'. Otherwise
- `TRUE' is returned.
-
- NOTES
- If this function fails you must assume `trie' is broken.
- However it can be freed with trie_free().
-*/
-
-my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen)
-{
- TRIE_NODE *node;
- TRIE_NODE *next;
- uchar p;
- uint k;
- DBUG_ENTER("trie_insert");
- DBUG_ASSERT(trie && key && keylen);
- node= &trie->root;
- trie->root.fail= NULL;
- for (k= 0; k < keylen; k++)
- {
- p= key[k];
- for (next= node->links; next; next= next->next)
- if (next->c == p)
- break;
-
- if (! next)
- {
- TRIE_NODE *tmp= (TRIE_NODE *)alloc_root(&trie->mem_root,
- sizeof(TRIE_NODE));
- if (! tmp)
- DBUG_RETURN(TRUE);
- tmp->leaf= 0;
- tmp->c= p;
- tmp->links= tmp->fail= tmp->next= NULL;
- trie->nnodes++;
- if (! node->links)
- {
- node->links= tmp;
- }
- else
- {
- for (next= node->links; next->next; next= next->next) /* no-op */;
- next->next= tmp;
- }
- node= tmp;
- }
- else
- {
- node= next;
- }
- }
- node->leaf= keylen;
- trie->nwords++;
- DBUG_RETURN(FALSE);
-}
-
-
-/*
- SYNOPSIS
- my_bool trie_prepare (TRIE *trie);
- trie - valid pointer to `TRIE'
-
- DESCRIPTION
- Constructs Aho-Corasick automaton.
-
- RETURN VALUE
- Upon successful completion, `trie_prepare' returns `FALSE'. Otherwise
- `TRUE' is returned.
-*/
-
-my_bool ac_trie_prepare (TRIE *trie)
-{
- TRIE_NODE **tmp_nodes;
- TRIE_NODE *node;
- uint32 fnode= 0;
- uint32 lnode= 0;
- DBUG_ENTER("trie_prepare");
- DBUG_ASSERT(trie);
-
- tmp_nodes= (TRIE_NODE **)my_malloc(trie->nnodes * sizeof(TRIE_NODE *), MYF(0));
- if (! tmp_nodes)
- DBUG_RETURN(TRUE);
-
- trie->root.fail= &trie->root;
- for (node= trie->root.links; node; node= node->next)
- {
- node->fail= &trie->root;
- tmp_nodes[lnode++]= node;
- }
-
- while (fnode < lnode)
- {
- TRIE_NODE *current= (TRIE_NODE *)tmp_nodes[fnode++];
- for (node= current->links; node; node= node->next)
- {
- TRIE_NODE *fail= current->fail;
- tmp_nodes[lnode++]= node;
- while (! (node->fail= trie_goto(&trie->root, fail, node->c)))
- fail= fail->fail;
- }
- }
- my_free(tmp_nodes);
- DBUG_RETURN(FALSE);
-}
-
-
-/*
- SYNOPSIS
- void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state);
- trie - valid pointer to `TRIE'
- state - value pointer to `AC_TRIE_STATE'
-
- DESCRIPTION
- Initializes `AC_TRIE_STATE' object.
-*/
-
-void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state)
-{
- DBUG_ENTER("ac_trie_init");
- DBUG_ASSERT(trie && state);
- state->trie= trie;
- state->node= &trie->root;
- DBUG_VOID_RETURN;
-}
diff --git a/packaging/Makefile.am b/packaging/Makefile.am
new file mode 100644
index 00000000000..3e6a79367b6
--- /dev/null
+++ b/packaging/Makefile.am
@@ -0,0 +1,14 @@
+EXTRA_DIST = \
+ WiX/AdminBackground.jpg \
+ WiX/AdminHeader.jpg \
+ WiX/CMakeLists.txt \
+ WiX/extra.wxs.in \
+ WiX/CPackWixConfig.cmake \
+ WiX/create_msi.cmake.in \
+ WiX/custom_ui.wxs \
+ WiX/MySQLServer.ico \
+ WiX/mysql_server.wxs.in \
+ WiX/ca/CMakeLists.txt \
+ WiX/ca/CustomAction.cpp \
+ WiX/ca/CustomAction.def \
+ WiX/ca/CustomAction.rc
diff --git a/packaging/WiX/CMakeLists.txt b/packaging/WiX/CMakeLists.txt
index 8a6a4ae4c41..052887f10a1 100644
--- a/packaging/WiX/CMakeLists.txt
+++ b/packaging/WiX/CMakeLists.txt
@@ -41,11 +41,13 @@ FOREACH(dir mysql performance_schema)
FILE(GLOB files ${CMAKE_BINARY_DIR}/sql/data/${dir}/*)
SET(filelist)
FOREACH(f ${files})
+ IF(NOT f MATCHES ".rule")
FILE(TO_NATIVE_PATH "${f}" file_native_path)
GET_FILENAME_COMPONENT(file_name "${f}" NAME)
SET(filelist
"${filelist}
<File Id='${file_name}' Source='${file_native_path}'/>")
+ ENDIF()
ENDFOREACH()
STRING(TOUPPER ${dir} DIR_UPPER)
SET(DATADIR_${DIR_UPPER}_FILES "${filelist}")
@@ -56,15 +58,34 @@ FIND_PROGRAM(HEAT_EXECUTABLE heat ${WIX_DIR})
FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR})
FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR})
+# WiX wants the license text as rtf; if there is no rtf license,
+# we create a fake one from the plain text COPYING file.
+IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
+ SET(COPYING_RTF "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
+ELSE()
+ FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING" CONTENTS)
+ STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}")
+ STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}")
+ FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15")
+ FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}")
+ FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n")
+ SET(COPYING_RTF "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf")
+ENDIF()
+GET_TARGET_PROPERTY(WIXCA_LOCATION wixca LOCATION)
+SET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake)
+SET(CPACK_WIX_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/extra.wxs;${CMAKE_CURRENT_SOURCE_DIR}/custom_ui.wxs")
+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
@ONLY)
+
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(WixWin64 " Win64='yes'")
ELSE()
SET(WixWin64)
ENDIF()
+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/extra.wxs.in
${CMAKE_CURRENT_BINARY_DIR}/extra.wxs)
@@ -72,28 +93,11 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
ENDIF()
-# WiX wants the license text as rtf; if there is no rtf license,
-# we create a fake one from the plain text COPYING file.
-IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf")
- MESSAGE("copying COPYING.rtf")
- FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf" CONTENTS)
- FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}")
-ELSE()
- MESSAGE("creating COPYING.rtf")
- FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING" CONTENTS)
- STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}")
- STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}")
- FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15")
- FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}")
- FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n")
-ENDIF()
ADD_CUSTOM_TARGET(
MSI
COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND}
- -DCPACK_WIX_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake
- -DCPACK_WIX_INCLUDE=${CMAKE_CURRENT_BINARY_DIR}/extra.wxs
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
)
@@ -103,10 +107,8 @@ ADD_CUSTOM_TARGET(
MSI_ESSENTIALS
COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND} -DESSENTIALS=1
- -DCPACK_WIX_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake
- -DCPACK_WIX_INCLUDE=${CMAKE_CURRENT_BINARY_DIR}/extra.wxs
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
)
-ADD_DEPENDENCIES(MSI wixca)
+ADD_DEPENDENCIES(MSI_ESSENTIALS wixca)
diff --git a/packaging/WiX/CPackWixConfig.cmake b/packaging/WiX/CPackWixConfig.cmake
index 0413b699fc5..f49406b5787 100644
--- a/packaging/WiX/CPackWixConfig.cmake
+++ b/packaging/WiX/CPackWixConfig.cmake
@@ -1,6 +1,5 @@
IF(ESSENTIALS)
- MESSAGE("Essentials!")
SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles")
SET(CPACK_WIX_UI "WixUI_InstallDir")
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
@@ -60,6 +59,7 @@ SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install MySQL Server")
SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer")
SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files")
SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" )
+ SET(CPACK_COMPONENT_DATAFILES_HIDDEN 1)
#Feature "Devel"
diff --git a/packaging/WiX/create_msi.cmake.in b/packaging/WiX/create_msi.cmake.in
index d6725e9ae6c..adc3cf4c4dd 100644
--- a/packaging/WiX/create_msi.cmake.in
+++ b/packaging/WiX/create_msi.cmake.in
@@ -10,6 +10,10 @@ SET(MINOR_VERSION "@MINOR_VERSION@")
SET(PATCH "@PATCH@")
SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)
SET(MANUFACTURER "@MANUFACTURER@")
+SET(WIXCA_LOCATION "@WIXCA_LOCATION@")
+SET(COPYING_RTF "@COPYING_RTF@")
+SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@")
+SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(Win64 " Win64='yes'")
@@ -30,7 +34,7 @@ IF(CPACK_WIX_CONFIG)
ENDIF()
IF(NOT CPACK_WIX_UI)
- SET(CPACK_WIX_UI "WixUI_Mondo")
+ SET(CPACK_WIX_UI "WixUI_Mondo_Custom")
ENDIF()
SET(WIX_FEATURES)
@@ -144,15 +148,16 @@ FOREACH(f ${WIX_FEATURES})
ENDFOREACH()
+IF(CMAKE_INSTALL_CONFIG_NAME)
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}"
+ WIXCA_LOCATION "${WIXCA_LOCATION}")
+ SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
+ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
-IF(CMAKE_INSTALL_CONFIG_NAME)
- SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
-ENDIF()
-
FOREACH(comp ${CPACK_COMPONENTS_ALL})
SET(ENV{DESTDIR} testinstall/${comp})
SET(DIRS ${DIRS} testinstall/${comp})
@@ -262,9 +267,12 @@ FOREACH(d ${DIRS})
SET(COMP_NAME ${d_name})
TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs ${abs}/${d_name}_component_group.wxs "${abs}/dirs")
FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>")
- FILE(READ ${d_name}.wxs WIX_TMP)
- SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
- FILE(REMOVE ${d_name}.wxs)
+ IF(EXISTS ${d_name}.wxs)
+ FILE(READ ${d_name}.wxs WIX_TMP)
+ SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
+ FILE(REMOVE ${d_name}.wxs)
+ ENDIF()
+
FILE(READ ${d_name}_component_group.wxs WIX_TMP)
SET(CPACK_WIX_COMPONENT_GROUPS "${CPACK_WIX_COMPONENT_GROUPS}\n${WIX_TMP}")
diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs
new file mode 100644
index 00000000000..90db5c416fe
--- /dev/null
+++ b/packaging/WiX/custom_ui.wxs
@@ -0,0 +1,81 @@
+<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
+ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+ <WixVariable Id="WixUICostingPopupOptOut" Value="1" Overridable="yes" />
+ <UI Id="WixUI_Mondo_Custom">
+ <Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade">
+ <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
+ <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
+ <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
+ <Condition Action="default">WixUI_InstallMode = "Remove"</Condition>
+ </Control>
+ <Control Id="InstallTitle" Type="Text" X="15" Y="15" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallTitle)">
+ <Condition Action="show">NOT Installed</Condition>
+ </Control>
+ <Control Id="InstallText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallText)">
+ <Condition Action="show">NOT Installed</Condition>
+ </Control>
+ <Control Id="UpgradeText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="no" NoPrefix="yes"
+ Text="Click Upgrade to upgrade your installation from version [OLDERVERSION] to version [ProductVersion]. Click Cancel to exit the upgrade."/>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.VerifyReadyDlgBannerBitmap)" />
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ </Dialog>
+
+ <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
+ <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
+ <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
+
+ <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
+ <Property Id="WixUI_Mode" Value="Mondo" />
+
+ <DialogRef Id="ErrorDlg" />
+ <DialogRef Id="FatalError" />
+ <DialogRef Id="FilesInUse" />
+ <DialogRef Id="MsiRMFilesInUse" />
+ <DialogRef Id="PrepareDlg" />
+ <DialogRef Id="ProgressDlg" />
+ <DialogRef Id="ResumeDlg" />
+ <DialogRef Id="UserExit" />
+
+ <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
+
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="1">NOT OLDERVERSIONBEINGUPGRADED</Publish>
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="UpgradeDlg" Order="2">OLDERVERSIONBEINGUPGRADED</Publish>
+
+ <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
+ <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish>
+
+ <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+
+ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish>
+
+ <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
+
+ <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
+
+ <Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
+ </UI>
+
+ <UIRef Id="WixUI_Common" />
+</Include>
diff --git a/packaging/WiX/extra.wxs.in b/packaging/WiX/extra.wxs.in
index b6c42136129..fe2e73c3340 100644
--- a/packaging/WiX/extra.wxs.in
+++ b/packaging/WiX/extra.wxs.in
@@ -48,7 +48,11 @@
</Directory>
</DirectoryRef>
- <Feature Id="UserEditableDatafiles" Level='1' Display='hidden' ConfigurableDirectory="DATADIR">
+ <Feature Id='UserEditableDataFiles'
+ Title='Server data files'
+ Description='Server data files'
+ ConfigurableDirectory='DATADIR'
+ Level='1'>
<ComponentRef Id="component.datadir"/>
<ComponentRef Id="component.datadir.mysql"/>
<ComponentRef Id="component.datadir.performance_schema"/>
diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in
index 8b20644e58d..59cc817a302 100644
--- a/packaging/WiX/mysql_server.wxs.in
+++ b/packaging/WiX/mysql_server.wxs.in
@@ -26,7 +26,9 @@
Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
IncludeMinimum="yes"
Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
- Property="OLDERVERSIONBEINGUPGRADED" />
+ Property="OLDERVERSIONBEINGUPGRADED"
+ MigrateFeatures="yes"
+ />
<UpgradeVersion
Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
OnlyDetect="yes"
@@ -39,6 +41,53 @@
<RemoveExistingProducts After="InstallInitialize"/>
</InstallExecuteSequence>
+ <!-- Save/restore install location -->
+ <CustomAction Id="SaveTargetDir" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]" />
+ <InstallExecuteSequence>
+ <Custom Action="SaveTargetDir" After="InstallValidate">
+ NOT
+ Installed
+ </Custom>
+ </InstallExecuteSequence>
+ <InstallUISequence>
+ <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->
+ <AppSearch After="FindRelatedProducts"/>
+ </InstallUISequence>
+
+ <!-- Find previous installation -->
+ <Property Id="INSTALLDIR">
+ <RegistrySearch Id="FindInstallLocation"
+ Root="HKLM"
+ Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
+ Name="InstallLocation"
+ Type="raw" />
+ </Property>
+ <Property Id="OLDERVERSION">
+ <RegistrySearch Id="FindOlderVersion"
+ Root="HKLM"
+ Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
+ Name="DisplayVersion"
+ Type="raw" />
+ </Property>
+ <Property Id="DATADIR">
+ <RegistrySearch Id="FindDataDir"
+ Root="HKLM"
+ Key="SOFTWARE\MySQL AB\[ProductName]"
+ Name="DataLocation"
+ Type="raw" />
+ </Property>
+ <Property Id="INSTALLDIR2">
+ <RegistrySearch Id="FindInstallLocation2"
+ Root="HKLM"
+ Key="SOFTWARE\MySQL AB\[ProductName]"
+ Name="Location"
+ Type="raw" />
+ </Property>
+ <CustomAction Id="SetInstallDir2" Property="INSTALLDIR" Value="[INSTALLDIR2]" />
+ <InstallUISequence>
+ <Custom Action="SetInstallDir2" After="AppSearch">INSTALLDIR2</Custom>
+ </InstallUISequence>
+
<!-- UI -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
@@ -60,10 +109,10 @@
<!-- License -->
<WixVariable
Id="WixUILicenseRtf"
- Value="@CMAKE_CURRENT_BINARY_DIR@/COPYING.rtf"/>
+ Value="@COPYING_RTF@"/>
<!-- How to remove the service on uninstall -->
- <Binary Id='wixca.dll' SourceFile='@CMAKE_CURRENT_BINARY_DIR@/ca/RelWithDebInfo/wixca.dll' />
+ <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' />
<CustomAction Id="UnregisterProperty" Property="UnregisterService" Value="[INSTALLDIR]" Return="check" />
<CustomAction Id="UnregisterPropertySilent" Property="UnregisterServiceSilently" Value="[INSTALLDIR]" Return="check" />
<CustomAction Id="UnregisterService"
@@ -81,8 +130,8 @@
<InstallExecuteSequence>
<Custom Action="UnregisterProperty" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE</Custom>
<Custom Action="UnregisterPropertySilent" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And UILevel&gt;2</Custom>
- <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And UILevel&lt;=2</Custom>
+ <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And UILevel&gt;4</Custom>
+ <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And UILevel&lt;=4</Custom>
</InstallExecuteSequence>
<!-- Installation root-->
diff --git a/regex/regcomp.c b/regex/regcomp.c
index 81c435ed552..b41a1ae6da9 100644
--- a/regex/regcomp.c
+++ b/regex/regcomp.c
@@ -285,18 +285,6 @@ register struct parse *p;
EMIT(ORPAREN, subno);
if(MUSTEAT(')', REG_EPAREN)) {}
break;
-#ifndef POSIX_MISTAKE
- case ')': /* happens only if no current unmatched ( */
- /*
- * You may ask, why the ifndef? Because I didn't notice
- * this until slightly too late for 1003.2, and none of the
- * other 1003.2 regular-expression reviewers noticed it at
- * all. So an unmatched ) is legal POSIX, at least until
- * we can get it fixed.
- */
- SETERROR(REG_EPAREN);
- break;
-#endif
case '^':
EMIT(OBOL, 0);
p->g->iflags |= USEBOL;
@@ -1228,66 +1216,6 @@ register char *cp;
}
#endif
-#ifdef NOT_USED
-/*
- - mcsub - subtract a collating element from a cset
- == static void mcsub(register cset *cs, register char *cp);
- */
-static void
-mcsub(cs, cp)
-register cset *cs;
-register char *cp;
-{
- register char *fp = mcfind(cs, cp);
- register size_t len = strlen(fp);
-
- assert(fp != NULL);
- (void) memmove(fp, fp + len + 1,
- cs->smultis - (fp + len + 1 - cs->multis));
- cs->smultis -= len;
-
- if (cs->smultis == 0) {
- free(cs->multis);
- cs->multis = NULL;
- return;
- }
-
- cs->multis = realloc(cs->multis, cs->smultis);
- assert(cs->multis != NULL);
-}
-
-/*
- - mcin - is a collating element in a cset?
- == static int mcin(register cset *cs, register char *cp);
- */
-static int
-mcin(cs, cp)
-register cset *cs;
-register char *cp;
-{
- return(mcfind(cs, cp) != NULL);
-}
-
-/*
- - mcfind - find a collating element in a cset
- == static char *mcfind(register cset *cs, register char *cp);
- */
-static char *
-mcfind(cs, cp)
-register cset *cs;
-register char *cp;
-{
- register char *p;
-
- if (cs->multis == NULL)
- return(NULL);
- for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
- if (strcmp(cp, p) == 0)
- return(p);
- return(NULL);
-}
-#endif
-
/*
- mcinvert - invert the list of collating elements in a cset
== static void mcinvert(register struct parse *p, register cset *cs);
diff --git a/regex/regcomp.ih b/regex/regcomp.ih
index 5deba89217a..cb93286e32f 100644
--- a/regex/regcomp.ih
+++ b/regex/regcomp.ih
@@ -30,11 +30,6 @@ static int nch(register struct parse *p, register cset *cs);
#ifdef USE_ORIG_REGEX_CODE
static void mcadd(register struct parse *p, register cset *cs, register char *cp);
#endif
-#ifdef NOT_USED
-static void mcsub(register cset *cs, register char *cp);
-static int mcin(register cset *cs, register char *cp);
-static char *mcfind(register cset *cs, register char *cp);
-#endif
static void mcinvert(register struct parse *p, register cset *cs);
static void mccase(register struct parse *p, register cset *cs);
static int isinsets(register struct re_guts *g, int c);
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index 9af722f7afc..4fb57b06d71 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -264,7 +264,6 @@ cp include/mysql.h \
include/sql_state.h \
include/mysqld_ername.h \
include/mysql_version.h \
- include/config-win.h \
libmysql/libmysql.def \
$DESTDIR/include/
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 7107a68ee84..e8a594c4d8b 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -43,7 +43,7 @@ SET (SQL_SOURCE
discover.cc ../libmysql/errmsg.c field.cc field_conv.cc
filesort.cc gstream.cc sha2.cc
ha_partition.cc
- handler.cc hash_filo.cc hash_filo.h sql_plugin_services.h
+ handler.cc hash_filo.h sql_plugin_services.h
hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc
item_create.cc item_func.cc item_geofunc.cc item_row.cc
item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc
@@ -60,7 +60,7 @@ SET (SQL_SOURCE
sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h
sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc
sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc
- sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc
+ sql_list.cc sql_load.cc sql_manager.cc sql_parse.cc
sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc
debug_sync.cc debug_sync.h
sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc
@@ -185,22 +185,15 @@ RUN_BISON(
# Gen_lex_hash
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
-TARGET_LINK_LIBRARIES(gen_lex_hash mysys)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
- COMMAND gen_lex_hash ARGS > lex_hash.h.tmp &&
- ${CMAKE_COMMAND} -E copy_if_different lex_hash.h.tmp lex_hash.h
- COMMAND ${CMAKE_COMMAND} -E remove -f lex_hash.h.tmp
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_lex_hash.cc)
+ COMMAND gen_lex_hash > lex_hash.h
+)
MYSQL_ADD_EXECUTABLE(mysql_tzinfo_to_sql tztime.cc)
SET_TARGET_PROPERTIES(mysql_tzinfo_to_sql PROPERTIES COMPILE_FLAGS "-DTZINFO2SQL")
-TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql ${MYSQLD_STATIC_PLUGIN_LIBS}
- mysys dbug strings vio regex
- ${LIBWRAP} ${LIBCRYPT} ${LIBDL}
- ${SSL_LIBRARIES})
+TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys)
ADD_CUSTOM_TARGET(
GenServerSource
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 4b1ecbbc8da..7fed55f3cd6 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -90,7 +90,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
item_create.h item_subselect.h item_row.h \
sql_priv.h item_geofunc.h sql_bitmap.h \
procedure.h sql_class.h sql_lex.h sql_list.h \
- sql_map.h sql_string.h unireg.h \
+ sql_string.h unireg.h \
sql_error.h field.h handler.h mysqld_suffix.h \
sql_profile.h mysqld.h sql_help.h frm_crypt.h \
ha_ndbcluster.h ha_ndbcluster_cond.h \
@@ -135,7 +135,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
item_row.cc item_geofunc.cc item_xmlfunc.cc \
field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \
net_serv.cc protocol.cc sql_state.c \
- lock.cc sql_string.cc sql_manager.cc sql_map.cc \
+ lock.cc sql_string.cc sql_manager.cc \
main.cc mysqld.cc password.c hash_filo.cc hostname.cc \
sql_connect.cc scheduler.cc sql_parse.cc \
keycaches.cc set_var.cc sql_yacc.yy sys_vars.cc \
@@ -160,8 +160,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
rpl_reporting.cc \
sql_union.cc sql_derived.cc \
sql_client.cc \
- repl_failsafe.h repl_failsafe.cc \
- sql_olap.cc sql_view.cc \
+ repl_failsafe.h repl_failsafe.cc sql_view.cc \
gstream.cc spatial.cc sql_help.cc sql_cursor.cc \
tztime.cc my_decimal.cc\
sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index dd1845b29bc..52c509621ac 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1402,6 +1402,8 @@ Event_job_data::execute(THD *thd, bool drop)
*/
thd->set_db(dbname.str, dbname.length);
+ lex_start(thd);
+
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (event_sctx.change_security_context(thd,
&definer_user, &definer_host,
@@ -1411,7 +1413,7 @@ Event_job_data::execute(THD *thd, bool drop)
"[%s].[%s.%s] execution failed, "
"failed to authenticate the user.",
definer.str, dbname.str, name.str);
- goto end_no_lex_start;
+ goto end;
}
#endif
@@ -1427,11 +1429,11 @@ Event_job_data::execute(THD *thd, bool drop)
"[%s].[%s.%s] execution failed, "
"user no longer has EVENT privilege.",
definer.str, dbname.str, name.str);
- goto end_no_lex_start;
+ goto end;
}
if (construct_sp_sql(thd, &sp_sql))
- goto end_no_lex_start;
+ goto end;
/*
Set up global thread attributes to reflect the properties of
@@ -1451,8 +1453,6 @@ Event_job_data::execute(THD *thd, bool drop)
if (parser_state.init(thd, thd->query(), thd->query_length()))
goto end;
- lex_start(thd);
-
if (parse_sql(thd, & parser_state, creation_ctx))
{
sql_print_error("Event Scheduler: "
@@ -1484,13 +1484,6 @@ Event_job_data::execute(THD *thd, bool drop)
}
end:
- if (thd->lex->sphead) /* NULL only if a parse error */
- {
- delete thd->lex->sphead;
- thd->lex->sphead= NULL;
- }
-
-end_no_lex_start:
if (drop && !thd->is_fatal_error)
{
/*
@@ -1529,7 +1522,6 @@ end_no_lex_start:
if (save_sctx)
event_sctx.restore_security_context(thd, save_sctx);
#endif
- lex_end(thd->lex);
thd->lex->unit.cleanup();
thd->end_statement();
thd->cleanup_after_query();
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index b7c01f10066..d47f1641bb0 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -518,17 +518,20 @@ Event_db_repository::table_scan_all_for_i_s(THD *thd, TABLE *schema_table,
*/
bool
-Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *tables,
+Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *i_s_table,
const char *db)
{
- TABLE *schema_table= tables->table;
- TABLE *event_table= NULL;
+ TABLE *schema_table= i_s_table->table;
+ Open_tables_backup open_tables_backup;
+ TABLE_LIST event_table;
int ret= 0;
DBUG_ENTER("Event_db_repository::fill_schema_events");
DBUG_PRINT("info",("db=%s", db? db:"(null)"));
- if (open_event_table(thd, TL_READ, &event_table))
+ event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
+
+ if (open_system_tables_for_read(thd, &event_table, &open_tables_backup))
DBUG_RETURN(TRUE);
/*
@@ -541,11 +544,11 @@ Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *tables,
every single row's `db` with the schema which we show.
*/
if (db)
- ret= index_read_for_db_for_i_s(thd, schema_table, event_table, db);
+ ret= index_read_for_db_for_i_s(thd, schema_table, event_table.table, db);
else
- ret= table_scan_all_for_i_s(thd, schema_table, event_table);
+ ret= table_scan_all_for_i_s(thd, schema_table, event_table.table);
- close_thread_tables(thd);
+ close_system_tables(thd, &open_tables_backup);
DBUG_PRINT("info", ("Return code=%d", ret));
DBUG_RETURN(ret);
@@ -584,10 +587,7 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
tables.init_one_table("mysql", 5, "event", 5, "event", lock_type);
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
- {
- close_thread_tables(thd);
DBUG_RETURN(TRUE);
- }
*table= tables.table;
tables.table->use_all_columns();
@@ -700,7 +700,8 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
end:
if (table)
- close_thread_tables(thd);
+ close_mysql_tables(thd);
+
thd->variables.sql_mode= saved_mode;
DBUG_RETURN(test(ret));
}
@@ -811,7 +812,8 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
end:
if (table)
- close_thread_tables(thd);
+ close_mysql_tables(thd);
+
thd->variables.sql_mode= saved_mode;
DBUG_RETURN(test(ret));
}
@@ -865,7 +867,7 @@ Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
end:
if (table)
- close_thread_tables(thd);
+ close_mysql_tables(thd);
DBUG_RETURN(test(ret));
}
@@ -934,33 +936,13 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
void
Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
{
- DBUG_ENTER("Event_db_repository::drop_schema_events");
- drop_events_by_field(thd, ET_FIELD_DB, schema);
- DBUG_VOID_RETURN;
-}
-
-
-/**
- Drops all events which have a specific value of a field.
-
- @pre The thread handle has no open tables.
-
- @param[in,out] thd Thread
- @param[in,out] table mysql.event TABLE
- @param[in] field Which field of the row to use for matching
- @param[in] field_value The value that should match
-*/
-
-void
-Event_db_repository::drop_events_by_field(THD *thd,
- enum enum_events_table_field field,
- LEX_STRING field_value)
-{
int ret= 0;
TABLE *table= NULL;
READ_RECORD read_record_info;
- DBUG_ENTER("Event_db_repository::drop_events_by_field");
- DBUG_PRINT("enter", ("field=%d field_value=%s", field, field_value.str));
+ enum enum_events_table_field field= ET_FIELD_DB;
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
+ DBUG_ENTER("Event_db_repository::drop_schema_events");
+ DBUG_PRINT("enter", ("field=%d schema=%s", field, schema.str));
if (open_event_table(thd, TL_WRITE, &table))
DBUG_VOID_RETURN;
@@ -979,7 +961,7 @@ Event_db_repository::drop_events_by_field(THD *thd,
get_field(thd->mem_root,
table->field[ET_FIELD_NAME])));
- if (!sortcmp_lex_string(et_field_lex, field_value, system_charset_info))
+ if (!sortcmp_lex_string(et_field_lex, schema, system_charset_info))
{
DBUG_PRINT("info", ("Dropping"));
if ((ret= table->file->ha_delete_row(table->record[0])))
@@ -989,6 +971,11 @@ Event_db_repository::drop_events_by_field(THD *thd,
}
end_read_record(&read_record_info);
close_thread_tables(thd);
+ /*
+ Make sure to only release the MDL lock on mysql.event, not other
+ metadata locks DROP DATABASE might have acquired.
+ */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
DBUG_VOID_RETURN;
}
@@ -1026,7 +1013,7 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
else if ((ret= etn->load_from_row(thd, table)))
my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), "event");
- close_thread_tables(thd);
+ close_mysql_tables(thd);
}
thd->variables.sql_mode= saved_mode;
@@ -1104,7 +1091,8 @@ update_timing_fields_for_event(THD *thd,
end:
if (table)
- close_thread_tables(thd);
+ close_mysql_tables(thd);
+
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -1151,7 +1139,7 @@ Event_db_repository::check_system_tables(THD *thd)
if (table_intact.check(tables.table, &mysql_db_table_def))
ret= 1;
- close_thread_tables(thd);
+ close_mysql_tables(thd);
}
/* Check mysql.user */
tables.init_one_table("mysql", 5, "user", 4, "user", TL_READ);
@@ -1171,7 +1159,7 @@ Event_db_repository::check_system_tables(THD *thd)
event_priv_column_position);
ret= 1;
}
- close_thread_tables(thd);
+ close_mysql_tables(thd);
}
/* Check mysql.event */
tables.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
@@ -1185,7 +1173,7 @@ Event_db_repository::check_system_tables(THD *thd)
{
if (table_intact.check(tables.table, &event_table_def))
ret= 1;
- close_thread_tables(thd);
+ close_mysql_tables(thd);
}
DBUG_RETURN(test(ret));
diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h
index ef778407d1e..ea7f3bbac0e 100644
--- a/sql/event_db_repository.h
+++ b/sql/event_db_repository.h
@@ -91,7 +91,7 @@ public:
bool
load_named_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et);
- bool
+ static bool
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
bool
@@ -109,9 +109,6 @@ public:
static bool
check_system_tables(THD *thd);
private:
- void
- drop_events_by_field(THD *thd, enum enum_events_table_field field,
- LEX_STRING field_value);
bool
index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table,
const char *db);
diff --git a/sql/events.cc b/sql/events.cc
index a548bda53e2..5379ec2c9eb 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -16,7 +16,7 @@
#include "sql_priv.h"
#include "unireg.h"
#include "sql_parse.h" // check_access
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_mysql_tables
#include "sql_show.h" // append_definer
#include "events.h"
#include "sql_db.h" // check_db_dir_existence
@@ -754,7 +754,6 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
{
char *db= NULL;
int ret;
- Open_tables_backup open_tables_backup;
DBUG_ENTER("Events::fill_schema_events");
if (check_if_system_tables_error())
@@ -773,15 +772,7 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
DBUG_RETURN(1);
db= thd->lex->select_lex.db;
}
- /*
- Reset and backup of the currently open tables in this thread
- is a way to allow SELECTs from INFORMATION_SCHEMA.events under
- LOCK TABLES and in pre-locked mode. See also
- Events::show_create_event for additional comments.
- */
- thd->reset_n_backup_open_tables_state(&open_tables_backup);
ret= db_repository->fill_schema_events(thd, tables, db);
- thd->restore_backup_open_tables_state(&open_tables_backup);
DBUG_RETURN(ret);
}
@@ -1161,8 +1152,7 @@ Events::load_events_from_db(THD *thd)
end:
end_read_record(&read_record_info);
- close_thread_tables(thd);
-
+ close_mysql_tables(thd);
DBUG_RETURN(ret);
}
diff --git a/sql/field.cc b/sql/field.cc
index 287698f5652..3c93ffadac5 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1277,61 +1277,6 @@ int Field::warn_if_overflow(int op_result)
}
-#ifdef NOT_USED
-static bool test_if_real(const char *str,int length, CHARSET_INFO *cs)
-{
- cs= system_charset_info; // QQ move test_if_real into CHARSET_INFO struct
-
- while (length && my_isspace(cs,*str))
- { // Allow start space
- length--; str++;
- }
- if (!length)
- return 0;
- if (*str == '+' || *str == '-')
- {
- length--; str++;
- if (!length || !(my_isdigit(cs,*str) || *str == '.'))
- return 0;
- }
- while (length && my_isdigit(cs,*str))
- {
- length--; str++;
- }
- if (!length)
- return 1;
- if (*str == '.')
- {
- length--; str++;
- while (length && my_isdigit(cs,*str))
- {
- length--; str++;
- }
- }
- if (!length)
- return 1;
- if (*str == 'E' || *str == 'e')
- {
- if (length < 3 || (str[1] != '+' && str[1] != '-') ||
- !my_isdigit(cs,str[2]))
- return 0;
- length-=3;
- str+=3;
- while (length && my_isdigit(cs,*str))
- {
- length--; str++;
- }
- }
- for (; length ; length--, str++)
- { // Allow end space
- if (!my_isspace(cs,*str))
- return 0;
- }
- return 1;
-}
-#endif
-
-
/**
Interpret field value as an integer but return the result as a string.
@@ -4198,7 +4143,7 @@ int Field_float::store(double nr)
}
else
#endif
- memcpy_fixed(ptr,(uchar*) &j,sizeof(j));
+ memcpy(ptr, &j, sizeof(j));
return error;
}
@@ -4221,7 +4166,7 @@ double Field_float::val_real(void)
}
else
#endif
- memcpy_fixed((uchar*) &j,ptr,sizeof(j));
+ memcpy(&j, ptr, sizeof(j));
return ((double) j);
}
@@ -4235,7 +4180,7 @@ longlong Field_float::val_int(void)
}
else
#endif
- memcpy_fixed((uchar*) &j,ptr,sizeof(j));
+ memcpy(&j, ptr, sizeof(j));
return (longlong) rint(j);
}
@@ -4252,7 +4197,7 @@ String *Field_float::val_str(String *val_buffer,
}
else
#endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
+ memcpy(&nr, ptr, sizeof(nr));
uint to_length=max(field_length,70);
val_buffer->alloc(to_length);
@@ -4290,8 +4235,8 @@ int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr)
else
#endif
{
- memcpy_fixed(&a,a_ptr,sizeof(float));
- memcpy_fixed(&b,b_ptr,sizeof(float));
+ memcpy(&a, a_ptr, sizeof(float));
+ memcpy(&b, b_ptr, sizeof(float));
}
return (a < b) ? -1 : (a > b) ? 1 : 0;
}
@@ -4308,7 +4253,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused)))
}
else
#endif
- memcpy_fixed(&nr,ptr,sizeof(float));
+ memcpy(&nr, ptr, sizeof(float));
uchar *tmp= to;
if (nr == (float) 0.0)
@@ -4319,7 +4264,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused)))
else
{
#ifdef WORDS_BIGENDIAN
- memcpy_fixed(tmp,&nr,sizeof(nr));
+ memcpy(tmp, &nr, sizeof(nr));
#else
tmp[0]= ptr[3]; tmp[1]=ptr[2]; tmp[2]= ptr[1]; tmp[3]=ptr[0];
#endif
@@ -7495,7 +7440,7 @@ double Field_blob::val_real(void)
uint32 length;
CHARSET_INFO *cs;
- memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
+ memcpy(&blob, ptr+packlength, sizeof(char*));
if (!blob)
return 0.0;
length= get_length(ptr);
@@ -7509,7 +7454,7 @@ longlong Field_blob::val_int(void)
ASSERT_COLUMN_MARKED_FOR_READ;
int not_used;
char *blob;
- memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
+ memcpy(&blob, ptr+packlength, sizeof(char*));
if (!blob)
return 0;
uint32 length=get_length(ptr);
@@ -7521,7 +7466,7 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
{
ASSERT_COLUMN_MARKED_FOR_READ;
char *blob;
- memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
+ memcpy(&blob, ptr+packlength, sizeof(char*));
if (!blob)
val_ptr->set("",0,charset()); // A bit safer than ->length(0)
else
@@ -7535,7 +7480,7 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value)
ASSERT_COLUMN_MARKED_FOR_READ;
const char *blob;
size_t length;
- memcpy_fixed(&blob, ptr+packlength, sizeof(const uchar*));
+ memcpy(&blob, ptr+packlength, sizeof(const uchar*));
if (!blob)
{
blob= "";
@@ -7563,8 +7508,8 @@ int Field_blob::cmp_max(const uchar *a_ptr, const uchar *b_ptr,
uint max_length)
{
uchar *blob1,*blob2;
- memcpy_fixed(&blob1,a_ptr+packlength,sizeof(char*));
- memcpy_fixed(&blob2,b_ptr+packlength,sizeof(char*));
+ memcpy(&blob1, a_ptr+packlength, sizeof(char*));
+ memcpy(&blob2, b_ptr+packlength, sizeof(char*));
uint a_len= get_length(a_ptr), b_len= get_length(b_ptr);
set_if_smaller(a_len, max_length);
set_if_smaller(b_len, max_length);
@@ -7578,8 +7523,8 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr,
char *a,*b;
uint diff;
uint32 a_length,b_length;
- memcpy_fixed(&a,a_ptr+packlength,sizeof(char*));
- memcpy_fixed(&b,b_ptr+packlength,sizeof(char*));
+ memcpy(&a, a_ptr+packlength, sizeof(char*));
+ memcpy(&b, b_ptr+packlength, sizeof(char*));
a_length=get_length(a_ptr);
if (a_length > max_length)
a_length=max_length;
@@ -7660,7 +7605,7 @@ int Field_blob::key_cmp(const uchar *key_ptr, uint max_key_length)
{
uchar *blob1;
uint blob_length=get_length(ptr);
- memcpy_fixed(&blob1,ptr+packlength,sizeof(char*));
+ memcpy(&blob1, ptr+packlength, sizeof(char*));
CHARSET_INFO *cs= charset();
uint local_char_length= max_key_length / cs->mbmaxlen;
local_char_length= my_charpos(cs, blob1, blob1+blob_length,
@@ -7738,7 +7683,7 @@ void Field_blob::sort_string(uchar *to,uint length)
break;
}
}
- memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
+ memcpy(&blob, ptr+packlength, sizeof(char*));
blob_length=my_strnxfrm(field_charset,
to, length, blob, blob_length);
@@ -8707,7 +8652,7 @@ String *Field_bit::val_str(String *val_buffer,
mi_int8store(buff,bits);
val_buffer->alloc(length);
- memcpy_fixed((char*) val_buffer->ptr(), buff+8-length, length);
+ memcpy((char *) val_buffer->ptr(), buff+8-length, length);
val_buffer->length(length);
val_buffer->set_charset(&my_charset_bin);
return val_buffer;
diff --git a/sql/field.h b/sql/field.h
index 46d8a2aa6d9..7b250c34fe4 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -32,7 +32,6 @@
#include "sql_error.h" /* MYSQL_ERROR */
#define DATETIME_DEC 6
-const uint32 max_field_size= (uint32) 4294967295U;
class Send_field;
class Protocol;
@@ -1763,22 +1762,22 @@ public:
void put_length(uchar *pos, uint32 length);
inline void get_ptr(uchar **str)
{
- memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
+ memcpy(str, ptr+packlength, sizeof(uchar*));
}
inline void get_ptr(uchar **str, uint row_offset)
{
- memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*));
+ memcpy(str, ptr+packlength+row_offset, sizeof(char*));
}
inline void set_ptr(uchar *length, uchar *data)
{
memcpy(ptr,length,packlength);
- memcpy_fixed(ptr+packlength,&data,sizeof(char*));
+ memcpy(ptr+packlength, &data,sizeof(char*));
}
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
{
uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
store_length(ptr_ofs, packlength, length);
- memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*));
+ memcpy(ptr_ofs+packlength, &data, sizeof(char*));
}
inline void set_ptr(uint32 length, uchar *data)
{
@@ -1797,7 +1796,7 @@ public:
return 1;
}
tmp=(uchar*) value.ptr();
- memcpy_fixed(ptr+packlength,&tmp,sizeof(char*));
+ memcpy(ptr+packlength, &tmp, sizeof(char*));
return 0;
}
virtual uchar *pack(uchar *to, const uchar *from,
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 299865e6114..ea6ff82e0aa 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -286,7 +286,7 @@ static void do_copy_blob(Copy_field *copy)
{
ulong length=((Field_blob*) copy->from_field)->get_length();
((Field_blob*) copy->to_field)->store_length(length);
- memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*));
+ memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*));
}
static void do_conv_blob(Copy_field *copy)
diff --git a/sql/filesort.cc b/sql/filesort.cc
index b98a7f780f4..419f18263cc 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -1665,7 +1665,7 @@ void change_double_for_sort(double nr,uchar *to)
else
{
#ifdef WORDS_BIGENDIAN
- memcpy_fixed(tmp,&nr,sizeof(nr));
+ memcpy(tmp, &nr, sizeof(nr));
#else
{
uchar *ptr= (uchar*) &nr;
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 5a0904f87b9..a9c03f7e2a7 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -77,33 +77,12 @@ So, we can read full search-structure as 32-bit word
*/
#define NO_YACC_SYMBOLS
-#include "my_global.h"
-#include "my_sys.h"
-#include "m_string.h"
-#ifndef __GNU_LIBRARY__
-#define __GNU_LIBRARY__ // Skip warnings in getopt.h
-#endif
-#include <my_getopt.h>
+#include <my_global.h>
#include "mysql_version.h"
#include "lex.h"
-
-const char *default_dbug_option="d:t:o,/tmp/gen_lex_hash.trace";
-
-struct my_option my_long_options[] =
-{
-#ifdef DBUG_OFF
- {"debug", '#', "This is a non-debug version. Catch this and exit",
- 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
-#else
- {"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
- (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
-#endif
- {"help", '?', "Display help and exit",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"version", 'V', "Output version information and exit",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
-};
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
struct hash_lex_struct
{
@@ -340,57 +319,6 @@ void print_find_structs()
}
-static void usage(int version)
-{
- printf("%s Ver 3.6 Distrib %s, for %s (%s)\n",
- my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
- if (version)
- return;
- puts("Copyright (C) 2001 MySQL AB, by VVA and Monty");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL license\n");
- puts("This program generates a perfect hashing function for the sql_lex.cc");
- printf("Usage: %s [OPTIONS]\n\n", my_progname);
- my_print_help(my_long_options);
-}
-
-
-extern "C" my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)))
-{
- switch(optid) {
- case 'V':
- usage(1);
- exit(0);
- case 'I':
- case '?':
- usage(0);
- exit(0);
- case '#':
- DBUG_PUSH(argument ? argument : default_dbug_option);
- break;
- }
- return 0;
-}
-
-
-static int get_options(int argc, char **argv)
-{
- int ho_error;
-
- if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option)))
- exit(ho_error);
-
- if (argc >= 1)
- {
- usage(0);
- exit(1);
- }
- return(0);
-}
-
-
int check_dup_symbols(SYMBOL *s1, SYMBOL *s2)
{
if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length))
@@ -441,11 +369,7 @@ int check_duplicates()
int main(int argc,char **argv)
{
- MY_INIT(argv[0]);
- DBUG_PROCESS(argv[0]);
- if (get_options(argc,(char **) argv))
- exit(1);
/* Broken up to indicate that it's not advice to you, gentle reader. */
printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
@@ -562,7 +486,6 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
}\n\
}\n"
);
- my_end(0);
exit(0);
}
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index ecf2984a4c0..d4a98265c49 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -36,6 +36,7 @@
#include "discover.h" // readfrm
#include "sql_acl.h" // wild_case_compare
#include "rpl_mi.h"
+#include "transaction.h"
/*
There is an incompatibility between GNU ar and the Solaris linker
@@ -7417,7 +7418,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
FALSE, /* drop_temporary */
FALSE, /* drop_view */
TRUE /* dont_log_query*/);
-
+ trans_commit_implicit(thd); /* Safety, should be unnecessary. */
+ thd->mdl_context.release_transactional_locks();
/* Clear error message that is returned when table is deleted */
thd->clear_error();
}
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index 4f8bb66fcb0..26fdb8e1425 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -36,6 +36,7 @@
#include "lock.h" // MYSQL_LOCK_IGNORE_FLUSH,
// mysql_unlock_tables
#include "sql_parse.h" // mysql_parse
+#include "transaction.h"
#ifdef ndb_dynamite
#undef assert
@@ -298,13 +299,6 @@ static void run_query(THD *thd, char *buf, char *end,
thd_ndb->m_error_code,
(int) thd->is_error(), thd->is_slave_error);
}
-
- /*
- After executing statement we should unlock and close tables open
- by it as well as release meta-data locks obtained by it.
- */
- close_thread_tables(thd);
-
/*
XXX: this code is broken. mysql_parse()/mysql_reset_thd_for_next_command()
can not be called from within a statement, and
@@ -2422,7 +2416,11 @@ int ndb_add_ndb_binlog_index(THD *thd, void *_row)
}
add_ndb_binlog_index_err:
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
ndb_binlog_index= 0;
thd->variables.option_bits= saved_options;
return error;
@@ -3969,7 +3967,9 @@ restart:
{
if (ndb_binlog_index->s->needs_reopen())
{
+ trans_commit_stmt(thd);
close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
ndb_binlog_index= 0;
}
}
@@ -4280,7 +4280,9 @@ restart:
if (do_ndbcluster_binlog_close_connection == BCCC_restart)
{
ndb_binlog_tables_inited= FALSE;
+ trans_commit_stmt(thd);
close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
ndb_binlog_index= 0;
goto restart;
}
@@ -4288,7 +4290,11 @@ err:
sql_print_information("Stopping Cluster Binlog");
DBUG_PRINT("info",("Shutting down cluster binlog thread"));
thd->proc_info= "Shutting down";
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
mysql_mutex_lock(&injector_mutex);
/* don't mess with the injector_ndb anymore from other threads */
injector_thd= 0;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index bd3cd780bc5..7891f658f45 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -64,10 +64,6 @@
#include "debug_sync.h"
static const char *ha_par_ext= ".par";
-#ifdef NOT_USED
-static int free_share(PARTITION_SHARE * share);
-static PARTITION_SHARE *get_share(const char *table_name, TABLE * table);
-#endif
/****************************************************************************
MODULE create/delete handler object
@@ -1129,13 +1125,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
part= i * num_subparts + j;
DBUG_PRINT("info", ("Optimize subpartition %u (%s)",
part, sub_elem->partition_name));
-#ifdef NOT_USED
- if (print_admin_msg(thd, "note", table_share->db.str, table->alias,
- opt_op_name[flag],
- "Start to operate on subpartition %s",
- sub_elem->partition_name))
- DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
-#endif
if ((error= handle_opt_part(thd, check_opt, m_file[part], flag)))
{
/* print a line which partition the error belongs to */
@@ -1162,13 +1151,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
{
DBUG_PRINT("info", ("Optimize partition %u (%s)", i,
part_elem->partition_name));
-#ifdef NOT_USED
- if (print_admin_msg(thd, "note", table_share->db.str, table->alias,
- opt_op_name[flag],
- "Start to operate on partition %s",
- part_elem->partition_name))
- DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
-#endif
if ((error= handle_opt_part(thd, check_opt, m_file[i], flag)))
{
/* print a line which partition the error belongs to */
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index cdbfb2163c7..cfab2dde394 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -143,9 +143,6 @@ private:
Variables for lock structures.
*/
THR_LOCK_DATA lock; /* MySQL lock */
-#ifdef NOT_USED
- PARTITION_SHARE *share; /* Shared lock info */
-#endif
/*
TRUE <=> this object was created with ha_partition::clone and doesn't
diff --git a/sql/handler.cc b/sql/handler.cc
index b42840c7b1b..9893b3cac16 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -190,15 +190,6 @@ plugin_ref ha_lock_engine(THD *thd, const handlerton *hton)
}
-#ifdef NOT_USED
-static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root)
-{
- handlerton *hton= ha_default_handlerton(current_thd);
- return (hton && hton->create) ? hton->create(hton, table, mem_root) : NULL;
-}
-#endif
-
-
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
{
plugin_ref plugin;
@@ -239,10 +230,6 @@ handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
RUN_HOOK(transaction, after_rollback, (thd, FALSE));
switch (database_type) {
-#ifndef NO_HASH
- case DB_TYPE_HASH:
- return ha_resolve_by_legacy_type(thd, DB_TYPE_HASH);
-#endif
case DB_TYPE_MRG_ISAM:
return ha_resolve_by_legacy_type(thd, DB_TYPE_MRG_MYISAM);
default:
@@ -1145,6 +1132,7 @@ int ha_commit_trans(THD *thd, bool all)
if (thd->in_sub_stmt)
{
+ DBUG_ASSERT(0);
/*
Since we don't support nested statement transactions in 5.0,
we can't commit or rollback stmt transactions while we are inside
@@ -1159,7 +1147,6 @@ int ha_commit_trans(THD *thd, bool all)
bail out with error even before ha_commit_trans() call. To be 100% safe
let us throw error in non-debug builds.
*/
- DBUG_ASSERT(0);
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
DBUG_RETURN(2);
}
@@ -1342,6 +1329,7 @@ int ha_rollback_trans(THD *thd, bool all)
if (thd->in_sub_stmt)
{
+ DBUG_ASSERT(0);
/*
If we are inside stored function or trigger we should not commit or
rollback current statement transaction. See comment in ha_commit_trans()
@@ -1349,7 +1337,6 @@ int ha_rollback_trans(THD *thd, bool all)
*/
if (!all)
DBUG_RETURN(0);
- DBUG_ASSERT(0);
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
DBUG_RETURN(1);
}
diff --git a/sql/handler.h b/sql/handler.h
index 96095798d18..cad97c1f751 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -33,10 +33,6 @@
#include <ft_global.h>
#include <keycache.h>
-#ifndef NO_HASH
-#define NO_HASH /* Not yet implemented */
-#endif
-
// the following is for checking tables
#define HA_ADMIN_ALREADY_DONE 1
@@ -846,6 +842,7 @@ struct THD_TRANS
bool modified_non_trans_table;
void reset() { no_2pc= FALSE; modified_non_trans_table= FALSE; }
+ bool is_empty() const { return ha_list == NULL; }
};
diff --git a/sql/hostname.cc b/sql/hostname.cc
index d309efc4196..5311d9ada73 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -126,7 +126,7 @@ static void prepare_hostname_cache_key(const char *ip_string,
DBUG_ASSERT(ip_string_length < HOST_ENTRY_KEY_SIZE);
memset(ip_key, 0, HOST_ENTRY_KEY_SIZE);
- memcpy_fixed(ip_key, ip_string, ip_string_length);
+ memcpy(ip_key, ip_string, ip_string_length);
}
static inline Host_entry *hostname_cache_search(const char *ip_key)
@@ -148,7 +148,7 @@ static bool add_hostname_impl(const char *ip_key, const char *hostname)
char *hostname_copy;
- memcpy_fixed(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE);
+ memcpy(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE);
if (hostname_size)
{
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 2a7c9ac8144..85565b735d4 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4720,8 +4720,6 @@ void Item_func_like::cleanup()
Item_bool_func2::cleanup();
}
-#ifdef USE_REGEX
-
/**
@brief Compile regular expression.
@@ -4873,9 +4871,6 @@ void Item_func_regex::cleanup()
}
-#endif /* USE_REGEX */
-
-
#ifdef LIKE_CMP_TOUPPER
#define likeconv(cs,A) (uchar) (cs)->toupper(A)
#else
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index b20a6892ce2..f9851011563 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -25,6 +25,7 @@
#include "thr_malloc.h" /* sql_calloc */
#include "item_func.h" /* Item_int_func, Item_bool_func */
+#include "my_regex.h"
extern Item_result item_cmp_type(Item_result a,Item_result b);
class Item_bool_func2;
@@ -268,7 +269,7 @@ protected:
my_bool result_for_null_param;
public:
Item_in_optimizer(Item *a, Item_in_subselect *b):
- Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0),
+ Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
save_cache(0), result_for_null_param(UNKNOWN)
{}
bool fix_fields(THD *, Item **);
@@ -1434,9 +1435,6 @@ public:
void cleanup();
};
-#ifdef USE_REGEX
-
-#include "my_regex.h"
class Item_func_regex :public Item_bool_func
{
@@ -1465,23 +1463,6 @@ public:
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
};
-#else
-
-class Item_func_regex :public Item_bool_func
-{
-public:
- Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) {}
- longlong val_int() { return 0;}
- const char *func_name() const { return "regex"; }
-
- virtual inline void print(String *str, enum_query_type query_type)
- {
- print_op(str, query_type);
- }
-};
-
-#endif /* USE_REGEX */
-
typedef class Item COND;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index e046087b16a..d734b55a970 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -49,7 +49,7 @@ void Item_geometry_func::fix_length_and_dec()
{
collation.set(&my_charset_bin);
decimals=0;
- max_length= max_field_size;
+ max_length= (uint32) 4294967295U;
maybe_null= 1;
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 34b09ca6fdc..d8d18fd8ef6 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -184,7 +184,7 @@ public:
void fix_length_and_dec();
uint cols();
- Item* element_index(uint i) { return my_reinterpret_cast(Item*)(row[i]); }
+ Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); }
Item** addr(uint i) { return (Item**)row + i; }
bool check_cols(uint c);
bool null_inside();
diff --git a/sql/lock.cc b/sql/lock.cc
index 0743120ec6b..1a77b576e67 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -313,7 +313,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags)
rc= thr_lock_errno_to_mysql[(int) thr_multi_lock(sql_lock->locks +
sql_lock->lock_count,
sql_lock->lock_count,
- thd->lock_id, timeout)];
+ &thd->lock_info, timeout)];
if (rc)
{
if (sql_lock->table_count)
@@ -627,110 +627,6 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b)
}
-/**
- Find duplicate lock in tables.
-
- Temporary tables are ignored here like they are ignored in
- get_lock_data(). If we allow two opens on temporary tables later,
- both functions should be checked.
-
- @param thd The current thread.
- @param needle The table to check for duplicate lock.
- @param haystack The list of tables to search for the dup lock.
-
- @note
- This is mainly meant for MERGE tables in INSERT ... SELECT
- situations. The 'real', underlying tables can be found only after
- the MERGE tables are opened. This function assumes that the tables are
- already locked.
-
- @retval
- NULL No duplicate lock found.
- @retval
- !NULL First table from 'haystack' that matches a lock on 'needle'.
-*/
-
-TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle,
- TABLE_LIST *haystack)
-{
- MYSQL_LOCK *mylock;
- TABLE **lock_tables;
- TABLE *table;
- TABLE *table2;
- THR_LOCK_DATA **lock_locks;
- THR_LOCK_DATA **table_lock_data;
- THR_LOCK_DATA **end_data;
- THR_LOCK_DATA **lock_data2;
- THR_LOCK_DATA **end_data2;
- DBUG_ENTER("mysql_lock_have_duplicate");
-
- /*
- Table may not be defined for derived or view tables.
- Table may not be part of a lock for delayed operations.
- */
- if (! (table= needle->table) || ! table->lock_count)
- goto end;
-
- /* A temporary table does not have locks. */
- if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
- goto end;
-
- /* Get command lock or LOCK TABLES lock. Maybe empty for INSERT DELAYED. */
- if (! (mylock= thd->lock))
- goto end;
-
- /* If we have less than two tables, we cannot have duplicates. */
- if (mylock->table_count < 2)
- goto end;
-
- lock_locks= mylock->locks;
- lock_tables= mylock->table;
-
- /* Prepare table related variables that don't change in loop. */
- DBUG_ASSERT((table->lock_position < mylock->table_count) &&
- (table == lock_tables[table->lock_position]));
- table_lock_data= lock_locks + table->lock_data_start;
- end_data= table_lock_data + table->lock_count;
-
- for (; haystack; haystack= haystack->next_global)
- {
- if (haystack->placeholder())
- continue;
- table2= haystack->table;
- if (table2->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
- continue;
-
- /* All tables in list must be in lock. */
- DBUG_ASSERT((table2->lock_position < mylock->table_count) &&
- (table2 == lock_tables[table2->lock_position]));
-
- for (lock_data2= lock_locks + table2->lock_data_start,
- end_data2= lock_data2 + table2->lock_count;
- lock_data2 < end_data2;
- lock_data2++)
- {
- THR_LOCK_DATA **lock_data;
- THR_LOCK *lock2= (*lock_data2)->lock;
-
- for (lock_data= table_lock_data;
- lock_data < end_data;
- lock_data++)
- {
- if ((*lock_data)->lock == lock2)
- {
- DBUG_PRINT("info", ("haystack match: '%s'", haystack->table_name));
- DBUG_RETURN(haystack);
- }
- }
- }
- }
-
- end:
- DBUG_PRINT("info", ("no duplicate found"));
- DBUG_RETURN(NULL);
-}
-
-
/** Unlock a set of external. */
static int unlock_external(THD *thd, TABLE **table,uint count)
@@ -851,62 +747,48 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
}
-/*****************************************************************************
- Lock table based on the name.
- This is used when we need total access to a closed, not open table
-*****************************************************************************/
-
/**
- Obtain exclusive metadata locks on the list of tables.
+ Obtain an exclusive metadata lock on a schema name.
- @param thd Thread handle
- @param table_list List of tables to lock
+ @param thd Thread handle.
+ @param db The database name.
- @note This function assumes that no metadata locks were acquired
- before calling it. Also it cannot be called while holding
- LOCK_open mutex. Both these invariants are enforced by asserts
- in MDL_context::acquire_locks().
- @note Initialization of MDL_request members of TABLE_LIST elements
- is a responsibility of the caller.
+ This function cannot be called while holding LOCK_open mutex.
+ To avoid deadlocks, we do not try to obtain exclusive metadata
+ locks in LOCK TABLES mode, since in this mode there may be
+ other metadata locks already taken by the current connection,
+ and we must not wait for MDL locks while holding locks.
- @retval FALSE Success.
- @retval TRUE Failure (OOM or thread was killed).
+ @retval FALSE Success.
+ @retval TRUE Failure: we're in LOCK TABLES mode, or out of memory,
+ or this connection was killed.
*/
-bool lock_table_names(THD *thd, TABLE_LIST *table_list)
+bool lock_schema_name(THD *thd, const char *db)
{
MDL_request_list mdl_requests;
MDL_request global_request;
- TABLE_LIST *lock_table;
+ MDL_request mdl_request;
- global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
+ if (thd->locked_tables_mode)
+ {
+ my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
+ return TRUE;
+ }
- for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
- mdl_requests.push_front(&lock_table->mdl_request);
+ global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
+ mdl_request.init(MDL_key::SCHEMA, db, "", MDL_EXCLUSIVE);
+ mdl_requests.push_front(&mdl_request);
mdl_requests.push_front(&global_request);
if (thd->mdl_context.acquire_locks(&mdl_requests,
thd->variables.lock_wait_timeout))
- return 1;
-
- return 0;
-}
-
-
-/**
- Release all metadata locks previously obtained by lock_table_names().
-
- @param thd Thread handle.
-
- @note Cannot be called while holding LOCK_open mutex.
-*/
+ return TRUE;
-void unlock_table_names(THD *thd)
-{
- DBUG_ENTER("unlock_table_names");
- thd->mdl_context.release_transactional_locks();
- DBUG_VOID_RETURN;
+ DEBUG_SYNC(thd, "after_wait_locked_schema_name");
+ return FALSE;
}
@@ -941,6 +823,7 @@ bool lock_routine_name(THD *thd, bool is_function,
MDL_key::PROCEDURE);
MDL_request_list mdl_requests;
MDL_request global_request;
+ MDL_request schema_request;
MDL_request mdl_request;
if (thd->locked_tables_mode)
@@ -954,9 +837,11 @@ bool lock_routine_name(THD *thd, bool is_function,
DEBUG_SYNC(thd, "before_wait_locked_pname");
global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
+ schema_request.init(MDL_key::SCHEMA, db, "", MDL_INTENTION_EXCLUSIVE);
mdl_request.init(mdl_type, db, name, MDL_EXCLUSIVE);
mdl_requests.push_front(&mdl_request);
+ mdl_requests.push_front(&schema_request);
mdl_requests.push_front(&global_request);
if (thd->mdl_context.acquire_locks(&mdl_requests,
diff --git a/sql/lock.h b/sql/lock.h
index 84c7bce0679..0083dd3ba18 100644
--- a/sql/lock.h
+++ b/sql/lock.h
@@ -60,12 +60,9 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock);
bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b);
-TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle,
- TABLE_LIST *haystack);
void broadcast_refresh(void);
/* Lock based on name */
-bool lock_table_names(THD *thd, TABLE_LIST *table_list);
-void unlock_table_names(THD *thd);
+bool lock_schema_name(THD *thd, const char *db);
/* Lock based on stored routine name */
bool lock_routine_name(THD *thd, bool is_function, const char *db,
const char *name);
diff --git a/sql/log.cc b/sql/log.cc
index 427057a7783..1e4682e4bc3 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -27,7 +27,7 @@
#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */
#include "sql_priv.h"
#include "log.h"
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // open_log_table
#include "sql_repl.h"
#include "sql_delete.h" // mysql_truncate
#include "sql_parse.h" // command_name
diff --git a/sql/log.h b/sql/log.h
index 4a58c3081d8..6e87b6cbade 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -637,7 +637,6 @@ enum enum_binlog_format {
BINLOG_FORMAT_ROW= 2, ///< row-based
BINLOG_FORMAT_UNSPEC=3 ///< thd_binlog_format() returns it when binlog is closed
};
-extern TYPELIB binlog_format_typelib;
int query_error_code(THD *thd, bool not_killed);
uint purge_log_get_error_code(int res);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 5236a2794cf..ea7f4b4b245 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3332,6 +3332,19 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
thd->table_map_for_update= (table_map)table_map_for_update;
thd->set_invoker(&user, &host);
+ /*
+ Flag if we need to rollback the statement transaction on
+ slave if it by chance succeeds.
+ If we expected a non-zero error code and get nothing and,
+ it is a concurrency issue or ignorable issue, effects
+ of the statement should be rolled back.
+ */
+ if (expected_error &&
+ (ignored_error_code(expected_error) ||
+ concurrency_error_code(expected_error)))
+ {
+ thd->variables.option_bits|= OPTION_MASTER_SQL_ERROR;
+ }
/* Execute the query (note that we bypass dispatch_command()) */
Parser_state parser_state;
if (!parser_state.init(thd, thd->query(), thd->query_length()))
@@ -3340,6 +3353,8 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
log_slow_statement(thd);
}
+ thd->variables.option_bits&= ~OPTION_MASTER_SQL_ERROR;
+
/*
Resetting the enable_slow_log thd variable.
@@ -3382,7 +3397,6 @@ START SLAVE; . Query: '%s'", expected_error, thd->query());
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
compare_errors:
-
/*
In the slave thread, we may sometimes execute some DROP / * 40005
TEMPORARY * / TABLE that come from parts of binlogs (likely if we
@@ -3430,26 +3444,8 @@ Default database: '%s'. Query: '%s'",
DBUG_PRINT("info",("error ignored"));
clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
thd->killed= THD::NOT_KILLED;
- /*
- When an error is expected and matches the actual error the
- slave does not report any error and by consequence changes
- on transactional tables are not rolled back in the function
- close_thread_tables(). For that reason, we explicitly roll
- them back here.
- */
- if (expected_error && expected_error == actual_error)
- trans_rollback_stmt(thd);
}
/*
- If we expected a non-zero error code and get nothing and, it is a concurrency
- issue or should be ignored.
- */
- else if (expected_error && !actual_error &&
- (concurrency_error_code(expected_error) ||
- ignored_error_code(expected_error)))
- trans_rollback_stmt(thd);
-
- /*
Other cases: mostly we expected no error and get one.
*/
else if (thd->is_slave_error || thd->is_fatal_error)
@@ -3516,7 +3512,6 @@ end:
thd->set_db(NULL, 0); /* will free the current database */
thd->set_query(NULL, 0);
DBUG_PRINT("info", ("end: query= 0"));
- close_thread_tables(thd);
/*
As a disk space optimization, future masters will not log an event for
LAST_INSERT_ID() if that function returned 0 (and thus they will be able
@@ -3719,6 +3714,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
{
DBUG_ENTER("Start_log_event_v3::do_apply_event");
+ int error= 0;
switch (binlog_version)
{
case 3:
@@ -3731,7 +3727,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
*/
if (created)
{
- close_temporary_tables(thd);
+ error= close_temporary_tables(thd);
cleanup_load_tmpdir();
}
else
@@ -3759,7 +3755,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
Can distinguish, based on the value of 'created': this event was
generated at master startup.
*/
- close_temporary_tables(thd);
+ error= close_temporary_tables(thd);
}
/*
Otherwise, can't distinguish a Start_log_event generated at
@@ -3771,7 +3767,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
/* this case is impossible */
DBUG_RETURN(1);
}
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -4946,7 +4942,22 @@ error:
thd->catalog= 0;
thd->set_db(NULL, 0); /* will free the current database */
thd->set_query(NULL, 0);
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
close_thread_tables(thd);
+ /*
+ - If inside a multi-statement transaction,
+ defer the release of metadata locks until the current
+ transaction is either committed or rolled back. This prevents
+ other statements from modifying the table for the entire
+ duration of this transaction. This provides commit ordering
+ and guarantees serializability across multiple transactions.
+ - If in autocommit mode, or outside a transactional context,
+ automatically release metadata locks of the current statement.
+ */
+ if (! thd->in_multi_stmt_transaction_mode())
+ thd->mdl_context.release_transactional_locks();
DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error",
thd->is_slave_error= 0; thd->is_fatal_error= 1;);
@@ -5531,11 +5542,9 @@ int Xid_log_event::do_apply_event(Relay_log_info const *rli)
/* For a slave Xid_log_event is COMMIT */
general_log_print(thd, COM_QUERY,
"COMMIT /* implicit, from Xid_log_event */");
- if (!(res= trans_commit(thd)))
- {
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
- }
+ res= trans_commit(thd); /* Automatically rolls back on error. */
+ thd->mdl_context.release_transactional_locks();
+
return res;
}
@@ -7610,8 +7619,6 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
We should not honour --slave-skip-errors at this point as we are
having severe errors which should not be skiped.
*/
- mysql_unlock_tables(thd, thd->lock);
- thd->lock= 0;
thd->is_slave_error= 1;
const_cast<Relay_log_info*>(rli)->slave_close_thread_tables(thd);
DBUG_RETURN(ERR_BAD_TABLE_DEF);
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 0426a410d98..ca66799baed 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -284,8 +284,6 @@ public:
public:
/** The key of the object (data) being protected. */
MDL_key key;
- void *cached_object;
- mdl_cached_object_release_hook cached_object_release_hook;
/**
Read-write lock protecting this lock context.
@@ -362,8 +360,6 @@ public:
MDL_lock(const MDL_key *key_arg)
: key(key_arg),
- cached_object(NULL),
- cached_object_release_hook(NULL),
m_ref_usage(0),
m_ref_release(0),
m_is_destroyed(FALSE)
@@ -405,14 +401,15 @@ public:
/**
- An implementation of the global metadata lock. The only locking modes
- which are supported at the moment are SHARED and INTENTION EXCLUSIVE.
+ An implementation of the scoped metadata lock. The only locking modes
+ which are supported at the moment are SHARED and INTENTION EXCLUSIVE
+ and EXCLUSIVE
*/
-class MDL_global_lock : public MDL_lock
+class MDL_scoped_lock : public MDL_lock
{
public:
- MDL_global_lock(const MDL_key *key_arg)
+ MDL_scoped_lock(const MDL_key *key_arg)
: MDL_lock(key_arg)
{ }
@@ -674,9 +671,6 @@ void MDL_map::remove(MDL_lock *lock)
{
uint ref_usage, ref_release;
- if (lock->cached_object)
- (*lock->cached_object_release_hook)(lock->cached_object);
-
/*
Destroy the MDL_lock object, but ensure that anyone that is
holding a reference to the object is not remaining, if so he
@@ -838,7 +832,8 @@ inline MDL_lock *MDL_lock::create(const MDL_key *mdl_key)
switch (mdl_key->mdl_namespace())
{
case MDL_key::GLOBAL:
- return new MDL_global_lock(mdl_key);
+ case MDL_key::SCHEMA:
+ return new MDL_scoped_lock(mdl_key);
default:
return new MDL_object_lock(mdl_key);
}
@@ -886,67 +881,6 @@ uint MDL_ticket::get_deadlock_weight() const
}
-/**
- Helper functions and macros to be used for killable waiting in metadata
- locking subsystem.
-
- @sa THD::enter_cond()/exit_cond()/killed.
-
- @note We can't use THD::enter_cond()/exit_cond()/killed directly here
- since this will make metadata subsystem dependent on THD class
- and thus prevent us from writing unit tests for it. And usage of
- wrapper functions to access THD::killed/enter_cond()/exit_cond()
- will probably introduce too much overhead.
-*/
-
-#define MDL_ENTER_COND(A, B, C, D) \
- mdl_enter_cond(A, B, C, D, __func__, __FILE__, __LINE__)
-
-static inline const char *mdl_enter_cond(THD *thd,
- st_my_thread_var *mysys_var,
- mysql_cond_t *cond,
- mysql_mutex_t *mutex,
- const char *calling_func,
- const char *calling_file,
- const unsigned int calling_line)
-{
- mysql_mutex_assert_owner(mutex);
-
- mysys_var->current_mutex= mutex;
- mysys_var->current_cond= cond;
-
- DEBUG_SYNC(thd, "mdl_enter_cond");
-
- return set_thd_proc_info(thd, "Waiting for table",
- calling_func, calling_file, calling_line);
-}
-
-#define MDL_EXIT_COND(A, B, C, D) \
- mdl_exit_cond(A, B, C, D, __func__, __FILE__, __LINE__)
-
-static inline void mdl_exit_cond(THD *thd,
- st_my_thread_var *mysys_var,
- mysql_mutex_t *mutex,
- const char* old_msg,
- const char *calling_func,
- const char *calling_file,
- const unsigned int calling_line)
-{
- DBUG_ASSERT(mutex == mysys_var->current_mutex);
-
- mysql_mutex_unlock(mutex);
- mysql_mutex_lock(&mysys_var->mutex);
- mysys_var->current_mutex= NULL;
- mysys_var->current_cond= NULL;
- mysql_mutex_unlock(&mysys_var->mutex);
-
- DEBUG_SYNC(thd, "mdl_exit_cond");
-
- (void) set_thd_proc_info(thd, old_msg, calling_func,
- calling_file, calling_line);
-}
-
-
/** Construct an empty wait slot. */
MDL_wait::MDL_wait()
@@ -1026,15 +960,14 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
{
const char *old_msg;
enum_wait_status result;
- st_my_thread_var *mysys_var= my_thread_var;
int wait_result= 0;
mysql_mutex_lock(&m_LOCK_wait_status);
- old_msg= MDL_ENTER_COND(thd, mysys_var, &m_COND_wait_status,
- &m_LOCK_wait_status);
+ old_msg= thd_enter_cond(thd, &m_COND_wait_status, &m_LOCK_wait_status,
+ "Waiting for table");
- while (!m_wait_status && !mysys_var->abort &&
+ while (!m_wait_status && !thd_killed(thd) &&
wait_result != ETIMEDOUT && wait_result != ETIME)
wait_result= mysql_cond_timedwait(&m_COND_wait_status, &m_LOCK_wait_status,
abs_timeout);
@@ -1053,14 +986,14 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
false, which means that the caller intends to restart the
wait.
*/
- if (mysys_var->abort)
+ if (thd_killed(thd))
m_wait_status= KILLED;
else if (set_status_on_timeout)
m_wait_status= TIMEOUT;
}
result= m_wait_status;
- MDL_EXIT_COND(thd, mysys_var, &m_LOCK_wait_status, old_msg);
+ thd_exit_cond(thd, old_msg);
return result;
}
@@ -1181,11 +1114,6 @@ void MDL_lock::reschedule_waiters()
*/
m_waiting.remove_ticket(ticket);
m_granted.add_ticket(ticket);
-
- /* If we are granting an X lock, release the cached object. */
- if (ticket->get_type() == MDL_EXCLUSIVE && cached_object)
- (*cached_object_release_hook)(cached_object);
- cached_object= NULL;
}
/*
If we could not update the wait slot of the waiter,
@@ -1201,61 +1129,66 @@ void MDL_lock::reschedule_waiters()
/**
- Compatibility (or rather "incompatibility") matrices for global metadata
+ Compatibility (or rather "incompatibility") matrices for scoped metadata
lock. Arrays of bitmaps which elements specify which granted/waiting locks
are incompatible with type of lock being requested.
- Here is how types of individual locks are translated to type of global lock:
+ Here is how types of individual locks are translated to type of scoped lock:
----------------+-------------+
Type of request | Correspond. |
- for indiv. lock | global lock |
+ for indiv. lock | scoped lock |
----------------+-------------+
S, SH, SR, SW | IS |
SNW, SNRW, X | IX |
SNW, SNRW -> X | IX (*) |
The first array specifies if particular type of request can be satisfied
- if there is granted global lock of certain type.
+ if there is granted scoped lock of certain type.
- | Type of active |
- Request | global lock |
- type | IS(**) IX S |
- ---------+----------------+
- IS | + + + |
- IX | + + - |
- S | + - + |
+ | Type of active |
+ Request | scoped lock |
+ type | IS(**) IX S X |
+ ---------+------------------+
+ IS | + + + + |
+ IX | + + - - |
+ S | + - + - |
+ X | + - - - |
The second array specifies if particular type of request can be satisfied
- if there is already waiting request for the global lock of certain type.
+ if there is already waiting request for the scoped lock of certain type.
I.e. it specifies what is the priority of different lock types.
- | Pending |
- Request | global lock |
- type | IS(**) IX S |
- ---------+--------------+
- IS | + + + |
- IX | + + - |
- S | + + + |
+ | Pending |
+ Request | scoped lock |
+ type | IS(**) IX S X |
+ ---------+-----------------+
+ IS | + + + + |
+ IX | + + - - |
+ S | + + + - |
+ X | + + + + |
Here: "+" -- means that request can be satisfied
"-" -- means that request can't be satisfied and should wait
- (*) Since for upgradable locks we always take intention exclusive global
+ (*) Since for upgradable locks we always take intention exclusive scoped
lock at the same time when obtaining the shared lock, there is no
need to obtain such lock during the upgrade itself.
- (**) Since intention shared global locks are compatible with all other
+ (**) Since intention shared scoped locks are compatible with all other
type of locks we don't even have any accounting for them.
*/
-const MDL_lock::bitmap_t MDL_global_lock::m_granted_incompatible[MDL_TYPE_END] =
+const MDL_lock::bitmap_t MDL_scoped_lock::m_granted_incompatible[MDL_TYPE_END] =
{
- MDL_BIT(MDL_SHARED), MDL_BIT(MDL_INTENTION_EXCLUSIVE), 0, 0, 0, 0, 0, 0
+ MDL_BIT(MDL_EXCLUSIVE) | MDL_BIT(MDL_SHARED),
+ MDL_BIT(MDL_EXCLUSIVE) | MDL_BIT(MDL_INTENTION_EXCLUSIVE), 0, 0, 0, 0, 0,
+ MDL_BIT(MDL_EXCLUSIVE) | MDL_BIT(MDL_SHARED) | MDL_BIT(MDL_INTENTION_EXCLUSIVE)
};
-const MDL_lock::bitmap_t MDL_global_lock::m_waiting_incompatible[MDL_TYPE_END] =
+const MDL_lock::bitmap_t MDL_scoped_lock::m_waiting_incompatible[MDL_TYPE_END] =
{
- MDL_BIT(MDL_SHARED), 0, 0, 0, 0, 0, 0, 0
+ MDL_BIT(MDL_EXCLUSIVE) | MDL_BIT(MDL_SHARED),
+ MDL_BIT(MDL_EXCLUSIVE), 0, 0, 0, 0, 0, 0
};
@@ -1655,10 +1588,6 @@ MDL_context::try_acquire_lock_impl(MDL_request *mdl_request,
{
lock->m_granted.add_ticket(ticket);
- if (mdl_request->type == MDL_EXCLUSIVE && lock->cached_object)
- (*lock->cached_object_release_hook)(lock->cached_object);
- lock->cached_object= NULL;
-
mysql_prlock_unlock(&lock->m_rwlock);
m_tickets.push_front(ticket);
@@ -1894,7 +1823,7 @@ extern "C" int mdl_request_ptr_cmp(const void* ptr1, const void* ptr2)
@note The list of requests should not contain non-exclusive lock requests.
There should not be any acquired locks in the context.
- @note Assumes that one already owns global intention exclusive lock.
+ @note Assumes that one already owns scoped intention exclusive lock.
@retval FALSE Success
@retval TRUE Failure
@@ -1911,13 +1840,6 @@ bool MDL_context::acquire_locks(MDL_request_list *mdl_requests,
if (req_count == 0)
return FALSE;
- /*
- To reduce deadlocks, the server acquires all exclusive
- locks at once. For shared locks, try_acquire_lock() is
- used instead.
- */
- DBUG_ASSERT(m_tickets.is_empty() || m_tickets.front() == m_trans_sentinel);
-
/* Sort requests according to MDL_key. */
if (! (sort_buf= (MDL_request **)my_malloc(req_count *
sizeof(MDL_request*),
@@ -2434,69 +2356,6 @@ bool MDL_ticket::has_pending_conflicting_lock() const
/**
- Associate pointer to an opaque object with a lock.
-
- @param cached_object Pointer to the object
- @param release_hook Cleanup function to be called when MDL subsystem
- decides to remove lock or associate another object.
-
- This is used to cache a pointer to TABLE_SHARE in the lock
- structure. Such caching can save one acquisition of LOCK_open
- and one table definition cache lookup for every table.
-
- Since the pointer may be stored only inside an acquired lock,
- the caching is only effective when there is more than one lock
- granted on a given table.
-
- This function has the following usage pattern:
- - try to acquire an MDL lock
- - when done, call for mdl_get_cached_object(). If it returns NULL, our
- thread has the only lock on this table.
- - look up TABLE_SHARE in the table definition cache
- - call mdl_set_cache_object() to assign the share to the opaque pointer.
-
- The release hook is invoked when the last shared metadata
- lock on this name is released.
-*/
-
-void
-MDL_ticket::set_cached_object(void *cached_object,
- mdl_cached_object_release_hook release_hook)
-{
- DBUG_ENTER("mdl_set_cached_object");
- DBUG_PRINT("enter", ("db=%s name=%s cached_object=%p",
- m_lock->key.db_name(), m_lock->key.name(),
- cached_object));
- /*
- TODO: This assumption works now since we do get_cached_object()
- and set_cached_object() in the same critical section. Once
- this becomes false we will have to call release_hook here and
- use additional mutex protecting 'cached_object' member.
- */
- DBUG_ASSERT(!m_lock->cached_object);
-
- m_lock->cached_object= cached_object;
- m_lock->cached_object_release_hook= release_hook;
-
- DBUG_VOID_RETURN;
-}
-
-
-/**
- Get a pointer to an opaque object that associated with the lock.
-
- @param ticket Lock ticket for the lock which the object is associated to.
-
- @return Pointer to an opaque object associated with the lock.
-*/
-
-void *MDL_ticket::get_cached_object()
-{
- return m_lock->cached_object;
-}
-
-
-/**
Releases metadata locks that were acquired after a specific savepoint.
@note Used to release tickets acquired during a savepoint unit.
diff --git a/sql/mdl.h b/sql/mdl.h
index 43d88c143c0..c8acd69c0f1 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -40,15 +40,16 @@ class Deadlock_detection_visitor;
Type of metadata lock request.
@sa Comments for MDL_object_lock::can_grant_lock() and
- MDL_global_lock::can_grant_lock() for details.
+ MDL_scoped_lock::can_grant_lock() for details.
*/
enum enum_mdl_type {
/*
- An intention exclusive metadata lock. Used only for global locks.
+ An intention exclusive metadata lock. Used only for scoped locks.
Owner of this type of lock can acquire upgradable exclusive locks on
individual objects.
- Compatible with other IX locks, but is incompatible with global S lock.
+ Compatible with other IX locks, but is incompatible with scoped S and
+ X locks.
*/
MDL_INTENTION_EXCLUSIVE= 0,
/*
@@ -179,6 +180,7 @@ public:
MDL_key is also used outside of the MDL subsystem.
*/
enum enum_mdl_namespace { GLOBAL=0,
+ SCHEMA,
TABLE,
FUNCTION,
PROCEDURE,
@@ -396,9 +398,6 @@ public:
public:
bool has_pending_conflicting_lock() const;
- void *get_cached_object();
- void set_cached_object(void *cached_object,
- mdl_cached_object_release_hook release_hook);
MDL_context *get_ctx() const { return m_ctx; }
bool is_upgradable_or_exclusive() const
{
@@ -646,6 +645,8 @@ private:
closes all open HANDLERs.
However, one can open a few HANDLERs after entering the
read only mode.
+ * LOCK TABLES locks include intention exclusive locks on
+ involved schemas.
*/
Ticket_list m_tickets;
/**
@@ -720,10 +721,10 @@ void mdl_destroy();
extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use,
bool needs_thr_lock_abort);
-extern "C" const char *set_thd_proc_info(void *thd_arg, const char *info,
- const char *calling_function,
- const char *calling_file,
- const unsigned int calling_line);
+extern "C" const char* thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond,
+ mysql_mutex_t *mutex, const char *msg);
+extern "C" void thd_exit_cond(MYSQL_THD thd, const char *old_msg);
+
#ifndef DBUG_OFF
extern mysql_mutex_t LOCK_open;
#endif
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f2cb3533eaf..afc515a9d8c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -27,8 +27,8 @@
// reset_status_vars
#include "strfunc.h" // find_set_from_flags
#include "parse_file.h" // File_parser_dummy_hook
-#include "sql_db.h" // my_database_names_free,
- // my_database_names_init
+#include "sql_db.h" // my_dboptions_cache_free
+ // my_dboptions_cache_init
#include "sql_table.h" // release_ddl_log, execute_ddl_log_recovery
#include "sql_connect.h" // free_max_user_conn, init_max_user_conn,
// handle_one_connection
@@ -294,12 +294,6 @@ arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
-const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS};
-static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 };
-TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
- log_output_names,
- (unsigned int *) log_output_names_len};
-
/* static variables */
#ifdef HAVE_PSI_INTERFACE
@@ -395,8 +389,8 @@ my_bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted
my_bool opt_reckless_slave = 0;
my_bool opt_enable_named_pipe= 0;
my_bool opt_local_infile, opt_slave_compressed_protocol;
-my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
-my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
+my_bool opt_safe_user_create = 0;
+my_bool opt_show_slave_auth_info;
my_bool opt_log_slave_updates= 0;
char *opt_slave_skip_errors;
@@ -440,9 +434,6 @@ my_bool sp_automatic_privileges= 1;
ulong opt_binlog_rows_event_max_size;
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
-TYPELIB binlog_format_typelib=
- { array_elements(binlog_format_names) - 1, "",
- binlog_format_names, NULL };
#ifdef HAVE_INITGROUPS
static bool calling_initgroups= FALSE; /**< Used in SIGSEGV handler. */
#endif
@@ -458,7 +449,7 @@ ulong thread_created;
ulong back_log, connect_timeout, concurrency, server_id;
ulong table_cache_size, table_def_size;
ulong what_to_log;
-ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
+ulong slow_launch_time, slave_open_temp_tables;
ulong open_files_limit, max_binlog_size, max_relay_log_size;
ulong slave_trans_retries;
uint slave_net_timeout;
@@ -547,7 +538,6 @@ char mysql_real_data_home[FN_REFLEN],
mysql_charsets_dir[FN_REFLEN],
*opt_init_file, *opt_tc_log_file;
char *lc_messages_dir_ptr, *log_error_file_ptr;
-char err_shared_dir[FN_REFLEN];
char mysql_unpacked_real_data_home[FN_REFLEN];
int mysql_unpacked_real_data_home_len;
uint mysql_real_data_home_len, mysql_data_home_len= 1;
@@ -581,7 +571,6 @@ Le_creator le_creator;
MYSQL_FILE *bootstrap_file;
int bootstrap_error;
-FILE *stderror_file=0;
I_List<THD> threads;
Rpl_filter* rpl_filter;
@@ -612,8 +601,8 @@ SHOW_COMP_OPTION have_profiling;
pthread_key(MEM_ROOT**,THR_MALLOC);
pthread_key(THD*, THR_THD);
mysql_mutex_t LOCK_thread_count;
-mysql_mutex_t LOCK_mysql_create_db, LOCK_open,
- LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
+mysql_mutex_t LOCK_open,
+ LOCK_status, LOCK_global_read_lock,
LOCK_error_log, LOCK_uuid_generator,
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
LOCK_crypt,
@@ -1431,7 +1420,7 @@ void clean_up(bool print_message)
bitmap_free(&slave_error_mask);
#endif
my_tz_free();
- my_database_names_free();
+ my_dboptions_cache_free();
#ifndef NO_EMBEDDED_ACCESS_CHECKS
servers_free(1);
acl_free(1);
@@ -1476,9 +1465,7 @@ void clean_up(bool print_message)
delete rpl_filter;
end_ssl();
vio_end();
-#ifdef USE_REGEX
my_regex_end();
-#endif
#if defined(ENABLED_DEBUG_SYNC)
/* End the debug sync facility. See debug_sync.cc. */
debug_sync_end();
@@ -1538,12 +1525,9 @@ static void wait_for_signal_thread_to_end()
static void clean_up_mutexes()
{
- mysql_mutex_destroy(&LOCK_mysql_create_db);
- mysql_mutex_destroy(&LOCK_lock_db);
mysql_rwlock_destroy(&LOCK_grant);
mysql_mutex_destroy(&LOCK_open);
mysql_mutex_destroy(&LOCK_thread_count);
- mysql_mutex_destroy(&LOCK_mapped_file);
mysql_mutex_destroy(&LOCK_status);
mysql_mutex_destroy(&LOCK_delayed_insert);
mysql_mutex_destroy(&LOCK_delayed_status);
@@ -1944,7 +1928,7 @@ static void network_init(void)
(void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,
sizeof(arg));
umask(0);
- if (bind(unix_sock, my_reinterpret_cast(struct sockaddr *) (&UNIXaddr),
+ if (bind(unix_sock, reinterpret_cast<struct sockaddr *>(&UNIXaddr),
sizeof(UNIXaddr)) < 0)
{
sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */
@@ -3355,9 +3339,7 @@ static int init_common_variables()
if (item_create_init())
return 1;
item_init();
-#ifdef USE_REGEX
my_regex_init(&my_charset_latin1);
-#endif
/*
Process a comma-separated character set list and choose
the first available character set. This is mostly for
@@ -3461,7 +3443,7 @@ static int init_common_variables()
use_temp_pool= 0;
#endif
- if (my_database_names_init())
+ if (my_dboptions_cache_init())
return 1;
/*
@@ -3518,12 +3500,8 @@ You should consider changing lower_case_table_names to 1 or 2",
static int init_thread_environment()
{
- mysql_mutex_init(key_LOCK_mysql_create_db,
- &LOCK_mysql_create_db, MY_MUTEX_INIT_SLOW);
- mysql_mutex_init(key_LOCK_lock_db, &LOCK_lock_db, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file, MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_delayed_insert,
&LOCK_delayed_insert, MY_MUTEX_INIT_FAST);
@@ -7701,8 +7679,8 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
- key_LOCK_lock_db, key_LOCK_manager, key_LOCK_mapped_file,
- key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
+ key_LOCK_manager,
+ key_LOCK_open, key_LOCK_prepared_stmt_count,
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data,
key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
@@ -7740,10 +7718,7 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_LOCK_gdl, "LOCK_gdl", PSI_FLAG_GLOBAL},
{ &key_LOCK_global_read_lock, "LOCK_global_read_lock", PSI_FLAG_GLOBAL},
{ &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_GLOBAL},
- { &key_LOCK_lock_db, "LOCK_lock_db", PSI_FLAG_GLOBAL},
{ &key_LOCK_manager, "LOCK_manager", PSI_FLAG_GLOBAL},
- { &key_LOCK_mapped_file, "LOCK_mapped_file", PSI_FLAG_GLOBAL},
- { &key_LOCK_mysql_create_db, "LOCK_mysql_create_db", PSI_FLAG_GLOBAL},
{ &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL},
{ &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_GLOBAL},
{ &key_LOCK_rpl_status, "LOCK_rpl_status", PSI_FLAG_GLOBAL},
diff --git a/sql/mysqld.h b/sql/mysqld.h
index e14cd15ceb8..22e757e6e8a 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -78,9 +78,6 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset;
-extern TYPELIB log_output_typelib;
-extern const char *log_output_names[];
-
/**
Character set of the buildin error messages loaded from errmsg.sys.
*/
@@ -105,7 +102,7 @@ extern bool volatile abort_loop;
extern bool in_bootstrap;
extern uint volatile thread_count, global_read_lock;
extern uint connection_count;
-extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
+extern my_bool opt_safe_user_create;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern uint slave_exec_mode_options;
@@ -173,7 +170,6 @@ extern ulong slave_trans_retries;
extern uint slave_net_timeout;
extern uint max_user_connections;
extern ulong what_to_log,flush_time;
-extern ulong query_buff_size;
extern ulong max_prepared_stmt_count, prepared_stmt_count;
extern ulong binlog_cache_size, open_files_limit;
extern ulonglong max_binlog_cache_size;
@@ -210,9 +206,7 @@ extern MYSQL_FILE *bootstrap_file;
extern my_bool old_mode;
extern LEX_STRING opt_init_connect, opt_init_slave;
extern int bootstrap_error;
-extern FILE *stderror_file;
extern I_List<THD> threads;
-extern char err_shared_dir[];
extern scheduler_functions thread_scheduler;
extern TYPELIB thread_handling_typelib;
extern my_decimal decimal_zero;
@@ -234,8 +228,8 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
- key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file,
- key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
+ key_LOCK_logger, key_LOCK_manager,
+ key_LOCK_open, key_LOCK_prepared_stmt_count,
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
key_LOCK_table_share, key_LOCK_thd_data,
key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
@@ -313,7 +307,6 @@ extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
extern char mysql_unpacked_real_data_home[];
extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
extern char default_logfile_name[FN_REFLEN];
-extern char err_shared_dir[];
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
@@ -323,8 +316,8 @@ extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded
/*
Server mutex locks and condition variables.
*/
-extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
- LOCK_mapped_file, LOCK_user_locks, LOCK_status,
+extern mysql_mutex_t LOCK_open,
+ LOCK_user_locks, LOCK_status,
LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc
index 76dc2846ed0..1f1b7f0c20f 100644
--- a/sql/nt_servc.cc
+++ b/sql/nt_servc.cc
@@ -375,29 +375,6 @@ void NTService::ServiceCtrlHandler(DWORD ctrlCode)
dwState=pService->dwState; // get current state
switch(ctrlCode) {
-
-#ifdef NOT_USED /* do we need this ? */
- case SERVICE_CONTROL_PAUSE:
- if (pService->bRunning && ! pService->bPause)
- {
- dwState = SERVICE_PAUSED;
- pService->SetStatus(SERVICE_PAUSE_PENDING,NO_ERROR, 0, 1,
- pService->nPauseTimeOut);
- pService->PauseService();
- }
- break;
-
- case SERVICE_CONTROL_CONTINUE:
- if (pService->bRunning && pService->bPause)
- {
- dwState = SERVICE_RUNNING;
- pService->SetStatus(SERVICE_CONTINUE_PENDING,NO_ERROR, 0, 1,
- pService->nResumeTimeOut);
- pService->ResumeService();
- }
- break;
-#endif
-
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
dwState = SERVICE_STOP_PENDING;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 6b7ab87aa62..953656d3a4f 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -795,31 +795,14 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
local_packet->realloc(local_packet->length()+10))
goto err;
pos= (char*) local_packet->ptr()+local_packet->length();
-
-#ifdef TO_BE_DELETED_IN_6
- if (!(thd->client_capabilities & CLIENT_LONG_FLAG))
- {
- pos[0]=3;
- int3store(pos+1,field.length);
- pos[4]=1;
- pos[5]=field.type;
- pos[6]=2;
- pos[7]= (char) field.flags;
- pos[8]= (char) field.decimals;
- pos+= 9;
- }
- else
-#endif
- {
- pos[0]=3;
- int3store(pos+1,field.length);
- pos[4]=1;
- pos[5]=field.type;
- pos[6]=3;
- int2store(pos+7,field.flags);
- pos[9]= (char) field.decimals;
- pos+= 10;
- }
+ pos[0]=3;
+ int3store(pos+1,field.length);
+ pos[4]=1;
+ pos[5]=field.type;
+ pos[6]=3;
+ int2store(pos+7,field.flags);
+ pos[9]= (char) field.decimals;
+ pos+= 10;
}
local_packet->length((uint) (pos - local_packet->ptr()));
if (flags & SEND_DEFAULTS)
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 9a1f7fb826b..47eb2f7031d 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -55,9 +55,6 @@ const char* rpl_status_type[]=
"AUTH_MASTER","IDLE_SLAVE","ACTIVE_SLAVE","LOST_SOLDIER","TROOP_SOLDIER",
"RECOVERY_CAPTAIN","NULL",NullS
};
-TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"",
- rpl_status_type, NULL};
-
static Slave_log_event* find_slave_event(IO_CACHE* log,
const char* log_file_name,
@@ -71,42 +68,6 @@ static Slave_log_event* find_slave_event(IO_CACHE* log,
functions like register_slave()) are working.
*/
-#if NOT_USED
-static int init_failsafe_rpl_thread(THD* thd)
-{
- DBUG_ENTER("init_failsafe_rpl_thread");
- thd->system_thread = SYSTEM_THREAD_DELAYED_INSERT;
- /*
- thd->bootstrap is to report errors barely to stderr; if this code is
- enable again one day, one should check if bootstrap is still needed (maybe
- this thread has no other error reporting method).
- */
- thd->bootstrap = 1;
- thd->security_ctx->skip_grants();
- my_net_init(&thd->net, 0);
- thd->net.read_timeout = slave_net_timeout;
- thd->max_client_packet_length=thd->net.max_packet;
- mysql_mutex_lock(&LOCK_thread_count);
- thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
- mysql_mutex_unlock(&LOCK_thread_count);
-
- if (init_thr_lock() || thd->store_globals())
- {
- /* purecov: begin inspected */
- close_connection(thd, ER_OUT_OF_RESOURCES, 1); // is this needed?
- statistic_increment(aborted_connects,&LOCK_status);
- one_thread_per_connection_end(thd,0);
- DBUG_RETURN(-1);
- /* purecov: end */
- }
-
- thd->mem_root->free= thd->mem_root->used= 0;
- thd_proc_info(thd, "Thread initialized");
- thd->set_time();
- DBUG_RETURN(0);
-}
-#endif
-
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
{
mysql_mutex_lock(&LOCK_rpl_status);
@@ -623,66 +584,6 @@ err:
}
-#if NOT_USED
-int find_recovery_captain(THD* thd, MYSQL* mysql)
-{
- return 0;
-}
-#endif
-
-#if NOT_USED
-pthread_handler_t handle_failsafe_rpl(void *arg)
-{
- DBUG_ENTER("handle_failsafe_rpl");
- THD *thd = new THD;
- thd->thread_stack = (char*)&thd;
- MYSQL* recovery_captain = 0;
- const char* msg;
-
- pthread_detach_this_thread();
- if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mysql_init(0)))
- {
- sql_print_error("Could not initialize failsafe replication thread");
- goto err;
- }
- mysql_mutex_lock(&LOCK_rpl_status);
- msg= thd->enter_cond(&COND_rpl_status,
- &LOCK_rpl_status, "Waiting for request");
- while (!thd->killed && !abort_loop)
- {
- bool break_req_chain = 0;
- mysql_cond_wait(&COND_rpl_status, &LOCK_rpl_status);
- thd_proc_info(thd, "Processing request");
- while (!break_req_chain)
- {
- switch (rpl_status) {
- case RPL_LOST_SOLDIER:
- if (find_recovery_captain(thd, recovery_captain))
- rpl_status=RPL_TROOP_SOLDIER;
- else
- rpl_status=RPL_RECOVERY_CAPTAIN;
- break_req_chain=1; /* for now until other states are implemented */
- break;
- default:
- break_req_chain=1;
- break;
- }
- }
- }
- thd->exit_cond(msg);
-err:
- if (recovery_captain)
- mysql_close(recovery_captain);
- delete thd;
-
- DBUG_LEAVE; // Must match DBUG_ENTER()
- my_thread_end();
- pthread_exit(0);
- return 0; // Avoid compiler warnings
-}
-#endif
-
-
/**
Execute a SHOW SLAVE HOSTS statement.
diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h
index 94b151aaee7..c6d00de47cb 100644
--- a/sql/repl_failsafe.h
+++ b/sql/repl_failsafe.h
@@ -30,7 +30,7 @@ extern RPL_STATUS rpl_status;
extern mysql_mutex_t LOCK_rpl_status;
extern mysql_cond_t COND_rpl_status;
-extern TYPELIB rpl_role_typelib, rpl_status_typelib;
+extern TYPELIB rpl_role_typelib;
extern const char* rpl_role_type[], *rpl_status_type[];
pthread_handler_t handle_failsafe_rpl(void *arg);
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index ced5c0943dd..8219f70727e 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -238,7 +238,8 @@ unpack_row(Relay_log_info const *rli,
conv_field ? conv_field : *field_ptr;
DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)",
conv_field ? "" : "not ",
- (*field_ptr)->field_name, field_ptr - begin_ptr));
+ (*field_ptr)->field_name,
+ (long) (field_ptr - begin_ptr)));
DBUG_ASSERT(f != NULL);
/*
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 03c369394bf..af9b452acd8 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1257,7 +1257,23 @@ void Relay_log_info::clear_tables_to_lock()
void Relay_log_info::slave_close_thread_tables(THD *thd)
{
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
+
close_thread_tables(thd);
+ /*
+ - If inside a multi-statement transaction,
+ defer the release of metadata locks until the current
+ transaction is either committed or rolled back. This prevents
+ other statements from modifying the table for the entire
+ duration of this transaction. This provides commit ordering
+ and guarantees serializability across multiple transactions.
+ - If in autocommit mode, or outside a transactional context,
+ automatically release metadata locks of the current statement.
+ */
+ if (! thd->in_multi_stmt_transaction_mode())
+ thd->mdl_context.release_transactional_locks();
clear_tables_to_lock();
}
#endif
diff --git a/sql/set_var.cc b/sql/set_var.cc
index ec9c09f02a3..9daaf883ea8 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -27,7 +27,6 @@
#include "mysqld.h" // lc_messages_dir
#include "sys_vars_shared.h"
#include "transaction.h"
-#include "sql_base.h" // close_thread_tables
#include "sql_locale.h" // my_locale_by_number,
// my_locale_by_name
#include "strfunc.h" // find_set_from_flags, find_set
diff --git a/sql/set_var.h b/sql/set_var.h
index 1b415567659..5f1f889c4ce 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -169,7 +169,6 @@ protected:
{ return ((uchar*)&global_system_variables) + offset; }
};
-#include "log.h" /* binlog_format_typelib */
#include "sql_plugin.h" /* SHOW_HA_ROWS, SHOW_MY_BOOL */
/****************************************************************************
diff --git a/sql/slave.cc b/sql/slave.cc
index 6caa04359a8..dff6b6946d4 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -83,7 +83,6 @@ ulonglong relay_log_space_limit = 0;
*/
int disconnect_slave_event_count = 0, abort_slave_event_count = 0;
-int events_till_abort = -1;
static pthread_key(Master_info*, RPL_MASTER_INFO);
@@ -798,17 +797,6 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
}
-#ifdef NOT_USED_YET
-static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/)
-{
- DBUG_ENTER("end_slave_on_walk");
-
- end_master_info(mi);
- DBUG_RETURN(0);
-}
-#endif
-
-
/*
Release slave threads at time of executing shutdown.
@@ -3044,7 +3032,6 @@ err:
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
DBUG_ASSERT(thd->net.buff != 0);
net_end(&thd->net); // destructor will not free it, because net.vio is 0
- close_thread_tables(thd);
mysql_mutex_lock(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
delete thd;
diff --git a/sql/sp.cc b/sql/sp.cc
index 5328471f4c0..0265ef45a2a 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -450,10 +450,7 @@ static TABLE *open_proc_table_for_update(THD *thd)
if (!proc_table_intact.check(table, &proc_table_def))
DBUG_RETURN(table);
- close_thread_tables(thd);
-
DBUG_RETURN(NULL);
-
}
@@ -856,6 +853,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
}
end:
+ thd->lex->sphead= NULL;
lex_end(thd->lex);
thd->lex= old_lex;
return ret;
@@ -1159,8 +1157,6 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
done:
thd->count_cuted_fields= saved_count_cuted_fields;
thd->variables.sql_mode= saved_mode;
-
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -1239,8 +1235,6 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
sp_cache_flush_obsolete(spc, &sp);
}
}
-
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -1348,7 +1342,6 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
sp_cache_invalidate();
}
err:
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -1370,6 +1363,7 @@ sp_drop_db_routines(THD *thd, char *db)
TABLE *table;
int ret;
uint key_len;
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("sp_drop_db_routines");
DBUG_PRINT("enter", ("db: %s", db));
@@ -1410,6 +1404,11 @@ sp_drop_db_routines(THD *thd, char *db)
table->file->ha_index_end();
close_thread_tables(thd);
+ /*
+ Make sure to only release the MDL lock on mysql.proc, not other
+ metadata locks DROP DATABASE might have acquired.
+ */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
err:
DBUG_RETURN(ret);
@@ -2142,6 +2141,7 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
newlex.current_select= NULL;
sp= sp_compile(thd, &defstr, sql_mode, creation_ctx);
*free_sp_head= 1;
+ thd->lex->sphead= NULL;
lex_end(thd->lex);
thd->lex= old_lex;
return sp;
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index f75acf11984..2d3a32c7f7f 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -38,6 +38,7 @@
#include "set_var.h"
#include "sql_parse.h" // cleanup_items
#include "sql_base.h" // close_thread_tables
+#include "transaction.h" // trans_commit_stmt
/*
Sufficient max length of printed destinations and frame offsets (all uints).
@@ -795,6 +796,7 @@ sp_head::~sp_head()
while ((lex= (LEX *)m_lex.pop()))
{
THD *thd= lex->thd;
+ thd->lex->sphead= NULL;
lex_end(thd->lex);
delete thd->lex;
thd->lex= lex;
@@ -1074,6 +1076,104 @@ void sp_head::recursion_level_error(THD *thd)
/**
+ Find an SQL handler for any condition (warning or error) after execution
+ of a stored routine instruction. Basically, this function looks for an
+ appropriate SQL handler in RT-contexts. If an SQL handler is found, it is
+ remembered in the RT-context for future activation (the context can be
+ inactive at the moment).
+
+ If there is no pending condition, the function just returns.
+
+ If there was an error during the execution, an SQL handler for it will be
+ searched within the current and outer scopes.
+
+ There might be several errors in the Warning Info (that's possible by using
+ SIGNAL/RESIGNAL in nested scopes) -- the function is looking for an SQL
+ handler for the latest (current) error only.
+
+ If there was a warning during the execution, an SQL handler for it will be
+ searched within the current scope only.
+
+ If several warnings were thrown during the execution and there are different
+ SQL handlers for them, it is not determined which SQL handler will be chosen.
+ Only one SQL handler will be executed.
+
+ If warnings and errors were thrown during the execution, the error takes
+ precedence. I.e. error handler will be executed. If there is no handler
+ for that error, condition will remain unhandled.
+
+ Once a warning or an error has been handled it is not removed from
+ Warning Info.
+
+ According to The Standard (quoting PeterG):
+
+ An SQL procedure statement works like this ...
+ SQL/Foundation 13.5 <SQL procedure statement>
+ (General Rules) (greatly summarized) says:
+ (1) Empty diagnostics area, thus clearing the condition.
+ (2) Execute statement.
+ During execution, if Exception Condition occurs,
+ set Condition Area = Exception Condition and stop
+ statement.
+ During execution, if No Data occurs,
+ set Condition Area = No Data Condition and continue
+ statement.
+ During execution, if Warning occurs,
+ and Condition Area is not already full due to
+ an earlier No Data condition, set Condition Area
+ = Warning and continue statement.
+ (3) Finish statement.
+ At end of execution, if Condition Area is not
+ already full due to an earlier No Data or Warning,
+ set Condition Area = Successful Completion.
+ In effect, this system means there is a precedence:
+ Exception trumps No Data, No Data trumps Warning,
+ Warning trumps Successful Completion.
+
+ NB: "Procedure statements" include any DDL or DML or
+ control statements. So CREATE and DELETE and WHILE
+ and CALL and RETURN are procedure statements. But
+ DECLARE and END are not procedure statements.
+
+ @param thd thread handle
+ @param ctx runtime context of the stored routine
+*/
+
+static void
+find_handler_after_execution(THD *thd, sp_rcontext *ctx)
+{
+ if (thd->is_error())
+ {
+ ctx->find_handler(thd,
+ thd->stmt_da->sql_errno(),
+ thd->stmt_da->get_sqlstate(),
+ MYSQL_ERROR::WARN_LEVEL_ERROR,
+ thd->stmt_da->message());
+ }
+ else if (thd->warning_info->statement_warn_count())
+ {
+ List_iterator<MYSQL_ERROR> it(thd->warning_info->warn_list());
+ MYSQL_ERROR *err;
+ while ((err= it++))
+ {
+ if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_WARN &&
+ err->get_level() != MYSQL_ERROR::WARN_LEVEL_NOTE)
+ continue;
+
+ if (ctx->find_handler(thd,
+ err->get_sql_errno(),
+ err->get_sqlstate(),
+ err->get_level(),
+ err->get_message_text()))
+ {
+ break;
+ }
+ }
+ }
+}
+
+
+/**
Execute the routine. The main instruction jump loop is there.
Assume the parameters already set.
@todo
@@ -1094,7 +1194,7 @@ sp_head::execute(THD *thd)
LEX_STRING saved_cur_db_name=
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
bool cur_db_changed= FALSE;
- sp_rcontext *ctx;
+ sp_rcontext *ctx= thd->spcont;
bool err_status= FALSE;
uint ip= 0;
ulong save_sql_mode;
@@ -1155,8 +1255,6 @@ sp_head::execute(THD *thd)
goto done;
}
- if ((ctx= thd->spcont))
- ctx->clear_handler();
thd->is_slave_error= 0;
old_arena= thd->stmt_arena;
@@ -1241,7 +1339,6 @@ sp_head::execute(THD *thd)
do
{
sp_instr *i;
- uint hip;
#if defined(ENABLED_PROFILING)
/*
@@ -1263,6 +1360,9 @@ sp_head::execute(THD *thd)
break;
}
+ /* Reset number of warnings for this query. */
+ thd->warning_info->reset_for_next_command();
+
DBUG_PRINT("execute", ("Instruction %u", ip));
/*
@@ -1307,40 +1407,28 @@ sp_head::execute(THD *thd)
free_root(&execute_mem_root, MYF(0));
/*
- Check if an exception has occurred and a handler has been found
- Note: We have to check even if err_status == FALSE, since warnings (and
- some errors) don't return a non-zero value. We also have to check even
- if thd->killed != 0, since some errors return with this even when a
- handler has been found (e.g. "bad data").
+ Find and process SQL handlers unless it is a fatal error (fatal
+ errors are not catchable by SQL handlers) or the connection has been
+ killed during execution.
*/
- if (ctx)
+ if (!thd->is_fatal_error && !thd->killed_errno())
{
- uint handler_index;
+ /*
+ Find SQL handler in the appropriate RT-contexts:
+ - warnings can be handled by SQL handlers within
+ the current scope only;
+ - errors can be handled by any SQL handler from outer scope.
+ */
+ find_handler_after_execution(thd, ctx);
- switch (ctx->found_handler(& hip, & handler_index)) {
- case SP_HANDLER_NONE:
- break;
- case SP_HANDLER_CONTINUE:
- thd->restore_active_arena(&execute_arena, &backup_arena);
- thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
- ctx->push_hstack(i->get_cont_dest());
- /* Fall through */
- default:
- if (ctx->end_partial_result_set)
- thd->protocol->end_partial_result_set(thd);
- ip= hip;
+ /* If found, activate handler for the current scope. */
+ if (ctx->activate_handler(thd, &ip, i, &execute_arena, &backup_arena))
err_status= FALSE;
- ctx->clear_handler();
- ctx->enter_handler(hip, handler_index);
- thd->clear_error();
- thd->is_fatal_error= 0;
- thd->killed= THD::NOT_KILLED;
- thd->mysys_var->abort= 0;
- continue;
- }
-
- ctx->end_partial_result_set= FALSE;
}
+
+ /* Reset sp_rcontext::end_partial_result_set flag. */
+ ctx->end_partial_result_set= FALSE;
+
} while (!err_status && !thd->killed && !thd->is_fatal_error);
#if defined(ENABLED_PROFILING)
@@ -1995,16 +2083,23 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
arguments evaluation. If arguments evaluation required prelocking mode,
we'll leave it here.
*/
+ thd->lex->unit.cleanup();
+
if (!thd->in_sub_stmt)
{
- thd->lex->unit.cleanup();
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
+ }
- thd_proc_info(thd, "closing tables");
- close_thread_tables(thd);
- thd_proc_info(thd, 0);
+ thd_proc_info(thd, "closing tables");
+ close_thread_tables(thd);
+ thd_proc_info(thd, 0);
- thd->rollback_item_tree_changes();
- }
+ if (! thd->in_sub_stmt && ! thd->in_multi_stmt_transaction_mode())
+ thd->mdl_context.release_transactional_locks();
+
+ thd->rollback_item_tree_changes();
DBUG_PRINT("info",(" %.*s: eval args done", (int) m_name.length,
m_name.str));
@@ -2197,6 +2292,7 @@ sp_head::restore_lex(THD *thd)
merge_table_list(thd, sublex->query_tables, sublex);
if (! sublex->sp_lex_in_use)
{
+ sublex->sphead= NULL;
lex_end(sublex);
delete sublex;
}
@@ -2806,12 +2902,27 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
DBUG_PRINT("info",("exec_core returned: %d", res));
}
- m_lex->unit.cleanup();
+ /*
+ Call after unit->cleanup() to close open table
+ key read.
+ */
+ if (open_tables)
+ {
+ m_lex->unit.cleanup();
+ /* Here we also commit or rollback the current statement. */
+ if (! thd->in_sub_stmt)
+ {
+ thd->stmt_da->can_overwrite_status= TRUE;
+ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
+ }
+ thd_proc_info(thd, "closing tables");
+ close_thread_tables(thd);
+ thd_proc_info(thd, 0);
- thd_proc_info(thd, "closing tables");
- /* Here we also commit or rollback the current statement. */
- close_thread_tables(thd);
- thd_proc_info(thd, 0);
+ if (! thd->in_sub_stmt && ! thd->in_multi_stmt_transaction_mode())
+ thd->mdl_context.release_transactional_locks();
+ }
if (m_lex->query_tables_own_last)
{
@@ -3012,23 +3123,14 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
{
int res= thd->spcont->set_variable(thd, m_offset, &m_value);
- if (res && thd->spcont->found_handler_here())
+ if (res)
{
- /*
- Failed to evaluate the value, and a handler has been found. Reset the
- variable to NULL.
- */
+ /* Failed to evaluate the value. Reset the variable to NULL. */
if (thd->spcont->set_variable(thd, m_offset, 0))
{
/* If this also failed, let's abort. */
-
- sp_rcontext *spcont= thd->spcont;
-
- thd->spcont= NULL; /* Avoid handlers */
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- spcont->clear_handler();
- thd->spcont= spcont;
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
}
}
@@ -3561,18 +3663,6 @@ sp_instr_copen::execute(THD *thd, uint *nextp)
if (thd->stmt_arena->free_list)
cleanup_items(thd->stmt_arena->free_list);
thd->stmt_arena= old_arena;
- /*
- Work around the fact that errors in selects are not returned properly
- (but instead converted into a warning), so if a condition handler
- caught, we have lost the result code.
- */
- if (!res)
- {
- uint dummy1, dummy2;
-
- if (thd->spcont->found_handler(&dummy1, &dummy2))
- res= -1;
- }
/* TODO: Assert here that we either have an error or a cursor */
}
DBUG_RETURN(res);
@@ -3748,13 +3838,11 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
{
int res= thd->spcont->set_case_expr(thd, m_case_expr_id, &m_case_expr);
- if (res &&
- !thd->spcont->get_case_expr(m_case_expr_id) &&
- thd->spcont->found_handler_here())
+ if (res && !thd->spcont->get_case_expr(m_case_expr_id))
{
/*
Failed to evaluate the value, the case expression is still not
- initialized, and a handler has been found. Set to NULL so we can continue.
+ initialized. Set to NULL so we can continue.
*/
Item *null_item= new Item_null();
@@ -3763,13 +3851,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item))
{
/* If this also failed, we have to abort. */
-
- sp_rcontext *spcont= thd->spcont;
-
- thd->spcont= NULL; /* Avoid handlers */
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
- spcont->clear_handler();
- thd->spcont= spcont;
+ my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
}
}
else
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 9796c49fdfb..b2446c8f680 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -682,6 +682,8 @@ public:
{
if (m_lex_resp)
{
+ /* Prevent endless recursion. */
+ m_lex->sphead= NULL;
lex_end(m_lex);
delete m_lex;
}
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index b12d5362c6b..c27c7d22da2 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -332,13 +332,6 @@ public:
int
push_cond(LEX_STRING *name, sp_cond_type_t *val);
- inline void
- pop_cond(uint num)
- {
- while (num--)
- pop_dynamic(&m_conds);
- }
-
sp_cond_type_t *
find_cond(LEX_STRING *name, my_bool scoped=0);
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 047cec76486..e76a5e9ebde 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -171,48 +171,50 @@ sp_rcontext::set_return_value(THD *thd, Item **return_value_item)
#define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2')
#define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2')
-/*
- Find a handler for the given errno.
- This is called from all error message functions (e.g. push_warning,
- net_send_error, et al) when a sp_rcontext is in effect. If a handler
- is found, no error is sent, and the the SP execution loop will instead
- invoke the found handler.
- This might be called several times before we get back to the execution
- loop, so m_hfound can be >= 0 if a handler has already been found.
- (In which case we don't search again - the first found handler will
- be used.)
- Handlers are pushed on the stack m_handler, with the latest/innermost
+/**
+ Find an SQL handler for the given error.
+
+ SQL handlers are pushed on the stack m_handler, with the latest/innermost
one on the top; we then search for matching handlers from the top and
down.
+
We search through all the handlers, looking for the most specific one
(sql_errno more specific than sqlstate more specific than the rest).
Note that mysql error code handlers is a MySQL extension, not part of
the standard.
- SYNOPSIS
- sql_errno The error code
- level Warning level
+ SQL handlers for warnings are searched in the current scope only.
- RETURN
- 1 if a handler was found, m_hfound is set to its index (>= 0)
- 0 if not found, m_hfound is -1
+ SQL handlers for errors are searched in the current and in outer scopes.
+ That's why finding and activation of handler must be separated: an errror
+ handler might be located in the outer scope, which is not active at the
+ moment. Before such handler can be activated, execution flow should
+ unwind to that scope.
+
+ Found SQL handler is remembered in m_hfound for future activation.
+ If no handler is found, m_hfound is -1.
+
+ @param thd Thread handle
+ @param sql_errno The error code
+ @param sqlstate The error SQL state
+ @param level The error level
+ @param msg The error message
+
+ @retval TRUE if an SQL handler was found
+ @retval FALSE otherwise
*/
bool
sp_rcontext::find_handler(THD *thd,
uint sql_errno,
- const char* sqlstate,
+ const char *sqlstate,
MYSQL_ERROR::enum_warning_level level,
- const char* msg,
- MYSQL_ERROR ** cond_hdl)
+ const char *msg)
{
- if (m_hfound >= 0)
- {
- *cond_hdl= NULL;
- return TRUE; // Already got one
- }
+ int i= m_hcount;
- int i= m_hcount, found= -1;
+ /* Reset previously found handler. */
+ m_hfound= -1;
/*
If this is a fatal sub-statement error, and this runtime
@@ -240,105 +242,56 @@ sp_rcontext::find_handler(THD *thd,
{
case sp_cond_type_t::number:
if (sql_errno == cond->mysqlerr &&
- (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number))
- found= i; // Always the most specific
+ (m_hfound < 0 || m_handler[m_hfound].cond->type > sp_cond_type_t::number))
+ m_hfound= i; // Always the most specific
break;
case sp_cond_type_t::state:
if (strcmp(sqlstate, cond->sqlstate) == 0 &&
- (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
- found= i;
+ (m_hfound < 0 || m_handler[m_hfound].cond->type > sp_cond_type_t::state))
+ m_hfound= i;
break;
case sp_cond_type_t::warning:
if ((IS_WARNING_CONDITION(sqlstate) ||
level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
- found < 0)
- found= i;
+ m_hfound < 0)
+ m_hfound= i;
break;
case sp_cond_type_t::notfound:
- if (IS_NOT_FOUND_CONDITION(sqlstate) && found < 0)
- found= i;
+ if (IS_NOT_FOUND_CONDITION(sqlstate) && m_hfound < 0)
+ m_hfound= i;
break;
case sp_cond_type_t::exception:
if (IS_EXCEPTION_CONDITION(sqlstate) &&
level == MYSQL_ERROR::WARN_LEVEL_ERROR &&
- found < 0)
- found= i;
+ m_hfound < 0)
+ m_hfound= i;
break;
}
}
- if (found < 0)
- {
- /*
- Only "exception conditions" are propagated to handlers in calling
- contexts. If no handler is found locally for a "completion condition"
- (warning or "not found") we will simply resume execution.
- */
- if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) &&
- level == MYSQL_ERROR::WARN_LEVEL_ERROR)
- return m_prev_runtime_ctx->find_handler(thd,
- sql_errno,
- sqlstate,
- level,
- msg,
- cond_hdl);
- *cond_hdl= NULL;
- return FALSE;
- }
-
- m_hfound= found;
- MYSQL_ERROR *raised= NULL;
- DBUG_ASSERT(m_hfound >= 0);
- DBUG_ASSERT((uint) m_hfound < m_root_parsing_ctx->max_handler_index());
- raised= & m_raised_conditions[m_hfound];
- raised->clear();
- raised->set(sql_errno, sqlstate, level, msg);
-
- *cond_hdl= raised;
- return TRUE;
-}
-
-/*
- Handle the error for a given errno.
- The severity of the error is adjusted depending of the current sql_mode.
- If an handler is present for the error (see find_handler()),
- this function will return true.
- If a handler is found and if the severity of the error indicate
- that the current instruction executed should abort,
- the flag thd->net.report_error is also set.
- This will cause the execution of the current instruction in a
- sp_instr* to fail, and give control to the handler code itself
- in the sp_head::execute() loop.
-
- SYNOPSIS
- sql_errno The error code
- level Warning level
- thd The current thread
+ if (m_hfound >= 0)
+ {
+ DBUG_ASSERT((uint) m_hfound < m_root_parsing_ctx->max_handler_index());
- RETURN
- TRUE if a handler was found.
- FALSE if no handler was found.
-*/
-bool
-sp_rcontext::handle_condition(THD *thd,
- uint sql_errno,
- const char* sqlstate,
- MYSQL_ERROR::enum_warning_level level,
- const char* msg,
- MYSQL_ERROR ** cond_hdl)
-{
- MYSQL_ERROR::enum_warning_level elevated_level= level;
+ m_raised_conditions[m_hfound].clear();
+ m_raised_conditions[m_hfound].set(sql_errno, sqlstate, level, msg);
+ return TRUE;
+ }
- /* Depending on the sql_mode of execution,
- warnings may be considered errors */
- if ((level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
- thd->really_abort_on_warning())
+ /*
+ Only "exception conditions" are propagated to handlers in calling
+ contexts. If no handler is found locally for a "completion condition"
+ (warning or "not found") we will simply resume execution.
+ */
+ if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) &&
+ level == MYSQL_ERROR::WARN_LEVEL_ERROR)
{
- elevated_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+ return m_prev_runtime_ctx->find_handler(thd, sql_errno, sqlstate,
+ level, msg);
}
- return find_handler(thd, sql_errno, sqlstate, elevated_level, msg, cond_hdl);
+ return FALSE;
}
void
@@ -384,7 +337,9 @@ sp_rcontext::pop_handlers(uint count)
{
DBUG_ENTER("sp_rcontext::pop_handlers");
DBUG_ASSERT(m_hcount >= count);
+
m_hcount-= count;
+
DBUG_PRINT("info", ("m_hcount: %d", m_hcount));
DBUG_VOID_RETURN;
}
@@ -394,7 +349,9 @@ sp_rcontext::push_hstack(uint h)
{
DBUG_ENTER("sp_rcontext::push_hstack");
DBUG_ASSERT(m_hsp < m_root_parsing_ctx->max_handler_index());
+
m_hstack[m_hsp++]= h;
+
DBUG_PRINT("info", ("m_hsp: %d", m_hsp));
DBUG_VOID_RETURN;
}
@@ -405,21 +362,74 @@ sp_rcontext::pop_hstack()
uint handler;
DBUG_ENTER("sp_rcontext::pop_hstack");
DBUG_ASSERT(m_hsp);
+
handler= m_hstack[--m_hsp];
+
DBUG_PRINT("info", ("m_hsp: %d", m_hsp));
DBUG_RETURN(handler);
}
-void
-sp_rcontext::enter_handler(uint hip, uint hindex)
+/**
+ Prepare found handler to be executed.
+
+ @retval TRUE if an SQL handler is activated (was found) and IP of the
+ first handler instruction.
+ @retval FALSE if there is no active handler
+*/
+
+bool
+sp_rcontext::activate_handler(THD *thd,
+ uint *ip,
+ sp_instr *instr,
+ Query_arena *execute_arena,
+ Query_arena *backup_arena)
{
- DBUG_ENTER("sp_rcontext::enter_handler");
- DBUG_ASSERT(m_ihsp < m_root_parsing_ctx->max_handler_index());
- m_in_handler[m_ihsp].ip= hip;
- m_in_handler[m_ihsp].index= hindex;
- m_ihsp++;
- DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp));
- DBUG_VOID_RETURN;
+ if (m_hfound < 0)
+ return FALSE;
+
+ switch (m_handler[m_hfound].type) {
+ case SP_HANDLER_NONE:
+ break;
+
+ case SP_HANDLER_CONTINUE:
+ thd->restore_active_arena(execute_arena, backup_arena);
+ thd->set_n_backup_active_arena(execute_arena, backup_arena);
+ push_hstack(instr->get_cont_dest());
+
+ /* Fall through */
+
+ default:
+ /* End aborted result set. */
+
+ if (end_partial_result_set)
+ thd->protocol->end_partial_result_set(thd);
+
+ /* Enter handler. */
+
+ DBUG_ASSERT(m_ihsp < m_root_parsing_ctx->max_handler_index());
+ DBUG_ASSERT(m_hfound >= 0);
+
+ m_in_handler[m_ihsp].ip= m_handler[m_hfound].handler;
+ m_in_handler[m_ihsp].index= m_hfound;
+ m_ihsp++;
+
+ DBUG_PRINT("info", ("Entering handler..."));
+ DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp));
+
+ /* Reset error state. */
+
+ thd->clear_error();
+ thd->killed= THD::NOT_KILLED; // Some errors set thd->killed
+ // (e.g. "bad data").
+
+ /* Return IP of the activated SQL handler. */
+ *ip= m_handler[m_hfound].handler;
+
+ /* Reset found handler. */
+ m_hfound= -1;
+ }
+
+ return TRUE;
}
void
@@ -427,9 +437,11 @@ sp_rcontext::exit_handler()
{
DBUG_ENTER("sp_rcontext::exit_handler");
DBUG_ASSERT(m_ihsp);
+
uint hindex= m_in_handler[m_ihsp-1].index;
m_raised_conditions[hindex].clear();
m_ihsp-= 1;
+
DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp));
DBUG_VOID_RETURN;
}
@@ -525,8 +537,7 @@ sp_cursor::open(THD *thd)
MYF(0));
return -1;
}
- if (mysql_open_cursor(thd, (uint) ALWAYS_MATERIALIZED_CURSOR, &result,
- &server_side_cursor))
+ if (mysql_open_cursor(thd, &result, &server_side_cursor))
return -1;
return 0;
}
@@ -568,6 +579,11 @@ sp_cursor::fetch(THD *thd, List<struct sp_variable> *vars)
return -1;
}
+ DBUG_EXECUTE_IF("bug23032_emit_warning",
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR,
+ ER(ER_UNKNOWN_ERROR)););
+
result.set_spvar_list(vars);
/* Attempt to fetch one row */
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index fad253706cb..1af758ed0af 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -131,67 +131,40 @@ class sp_rcontext : public Sql_alloc
return m_return_value_set;
}
+ /*
+ SQL handlers support.
+ */
+
void push_handler(struct sp_cond_type *cond, uint h, int type);
void pop_handlers(uint count);
- // Returns 1 if a handler was found, 0 otherwise.
bool
find_handler(THD *thd,
uint sql_errno,
- const char* sqlstate,
+ const char *sqlstate,
MYSQL_ERROR::enum_warning_level level,
- const char* msg,
- MYSQL_ERROR ** cond_hdl);
+ const char *msg);
- // If there is an error handler for this error, handle it and return TRUE.
- bool
- handle_condition(THD *thd,
- uint sql_errno,
- const char* sqlstate,
- MYSQL_ERROR::enum_warning_level level,
- const char* msg,
- MYSQL_ERROR ** cond_hdl);
-
- // Returns handler type and sets *ip to location if one was found
- inline int
- found_handler(uint *ip, uint *index)
- {
- if (m_hfound < 0)
- return SP_HANDLER_NONE;
- *ip= m_handler[m_hfound].handler;
- *index= m_hfound;
- return m_handler[m_hfound].type;
- }
-
- MYSQL_ERROR* raised_condition() const;
-
- // Returns true if we found a handler in this context
- inline bool
- found_handler_here()
- {
- return (m_hfound >= 0);
- }
+ MYSQL_ERROR *
+ raised_condition() const;
- // Clears the handler find state
- inline void
- clear_handler()
- {
- m_hfound= -1;
- }
+ void
+ push_hstack(uint h);
- void push_hstack(uint h);
+ uint
+ pop_hstack();
- uint pop_hstack();
+ bool
+ activate_handler(THD *thd,
+ uint *ip,
+ sp_instr *instr,
+ Query_arena *execute_arena,
+ Query_arena *backup_arena);
- /**
- Enter a SQL exception handler.
- @param hip the handler instruction pointer
- @param index the handler index
- */
- void enter_handler(uint hip, uint index);
- void exit_handler();
+ void
+ exit_handler();
void
push_cursor(sp_lex_keeper *lex_keeper, sp_instr_cpush *i);
@@ -199,7 +172,7 @@ class sp_rcontext : public Sql_alloc
void
pop_cursors(uint count);
- void
+ inline void
pop_all_cursors()
{
pop_cursors(m_ccount);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 7e004c05f8e..19373507955 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -27,7 +27,7 @@
#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */
#include "sql_priv.h"
#include "sql_acl.h" // MYSQL_DB_FIELD_COUNT, ACL_ACCESS
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_mysql_tables
#include "key.h" // key_copy, key_cmp_if_same, key_restore
#include "sql_show.h" // append_identifier
#include "sql_table.h" // build_table_filename
@@ -678,16 +678,15 @@ my_bool acl_reload(THD *thd)
To avoid deadlocks we should obtain table locks before
obtaining acl_cache->lock mutex.
*/
- bzero((char*) tables, sizeof(tables));
- tables[0].alias= tables[0].table_name= (char*) "host";
- tables[1].alias= tables[1].table_name= (char*) "user";
- tables[2].alias= tables[2].table_name= (char*) "db";
- tables[0].db=tables[1].db=tables[2].db=(char*) "mysql";
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("host"), "host", TL_READ);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_READ);
+ tables[2].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("db"), "db", TL_READ);
tables[0].next_local= tables[0].next_global= tables+1;
tables[1].next_local= tables[1].next_global= tables+2;
- tables[0].lock_type=tables[1].lock_type=tables[2].lock_type=TL_READ;
tables[0].open_type= tables[1].open_type= tables[2].open_type= OT_BASE_ONLY;
- init_mdl_requests(tables);
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{
@@ -731,9 +730,7 @@ my_bool acl_reload(THD *thd)
if (old_initialized)
mysql_mutex_unlock(&acl_cache->lock);
end:
- trans_commit_implicit(thd);
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
+ close_mysql_tables(thd);
DBUG_RETURN(return_val);
}
@@ -1586,6 +1583,7 @@ bool change_password(THD *thd, const char *host, const char *user,
/* Buffer should be extended when password length is extended. */
char buff[512];
ulong query_length;
+ bool save_binlog_row_based;
uint new_password_len= (uint) strlen(new_password);
bool result= 1;
DBUG_ENTER("change_password");
@@ -1615,10 +1613,17 @@ bool change_password(THD *thd, const char *host, const char *user,
DBUG_RETURN(0);
}
#endif
-
if (!(table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
DBUG_RETURN(1);
+ /*
+ This statement will be replicated as a statement, even when using
+ row-based replication. The flag will be reset at the end of the
+ statement.
+ */
+ if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+ thd->clear_current_stmt_binlog_format_row();
+
mysql_mutex_lock(&acl_cache->lock);
ACL_USER *acl_user;
if (!(acl_user= find_acl_user(host, user, TRUE)))
@@ -1653,7 +1658,13 @@ bool change_password(THD *thd, const char *host, const char *user,
FALSE, FALSE, FALSE, 0);
}
end:
- close_thread_tables(thd);
+ close_mysql_tables(thd);
+
+ /* Restore the state of binlog format */
+ DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
+ if (save_binlog_row_based)
+ thd->set_current_stmt_binlog_format_row();
+
DBUG_RETURN(result);
}
@@ -1924,9 +1935,8 @@ static bool test_if_create_new_users(THD *thd)
{
TABLE_LIST tl;
ulong db_access;
- bzero((char*) &tl,sizeof(tl));
- tl.db= (char*) "mysql";
- tl.table_name= (char*) "user";
+ tl.init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_WRITE);
create_new_users= 1;
db_access=acl_get(sctx->host, sctx->ip,
@@ -3062,7 +3072,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
class LEX_COLUMN *column;
List_iterator <LEX_COLUMN> column_iter(columns);
- if (open_and_lock_tables(thd, table_list, TRUE, 0))
+ if (open_normal_and_derived_tables(thd, table_list, 0))
DBUG_RETURN(TRUE);
while ((column = column_iter++))
@@ -3084,7 +3094,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
column_priv|= column->rights;
}
- close_thread_tables(thd);
+ close_mysql_tables(thd);
}
else
{
@@ -3116,20 +3126,18 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
/* open the mysql.tables_priv and mysql.columns_priv tables */
- bzero((char*) &tables,sizeof(tables));
- tables[0].alias=tables[0].table_name= (char*) "user";
- tables[1].alias=tables[1].table_name= (char*) "tables_priv";
- tables[2].alias=tables[2].table_name= (char*) "columns_priv";
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_WRITE);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("tables_priv"),
+ "tables_priv", TL_WRITE);
+ tables[2].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("columns_priv"),
+ "columns_priv", TL_WRITE);
tables[0].next_local= tables[0].next_global= tables+1;
/* Don't open column table if we don't need it ! */
- tables[1].next_local=
- tables[1].next_global= ((column_priv ||
- (revoke_grant &&
- ((rights & COL_ACLS) || columns.elements)))
- ? tables+2 : 0);
- tables[0].lock_type=tables[1].lock_type=tables[2].lock_type=TL_WRITE;
- tables[0].db=tables[1].db=tables[2].db=(char*) "mysql";
- init_mdl_requests(tables);
+ if (column_priv || (revoke_grant && ((rights & COL_ACLS) || columns.elements)))
+ tables[1].next_local= tables[1].next_global= tables+2;
/*
This statement will be replicated as a statement, even when using
@@ -3176,7 +3184,6 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
thd->lex->sql_command= backup.sql_command;
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{ // Should never happen
- close_thread_tables(thd); /* purecov: deadcode */
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -3363,13 +3370,11 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
/* open the mysql.user and mysql.procs_priv tables */
- bzero((char*) &tables,sizeof(tables));
- tables[0].alias=tables[0].table_name= (char*) "user";
- tables[1].alias=tables[1].table_name= (char*) "procs_priv";
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_WRITE);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("procs_priv"), "procs_priv", TL_WRITE);
tables[0].next_local= tables[0].next_global= tables+1;
- tables[0].lock_type=tables[1].lock_type=TL_WRITE;
- tables[0].db=tables[1].db=(char*) "mysql";
- init_mdl_requests(tables);
/*
This statement will be replicated as a statement, even when using
@@ -3404,7 +3409,6 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{ // Should never happen
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -3520,13 +3524,11 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
}
/* open the mysql.user and mysql.db tables */
- bzero((char*) &tables,sizeof(tables));
- tables[0].alias=tables[0].table_name=(char*) "user";
- tables[1].alias=tables[1].table_name=(char*) "db";
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_WRITE);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("db"), "db", TL_WRITE);
tables[0].next_local= tables[0].next_global= tables+1;
- tables[0].lock_type=tables[1].lock_type=TL_WRITE;
- tables[0].db=tables[1].db=(char*) "mysql";
- init_mdl_requests(tables);
/*
This statement will be replicated as a statement, even when using
@@ -3561,7 +3563,6 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{ // This should never happen
- close_thread_tables(thd); /* purecov: deadcode */
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -3621,7 +3622,6 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
}
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
if (!result)
my_ok(thd);
@@ -3882,10 +3882,7 @@ static my_bool grant_reload_procs_priv(THD *thd)
table.open_type= OT_BASE_ONLY;
if (open_and_lock_tables(thd, &table, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
- {
- close_thread_tables(thd);
DBUG_RETURN(TRUE);
- }
mysql_rwlock_wrlock(&LOCK_grant);
/* Save a copy of the current hash if we need to undo the grant load */
@@ -3907,7 +3904,7 @@ static my_bool grant_reload_procs_priv(THD *thd)
}
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
+ close_mysql_tables(thd);
DBUG_RETURN(return_val);
}
@@ -3939,14 +3936,14 @@ my_bool grant_reload(THD *thd)
if (!initialized)
DBUG_RETURN(0);
- bzero((char*) tables, sizeof(tables));
- tables[0].alias= tables[0].table_name= (char*) "tables_priv";
- tables[1].alias= tables[1].table_name= (char*) "columns_priv";
- tables[0].db= tables[1].db= (char *) "mysql";
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("tables_priv"),
+ "tables_priv", TL_READ);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("columns_priv"),
+ "columns_priv", TL_READ);
tables[0].next_local= tables[0].next_global= tables+1;
- tables[0].lock_type= tables[1].lock_type= TL_READ;
tables[0].open_type= tables[1].open_type= OT_BASE_ONLY;
- init_mdl_requests(tables);
/*
To avoid deadlocks we should obtain table locks before
@@ -3978,9 +3975,7 @@ my_bool grant_reload(THD *thd)
free_root(&old_mem,MYF(0));
}
mysql_rwlock_unlock(&LOCK_grant);
- trans_commit_implicit(thd);
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
+ close_mysql_tables(thd);
/*
It is OK failing to load procs_priv table because we may be
@@ -5218,22 +5213,23 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
DBUG_RETURN(-1);
}
- bzero((char*) tables, GRANT_TABLES*sizeof(*tables));
- tables->alias= tables->table_name= (char*) "user";
- (tables+1)->alias= (tables+1)->table_name= (char*) "db";
- (tables+2)->alias= (tables+2)->table_name= (char*) "tables_priv";
- (tables+3)->alias= (tables+3)->table_name= (char*) "columns_priv";
- (tables+4)->alias= (tables+4)->table_name= (char*) "procs_priv";
+ tables->init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("user"), "user", TL_WRITE);
+ (tables+1)->init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("db"), "db", TL_WRITE);
+ (tables+2)->init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("tables_priv"),
+ "tables_priv", TL_WRITE);
+ (tables+3)->init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("columns_priv"),
+ "columns_priv", TL_WRITE);
+ (tables+4)->init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("procs_priv"),
+ "procs_priv", TL_WRITE);
tables->next_local= tables->next_global= tables+1;
(tables+1)->next_local= (tables+1)->next_global= tables+2;
(tables+2)->next_local= (tables+2)->next_global= tables+3;
(tables+3)->next_local= (tables+3)->next_global= tables+4;
- tables->lock_type= (tables+1)->lock_type=
- (tables+2)->lock_type= (tables+3)->lock_type=
- (tables+4)->lock_type= TL_WRITE;
- tables->db= (tables+1)->db= (tables+2)->db=
- (tables+3)->db= (tables+4)->db= (char*) "mysql";
- init_mdl_requests(tables);
#ifdef HAVE_REPLICATION
/*
@@ -5257,7 +5253,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{ // This should never happen
- close_thread_tables(thd);
DBUG_RETURN(-1);
}
@@ -5895,7 +5890,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -5980,7 +5974,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
thd->variables.sql_mode= old_sql_mode;
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
@@ -6077,7 +6070,6 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -6275,8 +6267,6 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list)
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
-
/* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
if (save_binlog_row_based)
@@ -6423,7 +6413,6 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name,
mysql_mutex_unlock(&acl_cache->lock);
mysql_rwlock_unlock(&LOCK_grant);
- close_thread_tables(thd);
thd->pop_internal_handler();
/* Restore the state of binlog format */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 2b1ce66e509..e810d5fc091 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -53,6 +53,7 @@
#include "rpl_filter.h"
#include "sql_table.h" // build_table_filename
#include "datadict.h" // dd_frm_type()
+#include "sql_hset.h" // Hash_set
#ifdef __WIN__
#include <io.h>
#endif
@@ -755,27 +756,6 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name)
}
-#ifdef DISABLED_UNTIL_GRL_IS_MADE_PART_OF_MDL
-/**
- @brief Mark table share as having one more user (increase its reference
- count).
-
- @param share Table share for which reference count should be increased.
-*/
-
-static void reference_table_share(TABLE_SHARE *share)
-{
- DBUG_ENTER("reference_table_share");
- DBUG_ASSERT(share->ref_count);
- mysql_mutex_assert_owner(&LOCK_open);
- share->ref_count++;
- DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
- (ulong) share, share->ref_count));
- DBUG_VOID_RETURN;
-}
-#endif
-
-
/*
Create a list for all open tables matching SQL expression
@@ -1422,6 +1402,9 @@ void close_thread_tables(THD *thd)
DEBUG_SYNC(thd, "before_close_thread_tables");
#endif
+ DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt ||
+ (thd->state_flags & Open_tables_state::BACKUPS_AVAIL));
+
/* Detach MERGE children after every statement. Even under LOCK TABLES. */
for (table= thd->open_tables; table; table= table->next)
{
@@ -1466,28 +1449,6 @@ void close_thread_tables(THD *thd)
Mark all temporary tables used by this statement as free for reuse.
*/
mark_temp_tables_as_free_for_reuse(thd);
- /*
- Let us commit transaction for statement. Since in 5.0 we only have
- one statement transaction and don't allow several nested statement
- transactions this call will do nothing if we are inside of stored
- function or trigger (i.e. statement transaction is already active and
- does not belong to statement for which we do close_thread_tables()).
- TODO: This should be fixed in later releases.
- */
- if (!(thd->state_flags & Open_tables_state::BACKUPS_AVAIL))
- {
- thd->stmt_da->can_overwrite_status= TRUE;
- thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
- thd->stmt_da->can_overwrite_status= FALSE;
-
- /*
- Reset transaction state, but only if we're not inside a
- sub-statement of a prelocked statement.
- */
- if (thd->locked_tables_mode <= LTM_LOCK_TABLES ||
- thd->lex->requires_prelocking())
- thd->transaction.stmt.reset();
- }
if (thd->locked_tables_mode)
{
@@ -1548,26 +1509,6 @@ void close_thread_tables(THD *thd)
if (thd->open_tables)
close_open_tables(thd);
- /*
- - If inside a multi-statement transaction,
- defer the release of metadata locks until the current
- transaction is either committed or rolled back. This prevents
- other statements from modifying the table for the entire
- duration of this transaction. This provides commit ordering
- and guarantees serializability across multiple transactions.
- - If closing a system table, defer the release of metadata locks
- to the caller. We have no sentinel in MDL subsystem to guard
- transactional locks from system tables locks, so don't know
- which locks are which here.
- - If in autocommit mode, or outside a transactional context,
- automatically release metadata locks of the current statement.
- */
- if (! thd->in_multi_stmt_transaction_mode() &&
- ! (thd->state_flags & Open_tables_state::BACKUPS_AVAIL))
- {
- thd->mdl_context.release_transactional_locks();
- }
-
DBUG_VOID_RETURN;
}
@@ -1582,7 +1523,14 @@ bool close_thread_table(THD *thd, TABLE **table_ptr)
DBUG_ASSERT(table->key_read == 0);
DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
mysql_mutex_assert_not_owner(&LOCK_open);
-
+ /*
+ The metadata lock must be released after giving back
+ the table to the table cache.
+ */
+ DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE,
+ table->s->db.str,
+ table->s->table_name.str,
+ MDL_SHARED));
table->mdl_ticket= NULL;
mysql_mutex_lock(&thd->LOCK_thd_data);
@@ -1634,7 +1582,7 @@ static inline uint tmpkeyval(THD *thd, TABLE *table)
creates one DROP TEMPORARY TABLE binlog event for each pseudo-thread
*/
-void close_temporary_tables(THD *thd)
+bool close_temporary_tables(THD *thd)
{
DBUG_ENTER("close_temporary_tables");
TABLE *table;
@@ -1642,9 +1590,10 @@ void close_temporary_tables(THD *thd)
TABLE *prev_table;
/* Assume thd->variables.option_bits has OPTION_QUOTE_SHOW_CREATE */
bool was_quote_show= TRUE;
+ bool error= 0;
if (!thd->temporary_tables)
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
if (!mysql_bin_log.is_open())
{
@@ -1655,7 +1604,7 @@ void close_temporary_tables(THD *thd)
close_temporary(table, 1, 1);
}
thd->temporary_tables= 0;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
/* Better add "if exists", in case a RESET MASTER has been done */
@@ -1754,11 +1703,27 @@ void close_temporary_tables(THD *thd)
qinfo.db= db.ptr();
qinfo.db_len= db.length();
thd->variables.character_set_client= cs_save;
- if (mysql_bin_log.write(&qinfo))
+
+ thd->stmt_da->can_overwrite_status= TRUE;
+ if ((error= (mysql_bin_log.write(&qinfo) || error)))
{
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, MYF(0),
- "Failed to write the DROP statement for temporary tables to binary log");
+ /*
+ If we're here following THD::cleanup, thence the connection
+ has been closed already. So lets print a message to the
+ error log instead of pushing yet another error into the
+ stmt_da.
+
+ Also, we keep the error flag so that we propagate the error
+ up in the stack. This way, if we're the SQL thread we notice
+ that close_temporary_tables failed. (Actually, the SQL
+ thread only calls close_temporary_tables while applying old
+ Start_log_event_v3 events.)
+ */
+ sql_print_error("Failed to write the DROP statement for "
+ "temporary tables to binary log");
}
+ thd->stmt_da->can_overwrite_status= FALSE;
+
thd->variables.pseudo_thread_id= save_pseudo_thread_id;
thd->thread_specific_used= save_thread_specific_used;
}
@@ -1771,7 +1736,8 @@ void close_temporary_tables(THD *thd)
if (!was_quote_show)
thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */
thd->temporary_tables=0;
- DBUG_VOID_RETURN;
+
+ DBUG_RETURN(error);
}
/*
@@ -1809,15 +1775,13 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
}
-/*
+/**
Test that table is unique (It's only exists once in the table list)
- SYNOPSIS
- unique_table()
- thd thread handle
- table table which should be checked
- table_list list of tables
- check_alias whether to check tables' aliases
+ @param thd thread handle
+ @param table table which should be checked
+ @param table_list list of tables
+ @param check_alias whether to check tables' aliases
NOTE: to exclude derived tables from check we use following mechanism:
a) during derived table processing set THD::derived_tables_processing
@@ -1828,7 +1792,7 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
processing loop, because multi-update call fix_fields() for some its
items (which mean JOIN::prepare for subqueries) before unique_table
call to detect which tables should be locked for write).
- c) unique_table skip all tables which belong to SELECT with
+ c) find_dup_table skip all tables which belong to SELECT with
SELECT::exclude_from_table_unique_test set.
Also SELECT::exclude_from_table_unique_test used to exclude from check
tables of main SELECT of multi-delete and multi-update
@@ -1840,17 +1804,17 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
TODO: when we will have table/view change detection we can do this check
only once for PS/SP
- RETURN
- found duplicate
- 0 if table is unique
+ @retval !=0 found duplicate
+ @retval 0 if table is unique
*/
-TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
- bool check_alias)
+static
+TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
+ bool check_alias)
{
TABLE_LIST *res;
const char *d_name, *t_name, *t_alias;
- DBUG_ENTER("unique_table");
+ DBUG_ENTER("find_dup_table");
DBUG_PRINT("enter", ("table alias: %s", table->alias));
/*
@@ -1865,6 +1829,9 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
*/
if (table->table)
{
+ /* All MyISAMMRG children are plain MyISAM tables. */
+ DBUG_ASSERT(table->table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
+
/* temporary table is always unique */
if (table->table && table->table->s->tmp_table != NO_TMP_TABLE)
DBUG_RETURN(0);
@@ -1886,8 +1853,7 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
Table is unique if it is present only once in the global list
of tables and once in the list of table locks.
*/
- if (! (res= find_table_in_global_list(table_list, d_name, t_name)) &&
- ! (res= mysql_lock_have_duplicate(thd, table, table_list)))
+ if (! (res= find_table_in_global_list(table_list, d_name, t_name)))
break;
/* Skip if same underlying table. */
@@ -1926,6 +1892,42 @@ next:
}
+/**
+ Test that the subject table of INSERT/UPDATE/DELETE/CREATE
+ or (in case of MyISAMMRG) one of its children are not used later
+ in the query.
+
+ For MyISAMMRG tables, it is assumed that all the underlying
+ tables of @c table (if any) are listed right after it and that
+ their @c parent_l field points at the main table.
+
+
+ @retval non-NULL The table list element for the table that
+ represents the duplicate.
+ @retval NULL No duplicates found.
+*/
+
+TABLE_LIST*
+unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
+ bool check_alias)
+{
+ TABLE_LIST *dup;
+ if (table->table && table->table->file->ht->db_type == DB_TYPE_MRG_MYISAM)
+ {
+ TABLE_LIST *child;
+ dup= NULL;
+ /* Check duplicates of all merge children. */
+ for (child= table->next_global; child && child->parent_l == table;
+ child= child->next_global)
+ {
+ if ((dup= find_dup_table(thd, child, child->next_global, check_alias)))
+ break;
+ }
+ }
+ else
+ dup= find_dup_table(thd, table, table_list, check_alias);
+ return dup;
+}
/*
Issue correct error message in case we found 2 duplicate tables which
prevent some update operation
@@ -2253,51 +2255,6 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name,
}
-/*
- Wait for condition but allow the user to send a kill to mysqld
-
- SYNOPSIS
- wait_for_condition()
- thd Thread handler
- mutex mutex that is currently hold that is associated with condition
- Will be unlocked on return
- cond Condition to wait for
-*/
-
-void wait_for_condition(THD *thd, mysql_mutex_t *mutex, mysql_cond_t *cond)
-{
- /* Wait until the current table is up to date */
- const char *proc_info;
- thd->mysys_var->current_mutex= mutex;
- thd->mysys_var->current_cond= cond;
- proc_info=thd->proc_info;
- thd_proc_info(thd, "Waiting for table");
- DBUG_ENTER("wait_for_condition");
- DEBUG_SYNC(thd, "waiting_for_table");
- if (!thd->killed)
- mysql_cond_wait(cond, mutex);
-
- /*
- We must unlock mutex first to avoid deadlock becasue conditions are
- sent to this thread by doing locks in the following order:
- lock(mysys_var->mutex)
- lock(mysys_var->current_mutex)
-
- One by effect of this that one can only use wait_for_condition with
- condition variables that are guranteed to not disapper (freed) even if this
- mutex is unlocked
- */
-
- mysql_mutex_unlock(mutex);
- mysql_mutex_lock(&thd->mysys_var->mutex);
- thd->mysys_var->current_mutex= 0;
- thd->mysys_var->current_cond= 0;
- thd_proc_info(thd, proc_info);
- mysql_mutex_unlock(&thd->mysys_var->mutex);
- DBUG_VOID_RETURN;
-}
-
-
/**
Check that table exists in table definition cache, on disk
or in some storage engine.
@@ -2363,20 +2320,6 @@ end:
/**
- @brief Helper function used by MDL subsystem for releasing TABLE_SHARE
- objects in cases when it no longer wants to cache reference to it.
-*/
-
-void table_share_release_hook(void *share)
-{
- mysql_mutex_lock(&LOCK_open);
- release_table_share((TABLE_SHARE*) share);
- broadcast_refresh();
- mysql_mutex_unlock(&LOCK_open);
-}
-
-
-/**
An error handler which converts, if possible, ER_LOCK_DEADLOCK error
that can occur when we are trying to acquire a metadata lock to
a request for back-off and re-start of open_tables() process.
@@ -2868,96 +2811,61 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
DBUG_RETURN(FALSE);
mysql_mutex_lock(&LOCK_open);
-#ifdef DISABLED_UNTIL_GRL_IS_MADE_PART_OF_MDL
- if (!(share= (TABLE_SHARE *) mdl_ticket->get_cached_object()))
-#endif
- {
- if (!(share= get_table_share_with_create(thd, table_list, key,
- key_length, OPEN_VIEW,
- &error,
- hash_value)))
- goto err_unlock2;
- if (share->is_view)
- {
- /*
- If parent_l of the table_list is non null then a merge table
- has this view as child table, which is not supported.
- */
- if (table_list->parent_l)
- {
- my_error(ER_WRONG_MRG_TABLE, MYF(0));
- goto err_unlock;
- }
-
- /*
- This table is a view. Validate its metadata version: in particular,
- that it was a view when the statement was prepared.
- */
- if (check_and_update_table_version(thd, table_list, share))
- goto err_unlock;
- if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
- goto err_unlock;
-
- /* Open view */
- if (open_new_frm(thd, share, alias,
- (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
- HA_GET_INDEX | HA_TRY_READ_ONLY),
- READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
- thd->open_options,
- 0, table_list, mem_root))
- goto err_unlock;
-
- /* TODO: Don't free this */
- release_table_share(share);
-
- DBUG_ASSERT(table_list->view);
+ if (!(share= get_table_share_with_create(thd, table_list, key,
+ key_length, OPEN_VIEW,
+ &error,
+ hash_value)))
+ goto err_unlock2;
- mysql_mutex_unlock(&LOCK_open);
- DBUG_RETURN(FALSE);
- }
+ if (share->is_view)
+ {
/*
- Note that situation when we are trying to open a table for what
- was a view during previous execution of PS will be handled in by
- the caller. Here we should simply open our table even if
- TABLE_LIST::view is true.
+ If parent_l of the table_list is non null then a merge table
+ has this view as child table, which is not supported.
*/
-
- if (table_list->i_s_requested_object & OPEN_VIEW_ONLY)
+ if (table_list->parent_l)
+ {
+ my_error(ER_WRONG_MRG_TABLE, MYF(0));
goto err_unlock;
+ }
-#ifdef DISABLED_UNTIL_GRL_IS_MADE_PART_OF_MDL
/*
- We are going to to store extra reference to the share in MDL-subsystem
- so we need to increase reference counter;
+ This table is a view. Validate its metadata version: in particular,
+ that it was a view when the statement was prepared.
*/
- reference_table_share(share);
- mdl_ticket->set_cached_object(share, table_share_release_hook);
-#endif
- }
-#ifdef DISABLED_UNTIL_GRL_IS_MADE_PART_OF_MDL
- else
- {
- if (table_list->view)
- {
- DBUG_ASSERT(thd->m_reprepare_observer);
- check_and_update_table_version(thd, table_list, share);
- /* Always an error. */
- DBUG_ASSERT(thd->is_error());
+ if (check_and_update_table_version(thd, table_list, share))
goto err_unlock;
- }
- /* When we have cached TABLE_SHARE we know that is not a view. */
- if (table_list->i_s_requested_object & OPEN_VIEW_ONLY)
+ if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
goto err_unlock;
- /*
- We are going to use this share for construction of new TABLE object
- so reference counter should be increased.
- */
- reference_table_share(share);
+ /* Open view */
+ if (open_new_frm(thd, share, alias,
+ (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
+ HA_GET_INDEX | HA_TRY_READ_ONLY),
+ READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
+ thd->open_options,
+ 0, table_list, mem_root))
+ goto err_unlock;
+
+ /* TODO: Don't free this */
+ release_table_share(share);
+
+ DBUG_ASSERT(table_list->view);
+
+ mysql_mutex_unlock(&LOCK_open);
+ DBUG_RETURN(FALSE);
}
-#endif
+ /*
+ Note that situation when we are trying to open a table for what
+ was a view during previous execution of PS will be handled in by
+ the caller. Here we should simply open our table even if
+ TABLE_LIST::view is true.
+ */
+
+ if (table_list->i_s_requested_object & OPEN_VIEW_ONLY)
+ goto err_unlock;
/*
If the version changes while we're opening the tables,
@@ -3095,8 +3003,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table_list->table= table;
DBUG_ASSERT(table->key_read == 0);
/* Tables may be reused in a sub statement. */
- if (table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN))
- table->file->extra(HA_EXTRA_DETACH_CHILDREN);
+ DBUG_ASSERT(! table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN));
DBUG_RETURN(FALSE);
err_lock:
@@ -3267,6 +3174,7 @@ Locked_tables_list::init_locked_tables(THD *thd)
return FALSE;
}
+
/**
Leave LTM_LOCK_TABLES mode if it's been entered.
@@ -3303,7 +3211,12 @@ Locked_tables_list::unlock_locked_tables(THD *thd)
}
thd->leave_locked_tables_mode();
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
close_thread_tables(thd);
+ /*
+ We rely on the caller to implicitly commit the
+ transaction and release transactional locks.
+ */
}
/*
After closing tables we can free memory used for storing lock
@@ -3885,38 +3798,15 @@ end_unlock:
Open_table_context::Open_table_context(THD *thd, uint flags)
:m_failed_table(NULL),
m_start_of_statement_svp(thd->mdl_context.mdl_savepoint()),
- m_global_mdl_request(NULL),
m_timeout(flags & MYSQL_LOCK_IGNORE_TIMEOUT ?
LONG_TIMEOUT : thd->variables.lock_wait_timeout),
m_flags(flags),
m_action(OT_NO_ACTION),
- m_has_locks((thd->in_multi_stmt_transaction_mode() &&
- thd->mdl_context.has_locks()) ||
- thd->mdl_context.trans_sentinel())
+ m_has_locks(thd->mdl_context.has_locks())
{}
/**
- Get MDL_request object for global intention exclusive lock which
- is acquired during opening tables for statements which take
- upgradable shared metadata locks.
-*/
-
-MDL_request *Open_table_context::get_global_mdl_request(THD *thd)
-{
- if (! m_global_mdl_request)
- {
- if ((m_global_mdl_request= new (thd->mem_root) MDL_request()))
- {
- m_global_mdl_request->init(MDL_key::GLOBAL, "", "",
- MDL_INTENTION_EXCLUSIVE);
- }
- }
- return m_global_mdl_request;
-}
-
-
-/**
Check if we can back-off and set back off action if we can.
Otherwise report and return error.
@@ -3964,13 +3854,23 @@ request_backoff_action(enum_open_table_action action_arg,
my_error(ER_LOCK_DEADLOCK, MYF(0));
return TRUE;
}
- m_action= action_arg;
/*
If auto-repair or discovery are requested, a pointer to table
list element must be provided.
*/
- DBUG_ASSERT((m_action != OT_DISCOVER && m_action != OT_REPAIR) || table);
- m_failed_table= table;
+ if (table)
+ {
+ DBUG_ASSERT(action_arg == OT_DISCOVER || action_arg == OT_REPAIR);
+ m_failed_table= (TABLE_LIST*) current_thd->alloc(sizeof(TABLE_LIST));
+ if (m_failed_table == NULL)
+ return TRUE;
+ m_failed_table->init_one_table(table->db, table->db_length,
+ table->table_name,
+ table->table_name_length,
+ table->alias, TL_WRITE);
+ m_failed_table->mdl_request.set_type(MDL_EXCLUSIVE);
+ }
+ m_action= action_arg;
return FALSE;
}
@@ -3992,11 +3892,6 @@ Open_table_context::
recover_from_failed_open(THD *thd)
{
bool result= FALSE;
- /*
- Remove reference to released ticket from MDL_request.
- */
- if (m_global_mdl_request)
- m_global_mdl_request->ticket= NULL;
/* Execute the action. */
switch (m_action)
{
@@ -4008,19 +3903,9 @@ recover_from_failed_open(THD *thd)
break;
case OT_DISCOVER:
{
- MDL_request mdl_global_request;
- MDL_request mdl_xlock_request(&m_failed_table->mdl_request);
- MDL_request_list mdl_requests;
-
- mdl_global_request.init(MDL_key::GLOBAL, "", "",
- MDL_INTENTION_EXCLUSIVE);
- mdl_xlock_request.set_type(MDL_EXCLUSIVE);
-
- mdl_requests.push_front(&mdl_xlock_request);
- mdl_requests.push_front(&mdl_global_request);
-
- if ((result=
- thd->mdl_context.acquire_locks(&mdl_requests, get_timeout())))
+ if ((result= lock_table_names(thd, m_failed_table, NULL,
+ get_timeout(),
+ MYSQL_OPEN_SKIP_TEMPORARY)))
break;
mysql_mutex_lock(&LOCK_open);
@@ -4037,19 +3922,9 @@ recover_from_failed_open(THD *thd)
}
case OT_REPAIR:
{
- MDL_request mdl_global_request;
- MDL_request mdl_xlock_request(&m_failed_table->mdl_request);
- MDL_request_list mdl_requests;
-
- mdl_global_request.init(MDL_key::GLOBAL, "", "",
- MDL_INTENTION_EXCLUSIVE);
- mdl_xlock_request.set_type(MDL_EXCLUSIVE);
-
- mdl_requests.push_front(&mdl_xlock_request);
- mdl_requests.push_front(&mdl_global_request);
-
- if ((result=
- thd->mdl_context.acquire_locks(&mdl_requests, get_timeout())))
+ if ((result= lock_table_names(thd, m_failed_table, NULL,
+ get_timeout(),
+ MYSQL_OPEN_SKIP_TEMPORARY)))
break;
mysql_mutex_lock(&LOCK_open);
@@ -4320,6 +4195,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
bool error= FALSE;
bool safe_to_ignore_table= FALSE;
DBUG_ENTER("open_and_process_table");
+ DEBUG_SYNC(thd, "open_and_process_table");
/*
Ignore placeholders for derived tables. After derived tables
@@ -4543,32 +4419,40 @@ end:
DBUG_RETURN(error);
}
+extern "C" uchar *schema_set_get_key(const uchar *record, size_t *length,
+ my_bool not_used __attribute__((unused)))
+{
+ TABLE_LIST *table=(TABLE_LIST*) record;
+ *length= table->db_length;
+ return (uchar*) table->db;
+}
/**
- Acquire upgradable (SNW, SNRW) metadata locks on tables to be opened
- for LOCK TABLES or a DDL statement. Under LOCK TABLES, we can't take
+ Acquire upgradable (SNW, SNRW) metadata locks on tables used by
+ LOCK TABLES or by a DDL statement. Under LOCK TABLES, we can't take
new locks, so use open_tables_check_upgradable_mdl() instead.
- @param thd Thread context.
- @param tables_start Start of list of tables on which upgradable locks
- should be acquired.
- @param tables_end End of list of tables.
- @param ot_ctx Context of open_tables() operation.
- @param flags Bitmap of flags to modify how the tables will be
- open, see open_table() description for details.
+ @param thd Thread context.
+ @param tables_start Start of list of tables on which upgradable locks
+ should be acquired.
+ @param tables_end End of list of tables.
+ @param lock_wait_timeout Seconds to wait before timeout.
+ @param flags Bitmap of flags to modify how the tables will be
+ open, see open_table() description for details.
@retval FALSE Success.
@retval TRUE Failure (e.g. connection was killed)
*/
-static bool
-open_tables_acquire_upgradable_mdl(THD *thd, TABLE_LIST *tables_start,
- TABLE_LIST *tables_end,
- Open_table_context *ot_ctx,
- uint flags)
+bool
+lock_table_names(THD *thd,
+ TABLE_LIST *tables_start, TABLE_LIST *tables_end,
+ ulong lock_wait_timeout, uint flags)
{
MDL_request_list mdl_requests;
TABLE_LIST *table;
+ MDL_request global_request;
+ Hash_set<TABLE_LIST, schema_set_get_key> schema_set;
DBUG_ASSERT(!thd->locked_tables_mode);
@@ -4581,30 +4465,37 @@ open_tables_acquire_upgradable_mdl(THD *thd, TABLE_LIST *tables_start,
(table->open_type != OT_BASE_ONLY &&
! (flags & MYSQL_OPEN_SKIP_TEMPORARY) &&
find_temporary_table(thd, table))))
+ {
+ if (schema_set.insert(table))
+ return TRUE;
mdl_requests.push_front(&table->mdl_request);
+ }
}
if (! mdl_requests.is_empty())
{
- DEBUG_SYNC(thd, "open_tables_acquire_upgradable_mdl");
-
- MDL_request *global_request= ot_ctx->get_global_mdl_request(thd);
-
- if (global_request == NULL)
- return TRUE;
- mdl_requests.push_front(global_request);
+ /*
+ Scoped locks: Take intention exclusive locks on all involved
+ schemas.
+ */
+ Hash_set<TABLE_LIST, schema_set_get_key>::Iterator it(schema_set);
+ while ((table= it++))
+ {
+ MDL_request *schema_request= new (thd->mem_root) MDL_request;
+ if (schema_request == NULL)
+ return TRUE;
+ schema_request->init(MDL_key::SCHEMA, table->db, "",
+ MDL_INTENTION_EXCLUSIVE);
+ mdl_requests.push_front(schema_request);
+ }
+ /* Take the global intention exclusive lock. */
+ global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
+ mdl_requests.push_front(&global_request);
}
- if (thd->mdl_context.acquire_locks(&mdl_requests, ot_ctx->get_timeout()))
+ if (thd->mdl_context.acquire_locks(&mdl_requests, lock_wait_timeout))
return TRUE;
- for (table= tables_start; table && table != tables_end;
- table= table->next_global)
- {
- if (table->mdl_request.type >= MDL_SHARED_NO_WRITE)
- table->mdl_request.ticket= NULL;
- }
-
return FALSE;
}
@@ -4776,12 +4667,21 @@ restart:
goto err;
}
}
- else if (open_tables_acquire_upgradable_mdl(thd, *start,
- thd->lex->first_not_own_table(),
- &ot_ctx, flags))
+ else
{
- error= TRUE;
- goto err;
+ TABLE_LIST *table;
+ if (lock_table_names(thd, *start, thd->lex->first_not_own_table(),
+ ot_ctx.get_timeout(), flags))
+ {
+ error= TRUE;
+ goto err;
+ }
+ for (table= *start; table && table != thd->lex->first_not_own_table();
+ table= table->next_global)
+ {
+ if (table->mdl_request.type >= MDL_SHARED_NO_WRITE)
+ table->mdl_request.ticket= NULL;
+ }
}
}
@@ -5354,6 +5254,8 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type,
table= 0;
end:
+ if (table == NULL)
+ close_thread_tables(thd);
thd_proc_info(thd, 0);
DBUG_RETURN(table);
}
@@ -5372,7 +5274,8 @@ end:
should work for this statement.
@note
- The lock will automaticaly be freed by close_thread_tables()
+ The thr_lock locks will automatically be freed by
+ close_thread_tables().
@retval FALSE OK.
@retval TRUE Error
@@ -5383,11 +5286,12 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
Prelocking_strategy *prelocking_strategy)
{
uint counter;
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("open_and_lock_tables");
DBUG_PRINT("enter", ("derived handling: %d", derived));
if (open_tables(thd, &tables, &counter, flags, prelocking_strategy))
- DBUG_RETURN(TRUE);
+ goto err;
DBUG_EXECUTE_IF("sleep_open_and_lock_after_open", {
const char *old_proc_info= thd->proc_info;
@@ -5396,15 +5300,22 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
thd->proc_info= old_proc_info;});
if (lock_tables(thd, tables, counter, flags))
- DBUG_RETURN(TRUE);
+ goto err;
if (derived &&
(mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
(thd->fill_derived_tables() &&
mysql_handle_derived(thd->lex, &mysql_derived_filling))))
- DBUG_RETURN(TRUE); /* purecov: inspected */
+ goto err;
DBUG_RETURN(FALSE);
+err:
+ if (! thd->in_sub_stmt)
+ trans_rollback_stmt(thd); /* Necessary if derived handling failed. */
+ close_thread_tables(thd);
+ /* Don't keep locks for a failed statement. */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+ DBUG_RETURN(TRUE);
}
@@ -5430,13 +5341,24 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags)
{
+ DML_prelocking_strategy prelocking_strategy;
uint counter;
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("open_normal_and_derived_tables");
DBUG_ASSERT(!thd->fill_derived_tables());
- if (open_tables(thd, &tables, &counter, flags) ||
+ if (open_tables(thd, &tables, &counter, flags, &prelocking_strategy) ||
mysql_handle_derived(thd->lex, &mysql_derived_prepare))
- DBUG_RETURN(TRUE); /* purecov: inspected */
+ goto end;
+
DBUG_RETURN(0);
+end:
+ /* No need to rollback statement transaction, it's not started. */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
+ close_thread_tables(thd);
+ /* Don't keep locks for a failed statement. */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+
+ DBUG_RETURN(TRUE); /* purecov: inspected */
}
@@ -5453,11 +5375,25 @@ bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags)
or schema tables) as free for reuse.
*/
-static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table)
+static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table_list)
{
- for (; table; table= table->next_global)
+ TABLE_LIST *table;
+ for (table= table_list; table; table= table->next_global)
if (!table->placeholder())
+ {
table->table->query_id= 0;
+ }
+ for (table= table_list; table; table= table->next_global)
+ if (!table->placeholder())
+ {
+ /*
+ Detach children of MyISAMMRG tables used in
+ sub-statements, they will be reattached at open.
+ This has to be done in a separate loop to make sure
+ that children have had their query_id cleared.
+ */
+ table->table->file->extra(HA_EXTRA_DETACH_CHILDREN);
+ }
}
@@ -5683,6 +5619,14 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
/* We have to cleanup translation tables of views. */
tmp->cleanup_items();
}
+ /*
+ No need to commit/rollback the statement transaction: it's
+ either not started or we're filling in an INFORMATION_SCHEMA
+ table on the fly, and thus mustn't manipulate with the
+ transaction of the enclosing statement.
+ */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty() ||
+ (thd->state_flags & Open_tables_state::BACKUPS_AVAIL));
close_thread_tables(thd);
thd->mdl_context.rollback_to_savepoint(start_of_statement_svp);
}
@@ -8750,6 +8694,7 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
automatically deleted once it is no longer referenced.
*/
share->version= 0;
+
while ((table= it++))
free_cache_entry(table);
}
@@ -9103,7 +9048,8 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
MYSQL_LOCK_IGNORE_TIMEOUT))
{
lex->restore_backup_query_tables_list(&query_tables_list_backup);
- goto error;
+ thd->restore_backup_open_tables_state(backup);
+ DBUG_RETURN(TRUE);
}
for (TABLE_LIST *tables= table_list; tables; tables= tables->next_global)
@@ -9114,11 +9060,6 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
lex->restore_backup_query_tables_list(&query_tables_list_backup);
DBUG_RETURN(FALSE);
-
-error:
- close_system_tables(thd, backup);
-
- DBUG_RETURN(TRUE);
}
@@ -9141,6 +9082,38 @@ close_system_tables(THD *thd, Open_tables_backup *backup)
}
+/**
+ A helper function to close a mysql.* table opened
+ in an auxiliary THD during bootstrap or in the main
+ connection, when we know that there are no locks
+ held by the connection due to a preceding implicit
+ commit.
+
+ This function assumes that there is no
+ statement transaction started for the operation
+ itself, since mysql.* tables are not transactional
+ and when they are used the binlog is off (DDL
+ binlogging is always statement-based.
+
+ We need this function since we'd like to not
+ just close the system table, but also release
+ the metadata lock on it.
+
+ Note, that in LOCK TABLES mode this function
+ does not release the metadata lock. But in this
+ mode the table can be opened only if it is locked
+ explicitly with LOCK TABLES.
+*/
+
+void
+close_mysql_tables(THD *thd)
+{
+ /* No need to commit/rollback statement transaction, it's not started. */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
+ close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
+}
+
/*
Open and lock one system table for update.
@@ -9212,16 +9185,7 @@ open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup)
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
}
else
- {
- /*
- If error in mysql_lock_tables(), open_ltable doesn't close the
- table. Thread kill during mysql_lock_tables() is such error. But
- open tables cannot be accepted when restoring the open tables
- state.
- */
- close_thread_tables(thd);
thd->restore_backup_open_tables_state(backup);
- }
thd->utime_after_lock= save_utime_after_lock;
DBUG_RETURN(table);
diff --git a/sql/sql_base.h b/sql/sql_base.h
index 20a068e27d7..45f1408e2f5 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -203,8 +203,9 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
COND **conds);
int setup_ftfuncs(SELECT_LEX* select);
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
-void wait_for_condition(THD *thd, mysql_mutex_t *mutex,
- mysql_cond_t *cond);
+bool lock_table_names(THD *thd, TABLE_LIST *table_list,
+ TABLE_LIST *table_list_end, ulong lock_wait_timeout,
+ uint flags);
bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags,
Prelocking_strategy *prelocking_strategy);
/* open_and_lock_tables with optional derived handling */
@@ -222,7 +223,7 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables);
void free_io_cache(TABLE *entry);
void intern_close_table(TABLE *entry);
bool close_thread_table(THD *thd, TABLE **table_ptr);
-void close_temporary_tables(THD *thd);
+bool close_temporary_tables(THD *thd);
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
bool check_alias);
int drop_temporary_table(THD *thd, TABLE_LIST *table_list);
@@ -239,6 +240,7 @@ bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
Open_tables_backup *backup);
void close_system_tables(THD *thd, Open_tables_backup *backup);
+void close_mysql_tables(THD *thd);
TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup);
void close_log_table(THD *thd, Open_tables_backup *backup);
@@ -480,8 +482,6 @@ public:
return m_start_of_statement_svp;
}
- MDL_request *get_global_mdl_request(THD *thd);
-
inline ulong get_timeout() const
{
return m_timeout;
@@ -499,11 +499,6 @@ private:
TABLE_LIST *m_failed_table;
MDL_ticket *m_start_of_statement_svp;
/**
- Request object for global intention exclusive lock which is acquired during
- opening tables for statements which take upgradable shared metadata locks.
- */
- MDL_request *m_global_mdl_request;
- /**
Lock timeout in seconds. Initialized to LONG_TIMEOUT when opening system
tables or to the "lock_wait_timeout" system variable for regular tables.
*/
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index eb4d353db81..60a871e9e88 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -29,7 +29,6 @@
#include "sql_priv.h"
#include "unireg.h" // REQUIRED: for other includes
#include "sql_class.h"
-#include "lock.h" // unlock_global_read_lock, mysql_unlock_tables
#include "sql_cache.h" // query_cache_abort
#include "sql_base.h" // close_thread_tables
#include "sql_time.h" // date_time_format_copy
@@ -491,7 +490,6 @@ THD::THD()
:Statement(&main_lex, &main_mem_root, CONVENTIONAL_EXECUTION,
/* statement id */ 0),
rli_fake(0),
- lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
binlog_unsafe_warning_flags(0),
stmt_accessed_table_flag(0),
@@ -625,7 +623,6 @@ THD::THD()
randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::global_query_id);
substitute_null_with_insert_id = FALSE;
thr_lock_info_init(&lock_info); /* safety: will be reset after start */
- thr_lock_owner_init(&main_lock_id, &lock_info);
m_internal_handler= NULL;
current_user_used= FALSE;
@@ -848,35 +845,6 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno,
}
}
- /*
- If a continue handler is found, the error message will be cleared
- by the stored procedures code.
- */
- if (!is_fatal_error && spcont &&
- spcont->handle_condition(this, sql_errno, sqlstate, level, msg, &cond))
- {
- /*
- Do not push any warnings, a handled error must be completely
- silenced.
- */
- DBUG_RETURN(cond);
- }
-
- /* Un-handled conditions */
-
- cond= raise_condition_no_handler(sql_errno, sqlstate, level, msg);
- DBUG_RETURN(cond);
-}
-
-MYSQL_ERROR*
-THD::raise_condition_no_handler(uint sql_errno,
- const char* sqlstate,
- MYSQL_ERROR::enum_warning_level level,
- const char* msg)
-{
- MYSQL_ERROR *cond= NULL;
- DBUG_ENTER("THD::raise_condition_no_handler");
-
query_cache_abort(&query_cache_tls);
/* FIXME: broken special case */
@@ -889,6 +857,7 @@ THD::raise_condition_no_handler(uint sql_errno,
cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
DBUG_RETURN(cond);
}
+
extern "C"
void *thd_alloc(MYSQL_THD thd, unsigned int size)
{
@@ -1114,7 +1083,6 @@ THD::~THD()
}
#endif
stmt_map.reset(); /* close all prepared statements */
- DBUG_ASSERT(lock_info.n_cursors == 0);
if (!cleanup_done)
cleanup();
@@ -1741,9 +1709,9 @@ bool select_send::send_result_set_metadata(List<Item> &list, uint flags)
return res;
}
-void select_send::abort()
+void select_send::abort_result_set()
{
- DBUG_ENTER("select_send::abort");
+ DBUG_ENTER("select_send::abort_result_set");
if (is_result_set_started && thd->spcont)
{
@@ -1817,12 +1785,6 @@ bool select_send::send_eof()
*/
ha_release_temporary_latches(thd);
- /* Unlock tables before sending packet to gain some speed */
- if (thd->lock && ! thd->locked_tables_mode)
- {
- mysql_unlock_tables(thd, thd->lock);
- thd->lock=0;
- }
/*
Don't send EOF if we're in error condition (which implies we've already
sent or are sending an error)
@@ -2596,7 +2558,6 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
id(id_arg),
mark_used_columns(MARK_COLUMNS_READ),
lex(lex_arg),
- cursor(0),
db(NULL),
db_length(0)
{
@@ -2618,7 +2579,6 @@ void Statement::set_statement(Statement *stmt)
mark_used_columns= stmt->mark_used_columns;
lex= stmt->lex;
query_string= stmt->query_string;
- cursor= stmt->cursor;
}
@@ -4171,71 +4131,6 @@ THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
Update_rows_log_event *);
#endif
-#ifdef NOT_USED
-static char const*
-field_type_name(enum_field_types type)
-{
- switch (type) {
- case MYSQL_TYPE_DECIMAL:
- return "MYSQL_TYPE_DECIMAL";
- case MYSQL_TYPE_TINY:
- return "MYSQL_TYPE_TINY";
- case MYSQL_TYPE_SHORT:
- return "MYSQL_TYPE_SHORT";
- case MYSQL_TYPE_LONG:
- return "MYSQL_TYPE_LONG";
- case MYSQL_TYPE_FLOAT:
- return "MYSQL_TYPE_FLOAT";
- case MYSQL_TYPE_DOUBLE:
- return "MYSQL_TYPE_DOUBLE";
- case MYSQL_TYPE_NULL:
- return "MYSQL_TYPE_NULL";
- case MYSQL_TYPE_TIMESTAMP:
- return "MYSQL_TYPE_TIMESTAMP";
- case MYSQL_TYPE_LONGLONG:
- return "MYSQL_TYPE_LONGLONG";
- case MYSQL_TYPE_INT24:
- return "MYSQL_TYPE_INT24";
- case MYSQL_TYPE_DATE:
- return "MYSQL_TYPE_DATE";
- case MYSQL_TYPE_TIME:
- return "MYSQL_TYPE_TIME";
- case MYSQL_TYPE_DATETIME:
- return "MYSQL_TYPE_DATETIME";
- case MYSQL_TYPE_YEAR:
- return "MYSQL_TYPE_YEAR";
- case MYSQL_TYPE_NEWDATE:
- return "MYSQL_TYPE_NEWDATE";
- case MYSQL_TYPE_VARCHAR:
- return "MYSQL_TYPE_VARCHAR";
- case MYSQL_TYPE_BIT:
- return "MYSQL_TYPE_BIT";
- case MYSQL_TYPE_NEWDECIMAL:
- return "MYSQL_TYPE_NEWDECIMAL";
- case MYSQL_TYPE_ENUM:
- return "MYSQL_TYPE_ENUM";
- case MYSQL_TYPE_SET:
- return "MYSQL_TYPE_SET";
- case MYSQL_TYPE_TINY_BLOB:
- return "MYSQL_TYPE_TINY_BLOB";
- case MYSQL_TYPE_MEDIUM_BLOB:
- return "MYSQL_TYPE_MEDIUM_BLOB";
- case MYSQL_TYPE_LONG_BLOB:
- return "MYSQL_TYPE_LONG_BLOB";
- case MYSQL_TYPE_BLOB:
- return "MYSQL_TYPE_BLOB";
- case MYSQL_TYPE_VAR_STRING:
- return "MYSQL_TYPE_VAR_STRING";
- case MYSQL_TYPE_STRING:
- return "MYSQL_TYPE_STRING";
- case MYSQL_TYPE_GEOMETRY:
- return "MYSQL_TYPE_GEOMETRY";
- }
- return "Unknown";
-}
-#endif
-
-
/* Declare in unnamed namespace. */
CPP_UNNAMED_NS_START
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c095fee6232..b23b65dae2f 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -38,7 +38,7 @@
#include "protocol.h" /* Protocol_text, Protocol_binary */
#include "violite.h" /* vio_is_connected */
#include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA,
- THR_LOCK_INFO, THR_LOCK_OWNER */
+ THR_LOCK_INFO */
class Reprepare_observer;
@@ -723,7 +723,6 @@ public:
ENGINE INNODB STATUS.
*/
LEX_STRING query_string;
- Server_side_cursor *cursor;
inline char *query() { return query_string.str; }
inline uint32 query_length() { return query_string.length; }
@@ -1416,9 +1415,6 @@ public:
struct system_status_var status_var; // Per thread statistic vars
struct system_status_var *initial_status_var; /* used by show status */
THR_LOCK_INFO lock_info; // Locking info of this thread
- THR_LOCK_OWNER main_lock_id; // To use for conventional queries
- THR_LOCK_OWNER *lock_id; // If not main_lock_id, points to
- // the lock_id of a cursor.
/**
Protects THD data accessed from other threads:
- thd->query and thd->query_length (used by SHOW ENGINE
@@ -2804,23 +2800,6 @@ private:
MYSQL_ERROR::enum_warning_level level,
const char* msg);
- /**
- Raise a generic SQL condition, without activation any SQL condition
- handlers.
- This method is necessary to support the RESIGNAL statement,
- which is allowed to bypass SQL exception handlers.
- @param sql_errno the condition error number
- @param sqlstate the condition SQLSTATE
- @param level the condition level
- @param msg the condition message text
- @return The condition raised, or NULL
- */
- MYSQL_ERROR*
- raise_condition_no_handler(uint sql_errno,
- const char* sqlstate,
- MYSQL_ERROR::enum_warning_level level,
- const char* msg);
-
public:
/** Overloaded to guard query/query_length fields */
virtual void set_statement(Statement *stmt);
@@ -2991,7 +2970,7 @@ public:
@retval TRUE error, an error message is set
*/
virtual bool check_simple_select() const;
- virtual void abort() {}
+ virtual void abort_result_set() {}
/*
Cleanup instance of this class for next execution of a prepared
statement/stored procedure.
@@ -3034,7 +3013,7 @@ public:
bool send_data(List<Item> &items);
bool send_eof();
virtual bool check_simple_select() const { return FALSE; }
- void abort();
+ void abort_result_set();
virtual void cleanup();
};
@@ -3126,7 +3105,7 @@ class select_insert :public select_result_interceptor {
virtual bool can_rollback_data() { return 0; }
void send_error(uint errcode,const char *err);
bool send_eof();
- void abort();
+ virtual void abort_result_set();
/* not implemented: select_insert is never re-used in prepared statements */
void cleanup();
};
@@ -3162,7 +3141,7 @@ public:
void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);
bool send_eof();
- void abort();
+ virtual void abort_result_set();
virtual bool can_rollback_data() { return 1; }
// Needed for access from local class MY_HOOKS in prepare(), since thd is proteted.
@@ -3496,7 +3475,7 @@ public:
{
return deleted;
}
- virtual void abort();
+ virtual void abort_result_set();
};
@@ -3547,7 +3526,7 @@ public:
{
return updated;
}
- virtual void abort();
+ virtual void abort_result_set();
};
class my_var : public Sql_alloc {
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 123b1cd1ec9..7a9834b4cde 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -19,7 +19,6 @@
#include "sql_priv.h"
#include "unireg.h"
#include "sql_cursor.h"
-#include "sql_select.h"
#include "probes_mysql.h"
#include "sql_parse.h" // mysql_execute_command
@@ -28,51 +27,6 @@
****************************************************************************/
/**
- Sensitive_cursor -- a sensitive non-materialized server side
- cursor. An instance of this class cursor has its own runtime
- state -- list of used items and memory root for runtime memory,
- open and locked tables, change list for the changes of the
- parsed tree. This state is freed when the cursor is closed.
-*/
-
-class Sensitive_cursor: public Server_side_cursor
-{
- MEM_ROOT main_mem_root;
- Query_arena *stmt_arena;
- JOIN *join;
- TABLE *open_tables;
- MYSQL_LOCK *lock;
- TABLE *derived_tables;
- /* List of items created during execution */
- query_id_t query_id;
- struct Engine_info
- {
- handlerton *ht;
- void *read_view;
- };
- Engine_info ht_info[MAX_HA];
- Item_change_list change_list;
- my_bool close_at_commit;
- THR_LOCK_OWNER lock_id;
-private:
- /* bzero cursor state in THD */
- void reset_thd(THD *thd);
-public:
- Sensitive_cursor(THD *thd, select_result *result_arg);
-
- THR_LOCK_OWNER *get_lock_id() { return &lock_id; }
- /* Save THD state into cursor */
- void post_open(THD *thd);
-
- virtual bool is_open() const { return join != 0; }
- virtual int open(JOIN *join);
- virtual void fetch(ulong num_rows);
- virtual void close();
- virtual ~Sensitive_cursor();
-};
-
-
-/**
Materialized_cursor -- an insensitive materialized server-side
cursor. The result set of this cursor is saved in a temporary
table at open. The cursor itself is simply an interface for the
@@ -124,10 +78,9 @@ public:
/**************************************************************************/
/**
- Attempt to open a materialized or non-materialized cursor.
+ Attempt to open a materialized cursor.
@param thd thread handle
- @param[in] flags create a materialized cursor or not
@param[in] result result class of the caller used as a destination
for the rows fetched from the cursor
@param[out] pcursor a pointer to store a pointer to cursor in
@@ -140,37 +93,21 @@ public:
non-zero an error, 'pcursor' has been left intact.
*/
-int mysql_open_cursor(THD *thd, uint flags, select_result *result,
+int mysql_open_cursor(THD *thd, select_result *result,
Server_side_cursor **pcursor)
{
- Sensitive_cursor *sensitive_cursor;
select_result *save_result;
Select_materialize *result_materialize;
LEX *lex= thd->lex;
int rc;
- /*
- The lifetime of the sensitive cursor is the same or less as the
- lifetime of the runtime memory of the statement it's opened for.
- */
if (! (result_materialize= new (thd->mem_root) Select_materialize(result)))
return 1;
- if (! (sensitive_cursor= new (thd->mem_root) Sensitive_cursor(thd, result)))
- {
- delete result_materialize;
- result_materialize= NULL;
- return 1;
- }
-
save_result= lex->result;
lex->result= result_materialize;
- if (! (flags & (uint) ALWAYS_MATERIALIZED_CURSOR))
- {
- thd->lock_id= sensitive_cursor->get_lock_id();
- thd->cursor= sensitive_cursor;
- }
+
MYSQL_QUERY_EXEC_START(thd->query(),
thd->thread_id,
(char *) (thd->db ? thd->db : ""),
@@ -181,20 +118,14 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result,
MYSQL_QUERY_EXEC_DONE(rc);
lex->result= save_result;
- thd->lock_id= &thd->main_lock_id;
- thd->cursor= 0;
-
/*
Possible options here:
- - a sensitive cursor is open. In this case rc is 0 and
- result_materialize->materialized_cursor is NULL, or
- a materialized cursor is open. In this case rc is 0 and
result_materialize->materialized is not NULL
- an error occurred during materialization.
result_materialize->materialized_cursor is not NULL, but rc != 0
- successful completion of mysql_execute_command without
- a cursor: rc is 0, result_materialize->materialized_cursor is NULL,
- sensitive_cursor is not open.
+ a cursor: rc is 0, result_materialize->materialized_cursor is NULL.
This is possible if some command writes directly to the
network, bypassing select_result mechanism. An example of
such command is SHOW VARIABLES or SHOW STATUS.
@@ -203,23 +134,10 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result,
{
if (result_materialize->materialized_cursor)
delete result_materialize->materialized_cursor;
- goto err_open;
- }
-
- if (sensitive_cursor->is_open())
- {
- DBUG_ASSERT(!result_materialize->materialized_cursor);
- /*
- It's safer if we grab THD state after mysql_execute_command
- is finished and not in Sensitive_cursor::open(), because
- currently the call to Sensitive_cursor::open is buried deep
- in JOIN::exec of the top level join.
- */
- sensitive_cursor->post_open(thd);
- *pcursor= sensitive_cursor;
goto end;
}
- else if (result_materialize->materialized_cursor)
+
+ if (result_materialize->materialized_cursor)
{
Materialized_cursor *materialized_cursor=
result_materialize->materialized_cursor;
@@ -227,18 +145,13 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result,
if ((rc= materialized_cursor->open(0)))
{
delete materialized_cursor;
- materialized_cursor= NULL;
- goto err_open;
+ goto end;
}
*pcursor= materialized_cursor;
thd->stmt_arena->cleanup_stmt();
- goto end;
}
-err_open:
- DBUG_ASSERT(! (sensitive_cursor && sensitive_cursor->is_open()));
- delete sensitive_cursor;
end:
delete result_materialize;
return rc;
@@ -270,279 +183,6 @@ void Server_side_cursor::operator delete(void *ptr, size_t size)
DBUG_VOID_RETURN;
}
-/****************************************************************************
- Sensitive_cursor
-****************************************************************************/
-
-Sensitive_cursor::Sensitive_cursor(THD *thd, select_result *result_arg)
- :Server_side_cursor(&main_mem_root, result_arg),
- stmt_arena(0),
- join(0),
- close_at_commit(FALSE)
-{
- /* We will overwrite it at open anyway. */
- init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
- thr_lock_owner_init(&lock_id, &thd->lock_info);
- bzero((void*) ht_info, sizeof(ht_info));
-}
-
-
-/**
- Save THD state into cursor.
-
- @todo
- - What problems can we have with it if cursor is open?
- - TODO: must be fixed because of the prelocked mode.
-*/
-void
-Sensitive_cursor::post_open(THD *thd)
-{
- Engine_info *info;
- /*
- We need to save and reset thd->mem_root, otherwise it'll be
- freed later in mysql_parse.
-
- We can't just change thd->mem_root here as we want to keep the
- things that are already allocated in thd->mem_root for
- Sensitive_cursor::fetch()
- */
- *mem_root= *thd->mem_root;
- stmt_arena= thd->stmt_arena;
- state= stmt_arena->state;
- /* Allocate a new memory root for thd */
- init_sql_alloc(thd->mem_root,
- thd->variables.query_alloc_block_size,
- thd->variables.query_prealloc_size);
-
- /*
- Save tables and zero THD pointers to prevent table close in
- close_thread_tables.
- */
- derived_tables= thd->derived_tables;
- open_tables= thd->open_tables;
- lock= thd->lock;
- query_id= thd->query_id;
- free_list= thd->free_list;
- thd->change_list.move_elements_to(&change_list);
- reset_thd(thd);
- /* Now we have an active cursor and can cause a deadlock */
- thd->lock_info.n_cursors++;
-
- close_at_commit= FALSE; /* reset in case we're reusing the cursor */
- info= &ht_info[0];
- for (Ha_trx_info *ha_trx_info= thd->transaction.stmt.ha_list;
- ha_trx_info; ha_trx_info= ha_trx_info->next())
- {
- handlerton *ht= ha_trx_info->ht();
- close_at_commit|= test(ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
- if (ht->create_cursor_read_view)
- {
- info->ht= ht;
- info->read_view= (ht->create_cursor_read_view)(ht, thd);
- ++info;
- }
- }
- /*
- What problems can we have with it if cursor is open?
- TODO: must be fixed because of the prelocked mode.
- */
-}
-
-
-/**
- bzero cursor state in THD.
-*/
-
-void
-Sensitive_cursor::reset_thd(THD *thd)
-{
- thd->derived_tables= 0;
- thd->set_open_tables(NULL);
- thd->lock= 0;
- thd->free_list= 0;
- thd->change_list.empty();
-}
-
-
-int
-Sensitive_cursor::open(JOIN *join_arg)
-{
- join= join_arg;
- THD *thd= join->thd;
- /* First non-constant table */
- JOIN_TAB *join_tab= join->join_tab + join->const_tables;
- DBUG_ENTER("Sensitive_cursor::open");
-
- join->change_result(result);
- /*
- Send fields description to the client; server_status is sent
- in 'EOF' packet, which follows send_result_set_metadata().
- We don't simply use SEND_EOF flag of send_result_set_metadata because we also
- want to flush the network buffer, which is done only in a standalone
- send_eof().
- */
- result->send_result_set_metadata(*join->fields, Protocol::SEND_NUM_ROWS);
- thd->server_status|= SERVER_STATUS_CURSOR_EXISTS;
- result->send_eof();
- thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS;
-
- /* Prepare JOIN for reading rows. */
- join->tmp_table= 0;
- join->join_tab[join->tables-1].next_select= setup_end_select_func(join);
- join->send_records= 0;
- join->fetch_limit= join->unit->offset_limit_cnt;
-
- /* Disable JOIN CACHE as it is not working with cursors yet */
- for (JOIN_TAB *tab= join_tab;
- tab != join->join_tab + join->tables - 1;
- tab++)
- {
- if (tab->next_select == sub_select_cache)
- tab->next_select= sub_select;
- }
-
- DBUG_ASSERT(join_tab->table->reginfo.not_exists_optimize == 0);
- DBUG_ASSERT(join_tab->not_used_in_distinct == 0);
- /*
- null_row is set only if row not found and it's outer join: should never
- happen for the first table in join_tab list
- */
- DBUG_ASSERT(join_tab->table->null_row == 0);
- DBUG_RETURN(0);
-}
-
-
-/**
- Fetch next num_rows rows from the cursor and send them to the client.
-
- Precondition:
- - Sensitive_cursor is open
-
- @param num_rows fetch up to this number of rows (maybe less)
-*/
-
-void
-Sensitive_cursor::fetch(ulong num_rows)
-{
- THD *thd= join->thd;
- JOIN_TAB *join_tab= join->join_tab + join->const_tables;
- enum_nested_loop_state error= NESTED_LOOP_OK;
- Query_arena backup_arena;
- Engine_info *info;
- DBUG_ENTER("Sensitive_cursor::fetch");
- DBUG_PRINT("enter",("rows: %lu", num_rows));
-
- DBUG_ASSERT(thd->derived_tables == 0 && thd->open_tables == 0 &&
- thd->lock == 0);
-
- thd->derived_tables= derived_tables;
- thd->set_open_tables(open_tables);
- thd->lock= lock;
- thd->set_query_id(query_id);
- change_list.move_elements_to(&thd->change_list);
- /* save references to memory allocated during fetch */
- thd->set_n_backup_active_arena(this, &backup_arena);
-
- for (info= ht_info; info->read_view ; info++)
- (info->ht->set_cursor_read_view)(info->ht, thd, info->read_view);
-
- join->fetch_limit+= num_rows;
-
- error= sub_select(join, join_tab, 0);
- if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS)
- error= sub_select(join,join_tab,1);
- if (error == NESTED_LOOP_QUERY_LIMIT)
- error= NESTED_LOOP_OK; /* select_limit used */
- if (error == NESTED_LOOP_CURSOR_LIMIT)
- join->resume_nested_loop= TRUE;
-
- ha_release_temporary_latches(thd);
-
- /* Grab free_list here to correctly free it in close */
- thd->restore_active_arena(this, &backup_arena);
-
- thd->change_list.move_elements_to(&change_list);
- reset_thd(thd);
-
- for (info= ht_info; info->read_view; info++)
- (info->ht->set_cursor_read_view)(info->ht, thd, 0);
-
- if (error == NESTED_LOOP_CURSOR_LIMIT)
- {
- /* Fetch limit worked, possibly more rows are there */
- thd->server_status|= SERVER_STATUS_CURSOR_EXISTS;
- result->send_eof();
- thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS;
- }
- else
- {
- close();
- if (error == NESTED_LOOP_OK)
- {
- thd->server_status|= SERVER_STATUS_LAST_ROW_SENT;
- result->send_eof();
- thd->server_status&= ~SERVER_STATUS_LAST_ROW_SENT;
- }
- else if (error != NESTED_LOOP_KILLED)
- my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
- }
- DBUG_VOID_RETURN;
-}
-
-
-/**
- @todo
- Another hack: we need to set THD state as if in a fetch to be
- able to call stmt close.
-*/
-void
-Sensitive_cursor::close()
-{
- THD *thd= join->thd;
- DBUG_ENTER("Sensitive_cursor::close");
-
- for (Engine_info *info= ht_info; info->read_view; info++)
- {
- (info->ht->close_cursor_read_view)(info->ht, thd, info->read_view);
- info->read_view= 0;
- info->ht= 0;
- }
-
- change_list.move_elements_to(&thd->change_list);
- {
- /*
- XXX: Another hack: we need to set THD state as if in a fetch to be
- able to call stmt close.
- */
- DBUG_ASSERT(lock || open_tables || derived_tables);
-
- TABLE *tmp_derived_tables= thd->derived_tables;
- MYSQL_LOCK *tmp_lock= thd->lock;
-
- thd->set_open_tables(open_tables);
- thd->derived_tables= derived_tables;
- thd->lock= lock;
-
- /* Is expected to at least close tables and empty thd->change_list */
- stmt_arena->cleanup_stmt();
-
- thd->set_open_tables(tmp_derived_tables);
- thd->derived_tables= tmp_derived_tables;
- thd->lock= tmp_lock;
- }
- thd->lock_info.n_cursors--; /* Decrease the number of active cursors */
- join= 0;
- stmt_arena= 0;
- free_items();
- DBUG_VOID_RETURN;
-}
-
-
-Sensitive_cursor::~Sensitive_cursor()
-{
- if (is_open())
- close();
-}
/***************************************************************************
Materialized_cursor
@@ -568,7 +208,8 @@ Materialized_cursor::Materialized_cursor(select_result *result_arg,
@param send_result_set_metadata List of fields that would be sent.
*/
-int Materialized_cursor::fill_item_list(THD *thd, List<Item> &send_result_set_metadata)
+int Materialized_cursor::fill_item_list(THD *thd,
+ List<Item> &send_result_set_metadata)
{
Query_arena backup_arena;
int rc;
@@ -606,6 +247,7 @@ end:
return rc || thd->is_error();
}
+
int Materialized_cursor::open(JOIN *join __attribute__((unused)))
{
THD *thd= fake_unit.thd;
diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h
index 2a394e281b4..ed7bfac821a 100644
--- a/sql/sql_cursor.h
+++ b/sql/sql_cursor.h
@@ -32,11 +32,11 @@ class JOIN;
*/
/**
- Server_side_cursor -- an interface for materialized and
- sensitive (non-materialized) implementation of cursors. All
- cursors are self-contained (created in their own memory root).
- For that reason they must be deleted only using a pointer to
- Server_side_cursor, not to its base class.
+ Server_side_cursor -- an interface for materialized
+ implementation of cursors. All cursors are self-contained
+ (created in their own memory root). For that reason they must
+ be deleted only using a pointer to Server_side_cursor, not to
+ its base class.
*/
class Server_side_cursor: protected Query_arena, public Sql_alloc
@@ -60,11 +60,7 @@ public:
};
-int mysql_open_cursor(THD *thd, uint flags,
- select_result *result,
+int mysql_open_cursor(THD *thd, select_result *result,
Server_side_cursor **res);
-/** Possible values for flags */
-enum { ANY_CURSOR= 1, ALWAYS_MATERIALIZED_CURSOR= 2 };
-
#endif /* _sql_cusor_h_ */
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 1040fc92851..517cb9139e9 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -21,14 +21,12 @@
#include "unireg.h"
#include "sql_db.h"
#include "sql_cache.h" // query_cache_*
-#include "lock.h" // wait_if_global_read_lock,
- // start_waiting_global_read_lock
+#include "lock.h" // lock_schema_name
#include "sql_table.h" // build_table_filename,
// filename_to_tablename
#include "sql_rename.h" // mysql_rename_tables
#include "sql_acl.h" // SELECT_ACL, DB_ACLS,
// acl_get, check_grant_db
-#include "sql_base.h" // wait_for_condition
#include "log_event.h" // Query_log_event
#include <mysys_err.h>
#include "sp.h"
@@ -58,106 +56,6 @@ static void mysql_change_db_impl(THD *thd,
CHARSET_INFO *new_db_charset);
-/* Database lock hash */
-HASH lock_db_cache;
-mysql_mutex_t LOCK_lock_db;
-int creating_database= 0; // how many database locks are made
-
-
-/* Structure for database lock */
-typedef struct my_dblock_st
-{
- char *name; /* Database name */
- uint name_length; /* Database length name */
-} my_dblock_t;
-
-
-/*
- lock_db key.
-*/
-
-extern "C" uchar* lock_db_get_key(my_dblock_t *, size_t *, my_bool not_used);
-
-uchar* lock_db_get_key(my_dblock_t *ptr, size_t *length,
- my_bool not_used __attribute__((unused)))
-{
- *length= ptr->name_length;
- return (uchar*) ptr->name;
-}
-
-
-/*
- Free lock_db hash element.
-*/
-
-extern "C" void lock_db_free_element(void *ptr);
-
-void lock_db_free_element(void *ptr)
-{
- my_free(ptr);
-}
-
-
-/*
- Put a database lock entry into the hash.
-
- DESCRIPTION
- Insert a database lock entry into hash.
- LOCK_db_lock must be previously locked.
-
- RETURN VALUES
- 0 on success.
- 1 on error.
-*/
-
-static my_bool lock_db_insert(const char *dbname, uint length)
-{
- my_dblock_t *opt;
- my_bool error= 0;
- DBUG_ENTER("lock_db_insert");
-
- mysql_mutex_assert_owner(&LOCK_lock_db);
-
- if (!(opt= (my_dblock_t*) my_hash_search(&lock_db_cache,
- (uchar*) dbname, length)))
- {
- /* Db is not in the hash, insert it */
- char *tmp_name;
- if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1,
- NullS))
- {
- error= 1;
- goto end;
- }
-
- opt->name= tmp_name;
- strmov(opt->name, dbname);
- opt->name_length= length;
-
- if ((error= my_hash_insert(&lock_db_cache, (uchar*) opt)))
- my_free(opt);
- }
-
-end:
- DBUG_RETURN(error);
-}
-
-
-/*
- Delete a database lock entry from hash.
-*/
-
-void lock_db_delete(const char *name, uint length)
-{
- my_dblock_t *opt;
- mysql_mutex_assert_owner(&LOCK_lock_db);
- if ((opt= (my_dblock_t *)my_hash_search(&lock_db_cache,
- (const uchar*) name, length)))
- my_hash_delete(&lock_db_cache, (uchar*) opt);
-}
-
-
/* Database options hash */
static HASH dboptions;
static my_bool dboptions_init= 0;
@@ -233,21 +131,16 @@ static void init_database_names_psi_keys(void)
}
#endif
-/*
- Initialize database option hash and locked database hash.
-
- SYNOPSIS
- my_database_names()
+/**
+ Initialize database option cache.
- NOTES
- Must be called before any other database function is called.
+ @note Must be called before any other database function is called.
- RETURN
- 0 ok
- 1 Fatal error
+ @retval 0 ok
+ @retval 1 Fatal error
*/
-bool my_database_names_init(void)
+bool my_dboptions_cache_init(void)
{
#ifdef HAVE_PSI_INTERFACE
init_database_names_psi_keys();
@@ -261,36 +154,30 @@ bool my_database_names_init(void)
error= my_hash_init(&dboptions, lower_case_table_names ?
&my_charset_bin : system_charset_info,
32, 0, 0, (my_hash_get_key) dboptions_get_key,
- free_dbopt,0) ||
- my_hash_init(&lock_db_cache, lower_case_table_names ?
- &my_charset_bin : system_charset_info,
- 32, 0, 0, (my_hash_get_key) lock_db_get_key,
- lock_db_free_element,0);
-
+ free_dbopt,0);
}
return error;
}
-/*
+/**
Free database option hash and locked databases hash.
*/
-void my_database_names_free(void)
+void my_dboptions_cache_free(void)
{
if (dboptions_init)
{
dboptions_init= 0;
my_hash_free(&dboptions);
mysql_rwlock_destroy(&LOCK_dboptions);
- my_hash_free(&lock_db_cache);
}
}
-/*
- Cleanup cached options
+/**
+ Cleanup cached options.
*/
void my_dbopt_cleanup(void)
@@ -395,7 +282,7 @@ end:
Deletes database options from the hash.
*/
-void del_dbopt(const char *path)
+static void del_dbopt(const char *path)
{
my_dbopt_t *opt;
mysql_rwlock_wrlock(&LOCK_dboptions);
@@ -664,25 +551,8 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1);
}
- /*
- Do not create database if another thread is holding read lock.
- Wait for global read lock before acquiring LOCK_mysql_create_db.
- After wait_if_global_read_lock() we have protection against another
- global read lock. If we would acquire LOCK_mysql_create_db first,
- another thread could step in and get the global read lock before we
- reach wait_if_global_read_lock(). If this thread tries the same as we
- (admin a db), it would then go and wait on LOCK_mysql_create_db...
- Furthermore wait_if_global_read_lock() checks if the current thread
- has the global read lock and refuses the operation with
- ER_CANT_UPDATE_WITH_READLOCK if applicable.
- */
- if (thd->global_read_lock.wait_if_global_read_lock(thd, FALSE, TRUE))
- {
- error= -1;
- goto exit2;
- }
-
- mysql_mutex_lock(&LOCK_mysql_create_db);
+ if (lock_schema_name(thd, db))
+ DBUG_RETURN(-1);
/* Check directory */
path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
@@ -786,7 +656,10 @@ not_silent:
qinfo.db = db;
qinfo.db_len = strlen(db);
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
+ /*
+ These DDL methods and logging are protected with the exclusive
+ metadata lock on the schema
+ */
if (mysql_bin_log.write(&qinfo))
{
error= -1;
@@ -797,9 +670,6 @@ not_silent:
}
exit:
- mysql_mutex_unlock(&LOCK_mysql_create_db);
- thd->global_read_lock.start_waiting_global_read_lock(thd);
-exit2:
DBUG_RETURN(error);
}
@@ -813,22 +683,8 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
int error= 0;
DBUG_ENTER("mysql_alter_db");
- /*
- Do not alter database if another thread is holding read lock.
- Wait for global read lock before acquiring LOCK_mysql_create_db.
- After wait_if_global_read_lock() we have protection against another
- global read lock. If we would acquire LOCK_mysql_create_db first,
- another thread could step in and get the global read lock before we
- reach wait_if_global_read_lock(). If this thread tries the same as we
- (admin a db), it would then go and wait on LOCK_mysql_create_db...
- Furthermore wait_if_global_read_lock() checks if the current thread
- has the global read lock and refuses the operation with
- ER_CANT_UPDATE_WITH_READLOCK if applicable.
- */
- if ((error= thd->global_read_lock.wait_if_global_read_lock(thd, FALSE, TRUE)))
- goto exit2;
-
- mysql_mutex_lock(&LOCK_mysql_create_db);
+ if (lock_schema_name(thd, db))
+ DBUG_RETURN(TRUE);
/*
Recreate db options file: /dbpath/.db.opt
@@ -866,16 +722,16 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
qinfo.db = db;
qinfo.db_len = strlen(db);
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
+ /*
+ These DDL methods and logging are protected with the exclusive
+ metadata lock on the schema.
+ */
if ((error= mysql_bin_log.write(&qinfo)))
goto exit;
}
my_ok(thd, result);
exit:
- mysql_mutex_unlock(&LOCK_mysql_create_db);
- thd->global_read_lock.start_waiting_global_read_lock(thd);
-exit2:
DBUG_RETURN(error);
}
@@ -907,25 +763,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
TABLE_LIST* dropped_tables= 0;
DBUG_ENTER("mysql_rm_db");
- /*
- Do not drop database if another thread is holding read lock.
- Wait for global read lock before acquiring LOCK_mysql_create_db.
- After wait_if_global_read_lock() we have protection against another
- global read lock. If we would acquire LOCK_mysql_create_db first,
- another thread could step in and get the global read lock before we
- reach wait_if_global_read_lock(). If this thread tries the same as we
- (admin a db), it would then go and wait on LOCK_mysql_create_db...
- Furthermore wait_if_global_read_lock() checks if the current thread
- has the global read lock and refuses the operation with
- ER_CANT_UPDATE_WITH_READLOCK if applicable.
- */
- if (thd->global_read_lock.wait_if_global_read_lock(thd, FALSE, TRUE))
- {
- error= -1;
- goto exit2;
- }
- mysql_mutex_lock(&LOCK_mysql_create_db);
+ if (lock_schema_name(thd, db))
+ DBUG_RETURN(TRUE);
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
@@ -1013,7 +853,10 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
qinfo.db = db;
qinfo.db_len = strlen(db);
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
+ /*
+ These DDL methods and logging are protected with the exclusive
+ metadata lock on the schema.
+ */
if (mysql_bin_log.write(&qinfo))
{
error= -1;
@@ -1045,7 +888,10 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
tbl_name_len= strlen(tbl->table_name) + 3;
if (query_pos + tbl_name_len + 1 >= query_end)
{
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
+ /*
+ These DDL methods and logging are protected with the exclusive
+ metadata lock on the schema.
+ */
if (write_to_binlog(thd, query, query_pos -1 - query, db, db_len))
{
error= -1;
@@ -1062,7 +908,10 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if (query_pos != query_data_start)
{
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
+ /*
+ These DDL methods and logging are protected with the exclusive
+ metadata lock on the schema.
+ */
if (write_to_binlog(thd, query, query_pos -1 - query, db, db_len))
{
error= -1;
@@ -1080,9 +929,6 @@ exit:
*/
if (thd->db && !strcmp(thd->db, db) && error == 0)
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
- mysql_mutex_unlock(&LOCK_mysql_create_db);
- thd->global_read_lock.start_waiting_global_read_lock(thd);
-exit2:
DBUG_RETURN(error);
}
@@ -1099,12 +945,12 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
long deleted=0;
ulong found_other_files=0;
char filePath[FN_REFLEN];
- TABLE_LIST *tot_list=0, **tot_list_next;
+ TABLE_LIST *tot_list=0, **tot_list_next_local, **tot_list_next_global;
List<String> raid_dirs;
DBUG_ENTER("mysql_rm_known_files");
DBUG_PRINT("enter",("path: %s", org_path));
- tot_list_next= &tot_list;
+ tot_list_next_local= tot_list_next_global= &tot_list;
for (uint idx=0 ;
idx < (uint) dirp->number_off_files && !thd->killed ;
@@ -1192,22 +1038,28 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
if (!table_list)
goto err;
table_list->db= (char*) (table_list+1);
- table_list->table_name= strmov(table_list->db, db) + 1;
- (void) filename_to_tablename(file->name, table_list->table_name,
- MYSQL50_TABLE_NAME_PREFIX_LENGTH +
- strlen(file->name) + 1);
+ table_list->db_length= strmov(table_list->db, db) - table_list->db;
+ table_list->table_name= table_list->db + table_list->db_length + 1;
+ table_list->table_name_length= filename_to_tablename(file->name,
+ table_list->table_name,
+ MYSQL50_TABLE_NAME_PREFIX_LENGTH +
+ strlen(file->name) + 1);
+ table_list->open_type= OT_BASE_ONLY;
/* To be able to correctly look up the table in the table cache. */
if (lower_case_table_names)
- my_casedn_str(files_charset_info, table_list->table_name);
+ table_list->table_name_length= my_casedn_str(files_charset_info,
+ table_list->table_name);
table_list->alias= table_list->table_name; // If lower_case_table_names=2
table_list->internal_tmp_table= is_prefix(file->name, tmp_file_prefix);
table_list->mdl_request.init(MDL_key::TABLE, table_list->db,
table_list->table_name, MDL_EXCLUSIVE);
/* Link into list */
- (*tot_list_next)= table_list;
- tot_list_next= &table_list->next_local;
+ (*tot_list_next_local)= table_list;
+ (*tot_list_next_global)= table_list;
+ tot_list_next_local= &table_list->next_local;
+ tot_list_next_global= &table_list->next_global;
deleted++;
}
else
@@ -1769,60 +1621,6 @@ bool mysql_opt_change_db(THD *thd,
}
-static int
-lock_databases(THD *thd, const char *db1, uint length1,
- const char *db2, uint length2)
-{
- mysql_mutex_lock(&LOCK_lock_db);
- while (!thd->killed &&
- (my_hash_search(&lock_db_cache,(uchar*) db1, length1) ||
- my_hash_search(&lock_db_cache,(uchar*) db2, length2)))
- {
- wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- mysql_mutex_lock(&LOCK_lock_db);
- }
-
- if (thd->killed)
- {
- mysql_mutex_unlock(&LOCK_lock_db);
- return 1;
- }
-
- lock_db_insert(db1, length1);
- lock_db_insert(db2, length2);
- creating_database++;
-
- /*
- Wait if a concurent thread is creating a table at the same time.
- The assumption here is that it will not take too long until
- there is a point in time when a table is not created.
- */
-
- while (!thd->killed && creating_table)
- {
- wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- mysql_mutex_lock(&LOCK_lock_db);
- }
-
- if (thd->killed)
- {
- lock_db_delete(db1, length1);
- lock_db_delete(db2, length2);
- creating_database--;
- mysql_mutex_unlock(&LOCK_lock_db);
- mysql_cond_signal(&COND_refresh);
- return(1);
- }
-
- /*
- We can unlock now as the hash will protect against anyone creating a table
- in the databases we are using
- */
- mysql_mutex_unlock(&LOCK_lock_db);
- return 0;
-}
-
-
/**
Upgrade a 5.0 database.
This function is invoked whenever an ALTER DATABASE UPGRADE query is executed:
@@ -1864,9 +1662,9 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
new_db.str= old_db->str + MYSQL50_TABLE_NAME_PREFIX_LENGTH;
new_db.length= old_db->length - MYSQL50_TABLE_NAME_PREFIX_LENGTH;
- if (lock_databases(thd, old_db->str, old_db->length,
- new_db.str, new_db.length))
- DBUG_RETURN(1);
+ /* Lock the old name, the new name will be locked by mysql_create_db().*/
+ if (lock_schema_name(thd, old_db->str))
+ DBUG_RETURN(-1);
/*
Let's remember if we should do "USE newdb" afterwards.
@@ -2033,15 +1831,6 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
error|= mysql_change_db(thd, & new_db, FALSE);
exit:
- mysql_mutex_lock(&LOCK_lock_db);
- /* Remove the databases from db lock cache */
- lock_db_delete(old_db->str, old_db->length);
- lock_db_delete(new_db.str, new_db.length);
- creating_database--;
- /* Signal waiting CREATE TABLE's to continue */
- mysql_cond_signal(&COND_refresh);
- mysql_mutex_unlock(&LOCK_lock_db);
-
DBUG_RETURN(error);
}
diff --git a/sql/sql_db.h b/sql/sql_db.h
index 96b3de80d3a..ecb8deaa397 100644
--- a/sql/sql_db.h
+++ b/sql/sql_db.h
@@ -35,8 +35,8 @@ bool mysql_opt_change_db(THD *thd,
LEX_STRING *saved_db_name,
bool force_switch,
bool *cur_db_changed);
-bool my_database_names_init(void);
-void my_database_names_free(void);
+bool my_dboptions_cache_init(void);
+void my_dboptions_cache_free(void);
bool check_db_dir_existence(const char *db_name);
bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
bool load_db_opt_by_name(THD *thd, const char *db_name,
@@ -45,9 +45,6 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
bool my_dbopt_init(void);
void my_dbopt_cleanup(void);
-extern int creating_database; // How many database locks are made
-extern HASH lock_db_cache;
-
#define MY_DB_OPT_FILE "db.opt"
#endif /* SQL_DB_INCLUDED */
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 00666bc85b4..2f69bac917e 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -770,9 +770,9 @@ void multi_delete::send_error(uint errcode,const char *err)
}
-void multi_delete::abort()
+void multi_delete::abort_result_set()
{
- DBUG_ENTER("multi_delete::abort");
+ DBUG_ENTER("multi_delete::abort_result_set");
/* the error was handled or nothing deleted and no side effects return */
if (error_handled ||
diff --git a/sql/sql_do.cc b/sql/sql_do.cc
index 79e488ac2a5..085473c24b8 100644
--- a/sql/sql_do.cc
+++ b/sql/sql_do.cc
@@ -39,9 +39,10 @@ bool mysql_do(THD *thd, List<Item> &values)
/*
Rollback the effect of the statement, since next instruction
will clear the error and the rollback in the end of
- dispatch_command() won't work.
+ mysql_execute_command() won't work.
*/
- trans_rollback_stmt(thd);
+ if (! thd->in_sub_stmt)
+ trans_rollback_stmt(thd);
thd->clear_error(); // DO always is OK
}
my_ok(thd);
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index cc6529f7b10..8c038e10a1f 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -494,14 +494,6 @@ void Warning_info::clear_warning_info(ulonglong warn_id_arg)
m_current_row_for_warning= 1; /* Start counting from the first row */
}
-void Warning_info::reserve_space(THD *thd, uint count)
-{
- /* Make room for count conditions */
- while ((m_warn_list.elements > 0) &&
- ((m_warn_list.elements + count) > thd->variables.max_error_count))
- m_warn_list.pop();
-}
-
/**
Append warnings only if the original contents of the routine
warning info was replaced.
@@ -588,16 +580,11 @@ void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg));
/*
- Calling push_warning/push_warning_printf with a
- level of WARN_LEVEL_ERROR *is* a bug.
- Either use my_error(), or WARN_LEVEL_WARN.
- Please fix the calling code, and do *NOT*
- add more work around code in the assert below.
+ Calling push_warning/push_warning_printf with a level of
+ WARN_LEVEL_ERROR *is* a bug. Either use my_printf_error(),
+ my_error(), or WARN_LEVEL_WARN.
*/
- DBUG_ASSERT( (level != MYSQL_ERROR::WARN_LEVEL_ERROR)
- || (code == ER_CANT_CREATE_TABLE) /* See Bug#47233 */
- || (code == ER_ILLEGAL_HA_CREATE_OPTION) /* See Bug#47233 */
- );
+ DBUG_ASSERT(level != MYSQL_ERROR::WARN_LEVEL_ERROR);
if (level == MYSQL_ERROR::WARN_LEVEL_ERROR)
level= MYSQL_ERROR::WARN_LEVEL_WARN;
diff --git a/sql/sql_error.h b/sql/sql_error.h
index 9e649a004df..87e98e27673 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -153,8 +153,8 @@ private:
Representation of a SQL condition.
A SQL condition can be a completion condition (note, warning),
or an exception condition (error, not found).
- @note This class is named MYSQL_ERROR instead of SQL_condition for historical reasons,
- to facilitate merging code with previous releases.
+ @note This class is named MYSQL_ERROR instead of SQL_condition for
+ historical reasons, to facilitate merging code with previous releases.
*/
class MYSQL_ERROR : public Sql_alloc
{
@@ -471,18 +471,6 @@ public:
ulong statement_warn_count() const { return m_statement_warn_count; }
- /**
- Reserve some space in the condition area.
- This is a privileged operation, reserved for the RESIGNAL implementation,
- as only the RESIGNAL statement is allowed to remove conditions from
- the condition area.
- For other statements, new conditions are not added to the condition
- area once the condition area is full.
- @param thd The current thread
- @param count The number of slots to reserve
- */
- void reserve_space(THD *thd, uint count);
-
/** Add a new condition to the current list. */
MYSQL_ERROR *push_warning(THD *thd,
uint sql_errno, const char* sqlstate,
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 06a453f7b12..f1dddbb2eb5 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -59,7 +59,7 @@
#include "key.h" // key_copy
#include "sql_base.h" // insert_fields
#include "sql_select.h"
-#include <assert.h>
+#include "transaction.h"
#define HANDLER_TABLES_HASH_SIZE 120
@@ -309,9 +309,15 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
}
if (error)
{
+ /*
+ No need to rollback statement transaction, it's not started.
+ If called with reopen flag, no need to rollback either,
+ it will be done at statement end.
+ */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
close_thread_tables(thd);
- thd->set_open_tables(backup_open_tables);
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+ thd->set_open_tables(backup_open_tables);
if (!reopen)
my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
else
@@ -578,6 +584,11 @@ retry:
if (sql_handler_lock_error.need_reopen())
{
DBUG_ASSERT(!lock && !thd->is_error());
+ /*
+ Always close statement transaction explicitly,
+ so that the engine doesn't have to count locks.
+ */
+ trans_rollback_stmt(thd);
mysql_ha_close_table(thd, hash_tables);
goto retry;
}
@@ -747,7 +758,11 @@ retry:
goto ok;
}
if (cond && !cond->val_int())
+ {
+ if (thd->is_error())
+ goto err;
continue;
+ }
if (num_rows >= offset_limit_cnt)
{
protocol->prepare_for_resend();
@@ -760,12 +775,18 @@ retry:
num_rows++;
}
ok:
+ /*
+ Always close statement transaction explicitly,
+ so that the engine doesn't have to count locks.
+ */
+ trans_commit_stmt(thd);
mysql_unlock_tables(thd,lock);
my_eof(thd);
DBUG_PRINT("exit",("OK"));
DBUG_RETURN(FALSE);
err:
+ trans_rollback_stmt(thd);
mysql_unlock_tables(thd,lock);
err0:
DBUG_PRINT("exit",("ERROR"));
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 7bea236269a..4e3df950134 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -643,23 +643,24 @@ bool mysqld_help(THD *thd, const char *mask)
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_help");
- bzero((uchar*)tables,sizeof(tables));
- tables[0].alias= tables[0].table_name= (char*) "help_topic";
- tables[0].lock_type= TL_READ;
+ tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("help_topic"),
+ "help_topic", TL_READ);
+ tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("help_category"),
+ "help_category", TL_READ);
+ tables[2].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("help_relation"),
+ "help_relation", TL_READ);
+ tables[3].init_one_table(C_STRING_WITH_LEN("mysql"),
+ C_STRING_WITH_LEN("help_keyword"),
+ "help_keyword", TL_READ);
tables[0].next_global= tables[0].next_local=
tables[0].next_name_resolution_table= &tables[1];
- tables[1].alias= tables[1].table_name= (char*) "help_category";
- tables[1].lock_type= TL_READ;
tables[1].next_global= tables[1].next_local=
tables[1].next_name_resolution_table= &tables[2];
- tables[2].alias= tables[2].table_name= (char*) "help_relation";
- tables[2].lock_type= TL_READ;
tables[2].next_global= tables[2].next_local=
tables[2].next_name_resolution_table= &tables[3];
- tables[3].alias= tables[3].table_name= (char*) "help_keyword";
- tables[3].lock_type= TL_READ;
- tables[0].db= tables[1].db= tables[2].db= tables[3].db= (char*) "mysql";
- init_mdl_requests(tables);
/*
HELP must be available under LOCK TABLES.
diff --git a/sql/sql_hset.h b/sql/sql_hset.h
new file mode 100644
index 00000000000..2ea70b91da8
--- /dev/null
+++ b/sql/sql_hset.h
@@ -0,0 +1,97 @@
+#ifndef SQL_HSET_INCLUDED
+#define SQL_HSET_INCLUDED
+/* Copyright (c) 2010, 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 Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "my_global.h"
+#include "hash.h"
+
+
+/**
+ A type-safe wrapper around mysys HASH.
+*/
+
+template <typename T, my_hash_get_key K>
+class Hash_set
+{
+public:
+ typedef T Value_type;
+ enum { START_SIZE= 8 };
+ /**
+ Constructs an empty hash. Does not allocate memory, it is done upon
+ the first insert. Thus does not cause or return errors.
+ */
+ Hash_set()
+ {
+ my_hash_clear(&m_hash);
+ }
+ /**
+ Destroy the hash by freeing the buckets table. Does
+ not call destructors for the elements.
+ */
+ ~Hash_set()
+ {
+ my_hash_free(&m_hash);
+ }
+ /**
+ Insert a single value into a hash. Does not tell whether
+ the value was inserted -- if an identical value existed,
+ it is not replaced.
+
+ @retval TRUE Out of memory.
+ @retval FALSE OK. The value either was inserted or existed
+ in the hash.
+ */
+ bool insert(T *value)
+ {
+ my_hash_init_opt(&m_hash, &my_charset_bin, START_SIZE, 0, 0, K, 0, MYF(0));
+ size_t key_len;
+ const uchar *key= K(reinterpret_cast<uchar*>(value), &key_len, FALSE);
+ if (my_hash_search(&m_hash, key, key_len) == NULL)
+ return my_hash_insert(&m_hash, reinterpret_cast<uchar *>(value));
+ return FALSE;
+ }
+ /** Is this hash set empty? */
+ bool is_empty() const { return m_hash.records == 0; }
+ /** Returns the number of unique elements. */
+ size_t size() const { return static_cast<size_t>(m_hash.records); }
+ /** An iterator over hash elements. Is not insert-stable. */
+ class Iterator
+ {
+ public:
+ Iterator(Hash_set &hash_set)
+ : m_hash(&hash_set.m_hash),
+ m_idx(0)
+ {}
+ /**
+ Return the current element and reposition the iterator to the next
+ element.
+ */
+ inline T *operator++(int)
+ {
+ if (m_idx < m_hash->records)
+ return reinterpret_cast<T*>(my_hash_element(m_hash, m_idx++));
+ return NULL;
+ }
+ void rewind() { m_idx= 0; }
+ private:
+ HASH *m_hash;
+ uint m_idx;
+ };
+private:
+ HASH m_hash;
+};
+
+#endif // SQL_HSET_INCLUDED
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index c783d74b363..a0d347f48de 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1862,7 +1862,10 @@ public:
while ((row=rows.get()))
delete row;
if (table)
+ {
close_thread_tables(&thd);
+ thd.mdl_context.release_transactional_locks();
+ }
mysql_mutex_lock(&LOCK_thread_count);
mysql_mutex_destroy(&mutex);
mysql_cond_destroy(&cond);
@@ -2414,6 +2417,8 @@ bool Delayed_insert::open_and_lock_table()
}
if (!(table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED))
{
+ /* To rollback InnoDB statement transaction. */
+ trans_rollback_stmt(&thd);
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(ME_FATALERROR),
table_list.table_name);
return TRUE;
@@ -2480,12 +2485,6 @@ pthread_handler_t handle_delayed_insert(void *arg)
goto err;
}
- /*
- Open table requires an initialized lex in case the table is
- partitioned. The .frm file contains a partial SQL string which is
- parsed using a lex, that depends on initialized thd->lex.
- */
- lex_start(thd);
thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock()
/*
Statement-based replication of INSERT DELAYED has problems with RAND()
@@ -2619,28 +2618,11 @@ pthread_handler_t handle_delayed_insert(void *arg)
}
err:
- /*
- mysql_lock_tables() can potentially start a transaction and write
- a table map. In the event of an error, that transaction has to be
- rolled back. We only need to roll back a potential statement
- transaction, since real transactions are rolled back in
- close_thread_tables().
-
- TODO: This is not true any more, table maps are generated on the
- first call to ha_*_row() instead. Remove code that are used to
- cover for the case outlined above.
- */
- trans_rollback_stmt(thd);
-
DBUG_LEAVE;
}
- /*
- di should be unlinked from the thread handler list and have no active
- clients
- */
-
close_thread_tables(thd); // Free the table
+ thd->mdl_context.release_transactional_locks();
di->table=0;
thd->killed= THD::KILL_CONNECTION; // If error
mysql_cond_broadcast(&di->cond_client); // Safety
@@ -2648,6 +2630,10 @@ pthread_handler_t handle_delayed_insert(void *arg)
mysql_mutex_lock(&LOCK_delayed_create); // Because of delayed_get_table
mysql_mutex_lock(&LOCK_delayed_insert);
+ /*
+ di should be unlinked from the thread handler list and have no active
+ clients
+ */
delete di;
mysql_mutex_unlock(&LOCK_delayed_insert);
mysql_mutex_unlock(&LOCK_delayed_create);
@@ -3413,9 +3399,9 @@ bool select_insert::send_eof()
DBUG_RETURN(0);
}
-void select_insert::abort() {
+void select_insert::abort_result_set() {
- DBUG_ENTER("select_insert::abort");
+ DBUG_ENTER("select_insert::abort_result_set");
/*
If the creation of the table failed (due to a syntax error, for
example), no table will have been opened and therefore 'table'
@@ -3952,9 +3938,9 @@ bool select_create::send_eof()
}
-void select_create::abort()
+void select_create::abort_result_set()
{
- DBUG_ENTER("select_create::abort");
+ DBUG_ENTER("select_create::abort_result_set");
/*
In select_insert::abort() we roll back the statement, including
@@ -3972,7 +3958,7 @@ void select_create::abort()
log state.
*/
tmp_disable_binlog(thd);
- select_insert::abort();
+ select_insert::abort_result_set();
thd->transaction.stmt.modified_non_trans_table= FALSE;
reenable_binlog(thd);
/* possible error of writing binary log is ignored deliberately */
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 79d91a461db..424dba78d39 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -41,7 +41,6 @@ sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
LEX_STRING constant for null-string to be used in parser and other places.
*/
const LEX_STRING null_lex_str= {NULL, 0};
-const LEX_STRING empty_lex_str= { (char*) "", 0 };
/**
@note The order of the elements of this array must correspond to
the order of elements in enum_binlog_stmt_unsafe.
@@ -450,6 +449,9 @@ void lex_end(LEX *lex)
}
reset_dynamic(&lex->plugins);
+ delete lex->sphead;
+ lex->sphead= NULL;
+
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index feb8079a06b..f1b558b8be4 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -589,11 +589,11 @@ public:
st_select_lex* outer_select();
st_select_lex* first_select()
{
- return my_reinterpret_cast(st_select_lex*)(slave);
+ return reinterpret_cast<st_select_lex*>(slave);
}
st_select_lex_unit* next_unit()
{
- return my_reinterpret_cast(st_select_lex_unit*)(next);
+ return reinterpret_cast<st_select_lex_unit*>(next);
}
st_select_lex* return_after_parsing() { return return_to; }
void exclude_level();
@@ -995,8 +995,6 @@ enum xa_option_words {XA_NONE, XA_JOIN, XA_RESUME, XA_ONE_PHASE,
XA_SUSPEND, XA_FOR_MIGRATE};
extern const LEX_STRING null_lex_str;
-extern const LEX_STRING empty_lex_str;
-
class Sroutine_hash_entry;
diff --git a/sql/sql_map.cc b/sql/sql_map.cc
deleted file mode 100644
index ca8a88bcbf8..00000000000
--- a/sql/sql_map.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Copyright (C) 2000-2001, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-
-#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
-#endif
-
-#include "sql_priv.h"
-#include "unireg.h" // REQUIRED: for other includes
-#include "sql_map.h" // mapped_files
-#include "sql_class.h" // THD
-
-#include <sys/stat.h>
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length)
-{
-#ifdef HAVE_MMAP
- name=my_strdup(filename,MYF(0));
- use_count=1;
- error=0;
- map=0;
- size=0;
- if ((file= mysql_file_open(key_file_map, name, O_RDONLY, MYF(MY_WME))) >= 0)
- {
- struct stat stat_buf;
- if (!fstat(file, &stat_buf))
- {
- if (!(map=(uchar*) my_mmap(0,(size_t)(size= stat_buf.st_size),PROT_READ,
- MAP_SHARED | MAP_NORESERVE,file,
- 0L)))
- {
- error=errno;
- my_error(ER_NO_FILE_MAPPING, MYF(0), (char *) name, error);
- }
- }
- if (map && memcmp(map,magic,magic_length))
- {
- my_error(ER_WRONG_MAGIC, MYF(0), name);
- (void) my_munmap((char*) map,(size_t)size);
- map=0;
- }
- if (!map)
- {
- (void) mysql_file_close(file, MYF(0));
- file= -1;
- }
- }
-#endif
-}
-
-
-mapped_files::~mapped_files()
-{
-#ifdef HAVE_MMAP
- if (file >= 0)
- {
- (void) my_munmap((char*) map,(size_t)size);
- (void) mysql_file_close(file, MYF(0));
- file= -1; map=0;
- }
- my_free(name);
-#endif
-}
-
-
-static I_List<mapped_files> maps_in_use;
-
-/*
-** Check if a file is mapped. If it is, then return pointer to old map,
-** else alloc new object
-*/
-
-mapped_files *map_file(const char * name,uchar *magic,uint magic_length)
-{
-#ifdef HAVE_MMAP
- mysql_mutex_lock(&LOCK_mapped_file);
- I_List_iterator<mapped_files> list(maps_in_use);
- mapped_files *map;
- char path[FN_REFLEN];
- sprintf(path,"%s/%s/%s.uniq",mysql_data_home,current_thd->db,name);
- (void) unpack_filename(path,path);
-
- while ((map=list++))
- {
- if (!strcmp(path,map->name))
- break;
- }
- if (!map)
- {
- map=new mapped_files(path,magic,magic_length);
- maps_in_use.append(map);
- }
- else
- {
- map->use_count++;
- if (!map->map)
- my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error);
- }
- mysql_mutex_unlock(&LOCK_mapped_file);
- return map;
-#else
- return NULL;
-#endif
-}
-
-/*
-** free the map if there are no more users for it
-*/
-
-void unmap_file(mapped_files *map)
-{
-#ifdef HAVE_MMAP
- mysql_mutex_lock(&LOCK_mapped_file);
- if (!map->use_count--)
- delete map;
- mysql_mutex_unlock(&LOCK_mapped_file);
-#endif
-}
-
-/*****************************************************************************
-** Instansiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-/* Used templates */
-template class I_List<mapped_files>;
-template class I_List_iterator<mapped_files>;
-#endif
diff --git a/sql/sql_map.h b/sql/sql_map.h
deleted file mode 100644
index be1c145df3f..00000000000
--- a/sql/sql_map.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef SQL_MAP_INCLUDED
-#define SQL_MAP_INCLUDED
-
-/* Copyright (C) 2000-2001, 2005 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-
-/* interface for memory mapped files */
-
-#ifdef USE_PRAGMA_INTERFACE
-#pragma interface /* gcc class implementation */
-#endif
-
-#include "my_base.h" /* ha_rows */
-#include "sql_list.h" /* ilink */
-
-class mapped_files;
-mapped_files *map_file(const char * name,uchar *magic,uint magic_length);
-void unmap_file(mapped_files *map);
-
-class mapped_files :public ilink {
- uchar *map;
- ha_rows size;
- char *name; // name of mapped file
- File file; // >= 0 if open
- int error; // If not mapped
- uint use_count;
-
-public:
- mapped_files(const char * name,uchar *magic,uint magic_length);
- ~mapped_files();
-
- friend class mapped_file;
- friend mapped_files *map_file(const char * name,uchar *magic,
- uint magic_length);
- friend void unmap_file(mapped_files *map);
-};
-
-
-class mapped_file
-{
- mapped_files *file;
-public:
- mapped_file(const char * name,uchar *magic,uint magic_length)
- {
- file=map_file(name,magic,magic_length); /* old or new map */
- }
- ~mapped_file()
- {
- unmap_file(file); /* free map */
- }
- uchar *map()
- {
- return file->map;
- }
-};
-
-#endif /* SQL_MAP_INCLUDED */
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
deleted file mode 100644
index b957d1e9be4..00000000000
--- a/sql/sql_olap.cc
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Copyright (C) 2000-2006 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-
-/*
- OLAP implementation by Sinisa Milivojevic <sinisa@mysql.com>
- Inspired by code submitted by Srilakshmi <lakshmi@gdit.iiit.net>
-
- The ROLLUP code in this file has to be complitely rewritten as it's
- not good enough to satisfy the goals of MySQL.
-
- In 4.1 we will replace this with a working, superior implementation
- of ROLLUP.
-*/
-
-#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1
-
-#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
-#endif
-
-#include "sql_priv.h"
-#include "unireg.h"
-#include "sql_select.h"
-
-
-/****************************************************************************
- Functions that recursively actually creates new SELECT's
- Returns 0 if OK, 1 if error, -1 if error already printed to client
-****************************************************************************/
-
-
-static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new_fields)
-{
- THD *thd=current_thd;
- Item *item, *new_item;
- Item_null *constant= new Item_null("ALL");
-
- SELECT_LEX *new_select = (SELECT_LEX *) thd->memdup((char*) select_lex, sizeof(*select_lex));
- if (!new_select)
- return 1;
- lex->last_selects->next=new_select;
- new_select->linkage=OLAP_TYPE;
- new_select->olap=NON_EXISTING_ONE;
- new_select->group_list.elements=0;
- new_select->group_list.first=(uchar *)0;
- new_select->group_list.next=(uchar **)&new_select->group_list.first;
- List<Item> privlist;
-
- List_iterator<Item> list_it(select_lex->item_list);
- List_iterator<Item> new_it(new_fields);
-
- while ((item=list_it++))
- {
- bool not_found= TRUE;
- if (item->type()==Item::FIELD_ITEM)
- {
- Item_field *iif = (Item_field *)item;
- new_it.rewind();
- while ((new_item=new_it++))
- {
- if (new_item->type()==Item::FIELD_ITEM &&
- !strcmp(((Item_field*)new_item)->table_name,iif->table_name) &&
- !strcmp(((Item_field*)new_item)->field_name,iif->field_name))
- {
- not_found= 0;
- ((Item_field*)new_item)->db_name=iif->db_name;
- Item_field *new_one=new Item_field(&select_lex->context,
- iif->db_name, iif->table_name, iif->field_name);
- privlist.push_back(new_one);
- if (add_to_list(new_select->group_list,new_one,1))
- return 1;
- break;
- }
- }
- }
- if (not_found)
- {
- if (item->type() == Item::FIELD_ITEM)
- privlist.push_back(constant);
- else
- privlist.push_back((Item*)thd->memdup((char *)item,item->size_of()));
- }
- }
- new_select->item_list=privlist;
-
- lex->last_selects = new_select;
- return 0;
-}
-
-/****************************************************************************
- Functions that recursively creates combinations of queries for OLAP
- Returns 0 if OK, 1 if error, -1 if error already printed to client
-****************************************************************************/
-
-static int olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex,
- SELECT_LEX *select_lex, int position, int selection, int num_fields,
- int num_new_fields)
-{
- int sl_return = 0;
- if (position == num_new_fields)
- {
- if (item)
- new_fields.push_front(item);
- sl_return = make_new_olap_select(lex, select_lex, new_fields);
- }
- else
- {
- if (item)
- new_fields.push_front(item);
- while ((num_fields - num_new_fields >= selection - position) && !sl_return)
- {
- item = old_fields.pop();
- sl_return = olap_combos(old_fields, new_fields, item, lex, select_lex, position+1, ++selection, num_fields, num_new_fields);
- }
- }
- return sl_return;
-}
-
-
-/****************************************************************************
- Top level function for converting OLAP clauses to multiple selects
- This is also a place where clauses treatment depends on OLAP type
- Returns 0 if OK, 1 if error, -1 if error already printed to client
-****************************************************************************/
-
-int handle_olaps(LEX *lex, SELECT_LEX *select_lex)
-{
- List<Item> item_list_copy, new_item_list;
- item_list_copy.empty();
- new_item_list.empty();
- int count=select_lex->group_list.elements;
- int sl_return=0;
-
-
- lex->last_selects=select_lex;
-
- for (ORDER *order= select_lex->group_list.first ; order ; order=order->next)
- item_list_copy.push_back(*(order->item));
-
- List<Item> all_fields(select_lex->item_list);
-
-
- if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list,
- select_lex->table_list.first
- &select_lex->leaf_tables, FALSE) ||
- setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ,
- &all_fields,1) ||
- setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ,
- &all_fields, 1))
- return -1;
-
- if (select_lex->olap == CUBE_TYPE)
- {
- for ( int i=count-1; i>=0 && !sl_return; i--)
- sl_return=olap_combos(item_list_copy, new_item_list, (Item *)0, lex, select_lex, 0, 0, count, i);
- }
- else if (select_lex->olap == ROLLUP_TYPE)
- {
- for ( int i=count-1; i>=0 && !sl_return; i--)
- {
- Item *item;
- item_list_copy.pop();
- List_iterator<Item> it(item_list_copy);
- new_item_list.empty();
- while ((item = it++))
- new_item_list.push_front(item);
- sl_return=make_new_olap_select(lex, select_lex, new_item_list);
- }
- }
- else
- sl_return=1; // impossible
- return sl_return;
-}
-
-#endif /* DISABLED_UNTIL_REWRITTEN_IN_4_1 */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 57a13d523a0..2ef8e9761b1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -115,6 +115,7 @@
"FUNCTION" : "PROCEDURE")
static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables);
+static void sql_kill(THD *thd, ulong id, bool only_kill_query);
const char *any_db="*any*"; // Special symbol for check_access
@@ -270,10 +271,10 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_LOAD]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_PROTECT_AGAINST_GRL |
CF_CAN_GENERATE_ROW_EVENTS;
- sql_command_flags[SQLCOM_CREATE_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
- sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
- sql_command_flags[SQLCOM_ALTER_DB_UPGRADE]= CF_AUTO_COMMIT_TRANS;
- sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
+ sql_command_flags[SQLCOM_CREATE_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
+ sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
+ sql_command_flags[SQLCOM_ALTER_DB_UPGRADE]= CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
+ sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
@@ -413,6 +414,9 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_FLUSH]= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_RESET]= CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_CHECK]= CF_AUTO_COMMIT_TRANS;
+ sql_command_flags[SQLCOM_CREATE_SERVER]= CF_AUTO_COMMIT_TRANS;
+ sql_command_flags[SQLCOM_ALTER_SERVER]= CF_AUTO_COMMIT_TRANS;
+ sql_command_flags[SQLCOM_DROP_SERVER]= CF_AUTO_COMMIT_TRANS;
}
bool sqlcom_can_generate_row_events(const THD *thd)
@@ -568,7 +572,6 @@ static void handle_bootstrap_impl(THD *thd)
}
mysql_parse(thd, thd->query(), length, &parser_state);
- close_thread_tables(thd); // Free tables
bootstrap_error= thd->is_error();
thd->protocol->end_statement();
@@ -1139,13 +1142,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{
char *beginning_of_next_stmt= (char*)
parser_state.m_lip.found_semicolon;
-
- thd->protocol->end_statement();
- query_cache_end_of_result(thd);
/*
Multiple queries exits, execute them individually
*/
- close_thread_tables(thd);
+ thd->protocol->end_statement();
+ query_cache_end_of_result(thd);
ulong length= (ulong)(packet_end - beginning_of_next_stmt);
log_slow_statement(thd);
@@ -1197,38 +1198,54 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *fields, *packet_end= packet + packet_length, *arg_end;
/* Locked closure of all tables */
TABLE_LIST table_list;
- LEX_STRING conv_name;
-
- /* used as fields initializator */
- lex_start(thd);
+ LEX_STRING table_name;
+ LEX_STRING db;
+ /*
+ SHOW statements should not add the used tables to the list of tables
+ used in a transaction.
+ */
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]);
- bzero((char*) &table_list,sizeof(table_list));
- if (thd->copy_db_to(&table_list.db, &table_list.db_length))
+ if (thd->copy_db_to(&db.str, &db.length))
break;
/*
We have name + wildcard in packet, separated by endzero
*/
arg_end= strend(packet);
uint arg_length= arg_end - packet;
-
+
/* Check given table name length. */
if (arg_length >= packet_length || arg_length > NAME_LEN)
{
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
break;
}
- thd->convert_string(&conv_name, system_charset_info,
+ thd->convert_string(&table_name, system_charset_info,
packet, arg_length, thd->charset());
- if (check_table_name(conv_name.str, conv_name.length, FALSE))
+ if (check_table_name(table_name.str, table_name.length, FALSE))
{
/* this is OK due to convert_string() null-terminating the string */
- my_error(ER_WRONG_TABLE_NAME, MYF(0), conv_name.str);
+ my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name.str);
break;
}
-
- table_list.alias= table_list.table_name= conv_name.str;
packet= arg_end + 1;
+ mysql_reset_thd_for_next_command(thd);
+ lex_start(thd);
+ /* Must be before we init the table list. */
+ if (lower_case_table_names)
+ table_name.length= my_casedn_str(files_charset_info, table_name.str);
+ table_list.init_one_table(db.str, db.length, table_name.str,
+ table_name.length, table_name.str, TL_READ);
+ /*
+ Init TABLE_LIST members necessary when the undelrying
+ table is view.
+ */
+ table_list.select_lex= &(thd->lex->select_lex);
+ thd->lex->
+ select_lex.table_list.link_in_list(&table_list,
+ &table_list.next_local);
+ thd->lex->add_to_query_tables(&table_list);
if (is_infoschema_db(table_list.db, table_list.db_length))
{
@@ -1242,32 +1259,23 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
thd->set_query(fields, query_length);
general_log_print(thd, command, "%s %s", table_list.table_name, fields);
- if (lower_case_table_names)
- my_casedn_str(files_charset_info, table_list.table_name);
- if (check_access(thd, SELECT_ACL, table_list.db,
- &table_list.grant.privilege,
- &table_list.grant.m_internal,
- 0, 0))
- break;
- if (check_grant(thd, SELECT_ACL, &table_list, TRUE, UINT_MAX, FALSE))
+ if (check_table_access(thd, SELECT_ACL, &table_list,
+ TRUE, UINT_MAX, FALSE))
break;
- /* init structures for VIEW processing */
- table_list.select_lex= &(thd->lex->select_lex);
-
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
- thd->lex->
- select_lex.table_list.link_in_list(&table_list,
- &table_list.next_local);
- thd->lex->add_to_query_tables(&table_list);
- init_mdl_requests(&table_list);
-
- /* switch on VIEW optimisation: do not fill temporary tables */
+ /*
+ Turn on an optimization relevant if the underlying table
+ is a view: do not fill derived tables.
+ */
thd->lex->sql_command= SQLCOM_SHOW_FIELDS;
+
mysqld_list_fields(thd,&table_list,fields);
thd->lex->unit.cleanup();
+ /* No need to rollback statement transaction, it's not started. */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
+ close_thread_tables(thd);
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+
thd->cleanup_after_query();
break;
}
@@ -1315,7 +1323,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
ulong options= (ulong) (uchar) packet[0];
if (trans_commit_implicit(thd))
break;
- close_thread_tables(thd);
thd->mdl_context.release_transactional_locks();
if (check_global_access(thd,RELOAD_ACL))
break;
@@ -1377,7 +1384,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
DBUG_PRINT("quit",("Got shutdown command for level %u", level));
general_log_print(thd, command, NullS);
my_eof(thd);
- close_thread_tables(thd); // Free before kill
kill_mysql();
error=TRUE;
break;
@@ -1480,33 +1486,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
break;
}
-
- /* report error issued during command execution */
- if (thd->killed_errno())
- {
- if (! thd->stmt_da->is_set())
- thd->send_kill_message();
- }
- if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA)
- {
- thd->killed= THD::NOT_KILLED;
- thd->mysys_var->abort= 0;
- }
-
- /* If commit fails, we should be able to reset the OK status. */
- thd->stmt_da->can_overwrite_status= TRUE;
- thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
- thd->stmt_da->can_overwrite_status= FALSE;
-
- thd->transaction.stmt.reset();
+ DBUG_ASSERT(thd->derived_tables == NULL &&
+ (thd->open_tables == NULL ||
+ (thd->locked_tables_mode == LTM_LOCK_TABLES)));
thd->protocol->end_statement();
query_cache_end_of_result(thd);
- thd->proc_info= "closing tables";
- /* Free tables */
- close_thread_tables(thd);
-
if (!thd->is_error() && !thd->killed_errno())
mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_RESULT, 0, 0);
@@ -1715,6 +1701,9 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
In brief: take exclusive locks, expel tables from the table
cache, reopen the tables, enter the 'LOCKED TABLES' mode,
downgrade the locks.
+ Note: the function is written to be called from
+ mysql_execute_command(), it is not reusable in arbitrary
+ execution context.
Required privileges
-------------------
@@ -1792,7 +1781,8 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
current internal MDL asserts, fix after discussing with
Dmitry.
*/
- if (lock_table_names(thd, all_tables))
+ if (lock_table_names(thd, all_tables, 0, thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
goto error;
for (table_list= all_tables; table_list;
@@ -1815,9 +1805,9 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
&lock_tables_prelocking_strategy) ||
thd->locked_tables_list.init_locked_tables(thd))
{
- close_thread_tables(thd);
goto error;
}
+ thd->variables.option_bits|= OPTION_TABLE_LOCK;
/*
Downgrade the exclusive locks.
@@ -2040,6 +2030,7 @@ mysql_execute_command(THD *thd)
thd->work_part_info= 0;
#endif
+ DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt);
/*
In many cases first table of main SELECT_LEX have special meaning =>
check that it is first table in global list and relink it first in
@@ -2221,8 +2212,7 @@ mysql_execute_command(THD *thd)
/* Commit the normal transaction if one is active. */
if (trans_commit_implicit(thd))
goto error;
- /* Close tables and release metadata locks. */
- close_thread_tables(thd);
+ /* Release metadata locks acquired in this transaction. */
thd->mdl_context.release_transactional_locks();
}
@@ -3401,7 +3391,7 @@ end_with_restore_list:
res|= thd->is_error();
MYSQL_MULTI_DELETE_DONE(res, del_result->num_deleted());
if (res)
- del_result->abort();
+ del_result->abort_result_set();
delete del_result;
}
else
@@ -3535,24 +3525,27 @@ end_with_restore_list:
done FLUSH TABLES WITH READ LOCK + BEGIN. If this assumption becomes
false, mysqldump will not work.
*/
- thd->locked_tables_list.unlock_locked_tables(thd);
if (thd->variables.option_bits & OPTION_TABLE_LOCK)
{
- trans_commit_implicit(thd);
+ res= trans_commit_implicit(thd);
+ thd->locked_tables_list.unlock_locked_tables(thd);
thd->mdl_context.release_transactional_locks();
thd->variables.option_bits&= ~(OPTION_TABLE_LOCK);
}
if (thd->global_read_lock.is_acquired())
thd->global_read_lock.unlock_global_read_lock(thd);
+ if (res)
+ goto error;
my_ok(thd);
break;
case SQLCOM_LOCK_TABLES:
+ /* We must end the transaction first, regardless of anything */
+ res= trans_commit_implicit(thd);
thd->locked_tables_list.unlock_locked_tables(thd);
- /* we must end the trasaction first, regardless of anything */
- if (trans_commit_implicit(thd))
- goto error;
- /* release transactional metadata locks. */
+ /* Release transactional metadata locks. */
thd->mdl_context.release_transactional_locks();
+ if (res)
+ goto error;
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
FALSE, UINT_MAX, FALSE))
goto error;
@@ -3575,17 +3568,14 @@ end_with_restore_list:
if (res)
{
+ trans_rollback_stmt(thd);
/*
Need to end the current transaction, so the storage engine (InnoDB)
can free its locks if LOCK TABLES locked some tables before finding
that it can't lock a table in its list
*/
- trans_rollback_stmt(thd);
trans_commit_implicit(thd);
- /*
- Close tables and release metadata locks otherwise a later call to
- close_thread_tables might not release the locks if autocommit is off.
- */
+ /* Close tables and release metadata locks. */
close_thread_tables(thd);
DBUG_ASSERT(!thd->locked_tables_mode);
thd->mdl_context.release_transactional_locks();
@@ -3633,12 +3623,6 @@ end_with_restore_list:
#endif
if (check_access(thd, CREATE_ACL, lex->name.str, NULL, NULL, 1, 0))
break;
- if (thd->locked_tables_mode)
- {
- my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
- ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
- goto error;
- }
res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias :
lex->name.str), &create_info, 0);
break;
@@ -3668,12 +3652,6 @@ end_with_restore_list:
#endif
if (check_access(thd, DROP_ACL, lex->name.str, NULL, NULL, 1, 0))
break;
- if (thd->locked_tables_mode)
- {
- my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
- ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
- goto error;
- }
res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0);
break;
}
@@ -3702,14 +3680,6 @@ end_with_restore_list:
res= 1;
break;
}
- if (thd->locked_tables_mode)
- {
- res= 1;
- my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
- ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
- goto error;
- }
-
res= mysql_upgrade_db(thd, db);
if (!res)
my_ok(thd);
@@ -3742,12 +3712,6 @@ end_with_restore_list:
#endif
if (check_access(thd, ALTER_ACL, db->str, NULL, NULL, 1, 0))
break;
- if (thd->locked_tables_mode)
- {
- my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
- ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
- goto error;
- }
res= mysql_alter_db(thd, db->str, &create_info);
break;
}
@@ -4230,9 +4194,7 @@ end_with_restore_list:
locks in the MDL context, so there is no risk to
deadlock.
*/
- trans_commit_implicit(thd);
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
+ close_mysql_tables(thd);
/*
Check if the definer exists on slave,
then use definer privilege to insert routine privileges to mysql.procs_priv.
@@ -4509,9 +4471,7 @@ create_sp_error:
locks in the MDL context, so there is no risk to
deadlock.
*/
- trans_commit_implicit(thd);
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
+ close_mysql_tables(thd);
if (sp_automatic_privileges && !opt_noacl &&
sp_revoke_privileges(thd, db, name,
@@ -4803,17 +4763,60 @@ finish:
DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() ||
thd->in_multi_stmt_transaction_mode());
+
+ if (! thd->in_sub_stmt)
+ {
+ /* report error issued during command execution */
+ if (thd->killed_errno())
+ {
+ if (! thd->stmt_da->is_set())
+ thd->send_kill_message();
+ }
+ if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA)
+ {
+ thd->killed= THD::NOT_KILLED;
+ thd->mysys_var->abort= 0;
+ }
+ if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR))
+ trans_rollback_stmt(thd);
+ else
+ {
+ /* If commit fails, we should be able to reset the OK status. */
+ thd->stmt_da->can_overwrite_status= TRUE;
+ trans_commit_stmt(thd);
+ thd->stmt_da->can_overwrite_status= FALSE;
+ }
+ }
+
+ lex->unit.cleanup();
+ /* Free tables */
+ thd_proc_info(thd, "closing tables");
+ close_thread_tables(thd);
+ thd_proc_info(thd, 0);
+
if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END))
{
+ /* No transaction control allowed in sub-statements. */
+ DBUG_ASSERT(! thd->in_sub_stmt);
/* If commit fails, we should be able to reset the OK status. */
thd->stmt_da->can_overwrite_status= TRUE;
- /* Commit or rollback the statement transaction. */
- thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
/* Commit the normal transaction if one is active. */
trans_commit_implicit(thd);
thd->stmt_da->can_overwrite_status= FALSE;
- /* Close tables and release metadata locks. */
- close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
+ }
+ else if (! thd->in_sub_stmt && ! thd->in_multi_stmt_transaction_mode())
+ {
+ /*
+ - If inside a multi-statement transaction,
+ defer the release of metadata locks until the current
+ transaction is either committed or rolled back. This prevents
+ other statements from modifying the table for the entire
+ duration of this transaction. This provides commit ordering
+ and guarantees serializability across multiple transactions.
+ - If in autocommit mode, or outside a transactional context,
+ automatically release metadata locks of the current statement.
+ */
thd->mdl_context.release_transactional_locks();
}
@@ -4858,7 +4861,7 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
ER_YES, str.ptr());
}
if (res)
- result->abort();
+ result->abort_result_set();
else
result->send_eof();
delete result;
@@ -5911,12 +5914,6 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
query_cache_abort(&thd->query_cache_tls);
}
- if (thd->lex->sphead)
- {
- delete thd->lex->sphead;
- thd->lex->sphead= 0;
- }
- lex->unit.cleanup();
thd_proc_info(thd, "freeing items");
thd->end_statement();
thd->cleanup_after_query();
@@ -6064,7 +6061,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
void store_position_for_column(const char *name)
{
- current_thd->lex->last_field->after=my_const_cast(char*) (name);
+ current_thd->lex->last_field->after=(char*) (name);
}
bool
@@ -7022,11 +7019,15 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query)
only_kill_query Should it kill the query or the connection
*/
+static
void sql_kill(THD *thd, ulong id, bool only_kill_query)
{
uint error;
if (!(error= kill_one_thread(thd, id, only_kill_query)))
- my_ok(thd);
+ {
+ if (! thd->killed)
+ my_ok(thd);
+ }
else
my_error(error, MYF(0), id);
}
@@ -7536,28 +7537,6 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
if (select_lex->item_list.elements)
{
/* Check permissions for used tables in CREATE TABLE ... SELECT */
-
-#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT
- /* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */
- /*
- Only do the check for PS, because we on execute we have to check that
- against the opened tables to ensure we don't use a table that is part
- of the view (which can only be done after the table has been opened).
- */
- if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
- {
- /*
- For temporary tables we don't have to check if the created table exists
- */
- if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
- find_table_in_global_list(tables, create_table->db,
- create_table->table_name))
- {
- error= FALSE;
- goto err;
- }
- }
-#endif
if (tables && check_table_access(thd, SELECT_ACL, tables, FALSE,
UINT_MAX, FALSE))
goto err;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index b55e8a46bc3..8b7fe8f7b83 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -51,7 +51,6 @@ bool parse_sql(THD *thd,
Object_creation_ctx *creation_ctx);
uint kill_one_thread(THD *thd, ulong id, bool only_kill_query);
-void sql_kill(THD *thd, ulong id, bool only_kill_query);
void free_items(Item *item);
void cleanup_items(Item *item);
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index ed6d3af2e43..fb880cce8d3 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -59,7 +59,7 @@
#include "my_md5.h"
#include "transaction.h"
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_all_tables_for_name
#include "sql_table.h" // build_table_filename,
// build_table_shadow_filename,
// table_to_filename
@@ -6756,7 +6756,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
table_list, FALSE, NULL,
written_bin_log));
err:
- close_thread_tables(thd);
DBUG_RETURN(TRUE);
}
#endif
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 2b6be403fc6..7e8c1fed999 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -21,7 +21,7 @@
#include "sql_locale.h"
#include "sql_plugin.h"
#include "sql_parse.h" // check_table_access
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_mysql_tables
#include "key.h" // key_copy
#include "sql_show.h" // remove_status_vars, add_status_vars
#include "strfunc.h" // find_set
@@ -901,19 +901,6 @@ static void plugin_del(struct st_plugin_int *plugin)
DBUG_VOID_RETURN;
}
-#ifdef NOT_USED
-
-static void plugin_del(const LEX_STRING *name)
-{
- struct st_plugin_int *plugin;
- DBUG_ENTER("plugin_del(name)");
- if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
- plugin_del(plugin);
- DBUG_VOID_RETURN;
-}
-
-#endif
-
static void reap_plugins(void)
{
uint count, idx;
@@ -1394,51 +1381,6 @@ static bool register_builtin(struct st_mysql_plugin *plugin,
DBUG_RETURN(0);
}
-#ifdef NOT_USED_YET
-/*
- Register a plugin at run time. (note, this doesn't initialize a plugin)
- Will be useful for embedded applications.
-
- SYNOPSIS
- plugin_register_builtin()
- thd current thread (used to store scratch data in mem_root)
- plugin static plugin to install
-
- RETURN
- false - plugin registered successfully
-*/
-bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin)
-{
- struct st_plugin_int tmp, *ptr;
- bool result= true;
- int dummy_argc= 0;
- DBUG_ENTER("plugin_register_builtin");
-
- bzero(&tmp, sizeof(tmp));
- tmp.plugin= plugin;
- tmp.name.str= (char *)plugin->name;
- tmp.name.length= strlen(plugin->name);
-
- mysql_mutex_lock(&LOCK_plugin);
- mysql_rwlock_wrlock(&LOCK_system_variables_hash);
-
- if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL))
- goto end;
- tmp.state= PLUGIN_IS_UNINITIALIZED;
- if ((result= register_builtin(plugin, &tmp, &ptr)))
- {
- mysql_del_sys_var_chain(tmp.system_vars);
- restore_pluginvar_names(tmp.system_vars);
- }
-
-end:
- mysql_rwlock_unlock(&LOCK_system_variables_hash);
- mysql_mutex_unlock(&LOCK_plugin);
-
- DBUG_RETURN(result);;
-}
-#endif /* NOT_USED_YET */
-
/*
called only by plugin_init()
@@ -1511,8 +1453,8 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info);
table->m_needs_reopen= TRUE; // Force close to free memory
+ close_mysql_tables(new_thd);
end:
- close_thread_tables(new_thd);
/* Remember that we don't have a THD */
my_pthread_setspecific_ptr(THR_THD, 0);
DBUG_VOID_RETURN;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index e6731a7bc4d..39cebfbe048 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -90,7 +90,7 @@ When one supplies long data for a placeholder:
#include "set_var.h"
#include "sql_prepare.h"
#include "sql_parse.h" // insert_precheck, update_precheck, delete_precheck
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // open_normal_and_derived_tables
#include "sql_cache.h" // query_cache_*
#include "sql_view.h" // create_view_precheck
#include "sql_delete.h" // mysql_prepare_delete
@@ -152,6 +152,7 @@ public:
THD *thd;
Select_fetch_protocol_binary result;
Item_param **param_array;
+ Server_side_cursor *cursor;
uint param_count;
uint last_errno;
uint flags;
@@ -2675,7 +2676,6 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length)
if (!cursor->is_open())
{
stmt->close_cursor();
- thd->cursor= 0;
reset_stmt_params(stmt);
}
@@ -2992,12 +2992,6 @@ Execute_sql_statement::execute_server_code(THD *thd)
error= mysql_execute_command(thd);
- if (thd->killed_errno())
- {
- if (! thd->stmt_da->is_set())
- thd->send_kill_message();
- }
-
/* report error issued during command execution */
if (error == 0 && thd->spcont == NULL)
general_log_write(thd, COM_STMT_EXECUTE,
@@ -3019,6 +3013,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg)
thd(thd_arg),
result(thd_arg),
param_array(0),
+ cursor(0),
param_count(0),
last_errno(0),
flags((uint) IS_IN_USE)
@@ -3105,13 +3100,8 @@ void Prepared_statement::cleanup_stmt()
DBUG_ENTER("Prepared_statement::cleanup_stmt");
DBUG_PRINT("enter",("stmt: 0x%lx", (long) this));
- delete lex->sphead;
- lex->sphead= 0;
- /* The order is important */
- lex->unit.cleanup();
cleanup_items(free_list);
thd->cleanup_after_query();
- close_thread_tables(thd);
thd->rollback_item_tree_changes();
DBUG_VOID_RETURN;
@@ -3275,21 +3265,16 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
to PREPARE stmt FROM "CREATE PROCEDURE ..."
*/
DBUG_ASSERT(lex->sphead == NULL || error != 0);
- if (lex->sphead)
- {
- delete lex->sphead;
- lex->sphead= NULL;
- }
+ /* The order is important */
+ lex->unit.cleanup();
+
+ /* No need to commit statement transaction, it's not started. */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
+ close_thread_tables(thd);
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
lex_end(lex);
cleanup_stmt();
- /*
- If not inside a multi-statement transaction, the metadata
- locks have already been released and our savepoint points
- to ticket which has been released as well.
- */
- if (thd->in_multi_stmt_transaction_mode())
- thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
thd->restore_backup_statement(this, &stmt_backup);
thd->stmt_arena= old_stmt_arena;
@@ -3396,11 +3381,6 @@ Prepared_statement::set_parameters(String *expanded_query,
and execute of a new statement. If this happens repeatedly
more than MAX_REPREPARE_ATTEMPTS times, we give up.
- In future we need to be able to keep the metadata locks between
- prepare and execute, but right now open_and_lock_tables(), as
- well as close_thread_tables() are buried deep inside
- execution code (mysql_execute_command()).
-
@return TRUE if an error, FALSE if success
@retval TRUE either MAX_REPREPARE_ATTEMPTS has been reached,
or some general error
@@ -3487,11 +3467,6 @@ Prepared_statement::execute_server_runnable(Server_runnable *server_runnable)
error= server_runnable->execute_server_code(thd);
- delete lex->sphead;
- lex->sphead= 0;
- /* The order is important */
- lex->unit.cleanup();
- close_thread_tables(thd);
thd->cleanup_after_query();
thd->restore_active_arena(this, &stmt_backup);
@@ -3780,8 +3755,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
/* Go! */
if (open_cursor)
- error= mysql_open_cursor(thd, (uint) ALWAYS_MATERIALIZED_CURSOR,
- &result, &cursor);
+ error= mysql_open_cursor(thd, &result, &cursor);
else
{
/*
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index 604890ffbe5..f0f6a1969f5 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -59,8 +59,6 @@
(Old), (New)); \
} while(0)
-extern char err_shared_dir[];
-
/*************************************************************************/
#endif
@@ -135,6 +133,16 @@ extern char err_shared_dir[];
Type of locks to be acquired is specified directly.
*/
#define SELECT_HIGH_PRIORITY (1ULL << 34) // SELECT, user
+/**
+ Is set in slave SQL thread when there was an
+ error on master, which, when is not reproducible
+ on slave (i.e. the query succeeds on slave),
+ is not terminal to the state of repliation,
+ and should be ignored. The slave SQL thread,
+ however, needs to rollback the effects of the
+ succeeded statement to keep replication consistent.
+*/
+#define OPTION_MASTER_SQL_ERROR (1ULL << 35)
/* The rest of the file is included in the server only */
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 130a99a374f..301b22bd70e 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -24,10 +24,9 @@
#include "sql_table.h" // build_table_filename
#include "sql_view.h" // mysql_frm_type, mysql_rename_view
#include "sql_trigger.h"
-#include "lock.h" // wait_if_global_read_lock, lock_table_names,
- // unlock_table_names,
+#include "lock.h" // wait_if_global_read_lock
// start_waiting_global_read_lock
-#include "sql_base.h" // tdc_remove_table
+#include "sql_base.h" // tdc_remove_table, lock_table_names,
#include "sql_handler.h" // mysql_ha_rm_tables
#include "datadict.h"
@@ -144,7 +143,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
}
}
- if (lock_table_names(thd, table_list))
+ if (lock_table_names(thd, table_list, 0, thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
goto err;
mysql_mutex_lock(&LOCK_open);
@@ -197,7 +197,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
if (!error)
query_cache_invalidate3(thd, table_list, 0);
- unlock_table_names(thd);
+ thd->mdl_context.release_transactional_locks();
err:
thd->global_read_lock.start_waiting_global_read_lock(thd);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 74d05780f81..ccfd93a1bc8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -33,7 +33,6 @@
#include "sql_select.h"
#include "sql_cache.h" // query_cache_*
#include "sql_table.h" // primary_key_name
-#include "sql_cursor.h"
#include "probes_mysql.h"
#include "key.h" // key_copy, key_cmp, key_cmp_if_same
#include "lock.h" // mysql_unlock_some_tables,
@@ -300,7 +299,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
thd->is_error()));
res|= thd->is_error();
if (unlikely(res))
- result->abort();
+ result->abort_result_set();
MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows);
DBUG_RETURN(res);
@@ -2340,35 +2339,13 @@ JOIN::exec()
curr_join->fields= curr_fields_list;
curr_join->procedure= procedure;
- if (is_top_level_join() && thd->cursor && tables != const_tables)
- {
- /*
- We are here if this is JOIN::exec for the last select of the main unit
- and the client requested to open a cursor.
- We check that not all tables are constant because this case is not
- handled by do_select() separately, and this case is not implemented
- for cursors yet.
- */
- DBUG_ASSERT(error == 0);
- /*
- curr_join is used only for reusable joins - that is,
- to perform SELECT for each outer row (like in subselects).
- This join is main, so we know for sure that curr_join == join.
- */
- DBUG_ASSERT(curr_join == this);
- /* Open cursor for the last join sweep */
- error= thd->cursor->open(this);
- }
- else
- {
- thd_proc_info(thd, "Sending data");
- DBUG_PRINT("info", ("%s", thd->proc_info));
- result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list :
- *curr_fields_list),
- Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
- error= do_select(curr_join, curr_fields_list, NULL, procedure);
- thd->limit_found_rows= curr_join->send_records;
- }
+ thd_proc_info(thd, "Sending data");
+ DBUG_PRINT("info", ("%s", thd->proc_info));
+ result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list :
+ *curr_fields_list),
+ Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
+ error= do_select(curr_join, curr_fields_list, NULL, procedure);
+ thd->limit_found_rows= curr_join->send_records;
/* Accumulate the counts from all join iterations of all join parts. */
thd->examined_row_count+= curr_join->examined_rows;
@@ -2563,16 +2540,6 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
join->exec();
- if (thd->cursor && thd->cursor->is_open())
- {
- /*
- A cursor was opened for the last sweep in exec().
- We are here only if this is mysql_select for top-level SELECT_LEX_UNIT
- and there were no error.
- */
- free_join= 0;
- }
-
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
select_lex->where= join->conds_history;
@@ -11642,37 +11609,23 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
enum_nested_loop_state rc;
READ_RECORD *info= &join_tab->read_record;
- if (join->resume_nested_loop)
- {
- /* If not the last table, plunge down the nested loop */
- if (join_tab < join->join_tab + join->tables - 1)
- rc= (*join_tab->next_select)(join, join_tab + 1, 0);
- else
- {
- join->resume_nested_loop= FALSE;
- rc= NESTED_LOOP_OK;
- }
- }
- else
- {
- join->return_tab= join_tab;
+ join->return_tab= join_tab;
- if (join_tab->last_inner)
- {
- /* join_tab is the first inner table for an outer join operation. */
-
- /* Set initial state of guard variables for this table.*/
- join_tab->found=0;
- join_tab->not_null_compl= 1;
+ if (join_tab->last_inner)
+ {
+ /* join_tab is the first inner table for an outer join operation. */
- /* Set first_unmatched for the last inner table of this group */
- join_tab->last_inner->first_unmatched= join_tab;
- }
- join->thd->warning_info->reset_current_row_for_warning();
+ /* Set initial state of guard variables for this table.*/
+ join_tab->found=0;
+ join_tab->not_null_compl= 1;
- error= (*join_tab->read_first_record)(join_tab);
- rc= evaluate_join_record(join, join_tab, error);
+ /* Set first_unmatched for the last inner table of this group */
+ join_tab->last_inner->first_unmatched= join_tab;
}
+ join->thd->warning_info->reset_current_row_for_warning();
+
+ error= (*join_tab->read_first_record)(join_tab);
+ rc= evaluate_join_record(join, join_tab, error);
while (rc == NESTED_LOOP_OK)
{
@@ -12480,11 +12433,6 @@ join_ft_read_first(JOIN_TAB *tab)
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 1);
-#if NOT_USED_YET
- /* as ft-key doesn't use store_key's, see also FT_SELECT::init() */
- if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
- return -1;
-#endif
table->file->ft_init();
if ((error= table->file->ft_read(table->record[0])))
@@ -12774,22 +12722,6 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{
copy_fields(&join->tmp_table_param);
copy_funcs(join->tmp_table_param.items_to_copy);
-#ifdef TO_BE_DELETED
- if (!table->uniques) // If not unique handling
- {
- /* Copy null values from group to row */
- ORDER *group;
- for (group=table->group ; group ; group=group->next)
- {
- Item *item= *group->item;
- if (item->maybe_null)
- {
- Field *field=item->get_tmp_table_field();
- field->ptr[-1]= (uchar) (field->is_null() ? 1 : 0);
- }
- }
- }
-#endif
if (!join->having || join->having->val_int())
{
int error;
@@ -13265,7 +13197,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
DBUG_RETURN(0);
}
- if (key_part->field != field)
+ if (key_part->field != field || !field->part_of_sortkey.is_set(idx))
DBUG_RETURN(0);
/* set flag to 1 if we can use read-next on key, else to -1 */
@@ -13997,44 +13929,6 @@ err:
DBUG_RETURN(-1);
}
-#ifdef NOT_YET
-/**
- Add the HAVING criteria to table->select.
-*/
-
-static bool fix_having(JOIN *join, Item **having)
-{
- (*having)->update_used_tables(); // Some tables may have been const
- JOIN_TAB *table=&join->join_tab[join->const_tables];
- table_map used_tables= join->const_table_map | table->table->map;
-
- DBUG_EXECUTE("where",print_where(*having,"having", QT_ORDINARY););
- Item* sort_table_cond=make_cond_for_table(*having,used_tables,used_tables);
- if (sort_table_cond)
- {
- if (!table->select)
- if (!(table->select=new SQL_SELECT))
- return 1;
- if (!table->select->cond)
- table->select->cond=sort_table_cond;
- else // This should never happen
- if (!(table->select->cond= new Item_cond_and(table->select->cond,
- sort_table_cond)) ||
- table->select->cond->fix_fields(join->thd, &table->select->cond))
- return 1;
- table->select_cond=table->select->cond;
- table->select_cond->top_level_item();
- DBUG_EXECUTE("where",print_where(table->select_cond,
- "select and having",
- QT_ORDINARY););
- *having=make_cond_for_table(*having,~ (table_map) 0,~used_tables);
- DBUG_EXECUTE("where",
- print_where(*having,"having after make_cond", QT_ORDINARY););
- }
- return 0;
-}
-#endif
-
/*****************************************************************************
Remove duplicates from tmp table
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 0496870bb3f..40f9e6d4054 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -309,11 +309,6 @@ public:
bool sort_and_group;
bool first_record,full_join,group, no_field_update;
bool do_send_rows;
- /**
- TRUE when we want to resume nested loop iterations when
- fetching data from a cursor
- */
- bool resume_nested_loop;
table_map const_table_map,found_const_table_map;
/*
Bitmap of all inner tables from outer joins
@@ -479,7 +474,6 @@ public:
sort_and_group= 0;
first_record= 0;
do_send_rows= 1;
- resume_nested_loop= FALSE;
send_records= 0;
found_records= 0;
fetch_limit= HA_POS_ERROR;
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index c7f9cf0b132..cfbf8e96719 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -36,7 +36,7 @@
#include "sql_priv.h"
#include "sql_servers.h"
#include "unireg.h"
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_mysql_tables
#include "records.h" // init_read_record, end_read_record
#include "hash_filo.h"
#include <m_ctype.h>
@@ -280,9 +280,7 @@ bool servers_reload(THD *thd)
}
end:
- trans_commit_implicit(thd);
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
+ close_mysql_tables(thd);
DBUG_PRINT("info", ("unlocking servers_cache"));
mysql_rwlock_unlock(&THR_LOCK_servers);
DBUG_RETURN(return_val);
@@ -535,6 +533,7 @@ int insert_server_record(TABLE *table, FOREIGN_SERVER *server)
{
int error;
DBUG_ENTER("insert_server_record");
+ tmp_disable_binlog(table->in_use);
table->use_all_columns();
empty_record(table);
@@ -571,6 +570,8 @@ int insert_server_record(TABLE *table, FOREIGN_SERVER *server)
}
else
error= ER_FOREIGN_SERVER_EXISTS;
+
+ reenable_binlog(table->in_use);
DBUG_RETURN(error);
}
@@ -625,7 +626,7 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
error= delete_server_record(table, name.str, name.length);
/* close the servers table before we call closed_cached_connection_tables */
- close_thread_tables(thd);
+ close_mysql_tables(thd);
if (close_cached_connection_tables(thd, TRUE, &name))
{
@@ -880,6 +881,7 @@ update_server_record(TABLE *table, FOREIGN_SERVER *server)
{
int error=0;
DBUG_ENTER("update_server_record");
+ tmp_disable_binlog(table->in_use);
table->use_all_columns();
/* set the field that's the PK to the value we're looking for */
table->field[0]->store(server->server_name,
@@ -913,6 +915,7 @@ update_server_record(TABLE *table, FOREIGN_SERVER *server)
}
end:
+ reenable_binlog(table->in_use);
DBUG_RETURN(error);
}
@@ -938,6 +941,7 @@ delete_server_record(TABLE *table,
{
int error;
DBUG_ENTER("delete_server_record");
+ tmp_disable_binlog(table->in_use);
table->use_all_columns();
/* set the field that's the PK to the value we're looking for */
@@ -959,6 +963,7 @@ delete_server_record(TABLE *table,
table->file->print_error(error, MYF(0));
}
+ reenable_binlog(table->in_use);
DBUG_RETURN(error);
}
@@ -1050,7 +1055,7 @@ int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
error= update_server(thd, existing, altered);
/* close the servers table before we call closed_cached_connection_tables */
- close_thread_tables(thd);
+ close_mysql_tables(thd);
if (close_cached_connection_tables(thd, FALSE, &name))
{
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 939db979804..4d58db2e36c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -660,22 +660,30 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
Protocol *protocol= thd->protocol;
char buff[2048];
String buffer(buff, sizeof(buff), system_charset_info);
+ List<Item> field_list;
+ bool error= TRUE;
DBUG_ENTER("mysqld_show_create");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->table_name));
+ /*
+ Metadata locks taken during SHOW CREATE should be released when
+ the statmement completes as it is an information statement.
+ */
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
+
/* We want to preserve the tree for views. */
thd->lex->view_prepare_mode= TRUE;
{
Show_create_error_handler view_error_suppressor(thd, table_list);
thd->push_internal_handler(&view_error_suppressor);
- bool error=
+ bool open_error=
open_normal_and_derived_tables(thd, table_list,
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL);
thd->pop_internal_handler();
- if (error && (thd->killed || thd->is_error()))
- DBUG_RETURN(TRUE);
+ if (open_error && (thd->killed || thd->is_error()))
+ goto exit;
}
/* TODO: add environment variables show when it become possible */
@@ -683,7 +691,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
{
my_error(ER_WRONG_OBJECT, MYF(0),
table_list->db, table_list->table_name, "VIEW");
- DBUG_RETURN(TRUE);
+ goto exit;
}
buffer.length(0);
@@ -695,9 +703,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
view_store_create_info(thd, table_list, &buffer) :
store_create_info(thd, table_list, &buffer, NULL,
FALSE /* show_database */)))
- DBUG_RETURN(TRUE);
+ goto exit;
- List<Item> field_list;
if (table_list->view)
{
field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
@@ -718,7 +725,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(TRUE);
+ goto exit;
+
protocol->prepare_for_resend();
if (table_list->view)
protocol->store(table_list->view_name.str, system_charset_info);
@@ -746,10 +754,16 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
- DBUG_RETURN(TRUE);
+ goto exit;
+ error= FALSE;
my_eof(thd);
- DBUG_RETURN(FALSE);
+
+exit:
+ close_thread_tables(thd);
+ /* Release any metadata locks taken during SHOW CREATE. */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+ DBUG_RETURN(error);
}
bool mysqld_show_create_db(THD *thd, char *dbname,
@@ -5709,52 +5723,6 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
}
-#ifdef NOT_USED
-static interval_type get_real_interval_type(interval_type i_type)
-{
- switch (i_type) {
- case INTERVAL_YEAR:
- return INTERVAL_YEAR;
-
- case INTERVAL_QUARTER:
- case INTERVAL_YEAR_MONTH:
- case INTERVAL_MONTH:
- return INTERVAL_MONTH;
-
- case INTERVAL_WEEK:
- case INTERVAL_DAY:
- return INTERVAL_DAY;
-
- case INTERVAL_DAY_HOUR:
- case INTERVAL_HOUR:
- return INTERVAL_HOUR;
-
- case INTERVAL_DAY_MINUTE:
- case INTERVAL_HOUR_MINUTE:
- case INTERVAL_MINUTE:
- return INTERVAL_MINUTE;
-
- case INTERVAL_DAY_SECOND:
- case INTERVAL_HOUR_SECOND:
- case INTERVAL_MINUTE_SECOND:
- case INTERVAL_SECOND:
- return INTERVAL_SECOND;
-
- case INTERVAL_DAY_MICROSECOND:
- case INTERVAL_HOUR_MICROSECOND:
- case INTERVAL_MINUTE_MICROSECOND:
- case INTERVAL_SECOND_MICROSECOND:
- case INTERVAL_MICROSECOND:
- return INTERVAL_MICROSECOND;
- case INTERVAL_LAST:
- DBUG_ASSERT(0);
- }
- DBUG_ASSERT(0);
- return INTERVAL_SECOND;
-}
-
-#endif
-
#ifdef HAVE_EVENT_SCHEDULER
/*
Loads an event from mysql.event and copies it's data to a row of
@@ -7774,6 +7742,10 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
bool show_create_trigger(THD *thd, const sp_name *trg_name)
{
TABLE_LIST *lst= get_trigger_table(thd, trg_name);
+ uint num_tables; /* NOTE: unused, only to pass to open_tables(). */
+ Table_triggers_list *triggers;
+ int trigger_idx;
+ bool error= TRUE;
if (!lst)
return TRUE;
@@ -7785,35 +7757,35 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name)
}
/*
- Open the table by name in order to load Table_triggers_list object.
-
- NOTE: there is race condition here -- the table can be dropped after
- LOCK_open is released. It will be fixed later by acquiring shared
- metadata lock on trigger or table name.
+ Metadata locks taken during SHOW CREATE TRIGGER should be released when
+ the statement completes as it is an information statement.
*/
+ MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
- uint num_tables; /* NOTE: unused, only to pass to open_tables(). */
-
- if (open_tables(thd, &lst, &num_tables, 0))
+ /*
+ Open the table by name in order to load Table_triggers_list object.
+ */
+ if (open_tables(thd, &lst, &num_tables,
+ MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
{
my_error(ER_TRG_CANT_OPEN_TABLE, MYF(0),
(const char *) trg_name->m_db.str,
(const char *) lst->table_name);
- return TRUE;
+ goto exit;
/* Perform closing actions and return error status. */
}
- Table_triggers_list *triggers= lst->table->triggers;
+ triggers= lst->table->triggers;
if (!triggers)
{
my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
- return TRUE;
+ goto exit;
}
- int trigger_idx= triggers->find_trigger_by_name(&trg_name->m_name);
+ trigger_idx= triggers->find_trigger_by_name(&trg_name->m_name);
if (trigger_idx < 0)
{
@@ -7821,16 +7793,22 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name)
(const char *) trg_name->m_db.str,
(const char *) lst->table_name);
- return TRUE;
+ goto exit;
}
- return show_create_trigger_impl(thd, triggers, trigger_idx);
+ error= show_create_trigger_impl(thd, triggers, trigger_idx);
/*
NOTE: if show_create_trigger_impl() failed, that means we could not
send data to the client. In this case we simply raise the error
status and client connection will be closed.
*/
+
+exit:
+ close_thread_tables(thd);
+ /* Release any metadata locks taken during SHOW CREATE TRIGGER. */
+ thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
+ return error;
}
class IS_internal_schema_access : public ACL_internal_schema_access
diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc
index f340da373e8..09e9a828fa1 100644
--- a/sql/sql_signal.cc
+++ b/sql/sql_signal.cc
@@ -499,18 +499,6 @@ bool Resignal_statement::execute(THD *thd)
}
/* RESIGNAL with signal_value */
-
- /* Make room for 2 conditions */
- thd->warning_info->reserve_space(thd, 2);
-
- MYSQL_ERROR *raised= NULL;
- raised= thd->raise_condition_no_handler(signaled->get_sql_errno(),
- signaled->get_sqlstate(),
- signaled->get_level(),
- signaled->get_message_text());
- if (raised)
- raised->copy_opt_attributes(signaled);
-
result= raise_condition(thd, signaled);
DBUG_RETURN(result);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 4471c336188..02a874ce62f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -22,17 +22,17 @@
#include "sql_rename.h" // do_rename
#include "sql_parse.h" // test_if_data_home_dir
#include "sql_cache.h" // query_cache_*
-#include "sql_base.h" // open_temporary_table
-#include "lock.h" // wait_if_global_read_lock, lock_table_names,
+#include "sql_base.h" // open_temporary_table, lock_table_names
+#include "lock.h" // wait_if_global_read_lock
// start_waiting_global_read_lock,
- // unlock_table_names, mysql_unlock_tables
+ // mysql_unlock_tables
#include "strfunc.h" // find_type2, find_set
#include "sql_view.h" // view_checksum
#include "sql_truncate.h" // regenerate_locked_table
#include "sql_partition.h" // mem_alloc_error,
// generate_partition_syntax,
// partition_info
-#include "sql_db.h" // load_db_opt_by_name, lock_db_cache, creating_database
+#include "sql_db.h" // load_db_opt_by_name
#include "sql_time.h" // make_truncated_value_warning
#include "records.h" // init_read_record, end_read_record
#include "filesort.h" // filesort_free_buffers
@@ -58,8 +58,6 @@
#include <io.h>
#endif
-int creating_table= 0; // How many mysql_create_table are running
-
const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
@@ -1954,7 +1952,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
{
if (!thd->locked_tables_mode)
{
- if (lock_table_names(thd, tables))
+ if (lock_table_names(thd, tables, NULL, thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
DBUG_RETURN(1);
mysql_mutex_lock(&LOCK_open);
for (table= tables; table; table= table->next_local)
@@ -1964,7 +1963,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
else
{
for (table= tables; table; table= table->next_local)
- if (find_temporary_table(thd, table->db, table->table_name))
+ if (table->open_type != OT_BASE_ONLY &&
+ find_temporary_table(thd, table->db, table->table_name))
{
/*
A temporary table.
@@ -2009,8 +2009,11 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
table->db, table->table_name, (long) table->table,
table->table ? (long) table->table->s : (long) -1));
- error= drop_temporary_table(thd, table);
-
+ if (table->open_type == OT_BASE_ONLY)
+ error= 1;
+ else
+ error= drop_temporary_table(thd, table);
+
switch (error) {
case 0:
// removed temporary table
@@ -2282,18 +2285,13 @@ err:
{
/*
Under LOCK TABLES we should release meta-data locks on the tables
- which were dropped. Otherwise we can rely on close_thread_tables()
- doing this. Unfortunately in this case we are likely to get more
- false positives in try_acquire_lock() function. So
- it makes sense to remove exclusive meta-data locks in all cases.
+ which were dropped.
Leave LOCK TABLES mode if we managed to drop all tables which were
locked. Additional check for 'non_temp_tables_count' is to avoid
leaving LOCK TABLES mode if we have dropped only temporary tables.
*/
- if (! thd->locked_tables_mode)
- unlock_table_names(thd);
- else
+ if (thd->locked_tables_mode)
{
if (thd->lock && thd->lock->table_count == 0 && non_temp_tables_count > 0)
{
@@ -2302,7 +2300,8 @@ err:
}
for (table= tables; table; table= table->next_local)
{
- if (table->mdl_request.ticket)
+ /* Drop locks for all successfully dropped tables. */
+ if (table->table == NULL && table->mdl_request.ticket)
{
/*
Under LOCK TABLES we may have several instances of table open
@@ -2313,6 +2312,10 @@ err:
}
}
}
+ /*
+ Rely on the caller to implicitly commit the transaction
+ and release metadata locks.
+ */
}
end:
@@ -4211,8 +4214,14 @@ warn:
}
-/*
- Database and name-locking aware wrapper for mysql_create_table_no_lock(),
+/**
+ Implementation of SQLCOM_CREATE_TABLE.
+
+ Take the metadata locks (including a shared lock on the affected
+ schema) and create the table. Is written to be called from
+ mysql_execute_command(), to which it delegates the common parts
+ with other commands (i.e. implicit commit before and after,
+ close of thread tables.
*/
bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
@@ -4222,31 +4231,13 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
bool result;
DBUG_ENTER("mysql_create_table");
- /* Wait for any database locks */
- mysql_mutex_lock(&LOCK_lock_db);
- while (!thd->killed &&
- my_hash_search(&lock_db_cache, (uchar*)create_table->db,
- create_table->db_length))
- {
- wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
- mysql_mutex_lock(&LOCK_lock_db);
- }
-
- if (thd->killed)
- {
- mysql_mutex_unlock(&LOCK_lock_db);
- DBUG_RETURN(TRUE);
- }
- creating_table++;
- mysql_mutex_unlock(&LOCK_lock_db);
-
/*
Open or obtain an exclusive metadata lock on table being created.
*/
if (open_and_lock_tables(thd, thd->lex->query_tables, FALSE, 0))
{
result= TRUE;
- goto unlock;
+ goto end;
}
/* Got lock. */
@@ -4268,20 +4259,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
!(create_info->options & HA_LEX_CREATE_TMP_TABLE))))
result= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
- if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
- {
- /*
- close_thread_tables() takes care about both closing open tables (which
- might be still around in case of error) and releasing metadata locks.
- */
- close_thread_tables(thd);
- }
-
-unlock:
- mysql_mutex_lock(&LOCK_lock_db);
- if (!--creating_table && creating_database)
- mysql_cond_signal(&COND_refresh);
- mysql_mutex_unlock(&LOCK_lock_db);
+end:
DBUG_RETURN(result);
}
@@ -4454,8 +4432,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
{
char key[MAX_DBKEY_LENGTH];
uint key_length;
- MDL_request mdl_global_request;
- MDL_request_list mdl_requests;
/*
If the table didn't exist, we have a shared metadata lock
on it that is left from mysql_admin_table()'s attempt to
@@ -4475,12 +4451,9 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
table_list->db, table_list->table_name,
MDL_EXCLUSIVE);
- mdl_global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
- mdl_requests.push_front(&table_list->mdl_request);
- mdl_requests.push_front(&mdl_global_request);
-
- if (thd->mdl_context.acquire_locks(&mdl_requests,
- thd->variables.lock_wait_timeout))
+ if (lock_table_names(thd, table_list, table_list->next_global,
+ thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
DBUG_RETURN(0);
has_mdl_lock= TRUE;
@@ -4776,6 +4749,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
trans_rollback_stmt(thd);
trans_rollback(thd);
close_thread_tables(thd);
+ thd->mdl_context.release_transactional_locks();
DBUG_PRINT("admin", ("simple error, admin next table"));
continue;
case -1: // error, message could be written to net
@@ -5062,11 +5036,11 @@ send_result_message:
trans_commit_stmt(thd);
trans_commit(thd);
close_thread_tables(thd);
- table->table= NULL;
thd->mdl_context.release_transactional_locks();
+ table->table= NULL;
if (!result_code) // recreation went ok
{
- /* Clear the ticket released in close_thread_tables(). */
+ /* Clear the ticket released above. */
table->mdl_request.ticket= NULL;
DEBUG_SYNC(thd, "ha_admin_open_ltable");
table->mdl_request.set_type(MDL_SHARED_WRITE);
@@ -5170,7 +5144,8 @@ send_result_message:
May be something modified. Consequently, we have to
invalidate the query cache.
*/
- query_cache_invalidate3(thd, table->table, 0);
+ table->table= 0; // For query cache
+ query_cache_invalidate3(thd, table, 0);
}
}
/* Error path, a admin command failed. */
@@ -5178,7 +5153,6 @@ send_result_message:
trans_commit_implicit(thd);
close_thread_tables(thd);
thd->mdl_context.release_transactional_locks();
- table->table=0; // For query cache
/*
If it is CHECK TABLE v1, v2, v3, and v1, v2, v3 are views, we will run
@@ -6575,6 +6549,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
Alter_table_prelocking_strategy alter_prelocking_strategy(alter_info);
+ DEBUG_SYNC(thd, "alter_table_before_open_tables");
error= open_and_lock_tables(thd, table_list, FALSE, 0,
&alter_prelocking_strategy);
@@ -6751,13 +6726,11 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
goto err;
DBUG_EXECUTE_IF("sleep_alter_enable_indexes", my_sleep(6000000););
error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
- /* COND_refresh will be signaled in close_thread_tables() */
break;
case DISABLE:
if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
goto err;
error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
- /* COND_refresh will be signaled in close_thread_tables() */
break;
default:
DBUG_ASSERT(FALSE);
@@ -6843,8 +6816,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
/*
Under LOCK TABLES we should adjust meta-data locks before finishing
- statement. Otherwise we can rely on close_thread_tables() releasing
- them.
+ statement. Otherwise we can rely on them being released
+ along with the implicit commit.
*/
if (new_name != table_name || new_db != db)
{
@@ -7391,8 +7364,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
5) Write statement to the binary log.
6) If we are under LOCK TABLES and do ALTER TABLE ... RENAME we
remove placeholders and release metadata locks.
- 7) If we are not not under LOCK TABLES we rely on close_thread_tables()
- call to remove placeholders and releasing metadata locks.
+ 7) If we are not not under LOCK TABLES we rely on the caller
+ (mysql_execute_command()) to release metadata locks.
*/
thd_proc_info(thd, "rename result table");
@@ -8021,7 +7994,13 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
}
}
thd->clear_error();
+ if (! thd->in_sub_stmt)
+ trans_rollback_stmt(thd);
close_thread_tables(thd);
+ /*
+ Don't release metadata locks, this will be done at
+ statement end.
+ */
table->table=0; // For query cache
}
if (protocol->write())
@@ -8031,10 +8010,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
my_eof(thd);
DBUG_RETURN(FALSE);
- err:
- close_thread_tables(thd); // Shouldn't be needed
- if (table)
- table->table=0;
+err:
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_table.h b/sql/sql_table.h
index 40b24605bd6..dca4b706605 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -210,7 +210,6 @@ uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
extern MYSQL_PLUGIN_IMPORT const char *primary_key_name;
-extern int creating_table; // How many mysql_create_table() are running
extern mysql_mutex_t LOCK_gdl;
#endif /* SQL_TABLE_INCLUDED */
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 2f084c369b6..a5664b00287 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -540,9 +540,9 @@ end:
}
/*
- If we are under LOCK TABLES we should restore original state of meta-data
- locks. Otherwise call to close_thread_tables() will take care about both
- TABLE instance created by open_n_lock_single_table() and metadata lock.
+ If we are under LOCK TABLES we should restore original state of
+ meta-data locks. Otherwise all locks will be released along
+ with the implicit commit.
*/
if (thd->locked_tables_mode && tables && lock_upgrade_done)
mdl_ticket->downgrade_exclusive_lock(MDL_SHARED_NO_READ_WRITE);
@@ -1321,6 +1321,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
thd->reset_db((char*) db, strlen(db));
while ((trg_create_str= it++))
{
+ sp_head *sp;
trg_sql_mode= itm++;
LEX_STRING *trg_definer= it_definer++;
@@ -1357,13 +1358,14 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
*/
lex.set_trg_event_type_for_tables();
- lex.sphead->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
-
int event= lex.trg_chistics.event;
int action_time= lex.trg_chistics.action_time;
- lex.sphead->set_creation_ctx(creation_ctx);
- triggers->bodies[event][action_time]= lex.sphead;
+ sp= triggers->bodies[event][action_time]= lex.sphead;
+ lex.sphead= NULL; /* Prevent double cleanup. */
+
+ sp->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
+ sp->set_creation_ctx(creation_ctx);
if (!trg_definer->length)
{
@@ -1376,27 +1378,26 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
(const char*) db,
- (const char*) lex.sphead->m_name.str);
+ (const char*) sp->m_name.str);
/*
Set definer to the '' to correct displaying in the information
schema.
*/
- lex.sphead->set_definer((char*) "", 0);
+ sp->set_definer((char*) "", 0);
/*
Triggers without definer information are executed under the
authorization of the invoker.
*/
- lex.sphead->m_chistics->suid= SP_IS_NOT_SUID;
+ sp->m_chistics->suid= SP_IS_NOT_SUID;
}
else
- lex.sphead->set_definer(trg_definer->str, trg_definer->length);
+ sp->set_definer(trg_definer->str, trg_definer->length);
- if (triggers->names_list.push_back(&lex.sphead->m_name,
- &table->mem_root))
+ if (triggers->names_list.push_back(&sp->m_name, &table->mem_root))
goto err_with_lex_cleanup;
if (!(on_table_name= alloc_lex_string(&table->mem_root)))
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index c2482ef1ce0..ee5c707cd69 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -242,9 +242,10 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref,
MDL_ticket **ticket_downgrade)
{
TABLE *table= NULL;
- MDL_ticket *mdl_ticket= NULL;
DBUG_ENTER("open_and_lock_table_for_truncate");
+ DBUG_ASSERT(table_ref->lock_type == TL_WRITE);
+ DBUG_ASSERT(table_ref->mdl_request.type == MDL_SHARED_NO_READ_WRITE);
/*
Before doing anything else, acquire a metadata lock on the table,
or ensure we have one. We don't use open_and_lock_tables()
@@ -266,6 +267,7 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref,
*hton_can_recreate= ha_check_storage_engine_flag(table->s->db_type(),
HTON_CAN_RECREATE);
+ table_ref->mdl_request.ticket= table->mdl_ticket;
}
else
{
@@ -273,21 +275,12 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref,
Even though we could use the previous execution branch here just as
well, we must not try to open the table:
*/
- MDL_request mdl_global_request, mdl_request;
- MDL_request_list mdl_requests;
-
- mdl_global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE);
- mdl_request.init(MDL_key::TABLE, table_ref->db, table_ref->table_name,
- MDL_SHARED_NO_READ_WRITE);
- mdl_requests.push_front(&mdl_request);
- mdl_requests.push_front(&mdl_global_request);
-
- if (thd->mdl_context.acquire_locks(&mdl_requests,
- thd->variables.lock_wait_timeout))
+ DBUG_ASSERT(table_ref->next_global == NULL);
+ if (lock_table_names(thd, table_ref, NULL,
+ thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
DBUG_RETURN(TRUE);
- mdl_ticket= mdl_request.ticket;
-
if (dd_check_storage_engine_flag(thd, table_ref->db, table_ref->table_name,
HTON_CAN_RECREATE, hton_can_recreate))
DBUG_RETURN(TRUE);
@@ -313,7 +306,9 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref,
else
{
ulong timeout= thd->variables.lock_wait_timeout;
- if (thd->mdl_context.upgrade_shared_lock_to_exclusive(mdl_ticket, timeout))
+ if (thd->mdl_context.
+ upgrade_shared_lock_to_exclusive(table_ref->mdl_request.ticket,
+ timeout))
DBUG_RETURN(TRUE);
mysql_mutex_lock(&LOCK_open);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db,
@@ -335,15 +330,14 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref,
table_ref->required_type= FRMTYPE_TABLE;
/* We don't need to load triggers. */
DBUG_ASSERT(table_ref->trg_event_map == 0);
- /* Work around partition parser rules using alter table's. */
- if (thd->lex->alter_info.flags & ALTER_ADMIN_PARTITION)
- {
- table_ref->lock_type= TL_WRITE;
- table_ref->mdl_request.set_type(MDL_SHARED_WRITE);
- }
- /* Ensure proper lock types (e.g. from the parser). */
- DBUG_ASSERT(table_ref->lock_type == TL_WRITE);
- DBUG_ASSERT(table_ref->mdl_request.type == MDL_SHARED_WRITE);
+ /*
+ Even though we have an MDL lock on the table here, we don't
+ pass MYSQL_OPEN_HAS_MDL_LOCK to open_and_lock_tables
+ since to truncate a MERGE table, we must open and lock
+ merge children, and on those we don't have an MDL lock.
+ Thus clear the ticket to satisfy MDL asserts.
+ */
+ table_ref->mdl_request.ticket= NULL;
/*
Open the table as it will handle some required preparations.
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 3d197303fb1..ba1d0ceadeb 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -33,7 +33,7 @@
#include "sql_priv.h"
#include "unireg.h"
-#include "sql_base.h" // close_thread_tables
+#include "sql_base.h" // close_mysql_tables
#include "sql_parse.h" // check_identifier_name
#include "sql_table.h" // write_bin_log
#include "records.h" // init_read_record, end_read_record
@@ -251,7 +251,7 @@ void udf_init()
table->m_needs_reopen= TRUE; // Force close to free memory
end:
- close_thread_tables(new_thd);
+ close_mysql_tables(new_thd);
delete new_thd;
/* Remember that we don't have a THD */
my_pthread_setspecific_ptr(THR_THD, 0);
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 9ca4556524f..acc0f704c44 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -36,8 +36,7 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result,
if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK |
setup_tables_done_option)))
res= unit->exec();
- if (res || !thd->cursor || !thd->cursor->is_open())
- res|= unit->cleanup();
+ res|= unit->cleanup();
DBUG_RETURN(res);
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index c52467531a9..35478e28520 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1261,7 +1261,7 @@ bool mysql_multi_update(THD *thd,
{
/* If we had a another error reported earlier then this will be ignored */
(*result)->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR));
- (*result)->abort();
+ (*result)->abort_result_set();
}
thd->abort_on_warning= 0;
DBUG_RETURN(res);
@@ -1861,7 +1861,7 @@ void multi_update::send_error(uint errcode,const char *err)
}
-void multi_update::abort()
+void multi_update::abort_result_set()
{
/* the error was handled or nothing deleted and no side effects return */
if (error_handled ||
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 69abe70e863..be13349b5a1 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -19,10 +19,10 @@
#include "sql_priv.h"
#include "unireg.h"
#include "sql_view.h"
-#include "sql_base.h" // find_table_in_global_list
+#include "sql_base.h" // find_table_in_global_list, lock_table_names
#include "sql_parse.h" // sql_parse
#include "sql_cache.h" // query_cache_*
-#include "lock.h" // wait_if_global_read_lock, lock_table_names
+#include "lock.h" // wait_if_global_read_lock
#include "sql_show.h" // append_identifier
#include "sql_table.h" // build_table_filename
#include "sql_db.h" // mysql_opt_change_db, mysql_change_db
@@ -1652,7 +1652,8 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
DBUG_RETURN(TRUE);
}
- if (lock_table_names(thd, views))
+ if (lock_table_names(thd, views, 0, thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_TEMPORARY))
DBUG_RETURN(TRUE);
mysql_mutex_lock(&LOCK_open);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3ba67368565..ca951897055 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6440,6 +6440,8 @@ alter_commands:
lex->sql_command= SQLCOM_TRUNCATE;
lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
lex->check_opt.init();
+ lex->query_tables->mdl_request.set_type(MDL_SHARED_NO_READ_WRITE);
+ lex->query_tables->lock_type= TL_WRITE;
}
| reorg_partition_rule
;
@@ -10693,7 +10695,7 @@ truncate:
lex->select_lex.sql_cache= SELECT_LEX::SQL_CACHE_UNSPECIFIED;
lex->select_lex.init_order();
YYPS->m_lock_type= TL_WRITE;
- YYPS->m_mdl_type= MDL_SHARED_WRITE;
+ YYPS->m_mdl_type= MDL_SHARED_NO_READ_WRITE;
}
table_name
{}
@@ -11184,10 +11186,10 @@ flush_options:
Lex->type|= REFRESH_TABLES;
/*
Set type of metadata and table locks for
- FLUSH TABLES table_list WITH READ LOCK.
+ FLUSH TABLES table_list [WITH READ LOCK].
*/
YYPS->m_lock_type= TL_READ_NO_INSERT;
- YYPS->m_mdl_type= MDL_EXCLUSIVE;
+ YYPS->m_mdl_type= MDL_SHARED_HIGH_PRIO;
}
opt_table_list {}
opt_with_read_lock {}
@@ -11197,7 +11199,13 @@ flush_options:
opt_with_read_lock:
/* empty */ {}
| WITH READ_SYM LOCK_SYM
- { Lex->type|= REFRESH_READ_LOCK; }
+ {
+ TABLE_LIST *tables= Lex->query_tables;
+ Lex->type|= REFRESH_READ_LOCK;
+ /* We acquire an X lock currently and then downgrade. */
+ for (; tables; tables= tables->next_global)
+ tables->mdl_request.set_type(MDL_EXCLUSIVE);
+ }
;
flush_options_list:
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 6e95961ebb0..320e6d9253e 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -796,7 +796,11 @@ static Sys_var_lexstring Sys_init_connect(
static Sys_var_charptr Sys_init_file(
"init_file", "Read SQL commands from this file at startup",
READ_ONLY GLOBAL_VAR(opt_init_file),
- IF_DISABLE_GRANT_OPTIONS(NO_CMD_LINE, CMD_LINE(REQUIRED_ARG)),
+#ifdef DISABLE_GRANT_OPTIONS
+ NO_CMD_LINE,
+#else
+ CMD_LINE(REQUIRED_ARG),
+#endif
IN_FS_CHARSET, DEFAULT(0));
static PolyLock_rwlock PLock_sys_init_slave(&LOCK_sys_init_slave);
@@ -2203,14 +2207,21 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type)
thd->variables.option_bits & OPTION_NOT_AUTOCOMMIT)
{ // activating autocommit
- if (trans_commit(thd))
+ if (trans_commit_stmt(thd) || trans_commit(thd))
{
thd->variables.option_bits&= ~OPTION_AUTOCOMMIT;
return true;
}
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
-
+ /*
+ Don't close thread tables or release metadata locks: if we do so, we
+ risk releasing locks/closing tables of expressions used to assign
+ other variables, as in:
+ set @var=my_stored_function1(), @@autocommit=1, @var2=(select max(a)
+ from my_table), ...
+ The locks will be released at statement end anyway, as SET
+ statement that assigns autocommit is marked to commit
+ transaction implicitly at the end (@sa stmt_causes_implicitcommit()).
+ */
thd->variables.option_bits&=
~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_NOT_AUTOCOMMIT);
thd->transaction.all.modified_non_trans_table= false;
@@ -2866,6 +2877,8 @@ static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type)
return false;
}
+static const char *log_output_names[] = { "NONE", "FILE", "TABLE", NULL};
+
static Sys_var_set Sys_log_output(
"log_output", "Syntax: log-output=value[,value...], "
"where \"value\" could be TABLE, FILE or NONE",
diff --git a/sql/table.cc b/sql/table.cc
index df94e70b558..bcdfd23b4c1 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -796,7 +796,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
goto err; /* purecov: inspected */
bzero((char*) keyinfo,n_length);
share->key_info= keyinfo;
- key_part= my_reinterpret_cast(KEY_PART_INFO*) (keyinfo+keys);
+ key_part= reinterpret_cast<KEY_PART_INFO*>(keyinfo+keys);
strpos=disk_buff+6;
if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
@@ -1821,8 +1821,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
if (!(key_info= (KEY*) alloc_root(&outparam->mem_root, n_length)))
goto err;
outparam->key_info= key_info;
- key_part= (my_reinterpret_cast(KEY_PART_INFO*) (key_info+share->keys));
-
+ key_part= (reinterpret_cast<KEY_PART_INFO*>(key_info+share->keys));
+
memcpy(key_info, share->key_info, sizeof(*key_info)*share->keys);
memcpy(key_part, share->key_info[0].key_part, (sizeof(*key_part) *
share->key_parts));
diff --git a/sql/transaction.cc b/sql/transaction.cc
index f6786f20dcf..a28fba8805d 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -28,6 +28,12 @@ static bool trans_check(THD *thd)
enum xa_states xa_state= thd->transaction.xid_state.xa_state;
DBUG_ENTER("trans_check");
+ /*
+ Always commit statement transaction before manipulating with
+ the normal one.
+ */
+ DBUG_ASSERT(thd->transaction.stmt.is_empty());
+
if (unlikely(thd->in_sub_stmt))
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
if (xa_state != XA_NOTR)
@@ -252,6 +258,14 @@ bool trans_commit_stmt(THD *thd)
{
DBUG_ENTER("trans_commit_stmt");
int res= FALSE;
+ /*
+ We currently don't invoke commit/rollback at end of
+ a sub-statement. In future, we perhaps should take
+ a savepoint for each nested statement, and release the
+ savepoint when statement has succeeded.
+ */
+ DBUG_ASSERT(! thd->in_sub_stmt);
+
if (thd->transaction.stmt.ha_list)
{
res= ha_commit_trans(thd, FALSE);
@@ -267,6 +281,9 @@ bool trans_commit_stmt(THD *thd)
RUN_HOOK(transaction, after_rollback, (thd, FALSE));
else
RUN_HOOK(transaction, after_commit, (thd, FALSE));
+
+ thd->transaction.stmt.reset();
+
DBUG_RETURN(test(res));
}
@@ -283,6 +300,14 @@ bool trans_rollback_stmt(THD *thd)
{
DBUG_ENTER("trans_rollback_stmt");
+ /*
+ We currently don't invoke commit/rollback at end of
+ a sub-statement. In future, we perhaps should take
+ a savepoint for each nested statement, and release the
+ savepoint when statement has succeeded.
+ */
+ DBUG_ASSERT(! thd->in_sub_stmt);
+
if (thd->transaction.stmt.ha_list)
{
ha_rollback_trans(thd, FALSE);
@@ -294,6 +319,8 @@ bool trans_rollback_stmt(THD *thd)
RUN_HOOK(transaction, after_rollback, (thd, FALSE));
+ thd->transaction.stmt.reset();
+
DBUG_RETURN(FALSE);
}
diff --git a/sql/tztime.cc b/sql/tztime.cc
index af8574c38f1..43d43123158 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -50,13 +50,6 @@
// MYSQL_LOCK_IGNORE_TIMEOUT
/*
- This forward declaration is needed because including sql_base.h
- causes further includes. [TODO] Eliminate this forward declaration
- and include a file with the prototype instead.
-*/
-extern void close_thread_tables(THD *thd);
-
-/*
Now we don't use abbreviations in server but we will do this in future.
*/
#if defined(TZINFO2SQL) || defined(TESTTIME)
@@ -1784,10 +1777,7 @@ end_with_setting_default_tz:
end_with_close:
if (time_zone_tables_exist)
- {
- close_thread_tables(thd);
- thd->mdl_context.release_transactional_locks();
- }
+ close_mysql_tables(thd);
end_with_cleanup:
diff --git a/sql/udf_example.c b/sql/udf_example.c
index c1dbdd069a9..36828bdf94d 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -133,7 +133,6 @@ typedef long long longlong;
#include <string.h>
#define strmov(a,b) stpcpy(a,b)
#define bzero(a,b) memset(a,0,b)
-#define memcpy_fixed(a,b,c) memcpy(a,b,c)
#endif
#endif
#include <mysql.h>
@@ -778,7 +777,7 @@ char *lookup(UDF_INIT *initid __attribute__((unused)), UDF_ARGS *args,
}
pthread_mutex_unlock(&LOCK_hostname);
#endif
- memcpy_fixed((char*) &in,(char*) *hostent->h_addr_list, sizeof(in.s_addr));
+ memcpy(&in, *hostent->h_addr_list, sizeof(in.s_addr));
*res_length= (ulong) (strmov(result, inet_ntoa(in)) - result);
return result;
}
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index c1dd6e6f38c..1e2753027dc 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -31,7 +31,7 @@ int az_open(azio_stream *s, const char *path, int Flags, File fd);
int do_flush(azio_stream *file, int flush);
int get_byte(azio_stream *s);
void check_header(azio_stream *s);
-void write_header(azio_stream *s);
+int write_header(azio_stream *s);
int destroy(azio_stream *s);
void putLong(File file, uLong x);
uLong getLong(azio_stream *s);
@@ -155,7 +155,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
}
-void write_header(azio_stream *s)
+int write_header(azio_stream *s)
{
char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE];
char *ptr= buffer;
@@ -191,8 +191,8 @@ void write_header(azio_stream *s)
*(ptr + AZ_DIRTY_POS)= (unsigned char)s->dirty; /* Start of Data Block Index Block */
/* Always begin at the begining, and end there as well */
- my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0,
- MYF(0));
+ return my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE,
+ 0, MYF(MY_NABP)) ? 1 : 0;
}
/* ===========================================================================
@@ -838,19 +838,19 @@ int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
s->frm_length= length;
s->start+= length;
- my_pwrite(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0));
-
- write_header(s);
- my_seek(s->file, 0, MY_SEEK_END, MYF(0));
+ if (my_pwrite(s->file, (uchar*) blob, s->frm_length,
+ s->frm_start_pos, MYF(MY_NABP)) ||
+ write_header(s) ||
+ (my_seek(s->file, 0, MY_SEEK_END, MYF(0)) == MY_FILEPOS_ERROR))
+ return 1;
return 0;
}
int azread_frm(azio_stream *s, char *blob)
{
- my_pread(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0));
-
- return 0;
+ return my_pread(s->file, (uchar*) blob, s->frm_length,
+ s->frm_start_pos, MYF(MY_NABP)) ? 1 : 0;
}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 63848370ff1..ef907b035b5 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -613,6 +613,34 @@ int ha_archive::close(void)
}
+/**
+ Copy a frm blob between streams.
+
+ @param src The source stream.
+ @param dst The destination stream.
+
+ @return Zero on success, non-zero otherwise.
+*/
+
+int ha_archive::frm_copy(azio_stream *src, azio_stream *dst)
+{
+ int rc= 0;
+ char *frm_ptr;
+
+ if (!(frm_ptr= (char *) my_malloc(src->frm_length, MYF(0))))
+ return HA_ERR_OUT_OF_MEM;
+
+ /* Write file offset is set to the end of the file. */
+ if (azread_frm(src, frm_ptr) ||
+ azwrite_frm(dst, frm_ptr, src->frm_length))
+ rc= my_errno ? my_errno : HA_ERR_INTERNAL_ERROR;
+
+ my_free(frm_ptr);
+
+ return rc;
+}
+
+
/*
We create our data file here. The format is pretty simple.
You can read about the format of the data file above.
@@ -1345,10 +1373,10 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
*/
int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
{
- DBUG_ENTER("ha_archive::optimize");
int rc= 0;
azio_stream writer;
char writer_filename[FN_REFLEN];
+ DBUG_ENTER("ha_archive::optimize");
init_archive_reader();
@@ -1366,6 +1394,13 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY)))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
+ /*
+ Transfer the embedded FRM so that the file can be discoverable.
+ Write file offset is set to the end of the file.
+ */
+ if ((rc= frm_copy(&archive, &writer)))
+ goto error;
+
/*
An extended rebuild is a lot more effort. We open up each row and re-record it.
Any dead rows are removed (aka rows that may have been partially recorded).
diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h
index 94842203f16..b258b403c3c 100644
--- a/storage/archive/ha_archive.h
+++ b/storage/archive/ha_archive.h
@@ -75,6 +75,7 @@ class ha_archive: public handler
archive_record_buffer *create_record_buffer(unsigned int length);
void destroy_record_buffer(archive_record_buffer *r);
+ int frm_copy(azio_stream *src, azio_stream *dst);
public:
ha_archive(handlerton *hton, TABLE_SHARE *table_arg);
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index a62444aba79..e8012a86ae6 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -803,15 +803,15 @@ int ha_tina::find_current_row(uchar *buf)
Field_blob *blob= *(Field_blob**) field;
uchar *src, *tgt;
uint length, packlength;
-
+
packlength= blob->pack_length_no_ptr();
length= blob->get_length(blob->ptr);
- memcpy_fixed(&src, blob->ptr + packlength, sizeof(char*));
+ memcpy(&src, blob->ptr + packlength, sizeof(char*));
if (src)
{
tgt= (uchar*) alloc_root(&blobroot, length);
bmove(tgt, src, length);
- memcpy_fixed(blob->ptr + packlength, &tgt, sizeof(char*));
+ memcpy(blob->ptr + packlength, &tgt, sizeof(char*));
}
}
}
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index d17b56bd4b1..b1ae276dce8 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -2752,9 +2752,9 @@ void ha_federated::position(const uchar *record __attribute__ ((unused)))
position_called= TRUE;
/* Store result set address. */
- memcpy_fixed(ref, &stored_result, sizeof(MYSQL_RES *));
+ memcpy(ref, &stored_result, sizeof(MYSQL_RES *));
/* Store data cursor position. */
- memcpy_fixed(ref + sizeof(MYSQL_RES *), &current_position,
+ memcpy(ref + sizeof(MYSQL_RES *), &current_position,
sizeof(MYSQL_ROW_OFFSET));
DBUG_VOID_RETURN;
}
@@ -2780,11 +2780,11 @@ int ha_federated::rnd_pos(uchar *buf, uchar *pos)
ha_statistic_increment(&SSV::ha_read_rnd_count);
/* Get stored result set. */
- memcpy_fixed(&result, pos, sizeof(MYSQL_RES *));
+ memcpy(&result, pos, sizeof(MYSQL_RES *));
DBUG_ASSERT(result);
/* Set data cursor position. */
- memcpy_fixed(&result->data_cursor, pos + sizeof(MYSQL_RES *),
- sizeof(MYSQL_ROW_OFFSET));
+ memcpy(&result->data_cursor, pos + sizeof(MYSQL_RES *),
+ sizeof(MYSQL_ROW_OFFSET));
/* Read a row. */
ret_val= read_next(buf, result);
MYSQL_READ_ROW_DONE(ret_val);
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 350958f8230..481257def1d 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -390,7 +390,7 @@ int ha_heap::rnd_pos(uchar * buf, uchar *pos)
MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str,
FALSE);
ha_statistic_increment(&SSV::ha_read_rnd_count);
- memcpy_fixed((char*) &heap_position, pos, sizeof(HEAP_PTR));
+ memcpy(&heap_position, pos, sizeof(HEAP_PTR));
error=heap_rrnd(file, buf, heap_position);
table->status=error ? STATUS_NOT_FOUND: 0;
MYSQL_READ_ROW_DONE(error);
@@ -654,7 +654,7 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
parts * sizeof(HA_KEYSEG),
MYF(MY_WME))))
return my_errno;
- seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + keys);
+ seg= reinterpret_cast<HA_KEYSEG*>(keydef + keys);
for (key= 0; key < keys; key++)
{
KEY *pos= table_arg->key_info+key;
diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c
index 1571fc98402..3ee903be7ed 100644
--- a/storage/heap/hp_test2.c
+++ b/storage/heap/hp_test2.c
@@ -179,11 +179,6 @@ int main(int argc, char *argv[])
printf("can't find key1: \"%s\"\n",(char*) key);
goto err;
}
-#ifdef NOT_USED
- if (file->current_ptr == hp_find_block(&file->s->block,0) ||
- file->current_ptr == hp_find_block(&file->s->block,1))
- continue; /* Don't remove 2 first records */
-#endif
if (heap_delete(file,record))
{
printf("error: %d; can't delete record: \"%s\"\n", my_errno,(char*) record);
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index b6399dcc478..218dbad2df0 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -40,6 +40,12 @@ IF(UNIX)
ENDIF()
ENDIF()
+# Enable InnoDB's UNIV_DEBUG if MySQL's WITH_DEBUG[_FULL] is defined
+# enable when this bug is resolved:
+# Bug#54861 Additional connections not handled properly in mtr --embedded
+#IF(WITH_DEBUG OR WITH_DEBUG_FULL)
+# ADD_DEFINITIONS("-DUNIV_DEBUG")
+#ENDIF()
IF(NOT MSVC)
# either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
@@ -182,11 +188,7 @@ IF(SIZEOF_PTHREAD_T)
ENDIF()
IF(MSVC)
- # Windows atomics do not perform well. Disable Windows atomics by default.
- # See bug#52102 for details.
-
- #ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DINNODB_RW_LOCKS_USE_ATOMICS -DHAVE_IB_PAUSE_INSTRUCTION)
- ADD_DEFINITIONS(-DHAVE_IB_PAUSE_INSTRUCTION)
+ ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DHAVE_IB_PAUSE_INSTRUCTION)
ENDIF()
diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c
index 05dd094b6df..f8638af2e71 100644
--- a/storage/innobase/btr/btr0btr.c
+++ b/storage/innobase/btr/btr0btr.c
@@ -737,7 +737,7 @@ btr_create(
ulint space, /*!< in: space where created */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
- dulint index_id,/*!< in: index id */
+ index_id_t index_id,/*!< in: index id */
dict_index_t* index, /*!< in: index */
mtr_t* mtr) /*!< in: mini-transaction handle */
{
@@ -1020,7 +1020,7 @@ btr_page_reorganize_low(
/* In crash recovery, dict_index_is_sec_or_ibuf() always
returns TRUE, even for clustered indexes. max_trx_id is
unused in clustered index pages. */
- ut_ad(!ut_dulint_is_zero(max_trx_id) || recovery);
+ ut_ad(max_trx_id != 0 || recovery);
}
if (UNIV_LIKELY_NULL(page_zip)
@@ -2883,7 +2883,7 @@ btr_discard_only_page_on_level(
ibuf_reset_free_bits(block);
if (page_is_leaf(buf_block_get_frame(block))) {
- ut_a(!ut_dulint_is_zero(max_trx_id));
+ ut_a(max_trx_id);
page_set_max_trx_id(block,
buf_block_get_page_zip(block),
max_trx_id, mtr);
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index 31e1a2d4b12..537d5f51184 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -660,7 +660,7 @@ retry_page_get:
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
}
- ut_ad(0 == ut_dulint_cmp(index->id, btr_page_get_index_id(page)));
+ ut_ad(index->id == btr_page_get_index_id(page));
if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) {
/* We are in the root node */
@@ -854,8 +854,7 @@ btr_cur_open_at_index_side_func(
RW_NO_LATCH, NULL, BUF_GET,
file, line, mtr);
page = buf_block_get_frame(block);
- ut_ad(0 == ut_dulint_cmp(index->id,
- btr_page_get_index_id(page)));
+ ut_ad(index->id == btr_page_get_index_id(page));
block->check_index_page_at_flush = TRUE;
@@ -975,8 +974,7 @@ btr_cur_open_at_rnd_pos_func(
RW_NO_LATCH, NULL, BUF_GET,
file, line, mtr);
page = buf_block_get_frame(block);
- ut_ad(0 == ut_dulint_cmp(index->id,
- btr_page_get_index_id(page)));
+ ut_ad(index->id == btr_page_get_index_id(page));
if (height == ULINT_UNDEFINED) {
/* We are in the root node */
@@ -1135,7 +1133,7 @@ btr_cur_trx_report(
const char* op) /*!< in: operation */
{
fprintf(stderr, "Trx with id " TRX_ID_FMT " going to ",
- TRX_ID_PREP_PRINTF(trx->id));
+ (ullint) trx->id);
fputs(op, stderr);
dict_index_name_print(stderr, trx, index);
putc('\n', stderr);
@@ -1826,7 +1824,7 @@ btr_cur_update_in_place(
page_zip_des_t* page_zip;
ulint err;
rec_t* rec;
- roll_ptr_t roll_ptr = ut_dulint_zero;
+ roll_ptr_t roll_ptr = 0;
trx_t* trx;
ulint was_delete_marked;
mem_heap_t* heap = NULL;
@@ -4936,7 +4934,7 @@ btr_copy_externally_stored_field(
/*******************************************************************//**
Copies an externally stored field of a record to mem heap.
-@return the field copied to heap */
+@return the field copied to heap, or NULL if the field is incomplete */
UNIV_INTERN
byte*
btr_rec_copy_externally_stored_field(
@@ -4966,6 +4964,18 @@ btr_rec_copy_externally_stored_field(
data = rec_get_nth_field(rec, offsets, no, &local_len);
+ ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+ if (UNIV_UNLIKELY
+ (!memcmp(data + local_len - BTR_EXTERN_FIELD_REF_SIZE,
+ field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) {
+ /* The externally stored field was not written yet.
+ This record should only be seen by
+ recv_recovery_rollback_active() or any
+ TRX_ISO_READ_UNCOMMITTED transactions. */
+ return(NULL);
+ }
+
return(btr_copy_externally_stored_field(len, data,
zip_size, local_len, heap));
}
diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c
index 98a321bdb80..06cc48c7c60 100644
--- a/storage/innobase/btr/btr0sea.c
+++ b/storage/innobase/btr/btr0sea.c
@@ -46,6 +46,7 @@ Created 2/17/1996 Heikki Tuuri
/** Flag: has the search system been enabled?
Protected by btr_search_latch and btr_search_enabled_mutex. */
UNIV_INTERN char btr_search_enabled = TRUE;
+UNIV_INTERN ibool btr_search_fully_disabled = FALSE;
/** Mutex protecting btr_search_enabled */
static mutex_t btr_search_enabled_mutex;
@@ -213,12 +214,19 @@ btr_search_disable(void)
mutex_enter(&btr_search_enabled_mutex);
rw_lock_x_lock(&btr_search_latch);
+ /* Disable access to hash index, also tell ha_insert_for_fold()
+ stop adding new nodes to hash index, but still allow updating
+ existing nodes */
btr_search_enabled = FALSE;
/* Clear all block->is_hashed flags and remove all entries
from btr_search_sys->hash_index. */
buf_pool_drop_hash_index();
+ /* hash index has been cleaned up, disallow any operation to
+ the hash index */
+ btr_search_fully_disabled = TRUE;
+
/* btr_search_enabled_mutex should guarantee this. */
ut_ad(!btr_search_enabled);
@@ -237,6 +245,7 @@ btr_search_enable(void)
rw_lock_x_lock(&btr_search_latch);
btr_search_enabled = TRUE;
+ btr_search_fully_disabled = FALSE;
rw_lock_x_unlock(&btr_search_latch);
mutex_exit(&btr_search_enabled_mutex);
@@ -523,9 +532,9 @@ btr_search_update_hash_ref(
buf_block_t* block, /*!< in: buffer block where cursor positioned */
btr_cur_t* cursor) /*!< in: cursor */
{
- ulint fold;
- rec_t* rec;
- dulint index_id;
+ ulint fold;
+ rec_t* rec;
+ index_id_t index_id;
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
#ifdef UNIV_SYNC_DEBUG
@@ -830,7 +839,7 @@ btr_search_guess_on_hash(
buf_block_t* block;
rec_t* rec;
ulint fold;
- dulint index_id;
+ index_id_t index_id;
#ifdef notdefined
btr_cur_t cursor2;
btr_pcur_t pcur;
@@ -922,8 +931,7 @@ btr_search_guess_on_hash(
is positioned on. We cannot look at the next of the previous
record to determine if our guess for the cursor position is
right. */
- if (UNIV_EXPECT
- (ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0)
+ if (UNIV_UNLIKELY(index_id != btr_page_get_index_id(block->frame))
|| !btr_search_check_guess(cursor,
has_search_latch,
tuple, mode, mtr)) {
@@ -1028,7 +1036,7 @@ btr_search_drop_page_hash_index(
const rec_t* rec;
ulint fold;
ulint prev_fold;
- dulint index_id;
+ index_id_t index_id;
ulint n_cached;
ulint n_recs;
ulint* folds;
@@ -1088,7 +1096,7 @@ retry:
index_id = btr_page_get_index_id(page);
- ut_a(0 == ut_dulint_cmp(index_id, index->id));
+ ut_a(index_id == index->id);
prev_fold = 0;
@@ -1245,7 +1253,7 @@ btr_search_build_page_hash_index(
rec_t* next_rec;
ulint fold;
ulint next_fold;
- dulint index_id;
+ index_id_t index_id;
ulint n_cached;
ulint n_recs;
ulint* folds;
@@ -1376,7 +1384,7 @@ btr_search_build_page_hash_index(
rw_lock_x_lock(&btr_search_latch);
- if (UNIV_UNLIKELY(!btr_search_enabled)) {
+ if (UNIV_UNLIKELY(btr_search_fully_disabled)) {
goto exit_func;
}
@@ -1498,7 +1506,7 @@ btr_search_update_hash_on_delete(
buf_block_t* block;
rec_t* rec;
ulint fold;
- dulint index_id;
+ index_id_t index_id;
ibool found;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
mem_heap_t* heap = NULL;
@@ -1604,7 +1612,7 @@ btr_search_update_hash_on_insert(
rec_t* rec;
rec_t* ins_rec;
rec_t* next_rec;
- dulint index_id;
+ index_id_t index_id;
ulint fold;
ulint ins_fold;
ulint next_fold = 0; /* remove warning (??? bug ???) */
@@ -1784,6 +1792,7 @@ btr_search_validate(void)
= buf_block_align(node->data);
const buf_block_t* hash_block;
buf_pool_t* buf_pool;
+ index_id_t page_index_id;
buf_pool = buf_pool_from_bpage((buf_page_t*) block);
@@ -1828,12 +1837,15 @@ btr_search_validate(void)
+ (block->curr_n_bytes > 0),
&heap);
- if (!block->is_hashed || node->fold
- != rec_fold((rec_t*)(node->data),
- offsets,
- block->curr_n_fields,
- block->curr_n_bytes,
- btr_page_get_index_id(block->frame))) {
+ page_index_id = btr_page_get_index_id(block->frame);
+
+ if (UNIV_UNLIKELY
+ (!block->is_hashed || node->fold
+ != rec_fold((rec_t*)(node->data),
+ offsets,
+ block->curr_n_fields,
+ block->curr_n_bytes,
+ page_index_id))) {
const page_t* page = block->frame;
ok = FALSE;
@@ -1843,21 +1855,17 @@ btr_search_validate(void)
" InnoDB: Error in an adaptive hash"
" index pointer to page %lu\n"
"InnoDB: ptr mem address %p"
- " index id %lu %lu,"
+ " index id %llu,"
" node fold %lu, rec fold %lu\n",
(ulong) page_get_page_no(page),
node->data,
- (ulong) ut_dulint_get_high(
- btr_page_get_index_id(page)),
- (ulong) ut_dulint_get_low(
- btr_page_get_index_id(page)),
+ (ullint) page_index_id,
(ulong) node->fold,
(ulong) rec_fold((rec_t*)(node->data),
offsets,
block->curr_n_fields,
block->curr_n_bytes,
- btr_page_get_index_id(
- page)));
+ page_index_id));
fputs("InnoDB: Record ", stderr);
rec_print_new(stderr, (rec_t*)node->data,
diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
index 4b6b0a82486..ab3c1abf490 100644
--- a/storage/innobase/buf/buf0buf.c
+++ b/storage/innobase/buf/buf0buf.c
@@ -522,7 +522,9 @@ buf_page_is_corrupted(
ib_uint64_t current_lsn;
if (log_peek_lsn(&current_lsn)
- && current_lsn < mach_read_ull(read_buf + FIL_PAGE_LSN)) {
+ && UNIV_UNLIKELY
+ (current_lsn
+ < mach_read_from_8(read_buf + FIL_PAGE_LSN))) {
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -538,7 +540,7 @@ buf_page_is_corrupted(
"InnoDB: for more information.\n",
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_OFFSET),
- mach_read_ull(read_buf + FIL_PAGE_LSN),
+ mach_read_from_8(read_buf + FIL_PAGE_LSN),
current_lsn);
}
}
@@ -735,17 +737,15 @@ buf_page_print(
#endif /* !UNIV_HOTBACKUP */
switch (fil_page_get_type(read_buf)) {
+ index_id_t index_id;
case FIL_PAGE_INDEX:
+ index_id = btr_page_get_index_id(read_buf);
fprintf(stderr,
"InnoDB: Page may be an index page where"
- " index id is %lu %lu\n",
- (ulong) ut_dulint_get_high(
- btr_page_get_index_id(read_buf)),
- (ulong) ut_dulint_get_low(
- btr_page_get_index_id(read_buf)));
+ " index id is %llu\n",
+ (ullint) index_id);
#ifndef UNIV_HOTBACKUP
- index = dict_index_find_on_id_low(
- btr_page_get_index_id(read_buf));
+ index = dict_index_find_on_id_low(index_id);
if (index) {
fputs("InnoDB: (", stderr);
dict_index_name_print(stderr, NULL, index);
@@ -4461,12 +4461,12 @@ buf_print_instance(
/*===============*/
buf_pool_t* buf_pool)
{
- dulint* index_ids;
+ index_id_t* index_ids;
ulint* counts;
ulint size;
ulint i;
ulint j;
- dulint id;
+ index_id_t id;
ulint n_found;
buf_chunk_t* chunk;
dict_index_t* index;
@@ -4475,7 +4475,7 @@ buf_print_instance(
size = buf_pool->curr_size;
- index_ids = mem_alloc(sizeof(dulint) * size);
+ index_ids = mem_alloc(size * sizeof *index_ids);
counts = mem_alloc(sizeof(ulint) * size);
buf_pool_mutex_enter(buf_pool);
@@ -4530,8 +4530,7 @@ buf_print_instance(
while (j < n_found) {
- if (ut_dulint_cmp(index_ids[j],
- id) == 0) {
+ if (index_ids[j] == id) {
counts[j]++;
break;
@@ -4554,8 +4553,8 @@ buf_print_instance(
index = dict_index_get_if_in_cache(index_ids[i]);
fprintf(stderr,
- "Block count for index %lu in buffer is about %lu",
- (ulong) ut_dulint_get_low(index_ids[i]),
+ "Block count for index %llu in buffer is about %lu",
+ (ullint) index_ids[i],
(ulong) counts[i]);
if (index) {
diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c
index 046f1ed51e8..3737627301f 100644
--- a/storage/innobase/buf/buf0flu.c
+++ b/storage/innobase/buf/buf0flu.c
@@ -114,7 +114,9 @@ buf_flush_insert_in_flush_rbt(
p_node = rbt_prev(buf_pool->flush_rbt, c_node);
if (p_node != NULL) {
- prev = *rbt_value(buf_page_t*, p_node);
+ buf_page_t** value;
+ value = rbt_value(buf_page_t*, p_node);
+ prev = *value;
ut_a(prev != NULL);
}
@@ -980,8 +982,8 @@ buf_flush_init_for_writing(
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_TYPE_ZBLOB2:
case FIL_PAGE_INDEX:
- mach_write_ull(page_zip->data
- + FIL_PAGE_LSN, newest_lsn);
+ mach_write_to_8(page_zip->data
+ + FIL_PAGE_LSN, newest_lsn);
memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
mach_write_to_4(page_zip->data
+ FIL_PAGE_SPACE_OR_CHKSUM,
@@ -1003,10 +1005,10 @@ buf_flush_init_for_writing(
}
/* Write the newest modification lsn to the page header and trailer */
- mach_write_ull(page + FIL_PAGE_LSN, newest_lsn);
+ mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn);
- mach_write_ull(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
- newest_lsn);
+ mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
+ newest_lsn);
/* Store the new formula checksum */
@@ -1094,8 +1096,8 @@ buf_flush_write_block_low(
ut_a(mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM)
== page_zip_calc_checksum(frame, zip_size));
}
- mach_write_ull(frame + FIL_PAGE_LSN,
- bpage->newest_modification);
+ mach_write_to_8(frame + FIL_PAGE_LSN,
+ bpage->newest_modification);
memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
break;
case BUF_BLOCK_FILE_PAGE:
@@ -2088,13 +2090,13 @@ buf_flush_validate_low(
ut_a(om > 0);
if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) {
- buf_page_t* rpage;
+ buf_page_t** prpage;
ut_a(rnode);
- rpage = *rbt_value(buf_page_t*, rnode);
+ prpage = rbt_value(buf_page_t*, rnode);
- ut_a(rpage);
- ut_a(rpage == bpage);
+ ut_a(*prpage);
+ ut_a(*prpage == bpage);
rnode = rbt_next(buf_pool->flush_rbt, rnode);
}
diff --git a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c
index a539c4e894b..e1d4b5081b8 100644
--- a/storage/innobase/buf/buf0lru.c
+++ b/storage/innobase/buf/buf0lru.c
@@ -2278,19 +2278,17 @@ buf_LRU_print_instance(
case BUF_BLOCK_FILE_PAGE:
frame = buf_block_get_frame((buf_block_t*) bpage);
fprintf(stderr, "\ntype %lu"
- " index id %lu\n",
+ " index id %llu\n",
(ulong) fil_page_get_type(frame),
- (ulong) ut_dulint_get_low(
- btr_page_get_index_id(frame)));
+ (ullint) btr_page_get_index_id(frame));
break;
case BUF_BLOCK_ZIP_PAGE:
frame = bpage->zip.data;
fprintf(stderr, "\ntype %lu size %lu"
- " index id %lu\n",
+ " index id %llu\n",
(ulong) fil_page_get_type(frame),
(ulong) buf_page_get_zip_size(bpage),
- (ulong) ut_dulint_get_low(
- btr_page_get_index_id(frame)));
+ (ullint) btr_page_get_index_id(frame));
break;
default:
diff --git a/storage/innobase/data/data0data.c b/storage/innobase/data/data0data.c
index 0715b49bf9c..0ef0cfa554a 100644
--- a/storage/innobase/data/data0data.c
+++ b/storage/innobase/data/data0data.c
@@ -367,7 +367,7 @@ dfield_print_also_hex(
prtype = dtype_get_prtype(dfield_get_type(dfield));
switch (dtype_get_mtype(dfield_get_type(dfield))) {
- dulint id;
+ ib_id_t id;
case DATA_INT:
switch (len) {
ulint val;
@@ -417,22 +417,16 @@ dfield_print_also_hex(
case 6:
id = mach_read_from_6(data);
- fprintf(stderr, "{%lu %lu}",
- ut_dulint_get_high(id),
- ut_dulint_get_low(id));
+ fprintf(stderr, "%llu", (ullint) id);
break;
case 7:
id = mach_read_from_7(data);
- fprintf(stderr, "{%lu %lu}",
- ut_dulint_get_high(id),
- ut_dulint_get_low(id));
+ fprintf(stderr, "%llu", (ullint) id);
break;
case 8:
id = mach_read_from_8(data);
- fprintf(stderr, "{%lu %lu}",
- ut_dulint_get_high(id),
- ut_dulint_get_low(id));
+ fprintf(stderr, "%llu", (ullint) id);
break;
default:
goto print_hex;
@@ -444,29 +438,25 @@ dfield_print_also_hex(
case DATA_TRX_ID:
id = mach_read_from_6(data);
- fprintf(stderr, "trx_id " TRX_ID_FMT,
- TRX_ID_PREP_PRINTF(id));
+ fprintf(stderr, "trx_id " TRX_ID_FMT, (ullint) id);
break;
case DATA_ROLL_PTR:
id = mach_read_from_7(data);
- fprintf(stderr, "roll_ptr {%lu %lu}",
- ut_dulint_get_high(id), ut_dulint_get_low(id));
+ fprintf(stderr, "roll_ptr " TRX_ID_FMT, (ullint) id);
break;
case DATA_ROW_ID:
id = mach_read_from_6(data);
- fprintf(stderr, "row_id {%lu %lu}",
- ut_dulint_get_high(id), ut_dulint_get_low(id));
+ fprintf(stderr, "row_id " TRX_ID_FMT, (ullint) id);
break;
default:
- id = mach_dulint_read_compressed(data);
+ id = mach_ull_read_compressed(data);
- fprintf(stderr, "mix_id {%lu %lu}",
- ut_dulint_get_high(id), ut_dulint_get_low(id));
+ fprintf(stderr, "mix_id " TRX_ID_FMT, (ullint) id);
}
break;
diff --git a/storage/innobase/data/data0type.c b/storage/innobase/data/data0type.c
index e834fd2ec55..20d1f5db8d3 100644
--- a/storage/innobase/data/data0type.c
+++ b/storage/innobase/data/data0type.c
@@ -49,10 +49,8 @@ ulint
dtype_get_at_most_n_mbchars(
/*========================*/
ulint prtype, /*!< in: precise type */
- ulint mbminlen, /*!< in: minimum length of a
- multi-byte character */
- ulint mbmaxlen, /*!< in: maximum length of a
- multi-byte character */
+ ulint mbminmaxlen, /*!< in: minimum and maximum length of
+ a multi-byte character */
ulint prefix_len, /*!< in: length of the requested
prefix, in characters, multiplied by
dtype_get_mbmaxlen(dtype) */
@@ -60,6 +58,9 @@ dtype_get_at_most_n_mbchars(
const char* str) /*!< in: the string whose prefix
length is being determined */
{
+ ulint mbminlen = DATA_MBMINLEN(mbminmaxlen);
+ ulint mbmaxlen = DATA_MBMAXLEN(mbminmaxlen);
+
ut_a(data_len != UNIV_SQL_NULL);
ut_ad(!mbmaxlen || !(prefix_len % mbmaxlen));
@@ -180,7 +181,7 @@ dtype_validate(
}
#ifndef UNIV_HOTBACKUP
- ut_a(type->mbminlen <= type->mbmaxlen);
+ ut_a(dtype_get_mbminlen(type) <= dtype_get_mbmaxlen(type));
#endif /* !UNIV_HOTBACKUP */
return(TRUE);
diff --git a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c
index e63c1dc94b9..20d676e6129 100644
--- a/storage/innobase/dict/dict0boot.c
+++ b/storage/innobase/dict/dict0boot.c
@@ -67,12 +67,15 @@ UNIV_INTERN
void
dict_hdr_get_new_id(
/*================*/
- dulint* table_id, /*!< out: table id (not assigned if NULL) */
- dulint* index_id, /*!< out: index id (not assigned if NULL) */
- ulint* space_id) /*!< out: space id (not assigned if NULL) */
+ table_id_t* table_id, /*!< out: table id
+ (not assigned if NULL) */
+ index_id_t* index_id, /*!< out: index id
+ (not assigned if NULL) */
+ ulint* space_id) /*!< out: space id
+ (not assigned if NULL) */
{
dict_hdr_t* dict_hdr;
- dulint id;
+ ib_id_t id;
mtr_t mtr;
mtr_start(&mtr);
@@ -80,16 +83,16 @@ dict_hdr_get_new_id(
dict_hdr = dict_hdr_get(&mtr);
if (table_id) {
- id = mtr_read_dulint(dict_hdr + DICT_HDR_TABLE_ID, &mtr);
- id = ut_dulint_add(id, 1);
- mlog_write_dulint(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr);
+ id = mach_read_from_8(dict_hdr + DICT_HDR_TABLE_ID);
+ id++;
+ mlog_write_ull(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr);
*table_id = id;
}
if (index_id) {
- id = mtr_read_dulint(dict_hdr + DICT_HDR_INDEX_ID, &mtr);
- id = ut_dulint_add(id, 1);
- mlog_write_dulint(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr);
+ id = mach_read_from_8(dict_hdr + DICT_HDR_INDEX_ID);
+ id++;
+ mlog_write_ull(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr);
*index_id = id;
}
@@ -114,7 +117,7 @@ dict_hdr_flush_row_id(void)
/*=======================*/
{
dict_hdr_t* dict_hdr;
- dulint id;
+ row_id_t id;
mtr_t mtr;
ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -125,7 +128,7 @@ dict_hdr_flush_row_id(void)
dict_hdr = dict_hdr_get(&mtr);
- mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
+ mlog_write_ull(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
mtr_commit(&mtr);
}
@@ -157,14 +160,14 @@ dict_hdr_create(
/* Start counting row, table, index, and tree ids from
DICT_HDR_FIRST_ID */
- mlog_write_dulint(dict_header + DICT_HDR_ROW_ID,
- ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
+ mlog_write_ull(dict_header + DICT_HDR_ROW_ID,
+ DICT_HDR_FIRST_ID, mtr);
- mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
- ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
+ mlog_write_ull(dict_header + DICT_HDR_TABLE_ID,
+ DICT_HDR_FIRST_ID, mtr);
- mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
- ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
+ mlog_write_ull(dict_header + DICT_HDR_INDEX_ID,
+ DICT_HDR_FIRST_ID, mtr);
mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID,
0, MLOG_4BYTES, mtr);
@@ -273,11 +276,9 @@ dict_boot(void)
..._MARGIN, it will immediately be updated to the disk-based
header. */
- dict_sys->row_id = ut_dulint_add(
- ut_dulint_align_up(mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID,
- &mtr),
- DICT_HDR_ROW_ID_WRITE_MARGIN),
- DICT_HDR_ROW_ID_WRITE_MARGIN);
+ dict_sys->row_id = DICT_HDR_ROW_ID_WRITE_MARGIN
+ + ut_uint64_align_up(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID),
+ DICT_HDR_ROW_ID_WRITE_MARGIN);
/* Insert into the dictionary cache the descriptions of the basic
system tables */
diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c
index 09353c45c8c..6824d0fa9f9 100644
--- a/storage/innobase/dict/dict0crea.c
+++ b/storage/innobase/dict/dict0crea.c
@@ -590,7 +590,7 @@ dict_build_index_def_step(
ins_node_set_new_row(node->ind_def, row);
/* Note that the index was created by this transaction. */
- index->trx_id = (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
+ index->trx_id = trx->id;
return(DB_SUCCESS);
}
@@ -761,7 +761,7 @@ dict_truncate_index_tree(
ibool drop = !space;
ulint zip_size;
ulint type;
- dulint index_id;
+ index_id_t index_id;
rec_t* rec;
const byte* ptr;
ulint len;
@@ -854,7 +854,7 @@ create:
for (index = UT_LIST_GET_FIRST(table->indexes);
index;
index = UT_LIST_GET_NEXT(indexes, index)) {
- if (!ut_dulint_cmp(index->id, index_id)) {
+ if (index->id == index_id) {
root_page_no = btr_create(type, space, zip_size,
index_id, index, mtr);
index->page = (unsigned int) root_page_no;
@@ -864,10 +864,9 @@ create:
ut_print_timestamp(stderr);
fprintf(stderr,
- " InnoDB: Index %lu %lu of table %s is missing\n"
+ " InnoDB: Index %llu of table %s is missing\n"
"InnoDB: from the data dictionary during TRUNCATE!\n",
- ut_dulint_get_high(index_id),
- ut_dulint_get_low(index_id),
+ (ullint) index_id,
table->name);
return(FIL_NULL);
@@ -1119,7 +1118,7 @@ dict_create_index_step(
if (node->state == INDEX_ADD_TO_CACHE) {
- dulint index_id = node->index->id;
+ index_id_t index_id = node->index->id;
err = dict_index_add_to_cache(
node->table, node->index, FIL_NULL,
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index a298d785449..802f0bd8b6f 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -256,8 +256,8 @@ dict_mutex_exit_for_mysql(void)
/** Get the mutex that protects index->stat_n_diff_key_vals[] */
#define GET_INDEX_STAT_MUTEX(index) \
- (&dict_index_stat_mutex[ut_fold_dulint(index->id) \
- % DICT_INDEX_STAT_MUTEX_SIZE])
+ (&dict_index_stat_mutex[ut_fold_ull(index->id) \
+ % DICT_INDEX_STAT_MUTEX_SIZE])
/**********************************************************************//**
Lock the appropriate mutex to protect index->stat_n_diff_key_vals[].
@@ -425,14 +425,14 @@ dict_index_t*
dict_index_get_on_id_low(
/*=====================*/
dict_table_t* table, /*!< in: table */
- dulint id) /*!< in: index id */
+ index_id_t id) /*!< in: index id */
{
dict_index_t* index;
index = dict_table_get_first_index(table);
while (index) {
- if (0 == ut_dulint_cmp(id, index->id)) {
+ if (id == index->id) {
/* Found */
return(index);
@@ -574,20 +574,18 @@ UNIV_INTERN
dict_table_t*
dict_table_get_on_id(
/*=================*/
- dulint table_id, /*!< in: table id */
- trx_t* trx) /*!< in: transaction handle */
+ table_id_t table_id, /*!< in: table id */
+ trx_t* trx) /*!< in: transaction handle */
{
dict_table_t* table;
- if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0
+ if (table_id <= DICT_FIELDS_ID
|| trx->dict_operation_lock_mode == RW_X_LATCH) {
- /* It is a system table which will always exist in the table
- cache: we avoid acquiring the dictionary mutex, because
- if we are doing a rollback to handle an error in TABLE
- CREATE, for example, we already have the mutex! */
- ut_ad(mutex_own(&(dict_sys->mutex))
- || trx->dict_operation_lock_mode == RW_X_LATCH);
+ /* Note: An X latch implies that the transaction
+ already owns the dictionary mutex. */
+
+ ut_ad(mutex_own(&dict_sys->mutex));
return(dict_table_get_on_id_low(table_id));
}
@@ -800,7 +798,7 @@ dict_table_add_to_cache(
table->cached = TRUE;
fold = ut_fold_string(table->name);
- id_fold = ut_fold_dulint(table->id);
+ id_fold = ut_fold_ull(table->id);
row_len = 0;
for (i = 0; i < table->n_def; i++) {
@@ -842,7 +840,7 @@ dict_table_add_to_cache(
dict_table_t* table2;
HASH_SEARCH(id_hash, dict_sys->table_id_hash, id_fold,
dict_table_t*, table2, ut_ad(table2->cached),
- ut_dulint_cmp(table2->id, table->id) == 0);
+ table2->id == table->id);
ut_a(table2 == NULL);
#ifdef UNIV_DEBUG
@@ -864,7 +862,8 @@ dict_table_add_to_cache(
/* Add table to LRU list of tables */
UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
- dict_sys->size += mem_heap_get_size(table->heap);
+ dict_sys->size += mem_heap_get_size(table->heap)
+ + strlen(table->name) + 1;
}
/**********************************************************************//**
@@ -876,7 +875,7 @@ UNIV_INTERN
dict_index_t*
dict_index_find_on_id_low(
/*======================*/
- dulint id) /*!< in: index id */
+ index_id_t id) /*!< in: index id */
{
dict_table_t* table;
dict_index_t* index;
@@ -887,7 +886,7 @@ dict_index_find_on_id_low(
index = dict_table_get_first_index(table);
while (index) {
- if (0 == ut_dulint_cmp(id, index->id)) {
+ if (id == index->id) {
/* Found */
return(index);
@@ -918,14 +917,21 @@ dict_table_rename_in_cache(
dict_foreign_t* foreign;
dict_index_t* index;
ulint fold;
- ulint old_size;
- const char* old_name;
+ char old_name[MAX_TABLE_NAME_LEN + 1];
ut_ad(table);
ut_ad(mutex_own(&(dict_sys->mutex)));
- old_size = mem_heap_get_size(table->heap);
- old_name = table->name;
+ /* store the old/current name to an automatic variable */
+ if (strlen(table->name) + 1 <= sizeof(old_name)) {
+ memcpy(old_name, table->name, strlen(table->name) + 1);
+ } else {
+ ut_print_timestamp(stderr);
+ fprintf(stderr, "InnoDB: too long table name: '%s', "
+ "max length is %d\n", table->name,
+ MAX_TABLE_NAME_LEN);
+ ut_error;
+ }
fold = ut_fold_string(new_name);
@@ -971,12 +977,22 @@ dict_table_rename_in_cache(
/* Remove table from the hash tables of tables */
HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
ut_fold_string(old_name), table);
- table->name = mem_heap_strdup(table->heap, new_name);
+
+ if (strlen(new_name) > strlen(table->name)) {
+ /* We allocate MAX_TABLE_NAME_LEN+1 bytes here to avoid
+ memory fragmentation, we assume a repeated calls of
+ ut_realloc() with the same size do not cause fragmentation */
+ ut_a(strlen(new_name) <= MAX_TABLE_NAME_LEN);
+ table->name = ut_realloc(table->name, MAX_TABLE_NAME_LEN + 1);
+ }
+ memcpy(table->name, new_name, strlen(new_name) + 1);
/* Add table to hash table of tables */
HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold,
table);
- dict_sys->size += (mem_heap_get_size(table->heap) - old_size);
+
+ dict_sys->size += strlen(new_name) - strlen(old_name);
+ ut_a(dict_sys->size > 0);
/* Update the table_name field in indexes */
index = dict_table_get_first_index(table);
@@ -1126,7 +1142,7 @@ void
dict_table_change_id_in_cache(
/*==========================*/
dict_table_t* table, /*!< in/out: table object already in cache */
- dulint new_id) /*!< in: new id to set */
+ table_id_t new_id) /*!< in: new id to set */
{
ut_ad(table);
ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -1135,12 +1151,12 @@ dict_table_change_id_in_cache(
/* Remove the table from the hash table of id's */
HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash,
- ut_fold_dulint(table->id), table);
+ ut_fold_ull(table->id), table);
table->id = new_id;
/* Add the table back to the hash table */
HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash,
- ut_fold_dulint(table->id), table);
+ ut_fold_ull(table->id), table);
}
/**********************************************************************//**
@@ -1196,12 +1212,12 @@ dict_table_remove_from_cache(
HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
ut_fold_string(table->name), table);
HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash,
- ut_fold_dulint(table->id), table);
+ ut_fold_ull(table->id), table);
/* Remove table from LRU list of tables */
UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
- size = mem_heap_get_size(table->heap);
+ size = mem_heap_get_size(table->heap) + strlen(table->name) + 1;
ut_ad(dict_sys->size >= size);
@@ -2458,8 +2474,7 @@ dict_table_get_index_by_max_id(
/* We found a matching index, select
the index with the higher id*/
- if (!found
- || ut_dulint_cmp(index->id, found->id) > 0) {
+ if (!found || index->id > found->id) {
found = index;
}
@@ -3947,7 +3962,7 @@ UNIV_INTERN
dict_index_t*
dict_index_get_if_in_cache_low(
/*===========================*/
- dulint index_id) /*!< in: index id */
+ index_id_t index_id) /*!< in: index id */
{
ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -3962,7 +3977,7 @@ UNIV_INTERN
dict_index_t*
dict_index_get_if_in_cache(
/*=======================*/
- dulint index_id) /*!< in: index id */
+ index_id_t index_id) /*!< in: index id */
{
dict_index_t* index;
@@ -4358,12 +4373,11 @@ dict_table_print_low(
fprintf(stderr,
"--------------------------------------\n"
- "TABLE: name %s, id %lu %lu, flags %lx, columns %lu,"
+ "TABLE: name %s, id %llu, flags %lx, columns %lu,"
" indexes %lu, appr.rows %lu\n"
" COLUMNS: ",
table->name,
- (ulong) ut_dulint_get_high(table->id),
- (ulong) ut_dulint_get_low(table->id),
+ (ullint) table->id,
(ulong) table->flags,
(ulong) table->n_cols,
(ulong) UT_LIST_GET_LEN(table->indexes),
@@ -4452,14 +4466,13 @@ dict_index_print_low(
}
fprintf(stderr,
- " INDEX: name %s, id %lu %lu, fields %lu/%lu,"
+ " INDEX: name %s, id %llu, fields %lu/%lu,"
" uniq %lu, type %lu\n"
" root page %lu, appr.key vals %lu,"
" leaf pages %lu, size pages %lu\n"
" FIELDS: ",
index->name,
- (ulong) ut_dulint_get_high(index->id),
- (ulong) ut_dulint_get_low(index->id),
+ (ullint) index->id,
(ulong) index->n_user_defined_cols,
(ulong) index->n_fields,
(ulong) index->n_uniq,
@@ -4831,8 +4844,7 @@ dict_table_get_index_on_name_and_min_id(
while (index != NULL) {
if (ut_strcmp(index->name, name) == 0) {
- if (!min_index
- || ut_dulint_cmp(index->id, min_index->id) < 0) {
+ if (!min_index || index->id < min_index->id) {
min_index = index;
}
diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
index 6bf2c1d9d81..20a18c72a39 100644
--- a/storage/innobase/dict/dict0load.c
+++ b/storage/innobase/dict/dict0load.c
@@ -364,7 +364,7 @@ dict_process_sys_indexes_rec(
mem_heap_t* heap, /*!< in/out: heap memory */
const rec_t* rec, /*!< in: current SYS_INDEXES rec */
dict_index_t* index, /*!< out: index to be filled */
- dulint* table_id) /*!< out: index table id */
+ table_id_t* table_id) /*!< out: index table id */
{
const char* err_msg;
byte* buf;
@@ -390,7 +390,7 @@ dict_process_sys_columns_rec(
mem_heap_t* heap, /*!< in/out: heap memory */
const rec_t* rec, /*!< in: current SYS_COLUMNS rec */
dict_col_t* column, /*!< out: dict_col_t to be filled */
- dulint* table_id, /*!< out: table id */
+ table_id_t* table_id, /*!< out: table id */
const char** col_name) /*!< out: column name */
{
const char* err_msg;
@@ -414,8 +414,8 @@ dict_process_sys_fields_rec(
dict_field_t* sys_field, /*!< out: dict_field_t to be
filled */
ulint* pos, /*!< out: Field position */
- dulint* index_id, /*!< out: current index id */
- dulint last_id) /*!< in: previous index id */
+ index_id_t* index_id, /*!< out: current index id */
+ index_id_t last_id) /*!< in: previous index id */
{
byte* buf;
byte* last_index_id;
@@ -644,7 +644,7 @@ dict_check_tablespaces_and_store_max_id(
dict_index_t* sys_index;
btr_pcur_t pcur;
const rec_t* rec;
- ulint max_space_id = 0;
+ ulint max_space_id;
mtr_t mtr;
mutex_enter(&(dict_sys->mutex));
@@ -655,6 +655,11 @@ dict_check_tablespaces_and_store_max_id(
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
ut_a(!dict_table_is_comp(sys_tables));
+ max_space_id = mtr_read_ulint(dict_hdr_get(&mtr)
+ + DICT_HDR_MAX_SPACE_ID,
+ MLOG_4BYTES, &mtr);
+ fil_set_max_space_id_if_bigger(max_space_id);
+
btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur,
TRUE, &mtr);
loop:
@@ -777,13 +782,14 @@ const char*
dict_load_column_low(
/*=================*/
dict_table_t* table, /*!< in/out: table, could be NULL
- if we just polulate a dict_column_t
+ if we just populate a dict_column_t
struct with information from
a SYS_COLUMNS record */
mem_heap_t* heap, /*!< in/out: memory heap
for temporary storage */
- dict_col_t* column, /*!< out: dict_column_t to fill */
- dulint* table_id, /*!< out: table id */
+ dict_col_t* column, /*!< out: dict_column_t to fill,
+ or NULL if table != NULL */
+ table_id_t* table_id, /*!< out: table id */
const char** col_name, /*!< out: column name */
const rec_t* rec) /*!< in: SYS_COLUMNS record */
{
@@ -795,6 +801,8 @@ dict_load_column_low(
ulint col_len;
ulint pos;
+ ut_ad(table || column);
+
if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
return("delete-marked record in SYS_COLUMNS");
}
@@ -811,8 +819,7 @@ err_len:
if (table_id) {
*table_id = mach_read_from_8(field);
- } else if (UNIV_UNLIKELY(ut_dulint_cmp(table->id,
- mach_read_from_8(field)))) {
+ } else if (UNIV_UNLIKELY(table->id != mach_read_from_8(field))) {
return("SYS_COLUMNS.TABLE_ID mismatch");
}
@@ -822,9 +829,9 @@ err_len:
goto err_len;
}
- if (!table) {
- pos = mach_read_from_4(field);
- } else if (UNIV_UNLIKELY(table->n_def != mach_read_from_4(field))) {
+ pos = mach_read_from_4(field);
+
+ if (UNIV_UNLIKELY(table && table->n_def != pos)) {
return("SYS_COLUMNS.POS mismatch");
}
@@ -1191,7 +1198,7 @@ dict_load_index_low(
ulint len;
ulint name_len;
char* name_buf;
- dulint id;
+ index_id_t id;
ulint n_fields;
ulint type;
ulint space;
@@ -1308,19 +1315,11 @@ dict_load_indexes(
dfield_t* dfield;
const rec_t* rec;
byte* buf;
- ibool is_sys_table;
mtr_t mtr;
ulint error = DB_SUCCESS;
ut_ad(mutex_own(&(dict_sys->mutex)));
- if ((ut_dulint_get_high(table->id) == 0)
- && (ut_dulint_get_low(table->id) < DICT_HDR_FIRST_ID)) {
- is_sys_table = TRUE;
- } else {
- is_sys_table = FALSE;
- }
-
mtr_start(&mtr);
sys_indexes = dict_table_get_low("SYS_INDEXES");
@@ -1406,7 +1405,7 @@ corrupted:
" is not clustered!\n", stderr);
goto corrupted;
- } else if (is_sys_table
+ } else if (table->id < DICT_HDR_FIRST_ID
&& (dict_index_is_clust(index)
|| ((table == dict_sys->sys_tables)
&& !strcmp("ID_IND", index->name)))) {
@@ -1766,7 +1765,7 @@ UNIV_INTERN
dict_table_t*
dict_load_table_on_id(
/*==================*/
- dulint table_id) /*!< in: table id */
+ table_id_t table_id) /*!< in: table id */
{
byte id_buf[8];
btr_pcur_t pcur;
@@ -1829,7 +1828,7 @@ dict_load_table_on_id(
ut_ad(len == 8);
/* Check if the table id in record is the one searched for */
- if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) {
+ if (table_id != mach_read_from_8(field)) {
btr_pcur_close(&pcur);
mtr_commit(&mtr);
diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c
index b6e516783c7..bbb8f810f44 100644
--- a/storage/innobase/dict/dict0mem.c
+++ b/storage/innobase/dict/dict0mem.c
@@ -73,7 +73,8 @@ dict_mem_table_create(
table->heap = heap;
table->flags = (unsigned int) flags;
- table->name = mem_heap_strdup(heap, name);
+ table->name = ut_malloc(strlen(name) + 1);
+ memcpy(table->name, name, strlen(name) + 1);
table->space = (unsigned int) space;
table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS);
@@ -112,6 +113,7 @@ dict_mem_table_free(
#ifndef UNIV_HOTBACKUP
mutex_free(&(table->autoinc_mutex));
#endif /* UNIV_HOTBACKUP */
+ ut_free(table->name);
mem_heap_free(table->heap);
}
@@ -204,6 +206,37 @@ dict_mem_table_add_col(
dict_mem_fill_column_struct(col, i, mtype, prtype, len);
}
+
+/**********************************************************************//**
+This function populates a dict_col_t memory structure with
+supplied information. */
+UNIV_INTERN
+void
+dict_mem_fill_column_struct(
+/*========================*/
+ dict_col_t* column, /*!< out: column struct to be
+ filled */
+ ulint col_pos, /*!< in: column position */
+ ulint mtype, /*!< in: main data type */
+ ulint prtype, /*!< in: precise type */
+ ulint col_len) /*!< in: column length */
+{
+#ifndef UNIV_HOTBACKUP
+ ulint mbminlen;
+ ulint mbmaxlen;
+#endif /* !UNIV_HOTBACKUP */
+
+ column->ind = (unsigned int) col_pos;
+ column->ord_part = 0;
+ column->mtype = (unsigned int) mtype;
+ column->prtype = (unsigned int) prtype;
+ column->len = (unsigned int) col_len;
+#ifndef UNIV_HOTBACKUP
+ dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
+ dict_col_set_mbminmaxlen(column, mbminlen, mbmaxlen);
+#endif /* !UNIV_HOTBACKUP */
+}
+
/**********************************************************************//**
Creates an index memory object.
@return own: index object */
diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
index 0d033c37879..710f0ac8603 100644
--- a/storage/innobase/fil/fil0fil.c
+++ b/storage/innobase/fil/fil0fil.c
@@ -1214,7 +1214,7 @@ try_again:
space->tablespace_version = fil_system->tablespace_version;
space->mark = FALSE;
- if (UNIV_LIKELY(purpose == FIL_TABLESPACE)
+ if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
&& UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
if (!fil_system->space_id_reuse_warned) {
fil_system->space_id_reuse_warned = TRUE;
@@ -1705,7 +1705,7 @@ fil_write_lsn_and_arch_no_to_file(
fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
- mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
+ mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
@@ -1799,7 +1799,7 @@ fil_read_flushed_lsn_and_arch_log_no(
os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
- flushed_lsn = mach_read_ull(buf + FIL_PAGE_FILE_FLUSH_LSN);
+ flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN);
ut_free(buf2);
@@ -2850,7 +2850,7 @@ fil_reset_too_high_lsns(
/* We have to read the file flush lsn from the header of the file */
- flush_lsn = mach_read_ull(page + FIL_PAGE_FILE_FLUSH_LSN);
+ flush_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN);
if (current_lsn >= flush_lsn) {
/* Ok */
@@ -2898,7 +2898,7 @@ fil_reset_too_high_lsns(
goto func_exit;
}
- if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) {
+ if (mach_read_from_8(page + FIL_PAGE_LSN) > current_lsn) {
/* We have to reset the lsn */
if (zip_size) {
@@ -2940,7 +2940,7 @@ fil_reset_too_high_lsns(
goto func_exit;
}
- mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
+ mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
success = os_file_write(filepath, file, page, 0, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE);
diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c
index 2bae8481d20..3efe147b998 100644
--- a/storage/innobase/fsp/fsp0fsp.c
+++ b/storage/innobase/fsp/fsp0fsp.c
@@ -127,9 +127,8 @@ typedef byte fseg_inode_t;
#define FSEG_ARR_OFFSET (FSEG_PAGE_DATA + FLST_NODE_SIZE)
/*-------------------------------------*/
-#define FSEG_ID 0 /* 8 bytes of segment id: if this is
- ut_dulint_zero, it means that the
- header is unused */
+#define FSEG_ID 0 /* 8 bytes of segment id: if this is 0,
+ it means that the header is unused */
#define FSEG_NOT_FULL_N_USED 8
/* number of used segment pages in
the FSEG_NOT_FULL list */
@@ -999,11 +998,11 @@ fsp_header_init(
flst_init(header + FSP_SEG_INODES_FULL, mtr);
flst_init(header + FSP_SEG_INODES_FREE, mtr);
- mlog_write_dulint(header + FSP_SEG_ID, ut_dulint_create(0, 1), mtr);
+ mlog_write_ull(header + FSP_SEG_ID, 1, mtr);
if (space == 0) {
fsp_fill_free_list(FALSE, space, header, mtr);
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
- 0, 0, ut_dulint_add(DICT_IBUF_ID_MIN, space),
+ 0, 0, DICT_IBUF_ID_MIN + space,
dict_ind_redundant, mtr);
} else {
fsp_fill_free_list(TRUE, space, header, mtr);
@@ -1841,7 +1840,7 @@ fsp_seg_inode_page_find_used(
inode = fsp_seg_inode_page_get_nth_inode(
page, i, zip_size, mtr);
- if (!ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
+ if (mach_read_from_8(inode + FSEG_ID)) {
/* This is used */
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
@@ -1872,7 +1871,7 @@ fsp_seg_inode_page_find_free(
inode = fsp_seg_inode_page_get_nth_inode(
page, i, zip_size, mtr);
- if (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
+ if (!mach_read_from_8(inode + FSEG_ID)) {
/* This is unused */
return(i);
@@ -1931,7 +1930,7 @@ fsp_alloc_seg_inode_page(
inode = fsp_seg_inode_page_get_nth_inode(page, i,
zip_size, mtr);
- mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
+ mlog_write_ull(inode + FSEG_ID, 0, mtr);
}
flst_add_last(space_header + FSP_SEG_INODES_FREE,
@@ -1998,7 +1997,7 @@ fsp_alloc_seg_inode(
page + FSEG_INODE_PAGE_NODE, mtr);
}
- ut_ad(ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))
+ ut_ad(!mach_read_from_8(inode + FSEG_ID)
|| mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
return(inode);
}
@@ -2036,7 +2035,7 @@ fsp_free_seg_inode(
page + FSEG_INODE_PAGE_NODE, mtr);
}
- mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
+ mlog_write_ull(inode + FSEG_ID, 0, mtr);
mlog_write_ulint(inode + FSEG_MAGIC_N, 0xfa051ce3, MLOG_4BYTES, mtr);
if (ULINT_UNDEFINED
@@ -2073,8 +2072,7 @@ fseg_inode_try_get(
inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
- if (UNIV_UNLIKELY
- (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID)))) {
+ if (UNIV_UNLIKELY(!mach_read_from_8(inode + FSEG_ID))) {
inode = NULL;
} else {
@@ -2249,7 +2247,7 @@ fseg_create_general(
ulint zip_size;
fsp_header_t* space_header;
fseg_inode_t* inode;
- dulint seg_id;
+ ib_id_t seg_id;
buf_block_t* block = 0; /* remove warning */
fseg_header_t* header = 0; /* remove warning */
rw_lock_t* latch;
@@ -2303,12 +2301,11 @@ fseg_create_general(
/* Read the next segment id from space header and increment the
value in space header */
- seg_id = mtr_read_dulint(space_header + FSP_SEG_ID, mtr);
+ seg_id = mach_read_from_8(space_header + FSP_SEG_ID);
- mlog_write_dulint(space_header + FSP_SEG_ID, ut_dulint_add(seg_id, 1),
- mtr);
+ mlog_write_ull(space_header + FSP_SEG_ID, seg_id + 1, mtr);
- mlog_write_dulint(inode + FSEG_ID, seg_id, mtr);
+ mlog_write_ull(inode + FSEG_ID, seg_id, mtr);
mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr);
flst_init(inode + FSEG_FREE, mtr);
@@ -2460,7 +2457,7 @@ fseg_fill_free_list(
{
xdes_t* descr;
ulint i;
- dulint seg_id;
+ ib_id_t seg_id;
ulint reserved;
ulint used;
@@ -2497,10 +2494,10 @@ fseg_fill_free_list(
xdes_set_state(descr, XDES_FSEG, mtr);
- seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
+ seg_id = mach_read_from_8(inode + FSEG_ID);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
- mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
+ mlog_write_ull(descr + XDES_ID, seg_id, mtr);
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
hint += FSP_EXTENT_SIZE;
@@ -2524,7 +2521,7 @@ fseg_alloc_free_extent(
mtr_t* mtr) /*!< in: mtr */
{
xdes_t* descr;
- dulint seg_id;
+ ib_id_t seg_id;
fil_addr_t first;
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
@@ -2545,10 +2542,10 @@ fseg_alloc_free_extent(
return(NULL);
}
- seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
+ seg_id = mach_read_from_8(inode + FSEG_ID);
xdes_set_state(descr, XDES_FSEG, mtr);
- mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
+ mlog_write_ull(descr + XDES_ID, seg_id, mtr);
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
/* Try to fill the segment free list */
@@ -2583,7 +2580,7 @@ fseg_alloc_free_page_low(
{
fsp_header_t* space_header;
ulint space_size;
- dulint seg_id;
+ ib_id_t seg_id;
ulint used;
ulint reserved;
xdes_t* descr; /*!< extent of the hinted page */
@@ -2599,9 +2596,9 @@ fseg_alloc_free_page_low(
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
- seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
+ seg_id = mach_read_from_8(seg_inode + FSEG_ID);
- ut_ad(!ut_dulint_is_zero(seg_id));
+ ut_ad(seg_id);
reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr);
@@ -2619,8 +2616,7 @@ fseg_alloc_free_page_low(
/* In the big if-else below we look for ret_page and ret_descr */
/*-------------------------------------------------------------*/
if ((xdes_get_state(descr, mtr) == XDES_FSEG)
- && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
- mtr), seg_id))
+ && mach_read_from_8(descr + XDES_ID) == seg_id
&& (xdes_get_bit(descr, XDES_FREE_BIT,
hint % FSP_EXTENT_SIZE, mtr) == TRUE)) {
@@ -2642,7 +2638,7 @@ fseg_alloc_free_page_low(
ut_a(ret_descr == descr);
xdes_set_state(ret_descr, XDES_FSEG, mtr);
- mlog_write_dulint(ret_descr + XDES_ID, seg_id, mtr);
+ mlog_write_ull(ret_descr + XDES_ID, seg_id, mtr);
flst_add_last(seg_inode + FSEG_FREE,
ret_descr + XDES_FLST_NODE, mtr);
@@ -2671,8 +2667,7 @@ fseg_alloc_free_page_low(
}
/*-----------------------------------------------------------*/
} else if ((xdes_get_state(descr, mtr) == XDES_FSEG)
- && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
- mtr), seg_id))
+ && mach_read_from_8(descr + XDES_ID) == seg_id
&& (!xdes_is_full(descr, mtr))) {
/* 4. We can take the page from the same extent as the
@@ -3243,8 +3238,8 @@ fseg_free_page_low(
xdes_t* descr;
ulint not_full_n_used;
ulint state;
- dulint descr_id;
- dulint seg_id;
+ ib_id_t descr_id;
+ ib_id_t seg_id;
ulint i;
ut_ad(seg_inode && mtr);
@@ -3303,20 +3298,18 @@ crash:
/* If we get here, the page is in some extent of the segment */
- descr_id = mtr_read_dulint(descr + XDES_ID, mtr);
- seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
+ descr_id = mach_read_from_8(descr + XDES_ID);
+ seg_id = mach_read_from_8(seg_inode + FSEG_ID);
#if 0
fprintf(stderr,
"InnoDB: InnoDB is freeing space %lu page %lu,\n"
- "InnoDB: which belongs to descr seg %lu %lu\n"
- "InnoDB: segment %lu %lu.\n",
+ "InnoDB: which belongs to descr seg %llu\n"
+ "InnoDB: segment %llu.\n",
(ulong) space, (ulong) page,
- (ulong) ut_dulint_get_high(descr_id),
- (ulong) ut_dulint_get_low(descr_id),
- (ulong) ut_dulint_get_high(seg_id),
- (ulong) ut_dulint_get_low(seg_id));
+ (ullint) descr_id,
+ (ullint) seg_id);
#endif /* 0 */
- if (0 != ut_dulint_cmp(descr_id, seg_id)) {
+ if (UNIV_UNLIKELY(descr_id != seg_id)) {
fputs("InnoDB: Dump of the tablespace extent descriptor: ",
stderr);
ut_print_buf(stderr, descr, 40);
@@ -3328,13 +3321,11 @@ crash:
"InnoDB: Serious error: InnoDB is trying to"
" free space %lu page %lu,\n"
"InnoDB: which does not belong to"
- " segment %lu %lu but belongs\n"
- "InnoDB: to segment %lu %lu.\n",
+ " segment %llu but belongs\n"
+ "InnoDB: to segment %llu.\n",
(ulong) space, (ulong) page,
- (ulong) ut_dulint_get_high(descr_id),
- (ulong) ut_dulint_get_low(descr_id),
- (ulong) ut_dulint_get_high(seg_id),
- (ulong) ut_dulint_get_low(seg_id));
+ (ullint) descr_id,
+ (ullint) seg_id);
goto crash;
}
@@ -3423,8 +3414,7 @@ fseg_free_extent(
descr = xdes_get_descriptor(space, zip_size, page, mtr);
ut_a(xdes_get_state(descr, mtr) == XDES_FSEG);
- ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr),
- mtr_read_dulint(seg_inode + FSEG_ID, mtr)));
+ ut_a(!memcmp(descr + XDES_ID, seg_inode + FSEG_ID, 8));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
@@ -3684,7 +3674,7 @@ fseg_validate_low(
mtr_t* mtr2) /*!< in: mtr */
{
ulint space;
- dulint seg_id;
+ ib_id_t seg_id;
mtr_t mtr;
xdes_t* descr;
fil_addr_t node_addr;
@@ -3696,7 +3686,7 @@ fseg_validate_low(
space = page_get_space_id(page_align(inode));
- seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2);
+ seg_id = mach_read_from_8(inode + FSEG_ID);
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
MLOG_4BYTES, mtr2);
flst_validate(inode + FSEG_FREE, mtr2);
@@ -3719,8 +3709,7 @@ fseg_validate_low(
ut_a(xdes_get_n_used(descr, &mtr) == 0);
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
- ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
- seg_id));
+ ut_a(mach_read_from_8(descr + XDES_ID) == seg_id);
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
mtr_commit(&mtr);
@@ -3744,8 +3733,7 @@ fseg_validate_low(
ut_a(xdes_get_n_used(descr, &mtr) > 0);
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
- ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
- seg_id));
+ ut_a(mach_read_from_8(descr + XDES_ID) == seg_id);
n_used2 += xdes_get_n_used(descr, &mtr);
@@ -3770,8 +3758,7 @@ fseg_validate_low(
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
- ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
- seg_id));
+ ut_a(mach_read_from_8(descr + XDES_ID) == seg_id);
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
mtr_commit(&mtr);
@@ -3822,8 +3809,6 @@ fseg_print_low(
mtr_t* mtr) /*!< in: mtr */
{
ulint space;
- ulint seg_id_low;
- ulint seg_id_high;
ulint n_used;
ulint n_frag;
ulint n_free;
@@ -3832,7 +3817,7 @@ fseg_print_low(
ulint reserved;
ulint used;
ulint page_no;
- dulint d_var;
+ ib_id_t seg_id;
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
space = page_get_space_id(page_align(inode));
@@ -3840,10 +3825,7 @@ fseg_print_low(
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
- d_var = mtr_read_dulint(inode + FSEG_ID, mtr);
-
- seg_id_low = ut_dulint_get_low(d_var);
- seg_id_high = ut_dulint_get_high(d_var);
+ seg_id = mach_read_from_8(inode + FSEG_ID);
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
MLOG_4BYTES, mtr);
@@ -3853,11 +3835,11 @@ fseg_print_low(
n_full = flst_get_len(inode + FSEG_FULL, mtr);
fprintf(stderr,
- "SEGMENT id %lu %lu space %lu; page %lu;"
+ "SEGMENT id %llu space %lu; page %lu;"
" res %lu used %lu; full ext %lu\n"
"fragm pages %lu; free extents %lu;"
" not full extents %lu: pages %lu\n",
- (ulong) seg_id_high, (ulong) seg_id_low,
+ (ullint) seg_id,
(ulong) space, (ulong) page_no,
(ulong) reserved, (ulong) used, (ulong) n_full,
(ulong) n_frag, (ulong) n_free, (ulong) n_not_full,
@@ -4059,8 +4041,7 @@ fsp_validate(
seg_inode = fsp_seg_inode_page_get_nth_inode(
seg_inode_page, n, zip_size, &mtr);
- ut_a(!ut_dulint_is_zero(
- mach_read_from_8(seg_inode + FSEG_ID)));
+ ut_a(mach_read_from_8(seg_inode + FSEG_ID) != 0);
fseg_validate_low(seg_inode, &mtr);
descr_count += flst_get_len(seg_inode + FSEG_FREE,
@@ -4105,8 +4086,7 @@ fsp_validate(
seg_inode = fsp_seg_inode_page_get_nth_inode(
seg_inode_page, n, zip_size, &mtr);
- if (!ut_dulint_is_zero(
- mach_read_from_8(seg_inode + FSEG_ID))) {
+ if (mach_read_from_8(seg_inode + FSEG_ID)) {
fseg_validate_low(seg_inode, &mtr);
descr_count += flst_get_len(
@@ -4168,11 +4148,9 @@ fsp_print(
ulint n_free;
ulint n_free_frag;
ulint n_full_frag;
- ulint seg_id_low;
- ulint seg_id_high;
+ ib_id_t seg_id;
ulint n;
ulint n_segs = 0;
- dulint d_var;
mtr_t mtr;
mtr_t mtr2;
@@ -4202,21 +4180,18 @@ fsp_print(
n_free_frag = flst_get_len(header + FSP_FREE_FRAG, &mtr);
n_full_frag = flst_get_len(header + FSP_FULL_FRAG, &mtr);
- d_var = mtr_read_dulint(header + FSP_SEG_ID, &mtr);
-
- seg_id_low = ut_dulint_get_low(d_var);
- seg_id_high = ut_dulint_get_high(d_var);
+ seg_id = mach_read_from_8(header + FSP_SEG_ID);
fprintf(stderr,
"FILE SPACE INFO: id %lu\n"
"size %lu, free limit %lu, free extents %lu\n"
"not full frag extents %lu: used pages %lu,"
" full frag extents %lu\n"
- "first seg id not used %lu %lu\n",
+ "first seg id not used %llu\n",
(ulong) space,
(ulong) size, (ulong) free_limit, (ulong) n_free,
(ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag,
- (ulong) seg_id_high, (ulong) seg_id_low);
+ (ullint) seg_id);
mtr_commit(&mtr);
@@ -4246,8 +4221,7 @@ fsp_print(
seg_inode = fsp_seg_inode_page_get_nth_inode(
seg_inode_page, n, zip_size, &mtr);
- ut_a(!ut_dulint_is_zero(
- mach_read_from_8(seg_inode + FSEG_ID)));
+ ut_a(mach_read_from_8(seg_inode + FSEG_ID) != 0);
fseg_print_low(seg_inode, &mtr);
n_segs++;
@@ -4284,8 +4258,7 @@ fsp_print(
seg_inode = fsp_seg_inode_page_get_nth_inode(
seg_inode_page, n, zip_size, &mtr);
- if (!ut_dulint_is_zero(
- mach_read_from_8(seg_inode + FSEG_ID))) {
+ if (mach_read_from_8(seg_inode + FSEG_ID)) {
fseg_print_low(seg_inode, &mtr);
n_segs++;
diff --git a/storage/innobase/ha/ha0ha.c b/storage/innobase/ha/ha0ha.c
index 9d9d341ad39..f9e798012f8 100644
--- a/storage/innobase/ha/ha0ha.c
+++ b/storage/innobase/ha/ha0ha.c
@@ -31,9 +31,7 @@ Created 8/22/1994 Heikki Tuuri
#ifdef UNIV_DEBUG
# include "buf0buf.h"
#endif /* UNIV_DEBUG */
-#ifdef UNIV_SYNC_DEBUG
-# include "btr0sea.h"
-#endif /* UNIV_SYNC_DEBUG */
+#include "btr0sea.h"
#include "page0page.h"
/*************************************************************//**
@@ -127,7 +125,8 @@ ha_clear(
/*************************************************************//**
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
-is inserted.
+is inserted. If btr_search_enabled is set to FALSE, we will only allow
+updating existing nodes, but no new node is allowed to be added.
@return TRUE if succeed, FALSE if no more memory could be allocated */
UNIV_INTERN
ibool
@@ -174,6 +173,7 @@ ha_insert_for_fold_func(
prev_block->n_pointers--;
block->n_pointers++;
}
+ ut_ad(!btr_search_fully_disabled);
# endif /* !UNIV_HOTBACKUP */
prev_node->block = block;
@@ -186,6 +186,13 @@ ha_insert_for_fold_func(
prev_node = prev_node->next;
}
+ /* We are in the process of disabling hash index, do not add
+ new chain node */
+ if (!btr_search_enabled) {
+ ut_ad(!btr_search_fully_disabled);
+ return(TRUE);
+ }
+
/* We have to allocate a new chain node */
node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t));
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 716b7bbbd56..ab9df9a0272 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -571,7 +571,7 @@ innodb_show_status(
THD* thd, /*!< in: the MySQL query thread of the caller */
stat_print_fn *stat_print);
static
-bool innobase_show_status(handlerton *hton, THD* thd,
+bool innobase_show_status(handlerton *hton, THD* thd,
stat_print_fn* stat_print,
enum ha_stat_type stat_type);
@@ -1032,6 +1032,8 @@ innobase_get_cset_width(
if (cs) {
*mbminlen = cs->mbminlen;
*mbmaxlen = cs->mbmaxlen;
+ ut_ad(*mbminlen < DATA_MBMAX);
+ ut_ad(*mbmaxlen < DATA_MBMAX);
} else {
THD* thd = current_thd;
@@ -1254,7 +1256,7 @@ innobase_mysql_tmpfile(void)
my_close(). */
#ifdef _WIN32
- /* Note that on Windows, the integer returned by mysql_tmpfile
+ /* Note that on Windows, the integer returned by mysql_tmpfile
has no relation to C runtime file descriptor. Here, we need
to call my_get_osfhandle to get the HANDLE and then convert it
to C runtime filedescriptor. */
@@ -2444,6 +2446,7 @@ innobase_change_buffering_inited_ok:
/* Get the current high water mark format. */
innobase_file_format_max = (char*) trx_sys_file_format_max_get();
+ btr_search_fully_disabled = (!btr_search_enabled);
DBUG_RETURN(FALSE);
error:
DBUG_RETURN(TRUE);
@@ -2956,9 +2959,9 @@ innobase_close_connection(
global_system_variables.log_warnings) {
sql_print_warning(
"MySQL is closing a connection that has an active "
- "InnoDB transaction. %lu row modifications will "
+ "InnoDB transaction. %llu row modifications will "
"roll back.",
- (ulong) trx->undo_no.low);
+ (ullint) trx->undo_no);
}
innobase_rollback_trx(trx);
@@ -4427,15 +4430,14 @@ ha_innobase::store_key_val_for_row(
memcpy(buff, src_start, true_len);
buff += true_len;
- /* Pad the unused space with spaces. Note that no
- padding is ever needed for UCS-2 because in MySQL,
- all UCS2 characters are 2 bytes, as MySQL does not
- support surrogate pairs, which are needed to represent
- characters in the range U+10000 to U+10FFFF. */
+ /* Pad the unused space with spaces. */
if (true_len < key_len) {
- ulint pad_len = key_len - true_len;
- memset(buff, ' ', pad_len);
+ ulint pad_len = key_len - true_len;
+ ut_a(!(pad_len % cs->mbminlen));
+
+ cs->cset->fill(cs, buff, pad_len,
+ 0x20 /* space */);
buff += pad_len;
}
}
@@ -4544,6 +4546,7 @@ build_template(
/* Note that in InnoDB, i is the column number. MySQL calls columns
'fields'. */
for (i = 0; i < n_fields; i++) {
+ const dict_col_t* col = &index->table->cols[i];
templ = prebuilt->mysql_template + n_requested_fields;
field = table->field[i];
@@ -4592,7 +4595,7 @@ include_field:
if (index == clust_index) {
templ->rec_field_no = dict_col_get_clust_pos(
- &index->table->cols[i], index);
+ col, index);
} else {
templ->rec_field_no = dict_index_get_nth_col_pos(
index, i);
@@ -4621,7 +4624,7 @@ include_field:
mysql_prefix_len = templ->mysql_col_offset
+ templ->mysql_col_len;
}
- templ->type = index->table->cols[i].mtype;
+ templ->type = col->mtype;
templ->mysql_type = (ulint)field->type();
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
@@ -4629,12 +4632,10 @@ include_field:
(((Field_varstring*)field)->length_bytes);
}
- templ->charset = dtype_get_charset_coll(
- index->table->cols[i].prtype);
- templ->mbminlen = index->table->cols[i].mbminlen;
- templ->mbmaxlen = index->table->cols[i].mbmaxlen;
- templ->is_unsigned = index->table->cols[i].prtype
- & DATA_UNSIGNED;
+ templ->charset = dtype_get_charset_coll(col->prtype);
+ templ->mbminlen = dict_col_get_mbminlen(col);
+ templ->mbmaxlen = dict_col_get_mbmaxlen(col);
+ templ->is_unsigned = col->prtype & DATA_UNSIGNED;
if (templ->type == DATA_BLOB) {
prebuilt->templ_contains_blob = TRUE;
}
@@ -5562,6 +5563,9 @@ ha_innobase::index_read(
prebuilt->index_usable = FALSE;
DBUG_RETURN(HA_ERR_CRASHED);
}
+ if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
+ DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED);
+ }
/* Note that if the index for which the search template is built is not
necessarily prebuilt->index, but can also be the clustered index */
@@ -6655,6 +6659,7 @@ ha_innobase::create(
const ulint file_format = srv_file_format;
const char* stmt;
size_t stmt_len;
+ enum row_type row_type;
DBUG_ENTER("ha_innobase::create");
@@ -6775,94 +6780,94 @@ ha_innobase::create(
}
}
- if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) {
- if (flags) {
- /* KEY_BLOCK_SIZE was specified. */
- if (form->s->row_type != ROW_TYPE_COMPRESSED) {
- /* ROW_FORMAT other than COMPRESSED
- ignores KEY_BLOCK_SIZE. It does not
- make sense to reject conflicting
- KEY_BLOCK_SIZE and ROW_FORMAT, because
- such combinations can be obtained
- with ALTER TABLE anyway. */
- push_warning_printf(
- thd,
- MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ignoring KEY_BLOCK_SIZE=%lu"
- " unless ROW_FORMAT=COMPRESSED.",
- create_info->key_block_size);
- flags = 0;
- }
- } else {
- /* No KEY_BLOCK_SIZE */
- if (form->s->row_type == ROW_TYPE_COMPRESSED) {
- /* ROW_FORMAT=COMPRESSED without
- KEY_BLOCK_SIZE implies half the
- maximum KEY_BLOCK_SIZE. */
- flags = (DICT_TF_ZSSIZE_MAX - 1)
- << DICT_TF_ZSSIZE_SHIFT
- | DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT;
+ row_type = form->s->row_type;
+
+ if (flags) {
+ /* KEY_BLOCK_SIZE was specified. */
+ if (!(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) {
+ /* ROW_FORMAT was not specified;
+ default to ROW_FORMAT=COMPRESSED */
+ row_type = ROW_TYPE_COMPRESSED;
+ } else if (row_type != ROW_TYPE_COMPRESSED) {
+ /* ROW_FORMAT other than COMPRESSED
+ ignores KEY_BLOCK_SIZE. It does not
+ make sense to reject conflicting
+ KEY_BLOCK_SIZE and ROW_FORMAT, because
+ such combinations can be obtained
+ with ALTER TABLE anyway. */
+ push_warning_printf(
+ thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: ignoring KEY_BLOCK_SIZE=%lu"
+ " unless ROW_FORMAT=COMPRESSED.",
+ create_info->key_block_size);
+ flags = 0;
+ }
+ } else {
+ /* No KEY_BLOCK_SIZE */
+ if (row_type == ROW_TYPE_COMPRESSED) {
+ /* ROW_FORMAT=COMPRESSED without
+ KEY_BLOCK_SIZE implies half the
+ maximum KEY_BLOCK_SIZE. */
+ flags = (DICT_TF_ZSSIZE_MAX - 1)
+ << DICT_TF_ZSSIZE_SHIFT
+ | DICT_TF_COMPACT
+ | DICT_TF_FORMAT_ZIP
+ << DICT_TF_FORMAT_SHIFT;
#if DICT_TF_ZSSIZE_MAX < 1
# error "DICT_TF_ZSSIZE_MAX < 1"
#endif
- }
}
+ }
- switch (form->s->row_type) {
- const char* row_format_name;
- case ROW_TYPE_REDUNDANT:
- break;
- case ROW_TYPE_COMPRESSED:
- case ROW_TYPE_DYNAMIC:
- row_format_name
- = form->s->row_type == ROW_TYPE_COMPRESSED
- ? "COMPRESSED"
- : "DYNAMIC";
-
- if (!srv_file_per_table) {
- push_warning_printf(
- thd,
- MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ROW_FORMAT=%s"
- " requires innodb_file_per_table.",
- row_format_name);
- } else if (file_format < DICT_TF_FORMAT_ZIP) {
- push_warning_printf(
- thd,
- MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ROW_FORMAT=%s"
- " requires innodb_file_format >"
- " Antelope.",
- row_format_name);
- } else {
- flags |= DICT_TF_COMPACT
- | (DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT);
- break;
- }
+ switch (row_type) {
+ const char* row_format_name;
+ case ROW_TYPE_REDUNDANT:
+ break;
+ case ROW_TYPE_COMPRESSED:
+ case ROW_TYPE_DYNAMIC:
+ row_format_name
+ = row_type == ROW_TYPE_COMPRESSED
+ ? "COMPRESSED"
+ : "DYNAMIC";
- /* fall through */
- case ROW_TYPE_NOT_USED:
- case ROW_TYPE_FIXED:
- default:
- push_warning(thd,
- MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: assuming ROW_FORMAT=COMPACT.");
- case ROW_TYPE_DEFAULT:
- case ROW_TYPE_COMPACT:
- flags = DICT_TF_COMPACT;
+ if (!srv_file_per_table) {
+ push_warning_printf(
+ thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: ROW_FORMAT=%s"
+ " requires innodb_file_per_table.",
+ row_format_name);
+ } else if (file_format < DICT_TF_FORMAT_ZIP) {
+ push_warning_printf(
+ thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: ROW_FORMAT=%s"
+ " requires innodb_file_format >"
+ " Antelope.",
+ row_format_name);
+ } else {
+ flags |= DICT_TF_COMPACT
+ | (DICT_TF_FORMAT_ZIP
+ << DICT_TF_FORMAT_SHIFT);
break;
}
- } else if (!flags) {
- /* No KEY_BLOCK_SIZE or ROW_FORMAT specified:
- use ROW_FORMAT=COMPACT by default. */
+
+ /* fall through */
+ case ROW_TYPE_NOT_USED:
+ case ROW_TYPE_FIXED:
+ default:
+ push_warning(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: assuming ROW_FORMAT=COMPACT.");
+ case ROW_TYPE_DEFAULT:
+ case ROW_TYPE_COMPACT:
flags = DICT_TF_COMPACT;
+ break;
}
/* Look for a primary key */
@@ -7419,6 +7424,10 @@ ha_innobase::records_in_range(
n_rows = HA_POS_ERROR;
goto func_exit;
}
+ if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) {
+ n_rows = HA_ERR_TABLE_DEF_CHANGED;
+ goto func_exit;
+ }
heap = mem_heap_create(2 * (key->key_parts * sizeof(dfield_t)
+ sizeof(dtuple_t)));
@@ -10826,7 +10835,7 @@ by the server. Can be set during server startup at command
line or configure file, and a read only variable after
server startup */
static MYSQL_SYSVAR_BOOL(file_format_check, innobase_file_format_check,
- PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+ PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Whether to perform system file format check.",
NULL, NULL, TRUE);
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ec17882590c..3744d16570c 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -99,8 +99,10 @@ innobase_col_to_mysql(
#ifdef UNIV_DEBUG
case DATA_MYSQL:
ut_ad(flen >= len);
- ut_ad(col->mbmaxlen >= col->mbminlen);
- ut_ad(col->mbmaxlen > col->mbminlen || flen == len);
+ ut_ad(DATA_MBMAXLEN(col->mbminmaxlen)
+ >= DATA_MBMINLEN(col->mbminmaxlen));
+ ut_ad(DATA_MBMAXLEN(col->mbminmaxlen)
+ > DATA_MBMINLEN(col->mbminmaxlen) || flen == len);
memcpy(dest, data, len);
break;
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 2c15a3b87db..0733a558080 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -401,133 +401,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_ADAPTIVE_HASH_LATCHED 20
- {STRUCT_FLD(field_name, "trx_apative_hash_latched"),
- STRUCT_FLD(field_length, 1),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, 0),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_ADAPTIVE_HASH_TIMEOUT 21
- {STRUCT_FLD(field_name, "trx_adaptive_hash_timeout"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_OPERATION_STATE 8
- {STRUCT_FLD(field_name, "trx_operation_state"),
- STRUCT_FLD(field_length, TRX_I_S_TRX_OP_STATE_MAX_LEN),
- STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_TABLES_IN_USE 9
- {STRUCT_FLD(field_name, "trx_tables_in_use"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_TABLES_LOCKED 10
- {STRUCT_FLD(field_name, "trx_tables_locked"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_LOCK_STRUCTS 11
- {STRUCT_FLD(field_name, "trx_lock_structs"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_LOCK_MEMORY_BYTES 12
- {STRUCT_FLD(field_name, "trx_lock_memory_bytes"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_ROWS_LOCKED 13
- {STRUCT_FLD(field_name, "trx_rows_locked"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_ROWS_MODIFIED 14
- {STRUCT_FLD(field_name, "trx_rows_modified"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_CONNCURRENCY_TICKETS 15
- {STRUCT_FLD(field_name, "trx_concurrency_tickets"),
- STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_ISOLATION_LEVEL 16
- {STRUCT_FLD(field_name, "trx_isolation_level"),
- STRUCT_FLD(field_length, TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN),
- STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, 0),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_UNIQUE_CHECKS 17
- {STRUCT_FLD(field_name, "trx_unique_checks"),
- STRUCT_FLD(field_length, 1),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
- STRUCT_FLD(value, 1),
- STRUCT_FLD(field_flags, 0),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_FOREIGN_KEY_CHECKS 18
- {STRUCT_FLD(field_name, "trx_foreign_key_checks"),
- STRUCT_FLD(field_length, 1),
- STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
- STRUCT_FLD(value, 1),
- STRUCT_FLD(field_flags, 0),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_LAST_FOREIGN_KEY_ERROR 19
- {STRUCT_FLD(field_name, "trx_last_foreign_key_error"),
- STRUCT_FLD(field_length, TRX_I_S_TRX_FK_ERROR_MAX_LEN),
- STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
- STRUCT_FLD(value, 0),
- STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL),
- STRUCT_FLD(old_name, ""),
- STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
-
-#define IDX_TRX_ADAPTIVE_HASH_LATCHED 20
- {STRUCT_FLD(field_name, "trx_apative_hash_latched"),
+ {STRUCT_FLD(field_name, "trx_adaptive_hash_latched"),
STRUCT_FLD(field_length, 1),
STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
STRUCT_FLD(value, 0),
@@ -674,7 +548,7 @@ fill_innodb_trx_from_cache(
OK(field_store_string(fields[IDX_TRX_LAST_FOREIGN_KEY_ERROR],
row->trx_foreign_key_error));
- /* trx_apative_hash_latched */
+ /* trx_adaptive_hash_latched */
OK(fields[IDX_TRX_ADAPTIVE_HASH_LATCHED]->store(
row->trx_has_search_latch));
@@ -1973,16 +1847,13 @@ i_s_dict_fill_sys_tables(
dict_table_t* table, /*!< in: table */
TABLE* table_to_fill) /*!< in/out: fill this table */
{
- longlong table_id;
Field** fields;
DBUG_ENTER("i_s_dict_fill_sys_tables");
fields = table_to_fill->field;
- table_id = ut_conv_dulint_to_longlong(table->id);
-
- OK(fields[SYS_TABLE_ID]->store(table_id, TRUE));
+ OK(fields[SYS_TABLE_ID]->store(longlong(table->id), TRUE));
OK(field_store_string(fields[SYS_TABLE_NAME], table->name));
@@ -2238,16 +2109,13 @@ i_s_dict_fill_sys_tablestats(
dict_table_t* table, /*!< in: table */
TABLE* table_to_fill) /*!< in/out: fill this table */
{
- longlong table_id;
Field** fields;
DBUG_ENTER("i_s_dict_fill_sys_tablestats");
fields = table_to_fill->field;
- table_id = ut_conv_dulint_to_longlong(table->id);
-
- OK(fields[SYS_TABLESTATS_ID]->store(table_id, TRUE));
+ OK(fields[SYS_TABLESTATS_ID]->store(longlong(table->id), TRUE));
OK(field_store_string(fields[SYS_TABLESTATS_NAME], table->name));
@@ -2495,27 +2363,22 @@ int
i_s_dict_fill_sys_indexes(
/*======================*/
THD* thd, /*!< in: thread */
- dulint tableid, /*!< in: table id */
+ table_id_t table_id, /*!< in: table id */
dict_index_t* index, /*!< in: populated dict_index_t
struct with index info */
TABLE* table_to_fill) /*!< in/out: fill this table */
{
- longlong table_id;
- longlong index_id;
Field** fields;
DBUG_ENTER("i_s_dict_fill_sys_indexes");
fields = table_to_fill->field;
- table_id = ut_conv_dulint_to_longlong(tableid);
- index_id = ut_conv_dulint_to_longlong(index->id);
-
- OK(fields[SYS_INDEX_ID]->store(index_id, TRUE));
+ OK(fields[SYS_INDEX_ID]->store(longlong(index->id), TRUE));
OK(field_store_string(fields[SYS_INDEX_NAME], index->name));
- OK(fields[SYS_INDEX_TABLE_ID]->store(table_id, TRUE));
+ OK(fields[SYS_INDEX_TABLE_ID]->store(longlong(table_id), TRUE));
OK(fields[SYS_INDEX_TYPE]->store(index->type));
@@ -2564,7 +2427,7 @@ i_s_sys_indexes_fill_table(
/* Process each record in the table */
while (rec) {
const char* err_msg;;
- dulint table_id;
+ table_id_t table_id;
dict_index_t index_rec;
/* Populate a dict_index_t structure with information from
@@ -2737,22 +2600,19 @@ int
i_s_dict_fill_sys_columns(
/*======================*/
THD* thd, /*!< in: thread */
- dulint tableid, /*!< in: table ID */
+ table_id_t table_id, /*!< in: table ID */
const char* col_name, /*!< in: column name */
dict_col_t* column, /*!< in: dict_col_t struct holding
more column information */
TABLE* table_to_fill) /*!< in/out: fill this table */
{
- longlong table_id;
Field** fields;
DBUG_ENTER("i_s_dict_fill_sys_columns");
fields = table_to_fill->field;
- table_id = ut_conv_dulint_to_longlong(tableid);
-
- OK(fields[SYS_COLUMN_TABLE_ID]->store(table_id, TRUE));
+ OK(fields[SYS_COLUMN_TABLE_ID]->store(longlong(table_id), TRUE));
OK(field_store_string(fields[SYS_COLUMN_NAME], col_name));
@@ -2803,7 +2663,7 @@ i_s_sys_columns_fill_table(
while (rec) {
const char* err_msg;
dict_col_t column_rec;
- dulint table_id;
+ table_id_t table_id;
/* populate a dict_col_t structure with information from
a SYS_COLUMNS row */
@@ -2948,21 +2808,18 @@ int
i_s_dict_fill_sys_fields(
/*=====================*/
THD* thd, /*!< in: thread */
- dulint indexid, /*!< in: index id for the field */
+ index_id_t index_id, /*!< in: index id for the field */
dict_field_t* field, /*!< in: table */
ulint pos, /*!< in: Field position */
TABLE* table_to_fill) /*!< in/out: fill this table */
{
- longlong index_id;
Field** fields;
DBUG_ENTER("i_s_dict_fill_sys_fields");
fields = table_to_fill->field;
- index_id = ut_conv_dulint_to_longlong(indexid);
-
- OK(fields[SYS_FIELD_INDEX_ID]->store(index_id, TRUE));
+ OK(fields[SYS_FIELD_INDEX_ID]->store(longlong(index_id), TRUE));
OK(field_store_string(fields[SYS_FIELD_NAME], field->name));
@@ -2988,7 +2845,7 @@ i_s_sys_fields_fill_table(
btr_pcur_t pcur;
const rec_t* rec;
mem_heap_t* heap;
- dulint last_id;
+ index_id_t last_id;
mtr_t mtr;
DBUG_ENTER("i_s_sys_fields_fill_table");
@@ -3005,14 +2862,14 @@ i_s_sys_fields_fill_table(
/* will save last index id so that we know whether we move to
the next index. This is used to calculate prefix length */
- last_id = ut_dulint_create(0, 0);
+ last_id = 0;
rec = dict_startscan_system(&pcur, &mtr, SYS_FIELDS);
while (rec) {
ulint pos;
const char* err_msg;
- dulint index_id;
+ index_id_t index_id;
dict_field_t field_rec;
/* Populate a dict_field_t structure with information from
diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c
index 0397af88ff4..dc8e61e5070 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.c
+++ b/storage/innobase/ibuf/ibuf0ibuf.c
@@ -565,7 +565,7 @@ ibuf_init_at_db_start(void)
dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
- table->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
+ table->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID;
dict_table_add_to_cache(table, heap);
mem_heap_free(heap);
@@ -576,7 +576,7 @@ ibuf_init_at_db_start(void)
dict_mem_index_add_field(index, "DUMMY_COLUMN", 0);
- index->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
+ index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID;
error = dict_index_add_to_cache(table, index,
FSP_IBUF_TREE_ROOT_PAGE_NO, FALSE);
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index cc08cc620c5..3912f315f2a 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -130,7 +130,7 @@ btr_page_get(
Gets the index id field of a page.
@return index id */
UNIV_INLINE
-dulint
+index_id_t
btr_page_get_index_id(
/*==================*/
const page_t* page); /*!< in: index page */
@@ -226,7 +226,7 @@ btr_create(
ulint space, /*!< in: space where created */
ulint zip_size,/*!< in: compressed page size in bytes
or 0 for uncompressed pages */
- dulint index_id,/*!< in: index id */
+ index_id_t index_id,/*!< in: index id */
dict_index_t* index, /*!< in: index */
mtr_t* mtr); /*!< in: mini-transaction handle */
/************************************************************//**
diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic
index 97944cc2e26..6c580a0bd6e 100644
--- a/storage/innobase/include/btr0btr.ic
+++ b/storage/innobase/include/btr0btr.ic
@@ -86,7 +86,7 @@ btr_page_set_index_id(
page_t* page, /*!< in: page to be created */
page_zip_des_t* page_zip,/*!< in: compressed page whose uncompressed
part will be updated, or NULL */
- dulint id, /*!< in: index id */
+ index_id_t id, /*!< in: index id */
mtr_t* mtr) /*!< in: mtr */
{
if (UNIV_LIKELY_NULL(page_zip)) {
@@ -95,8 +95,7 @@ btr_page_set_index_id(
page + (PAGE_HEADER + PAGE_INDEX_ID),
8, mtr);
} else {
- mlog_write_dulint(page + (PAGE_HEADER + PAGE_INDEX_ID),
- id, mtr);
+ mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
}
}
#endif /* !UNIV_HOTBACKUP */
@@ -105,7 +104,7 @@ btr_page_set_index_id(
Gets the index id field of a page.
@return index id */
UNIV_INLINE
-dulint
+index_id_t
btr_page_get_index_id(
/*==================*/
const page_t* page) /*!< in: index page */
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 136d2d068a1..757477838ee 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -558,7 +558,7 @@ btr_copy_externally_stored_field_prefix(
ulint local_len);/*!< in: length of data, in bytes */
/*******************************************************************//**
Copies an externally stored field of a record to mem heap.
-@return the field copied to heap */
+@return the field copied to heap, or NULL if the field is incomplete */
UNIV_INTERN
byte*
btr_rec_copy_externally_stored_field(
diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h
index f98ba386f9c..20a2be7f877 100644
--- a/storage/innobase/include/btr0sea.h
+++ b/storage/innobase/include/btr0sea.h
@@ -190,7 +190,13 @@ btr_search_validate(void);
/** Flag: has the search system been enabled?
Protected by btr_search_latch and btr_search_enabled_mutex. */
-extern char btr_search_enabled;
+extern char btr_search_enabled;
+
+/** Flag: whether the search system has completed its disabling process,
+It is set to TRUE right after buf_pool_drop_hash_index() in
+btr_search_disable(), indicating hash index entries are cleaned up.
+Protected by btr_search_latch and btr_search_enabled_mutex. */
+extern ibool btr_search_fully_disabled;
/** The search info struct in an index */
struct btr_search_struct{
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 5326ca9c14f..f33ef65ddf2 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -869,7 +869,8 @@ buf_page_set_accessed(
__attribute__((nonnull));
/*********************************************************************//**
Gets the buf_block_t handle of a buffered file block if an uncompressed
-page frame exists, or NULL.
+page frame exists, or NULL. Note: even though bpage is not declared a
+const we don't update its value. It is safe to make this pure.
@return control block, or NULL */
UNIV_INLINE
buf_block_t*
diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h
index f9fce3f3657..11e4027777a 100644
--- a/storage/innobase/include/data0data.h
+++ b/storage/innobase/include/data0data.h
@@ -309,7 +309,7 @@ dtuple_fold(
ulint n_fields,/*!< in: number of complete fields to fold */
ulint n_bytes,/*!< in: number of bytes to fold in an
incomplete last field */
- dulint tree_id)/*!< in: index tree id */
+ index_id_t tree_id)/*!< in: index tree id */
__attribute__((pure));
/*******************************************************************//**
Sets types of fields binary in a tuple. */
diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic
index da79aa33702..2e3adf4b707 100644
--- a/storage/innobase/include/data0data.ic
+++ b/storage/innobase/include/data0data.ic
@@ -518,7 +518,7 @@ dtuple_fold(
ulint n_fields,/*!< in: number of complete fields to fold */
ulint n_bytes,/*!< in: number of bytes to fold in an
incomplete last field */
- dulint tree_id)/*!< in: index tree id */
+ index_id_t tree_id)/*!< in: index tree id */
{
const dfield_t* field;
ulint i;
@@ -530,7 +530,7 @@ dtuple_fold(
ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N);
ut_ad(dtuple_check_typed(tuple));
- fold = ut_fold_dulint(tree_id);
+ fold = ut_fold_ull(tree_id);
for (i = 0; i < n_fields; i++) {
field = dtuple_get_nth_field(tuple, i);
diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h
index a73bed3a9f5..850cf2e2975 100644
--- a/storage/innobase/include/data0type.h
+++ b/storage/innobase/include/data0type.h
@@ -128,7 +128,7 @@ columns, and for them the precise type is usually not used at all.
/* Precise data types for system columns and the length of those columns;
NOTE: the values must run from 0 up in the order given! All codes must
be less than 256 */
-#define DATA_ROW_ID 0 /* row id: a dulint */
+#define DATA_ROW_ID 0 /* row id: a 48-bit integer */
#define DATA_ROW_ID_LEN 6 /* stored length for row id */
#define DATA_TRX_ID 1 /* transaction id: 6 bytes */
@@ -168,6 +168,17 @@ SQL null*/
store the charset-collation number; one byte is left unused, though */
#define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE 6
+/* Maximum multi-byte character length in bytes, plus 1 */
+#define DATA_MBMAX 5
+
+/* Pack mbminlen, mbmaxlen to mbminmaxlen. */
+#define DATA_MBMINMAXLEN(mbminlen, mbmaxlen) \
+ ((mbmaxlen) * DATA_MBMAX + (mbminlen))
+/* Get mbminlen from mbminmaxlen. */
+#define DATA_MBMINLEN(mbminmaxlen) UNIV_EXPECT(((mbminmaxlen) % DATA_MBMAX), 1)
+/* Get mbmaxlen from mbminmaxlen. */
+#define DATA_MBMAXLEN(mbminmaxlen) ((mbminmaxlen) / DATA_MBMAX)
+
#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
Gets the MySQL type code from a dtype.
@@ -187,10 +198,8 @@ ulint
dtype_get_at_most_n_mbchars(
/*========================*/
ulint prtype, /*!< in: precise type */
- ulint mbminlen, /*!< in: minimum length of a
- multi-byte character */
- ulint mbmaxlen, /*!< in: maximum length of a
- multi-byte character */
+ ulint mbminmaxlen, /*!< in: minimum and maximum length of
+ a multi-byte character */
ulint prefix_len, /*!< in: length of the requested
prefix, in characters, multiplied by
dtype_get_mbmaxlen(dtype) */
@@ -335,6 +344,19 @@ dtype_get_mbmaxlen(
/*===============*/
const dtype_t* type); /*!< in: type */
/*********************************************************************//**
+Sets the minimum and maximum length of a character, in bytes. */
+UNIV_INLINE
+void
+dtype_set_mbminmaxlen(
+/*==================*/
+ dtype_t* type, /*!< in/out: type */
+ ulint mbminlen, /*!< in: minimum length of a char,
+ in bytes, or 0 if this is not
+ a character type */
+ ulint mbmaxlen); /*!< in: maximum length of a char,
+ in bytes, or 0 if this is not
+ a character type */
+/*********************************************************************//**
Gets the padding character code for the type.
@return padding character code, or ULINT_UNDEFINED if no padding specified */
UNIV_INLINE
@@ -354,8 +376,8 @@ dtype_get_fixed_size_low(
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type */
ulint len, /*!< in: length */
- ulint mbminlen, /*!< in: minimum length of a multibyte char */
- ulint mbmaxlen, /*!< in: maximum length of a multibyte char */
+ ulint mbminmaxlen, /*!< in: minimum and maximum length of a
+ multibyte character, in bytes */
ulint comp); /*!< in: nonzero=ROW_FORMAT=COMPACT */
#ifndef UNIV_HOTBACKUP
/***********************************************************************//**
@@ -368,8 +390,8 @@ dtype_get_min_size_low(
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type */
ulint len, /*!< in: length */
- ulint mbminlen, /*!< in: minimum length of a multibyte char */
- ulint mbmaxlen); /*!< in: maximum length of a multibyte char */
+ ulint mbminmaxlen); /*!< in: minimum and maximum length of a
+ multibyte character */
/***********************************************************************//**
Returns the maximum size of a data type. Note: types in system tables may be
incomplete and return incorrect information.
@@ -472,10 +494,11 @@ struct dtype_struct{
the string, MySQL uses 1 or 2
bytes to store the string length) */
#ifndef UNIV_HOTBACKUP
- unsigned mbminlen:2; /*!< minimum length of a
- character, in bytes */
- unsigned mbmaxlen:3; /*!< maximum length of a
- character, in bytes */
+ unsigned mbminmaxlen:5; /*!< minimum and maximum length of a
+ character, in bytes;
+ DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
+ mbminlen=DATA_MBMINLEN(mbminmaxlen);
+ mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */
#endif /* !UNIV_HOTBACKUP */
};
diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic
index 2bf67a941bd..757dd815c5e 100644
--- a/storage/innobase/include/data0type.ic
+++ b/storage/innobase/include/data0type.ic
@@ -93,14 +93,35 @@ dtype_get_mblen(
innobase_get_cset_width(dtype_get_charset_coll(prtype),
mbminlen, mbmaxlen);
ut_ad(*mbminlen <= *mbmaxlen);
- ut_ad(*mbminlen <= 2); /* mbminlen in dtype_t is 0..3 */
- ut_ad(*mbmaxlen < 1 << 3); /* mbmaxlen in dtype_t is 0..7 */
+ ut_ad(*mbminlen < DATA_MBMAX);
+ ut_ad(*mbmaxlen < DATA_MBMAX);
} else {
*mbminlen = *mbmaxlen = 0;
}
}
/*********************************************************************//**
+Sets the minimum and maximum length of a character, in bytes. */
+UNIV_INLINE
+void
+dtype_set_mbminmaxlen(
+/*==================*/
+ dtype_t* type, /*!< in/out: type */
+ ulint mbminlen, /*!< in: minimum length of a char,
+ in bytes, or 0 if this is not
+ a character type */
+ ulint mbmaxlen) /*!< in: maximum length of a char,
+ in bytes, or 0 if this is not
+ a character type */
+{
+ ut_ad(mbminlen < DATA_MBMAX);
+ ut_ad(mbmaxlen < DATA_MBMAX);
+ ut_ad(mbminlen <= mbmaxlen);
+
+ type->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
+}
+
+/*********************************************************************//**
Compute the mbminlen and mbmaxlen members of a data type structure. */
UNIV_INLINE
void
@@ -112,8 +133,7 @@ dtype_set_mblen(
ulint mbmaxlen;
dtype_get_mblen(type->mtype, type->prtype, &mbminlen, &mbmaxlen);
- type->mbminlen = mbminlen;
- type->mbmaxlen = mbmaxlen;
+ dtype_set_mbminmaxlen(type, mbminlen, mbmaxlen);
ut_ad(dtype_validate(type));
}
@@ -210,7 +230,7 @@ dtype_get_mbminlen(
const dtype_t* type) /*!< in: type */
{
ut_ad(type);
- return(type->mbminlen);
+ return(DATA_MBMINLEN(type->mbminmaxlen));
}
/*********************************************************************//**
Gets the maximum length of a character, in bytes.
@@ -223,7 +243,7 @@ dtype_get_mbmaxlen(
const dtype_t* type) /*!< in: type */
{
ut_ad(type);
- return(type->mbmaxlen);
+ return(DATA_MBMAXLEN(type->mbminmaxlen));
}
/*********************************************************************//**
@@ -404,8 +424,8 @@ dtype_get_fixed_size_low(
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type */
ulint len, /*!< in: length */
- ulint mbminlen, /*!< in: minimum length of a multibyte char */
- ulint mbmaxlen, /*!< in: maximum length of a multibyte char */
+ ulint mbminmaxlen, /*!< in: minimum and maximum length of
+ a multibyte character, in bytes */
ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */
{
switch (mtype) {
@@ -453,8 +473,9 @@ dtype_get_fixed_size_low(
dtype_get_charset_coll(prtype),
&i_mbminlen, &i_mbmaxlen);
- if (UNIV_UNLIKELY(mbminlen != i_mbminlen)
- || UNIV_UNLIKELY(mbmaxlen != i_mbmaxlen)) {
+ if (UNIV_UNLIKELY
+ (DATA_MBMINMAXLEN(i_mbminlen, i_mbmaxlen)
+ != mbminmaxlen)) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: "
@@ -464,10 +485,10 @@ dtype_get_fixed_size_low(
"type->mbmaxlen=%lu\n",
(ulong) i_mbminlen,
(ulong) i_mbmaxlen,
- (ulong) mbminlen,
- (ulong) mbmaxlen);
+ (ulong) DATA_MBMINLEN(mbminmaxlen),
+ (ulong) DATA_MBMAXLEN(mbminmaxlen));
}
- if (mbminlen == mbmaxlen) {
+ if (i_mbminlen == i_mbmaxlen) {
return(len);
}
}
@@ -499,8 +520,8 @@ dtype_get_min_size_low(
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type */
ulint len, /*!< in: length */
- ulint mbminlen, /*!< in: minimum length of a multibyte char */
- ulint mbmaxlen) /*!< in: maximum length of a multibyte char */
+ ulint mbminmaxlen) /*!< in: minimum and maximum length of a
+ multi-byte character */
{
switch (mtype) {
case DATA_SYS:
@@ -527,14 +548,22 @@ dtype_get_min_size_low(
case DATA_DOUBLE:
return(len);
case DATA_MYSQL:
- if ((prtype & DATA_BINARY_TYPE) || mbminlen == mbmaxlen) {
+ if (prtype & DATA_BINARY_TYPE) {
return(len);
+ } else {
+ ulint mbminlen = DATA_MBMINLEN(mbminmaxlen);
+ ulint mbmaxlen = DATA_MBMAXLEN(mbminmaxlen);
+
+ if (mbminlen == mbmaxlen) {
+ return(len);
+ }
+
+ /* this is a variable-length character set */
+ ut_a(mbminlen > 0);
+ ut_a(mbmaxlen > mbminlen);
+ ut_a(len % mbmaxlen == 0);
+ return(len * mbminlen / mbmaxlen);
}
- /* this is a variable-length character set */
- ut_a(mbminlen > 0);
- ut_a(mbmaxlen > mbminlen);
- ut_a(len % mbmaxlen == 0);
- return(len * mbminlen / mbmaxlen);
case DATA_VARCHAR:
case DATA_BINARY:
case DATA_DECIMAL:
@@ -595,9 +624,9 @@ dtype_get_sql_null_size(
{
#ifndef UNIV_HOTBACKUP
return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len,
- type->mbminlen, type->mbmaxlen, comp));
+ type->mbminmaxlen, comp));
#else /* !UNIV_HOTBACKUP */
return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len,
- 0, 0, 0));
+ 0, 0));
#endif /* !UNIV_HOTBACKUP */
}
diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h
index 148b5cbe250..22df826da65 100644
--- a/storage/innobase/include/dict0boot.h
+++ b/storage/innobase/include/dict0boot.h
@@ -51,32 +51,35 @@ UNIV_INTERN
void
dict_hdr_get_new_id(
/*================*/
- dulint* table_id, /*!< out: table id (not assigned if NULL) */
- dulint* index_id, /*!< out: index id (not assigned if NULL) */
- ulint* space_id); /*!< out: space id (not assigned if NULL) */
+ table_id_t* table_id, /*!< out: table id
+ (not assigned if NULL) */
+ index_id_t* index_id, /*!< out: index id
+ (not assigned if NULL) */
+ ulint* space_id); /*!< out: space id
+ (not assigned if NULL) */
/**********************************************************************//**
Returns a new row id.
@return the new id */
UNIV_INLINE
-dulint
+row_id_t
dict_sys_get_new_row_id(void);
/*=========================*/
/**********************************************************************//**
Reads a row id from a record or other 6-byte stored form.
@return row id */
UNIV_INLINE
-dulint
+row_id_t
dict_sys_read_row_id(
/*=================*/
- byte* field); /*!< in: record field */
+ const byte* field); /*!< in: record field */
/**********************************************************************//**
Writes a row id to a record or other 6-byte stored form. */
UNIV_INLINE
void
dict_sys_write_row_id(
/*==================*/
- byte* field, /*!< in: record field */
- dulint row_id);/*!< in: row id */
+ byte* field, /*!< in: record field */
+ row_id_t row_id);/*!< in: row id */
/*****************************************************************//**
Initializes the data dictionary memory structures when the database is
started. This function is also called when the data dictionary is created. */
@@ -97,12 +100,12 @@ dict_create(void);
#define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
/* The ids for the basic system tables and their indexes */
-#define DICT_TABLES_ID ut_dulint_create(0, 1)
-#define DICT_COLUMNS_ID ut_dulint_create(0, 2)
-#define DICT_INDEXES_ID ut_dulint_create(0, 3)
-#define DICT_FIELDS_ID ut_dulint_create(0, 4)
+#define DICT_TABLES_ID 1
+#define DICT_COLUMNS_ID 2
+#define DICT_INDEXES_ID 3
+#define DICT_FIELDS_ID 4
/* The following is a secondary index on SYS_TABLES */
-#define DICT_TABLE_IDS_ID ut_dulint_create(0, 5)
+#define DICT_TABLE_IDS_ID 5
#define DICT_HDR_FIRST_ID 10 /* the ids for tables etc. start
from this number, except for basic
@@ -110,7 +113,7 @@ dict_create(void);
indexes; ibuf tables and indexes are
assigned as the id the number
DICT_IBUF_ID_MIN plus the space id */
-#define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0)
+#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL
/* The offset of the dictionary header on the page */
#define DICT_HDR FSEG_PAGE_DATA
diff --git a/storage/innobase/include/dict0boot.ic b/storage/innobase/include/dict0boot.ic
index d5f372e38c4..d3ba9eee78f 100644
--- a/storage/innobase/include/dict0boot.ic
+++ b/storage/innobase/include/dict0boot.ic
@@ -36,22 +36,22 @@ dict_hdr_flush_row_id(void);
Returns a new row id.
@return the new id */
UNIV_INLINE
-dulint
+row_id_t
dict_sys_get_new_row_id(void)
/*=========================*/
{
- dulint id;
+ row_id_t id;
mutex_enter(&(dict_sys->mutex));
id = dict_sys->row_id;
- if (0 == (ut_dulint_get_low(id) % DICT_HDR_ROW_ID_WRITE_MARGIN)) {
+ if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) {
dict_hdr_flush_row_id();
}
- UT_DULINT_INC(dict_sys->row_id);
+ dict_sys->row_id++;
mutex_exit(&(dict_sys->mutex));
@@ -62,10 +62,10 @@ dict_sys_get_new_row_id(void)
Reads a row id from a record or other 6-byte stored form.
@return row id */
UNIV_INLINE
-dulint
+row_id_t
dict_sys_read_row_id(
/*=================*/
- byte* field) /*!< in: record field */
+ const byte* field) /*!< in: record field */
{
#if DATA_ROW_ID_LEN != 6
# error "DATA_ROW_ID_LEN != 6"
@@ -80,8 +80,8 @@ UNIV_INLINE
void
dict_sys_write_row_id(
/*==================*/
- byte* field, /*!< in: record field */
- dulint row_id) /*!< in: row id */
+ byte* field, /*!< in: record field */
+ row_id_t row_id) /*!< in: row id */
{
#if DATA_ROW_ID_LEN != 6
# error "DATA_ROW_ID_LEN != 6"
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 3a1bee4cd89..971173a65a5 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -75,8 +75,8 @@ UNIV_INTERN
dict_table_t*
dict_table_get_on_id(
/*=================*/
- dulint table_id, /*!< in: table id */
- trx_t* trx); /*!< in: transaction handle */
+ table_id_t table_id, /*!< in: table id */
+ trx_t* trx); /*!< in: transaction handle */
/********************************************************************//**
Decrements the count of open MySQL handles to a table. */
UNIV_INTERN
@@ -102,6 +102,33 @@ void
dict_load_space_id_list(void);
/*=========================*/
/*********************************************************************//**
+Gets the minimum number of bytes per character.
+@return minimum multi-byte char size, in bytes */
+UNIV_INLINE
+ulint
+dict_col_get_mbminlen(
+/*==================*/
+ const dict_col_t* col); /*!< in: column */
+/*********************************************************************//**
+Gets the maximum number of bytes per character.
+@return maximum multi-byte char size, in bytes */
+UNIV_INLINE
+ulint
+dict_col_get_mbmaxlen(
+/*==================*/
+ const dict_col_t* col); /*!< in: column */
+/*********************************************************************//**
+Sets the minimum and maximum number of bytes per character. */
+UNIV_INLINE
+void
+dict_col_set_mbminmaxlen(
+/*=====================*/
+ dict_col_t* col, /*!< in/out: column */
+ ulint mbminlen, /*!< in: minimum multi-byte
+ character size, in bytes */
+ ulint mbmaxlen); /*!< in: minimum multi-byte
+ character size, in bytes */
+/*********************************************************************//**
Gets the column data type. */
UNIV_INLINE
void
@@ -277,7 +304,7 @@ void
dict_table_change_id_in_cache(
/*==========================*/
dict_table_t* table, /*!< in/out: table object already in cache */
- dulint new_id);/*!< in: new id to set */
+ table_id_t new_id);/*!< in: new id to set */
/**********************************************************************//**
Adds a foreign key constraint object to the dictionary cache. May free
the object if there already is an object with the same identifier in.
@@ -397,7 +424,7 @@ dict_index_t*
dict_index_get_on_id_low(
/*=====================*/
dict_table_t* table, /*!< in: table */
- dulint index_id); /*!< in: index id */
+ index_id_t index_id); /*!< in: index id */
/**********************************************************************//**
Checks if a table is in the dictionary cache.
@return table, NULL if not found */
@@ -423,7 +450,7 @@ UNIV_INLINE
dict_table_t*
dict_table_get_on_id_low(
/*=====================*/
- dulint table_id); /*!< in: table id */
+ table_id_t table_id); /*!< in: table id */
/**********************************************************************//**
Find an index that is equivalent to the one passed in and is not marked
for deletion.
@@ -710,7 +737,7 @@ UNIV_INTERN
dict_index_t*
dict_index_find_on_id_low(
/*======================*/
- dulint id); /*!< in: index id */
+ index_id_t id); /*!< in: index id */
/**********************************************************************//**
Adds an index to the dictionary cache.
@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
@@ -901,7 +928,7 @@ UNIV_INTERN
dict_index_t*
dict_index_get_if_in_cache_low(
/*===========================*/
- dulint index_id); /*!< in: index id */
+ index_id_t index_id); /*!< in: index id */
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**********************************************************************//**
Returns an index object if it is found in the dictionary cache.
@@ -910,7 +937,7 @@ UNIV_INTERN
dict_index_t*
dict_index_get_if_in_cache(
/*=======================*/
- dulint index_id); /*!< in: index id */
+ index_id_t index_id); /*!< in: index id */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG
/**********************************************************************//**
@@ -1135,7 +1162,7 @@ struct dict_sys_struct{
and DROP TABLE, as well as reading
the dictionary data for a table from
system tables */
- dulint row_id; /*!< the next row id to assign;
+ row_id_t row_id; /*!< the next row id to assign;
NOTE that at a checkpoint this
must be written to the dict system
header and flushed to a file; in
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index 93c3f8d4733..09f967aa74a 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -29,6 +29,46 @@ Created 1/8/1996 Heikki Tuuri
#include "rem0types.h"
/*********************************************************************//**
+Gets the minimum number of bytes per character.
+@return minimum multi-byte char size, in bytes */
+UNIV_INLINE
+ulint
+dict_col_get_mbminlen(
+/*==================*/
+ const dict_col_t* col) /*!< in: column */
+{
+ return(DATA_MBMINLEN(col->mbminmaxlen));
+}
+/*********************************************************************//**
+Gets the maximum number of bytes per character.
+@return maximum multi-byte char size, in bytes */
+UNIV_INLINE
+ulint
+dict_col_get_mbmaxlen(
+/*==================*/
+ const dict_col_t* col) /*!< in: column */
+{
+ return(DATA_MBMAXLEN(col->mbminmaxlen));
+}
+/*********************************************************************//**
+Sets the minimum and maximum number of bytes per character. */
+UNIV_INLINE
+void
+dict_col_set_mbminmaxlen(
+/*=====================*/
+ dict_col_t* col, /*!< in/out: column */
+ ulint mbminlen, /*!< in: minimum multi-byte
+ character size, in bytes */
+ ulint mbmaxlen) /*!< in: minimum multi-byte
+ character size, in bytes */
+{
+ ut_ad(mbminlen < DATA_MBMAX);
+ ut_ad(mbmaxlen < DATA_MBMAX);
+ ut_ad(mbminlen <= mbmaxlen);
+
+ col->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
+}
+/*********************************************************************//**
Gets the column data type. */
UNIV_INLINE
void
@@ -42,8 +82,7 @@ dict_col_copy_type(
type->mtype = col->mtype;
type->prtype = col->prtype;
type->len = col->len;
- type->mbminlen = col->mbminlen;
- type->mbmaxlen = col->mbmaxlen;
+ type->mbminmaxlen = col->mbminmaxlen;
}
#endif /* !UNIV_HOTBACKUP */
@@ -65,8 +104,7 @@ dict_col_type_assert_equal(
ut_ad(col->prtype == type->prtype);
ut_ad(col->len == type->len);
# ifndef UNIV_HOTBACKUP
- ut_ad(col->mbminlen == type->mbminlen);
- ut_ad(col->mbmaxlen == type->mbmaxlen);
+ ut_ad(col->mbminmaxlen == type->mbminmaxlen);
# endif /* !UNIV_HOTBACKUP */
return(TRUE);
@@ -84,7 +122,7 @@ dict_col_get_min_size(
const dict_col_t* col) /*!< in: column */
{
return(dtype_get_min_size_low(col->mtype, col->prtype, col->len,
- col->mbminlen, col->mbmaxlen));
+ col->mbminmaxlen));
}
/***********************************************************************//**
Returns the maximum size of the column.
@@ -109,7 +147,7 @@ dict_col_get_fixed_size(
ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */
{
return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
- col->mbminlen, col->mbmaxlen, comp));
+ col->mbminmaxlen, comp));
}
/***********************************************************************//**
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
@@ -780,7 +818,7 @@ UNIV_INLINE
dict_table_t*
dict_table_get_on_id_low(
/*=====================*/
- dulint table_id) /*!< in: table id */
+ table_id_t table_id) /*!< in: table id */
{
dict_table_t* table;
ulint fold;
@@ -788,11 +826,11 @@ dict_table_get_on_id_low(
ut_ad(mutex_own(&(dict_sys->mutex)));
/* Look for the table name in the hash table */
- fold = ut_fold_dulint(table_id);
+ fold = ut_fold_ull(table_id);
HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold,
dict_table_t*, table, ut_ad(table->cached),
- !ut_dulint_cmp(table->id, table_id));
+ table->id == table_id);
if (table == NULL) {
table = dict_load_table_on_id(table_id);
}
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index d85f8f7fc3e..6a718a464ab 100644
--- a/storage/innobase/include/dict0load.h
+++ b/storage/innobase/include/dict0load.h
@@ -109,8 +109,9 @@ dict_load_column_low(
a SYS_COLUMNS record */
mem_heap_t* heap, /*!< in/out: memory heap
for temporary storage */
- dict_col_t* column, /*!< out: dict_column_t to fill */
- dulint* table_id, /*!< out: table id */
+ dict_col_t* column, /*!< out: dict_column_t to fill,
+ or NULL if table != NULL */
+ table_id_t* table_id, /*!< out: table id */
const char** col_name, /*!< out: column name */
const rec_t* rec); /*!< in: SYS_COLUMNS record */
/********************************************************************//**
@@ -173,7 +174,7 @@ UNIV_INTERN
dict_table_t*
dict_load_table_on_id(
/*==================*/
- dulint table_id); /*!< in: table id */
+ table_id_t table_id); /*!< in: table id */
/********************************************************************//**
This function is called when the database is booted.
Loads system table index definitions except for the clustered index which
@@ -255,7 +256,7 @@ dict_process_sys_indexes_rec(
const rec_t* rec, /*!< in: current SYS_INDEXES rec */
dict_index_t* index, /*!< out: dict_index_t to be
filled */
- dulint* table_id); /*!< out: table id */
+ table_id_t* table_id); /*!< out: table id */
/********************************************************************//**
This function parses a SYS_COLUMNS record and populate a dict_column_t
structure with the information from the record.
@@ -267,7 +268,7 @@ dict_process_sys_columns_rec(
mem_heap_t* heap, /*!< in/out: heap memory */
const rec_t* rec, /*!< in: current SYS_COLUMNS rec */
dict_col_t* column, /*!< out: dict_col_t to be filled */
- dulint* table_id, /*!< out: table id */
+ table_id_t* table_id, /*!< out: table id */
const char** col_name); /*!< out: column name */
/********************************************************************//**
This function parses a SYS_FIELDS record and populate a dict_field_t
@@ -282,8 +283,8 @@ dict_process_sys_fields_rec(
dict_field_t* sys_field, /*!< out: dict_field_t to be
filled */
ulint* pos, /*!< out: Field position */
- dulint* index_id, /*!< out: current index id */
- dulint last_id); /*!< in: previous index id */
+ index_id_t* index_id, /*!< out: current index id */
+ index_id_t last_id); /*!< in: previous index id */
/********************************************************************//**
This function parses a SYS_FOREIGN record and populate a dict_foreign_t
structure with the information from the record. For detail information
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 57e5b5394ee..75f9acd6b26 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -151,9 +151,9 @@ dict_mem_table_add_col(
ulint prtype, /*!< in: precise type */
ulint len); /*!< in: precision */
/**********************************************************************//**
-This function poplulates a dict_col_t memory structure with
+This function populates a dict_col_t memory structure with
supplied information. */
-UNIV_INLINE
+UNIV_INTERN
void
dict_mem_fill_column_struct(
/*========================*/
@@ -162,7 +162,7 @@ dict_mem_fill_column_struct(
ulint col_pos, /*!< in: column position */
ulint mtype, /*!< in: main data type */
ulint prtype, /*!< in: precise type */
- ulint col_len); /*!< in: column lenght */
+ ulint col_len); /*!< in: column length */
/**********************************************************************//**
This function poplulates a dict_index_t index memory structure with
supplied information. */
@@ -249,10 +249,11 @@ struct dict_col_struct{
the string, MySQL uses 1 or 2
bytes to store the string length) */
- unsigned mbminlen:2; /*!< minimum length of a
- character, in bytes */
- unsigned mbmaxlen:3; /*!< maximum length of a
- character, in bytes */
+ unsigned mbminmaxlen:5; /*!< minimum and maximum length of a
+ character, in bytes;
+ DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
+ mbminlen=DATA_MBMINLEN(mbminmaxlen);
+ mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */
/*----------------------*/
/* End of definitions copied from dtype_t */
/* @} */
@@ -293,7 +294,7 @@ struct dict_field_struct{
/** Data structure for an index. Most fields will be
initialized to 0, NULL or FALSE in dict_mem_index_create(). */
struct dict_index_struct{
- dulint id; /*!< id of the index */
+ index_id_t id; /*!< id of the index */
mem_heap_t* heap; /*!< memory heap */
const char* name; /*!< index name */
const char* table_name;/*!< table name */
@@ -349,7 +350,7 @@ struct dict_index_struct{
/* @} */
rw_lock_t lock; /*!< read-write lock protecting the
upper levels of the index tree */
- ib_uint64_t trx_id; /*!< id of the transaction that created this
+ trx_id_t trx_id; /*!< id of the transaction that created this
index, or 0 if the index existed
when InnoDB was started up */
#endif /* !UNIV_HOTBACKUP */
@@ -414,9 +415,9 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
/** Data structure for a database table. Most fields will be
initialized to 0, NULL or FALSE in dict_mem_table_create(). */
struct dict_table_struct{
- dulint id; /*!< id of the table */
+ table_id_t id; /*!< id of the table */
mem_heap_t* heap; /*!< memory heap */
- const char* name; /*!< table name */
+ char* name; /*!< table name */
const char* dir_path_of_temp_table;/*!< NULL or the directory path
where a TEMPORARY table that was explicitly
created by a user should be placed if
diff --git a/storage/innobase/include/dict0mem.ic b/storage/innobase/include/dict0mem.ic
index 5a851da5640..1d80ffc9b94 100644
--- a/storage/innobase/include/dict0mem.ic
+++ b/storage/innobase/include/dict0mem.ic
@@ -70,35 +70,3 @@ dict_mem_fill_index_struct(
index->magic_n = DICT_INDEX_MAGIC_N;
#endif /* UNIV_DEBUG */
}
-
-/**********************************************************************//**
-This function poplulates a dict_col_t memory structure with
-supplied information. */
-UNIV_INLINE
-void
-dict_mem_fill_column_struct(
-/*========================*/
- dict_col_t* column, /*!< out: column struct to be
- filled */
- ulint col_pos, /*!< in: column position */
- ulint mtype, /*!< in: main data type */
- ulint prtype, /*!< in: precise type */
- ulint col_len) /*!< in: column lenght */
-{
-#ifndef UNIV_HOTBACKUP
- ulint mbminlen;
- ulint mbmaxlen;
-#endif /* !UNIV_HOTBACKUP */
-
- column->ind = (unsigned int) col_pos;
- column->ord_part = 0;
- column->mtype = (unsigned int) mtype;
- column->prtype = (unsigned int) prtype;
- column->len = (unsigned int) col_len;
-#ifndef UNIV_HOTBACKUP
- dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen);
-
- column->mbminlen = (unsigned int) mbminlen;
- column->mbmaxlen = (unsigned int) mbmaxlen;
-#endif /* !UNIV_HOTBACKUP */
-}
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index 7ad69193cc9..0a9edfbfe70 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -45,4 +45,7 @@ typedef struct tab_node_struct tab_node_t;
#define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */
#define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
+typedef ib_id_t table_id_t;
+typedef ib_id_t index_id_t;
+
#endif
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index c746915844b..d7d98787bcf 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -26,6 +26,7 @@ Created 10/25/1995 Heikki Tuuri
#ifndef fil0fil_h
#define fil0fil_h
+#include "univ.i"
#include "dict0types.h"
#include "ut0byte.h"
#include "os0file.h"
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index 0319c0e9261..3eca80beda4 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -670,7 +670,7 @@ lock_get_type(
Gets the id of the transaction owning a lock.
@return transaction id */
UNIV_INTERN
-ullint
+trx_id_t
lock_get_trx_id(
/*============*/
const lock_t* lock); /*!< in: lock */
@@ -699,7 +699,7 @@ lock_get_type_str(
Gets the id of the table on which the lock is.
@return id of the table */
UNIV_INTERN
-ullint
+table_id_t
lock_get_table_id(
/*==============*/
const lock_t* lock); /*!< in: lock */
diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic
index 139f4041a36..1ce00fd7313 100644
--- a/storage/innobase/include/log0log.ic
+++ b/storage/innobase/include/log0log.ic
@@ -433,7 +433,10 @@ void
log_free_check(void)
/*================*/
{
- /* ut_ad(sync_thread_levels_empty()); */
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(sync_thread_levels_empty_gen(TRUE));
+#endif /* UNIV_SYNC_DEBUG */
if (log_sys->check_flush_or_checkpoint) {
diff --git a/storage/innobase/include/mach0data.h b/storage/innobase/include/mach0data.h
index 44ee3df22ce..8434bc73586 100644
--- a/storage/innobase/include/mach0data.h
+++ b/storage/innobase/include/mach0data.h
@@ -166,14 +166,14 @@ UNIV_INLINE
void
mach_write_to_6(
/*============*/
- byte* b, /*!< in: pointer to 6 bytes where to store */
- dulint n); /*!< in: dulint integer to be stored */
+ byte* b, /*!< in: pointer to 6 bytes where to store */
+ ib_uint64_t id); /*!< in: 48-bit integer */
/********************************************************//**
The following function is used to fetch data from 6 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
+@return 48-bit integer */
UNIV_INLINE
-dulint
+ib_uint64_t
mach_read_from_6(
/*=============*/
const byte* b) /*!< in: pointer to 6 bytes */
@@ -185,14 +185,14 @@ UNIV_INLINE
void
mach_write_to_7(
/*============*/
- byte* b, /*!< in: pointer to 7 bytes where to store */
- dulint n); /*!< in: dulint integer to be stored */
+ byte* b, /*!< in: pointer to 7 bytes where to store */
+ ib_uint64_t n); /*!< in: 56-bit integer */
/********************************************************//**
The following function is used to fetch data from 7 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
+@return 56-bit integer */
UNIV_INLINE
-dulint
+ib_uint64_t
mach_read_from_7(
/*=============*/
const byte* b) /*!< in: pointer to 7 bytes */
@@ -204,88 +204,69 @@ UNIV_INLINE
void
mach_write_to_8(
/*============*/
- byte* b, /*!< in: pointer to 8 bytes where to store */
- dulint n); /*!< in: dulint integer to be stored */
-/*******************************************************//**
-The following function is used to store data in 8 consecutive
-bytes. We store the most significant byte to the lowest address. */
-UNIV_INLINE
-void
-mach_write_ull(
-/*===========*/
byte* b, /*!< in: pointer to 8 bytes where to store */
ib_uint64_t n); /*!< in: 64-bit integer to be stored */
/********************************************************//**
The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
-UNIV_INLINE
-dulint
-mach_read_from_8(
-/*=============*/
- const byte* b) /*!< in: pointer to 8 bytes */
- __attribute__((nonnull, pure));
-/********************************************************//**
-The following function is used to fetch data from 8 consecutive
-bytes. The most significant byte is at the lowest address.
@return 64-bit integer */
UNIV_INLINE
ib_uint64_t
-mach_read_ull(
-/*==========*/
+mach_read_from_8(
+/*=============*/
const byte* b) /*!< in: pointer to 8 bytes */
__attribute__((nonnull, pure));
/*********************************************************//**
-Writes a dulint in a compressed form (5..9 bytes).
+Writes a 64-bit integer in a compressed form (5..9 bytes).
@return size in bytes */
UNIV_INLINE
ulint
-mach_dulint_write_compressed(
-/*=========================*/
- byte* b, /*!< in: pointer to memory where to store */
- dulint n); /*!< in: dulint integer to be stored */
+mach_ull_write_compressed(
+/*======================*/
+ byte* b, /*!< in: pointer to memory where to store */
+ ib_uint64_t n); /*!< in: 64-bit integer to be stored */
/*********************************************************//**
-Returns the size of a dulint when written in the compressed form.
+Returns the size of a 64-bit integer when written in the compressed form.
@return compressed size in bytes */
UNIV_INLINE
ulint
-mach_dulint_get_compressed_size(
-/*============================*/
- dulint n); /*!< in: dulint integer to be stored */
+mach_ull_get_compressed_size(
+/*=========================*/
+ ib_uint64_t n); /*!< in: 64-bit integer to be stored */
/*********************************************************//**
-Reads a dulint in a compressed form.
-@return read dulint */
+Reads a 64-bit integer in a compressed form.
+@return the value read */
UNIV_INLINE
-dulint
-mach_dulint_read_compressed(
-/*========================*/
+ib_uint64_t
+mach_ull_read_compressed(
+/*=====================*/
const byte* b) /*!< in: pointer to memory from where to read */
__attribute__((nonnull, pure));
/*********************************************************//**
-Writes a dulint in a compressed form (1..11 bytes).
+Writes a 64-bit integer in a compressed form (1..11 bytes).
@return size in bytes */
UNIV_INLINE
ulint
-mach_dulint_write_much_compressed(
-/*==============================*/
- byte* b, /*!< in: pointer to memory where to store */
- dulint n); /*!< in: dulint integer to be stored */
+mach_ull_write_much_compressed(
+/*===========================*/
+ byte* b, /*!< in: pointer to memory where to store */
+ ib_uint64_t n); /*!< in: 64-bit integer to be stored */
/*********************************************************//**
-Returns the size of a dulint when written in the compressed form.
+Returns the size of a 64-bit integer when written in the compressed form.
@return compressed size in bytes */
UNIV_INLINE
ulint
-mach_dulint_get_much_compressed_size(
-/*=================================*/
- dulint n) /*!< in: dulint integer to be stored */
+mach_ull_get_much_compressed_size(
+/*==============================*/
+ ib_uint64_t n) /*!< in: 64-bit integer to be stored */
__attribute__((const));
/*********************************************************//**
-Reads a dulint in a compressed form.
-@return read dulint */
+Reads a 64-bit integer in a compressed form.
+@return the value read */
UNIV_INLINE
-dulint
-mach_dulint_read_much_compressed(
-/*=============================*/
+ib_uint64_t
+mach_ull_read_much_compressed(
+/*==========================*/
const byte* b) /*!< in: pointer to memory from where to read */
__attribute__((nonnull, pure));
/*********************************************************//**
@@ -299,15 +280,16 @@ mach_parse_compressed(
byte* end_ptr,/*!< in: pointer to end of the buffer */
ulint* val); /*!< out: read value */
/*********************************************************//**
-Reads a dulint in a compressed form if the log record fully contains it.
-@return pointer to end of the stored field, NULL if not complete */
-UNIV_INTERN
+Reads a 64-bit integer in a compressed form
+if the log record fully contains it.
+@return pointer to end of the stored field, NULL if not complete */
+UNIV_INLINE
byte*
-mach_dulint_parse_compressed(
-/*=========================*/
- byte* ptr, /*!< in: pointer to buffer from where to read */
- byte* end_ptr,/*!< in: pointer to end of the buffer */
- dulint* val); /*!< out: read value */
+mach_ull_parse_compressed(
+/*======================*/
+ byte* ptr, /*!< in: pointer to buffer from where to read */
+ byte* end_ptr,/*!< in: pointer to end of the buffer */
+ ib_uint64_t* val); /*!< out: read value */
#ifndef UNIV_HOTBACKUP
/*********************************************************//**
Reads a double. It is stored in a little-endian format.
diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic
index 96d2417ac81..b1e5991d39e 100644
--- a/storage/innobase/include/mach0data.ic
+++ b/storage/innobase/include/mach0data.ic
@@ -280,22 +280,6 @@ UNIV_INLINE
void
mach_write_to_8(
/*============*/
- byte* b, /*!< in: pointer to 8 bytes where to store */
- dulint n) /*!< in: dulint integer to be stored */
-{
- ut_ad(b);
-
- mach_write_to_4(b, ut_dulint_get_high(n));
- mach_write_to_4(b + 4, ut_dulint_get_low(n));
-}
-
-/*******************************************************//**
-The following function is used to store data in 8 consecutive
-bytes. We store the most significant byte to the lowest address. */
-UNIV_INLINE
-void
-mach_write_ull(
-/*===========*/
byte* b, /*!< in: pointer to 8 bytes where to store */
ib_uint64_t n) /*!< in: 64-bit integer to be stored */
{
@@ -308,32 +292,11 @@ mach_write_ull(
/********************************************************//**
The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
-UNIV_INLINE
-dulint
-mach_read_from_8(
-/*=============*/
- const byte* b) /*!< in: pointer to 8 bytes */
-{
- ulint high;
- ulint low;
-
- ut_ad(b);
-
- high = mach_read_from_4(b);
- low = mach_read_from_4(b + 4);
-
- return(ut_dulint_create(high, low));
-}
-
-/********************************************************//**
-The following function is used to fetch data from 8 consecutive
-bytes. The most significant byte is at the lowest address.
@return 64-bit integer */
UNIV_INLINE
ib_uint64_t
-mach_read_ull(
-/*==========*/
+mach_read_from_8(
+/*=============*/
const byte* b) /*!< in: pointer to 8 bytes */
{
ib_uint64_t ull;
@@ -351,34 +314,28 @@ UNIV_INLINE
void
mach_write_to_7(
/*============*/
- byte* b, /*!< in: pointer to 7 bytes where to store */
- dulint n) /*!< in: dulint integer to be stored */
+ byte* b, /*!< in: pointer to 7 bytes where to store */
+ ib_uint64_t n) /*!< in: 56-bit integer */
{
ut_ad(b);
- mach_write_to_3(b, ut_dulint_get_high(n));
- mach_write_to_4(b + 3, ut_dulint_get_low(n));
+ mach_write_to_3(b, (ulint) (n >> 32));
+ mach_write_to_4(b + 3, (ulint) n);
}
/********************************************************//**
The following function is used to fetch data from 7 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
+@return 56-bit integer */
UNIV_INLINE
-dulint
+ib_uint64_t
mach_read_from_7(
/*=============*/
const byte* b) /*!< in: pointer to 7 bytes */
{
- ulint high;
- ulint low;
-
ut_ad(b);
- high = mach_read_from_3(b);
- low = mach_read_from_4(b + 3);
-
- return(ut_dulint_create(high, low));
+ return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3)));
}
/*******************************************************//**
@@ -388,162 +345,196 @@ UNIV_INLINE
void
mach_write_to_6(
/*============*/
- byte* b, /*!< in: pointer to 6 bytes where to store */
- dulint n) /*!< in: dulint integer to be stored */
+ byte* b, /*!< in: pointer to 6 bytes where to store */
+ ib_uint64_t n) /*!< in: 48-bit integer */
{
ut_ad(b);
- mach_write_to_2(b, ut_dulint_get_high(n));
- mach_write_to_4(b + 2, ut_dulint_get_low(n));
+ mach_write_to_2(b, (ulint) (n >> 32));
+ mach_write_to_4(b + 2, (ulint) n);
}
/********************************************************//**
The following function is used to fetch data from 6 consecutive
bytes. The most significant byte is at the lowest address.
-@return dulint integer */
+@return 48-bit integer */
UNIV_INLINE
-dulint
+ib_uint64_t
mach_read_from_6(
/*=============*/
const byte* b) /*!< in: pointer to 6 bytes */
{
- ulint high;
- ulint low;
-
ut_ad(b);
- high = mach_read_from_2(b);
- low = mach_read_from_4(b + 2);
-
- return(ut_dulint_create(high, low));
+ return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2)));
}
/*********************************************************//**
-Writes a dulint in a compressed form (5..9 bytes).
+Writes a 64-bit integer in a compressed form (5..9 bytes).
@return size in bytes */
UNIV_INLINE
ulint
-mach_dulint_write_compressed(
-/*=========================*/
- byte* b, /*!< in: pointer to memory where to store */
- dulint n) /*!< in: dulint integer to be stored */
+mach_ull_write_compressed(
+/*======================*/
+ byte* b, /*!< in: pointer to memory where to store */
+ ib_uint64_t n) /*!< in: 64-bit integer to be stored */
{
ulint size;
ut_ad(b);
- size = mach_write_compressed(b, ut_dulint_get_high(n));
- mach_write_to_4(b + size, ut_dulint_get_low(n));
+ size = mach_write_compressed(b, (ulint) (n >> 32));
+ mach_write_to_4(b + size, (ulint) n);
return(size + 4);
}
/*********************************************************//**
-Returns the size of a dulint when written in the compressed form.
+Returns the size of a 64-bit integer when written in the compressed form.
@return compressed size in bytes */
UNIV_INLINE
ulint
-mach_dulint_get_compressed_size(
-/*============================*/
- dulint n) /*!< in: dulint integer to be stored */
+mach_ull_get_compressed_size(
+/*=========================*/
+ ib_uint64_t n) /*!< in: 64-bit integer to be stored */
{
- return(4 + mach_get_compressed_size(ut_dulint_get_high(n)));
+ return(4 + mach_get_compressed_size((ulint) (n >> 32)));
}
/*********************************************************//**
-Reads a dulint in a compressed form.
-@return read dulint */
+Reads a 64-bit integer in a compressed form.
+@return the value read */
UNIV_INLINE
-dulint
-mach_dulint_read_compressed(
-/*========================*/
+ib_uint64_t
+mach_ull_read_compressed(
+/*=====================*/
const byte* b) /*!< in: pointer to memory from where to read */
{
- ulint high;
- ulint low;
- ulint size;
+ ib_uint64_t n;
+ ulint size;
ut_ad(b);
- high = mach_read_compressed(b);
+ n = (ib_uint64_t) mach_read_compressed(b);
- size = mach_get_compressed_size(high);
+ size = mach_get_compressed_size((ulint) n);
- low = mach_read_from_4(b + size);
+ n <<= 32;
+ n |= (ib_uint64_t) mach_read_from_4(b + size);
- return(ut_dulint_create(high, low));
+ return(n);
}
/*********************************************************//**
-Writes a dulint in a compressed form (1..11 bytes).
+Writes a 64-bit integer in a compressed form (1..11 bytes).
@return size in bytes */
UNIV_INLINE
ulint
-mach_dulint_write_much_compressed(
-/*==============================*/
- byte* b, /*!< in: pointer to memory where to store */
- dulint n) /*!< in: dulint integer to be stored */
+mach_ull_write_much_compressed(
+/*===========================*/
+ byte* b, /*!< in: pointer to memory where to store */
+ ib_uint64_t n) /*!< in: 64-bit integer to be stored */
{
ulint size;
ut_ad(b);
- if (ut_dulint_get_high(n) == 0) {
- return(mach_write_compressed(b, ut_dulint_get_low(n)));
+ if (!(n >> 32)) {
+ return(mach_write_compressed(b, (ulint) n));
}
*b = (byte)0xFF;
- size = 1 + mach_write_compressed(b + 1, ut_dulint_get_high(n));
+ size = 1 + mach_write_compressed(b + 1, (ulint) (n >> 32));
- size += mach_write_compressed(b + size, ut_dulint_get_low(n));
+ size += mach_write_compressed(b + size, (ulint) n & 0xFFFFFFFF);
return(size);
}
/*********************************************************//**
-Returns the size of a dulint when written in the compressed form.
+Returns the size of a 64-bit integer when written in the compressed form.
@return compressed size in bytes */
UNIV_INLINE
ulint
-mach_dulint_get_much_compressed_size(
-/*=================================*/
- dulint n) /*!< in: dulint integer to be stored */
+mach_ull_get_much_compressed_size(
+/*==============================*/
+ ib_uint64_t n) /*!< in: 64-bit integer to be stored */
{
- if (0 == ut_dulint_get_high(n)) {
- return(mach_get_compressed_size(ut_dulint_get_low(n)));
+ if (!(n >> 32)) {
+ return(mach_get_compressed_size((ulint) n));
}
- return(1 + mach_get_compressed_size(ut_dulint_get_high(n))
- + mach_get_compressed_size(ut_dulint_get_low(n)));
+ return(1 + mach_get_compressed_size((ulint) (n >> 32))
+ + mach_get_compressed_size((ulint) n & ULINT32_MASK));
}
/*********************************************************//**
-Reads a dulint in a compressed form.
-@return read dulint */
+Reads a 64-bit integer in a compressed form.
+@return the value read */
UNIV_INLINE
-dulint
-mach_dulint_read_much_compressed(
-/*=============================*/
+ib_uint64_t
+mach_ull_read_much_compressed(
+/*==========================*/
const byte* b) /*!< in: pointer to memory from where to read */
{
- ulint high;
- ulint low;
- ulint size;
+ ib_uint64_t n;
+ ulint size;
ut_ad(b);
if (*b != (byte)0xFF) {
- high = 0;
+ n = 0;
size = 0;
} else {
- high = mach_read_compressed(b + 1);
+ n = (ib_uint64_t) mach_read_compressed(b + 1);
+
+ size = 1 + mach_get_compressed_size((ulint) n);
+ n <<= 32;
+ }
+
+ n |= mach_read_compressed(b + size);
+
+ return(n);
+}
+
+/*********************************************************//**
+Reads a 64-bit integer in a compressed form
+if the log record fully contains it.
+@return pointer to end of the stored field, NULL if not complete */
+UNIV_INLINE
+byte*
+mach_ull_parse_compressed(
+/*======================*/
+ byte* ptr, /* in: pointer to buffer from where to read */
+ byte* end_ptr,/* in: pointer to end of the buffer */
+ ib_uint64_t* val) /* out: read value */
+{
+ ulint size;
+
+ ut_ad(ptr);
+ ut_ad(end_ptr);
+ ut_ad(val);
+
+ if (end_ptr < ptr + 5) {
+
+ return(NULL);
+ }
+
+ *val = mach_read_compressed(ptr);
+
+ size = mach_get_compressed_size((ulint) *val);
+
+ ptr += size;
+
+ if (end_ptr < ptr + 4) {
- size = 1 + mach_get_compressed_size(high);
+ return(NULL);
}
- low = mach_read_compressed(b + size);
+ *val <<= 32;
+ *val |= mach_read_from_4(ptr);
- return(ut_dulint_create(high, low));
+ return(ptr + 4);
}
#ifndef UNIV_HOTBACKUP
/*********************************************************//**
diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h
index 6322af2a569..d271002a5fe 100644
--- a/storage/innobase/include/mtr0log.h
+++ b/storage/innobase/include/mtr0log.h
@@ -47,11 +47,11 @@ Writes 8 bytes to a file page buffered in the buffer pool.
Writes the corresponding log record to the mini-transaction log. */
UNIV_INTERN
void
-mlog_write_dulint(
-/*==============*/
- byte* ptr, /*!< in: pointer where to write */
- dulint val, /*!< in: value to write */
- mtr_t* mtr); /*!< in: mini-transaction handle */
+mlog_write_ull(
+/*===========*/
+ byte* ptr, /*!< in: pointer where to write */
+ ib_uint64_t val, /*!< in: value to write */
+ mtr_t* mtr); /*!< in: mini-transaction handle */
/********************************************************//**
Writes a string to a file page buffered in the buffer pool. Writes the
corresponding log record to the mini-transaction log. */
@@ -125,13 +125,13 @@ mlog_catenate_ulint_compressed(
mtr_t* mtr, /*!< in: mtr */
ulint val); /*!< in: value to write */
/********************************************************//**
-Catenates a compressed dulint to mlog. */
+Catenates a compressed 64-bit integer to mlog. */
UNIV_INLINE
void
-mlog_catenate_dulint_compressed(
-/*============================*/
- mtr_t* mtr, /*!< in: mtr */
- dulint val); /*!< in: value to write */
+mlog_catenate_ull_compressed(
+/*=========================*/
+ mtr_t* mtr, /*!< in: mtr */
+ ib_uint64_t val); /*!< in: value to write */
/********************************************************//**
Opens a buffer to mlog. It must be closed with mlog_close.
@return buffer, NULL if log mode MTR_LOG_NONE */
@@ -183,7 +183,7 @@ mlog_parse_initial_log_record(
ulint* space, /*!< out: space id */
ulint* page_no);/*!< out: page number */
/********************************************************//**
-Parses a log record written by mlog_write_ulint or mlog_write_dulint.
+Parses a log record written by mlog_write_ulint or mlog_write_ull.
@return parsed record end, NULL if not a complete record */
UNIV_INTERN
byte*
diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic
index 5c24c38b337..c670a0a8c82 100644
--- a/storage/innobase/include/mtr0log.ic
+++ b/storage/innobase/include/mtr0log.ic
@@ -142,13 +142,13 @@ mlog_catenate_ulint_compressed(
}
/********************************************************//**
-Catenates a compressed dulint to mlog. */
+Catenates a compressed 64-bit integer to mlog. */
UNIV_INLINE
void
-mlog_catenate_dulint_compressed(
-/*============================*/
- mtr_t* mtr, /*!< in: mtr */
- dulint val) /*!< in: value to write */
+mlog_catenate_ull_compressed(
+/*=========================*/
+ mtr_t* mtr, /*!< in: mtr */
+ ib_uint64_t val) /*!< in: value to write */
{
byte* log_ptr;
@@ -160,7 +160,7 @@ mlog_catenate_dulint_compressed(
return;
}
- log_ptr += mach_dulint_write_compressed(log_ptr, val);
+ log_ptr += mach_ull_write_compressed(log_ptr, val);
mlog_close(mtr, log_ptr);
}
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index bc3f1951be9..8abca093548 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -264,15 +264,6 @@ mtr_read_ulint(
const byte* ptr, /*!< in: pointer from where to read */
ulint type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
mtr_t* mtr); /*!< in: mini-transaction handle */
-/********************************************************//**
-Reads 8 bytes from a file page buffered in the buffer pool.
-@return value read */
-UNIV_INTERN
-dulint
-mtr_read_dulint(
-/*============*/
- const byte* ptr, /*!< in: pointer from where to read */
- mtr_t* mtr); /*!< in: mini-transaction handle */
#ifndef UNIV_HOTBACKUP
/*********************************************************************//**
This macro locks an rw-lock in s-mode. */
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index 197e361b2b1..6d95b280330 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -177,6 +177,13 @@ log. */
#define OS_WIN95 2 /*!< Microsoft Windows 95 */
#define OS_WINNT 3 /*!< Microsoft Windows NT 3.x */
#define OS_WIN2000 4 /*!< Microsoft Windows 2000 */
+#define OS_WINXP 5 /*!< Microsoft Windows XP
+ or Windows Server 2003 */
+#define OS_WINVISTA 6 /*!< Microsoft Windows Vista
+ or Windows Server 2008 */
+#define OS_WIN7 7 /*!< Microsoft Windows 7
+ or Windows Server 2008 R2 */
+
extern ulint os_n_file_reads;
extern ulint os_n_file_writes;
@@ -368,7 +375,8 @@ typedef DIR* os_file_dir_t; /*!< directory stream */
/***********************************************************************//**
Gets the operating system version. Currently works only on Windows.
-@return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
+@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA,
+OS_WIN7. */
UNIV_INTERN
ulint
os_get_os_version(void);
diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index 0c22162b900..0b600c80ce3 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -38,28 +38,18 @@ Created 9/6/1995 Heikki Tuuri
#include "ut0lst.h"
#ifdef __WIN__
-
+/** Native event (slow)*/
+typedef HANDLE os_native_event_t;
/** Native mutex */
-#define os_fast_mutex_t CRITICAL_SECTION
-
-/** Native event */
-typedef HANDLE os_native_event_t;
-
-/** Operating system event */
-typedef struct os_event_struct os_event_struct_t;
-/** Operating system event handle */
-typedef os_event_struct_t* os_event_t;
-
-/** An asynchronous signal sent between threads */
-struct os_event_struct {
- os_native_event_t handle;
- /*!< Windows event */
- UT_LIST_NODE_T(os_event_struct_t) os_event_list;
- /*!< list of all created events */
-};
+typedef CRITICAL_SECTION os_fast_mutex_t;
+/** Native condition variable. */
+typedef CONDITION_VARIABLE os_cond_t;
#else
/** Native mutex */
-typedef pthread_mutex_t os_fast_mutex_t;
+typedef pthread_mutex_t os_fast_mutex_t;
+/** Native condition variable */
+typedef pthread_cond_t os_cond_t;
+#endif
/** Operating system event */
typedef struct os_event_struct os_event_struct_t;
@@ -68,6 +58,10 @@ typedef os_event_struct_t* os_event_t;
/** An asynchronous signal sent between threads */
struct os_event_struct {
+#ifdef __WIN__
+ HANDLE handle; /*!< kernel event object, slow,
+ used on older Windows */
+#endif
os_fast_mutex_t os_mutex; /*!< this mutex protects the next
fields */
ibool is_set; /*!< this is TRUE when the event is
@@ -76,24 +70,17 @@ struct os_event_struct {
this event */
ib_int64_t signal_count; /*!< this is incremented each time
the event becomes signaled */
- pthread_cond_t cond_var; /*!< condition variable is used in
+ os_cond_t cond_var; /*!< condition variable is used in
waiting for the event */
UT_LIST_NODE_T(os_event_struct_t) os_event_list;
/*!< list of all created events */
};
-#endif
/** Operating system mutex */
typedef struct os_mutex_struct os_mutex_str_t;
/** Operating system mutex handle */
typedef os_mutex_str_t* os_mutex_t;
-/** Denotes an infinite delay for os_event_wait_time() */
-#define OS_SYNC_INFINITE_TIME ((ulint)(-1))
-
-/** Return value of os_event_wait_time() when the time is exceeded */
-#define OS_SYNC_TIME_EXCEEDED 1
-
/** Mutex protecting counts and the event and OS 'slow' mutex lists */
extern os_mutex_t os_sync_mutex;
@@ -187,42 +174,14 @@ os_event_wait_low(
#define os_event_wait(event) os_event_wait_low(event, 0)
-/**********************************************************//**
-Waits for an event object until it is in the signaled state or
-a timeout is exceeded. In Unix the timeout is always infinite.
-@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
-UNIV_INTERN
-ulint
-os_event_wait_time(
-/*===============*/
- os_event_t event, /*!< in: event to wait */
- ulint time); /*!< in: timeout in microseconds, or
- OS_SYNC_INFINITE_TIME */
-#ifdef __WIN__
-/**********************************************************//**
-Waits for any event in an OS native event array. Returns if even a single
-one is signaled or becomes signaled.
-@return index of the event which was signaled */
-UNIV_INTERN
-ulint
-os_event_wait_multiple(
-/*===================*/
- ulint n, /*!< in: number of events in the
- array */
- os_native_event_t* native_event_array);
- /*!< in: pointer to an array of event
- handles */
-#endif
/*********************************************************//**
Creates an operating system mutex semaphore. Because these are slow, the
mutex semaphore of InnoDB itself (mutex_t) should be used where possible.
@return the mutex handle */
UNIV_INTERN
os_mutex_t
-os_mutex_create(
-/*============*/
- const char* name); /*!< in: the name of the mutex, if NULL
- the mutex is created without a name */
+os_mutex_create(void);
+/*=================*/
/**********************************************************//**
Acquires ownership of a mutex semaphore. */
UNIV_INTERN
diff --git a/storage/innobase/include/os0sync.ic b/storage/innobase/include/os0sync.ic
index 1f3ce38fa65..c33f13aaad6 100644
--- a/storage/innobase/include/os0sync.ic
+++ b/storage/innobase/include/os0sync.ic
@@ -28,8 +28,7 @@ Created 9/6/1995 Heikki Tuuri
#endif
/**********************************************************//**
-Acquires ownership of a fast mutex. Currently in Windows this is the same
-as os_fast_mutex_lock!
+Acquires ownership of a fast mutex.
@return 0 if success, != 0 if was reserved by another thread */
UNIV_INLINE
ulint
@@ -38,9 +37,13 @@ os_fast_mutex_trylock(
os_fast_mutex_t* fast_mutex) /*!< in: mutex to acquire */
{
#ifdef __WIN__
- EnterCriticalSection(fast_mutex);
+ if (TryEnterCriticalSection(fast_mutex)) {
- return(0);
+ return(0);
+ } else {
+
+ return(1);
+ }
#else
/* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock
so that it returns 0 on success. In the operating system
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 3899499fb6a..826fd13125d 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -66,7 +66,7 @@ typedef byte page_header_t;
direction */
#define PAGE_N_RECS 16 /* number of user records on the page */
#define PAGE_MAX_TRX_ID 18 /* highest id of a trx which may have modified
- a record on the page; a dulint; defined only
+ a record on the page; trx_id_t; defined only
in secondary indexes and in the insert buffer
tree; NOTE: this may be modified only
when the thread has an x-latch to the page,
diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic
index 8f794410f20..e9624c2360f 100644
--- a/storage/innobase/include/page0page.ic
+++ b/storage/innobase/include/page0page.ic
@@ -94,11 +94,10 @@ page_update_max_trx_id(
TRUE for the dummy indexes constructed during redo log
application). In that case, PAGE_MAX_TRX_ID is unused,
and trx_id is usually zero. */
- ut_ad(!ut_dulint_is_zero(trx_id) || recv_recovery_is_on());
+ ut_ad(trx_id || recv_recovery_is_on());
ut_ad(page_is_leaf(buf_block_get_frame(block)));
- if (ut_dulint_cmp(page_get_max_trx_id(buf_block_get_frame(block)),
- trx_id) < 0) {
+ if (page_get_max_trx_id(buf_block_get_frame(block)) < trx_id) {
page_set_max_trx_id(block, page_zip, trx_id, mtr);
}
diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h
index 524fe4ac3e7..141b2706d7d 100644
--- a/storage/innobase/include/pars0pars.h
+++ b/storage/innobase/include/pars0pars.h
@@ -520,35 +520,18 @@ pars_info_add_int4_literal(
Equivalent to:
char buf[8];
-mach_write_ull(buf, val);
-pars_info_add_literal(info, name, buf, 8, DATA_INT, 0);
-
-except that the buffer is dynamically allocated from the info struct's
-heap. */
-UNIV_INTERN
-void
-pars_info_add_uint64_literal(
-/*=========================*/
- pars_info_t* info, /*!< in: info struct */
- const char* name, /*!< in: name */
- ib_uint64_t val); /*!< in: value */
-
-/****************************************************************//**
-Equivalent to:
-
-char buf[8];
mach_write_to_8(buf, val);
-pars_info_add_literal(info, name, buf, 8, DATA_BINARY, 0);
+pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
except that the buffer is dynamically allocated from the info struct's
heap. */
UNIV_INTERN
void
-pars_info_add_dulint_literal(
-/*=========================*/
+pars_info_add_ull_literal(
+/*======================*/
pars_info_t* info, /*!< in: info struct */
const char* name, /*!< in: name */
- dulint val); /*!< in: value */
+ ib_uint64_t val); /*!< in: value */
/****************************************************************//**
Add user function. */
UNIV_INTERN
diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h
index 39f8d07af89..09734bbb197 100644
--- a/storage/innobase/include/que0que.h
+++ b/storage/innobase/include/que0que.h
@@ -421,9 +421,6 @@ struct que_fork_struct{
ibool cur_on_row; /*!< TRUE if cursor is on a row, i.e.,
it is not before the first row or
after the last row */
- dulint n_inserts; /*!< number of rows inserted */
- dulint n_updates; /*!< number of rows updated */
- dulint n_deletes; /*!< number of rows deleted */
sel_node_t* last_sel_node; /*!< last executed select node, or NULL
if none */
UT_LIST_NODE_T(que_fork_t)
diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h
index 4d9a9fade36..73ea66f4da2 100644
--- a/storage/innobase/include/read0read.h
+++ b/storage/innobase/include/read0read.h
@@ -43,8 +43,7 @@ read_view_t*
read_view_open_now(
/*===============*/
trx_id_t cr_trx_id, /*!< in: trx_id of creating
- transaction, or ut_dulint_zero
- used in purge */
+ transaction, or 0 used in purge */
mem_heap_t* heap); /*!< in: memory heap from which
allocated */
/*********************************************************************//**
@@ -56,8 +55,7 @@ read_view_t*
read_view_oldest_copy_or_open_new(
/*==============================*/
trx_id_t cr_trx_id, /*!< in: trx_id of creating
- transaction, or ut_dulint_zero
- used in purge */
+ transaction, or 0 used in purge */
mem_heap_t* heap); /*!< in: memory heap from which
allocated */
/*********************************************************************//**
@@ -125,7 +123,7 @@ read should not see the modifications to the database. */
struct read_view_struct{
ulint type; /*!< VIEW_NORMAL, VIEW_HIGH_GRANULARITY */
- undo_no_t undo_no;/*!< ut_dulint_zero or if type is
+ undo_no_t undo_no;/*!< 0 or if type is
VIEW_HIGH_GRANULARITY
transaction undo_no when this high-granularity
consistent read view was created */
@@ -156,7 +154,7 @@ struct read_view_struct{
that is, up_limit_id and low_limit_id. */
trx_id_t creator_trx_id;
/*!< trx id of creating transaction, or
- ut_dulint_zero used in purge */
+ 0 used in purge */
UT_LIST_NODE_T(read_view_t) view_list;
/*!< List of read views in trx_sys */
};
diff --git a/storage/innobase/include/read0read.ic b/storage/innobase/include/read0read.ic
index 9924967cc2d..5bb5249b591 100644
--- a/storage/innobase/include/read0read.ic
+++ b/storage/innobase/include/read0read.ic
@@ -64,15 +64,14 @@ read_view_sees_trx_id(
trx_id_t trx_id) /*!< in: trx id */
{
ulint n_ids;
- int cmp;
ulint i;
- if (ut_dulint_cmp(trx_id, view->up_limit_id) < 0) {
+ if (trx_id < view->up_limit_id) {
return(TRUE);
}
- if (ut_dulint_cmp(trx_id, view->low_limit_id) >= 0) {
+ if (trx_id >= view->low_limit_id) {
return(FALSE);
}
@@ -85,12 +84,11 @@ read_view_sees_trx_id(
n_ids = view->n_trx_ids;
for (i = 0; i < n_ids; i++) {
+ trx_id_t view_trx_id
+ = read_view_get_nth_trx_id(view, n_ids - i - 1);
- cmp = ut_dulint_cmp(
- trx_id,
- read_view_get_nth_trx_id(view, n_ids - i - 1));
- if (cmp <= 0) {
- return(cmp < 0);
+ if (trx_id <= view_trx_id) {
+ return(trx_id != view_trx_id);
}
}
diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h
index 17d08afabb9..53402e8d3a9 100644
--- a/storage/innobase/include/rem0rec.h
+++ b/storage/innobase/include/rem0rec.h
@@ -659,7 +659,7 @@ rec_fold(
fields to fold */
ulint n_bytes, /*!< in: number of bytes to fold
in an incomplete last field */
- dulint tree_id) /*!< in: index tree id */
+ index_id_t tree_id) /*!< in: index tree id */
__attribute__((pure));
#endif /* !UNIV_HOTBACKUP */
/*********************************************************//**
diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic
index 8e5bd9a7fcd..ba306eaf27f 100644
--- a/storage/innobase/include/rem0rec.ic
+++ b/storage/innobase/include/rem0rec.ic
@@ -1594,7 +1594,7 @@ rec_fold(
fields to fold */
ulint n_bytes, /*!< in: number of bytes to fold
in an incomplete last field */
- dulint tree_id) /*!< in: index tree id */
+ index_id_t tree_id) /*!< in: index tree id */
{
ulint i;
const byte* data;
@@ -1618,7 +1618,7 @@ rec_fold(
n_bytes = 0;
}
- fold = ut_fold_dulint(tree_id);
+ fold = ut_fold_ull(tree_id);
for (i = 0; i < n_fields; i++) {
data = rec_get_nth_field(rec, offsets, i, &len);
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index 39ea240772c..d9c26a2ee3b 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -103,6 +103,17 @@ row_mysql_read_blob_ref(
ulint col_len); /*!< in: BLOB reference length
(not BLOB length) */
/**************************************************************//**
+Pad a column with spaces. */
+UNIV_INTERN
+void
+row_mysql_pad_col(
+/*==============*/
+ ulint mbminlen, /*!< in: minimum size of a character,
+ in bytes */
+ byte* pad, /*!< out: padded buffer */
+ ulint len); /*!< in: number of bytes to pad */
+
+/**************************************************************//**
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
The counterpart of this function is row_sel_field_store_in_mysql_format() in
row0sel.c.
@@ -622,7 +633,11 @@ struct row_prebuilt_struct {
the secondary index, then this is
set to TRUE */
unsigned templ_contains_blob:1;/*!< TRUE if the template contains
- BLOB column(s) */
+ a column with DATA_BLOB ==
+ get_innobase_type_from_mysql_type();
+ not to be confused with InnoDB
+ externally stored columns
+ (VARCHAR can be off-page too) */
mysql_row_templ_t* mysql_template;/*!< template used to transform
rows fast between MySQL and Innobase
formats; memory for this template
diff --git a/storage/innobase/include/row0upd.h b/storage/innobase/include/row0upd.h
index 635d746d5a1..f7bec6f7561 100644
--- a/storage/innobase/include/row0upd.h
+++ b/storage/innobase/include/row0upd.h
@@ -132,7 +132,7 @@ row_upd_index_entry_sys_field(
them */
dict_index_t* index, /*!< in: clustered index */
ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */
- dulint val); /*!< in: value to write */
+ ib_uint64_t val); /*!< in: value to write */
/*********************************************************************//**
Creates an update node for a query graph.
@return own: update node */
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 18f7c07c3c6..d78c8113aee 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -112,6 +112,9 @@ 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 */
extern my_bool srv_use_native_aio;
+#ifdef __WIN__
+extern ibool srv_use_native_conditions;
+#endif
extern ulint srv_n_data_files;
extern char** srv_data_file_names;
extern ulint* srv_data_file_sizes;
@@ -161,9 +164,9 @@ is 5% of the max where max is srv_io_capacity. */
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
#ifdef UNIV_LOG_ARCHIVE
-extern ibool srv_log_archive_on;
-extern ibool srv_archive_recovery;
-extern dulint srv_archive_recovery_limit_lsn;
+extern ibool srv_log_archive_on;
+extern ibool srv_archive_recovery;
+extern ib_uint64_t srv_archive_recovery_limit_lsn;
#endif /* UNIV_LOG_ARCHIVE */
extern char* srv_file_flush_method_str;
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index 4e73bee9108..940e583350a 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -621,7 +621,7 @@ or row lock! */
#define SYNC_FILE_FORMAT_TAG 1200 /* Used to serialize access to the
file format tag */
#define SYNC_DICT_OPERATION 1001 /* table create, drop, etc. reserve
- this in X-mode, implicit or backround
+ this in X-mode; implicit or backround
operations purge, rollback, foreign
key checks reserve this in S-mode */
#define SYNC_DICT 1000
diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h
index c610782c229..8f8b7367fb0 100644
--- a/storage/innobase/include/trx0i_s.h
+++ b/storage/innobase/include/trx0i_s.h
@@ -30,6 +30,7 @@ Created July 17, 2007 Vasil Dimov
#include "univ.i"
#include "trx0types.h"
+#include "dict0types.h"
#include "ut0ut.h"
/** The maximum amount of memory that can be consumed by innodb_trx,
@@ -95,7 +96,7 @@ struct i_s_hash_chain_struct {
/** This structure represents INFORMATION_SCHEMA.innodb_locks row */
struct i_s_locks_row_struct {
- ullint lock_trx_id; /*!< transaction identifier */
+ trx_id_t lock_trx_id; /*!< transaction identifier */
const char* lock_mode; /*!< lock mode from
lock_get_mode_str() */
const char* lock_type; /*!< lock type from
@@ -116,7 +117,7 @@ struct i_s_locks_row_struct {
/** The following are auxiliary and not included in the table */
/* @{ */
- ullint lock_table_id;
+ table_id_t lock_table_id;
/*!< table identifier from
lock_get_table_id */
i_s_hash_chain_t hash_chain; /*!< hash table chain node for
@@ -126,10 +127,10 @@ struct i_s_locks_row_struct {
/** This structure represents INFORMATION_SCHEMA.innodb_trx row */
struct i_s_trx_row_struct {
- ullint trx_id; /*!< transaction identifier */
- const char* trx_state; /*!< transaction state from
- trx_get_que_state_str() */
- ib_time_t trx_started; /*!< trx_struct::start_time */
+ trx_id_t trx_id; /*!< transaction identifier */
+ const char* trx_state; /*!< transaction state from
+ trx_get_que_state_str() */
+ ib_time_t trx_started; /*!< trx_struct::start_time */
const i_s_locks_row_t* requested_lock_row;
/*!< pointer to a row
in innodb_locks if trx
diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h
index a6e56e963c6..477748f6f89 100644
--- a/storage/innobase/include/trx0rec.h
+++ b/storage/innobase/include/trx0rec.h
@@ -108,7 +108,7 @@ trx_undo_rec_get_pars(
ibool* updated_extern, /*!< out: TRUE if we updated an
externally stored fild */
undo_no_t* undo_no, /*!< out: undo log record number */
- dulint* table_id); /*!< out: table id */
+ table_id_t* table_id); /*!< out: table id */
/*******************************************************************//**
Builds a row reference from an undo log record.
@return pointer to remaining part of undo record */
@@ -227,7 +227,7 @@ trx_undo_report_row_operation(
index, otherwise NULL */
roll_ptr_t* roll_ptr); /*!< out: rollback pointer to the
inserted undo log record,
- ut_dulint_zero if BTR_NO_UNDO_LOG
+ 0 if BTR_NO_UNDO_LOG
flag was specified */
/******************************************************************//**
Copies an undo record to heap. This function can be called if we know that
diff --git a/storage/innobase/include/trx0rec.ic b/storage/innobase/include/trx0rec.ic
index e7e41d6d9f6..f0b3276ed44 100644
--- a/storage/innobase/include/trx0rec.ic
+++ b/storage/innobase/include/trx0rec.ic
@@ -78,7 +78,7 @@ trx_undo_rec_get_undo_no(
ptr = undo_rec + 3;
- return(mach_dulint_read_much_compressed(ptr));
+ return(mach_ull_read_much_compressed(ptr));
}
/**********************************************************************//**
@@ -90,7 +90,7 @@ trx_undo_rec_get_offset(
/*====================*/
undo_no_t undo_no) /*!< in: undo no read from node */
{
- return (3 + mach_dulint_get_much_compressed_size(undo_no));
+ return (3 + mach_ull_get_much_compressed_size(undo_no));
}
/***********************************************************************//**
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
index fc92b4317d5..63e3f6be934 100644
--- a/storage/innobase/include/trx0sys.h
+++ b/storage/innobase/include/trx0sys.h
@@ -568,11 +568,16 @@ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_NO. */
(TRX_SYS_PAGE_NO of TRX_SYS_SPACE) */
#define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
-/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format
+/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format
identifier is added to this constant. */
#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
/** Contents of TRX_SYS_FILE_FORMAT_TAG+4 when valid */
#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL
+/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format
+identifier is added to this 64-bit constant. */
+#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \
+ ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \
+ | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
/* @} */
/** Doublewrite control struct */
diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic
index 820d31d0692..385c7f4f0cc 100644
--- a/storage/innobase/include/trx0sys.ic
+++ b/storage/innobase/include/trx0sys.ic
@@ -266,7 +266,7 @@ trx_get_on_id(
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
while (trx != NULL) {
- if (0 == ut_dulint_cmp(trx_id, trx->id)) {
+ if (trx_id == trx->id) {
return(trx);
}
@@ -315,12 +315,12 @@ trx_is_active(
ut_ad(mutex_own(&(kernel_mutex)));
- if (ut_dulint_cmp(trx_id, trx_list_get_min_trx_id()) < 0) {
+ if (trx_id < trx_list_get_min_trx_id()) {
return(FALSE);
}
- if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) {
+ if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) {
/* There must be corruption: we return TRUE because this
function is only called by lock_clust_rec_some_has_impl()
@@ -359,15 +359,12 @@ trx_sys_get_new_trx_id(void)
Thus trx id values will not overlap when the database is
repeatedly started! */
- if (ut_dulint_get_low(trx_sys->max_trx_id)
- % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) {
+ if ((ulint) trx_sys->max_trx_id % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) {
trx_sys_flush_max_trx_id();
}
- id = trx_sys->max_trx_id;
-
- UT_DULINT_INC(trx_sys->max_trx_id);
+ id = trx_sys->max_trx_id++;
return(id);
}
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index abd175d365b..6a817ccdc8e 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -408,30 +408,20 @@ Calculates the "weight" of a transaction. The weight of one transaction
is estimated as the number of altered rows + the number of locked rows.
@param t transaction
@return transaction weight */
-#define TRX_WEIGHT(t) \
- ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
+#define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->trx_locks))
/*******************************************************************//**
Compares the "weight" (or size) of two transactions. Transactions that
have edited non-transactional tables are considered heavier than ones
that have not.
-@return <0, 0 or >0; similar to strcmp(3) */
+@return TRUE if weight(a) >= weight(b) */
UNIV_INTERN
-int
-trx_weight_cmp(
-/*===========*/
+ibool
+trx_weight_ge(
+/*==========*/
const trx_t* a, /*!< in: the first transaction to be compared */
const trx_t* b); /*!< in: the second transaction to be compared */
-/*******************************************************************//**
-Retrieves transacion's id, represented as unsigned long long.
-@return transaction's id */
-UNIV_INLINE
-ullint
-trx_get_id(
-/*=======*/
- const trx_t* trx); /*!< in: transaction */
-
/* Maximum length of a string that can be returned by
trx_get_que_state_str(). */
#define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */
@@ -555,8 +545,8 @@ struct trx_struct{
max trx id when the transaction is
moved to COMMITTED_IN_MEMORY state */
ib_uint64_t commit_lsn; /*!< lsn at the time of the commit */
- trx_id_t table_id; /*!< Table to drop iff dict_operation
- is TRUE, or ut_dulint_zero. */
+ table_id_t table_id; /*!< Table to drop iff dict_operation
+ is TRUE, or 0. */
/*------------------------------*/
void* mysql_thd; /*!< MySQL thread handle corresponding
to this trx, or NULL */
diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic
index 7332eeece85..4a1d3bcde0b 100644
--- a/storage/innobase/include/trx0trx.ic
+++ b/storage/innobase/include/trx0trx.ic
@@ -69,18 +69,6 @@ trx_get_error_info(
}
/*******************************************************************//**
-Retrieves transacion's id, represented as unsigned long long.
-@return transaction's id */
-UNIV_INLINE
-ullint
-trx_get_id(
-/*=======*/
- const trx_t* trx) /*!< in: transaction */
-{
- return((ullint)ut_conv_dulint_to_longlong(trx->id));
-}
-
-/*******************************************************************//**
Retrieves transaction's que state in a human readable string. The string
should not be free()'d or modified.
@return string in the data segment */
diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h
index 40a7256cbfd..a4115b5aca7 100644
--- a/storage/innobase/include/trx0types.h
+++ b/storage/innobase/include/trx0types.h
@@ -28,10 +28,7 @@ Created 3/26/1996 Heikki Tuuri
#include "ut0byte.h"
-/** prepare trx_t::id for being printed via printf(3) */
-#define TRX_ID_PREP_PRINTF(id) (ullint) ut_conv_dulint_to_longlong(id)
-
-/** printf(3) format used for printing TRX_ID_PRINTF_PREP() */
+/** printf(3) format used for printing DB_TRX_ID and other system fields */
#define TRX_ID_FMT "%llX"
/** maximum length that a formatted trx_t::id could take, not including
@@ -81,12 +78,14 @@ enum trx_rb_ctx {
in crash recovery */
};
+/** Row identifier (DB_ROW_ID, DATA_ROW_ID) */
+typedef ib_id_t row_id_t;
/** Transaction identifier (DB_TRX_ID, DATA_TRX_ID) */
-typedef dulint trx_id_t;
+typedef ib_id_t trx_id_t;
/** Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR) */
-typedef dulint roll_ptr_t;
+typedef ib_id_t roll_ptr_t;
/** Undo number */
-typedef dulint undo_no_t;
+typedef ib_id_t undo_no_t;
/** Transaction savepoint */
typedef struct trx_savept_struct trx_savept_t;
diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h
index a084f2394b5..54809f9c2d5 100644
--- a/storage/innobase/include/trx0undo.h
+++ b/storage/innobase/include/trx0undo.h
@@ -383,7 +383,7 @@ struct trx_undo_struct{
XID xid; /*!< X/Open XA transaction
identification */
ibool dict_operation; /*!< TRUE if a dict operation trx */
- dulint table_id; /*!< if a dict operation, then the table
+ table_id_t table_id; /*!< if a dict operation, then the table
id */
trx_rseg_t* rseg; /*!< rseg where the undo log belongs */
/*-----------------------------*/
diff --git a/storage/innobase/include/trx0undo.ic b/storage/innobase/include/trx0undo.ic
index 6502ee826e5..b81330f7f8b 100644
--- a/storage/innobase/include/trx0undo.ic
+++ b/storage/innobase/include/trx0undo.ic
@@ -39,16 +39,19 @@ trx_undo_build_roll_ptr(
ulint page_no, /*!< in: page number */
ulint offset) /*!< in: offset of the undo entry within page */
{
+ roll_ptr_t roll_ptr;
#if DATA_ROLL_PTR_LEN != 7
# error "DATA_ROLL_PTR_LEN != 7"
#endif
+ ut_ad(is_insert == 0 || is_insert == 1);
ut_ad(rseg_id < TRX_SYS_N_RSEGS);
+ ut_ad(offset < 65536);
- return(ut_dulint_create(is_insert * 128 * 256 * 256
- + rseg_id * 256 * 256
- + (page_no / 256) / 256,
- (page_no % (256 * 256)) * 256 * 256
- + offset));
+ roll_ptr = (roll_ptr_t) is_insert << 55
+ | (roll_ptr_t) rseg_id << 48
+ | (roll_ptr_t) page_no << 16
+ | offset;
+ return(roll_ptr);
}
/***********************************************************************//**
@@ -64,24 +67,20 @@ trx_undo_decode_roll_ptr(
ulint* offset) /*!< out: offset of the undo
entry within page */
{
- ulint low;
- ulint high;
#if DATA_ROLL_PTR_LEN != 7
# error "DATA_ROLL_PTR_LEN != 7"
#endif
#if TRUE != 1
# error "TRUE != 1"
#endif
- high = ut_dulint_get_high(roll_ptr);
- low = ut_dulint_get_low(roll_ptr);
-
- *offset = low % (256 * 256);
-
- *is_insert = high / (256 * 256 * 128); /* TRUE == 1 */
- *rseg_id = (high / (256 * 256)) % 128;
-
- *page_no = (high % (256 * 256)) * 256 * 256
- + (low / 256) / 256;
+ ut_ad(roll_ptr < (1ULL << 56));
+ *offset = (ulint) roll_ptr & 0xFFFF;
+ roll_ptr >>= 16;
+ *page_no = (ulint) roll_ptr & 0xFFFFFFFF;
+ roll_ptr >>= 32;
+ *rseg_id = (ulint) roll_ptr & 0x7F;
+ roll_ptr >>= 7;
+ *is_insert = (ibool) roll_ptr; /* TRUE==1 */
}
/***********************************************************************//**
@@ -93,16 +92,14 @@ trx_undo_roll_ptr_is_insert(
/*========================*/
roll_ptr_t roll_ptr) /*!< in: roll pointer */
{
- ulint high;
#if DATA_ROLL_PTR_LEN != 7
# error "DATA_ROLL_PTR_LEN != 7"
#endif
#if TRUE != 1
# error "TRUE != 1"
#endif
- high = ut_dulint_get_high(roll_ptr);
-
- return(high / (256 * 256 * 128));
+ ut_ad(roll_ptr < (1ULL << 56));
+ return((ibool) (roll_ptr >> 55));
}
#endif /* !UNIV_HOTBACKUP */
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index ea213486445..ac87942f255 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 1
-#define INNODB_VERSION_BUGFIX 1
+#define INNODB_VERSION_BUGFIX 2
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
@@ -310,6 +310,12 @@ management to ensure correct alignment for doubles etc. */
/* Maximum number of parallel threads in a parallelized operation */
#define UNIV_MAX_PARALLELISM 32
+/* The maximum length of a table name. This is the MySQL limit and is
+defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the
+number does not include a terminating '\0'. InnoDB probably can handle
+longer names internally */
+#define MAX_TABLE_NAME_LEN 192
+
/*
UNIVERSAL TYPE DEFINITIONS
==========================
@@ -365,8 +371,10 @@ typedef unsigned long long int ullint;
/* The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1))
+/** The bitmask of 32-bit unsigned integer */
+#define ULINT32_MASK 0xFFFFFFFF
/* The undefined 32-bit unsigned integer */
-#define ULINT32_UNDEFINED 0xFFFFFFFF
+#define ULINT32_UNDEFINED ULINT32_MASK
/* Maximum value for a ulint */
#define ULINT_MAX ((ulint)(-2))
@@ -374,6 +382,9 @@ typedef unsigned long long int ullint;
/* Maximum value for ib_uint64_t */
#define IB_ULONGLONG_MAX ((ib_uint64_t) (~0ULL))
+/** The generic InnoDB system object identifier data type */
+typedef ib_uint64_t ib_id_t;
+
/* This 'ibool' type is used within Innobase. Remember that different included
headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */
#define ibool ulint
diff --git a/storage/innobase/include/ut0byte.h b/storage/innobase/include/ut0byte.h
index f55e2888c60..b99d7175b94 100644
--- a/storage/innobase/include/ut0byte.h
+++ b/storage/innobase/include/ut0byte.h
@@ -27,145 +27,22 @@ Created 1/20/1994 Heikki Tuuri
#define ut0byte_h
-#include "univ.i"
-
-/** Pair of ulint integers. */
-typedef struct dulint_struct dulint;
-/** Type definition for a 64-bit unsigned integer, which works also
-in 32-bit machines. NOTE! Access the fields only with the accessor
-functions. This definition appears here only for the compiler to
-know the size of a dulint. */
-struct dulint_struct{
- ulint high; /*!< most significant 32 bits */
- ulint low; /*!< least significant 32 bits */
-};
-
-/** Zero value for a dulint */
-extern const dulint ut_dulint_zero;
-/** Maximum value for a dulint */
-extern const dulint ut_dulint_max;
+#include "univ.i"
/*******************************************************//**
-Creates a 64-bit dulint out of two ulints.
+Creates a 64-bit integer out of two 32-bit integers.
@return created dulint */
UNIV_INLINE
-dulint
-ut_dulint_create(
-/*=============*/
- ulint high, /*!< in: high-order 32 bits */
- ulint low); /*!< in: low-order 32 bits */
-/*******************************************************//**
-Gets the high-order 32 bits of a dulint.
-@return 32 bits in ulint */
-UNIV_INLINE
-ulint
-ut_dulint_get_high(
-/*===============*/
- dulint d); /*!< in: dulint */
-/*******************************************************//**
-Gets the low-order 32 bits of a dulint.
-@return 32 bits in ulint */
-UNIV_INLINE
-ulint
-ut_dulint_get_low(
-/*==============*/
- dulint d); /*!< in: dulint */
-/*******************************************************//**
-Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit
-integer type.
-@return value in ib_int64_t type */
-UNIV_INLINE
-ib_int64_t
-ut_conv_dulint_to_longlong(
-/*=======================*/
- dulint d); /*!< in: dulint */
-/*******************************************************//**
-Tests if a dulint is zero.
-@return TRUE if zero */
-UNIV_INLINE
-ibool
-ut_dulint_is_zero(
-/*==============*/
- dulint a); /*!< in: dulint */
-/*******************************************************//**
-Compares two dulints.
-@return -1 if a < b, 0 if a == b, 1 if a > b */
-UNIV_INLINE
-int
-ut_dulint_cmp(
-/*==========*/
- dulint a, /*!< in: dulint */
- dulint b); /*!< in: dulint */
-/*******************************************************//**
-Calculates the max of two dulints.
-@return max(a, b) */
-UNIV_INLINE
-dulint
-ut_dulint_get_max(
-/*==============*/
- dulint a, /*!< in: dulint */
- dulint b); /*!< in: dulint */
-/*******************************************************//**
-Calculates the min of two dulints.
-@return min(a, b) */
-UNIV_INLINE
-dulint
-ut_dulint_get_min(
-/*==============*/
- dulint a, /*!< in: dulint */
- dulint b); /*!< in: dulint */
-/*******************************************************//**
-Adds a ulint to a dulint.
-@return sum a + b */
-UNIV_INLINE
-dulint
-ut_dulint_add(
+ib_uint64_t
+ut_ull_create(
/*==========*/
- dulint a, /*!< in: dulint */
- ulint b); /*!< in: ulint */
-/*******************************************************//**
-Subtracts a ulint from a dulint.
-@return a - b */
-UNIV_INLINE
-dulint
-ut_dulint_subtract(
-/*===============*/
- dulint a, /*!< in: dulint */
- ulint b); /*!< in: ulint, b <= a */
-/*******************************************************//**
-Subtracts a dulint from another. NOTE that the difference must be positive
-and smaller that 4G.
-@return a - b */
-UNIV_INLINE
-ulint
-ut_dulint_minus(
-/*============*/
- dulint a, /*!< in: dulint; NOTE a must be >= b and at most
- 2 to power 32 - 1 greater */
- dulint b); /*!< in: dulint */
-/********************************************************//**
-Rounds a dulint downward to a multiple of a power of 2.
-@return rounded value */
-UNIV_INLINE
-dulint
-ut_dulint_align_down(
-/*=================*/
- dulint n, /*!< in: number to be rounded */
- ulint align_no); /*!< in: align by this number which must be a
- power of 2 */
-/********************************************************//**
-Rounds a dulint upward to a multiple of a power of 2.
-@return rounded value */
-UNIV_INLINE
-dulint
-ut_dulint_align_up(
-/*===============*/
- dulint n, /*!< in: number to be rounded */
- ulint align_no); /*!< in: align by this number which must be a
- power of 2 */
+ ulint high, /*!< in: high-order 32 bits */
+ ulint low) /*!< in: low-order 32 bits */
+ __attribute__((const));
+
/********************************************************//**
-Rounds a dulint downward to a multiple of a power of 2.
+Rounds a 64-bit integer downward to a multiple of a power of 2.
@return rounded value */
UNIV_INLINE
ib_uint64_t
@@ -184,34 +61,6 @@ ut_uint64_align_up(
ib_uint64_t n, /*!< in: number to be rounded */
ulint align_no); /*!< in: align by this number
which must be a power of 2 */
-/*******************************************************//**
-Increments a dulint variable by 1. */
-#define UT_DULINT_INC(D)\
-{\
- if ((D).low == 0xFFFFFFFFUL) {\
- (D).high = (D).high + 1;\
- (D).low = 0;\
- } else {\
- (D).low = (D).low + 1;\
- }\
-}
-/*******************************************************//**
-Tests if two dulints are equal. */
-#define UT_DULINT_EQ(D1, D2) (((D1).low == (D2).low)\
- && ((D1).high == (D2).high))
-#ifdef notdefined
-/************************************************************//**
-Sort function for dulint arrays. */
-UNIV_INTERN
-void
-ut_dulint_sort(
-/*===========*/
- dulint* arr, /*!< in/out: array to be sorted */
- dulint* aux_arr,/*!< in/out: auxiliary array (same size as arr) */
- ulint low, /*!< in: low bound of sort interval, inclusive */
- ulint high); /*!< in: high bound of sort interval, noninclusive */
-#endif /* notdefined */
-
/*********************************************************//**
The following function rounds up a pointer to the nearest aligned address.
@return aligned pointer */
diff --git a/storage/innobase/include/ut0byte.ic b/storage/innobase/include/ut0byte.ic
index 3dd51890cb4..e7908efa41a 100644
--- a/storage/innobase/include/ut0byte.ic
+++ b/storage/innobase/include/ut0byte.ic
@@ -24,260 +24,22 @@ Created 5/30/1994 Heikki Tuuri
*******************************************************************/
/*******************************************************//**
-Creates a 64-bit dulint out of two ulints.
+Creates a 64-bit integer out of two 32-bit integers.
@return created dulint */
UNIV_INLINE
-dulint
-ut_dulint_create(
-/*=============*/
+ib_uint64_t
+ut_ull_create(
+/*==========*/
ulint high, /*!< in: high-order 32 bits */
ulint low) /*!< in: low-order 32 bits */
{
- dulint res;
-
- ut_ad(high <= 0xFFFFFFFF);
- ut_ad(low <= 0xFFFFFFFF);
-
- res.high = high;
- res.low = low;
-
- return(res);
-}
-
-/*******************************************************//**
-Gets the high-order 32 bits of a dulint.
-@return 32 bits in ulint */
-UNIV_INLINE
-ulint
-ut_dulint_get_high(
-/*===============*/
- dulint d) /*!< in: dulint */
-{
- return(d.high);
-}
-
-/*******************************************************//**
-Gets the low-order 32 bits of a dulint.
-@return 32 bits in ulint */
-UNIV_INLINE
-ulint
-ut_dulint_get_low(
-/*==============*/
- dulint d) /*!< in: dulint */
-{
- return(d.low);
-}
-
-/*******************************************************//**
-Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit
-integer type.
-@return value in ib_int64_t type */
-UNIV_INLINE
-ib_int64_t
-ut_conv_dulint_to_longlong(
-/*=======================*/
- dulint d) /*!< in: dulint */
-{
- return((ib_int64_t)d.low
- + (((ib_int64_t)d.high) << 32));
-}
-
-/*******************************************************//**
-Tests if a dulint is zero.
-@return TRUE if zero */
-UNIV_INLINE
-ibool
-ut_dulint_is_zero(
-/*==============*/
- dulint a) /*!< in: dulint */
-{
- if ((a.low == 0) && (a.high == 0)) {
-
- return(TRUE);
- }
-
- return(FALSE);
-}
-
-/*******************************************************//**
-Compares two dulints.
-@return -1 if a < b, 0 if a == b, 1 if a > b */
-UNIV_INLINE
-int
-ut_dulint_cmp(
-/*==========*/
- dulint a, /*!< in: dulint */
- dulint b) /*!< in: dulint */
-{
- if (a.high > b.high) {
- return(1);
- } else if (a.high < b.high) {
- return(-1);
- } else if (a.low > b.low) {
- return(1);
- } else if (a.low < b.low) {
- return(-1);
- } else {
- return(0);
- }
-}
-
-/*******************************************************//**
-Calculates the max of two dulints.
-@return max(a, b) */
-UNIV_INLINE
-dulint
-ut_dulint_get_max(
-/*==============*/
- dulint a, /*!< in: dulint */
- dulint b) /*!< in: dulint */
-{
- if (ut_dulint_cmp(a, b) > 0) {
-
- return(a);
- }
-
- return(b);
-}
-
-/*******************************************************//**
-Calculates the min of two dulints.
-@return min(a, b) */
-UNIV_INLINE
-dulint
-ut_dulint_get_min(
-/*==============*/
- dulint a, /*!< in: dulint */
- dulint b) /*!< in: dulint */
-{
- if (ut_dulint_cmp(a, b) > 0) {
-
- return(b);
- }
-
- return(a);
-}
-
-/*******************************************************//**
-Adds a ulint to a dulint.
-@return sum a + b */
-UNIV_INLINE
-dulint
-ut_dulint_add(
-/*==========*/
- dulint a, /*!< in: dulint */
- ulint b) /*!< in: ulint */
-{
- if (0xFFFFFFFFUL - b >= a.low) {
- a.low += b;
-
- return(a);
- }
-
- a.low = a.low - (0xFFFFFFFFUL - b) - 1;
-
- a.high++;
-
- return(a);
-}
-
-/*******************************************************//**
-Subtracts a ulint from a dulint.
-@return a - b */
-UNIV_INLINE
-dulint
-ut_dulint_subtract(
-/*===============*/
- dulint a, /*!< in: dulint */
- ulint b) /*!< in: ulint, b <= a */
-{
- if (a.low >= b) {
- a.low -= b;
-
- return(a);
- }
-
- b -= a.low + 1;
-
- a.low = 0xFFFFFFFFUL - b;
-
- ut_ad(a.high > 0);
-
- a.high--;
-
- return(a);
-}
-
-/*******************************************************//**
-Subtracts a dulint from another. NOTE that the difference must be positive
-and smaller that 4G.
-@return a - b */
-UNIV_INLINE
-ulint
-ut_dulint_minus(
-/*============*/
- dulint a, /*!< in: dulint; NOTE a must be >= b and at most
- 2 to power 32 - 1 greater */
- dulint b) /*!< in: dulint */
-{
- ulint diff;
-
- if (a.high == b.high) {
- ut_ad(a.low >= b.low);
-
- return(a.low - b.low);
- }
-
- ut_ad(a.high == b.high + 1);
-
- diff = (ulint)(0xFFFFFFFFUL - b.low);
- diff += 1 + a.low;
-
- ut_ad(diff > a.low);
-
- return(diff);
-}
-
-/********************************************************//**
-Rounds a dulint downward to a multiple of a power of 2.
-@return rounded value */
-UNIV_INLINE
-dulint
-ut_dulint_align_down(
-/*=================*/
- dulint n, /*!< in: number to be rounded */
- ulint align_no) /*!< in: align by this number which must be a
- power of 2 */
-{
- ulint low, high;
-
- ut_ad(align_no > 0);
- ut_ad(((align_no - 1) & align_no) == 0);
-
- low = ut_dulint_get_low(n);
- high = ut_dulint_get_high(n);
-
- low = low & ~(align_no - 1);
-
- return(ut_dulint_create(high, low));
-}
-
-/********************************************************//**
-Rounds a dulint upward to a multiple of a power of 2.
-@return rounded value */
-UNIV_INLINE
-dulint
-ut_dulint_align_up(
-/*===============*/
- dulint n, /*!< in: number to be rounded */
- ulint align_no) /*!< in: align by this number which must be a
- power of 2 */
-{
- return(ut_dulint_align_down(ut_dulint_add(n, align_no - 1), align_no));
+ ut_ad(high <= ULINT32_MASK);
+ ut_ad(low <= ULINT32_MASK);
+ return(((ib_uint64_t) high) << 32 | low);
}
/********************************************************//**
-Rounds ib_uint64_t downward to a multiple of a power of 2.
+Rounds a 64-bit integer downward to a multiple of a power of 2.
@return rounded value */
UNIV_INLINE
ib_uint64_t
diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h
index ce5152e942f..946b1117af7 100644
--- a/storage/innobase/include/ut0rnd.h
+++ b/storage/innobase/include/ut0rnd.h
@@ -97,13 +97,13 @@ ut_fold_ulint_pair(
ulint n2) /*!< in: ulint */
__attribute__((const));
/*************************************************************//**
-Folds a dulint.
+Folds a 64-bit integer.
@return folded value */
UNIV_INLINE
ulint
-ut_fold_dulint(
-/*===========*/
- dulint d) /*!< in: dulint */
+ut_fold_ull(
+/*========*/
+ ib_uint64_t d) /*!< in: 64-bit integer */
__attribute__((const));
/*************************************************************//**
Folds a character string ending in the null character.
diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic
index c3dbd86923c..a6ba4ec2ba2 100644
--- a/storage/innobase/include/ut0rnd.ic
+++ b/storage/innobase/include/ut0rnd.ic
@@ -173,16 +173,16 @@ ut_fold_ulint_pair(
}
/*************************************************************//**
-Folds a dulint.
+Folds a 64-bit integer.
@return folded value */
UNIV_INLINE
ulint
-ut_fold_dulint(
-/*===========*/
- dulint d) /*!< in: dulint */
+ut_fold_ull(
+/*========*/
+ ib_uint64_t d) /*!< in: 64-bit integer */
{
- return(ut_fold_ulint_pair(ut_dulint_get_low(d),
- ut_dulint_get_high(d)));
+ return(ut_fold_ulint_pair((ulint) d & ULINT32_MASK,
+ (ulint) (d >> 32)));
}
/*************************************************************//**
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index 0e57a52666e..dcfca1b6315 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -468,7 +468,7 @@ lock_check_trx_id_sanity(
/* A sanity check: the trx_id in rec must be smaller than the global
trx id counter */
- if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) {
+ if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: transaction id associated"
" with record\n",
@@ -481,8 +481,7 @@ lock_check_trx_id_sanity(
" global trx id counter " TRX_ID_FMT "!\n"
"InnoDB: The table is corrupt. You have to do"
" dump + drop + reimport.\n",
- TRX_ID_PREP_PRINTF(trx_id),
- TRX_ID_PREP_PRINTF(trx_sys->max_trx_id));
+ (ullint) trx_id, (ullint) trx_sys->max_trx_id);
is_ok = FALSE;
}
@@ -556,9 +555,9 @@ lock_sec_rec_cons_read_sees(
}
max_trx_id = page_get_max_trx_id(page_align(rec));
- ut_ad(!ut_dulint_is_zero(max_trx_id));
+ ut_ad(max_trx_id);
- return(ut_dulint_cmp(max_trx_id, view->up_limit_id) < 0);
+ return(max_trx_id < view->up_limit_id);
}
/*********************************************************************//**
@@ -1594,8 +1593,7 @@ lock_sec_rec_some_has_impl_off_kernel(
max trx id to the log, and therefore during recovery, this value
for a page may be incorrect. */
- if (!(ut_dulint_cmp(page_get_max_trx_id(page),
- trx_list_get_min_trx_id()) >= 0)
+ if (page_get_max_trx_id(page) < trx_list_get_min_trx_id()
&& !recv_recovery_is_on()) {
return(NULL);
@@ -1820,8 +1818,8 @@ lock_rec_enqueue_waiting(
#ifdef UNIV_DEBUG
if (lock_print_waits) {
- fprintf(stderr, "Lock wait for trx %lu in index ",
- (ulong) ut_dulint_get_low(trx->id));
+ fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " in index ",
+ (ullint) trx->id);
ut_print_name(stderr, trx, FALSE, index->name);
}
#endif /* UNIV_DEBUG */
@@ -2193,8 +2191,8 @@ lock_grant(
#ifdef UNIV_DEBUG
if (lock_print_waits) {
- fprintf(stderr, "Lock wait for trx %lu ends\n",
- (ulong) ut_dulint_get_low(lock->trx->id));
+ fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " ends\n",
+ (ullint) lock->trx->id);
}
#endif /* UNIV_DEBUG */
@@ -3486,8 +3484,7 @@ lock_deadlock_recursive(
}
#endif /* UNIV_DEBUG */
- if (trx_weight_cmp(wait_lock->trx,
- start) >= 0) {
+ if (trx_weight_ge(wait_lock->trx, start)) {
/* Our recursion starting point
transaction is 'smaller', let us
choose 'start' as the victim and roll
@@ -4023,7 +4020,7 @@ lock_release_off_kernel(
ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
if (lock_get_mode(lock) != LOCK_IS
- && !ut_dulint_is_zero(trx->undo_no)) {
+ && trx->undo_no != 0) {
/* The trx may have modified the table. We
block the use of the MySQL query cache for
@@ -4222,8 +4219,7 @@ lock_table_print(
fputs("TABLE LOCK table ", file);
ut_print_name(file, lock->trx, TRUE,
lock->un_member.tab_lock.table->name);
- fprintf(file, " trx id " TRX_ID_FMT,
- TRX_ID_PREP_PRINTF(lock->trx->id));
+ fprintf(file, " trx id " TRX_ID_FMT, (ullint) lock->trx->id);
if (lock_get_mode(lock) == LOCK_S) {
fputs(" lock mode S", file);
@@ -4276,8 +4272,7 @@ lock_rec_print(
(ulong) space, (ulong) page_no,
(ulong) lock_rec_get_n_bits(lock));
dict_index_name_print(file, lock->trx, lock->index);
- fprintf(file, " trx id " TRX_ID_FMT,
- TRX_ID_PREP_PRINTF(lock->trx->id));
+ fprintf(file, " trx id " TRX_ID_FMT, (ullint) lock->trx->id);
if (lock_get_mode(lock) == LOCK_S) {
fputs(" lock mode S", file);
@@ -4412,13 +4407,13 @@ lock_print_info_summary(
"------------\n", file);
fprintf(file, "Trx id counter " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(trx_sys->max_trx_id));
+ (ullint) trx_sys->max_trx_id);
fprintf(file,
"Purge done for trx's n:o < " TRX_ID_FMT
" undo n:o < " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(purge_sys->purge_trx_no),
- TRX_ID_PREP_PRINTF(purge_sys->purge_undo_no));
+ (ullint) purge_sys->purge_trx_no,
+ (ullint) purge_sys->purge_undo_no);
fprintf(file,
"History list length %lu\n",
@@ -4495,10 +4490,8 @@ loop:
"Trx read view will not see trx with"
" id >= " TRX_ID_FMT
", sees < " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(
- trx->read_view->low_limit_id),
- TRX_ID_PREP_PRINTF(
- trx->read_view->up_limit_id));
+ (ullint) trx->read_view->low_limit_id,
+ (ullint) trx->read_view->up_limit_id);
}
if (trx->que_state == TRX_QUE_LOCK_WAIT) {
@@ -4912,12 +4905,12 @@ ibool
lock_validate(void)
/*===============*/
{
- lock_t* lock;
- trx_t* trx;
- dulint limit;
- ulint space;
- ulint page_no;
- ulint i;
+ lock_t* lock;
+ trx_t* trx;
+ ib_uint64_t limit;
+ ulint space;
+ ulint page_no;
+ ulint i;
lock_mutex_enter_kernel();
@@ -4941,20 +4934,21 @@ lock_validate(void)
for (i = 0; i < hash_get_n_cells(lock_sys->rec_hash); i++) {
- limit = ut_dulint_zero;
+ limit = 0;
for (;;) {
lock = HASH_GET_FIRST(lock_sys->rec_hash, i);
while (lock) {
+ ib_uint64_t space_page;
ut_a(trx_in_trx_list(lock->trx));
space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no;
- if (ut_dulint_cmp(
- ut_dulint_create(space, page_no),
- limit) >= 0) {
+ space_page = ut_ull_create(space, page_no);
+
+ if (space_page >= limit) {
break;
}
@@ -4974,7 +4968,7 @@ lock_validate(void)
lock_mutex_enter_kernel();
- limit = ut_dulint_create(space, page_no + 1);
+ limit = ut_ull_create(space, page_no + 1);
}
}
@@ -5348,8 +5342,7 @@ lock_sec_rec_read_check_and_lock(
if the max trx id for the page >= min trx id for the trx list or a
database recovery is running. */
- if (((ut_dulint_cmp(page_get_max_trx_id(block->frame),
- trx_list_get_min_trx_id()) >= 0)
+ if ((page_get_max_trx_id(block->frame) >= trx_list_get_min_trx_id()
|| recv_recovery_is_on())
&& !page_rec_is_supremum(rec)) {
@@ -5572,12 +5565,12 @@ lock_get_type(
Gets the id of the transaction owning a lock.
@return transaction id */
UNIV_INTERN
-ullint
+trx_id_t
lock_get_trx_id(
/*============*/
const lock_t* lock) /*!< in: lock */
{
- return(trx_get_id(lock->trx));
+ return(lock->trx->id);
}
/*******************************************************************//**
@@ -5671,7 +5664,7 @@ lock_get_table(
Gets the id of the table on which the lock is.
@return id of the table */
UNIV_INTERN
-ullint
+table_id_t
lock_get_table_id(
/*==============*/
const lock_t* lock) /*!< in: lock */
@@ -5680,7 +5673,7 @@ lock_get_table_id(
table = lock_get_table(lock);
- return((ullint)ut_conv_dulint_to_longlong(table->id));
+ return(table->id);
}
/*******************************************************************//**
diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c
index 386f9630baa..401cede1d8f 100644
--- a/storage/innobase/log/log0log.c
+++ b/storage/innobase/log/log0log.c
@@ -1166,7 +1166,7 @@ log_group_file_header_flush(
buf = *(group->file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_GROUP_ID, group->id);
- mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
+ mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn);
/* Wipe over possible label of ibbackup --restore */
memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, " ", 4);
@@ -1769,8 +1769,8 @@ log_group_checkpoint(
buf = group->checkpoint_buf;
- mach_write_ull(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
- mach_write_ull(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
+ mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
+ mach_write_to_8(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
log_group_calc_lsn_offset(
@@ -1790,9 +1790,9 @@ log_group_checkpoint(
}
}
- mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
+ mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
#else /* UNIV_LOG_ARCHIVE */
- mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
+ mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
#endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < LOG_MAX_N_GROUPS; i++) {
@@ -1884,7 +1884,7 @@ log_reset_first_header_and_checkpoint(
ib_uint64_t lsn;
mach_write_to_4(hdr_buf + LOG_GROUP_ID, 0);
- mach_write_ull(hdr_buf + LOG_FILE_START_LSN, start);
+ mach_write_to_8(hdr_buf + LOG_FILE_START_LSN, start);
lsn = start + LOG_BLOCK_HDR_SIZE;
@@ -1896,15 +1896,15 @@ log_reset_first_header_and_checkpoint(
+ (sizeof "ibbackup ") - 1));
buf = hdr_buf + LOG_CHECKPOINT_1;
- mach_write_ull(buf + LOG_CHECKPOINT_NO, 0);
- mach_write_ull(buf + LOG_CHECKPOINT_LSN, lsn);
+ mach_write_to_8(buf + LOG_CHECKPOINT_NO, 0);
+ mach_write_to_8(buf + LOG_CHECKPOINT_LSN, lsn);
mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE);
mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024);
- mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
+ mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1);
mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold);
@@ -2272,7 +2272,7 @@ log_group_archive_file_header_write(
buf = *(group->archive_file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_GROUP_ID, group->id);
- mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
+ mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn);
mach_write_to_4(buf + LOG_FILE_NO, file_no);
mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, FALSE);
@@ -2308,7 +2308,7 @@ log_group_archive_completed_header_write(
buf = *(group->archive_file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, TRUE);
- mach_write_ull(buf + LOG_FILE_END_LSN, end_lsn);
+ mach_write_to_8(buf + LOG_FILE_END_LSN, end_lsn);
dest_offset = nth_file * group->file_size + LOG_FILE_ARCH_COMPLETED;
diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c
index f47f47e6a68..f983c4fb974 100644
--- a/storage/innobase/log/log0recv.c
+++ b/storage/innobase/log/log0recv.c
@@ -704,11 +704,11 @@ recv_find_max_checkpoint(
group->state = LOG_GROUP_OK;
- group->lsn = mach_read_ull(
+ group->lsn = mach_read_from_8(
buf + LOG_CHECKPOINT_LSN);
group->lsn_offset = mach_read_from_4(
buf + LOG_CHECKPOINT_OFFSET);
- checkpoint_no = mach_read_ull(
+ checkpoint_no = mach_read_from_8(
buf + LOG_CHECKPOINT_NO);
#ifdef UNIV_DEBUG
@@ -778,14 +778,14 @@ recv_read_cp_info_for_backup(
cp_buf = hdr + LOG_CHECKPOINT_1;
if (recv_check_cp_is_consistent(cp_buf)) {
- max_cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
+ max_cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
max_cp = LOG_CHECKPOINT_1;
}
cp_buf = hdr + LOG_CHECKPOINT_2;
if (recv_check_cp_is_consistent(cp_buf)) {
- if (mach_read_ull(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) {
+ if (mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) {
max_cp = LOG_CHECKPOINT_2;
}
}
@@ -796,7 +796,7 @@ recv_read_cp_info_for_backup(
cp_buf = hdr + max_cp;
- *lsn = mach_read_ull(cp_buf + LOG_CHECKPOINT_LSN);
+ *lsn = mach_read_from_8(cp_buf + LOG_CHECKPOINT_LSN);
*offset = mach_read_from_4(cp_buf + LOG_CHECKPOINT_OFFSET);
/* If the user is running a pre-3.23.50 version of InnoDB, its
@@ -816,9 +816,9 @@ recv_read_cp_info_for_backup(
/* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */
- *cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
+ *cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
- *first_header_lsn = mach_read_ull(hdr + LOG_FILE_START_LSN);
+ *first_header_lsn = mach_read_from_8(hdr + LOG_FILE_START_LSN);
return(TRUE);
}
@@ -1541,7 +1541,7 @@ recv_recover_page_func(
#endif /* !UNIV_HOTBACKUP */
/* Read the newest modification lsn from the page */
- page_lsn = mach_read_ull(page + FIL_PAGE_LSN);
+ page_lsn = mach_read_from_8(page + FIL_PAGE_LSN);
#ifndef UNIV_HOTBACKUP
/* It may be that the page has been modified in the buffer
@@ -1616,14 +1616,14 @@ recv_recover_page_func(
block, &mtr);
end_lsn = recv->start_lsn + recv->len;
- mach_write_ull(FIL_PAGE_LSN + page, end_lsn);
- mach_write_ull(UNIV_PAGE_SIZE
- - FIL_PAGE_END_LSN_OLD_CHKSUM
- + page, end_lsn);
+ mach_write_to_8(FIL_PAGE_LSN + page, end_lsn);
+ mach_write_to_8(UNIV_PAGE_SIZE
+ - FIL_PAGE_END_LSN_OLD_CHKSUM
+ + page, end_lsn);
if (page_zip) {
- mach_write_ull(FIL_PAGE_LSN
- + page_zip->data, end_lsn);
+ mach_write_to_8(FIL_PAGE_LSN
+ + page_zip->data, end_lsn);
}
}
@@ -1995,7 +1995,7 @@ recv_apply_log_recs_for_backup(void)
buf_flush_init_for_writing(
block->frame, buf_block_get_page_zip(block),
- mach_read_ull(block->frame + FIL_PAGE_LSN));
+ mach_read_from_8(block->frame + FIL_PAGE_LSN));
if (zip_size) {
error = fil_io(OS_FILE_WRITE, TRUE,
@@ -2961,9 +2961,9 @@ recv_recovery_from_checkpoint_start_func(
buf = log_sys->checkpoint_buf;
- checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN);
- checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO);
- archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
+ checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
+ checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
+ archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
/* Read the first log file header to print a note if this is
a recovery from a restored InnoDB Hot Backup */
@@ -3613,8 +3613,8 @@ ask_again:
return(TRUE);
}
- start_lsn = mach_read_ull(buf + LOG_FILE_START_LSN);
- file_end_lsn = mach_read_ull(buf + LOG_FILE_END_LSN);
+ start_lsn = mach_read_from_8(buf + LOG_FILE_START_LSN);
+ file_end_lsn = mach_read_from_8(buf + LOG_FILE_END_LSN);
if (!recv_sys->scanned_lsn) {
diff --git a/storage/innobase/mach/mach0data.c b/storage/innobase/mach/mach0data.c
index e030ce9aadf..647d9e57384 100644
--- a/storage/innobase/mach/mach0data.c
+++ b/storage/innobase/mach/mach0data.c
@@ -92,43 +92,3 @@ mach_parse_compressed(
return(ptr + 5);
}
}
-
-/*********************************************************//**
-Reads a dulint in a compressed form if the log record fully contains it.
-@return pointer to end of the stored field, NULL if not complete */
-UNIV_INTERN
-byte*
-mach_dulint_parse_compressed(
-/*=========================*/
- byte* ptr, /*!< in: pointer to buffer from where to read */
- byte* end_ptr,/*!< in: pointer to end of the buffer */
- dulint* val) /*!< out: read value */
-{
- ulint high;
- ulint low;
- ulint size;
-
- ut_ad(ptr && end_ptr && val);
-
- if (end_ptr < ptr + 5) {
-
- return(NULL);
- }
-
- high = mach_read_compressed(ptr);
-
- size = mach_get_compressed_size(high);
-
- ptr += size;
-
- if (end_ptr < ptr + 4) {
-
- return(NULL);
- }
-
- low = mach_read_from_4(ptr);
-
- *val = ut_dulint_create(high, low);
-
- return(ptr + 4);
-}
diff --git a/storage/innobase/mtr/mtr0log.c b/storage/innobase/mtr/mtr0log.c
index 3f3dab36b76..04eeb4391cd 100644
--- a/storage/innobase/mtr/mtr0log.c
+++ b/storage/innobase/mtr/mtr0log.c
@@ -133,7 +133,7 @@ mlog_parse_initial_log_record(
}
/********************************************************//**
-Parses a log record written by mlog_write_ulint or mlog_write_dulint.
+Parses a log record written by mlog_write_ulint or mlog_write_ull.
@return parsed record end, NULL if not a complete record or a corrupt record */
UNIV_INTERN
byte*
@@ -145,9 +145,9 @@ mlog_parse_nbytes(
byte* page, /*!< in: page where to apply the log record, or NULL */
void* page_zip)/*!< in/out: compressed page, or NULL */
{
- ulint offset;
- ulint val;
- dulint dval;
+ ulint offset;
+ ulint val;
+ ib_uint64_t dval;
ut_a(type <= MLOG_8BYTES);
ut_a(!page || !page_zip || fil_page_get_type(page) != FIL_PAGE_INDEX);
@@ -167,7 +167,7 @@ mlog_parse_nbytes(
}
if (type == MLOG_8BYTES) {
- ptr = mach_dulint_parse_compressed(ptr, end_ptr, &dval);
+ ptr = mach_ull_parse_compressed(ptr, end_ptr, &dval);
if (ptr == NULL) {
@@ -290,11 +290,11 @@ Writes 8 bytes to a file page buffered in the buffer pool.
Writes the corresponding log record to the mini-transaction log. */
UNIV_INTERN
void
-mlog_write_dulint(
-/*==============*/
- byte* ptr, /*!< in: pointer where to write */
- dulint val, /*!< in: value to write */
- mtr_t* mtr) /*!< in: mini-transaction handle */
+mlog_write_ull(
+/*===========*/
+ byte* ptr, /*!< in: pointer where to write */
+ ib_uint64_t val, /*!< in: value to write */
+ mtr_t* mtr) /*!< in: mini-transaction handle */
{
byte* log_ptr;
@@ -316,7 +316,7 @@ mlog_write_dulint(
mach_write_to_2(log_ptr, page_offset(ptr));
log_ptr += 2;
- log_ptr += mach_dulint_write_compressed(log_ptr, val);
+ log_ptr += mach_ull_write_compressed(log_ptr, val);
mlog_close(mtr, log_ptr);
}
diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c
index b01462f6b9b..74d04a22b86 100644
--- a/storage/innobase/mtr/mtr0mtr.c
+++ b/storage/innobase/mtr/mtr0mtr.c
@@ -337,9 +337,12 @@ mtr_memo_release(
slot = dyn_array_get_element(memo, offset);
if (object == slot->object && type == slot->type) {
- if (mtr->modifications) {
- mtr_memo_slot_note_modification(mtr, slot);
- }
+
+ /* We cannot release a page that has been written
+ to in the middle of a mini-transaction. */
+
+ ut_ad(!(mtr->modifications
+ && slot->type == MTR_MEMO_PAGE_X_FIX));
mtr_memo_slot_release(mtr, slot);
@@ -375,23 +378,6 @@ mtr_read_ulint(
}
}
-/********************************************************//**
-Reads 8 bytes from a file page buffered in the buffer pool.
-@return value read */
-UNIV_INTERN
-dulint
-mtr_read_dulint(
-/*============*/
- const byte* ptr, /*!< in: pointer from where to read */
- mtr_t* mtr __attribute__((unused)))
- /*!< in: mini-transaction handle */
-{
- ut_ad(mtr->state == MTR_ACTIVE);
- ut_ad(mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_S_FIX)
- || mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_X_FIX));
- return(mach_read_from_8(ptr));
-}
-
#ifdef UNIV_DEBUG
# ifndef UNIV_HOTBACKUP
/**********************************************************//**
diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c
index a7117386608..65c5d65f860 100644
--- a/storage/innobase/os/os0file.c
+++ b/storage/innobase/os/os0file.c
@@ -183,7 +183,7 @@ struct os_aio_slot_struct{
which pending aio operation was
completed */
#ifdef WIN_ASYNC_IO
- os_event_t event; /*!< event object we need in the
+ HANDLE handle; /*!< handle object we need in the
OVERLAPPED struct */
OVERLAPPED control; /*!< Windows control block for the
aio request */
@@ -225,7 +225,7 @@ struct os_aio_array_struct{
aio array outside the ibuf segment */
os_aio_slot_t* slots; /*!< Pointer to the slots in the array */
#ifdef __WIN__
- os_native_event_t* native_events;
+ HANDLE* handles;
/*!< Pointer to an array of OS native
event handles where we copied the
handles from slots, in the same
@@ -304,7 +304,8 @@ UNIV_INTERN ulint os_n_pending_reads = 0;
/***********************************************************************//**
Gets the operating system version. Currently works only on Windows.
-@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */
+@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA,
+OS_WIN7. */
UNIV_INTERN
ulint
os_get_os_version(void)
@@ -322,10 +323,18 @@ os_get_os_version(void)
} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
return(OS_WIN95);
} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- if (os_info.dwMajorVersion <= 4) {
- return(OS_WINNT);
- } else {
- return(OS_WIN2000);
+ switch (os_info.dwMajorVersion) {
+ case 3:
+ case 4:
+ return OS_WINNT;
+ case 5:
+ return (os_info.dwMinorVersion == 0) ? OS_WIN2000
+ : OS_WINXP;
+ case 6:
+ return (os_info.dwMinorVersion == 0) ? OS_WINVISTA
+ : OS_WIN7;
+ default:
+ return OS_WIN7;
}
} else {
ut_error;
@@ -673,10 +682,10 @@ os_io_init_simple(void)
{
ulint i;
- os_file_count_mutex = os_mutex_create(NULL);
+ os_file_count_mutex = os_mutex_create();
for (i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) {
- os_file_seek_mutexes[i] = os_mutex_create(NULL);
+ os_file_seek_mutexes[i] = os_mutex_create();
}
}
@@ -3217,7 +3226,7 @@ os_aio_array_create(
array = ut_malloc(sizeof(os_aio_array_t));
- array->mutex = os_mutex_create(NULL);
+ array->mutex = os_mutex_create();
array->not_full = os_event_create(NULL);
array->is_empty = os_event_create(NULL);
@@ -3229,10 +3238,13 @@ os_aio_array_create(
array->cur_seg = 0;
array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
#ifdef __WIN__
- array->native_events = ut_malloc(n * sizeof(os_native_event_t));
+ array->handles = ut_malloc(n * sizeof(HANDLE));
#endif
#if defined(LINUX_NATIVE_AIO)
+ array->aio_ctx = NULL;
+ array->aio_events = NULL;
+
/* If we are not using native aio interface then skip this
part of initialization. */
if (!srv_use_native_aio) {
@@ -3270,13 +3282,13 @@ skip_native_aio:
slot->pos = i;
slot->reserved = FALSE;
#ifdef WIN_ASYNC_IO
- slot->event = os_event_create(NULL);
+ slot->handle = CreateEvent(NULL,TRUE, FALSE, NULL);
over = &(slot->control);
- over->hEvent = slot->event->handle;
+ over->hEvent = slot->handle;
- *((array->native_events) + i) = over->hEvent;
+ *((array->handles) + i) = over->hEvent;
#elif defined(LINUX_NATIVE_AIO)
@@ -3302,17 +3314,24 @@ os_aio_array_free(
for (i = 0; i < array->n_slots; i++) {
os_aio_slot_t* slot = os_aio_array_get_nth_slot(array, i);
- os_event_free(slot->event);
+ CloseHandle(slot->handle);
}
#endif /* WIN_ASYNC_IO */
#ifdef __WIN__
- ut_free(array->native_events);
+ ut_free(array->handles);
#endif /* __WIN__ */
os_mutex_free(array->mutex);
os_event_free(array->not_full);
os_event_free(array->is_empty);
+#if defined(LINUX_NATIVE_AIO)
+ if (srv_use_native_aio) {
+ ut_free(array->aio_events);
+ ut_free(array->aio_ctx);
+ }
+#endif /* LINUX_NATIVE_AIO */
+
ut_free(array->slots);
ut_free(array);
}
@@ -3453,7 +3472,7 @@ os_aio_array_wake_win_aio_at_shutdown(
for (i = 0; i < array->n_slots; i++) {
- os_event_set((array->slots + i)->event);
+ SetEvent((array->slots + i)->handle);
}
}
#endif
@@ -3692,7 +3711,7 @@ found:
control = &(slot->control);
control->Offset = (DWORD)offset;
control->OffsetHigh = (DWORD)offset_high;
- os_event_reset(slot->event);
+ ResetEvent(slot->handle);
#elif defined(LINUX_NATIVE_AIO)
@@ -3764,7 +3783,7 @@ os_aio_array_free_slot(
#ifdef WIN_ASYNC_IO
- os_event_reset(slot->event);
+ ResetEvent(slot->handle);
#elif defined(LINUX_NATIVE_AIO)
@@ -4198,13 +4217,20 @@ os_aio_windows_handle(
n = array->n_slots / array->n_segments;
if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
+ WaitForSingleObject(
+ os_aio_array_get_nth_slot(array, pos)->handle,
+ INFINITE);
i = pos;
} else {
srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
- i = os_event_wait_multiple(n,
- (array->native_events)
- + segment * n);
+ i = WaitForMultipleObjects((DWORD) n,
+ array->handles + segment * n,
+ FALSE,
+ INFINITE);
+ }
+
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+ os_thread_exit(NULL);
}
os_mutex_enter(array->mutex);
diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c
index 60467242e14..3c70e93aae0 100644
--- a/storage/innobase/os/os0sync.c
+++ b/storage/innobase/os/os0sync.c
@@ -35,6 +35,7 @@ Created 9/6/1995 Heikki Tuuri
#include "ut0mem.h"
#include "srv0start.h"
+#include "srv0srv.h"
/* Type definition for an operating system mutex struct */
struct os_mutex_struct{
@@ -76,6 +77,155 @@ event embedded inside a mutex, on free, this generates a recursive call.
This version of the free event function doesn't acquire the global lock */
static void os_event_free_internal(os_event_t event);
+/* On Windows (Vista and later), load function pointers for condition
+variable handling. Those functions are not available in prior versions,
+so we have to use them via runtime loading, as long as we support XP. */
+static void os_cond_module_init(void);
+
+#ifdef __WIN__
+/* Prototypes and function pointers for condition variable functions */
+typedef VOID (WINAPI* InitializeConditionVariableProc)
+ (PCONDITION_VARIABLE ConditionVariable);
+static InitializeConditionVariableProc initialize_condition_variable;
+
+typedef BOOL (WINAPI* SleepConditionVariableCSProc)
+ (PCONDITION_VARIABLE ConditionVariable,
+ PCRITICAL_SECTION CriticalSection,
+ DWORD dwMilliseconds);
+static SleepConditionVariableCSProc sleep_condition_variable;
+
+typedef VOID (WINAPI* WakeAllConditionVariableProc)
+ (PCONDITION_VARIABLE ConditionVariable);
+static WakeAllConditionVariableProc wake_all_condition_variable;
+
+typedef VOID (WINAPI* WakeConditionVariableProc)
+ (PCONDITION_VARIABLE ConditionVariable);
+static WakeConditionVariableProc wake_condition_variable;
+#endif
+
+/*********************************************************//**
+Initialitze condition variable */
+UNIV_INLINE
+void
+os_cond_init(
+/*=========*/
+ os_cond_t* cond) /*!< in: condition variable. */
+{
+ ut_a(cond);
+
+#ifdef __WIN__
+ ut_a(initialize_condition_variable != NULL);
+ initialize_condition_variable(cond);
+#else
+ ut_a(pthread_cond_init(cond, NULL) == 0);
+#endif
+}
+
+/*********************************************************//**
+Wait on condition variable */
+UNIV_INLINE
+void
+os_cond_wait(
+/*=========*/
+ os_cond_t* cond, /*!< in: condition variable. */
+ os_fast_mutex_t* mutex) /*!< in: fast mutex */
+{
+ ut_a(cond);
+ ut_a(mutex);
+
+#ifdef __WIN__
+ ut_a(sleep_condition_variable != NULL);
+ ut_a(sleep_condition_variable(cond, mutex, INFINITE));
+#else
+ ut_a(pthread_cond_wait(cond, mutex) == 0);
+#endif
+}
+
+/*********************************************************//**
+Wakes all threads waiting for condition variable */
+UNIV_INLINE
+void
+os_cond_broadcast(
+/*==============*/
+ os_cond_t* cond) /*!< in: condition variable. */
+{
+ ut_a(cond);
+
+#ifdef __WIN__
+ ut_a(wake_all_condition_variable != NULL);
+ wake_all_condition_variable(cond);
+#else
+ ut_a(pthread_cond_broadcast(cond) == 0);
+#endif
+}
+
+/*********************************************************//**
+Wakes one thread waiting for condition variable */
+UNIV_INLINE
+void
+os_cond_signal(
+/*==========*/
+ os_cond_t* cond) /*!< in: condition variable. */
+{
+ ut_a(cond);
+
+#ifdef __WIN__
+ ut_a(wake_condition_variable != NULL);
+ wake_condition_variable(cond);
+#else
+ ut_a(pthread_cond_signal(cond) == 0);
+#endif
+}
+
+/*********************************************************//**
+Destroys condition variable */
+UNIV_INLINE
+void
+os_cond_destroy(
+/*============*/
+ os_cond_t* cond) /*!< in: condition variable. */
+{
+#ifdef __WIN__
+ /* Do nothing */
+#else
+ ut_a(pthread_cond_destroy(cond) == 0);
+#endif
+}
+
+/*********************************************************//**
+On Windows (Vista and later), load function pointers for condition variable
+handling. Those functions are not available in prior versions, so we have to
+use them via runtime loading, as long as we support XP. */
+static
+void
+os_cond_module_init(void)
+/*=====================*/
+{
+#ifdef __WIN__
+ HMODULE h_dll;
+
+ if (!srv_use_native_conditions)
+ return;
+
+ h_dll = GetModuleHandle("kernel32");
+
+ initialize_condition_variable = (InitializeConditionVariableProc)
+ GetProcAddress(h_dll, "InitializeConditionVariable");
+ sleep_condition_variable = (SleepConditionVariableCSProc)
+ GetProcAddress(h_dll, "SleepConditionVariableCS");
+ wake_all_condition_variable = (WakeAllConditionVariableProc)
+ GetProcAddress(h_dll, "WakeAllConditionVariable");
+ wake_condition_variable = (WakeConditionVariableProc)
+ GetProcAddress(h_dll, "WakeConditionVariable");
+
+ /* When using native condition variables, check function pointers */
+ ut_a(initialize_condition_variable);
+ ut_a(sleep_condition_variable);
+ ut_a(wake_all_condition_variable);
+ ut_a(wake_condition_variable);
+#endif
+}
+
/*********************************************************//**
Initializes global event and OS 'slow' mutex lists. */
UNIV_INTERN
@@ -89,7 +239,10 @@ os_sync_init(void)
os_sync_mutex = NULL;
os_sync_mutex_inited = FALSE;
- os_sync_mutex = os_mutex_create(NULL);
+ /* Now for Windows only */
+ os_cond_module_init();
+
+ os_sync_mutex = os_mutex_create();
os_sync_mutex_inited = TRUE;
}
@@ -143,42 +296,45 @@ os_event_create(
const char* name) /*!< in: the name of the event, if NULL
the event is created without a name */
{
-#ifdef __WIN__
- os_event_t event;
-
- event = ut_malloc(sizeof(struct os_event_struct));
-
- event->handle = CreateEvent(NULL, /* No security attributes */
- TRUE, /* Manual reset */
- FALSE, /* Initial state nonsignaled */
- (LPCTSTR) name);
- if (!event->handle) {
- fprintf(stderr,
- "InnoDB: Could not create a Windows event semaphore;"
- " Windows error %lu\n",
- (ulong) GetLastError());
- }
-#else /* Unix */
os_event_t event;
- UT_NOT_USED(name);
+#ifdef __WIN__
+ if(!srv_use_native_conditions) {
+
+ event = ut_malloc(sizeof(struct os_event_struct));
+
+ event->handle = CreateEvent(NULL,
+ TRUE,
+ FALSE,
+ (LPCTSTR) name);
+ if (!event->handle) {
+ fprintf(stderr,
+ "InnoDB: Could not create a Windows event"
+ " semaphore; Windows error %lu\n",
+ (ulong) GetLastError());
+ }
+ } else /* Windows with condition variables */
+#endif
- event = ut_malloc(sizeof(struct os_event_struct));
+ {
+ UT_NOT_USED(name);
- os_fast_mutex_init(&(event->os_mutex));
+ event = ut_malloc(sizeof(struct os_event_struct));
- ut_a(0 == pthread_cond_init(&(event->cond_var), NULL));
+ os_fast_mutex_init(&(event->os_mutex));
- event->is_set = FALSE;
+ os_cond_init(&(event->cond_var));
- /* We return this value in os_event_reset(), which can then be
- be used to pass to the os_event_wait_low(). The value of zero
- is reserved in os_event_wait_low() for the case when the
- caller does not want to pass any signal_count value. To
- distinguish between the two cases we initialize signal_count
- to 1 here. */
- event->signal_count = 1;
-#endif /* __WIN__ */
+ event->is_set = FALSE;
+
+ /* We return this value in os_event_reset(), which can then be
+ be used to pass to the os_event_wait_low(). The value of zero
+ is reserved in os_event_wait_low() for the case when the
+ caller does not want to pass any signal_count value. To
+ distinguish between the two cases we initialize signal_count
+ to 1 here. */
+ event->signal_count = 1;
+ }
/* The os_sync_mutex can be NULL because during startup an event
can be created [ because it's embedded in the mutex/rwlock ] before
@@ -208,10 +364,15 @@ os_event_set(
/*=========*/
os_event_t event) /*!< in: event to set */
{
-#ifdef __WIN__
ut_a(event);
- ut_a(SetEvent(event->handle));
-#else
+
+#ifdef __WIN__
+ if (!srv_use_native_conditions) {
+ ut_a(SetEvent(event->handle));
+ return;
+ }
+#endif
+
ut_a(event);
os_fast_mutex_lock(&(event->os_mutex));
@@ -221,11 +382,10 @@ os_event_set(
} else {
event->is_set = TRUE;
event->signal_count += 1;
- ut_a(0 == pthread_cond_broadcast(&(event->cond_var)));
+ os_cond_broadcast(&(event->cond_var));
}
os_fast_mutex_unlock(&(event->os_mutex));
-#endif
}
/**********************************************************//**
@@ -244,12 +404,14 @@ os_event_reset(
{
ib_int64_t ret = 0;
-#ifdef __WIN__
ut_a(event);
- ut_a(ResetEvent(event->handle));
-#else
- ut_a(event);
+#ifdef __WIN__
+ if(!srv_use_native_conditions) {
+ ut_a(ResetEvent(event->handle));
+ return(0);
+ }
+#endif
os_fast_mutex_lock(&(event->os_mutex));
@@ -261,7 +423,6 @@ os_event_reset(
ret = event->signal_count;
os_fast_mutex_unlock(&(event->os_mutex));
-#endif
return(ret);
}
@@ -274,19 +435,21 @@ os_event_free_internal(
os_event_t event) /*!< in: event to free */
{
#ifdef __WIN__
- ut_a(event);
+ if(!srv_use_native_conditions) {
+ ut_a(event);
+ ut_a(CloseHandle(event->handle));
+ } else
+#endif
+ {
+ ut_a(event);
- ut_a(CloseHandle(event->handle));
-#else
- ut_a(event);
+ /* This is to avoid freeing the mutex twice */
+ os_fast_mutex_free(&(event->os_mutex));
- /* This is to avoid freeing the mutex twice */
- os_fast_mutex_free(&(event->os_mutex));
+ os_cond_destroy(&(event->cond_var));
+ }
- ut_a(0 == pthread_cond_destroy(&(event->cond_var)));
-#endif
/* Remove from the list of events */
-
UT_LIST_REMOVE(os_event_list, os_event_list, event);
os_event_count--;
@@ -303,18 +466,19 @@ os_event_free(
os_event_t event) /*!< in: event to free */
{
-#ifdef __WIN__
ut_a(event);
+#ifdef __WIN__
+ if(!srv_use_native_conditions){
+ ut_a(CloseHandle(event->handle));
+ } else /*Windows with condition variables */
+#endif
+ {
+ os_fast_mutex_free(&(event->os_mutex));
- ut_a(CloseHandle(event->handle));
-#else
- ut_a(event);
+ os_cond_destroy(&(event->cond_var));
+ }
- os_fast_mutex_free(&(event->os_mutex));
- ut_a(0 == pthread_cond_destroy(&(event->cond_var)));
-#endif
/* Remove from the list of events */
-
os_mutex_enter(os_sync_mutex);
UT_LIST_REMOVE(os_event_list, os_event_list, event);
@@ -355,23 +519,27 @@ os_event_wait_low(
returned by previous call of
os_event_reset(). */
{
+ ib_int64_t old_signal_count;
+
#ifdef __WIN__
- DWORD err;
+ if(!srv_use_native_conditions) {
+ DWORD err;
- ut_a(event);
+ ut_a(event);
- UT_NOT_USED(reset_sig_count);
+ UT_NOT_USED(reset_sig_count);
- /* Specify an infinite time limit for waiting */
- err = WaitForSingleObject(event->handle, INFINITE);
+ /* Specify an infinite wait */
+ err = WaitForSingleObject(event->handle, INFINITE);
- ut_a(err == WAIT_OBJECT_0);
+ ut_a(err == WAIT_OBJECT_0);
- if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
- os_thread_exit(NULL);
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+ os_thread_exit(NULL);
+ }
+ return;
}
-#else
- ib_int64_t old_signal_count;
+#endif
os_fast_mutex_lock(&(event->os_mutex));
@@ -396,93 +564,13 @@ os_event_wait_low(
return;
}
- pthread_cond_wait(&(event->cond_var), &(event->os_mutex));
+ os_cond_wait(&(event->cond_var), &(event->os_mutex));
/* Solaris manual said that spurious wakeups may occur: we
have to check if the event really has been signaled after
we came here to wait */
}
-#endif
-}
-
-/**********************************************************//**
-Waits for an event object until it is in the signaled state or
-a timeout is exceeded. In Unix the timeout is always infinite.
-@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
-UNIV_INTERN
-ulint
-os_event_wait_time(
-/*===============*/
- os_event_t event, /*!< in: event to wait */
- ulint time) /*!< in: timeout in microseconds, or
- OS_SYNC_INFINITE_TIME */
-{
-#ifdef __WIN__
- DWORD err;
-
- ut_a(event);
-
- if (time != OS_SYNC_INFINITE_TIME) {
- err = WaitForSingleObject(event->handle, (DWORD) time / 1000);
- } else {
- err = WaitForSingleObject(event->handle, INFINITE);
- }
-
- if (err == WAIT_OBJECT_0) {
-
- return(0);
- } else if (err == WAIT_TIMEOUT) {
-
- return(OS_SYNC_TIME_EXCEEDED);
- } else {
- ut_error;
- return(1000000); /* dummy value to eliminate compiler warn. */
- }
-#else
- UT_NOT_USED(time);
-
- /* In Posix this is just an ordinary, infinite wait */
-
- os_event_wait(event);
-
- return(0);
-#endif
-}
-
-#ifdef __WIN__
-/**********************************************************//**
-Waits for any event in an OS native event array. Returns if even a single
-one is signaled or becomes signaled.
-@return index of the event which was signaled */
-UNIV_INTERN
-ulint
-os_event_wait_multiple(
-/*===================*/
- ulint n, /*!< in: number of events in the
- array */
- os_native_event_t* native_event_array)
- /*!< in: pointer to an array of event
- handles */
-{
- DWORD index;
-
- ut_a(native_event_array);
- ut_a(n > 0);
-
- index = WaitForMultipleObjects((DWORD) n, native_event_array,
- FALSE, /* Wait for any 1 event */
- INFINITE); /* Infinite wait time
- limit */
- ut_a(index >= WAIT_OBJECT_0); /* NOTE: Pointless comparison */
- ut_a(index < WAIT_OBJECT_0 + n);
-
- if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
- os_thread_exit(NULL);
- }
-
- return(index - WAIT_OBJECT_0);
}
-#endif
/*********************************************************//**
Creates an operating system mutex semaphore. Because these are slow, the
@@ -490,29 +578,15 @@ mutex semaphore of InnoDB itself (mutex_t) should be used where possible.
@return the mutex handle */
UNIV_INTERN
os_mutex_t
-os_mutex_create(
-/*============*/
- const char* name) /*!< in: the name of the mutex, if NULL
- the mutex is created without a name */
+os_mutex_create(void)
+/*=================*/
{
-#ifdef __WIN__
- HANDLE mutex;
- os_mutex_t mutex_str;
-
- mutex = CreateMutex(NULL, /* No security attributes */
- FALSE, /* Initial state: no owner */
- (LPCTSTR) name);
- ut_a(mutex);
-#else
os_fast_mutex_t* mutex;
os_mutex_t mutex_str;
- UT_NOT_USED(name);
-
mutex = ut_malloc(sizeof(os_fast_mutex_t));
os_fast_mutex_init(mutex);
-#endif
mutex_str = ut_malloc(sizeof(os_mutex_str_t));
mutex_str->handle = mutex;
@@ -543,25 +617,11 @@ os_mutex_enter(
/*===========*/
os_mutex_t mutex) /*!< in: mutex to acquire */
{
-#ifdef __WIN__
- DWORD err;
-
- ut_a(mutex);
-
- /* Specify infinite time limit for waiting */
- err = WaitForSingleObject(mutex->handle, INFINITE);
-
- ut_a(err == WAIT_OBJECT_0);
-
- (mutex->count)++;
- ut_a(mutex->count == 1);
-#else
os_fast_mutex_lock(mutex->handle);
(mutex->count)++;
ut_a(mutex->count == 1);
-#endif
}
/**********************************************************//**
@@ -577,11 +637,7 @@ os_mutex_exit(
ut_a(mutex->count == 1);
(mutex->count)--;
-#ifdef __WIN__
- ut_a(ReleaseMutex(mutex->handle));
-#else
os_fast_mutex_unlock(mutex->handle);
-#endif
}
/**********************************************************//**
@@ -610,15 +666,9 @@ os_mutex_free(
os_mutex_exit(os_sync_mutex);
}
-#ifdef __WIN__
- ut_a(CloseHandle(mutex->handle));
-
- ut_free(mutex);
-#else
os_fast_mutex_free(mutex->handle);
ut_free(mutex->handle);
ut_free(mutex);
-#endif
}
/*********************************************************//**
diff --git a/storage/innobase/os/os0thread.c b/storage/innobase/os/os0thread.c
index 632199b56bc..adc876be5d5 100644
--- a/storage/innobase/os/os0thread.c
+++ b/storage/innobase/os/os0thread.c
@@ -242,7 +242,7 @@ os_thread_yield(void)
/*=================*/
{
#if defined(__WIN__)
- Sleep(0);
+ SwitchToThread();
#elif (defined(HAVE_SCHED_YIELD) && defined(HAVE_SCHED_H))
sched_yield();
#elif defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c
index 10008f9ac25..2e785412ac9 100644
--- a/storage/innobase/page/page0page.c
+++ b/storage/innobase/page/page0page.c
@@ -235,8 +235,8 @@ page_set_max_trx_id(
8, mtr);
#ifndef UNIV_HOTBACKUP
} else if (mtr) {
- mlog_write_dulint(page + (PAGE_HEADER + PAGE_MAX_TRX_ID),
- trx_id, mtr);
+ mlog_write_ull(page + (PAGE_HEADER + PAGE_MAX_TRX_ID),
+ trx_id, mtr);
#endif /* !UNIV_HOTBACKUP */
} else {
mach_write_to_8(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), trx_id);
@@ -457,7 +457,7 @@ page_create_low(
page_header_set_field(page, NULL, PAGE_DIRECTION, PAGE_NO_DIRECTION);
page_header_set_field(page, NULL, PAGE_N_DIRECTION, 0);
page_header_set_field(page, NULL, PAGE_N_RECS, 0);
- page_set_max_trx_id(block, NULL, ut_dulint_zero, NULL);
+ page_set_max_trx_id(block, NULL, 0, NULL);
memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START
- page_offset(heap_top));
diff --git a/storage/innobase/page/page0zip.c b/storage/innobase/page/page0zip.c
index 14ec3e7a94f..98640a8e6fb 100644
--- a/storage/innobase/page/page0zip.c
+++ b/storage/innobase/page/page0zip.c
@@ -1464,6 +1464,7 @@ page_zip_fields_free(
dict_table_t* table = index->table;
mem_heap_free(index->heap);
mutex_free(&(table->autoinc_mutex));
+ ut_free(table->name);
mem_heap_free(table->heap);
}
}
@@ -4467,7 +4468,7 @@ page_zip_reorganize(
/* Copy max trx id to recreated page */
trx_id_t max_trx_id = page_get_max_trx_id(temp_page);
page_set_max_trx_id(block, NULL, max_trx_id, NULL);
- ut_ad(!ut_dulint_is_zero(max_trx_id));
+ ut_ad(max_trx_id != 0);
}
/* Restore logging. */
@@ -4527,7 +4528,7 @@ page_zip_copy_recs(
/* The PAGE_MAX_TRX_ID must be set on leaf pages of secondary
indexes. It does not matter on other pages. */
ut_a(dict_index_is_clust(index) || !page_is_leaf(src)
- || !ut_dulint_is_zero(page_get_max_trx_id(src)));
+ || page_get_max_trx_id(src));
UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE);
UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip));
diff --git a/storage/innobase/pars/pars0pars.c b/storage/innobase/pars/pars0pars.c
index 613e7962f0e..ef107f2896f 100644
--- a/storage/innobase/pars/pars0pars.c
+++ b/storage/innobase/pars/pars0pars.c
@@ -2031,29 +2031,6 @@ pars_info_add_int4_literal(
Equivalent to:
char buf[8];
-mach_write_ull(buf, val);
-pars_info_add_literal(info, name, buf, 8, DATA_INT, 0);
-
-except that the buffer is dynamically allocated from the info struct's
-heap. */
-UNIV_INTERN
-void
-pars_info_add_uint64_literal(
-/*=========================*/
- pars_info_t* info, /*!< in: info struct */
- const char* name, /*!< in: name */
- ib_uint64_t val) /*!< in: value */
-{
- byte* buf = mem_heap_alloc(info->heap, 8);
-
- mach_write_ull(buf, val);
- pars_info_add_literal(info, name, buf, 8, DATA_INT, 0);
-}
-
-/****************************************************************//**
-Equivalent to:
-
-char buf[8];
mach_write_to_8(buf, val);
pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
@@ -2061,11 +2038,11 @@ except that the buffer is dynamically allocated from the info struct's
heap. */
UNIV_INTERN
void
-pars_info_add_dulint_literal(
-/*=========================*/
+pars_info_add_ull_literal(
+/*======================*/
pars_info_t* info, /*!< in: info struct */
const char* name, /*!< in: name */
- dulint val) /*!< in: value */
+ ib_uint64_t val) /*!< in: value */
{
byte* buf = mem_heap_alloc(info->heap, 8);
diff --git a/storage/innobase/read/read0read.c b/storage/innobase/read/read0read.c
index 85adae4ddff..9975b8c2c57 100644
--- a/storage/innobase/read/read0read.c
+++ b/storage/innobase/read/read0read.c
@@ -168,8 +168,7 @@ read_view_t*
read_view_oldest_copy_or_open_new(
/*==============================*/
trx_id_t cr_trx_id, /*!< in: trx_id of creating
- transaction, or ut_dulint_zero
- used in purge */
+ transaction, or 0 used in purge */
mem_heap_t* heap) /*!< in: memory heap from which
allocated */
{
@@ -191,7 +190,7 @@ read_view_oldest_copy_or_open_new(
n = old_view->n_trx_ids;
- if (!ut_dulint_is_zero(old_view->creator_trx_id)) {
+ if (old_view->creator_trx_id) {
n++;
} else {
needs_insert = FALSE;
@@ -206,9 +205,8 @@ read_view_oldest_copy_or_open_new(
while (i < n) {
if (needs_insert
&& (i >= old_view->n_trx_ids
- || ut_dulint_cmp(old_view->creator_trx_id,
- read_view_get_nth_trx_id(old_view, i))
- > 0)) {
+ || old_view->creator_trx_id
+ > read_view_get_nth_trx_id(old_view, i))) {
read_view_set_nth_trx_id(view_copy, i,
old_view->creator_trx_id);
@@ -252,8 +250,7 @@ read_view_t*
read_view_open_now(
/*===============*/
trx_id_t cr_trx_id, /*!< in: trx_id of creating
- transaction, or ut_dulint_zero
- used in purge */
+ transaction, or 0 used in purge */
mem_heap_t* heap) /*!< in: memory heap from which
allocated */
{
@@ -267,7 +264,7 @@ read_view_open_now(
view->creator_trx_id = cr_trx_id;
view->type = VIEW_NORMAL;
- view->undo_no = ut_dulint_zero;
+ view->undo_no = 0;
/* No future transactions should be visible in the view */
@@ -280,7 +277,7 @@ read_view_open_now(
/* No active transaction should be visible, except cr_trx */
while (trx) {
- if (ut_dulint_cmp(trx->id, cr_trx_id) != 0
+ if (trx->id != cr_trx_id
&& (trx->conc_state == TRX_ACTIVE
|| trx->conc_state == TRX_PREPARED)) {
@@ -292,9 +289,9 @@ read_view_open_now(
trx_sys->max_trx_id can still be active, if it is
in the middle of its commit! Note that when a
transaction starts, we initialize trx->no to
- ut_dulint_max. */
+ IB_ULONGLONG_MAX. */
- if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) {
+ if (view->low_limit_no > trx->no) {
view->low_limit_no = trx->no;
}
@@ -367,22 +364,20 @@ read_view_print(
if (view->type == VIEW_HIGH_GRANULARITY) {
fprintf(stderr,
- "High-granularity read view undo_n:o %lu %lu\n",
- (ulong) ut_dulint_get_high(view->undo_no),
- (ulong) ut_dulint_get_low(view->undo_no));
+ "High-granularity read view undo_n:o %llu\n",
+ (ullint) view->undo_no);
} else {
fprintf(stderr, "Normal read view\n");
}
- fprintf(stderr, "Read view low limit trx n:o %lu %lu\n",
- (ulong) ut_dulint_get_high(view->low_limit_no),
- (ulong) ut_dulint_get_low(view->low_limit_no));
+ fprintf(stderr, "Read view low limit trx n:o " TRX_ID_FMT "\n",
+ (ullint) view->low_limit_no);
fprintf(stderr, "Read view up limit trx id " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(view->up_limit_id));
+ (ullint) view->up_limit_id);
fprintf(stderr, "Read view low limit trx id " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(view->low_limit_id));
+ (ullint) view->low_limit_id);
fprintf(stderr, "Read view individually stored trx ids:\n");
@@ -390,8 +385,7 @@ read_view_print(
for (i = 0; i < n_ids; i++) {
fprintf(stderr, "Read view trx id " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(
- read_view_get_nth_trx_id(view, i)));
+ (ullint) read_view_get_nth_trx_id(view, i));
}
}
@@ -460,9 +454,9 @@ read_cursor_view_create_for_mysql(
trx_sys->max_trx_id can still be active, if it is
in the middle of its commit! Note that when a
transaction starts, we initialize trx->no to
- ut_dulint_max. */
+ IB_ULONGLONG_MAX. */
- if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) {
+ if (view->low_limit_no > trx->no) {
view->low_limit_no = trx->no;
}
diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c
index c882a065cd1..8fd8c4f8532 100644
--- a/storage/innobase/row/row0ins.c
+++ b/storage/innobase/row/row0ins.c
@@ -51,6 +51,15 @@ Created 4/20/1996 Heikki Tuuri
#define ROW_INS_PREV 1
#define ROW_INS_NEXT 2
+/*************************************************************************
+IMPORTANT NOTE: Any operation that generates redo MUST check that there
+is enough space in the redo log before for that operation. This is
+done by calling log_free_check(). The reason for checking the
+availability of the redo log space before the start of the operation is
+that we MUST not hold any synchonization objects when performing the
+check.
+If you make a change in this module make sure that no codepath is
+introduced where a call to log_free_check() is bypassed. */
/*********************************************************************//**
Creates an insert node struct.
@@ -78,7 +87,7 @@ ins_node_create(
node->select = NULL;
- node->trx_id = ut_dulint_zero;
+ node->trx_id = 0;
node->entry_sys_heap = mem_heap_create(128);
@@ -198,7 +207,7 @@ ins_node_set_new_row(
/* As we allocated a new trx id buf, the trx id should be written
there again: */
- node->trx_id = ut_dulint_zero;
+ node->trx_id = 0;
}
/*******************************************************************//**
@@ -506,8 +515,7 @@ row_ins_cascade_calc_update_vec(
if (!dfield_is_null(&ufield->new_val)
&& dtype_get_at_most_n_mbchars(
- col->prtype,
- col->mbminlen, col->mbmaxlen,
+ col->prtype, col->mbminmaxlen,
col->len,
ufield_len,
dfield_get_data(&ufield->new_val))
@@ -530,49 +538,37 @@ row_ins_cascade_calc_update_vec(
if (min_size > ufield_len) {
- char* pad_start;
- const char* pad_end;
- char* padded_data
- = mem_heap_alloc(
- heap, min_size);
- pad_start = padded_data + ufield_len;
- pad_end = padded_data + min_size;
+ byte* pad;
+ ulint pad_len;
+ byte* padded_data;
+ ulint mbminlen;
+
+ padded_data = mem_heap_alloc(
+ heap, min_size);
+
+ pad = padded_data + ufield_len;
+ pad_len = min_size - ufield_len;
memcpy(padded_data,
dfield_get_data(&ufield
->new_val),
- dfield_get_len(&ufield
- ->new_val));
+ ufield_len);
- switch (UNIV_EXPECT(col->mbminlen,1)) {
- default:
- ut_error;
- return(ULINT_UNDEFINED);
- case 1:
- if (UNIV_UNLIKELY
- (dtype_get_charset_coll(
- col->prtype)
- == DATA_MYSQL_BINARY_CHARSET_COLL)) {
- /* Do not pad BINARY
- columns. */
- return(ULINT_UNDEFINED);
- }
+ mbminlen = dict_col_get_mbminlen(col);
+
+ ut_ad(!(ufield_len % mbminlen));
+ ut_ad(!(min_size % mbminlen));
- /* space=0x20 */
- memset(pad_start, 0x20,
- pad_end - pad_start);
- break;
- case 2:
- /* space=0x0020 */
- ut_a(!(ufield_len % 2));
- ut_a(!(min_size % 2));
- do {
- *pad_start++ = 0x00;
- *pad_start++ = 0x20;
- } while (pad_start < pad_end);
- break;
+ if (mbminlen == 1
+ && dtype_get_charset_coll(
+ col->prtype)
+ == DATA_MYSQL_BINARY_CHARSET_COLL) {
+ /* Do not pad BINARY columns */
+ return(ULINT_UNDEFINED);
}
+ row_mysql_pad_col(mbminlen,
+ pad, pad_len);
dfield_set_data(&ufield->new_val,
padded_data, min_size);
}
@@ -2223,7 +2219,7 @@ row_ins_index_entry_set_vals(
= dict_field_get_col(ind_field);
len = dtype_get_at_most_n_mbchars(
- col->prtype, col->mbminlen, col->mbmaxlen,
+ col->prtype, col->mbminmaxlen,
ind_field->prefix_len,
len, dfield_get_data(row_field));
@@ -2270,7 +2266,7 @@ row_ins_alloc_row_id_step(
/*======================*/
ins_node_t* node) /*!< in: row insert node */
{
- dulint row_id;
+ row_id_t row_id;
ut_ad(node->state == INS_NODE_ALLOC_ROW_ID);
@@ -2457,7 +2453,7 @@ row_ins_step(
/* It may be that the current session has not yet started
its transaction, or it has been committed: */
- if (UT_DULINT_EQ(trx->id, node->trx_id)) {
+ if (trx->id == node->trx_id) {
/* No need to do IX-locking */
goto same_trx;
diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c
index eac2f9fb377..38ec4bff08f 100644
--- a/storage/innobase/row/row0merge.c
+++ b/storage/innobase/row/row0merge.c
@@ -338,7 +338,7 @@ row_merge_buf_add(
if (ifield->prefix_len) {
len = dtype_get_at_most_n_mbchars(
col->prtype,
- col->mbminlen, col->mbmaxlen,
+ col->mbminmaxlen,
ifield->prefix_len,
len, dfield_get_data(field));
dfield_set_len(field, len);
@@ -1779,6 +1779,11 @@ row_merge_copy_blobs(
(below). */
data = btr_rec_copy_externally_stored_field(
mrec, offsets, zip_size, i, &len, heap);
+ /* Because we have locked the table, any records
+ written by incomplete transactions must have been
+ rolled back already. There must not be any incomplete
+ BLOB columns. */
+ ut_a(data);
dfield_set_data(field, data, len);
}
@@ -2023,7 +2028,7 @@ row_merge_drop_index(
ut_ad(index && table && trx);
- pars_info_add_dulint_literal(info, "indexid", index->id);
+ pars_info_add_ull_literal(info, "indexid", index->id);
trx_start_if_not_started(trx);
trx->op_info = "dropping index";
@@ -2093,7 +2098,7 @@ row_merge_drop_temp_indexes(void)
const rec_t* rec;
const byte* field;
ulint len;
- dulint table_id;
+ table_id_t table_id;
dict_table_t* table;
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
@@ -2322,7 +2327,7 @@ row_merge_rename_indexes(
trx->op_info = "renaming indexes";
- pars_info_add_dulint_literal(info, "tableid", table->id);
+ pars_info_add_ull_literal(info, "tableid", table->id);
err = que_eval_sql(info, rename_indexes, FALSE, trx);
@@ -2359,7 +2364,7 @@ row_merge_rename_tables(
{
ulint err = DB_ERROR;
pars_info_t* info;
- const char* old_name= old_table->name;
+ char old_name[MAX_TABLE_NAME_LEN + 1];
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
ut_ad(old_table != new_table);
@@ -2367,6 +2372,17 @@ row_merge_rename_tables(
ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
+ /* store the old/current name to an automatic variable */
+ if (strlen(old_table->name) + 1 <= sizeof(old_name)) {
+ memcpy(old_name, old_table->name, strlen(old_table->name) + 1);
+ } else {
+ ut_print_timestamp(stderr);
+ fprintf(stderr, "InnoDB: too long table name: '%s', "
+ "max length is %d\n", old_table->name,
+ MAX_TABLE_NAME_LEN);
+ ut_error;
+ }
+
trx->op_info = "renaming tables";
/* We use the private SQL parser of Innobase to generate the query
@@ -2499,8 +2515,7 @@ row_merge_create_index(
/* Note the id of the transaction that created this
index, we use it to restrict readers from accessing
this index, to ensure read consistency. */
- index->trx_id = (ib_uint64_t)
- ut_conv_dulint_to_longlong(trx->id);
+ index->trx_id = trx->id;
} else {
index = NULL;
}
@@ -2517,10 +2532,8 @@ row_merge_is_index_usable(
const trx_t* trx, /*!< in: transaction */
const dict_index_t* index) /*!< in: index to check */
{
- return(!trx->read_view || read_view_sees_trx_id(
- trx->read_view,
- ut_dulint_create((ulint) (index->trx_id >> 32),
- (ulint) index->trx_id & 0xFFFFFFFF)));
+ return(!trx->read_view
+ || read_view_sees_trx_id(trx->read_view, index->trx_id));
}
/*********************************************************************//**
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 1f7f98a59a2..1262ac71e98 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -266,6 +266,49 @@ row_mysql_read_blob_ref(
}
/**************************************************************//**
+Pad a column with spaces. */
+UNIV_INTERN
+void
+row_mysql_pad_col(
+/*==============*/
+ ulint mbminlen, /*!< in: minimum size of a character,
+ in bytes */
+ byte* pad, /*!< out: padded buffer */
+ ulint len) /*!< in: number of bytes to pad */
+{
+ const byte* pad_end;
+
+ switch (UNIV_EXPECT(mbminlen, 1)) {
+ default:
+ ut_error;
+ case 1:
+ /* space=0x20 */
+ memset(pad, 0x20, len);
+ break;
+ case 2:
+ /* space=0x0020 */
+ pad_end = pad + len;
+ ut_a(!(len % 2));
+ do {
+ *pad++ = 0x00;
+ *pad++ = 0x20;
+ } while (pad < pad_end);
+ break;
+ case 4:
+ /* space=0x00000020 */
+ pad_end = pad + len;
+ ut_a(!(len % 4));
+ do {
+ *pad++ = 0x00;
+ *pad++ = 0x00;
+ *pad++ = 0x00;
+ *pad++ = 0x20;
+ } while (pad < pad_end);
+ break;
+ }
+}
+
+/**************************************************************//**
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
The counterpart of this function is row_sel_field_store_in_mysql_format() in
row0sel.c.
@@ -357,12 +400,28 @@ row_mysql_store_col_in_innobase_format(
/* Remove trailing spaces from old style VARCHAR
columns. */
- /* Handle UCS2 strings differently. */
+ /* Handle Unicode strings differently. */
ulint mbminlen = dtype_get_mbminlen(dtype);
ptr = mysql_data;
- if (mbminlen == 2) {
+ switch (mbminlen) {
+ default:
+ ut_error;
+ case 4:
+ /* space=0x00000020 */
+ /* Trim "half-chars", just in case. */
+ col_len &= ~3;
+
+ while (col_len >= 4
+ && ptr[col_len - 4] == 0x00
+ && ptr[col_len - 3] == 0x00
+ && ptr[col_len - 2] == 0x00
+ && ptr[col_len - 1] == 0x20) {
+ col_len -= 4;
+ }
+ break;
+ case 2:
/* space=0x0020 */
/* Trim "half-chars", just in case. */
col_len &= ~1;
@@ -371,8 +430,8 @@ row_mysql_store_col_in_innobase_format(
&& ptr[col_len - 1] == 0x20) {
col_len -= 2;
}
- } else {
- ut_a(mbminlen == 1);
+ break;
+ case 1:
/* space=0x20 */
while (col_len > 0
&& ptr[col_len - 1] == 0x20) {
@@ -1532,7 +1591,7 @@ row_unlock_for_mysql(
}
}
- if (ut_dulint_cmp(rec_trx_id, trx->id) != 0) {
+ if (rec_trx_id != trx->id) {
/* We did not update the record: unlock it */
rec = btr_pcur_get_rec(pcur);
@@ -2283,7 +2342,7 @@ row_discard_tablespace_for_mysql(
trx_t* trx) /*!< in: transaction handle */
{
dict_foreign_t* foreign;
- dulint new_id;
+ table_id_t new_id;
dict_table_t* table;
ibool success;
ulint err;
@@ -2405,7 +2464,7 @@ row_discard_tablespace_for_mysql(
info = pars_info_create();
pars_info_add_str_literal(info, "table_name", name);
- pars_info_add_dulint_literal(info, "new_id", new_id);
+ pars_info_add_ull_literal(info, "new_id", new_id);
err = que_eval_sql(info,
"PROCEDURE DISCARD_TABLESPACE_PROC () IS\n"
@@ -2619,7 +2678,7 @@ row_truncate_table_for_mysql(
dict_index_t* sys_index;
btr_pcur_t pcur;
mtr_t mtr;
- dulint new_id;
+ table_id_t new_id;
ulint recreate_space = 0;
pars_info_t* info = NULL;
@@ -2873,8 +2932,8 @@ next_rec:
info = pars_info_create();
pars_info_add_int4_literal(info, "space", (lint) table->space);
- pars_info_add_dulint_literal(info, "old_id", table->id);
- pars_info_add_dulint_literal(info, "new_id", new_id);
+ pars_info_add_ull_literal(info, "old_id", table->id);
+ pars_info_add_ull_literal(info, "new_id", new_id);
err = que_eval_sql(info,
"PROCEDURE RENUMBER_TABLESPACE_PROC () IS\n"
diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c
index da9d31f333f..fe7a3e0236e 100644
--- a/storage/innobase/row/row0purge.c
+++ b/storage/innobase/row/row0purge.c
@@ -44,6 +44,16 @@ Created 3/14/1997 Heikki Tuuri
#include "row0mysql.h"
#include "log0log.h"
+/*************************************************************************
+IMPORTANT NOTE: Any operation that generates redo MUST check that there
+is enough space in the redo log before for that operation. This is
+done by calling log_free_check(). The reason for checking the
+availability of the redo log space before the start of the operation is
+that we MUST not hold any synchonization objects when performing the
+check.
+If you make a change in this module make sure that no codepath is
+introduced where a call to log_free_check() is bypassed. */
+
/********************************************************************//**
Creates a purge node to a query graph.
@return own: purge node */
@@ -126,6 +136,7 @@ row_purge_remove_clust_if_poss_low(
pcur = &(node->pcur);
btr_cur = btr_pcur_get_btr_cur(pcur);
+ log_free_check();
mtr_start(&mtr);
success = row_purge_reposition_pcur(mode, node, &mtr);
@@ -140,10 +151,9 @@ row_purge_remove_clust_if_poss_low(
rec = btr_pcur_get_rec(pcur);
- if (0 != ut_dulint_cmp(node->roll_ptr, row_get_rec_roll_ptr(
- rec, index, rec_get_offsets(
- rec, index, offsets_,
- ULINT_UNDEFINED, &heap)))) {
+ if (node->roll_ptr != row_get_rec_roll_ptr(
+ rec, index, rec_get_offsets(rec, index, offsets_,
+ ULINT_UNDEFINED, &heap))) {
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
@@ -606,7 +616,7 @@ row_purge_parse_undo_rec(
byte* ptr;
trx_t* trx;
undo_no_t undo_no;
- dulint table_id;
+ table_id_t table_id;
trx_id_t trx_id;
roll_ptr_t roll_ptr;
ulint info_bits;
diff --git a/storage/innobase/row/row0row.c b/storage/innobase/row/row0row.c
index 6cdfa410c15..050b8522fa3 100644
--- a/storage/innobase/row/row0row.c
+++ b/storage/innobase/row/row0row.c
@@ -156,7 +156,7 @@ row_build_index_entry(
}
len = dtype_get_at_most_n_mbchars(
- col->prtype, col->mbminlen, col->mbmaxlen,
+ col->prtype, col->mbminmaxlen,
ind_field->prefix_len, len, dfield_get_data(dfield));
dfield_set_len(dfield, len);
}
@@ -294,7 +294,13 @@ row_build(
ut_ad(dtuple_check_typed(row));
- if (j) {
+ if (!ext) {
+ /* REDUNDANT and COMPACT formats store a local
+ 768-byte prefix of each externally stored
+ column. No cache is needed. */
+ ut_ad(dict_table_get_format(index->table)
+ < DICT_TF_FORMAT_ZIP);
+ } else if (j) {
*ext = row_ext_create(j, ext_cols, row,
dict_table_zip_size(index->table),
heap);
@@ -514,8 +520,7 @@ row_build_row_ref(
dfield_set_len(dfield,
dtype_get_at_most_n_mbchars(
dtype->prtype,
- dtype->mbminlen,
- dtype->mbmaxlen,
+ dtype->mbminmaxlen,
clust_col_prefix_len,
len, (char*) field));
}
@@ -629,8 +634,7 @@ notfound:
dfield_set_len(dfield,
dtype_get_at_most_n_mbchars(
dtype->prtype,
- dtype->mbminlen,
- dtype->mbmaxlen,
+ dtype->mbminmaxlen,
clust_col_prefix_len,
len, (char*) field));
}
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index 2861235a995..39ab2179740 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -88,10 +88,8 @@ row_sel_sec_rec_is_for_blob(
/*========================*/
ulint mtype, /*!< in: main type */
ulint prtype, /*!< in: precise type */
- ulint mbminlen, /*!< in: minimum length of a
- multi-byte character */
- ulint mbmaxlen, /*!< in: maximum length of a
- multi-byte character */
+ ulint mbminmaxlen, /*!< in: minimum and maximum length of
+ a multi-byte character */
const byte* clust_field, /*!< in: the locally stored part of
the clustered index column, including
the BLOB pointer; the clustered
@@ -119,7 +117,7 @@ row_sel_sec_rec_is_for_blob(
return(FALSE);
}
- len = dtype_get_at_most_n_mbchars(prtype, mbminlen, mbmaxlen,
+ len = dtype_get_at_most_n_mbchars(prtype, mbminmaxlen,
sec_len, len, (const char*) buf);
return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len));
@@ -202,14 +200,14 @@ row_sel_sec_rec_is_for_clust_rec(
}
len = dtype_get_at_most_n_mbchars(
- col->prtype, col->mbminlen, col->mbmaxlen,
+ col->prtype, col->mbminmaxlen,
ifield->prefix_len, len, (char*) clust_field);
if (rec_offs_nth_extern(clust_offs, clust_pos)
&& len < sec_len) {
if (!row_sel_sec_rec_is_for_blob(
col->mtype, col->prtype,
- col->mbminlen, col->mbmaxlen,
+ col->mbminmaxlen,
clust_field, clust_len,
sec_field, sec_len,
dict_table_zip_size(
@@ -416,7 +414,7 @@ row_sel_fetch_columns(
field_no))) {
/* Copy an externally stored field to the
- temporary heap */
+ temporary heap, if possible. */
heap = mem_heap_create(1);
@@ -425,6 +423,17 @@ row_sel_fetch_columns(
dict_table_zip_size(index->table),
field_no, &len, heap);
+ /* data == NULL means that the
+ externally stored field was not
+ written yet. This record
+ should only be seen by
+ recv_recovery_rollback_active() or any
+ TRX_ISO_READ_UNCOMMITTED
+ transactions. The InnoDB SQL parser
+ (the sole caller of this function)
+ does not implement READ UNCOMMITTED,
+ and it is not involved during rollback. */
+ ut_a(data);
ut_a(len != UNIV_SQL_NULL);
needs_copy = TRUE;
@@ -926,6 +935,7 @@ row_sel_get_clust_rec(
when plan->clust_pcur was positioned. The latch will not be
released until mtr_commit(mtr). */
+ ut_ad(!rec_get_deleted_flag(clust_rec, rec_offs_comp(offsets)));
row_sel_fetch_columns(index, clust_rec, offsets,
UT_LIST_GET_FIRST(plan->columns));
*out_rec = clust_rec;
@@ -1628,6 +1638,13 @@ skip_lock:
}
if (old_vers == NULL) {
+ /* The record does not exist
+ in our read view. Skip it, but
+ first attempt to determine
+ whether the index segment we
+ are searching through has been
+ exhausted. */
+
offsets = rec_get_offsets(
rec, index, offsets,
ULINT_UNDEFINED, &heap);
@@ -2508,13 +2525,13 @@ row_sel_field_store_in_mysql_format(
ulint len) /*!< in: length of the data */
{
byte* ptr;
- byte* field_end;
- byte* pad_ptr;
ut_ad(len != UNIV_SQL_NULL);
UNIV_MEM_ASSERT_RW(data, len);
switch (templ->type) {
+ const byte* field_end;
+ byte* pad;
case DATA_INT:
/* Convert integer data from Innobase to a little-endian
format, sign bit restored to normal */
@@ -2558,38 +2575,32 @@ row_sel_field_store_in_mysql_format(
unused end of a >= 5.0.3 true VARCHAR column, just in case
MySQL expects its contents to be deterministic. */
- pad_ptr = dest + len;
+ pad = dest + len;
ut_ad(templ->mbminlen <= templ->mbmaxlen);
- /* We handle UCS2 charset strings differently. */
- if (templ->mbminlen == 2) {
- /* A space char is two bytes, 0x0020 in UCS2 */
+ /* We treat some Unicode charset strings specially. */
+ switch (templ->mbminlen) {
+ case 4:
+ /* InnoDB should never have stripped partial
+ UTF-32 characters. */
+ ut_a(!(len & 3));
+ break;
+ case 2:
+ /* A space char is two bytes,
+ 0x0020 in UCS2 and UTF-16 */
- if (len & 1) {
+ if (UNIV_UNLIKELY(len & 1)) {
/* A 0x20 has been stripped from the column.
Pad it back. */
- if (pad_ptr < field_end) {
- *pad_ptr = 0x20;
- pad_ptr++;
+ if (pad < field_end) {
+ *pad++ = 0x20;
}
}
-
- /* Pad the rest of the string with 0x0020 */
-
- while (pad_ptr < field_end) {
- *pad_ptr = 0x00;
- pad_ptr++;
- *pad_ptr = 0x20;
- pad_ptr++;
- }
- } else {
- ut_ad(templ->mbminlen == 1);
- /* space=0x20 */
-
- memset(pad_ptr, 0x20, field_end - pad_ptr);
}
+
+ row_mysql_pad_col(templ->mbminlen, pad, field_end - pad);
break;
case DATA_BLOB:
@@ -2614,9 +2625,9 @@ row_sel_field_store_in_mysql_format(
|| !(templ->mysql_col_len % templ->mbmaxlen));
ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len);
- if (templ->mbminlen != templ->mbmaxlen) {
+ if (templ->mbminlen == 1 && templ->mbmaxlen != 1) {
/* Pad with spaces. This undoes the stripping
- done in row0mysql.ic, function
+ done in row0mysql.c, function
row_mysql_store_col_in_innobase_format(). */
memset(dest + len, 0x20, templ->mysql_col_len - len);
@@ -2647,9 +2658,8 @@ Convert a row in the Innobase format to a row in the MySQL format.
Note that the template in prebuilt may advise us to copy only a few
columns to mysql_rec, other columns are left blank. All columns may not
be needed in the query.
-@return TRUE if success, FALSE if could not allocate memory for a BLOB
-(though we may also assert in that case) */
-static
+@return TRUE on success, FALSE if not all columns could be retrieved */
+static __attribute__((warn_unused_result))
ibool
row_sel_store_mysql_rec(
/*====================*/
@@ -2672,6 +2682,7 @@ row_sel_store_mysql_rec(
ut_ad(prebuilt->mysql_template);
ut_ad(prebuilt->default_rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
+ ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
mem_heap_free(prebuilt->blob_heap);
@@ -2719,6 +2730,21 @@ row_sel_store_mysql_rec(
dict_table_zip_size(prebuilt->table),
templ->rec_field_no, &len, heap);
+ if (UNIV_UNLIKELY(!data)) {
+ /* The externally stored field
+ was not written yet. This
+ record should only be seen by
+ recv_recovery_rollback_active()
+ or any TRX_ISO_READ_UNCOMMITTED
+ transactions. */
+
+ if (extern_field_heap) {
+ mem_heap_free(extern_field_heap);
+ }
+
+ return(FALSE);
+ }
+
ut_a(len != UNIV_SQL_NULL);
} else {
/* Field is stored in the row. */
@@ -3136,9 +3162,10 @@ row_sel_pop_cached_row_for_mysql(
}
/********************************************************************//**
-Pushes a row for MySQL to the fetch cache. */
-UNIV_INLINE
-void
+Pushes a row for MySQL to the fetch cache.
+@return TRUE on success, FALSE if the record contains incomplete BLOBs */
+UNIV_INLINE __attribute__((warn_unused_result))
+ibool
row_sel_push_cache_row_for_mysql(
/*=============================*/
row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */
@@ -3180,10 +3207,11 @@ row_sel_push_cache_row_for_mysql(
prebuilt->fetch_cache[
prebuilt->n_fetch_cached],
prebuilt, rec, offsets))) {
- ut_error;
+ return(FALSE);
}
prebuilt->n_fetch_cached++;
+ return(TRUE);
}
/*********************************************************************//**
@@ -3578,11 +3606,21 @@ row_search_for_mysql(
if (!row_sel_store_mysql_rec(buf, prebuilt,
rec, offsets)) {
- err = DB_TOO_BIG_RECORD;
-
- /* We let the main loop to do the
- error handling */
- goto shortcut_fails_too_big_rec;
+ /* Only fresh inserts may contain
+ incomplete externally stored
+ columns. Pretend that such
+ records do not exist. Such
+ records may only be accessed
+ at the READ UNCOMMITTED
+ isolation level or when
+ rolling back a recovered
+ transaction. Rollback happens
+ at a lower level, not here. */
+ ut_a(trx->isolation_level
+ == TRX_ISO_READ_UNCOMMITTED);
+
+ /* Proceed as in case SEL_RETRY. */
+ break;
}
mtr_commit(&mtr);
@@ -3622,7 +3660,7 @@ release_search_latch_if_needed:
default:
ut_ad(0);
}
-shortcut_fails_too_big_rec:
+
mtr_commit(&mtr);
mtr_start(&mtr);
}
@@ -4357,9 +4395,18 @@ requires_clust_rec:
not cache rows because there the cursor is a scrollable
cursor. */
- row_sel_push_cache_row_for_mysql(prebuilt, result_rec,
- offsets);
- if (prebuilt->n_fetch_cached == MYSQL_FETCH_CACHE_SIZE) {
+ if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec,
+ offsets)) {
+ /* Only fresh inserts may contain incomplete
+ externally stored columns. Pretend that such
+ records do not exist. Such records may only be
+ accessed at the READ UNCOMMITTED isolation
+ level or when rolling back a recovered
+ transaction. Rollback happens at a lower
+ level, not here. */
+ ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED);
+ } else if (prebuilt->n_fetch_cached
+ == MYSQL_FETCH_CACHE_SIZE) {
goto got_row;
}
@@ -4375,9 +4422,17 @@ requires_clust_rec:
} else {
if (!row_sel_store_mysql_rec(buf, prebuilt,
result_rec, offsets)) {
- err = DB_TOO_BIG_RECORD;
-
- goto lock_wait_or_error;
+ /* Only fresh inserts may contain
+ incomplete externally stored
+ columns. Pretend that such records do
+ not exist. Such records may only be
+ accessed at the READ UNCOMMITTED
+ isolation level or when rolling back a
+ recovered transaction. Rollback
+ happens at a lower level, not here. */
+ ut_a(trx->isolation_level
+ == TRX_ISO_READ_UNCOMMITTED);
+ goto next_rec;
}
}
@@ -4622,8 +4677,7 @@ row_search_check_if_query_cache_permitted(
IX type locks actually would require ret = FALSE. */
if (UT_LIST_GET_LEN(table->locks) == 0
- && ut_dulint_cmp(trx->id,
- table->query_cache_inv_trx_id) >= 0) {
+ && trx->id >= table->query_cache_inv_trx_id) {
ret = TRUE;
diff --git a/storage/innobase/row/row0uins.c b/storage/innobase/row/row0uins.c
index c35f1ef7a44..d25afed3840 100644
--- a/storage/innobase/row/row0uins.c
+++ b/storage/innobase/row/row0uins.c
@@ -46,6 +46,16 @@ Created 2/25/1997 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "log0log.h"
+/*************************************************************************
+IMPORTANT NOTE: Any operation that generates redo MUST check that there
+is enough space in the redo log before for that operation. This is
+done by calling log_free_check(). The reason for checking the
+availability of the redo log space before the start of the operation is
+that we MUST not hold any synchonization objects when performing the
+check.
+If you make a change in this module make sure that no codepath is
+introduced where a call to log_free_check() is bypassed. */
+
/***************************************************************//**
Removes a clustered index record. The pcur in node was positioned on the
record, now it is detached.
@@ -68,7 +78,7 @@ row_undo_ins_remove_clust_rec(
&mtr);
ut_a(success);
- if (ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) {
+ if (node->table->id == DICT_INDEXES_ID) {
ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
/* Drop the index tree associated with the row in
@@ -151,7 +161,6 @@ row_undo_ins_remove_sec_low(
mtr_t mtr;
enum row_search_result search_result;
- log_free_check();
mtr_start(&mtr);
btr_cur = btr_pcur_get_btr_cur(&pcur);
@@ -251,7 +260,7 @@ row_undo_ins_parse_undo_rec(
dict_index_t* clust_index;
byte* ptr;
undo_no_t undo_no;
- dulint table_id;
+ table_id_t table_id;
ulint type;
ulint dummy;
ibool dummy_extern;
@@ -337,6 +346,7 @@ row_undo_ins(
transactions. */
ut_a(trx_is_recv(node->trx));
} else {
+ log_free_check();
err = row_undo_ins_remove_sec(node->index, entry);
if (err != DB_SUCCESS) {
@@ -348,5 +358,6 @@ row_undo_ins(
node->index = dict_table_get_next_index(node->index);
}
+ log_free_check();
return(row_undo_ins_remove_clust_rec(node));
}
diff --git a/storage/innobase/row/row0umod.c b/storage/innobase/row/row0umod.c
index 75de18a0b7d..aebff0764c8 100644
--- a/storage/innobase/row/row0umod.c
+++ b/storage/innobase/row/row0umod.c
@@ -58,12 +58,22 @@ delete marked clustered index record was delete unmarked and possibly also
some of its fields were changed. Now, it is possible that the delete marked
version has become obsolete at the time the undo is started. */
+/*************************************************************************
+IMPORTANT NOTE: Any operation that generates redo MUST check that there
+is enough space in the redo log before for that operation. This is
+done by calling log_free_check(). The reason for checking the
+availability of the redo log space before the start of the operation is
+that we MUST not hold any synchonization objects when performing the
+check.
+If you make a change in this module make sure that no codepath is
+introduced where a call to log_free_check() is bypassed. */
+
/***********************************************************//**
Checks if also the previous version of the clustered index record was
modified or inserted by the same transaction, and its undo number is such
that it should be undone in the same rollback.
@return TRUE if also previous modify or insert of this row should be undone */
-UNIV_INLINE
+static
ibool
row_undo_mod_undo_also_prev_vers(
/*=============================*/
@@ -75,9 +85,9 @@ row_undo_mod_undo_also_prev_vers(
trx = node->trx;
- if (0 != ut_dulint_cmp(node->new_trx_id, trx->id)) {
+ if (node->new_trx_id != trx->id) {
- *undo_no = ut_dulint_zero;
+ *undo_no = 0;
return(FALSE);
}
@@ -85,7 +95,7 @@ row_undo_mod_undo_also_prev_vers(
*undo_no = trx_undo_rec_get_undo_no(undo_rec);
- return(ut_dulint_cmp(trx->roll_limit, *undo_no) <= 0);
+ return(trx->roll_limit <= *undo_no);
}
/***********************************************************//**
@@ -231,6 +241,8 @@ row_undo_mod_clust(
ut_ad(node && thr);
+ log_free_check();
+
/* Check if also the previous version of the clustered index record
should be undone in this same rollback operation */
@@ -778,7 +790,7 @@ row_undo_mod_parse_undo_rec(
dict_index_t* clust_index;
byte* ptr;
undo_no_t undo_no;
- dulint table_id;
+ table_id_t table_id;
trx_id_t trx_id;
roll_ptr_t roll_ptr;
ulint info_bits;
diff --git a/storage/innobase/row/row0undo.c b/storage/innobase/row/row0undo.c
index 3d739c9689a..09970b7fe21 100644
--- a/storage/innobase/row/row0undo.c
+++ b/storage/innobase/row/row0undo.c
@@ -185,9 +185,8 @@ row_undo_search_clust_to_pcur(
offsets = rec_get_offsets(rec, clust_index, offsets,
ULINT_UNDEFINED, &heap);
- if (!found || 0 != ut_dulint_cmp(node->roll_ptr,
- row_get_rec_roll_ptr(rec, clust_index,
- offsets))) {
+ if (!found || node->roll_ptr
+ != row_get_rec_roll_ptr(rec, clust_index, offsets)) {
/* We must remove the reservation on the undo log record
BEFORE releasing the latch on the clustered index page: this
@@ -199,8 +198,24 @@ row_undo_search_clust_to_pcur(
ret = FALSE;
} else {
+ row_ext_t** ext;
+
+ if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) {
+ /* In DYNAMIC or COMPRESSED format, there is
+ no prefix of externally stored columns in the
+ clustered index record. Build a cache of
+ column prefixes. */
+ ext = &node->ext;
+ } else {
+ /* REDUNDANT and COMPACT formats store a local
+ 768-byte prefix of each externally stored
+ column. No cache is needed. */
+ ext = NULL;
+ node->ext = NULL;
+ }
+
node->row = row_build(ROW_COPY_DATA, clust_index, rec,
- offsets, NULL, &node->ext, node->heap);
+ offsets, NULL, ext, node->heap);
if (node->update) {
node->undo_row = dtuple_copy(node->row, node->heap);
row_upd_replace(node->undo_row, &node->undo_ext,
@@ -297,7 +312,7 @@ row_undo(
if (locked_data_dict) {
- row_mysql_lock_data_dictionary(trx);
+ row_mysql_freeze_data_dictionary(trx);
}
if (node->state == UNDO_NODE_INSERT) {
@@ -312,7 +327,7 @@ row_undo(
if (locked_data_dict) {
- row_mysql_unlock_data_dictionary(trx);
+ row_mysql_unfreeze_data_dictionary(trx);
}
/* Do some cleanup */
diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c
index f1a90a3bf1c..588ee352ba0 100644
--- a/storage/innobase/row/row0upd.c
+++ b/storage/innobase/row/row0upd.c
@@ -92,6 +92,16 @@ the x-latch freed? The most efficient way for performing a
searched delete is obviously to keep the x-latch for several
steps of query graph execution. */
+/*************************************************************************
+IMPORTANT NOTE: Any operation that generates redo MUST check that there
+is enough space in the redo log before for that operation. This is
+done by calling log_free_check(). The reason for checking the
+availability of the redo log space before the start of the operation is
+that we MUST not hold any synchonization objects when performing the
+check.
+If you make a change in this module make sure that no codepath is
+introduced where a call to log_free_check() is bypassed. */
+
/***********************************************************//**
Checks if an update vector changes some of the first ordering fields of an
index record. This is only used in foreign key checks and we can assume
@@ -367,7 +377,7 @@ row_upd_index_entry_sys_field(
them */
dict_index_t* index, /*!< in: clustered index */
ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */
- dulint val) /*!< in: value to write */
+ ib_uint64_t val) /*!< in: value to write */
{
dfield_t* dfield;
byte* field;
@@ -526,7 +536,7 @@ row_upd_write_sys_vals_to_log(
trx_write_roll_ptr(log_ptr, roll_ptr);
log_ptr += DATA_ROLL_PTR_LEN;
- log_ptr += mach_dulint_write_compressed(log_ptr, trx->id);
+ log_ptr += mach_ull_write_compressed(log_ptr, trx->id);
return(log_ptr);
}
@@ -560,7 +570,7 @@ row_upd_parse_sys_vals(
*roll_ptr = trx_read_roll_ptr(ptr);
ptr += DATA_ROLL_PTR_LEN;
- ptr = mach_dulint_parse_compressed(ptr, end_ptr, trx_id);
+ ptr = mach_ull_parse_compressed(ptr, end_ptr, trx_id);
return(ptr);
}
@@ -939,7 +949,7 @@ row_upd_index_replace_new_col_val(
}
len = dtype_get_at_most_n_mbchars(col->prtype,
- col->mbminlen, col->mbmaxlen,
+ col->mbminmaxlen,
field->prefix_len, len,
(const char*) data);
@@ -1388,6 +1398,7 @@ row_upd_store_row(
dict_index_t* clust_index;
rec_t* rec;
mem_heap_t* heap = NULL;
+ row_ext_t** ext;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
const ulint* offsets;
rec_offs_init(offsets_);
@@ -1404,8 +1415,22 @@ row_upd_store_row(
offsets = rec_get_offsets(rec, clust_index, offsets_,
ULINT_UNDEFINED, &heap);
+
+ if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) {
+ /* In DYNAMIC or COMPRESSED format, there is no prefix
+ of externally stored columns in the clustered index
+ record. Build a cache of column prefixes. */
+ ext = &node->ext;
+ } else {
+ /* REDUNDANT and COMPACT formats store a local
+ 768-byte prefix of each externally stored column.
+ No cache is needed. */
+ ext = NULL;
+ node->ext = NULL;
+ }
+
node->row = row_build(ROW_COPY_DATA, clust_index, rec, offsets,
- NULL, &node->ext, node->heap);
+ NULL, ext, node->heap);
if (node->is_delete) {
node->upd_row = NULL;
node->upd_ext = NULL;
@@ -1454,7 +1479,6 @@ row_upd_sec_index_entry(
entry = row_build_index_entry(node->row, node->ext, index, heap);
ut_a(entry);
- log_free_check();
mtr_start(&mtr);
/* Set the query thread, so that ibuf_insert_low() will be
@@ -1557,7 +1581,7 @@ Updates the secondary index record if it is changed in the row update or
deletes it if this is a delete.
@return DB_SUCCESS if operation successfully completed, else error
code or DB_LOCK_WAIT */
-UNIV_INLINE
+static
ulint
row_upd_sec_step(
/*=============*/
@@ -1903,8 +1927,7 @@ row_upd_clust_step(
then we have to free the file segments of the index tree associated
with the index */
- if (node->is_delete
- && ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) {
+ if (node->is_delete && node->table->id == DICT_INDEXES_ID) {
dict_drop_index_tree(btr_pcur_get_rec(pcur), mtr);
@@ -2049,6 +2072,7 @@ row_upd(
if (node->state == UPD_NODE_UPDATE_CLUSTERED
|| node->state == UPD_NODE_INSERT_CLUSTERED) {
+ log_free_check();
err = row_upd_clust_step(node, thr);
if (err != DB_SUCCESS) {
@@ -2063,6 +2087,8 @@ row_upd(
}
while (node->index != NULL) {
+
+ log_free_check();
err = row_upd_sec_step(node, thr);
if (err != DB_SUCCESS) {
diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c
index a4fbb5289aa..3e6fc3f18b6 100644
--- a/storage/innobase/row/row0vers.c
+++ b/storage/innobase/row/row0vers.c
@@ -209,7 +209,7 @@ row_vers_impl_x_locked_off_kernel(
prev_trx_id must have already committed for the trx_id
to be able to modify the row. Therefore, prev_trx_id
cannot hold any implicit lock. */
- if (vers_del && 0 != ut_dulint_cmp(trx_id, prev_trx_id)) {
+ if (vers_del && trx_id != prev_trx_id) {
mutex_enter(&kernel_mutex);
break;
@@ -280,7 +280,7 @@ row_vers_impl_x_locked_off_kernel(
break;
}
- if (0 != ut_dulint_cmp(trx_id, prev_trx_id)) {
+ if (trx_id != prev_trx_id) {
/* The versions modified by the trx_id transaction end
to prev_version: no implicit x-lock */
@@ -533,7 +533,7 @@ row_vers_build_for_consistent_read(
undo_no of the record is < undo_no in the view. */
if (view->type == VIEW_HIGH_GRANULARITY
- && ut_dulint_cmp(view->creator_trx_id, trx_id) == 0) {
+ && view->creator_trx_id == trx_id) {
roll_ptr = row_get_rec_roll_ptr(version, index,
*offsets);
@@ -541,7 +541,7 @@ row_vers_build_for_consistent_read(
undo_no = trx_undo_rec_get_undo_no(undo_rec);
mem_heap_empty(heap);
- if (ut_dulint_cmp(view->undo_no, undo_no) > 0) {
+ if (view->undo_no > undo_no) {
/* The view already sees this version: we can
copy it to in_heap and return */
@@ -632,7 +632,7 @@ row_vers_build_for_semi_consistent_read(
mem_heap_t* heap = NULL;
byte* buf;
ulint err;
- trx_id_t rec_trx_id = ut_dulint_zero;
+ trx_id_t rec_trx_id = 0;
ut_ad(dict_index_is_clust(index));
ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
@@ -684,7 +684,7 @@ row_vers_build_for_semi_consistent_read(
rolled back and the transaction is removed from
the global list of transactions. */
- if (!ut_dulint_cmp(rec_trx_id, version_trx_id)) {
+ if (rec_trx_id == version_trx_id) {
/* The transaction was committed while
we searched for earlier versions.
Return the current version as a
diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
index 6354689105a..97d699dde99 100644
--- a/storage/innobase/srv/srv0srv.c
+++ b/storage/innobase/srv/srv0srv.c
@@ -142,6 +142,21 @@ use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
UNIV_INTERN my_bool srv_use_native_aio = TRUE;
+#ifdef __WIN__
+/* Windows native condition variables. We use runtime loading / function
+pointers, because they are not available on Windows Server 2003 and
+Windows XP/2000.
+
+We use condition for events on Windows if possible, even if os_event
+resembles Windows kernel event object well API-wise. The reason is
+performance, kernel objects are heavyweights and WaitForSingleObject() is a
+performance killer causing calling thread to context switch. Besides, Innodb
+is preallocating large number (often millions) of os_events. With kernel event
+objects it takes a big chunk out of non-paged pool, which is better suited
+for tasks like IO than for storing idle event objects. */
+UNIV_INTERN ibool srv_use_native_conditions = FALSE;
+#endif /* __WIN__ */
+
UNIV_INTERN ulint srv_n_data_files = 0;
UNIV_INTERN char** srv_data_file_names = NULL;
/* size in database pages */
@@ -3007,6 +3022,8 @@ srv_purge_thread(
slot_no = srv_table_reserve_slot(SRV_WORKER);
+ slot = srv_table_get_nth_slot(slot_no);
+
++srv_n_threads_active[SRV_WORKER];
mutex_exit(&kernel_mutex);
@@ -3058,20 +3075,16 @@ srv_purge_thread(
mutex_enter(&kernel_mutex);
+ ut_ad(srv_table_get_nth_slot(slot_no) == slot);
+
/* Decrement the active count. */
srv_suspend_thread();
- mutex_exit(&kernel_mutex);
+ slot->in_use = FALSE;
/* Free the thread local memory. */
thr_local_free(os_thread_get_curr_id());
- mutex_enter(&kernel_mutex);
-
- /* Free the slot for reuse. */
- slot = srv_table_get_nth_slot(slot_no);
- slot->in_use = FALSE;
-
mutex_exit(&kernel_mutex);
#ifdef UNIV_DEBUG_THREAD_CREATION
diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c
index 686ee6a4198..4da836672ec 100644
--- a/storage/innobase/srv/srv0start.c
+++ b/storage/innobase/srv/srv0start.c
@@ -1160,9 +1160,17 @@ innobase_start_or_create_for_mysql(void)
srv_use_native_aio = FALSE;
break;
+
+ case OS_WIN2000:
+ case OS_WINXP:
+ /* On 2000 and XP, async IO is available. */
+ srv_use_native_aio = TRUE;
+ break;
+
default:
- /* On Win 2000 and XP use async i/o */
+ /* Vista and later have both async IO and condition variables */
srv_use_native_aio = TRUE;
+ srv_use_native_conditions = TRUE;
break;
}
@@ -1695,20 +1703,6 @@ innobase_start_or_create_for_mysql(void)
/* fprintf(stderr, "Max allowed record size %lu\n",
page_get_free_space_of_empty() / 2); */
- /* Create the thread which watches the timeouts for lock waits */
- os_thread_create(&srv_lock_timeout_thread, NULL,
- thread_ids + 2 + SRV_MAX_N_IO_THREADS);
-
- /* Create the thread which warns of long semaphore waits */
- os_thread_create(&srv_error_monitor_thread, NULL,
- thread_ids + 3 + SRV_MAX_N_IO_THREADS);
-
- /* Create the thread which prints InnoDB monitor info */
- os_thread_create(&srv_monitor_thread, NULL,
- thread_ids + 4 + SRV_MAX_N_IO_THREADS);
-
- srv_is_being_started = FALSE;
-
if (trx_doublewrite == NULL) {
/* Create the doublewrite buffer to a new tablespace */
@@ -1721,8 +1715,29 @@ innobase_start_or_create_for_mysql(void)
We create the new segments only if it's a new database or
the database was shutdown cleanly. */
+ /* Note: When creating the extra rollback segments during an upgrade
+ we violate the latching order, even if the change buffer is empty.
+ We make an exception in sync0sync.c and check srv_is_being_started
+ for that violation. It cannot create a deadlock because we are still
+ running in single threaded mode essentially. Only the IO threads
+ should be running at this stage. */
+
trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
+ /* Create the thread which watches the timeouts for lock waits */
+ os_thread_create(&srv_lock_timeout_thread, NULL,
+ thread_ids + 2 + SRV_MAX_N_IO_THREADS);
+
+ /* Create the thread which warns of long semaphore waits */
+ os_thread_create(&srv_error_monitor_thread, NULL,
+ thread_ids + 3 + SRV_MAX_N_IO_THREADS);
+
+ /* Create the thread which prints InnoDB monitor info */
+ os_thread_create(&srv_monitor_thread, NULL,
+ thread_ids + 4 + SRV_MAX_N_IO_THREADS);
+
+ srv_is_being_started = FALSE;
+
err = dict_create_or_check_foreign_constraint_tables();
if (err != DB_SUCCESS) {
diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c
index 248bd2cd25d..753ebd958ac 100644
--- a/storage/innobase/sync/sync0arr.c
+++ b/storage/innobase/sync/sync0arr.c
@@ -250,7 +250,7 @@ sync_array_create(
/* Then create the mutex to protect the wait array complex */
if (protection == SYNC_ARRAY_OS_MUTEX) {
- arr->os_mutex = os_mutex_create(NULL);
+ arr->os_mutex = os_mutex_create();
} else if (protection == SYNC_ARRAY_MUTEX) {
mutex_create(syn_arr_mutex_key,
&arr->mutex, SYNC_NO_ORDER_CHECK);
diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c
index 235f733382d..8062d9e902e 100644
--- a/storage/innobase/sync/sync0sync.c
+++ b/storage/innobase/sync/sync0sync.c
@@ -40,6 +40,9 @@ Created 9/5/1995 Heikki Tuuri
#include "srv0srv.h"
#include "buf0types.h"
#include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
+#ifdef UNIV_SYNC_DEBUG
+# include "srv0start.h" /* srv_is_being_started */
+#endif /* UNIV_SYNC_DEBUG */
/*
REASONS FOR IMPLEMENTING THE SPIN LOCK MUTEX
@@ -1152,6 +1155,13 @@ sync_thread_add_level(
case SYNC_TREE_NODE_FROM_HASH:
/* Do no order checking */
break;
+ case SYNC_TRX_SYS_HEADER:
+ if (srv_is_being_started) {
+ /* This is violated during trx_sys_create_rsegs()
+ when creating additional rollback segments when
+ upgrading in innobase_start_or_create_for_mysql(). */
+ break;
+ }
case SYNC_MEM_POOL:
case SYNC_MEM_HASH:
case SYNC_RECV:
@@ -1160,7 +1170,6 @@ sync_thread_add_level(
case SYNC_LOG_FLUSH_ORDER:
case SYNC_THR_LOCAL:
case SYNC_ANY_LATCH:
- case SYNC_TRX_SYS_HEADER:
case SYNC_FILE_FORMAT_TAG:
case SYNC_DOUBLEWRITE:
case SYNC_SEARCH_SYS:
@@ -1222,8 +1231,12 @@ sync_thread_add_level(
ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP - 1,
TRUE));
} else {
- ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP,
- TRUE));
+ /* This is violated during trx_sys_create_rsegs()
+ when creating additional rollback segments when
+ upgrading in innobase_start_or_create_for_mysql(). */
+ ut_a(srv_is_being_started
+ || sync_thread_levels_g(array, SYNC_IBUF_BITMAP,
+ TRUE));
}
break;
case SYNC_FSP_PAGE:
@@ -1492,14 +1505,16 @@ sync_print_wait_info(
fprintf(file,
"Mutex spin waits %llu, rounds %llu, OS waits %llu\n"
- "RW-shared spins %llu, OS waits %llu;"
- " RW-excl spins %llu, OS waits %llu\n",
+ "RW-shared spins %llu, rounds %llu, OS waits %llu\n"
+ "RW-excl spins %llu, rounds %llu, OS waits %llu\n",
mutex_spin_wait_count,
mutex_spin_round_count,
mutex_os_wait_count,
rw_s_spin_wait_count,
+ rw_s_spin_round_count,
rw_s_os_wait_count,
rw_x_spin_wait_count,
+ rw_x_spin_round_count,
rw_x_os_wait_count);
fprintf(file,
diff --git a/storage/innobase/trx/trx0i_s.c b/storage/innobase/trx/trx0i_s.c
index 8b719646023..1ad074769c7 100644
--- a/storage/innobase/trx/trx0i_s.c
+++ b/storage/innobase/trx/trx0i_s.c
@@ -444,7 +444,7 @@ fill_trx_row(
ut_ad(mutex_own(&kernel_mutex));
- row->trx_id = trx_get_id(trx);
+ row->trx_id = trx->id;
row->trx_started = (ib_time_t) trx->start_time;
row->trx_state = trx_get_que_state_str(trx);
@@ -462,7 +462,7 @@ fill_trx_row(
row->trx_wait_started = 0;
}
- row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
+ row->trx_weight = (ullint) TRX_WEIGHT(trx);
if (trx->mysql_thd == NULL) {
/* For internal transactions e.g., purge and transactions
@@ -527,7 +527,7 @@ thd_done:
row->trx_rows_locked = lock_number_of_rows_locked(trx);
- row->trx_rows_modified = ut_conv_dulint_to_longlong(trx->undo_no);
+ row->trx_rows_modified = trx->undo_no;
row->trx_concurrency_tickets = trx->n_tickets_to_enter_innodb;
diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c
index 550a8c9c4b3..e17ed547050 100644
--- a/storage/innobase/trx/trx0purge.c
+++ b/storage/innobase/trx/trx0purge.c
@@ -145,47 +145,44 @@ void
trx_purge_arr_get_biggest(
/*======================*/
trx_undo_arr_t* arr, /*!< in: purge array */
- trx_id_t* trx_no, /*!< out: transaction number: ut_dulint_zero
+ trx_id_t* trx_no, /*!< out: transaction number: 0
if array is empty */
undo_no_t* undo_no)/*!< out: undo number */
{
trx_undo_inf_t* cell;
trx_id_t pair_trx_no;
undo_no_t pair_undo_no;
- int trx_cmp;
- ulint n_used;
ulint i;
ulint n;
- n = 0;
- n_used = arr->n_used;
- pair_trx_no = ut_dulint_zero;
- pair_undo_no = ut_dulint_zero;
+ n = arr->n_used;
+ pair_trx_no = 0;
+ pair_undo_no = 0;
- for (i = 0;; i++) {
- cell = trx_undo_arr_get_nth_info(arr, i);
+ if (n) {
+ for (i = 0;; i++) {
+ cell = trx_undo_arr_get_nth_info(arr, i);
- if (cell->in_use) {
- n++;
- trx_cmp = ut_dulint_cmp(cell->trx_no, pair_trx_no);
+ if (!cell->in_use) {
+ continue;
+ }
- if ((trx_cmp > 0)
- || ((trx_cmp == 0)
- && (ut_dulint_cmp(cell->undo_no,
- pair_undo_no) >= 0))) {
+ if ((cell->trx_no > pair_trx_no)
+ || ((cell->trx_no == pair_trx_no)
+ && cell->undo_no >= pair_undo_no)) {
pair_trx_no = cell->trx_no;
pair_undo_no = cell->undo_no;
}
- }
-
- if (n == n_used) {
- *trx_no = pair_trx_no;
- *undo_no = pair_undo_no;
- return;
+ if (!--n) {
+ break;
+ }
}
}
+
+ *trx_no = pair_trx_no;
+ *undo_no = pair_undo_no;
}
/****************************************************************//**
@@ -233,8 +230,8 @@ trx_purge_sys_create(void)
purge_sys->n_pages_handled = 0;
- purge_sys->purge_trx_no = ut_dulint_zero;
- purge_sys->purge_undo_no = ut_dulint_zero;
+ purge_sys->purge_trx_no = 0;
+ purge_sys->purge_undo_no = 0;
purge_sys->next_stored = FALSE;
rw_lock_create(trx_purge_latch_key,
@@ -257,7 +254,7 @@ trx_purge_sys_create(void)
purge_sys->query = trx_purge_graph_build();
- purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero,
+ purge_sys->view = read_view_oldest_copy_or_open_new(0,
purge_sys->heap);
}
@@ -370,7 +367,7 @@ trx_purge_add_update_undo_to_history(
}
/* Write the trx number to the undo log header */
- mlog_write_dulint(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
+ mlog_write_ull(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
/* Write information about delete markings to the undo log header */
if (!undo->del_marks) {
@@ -512,9 +509,9 @@ trx_purge_truncate_rseg_history(
page_t* undo_page;
trx_ulogf_t* log_hdr;
trx_usegf_t* seg_hdr;
- int cmp;
ulint n_removed_logs = 0;
mtr_t mtr;
+ trx_id_t undo_trx_no;
ut_ad(mutex_own(&(purge_sys->mutex)));
@@ -540,15 +537,16 @@ loop:
hdr_addr.page, &mtr);
log_hdr = undo_page + hdr_addr.boffset;
+ undo_trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO);
- cmp = ut_dulint_cmp(mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO),
- limit_trx_no);
- if (cmp == 0) {
- trx_undo_truncate_start(rseg, rseg->space, hdr_addr.page,
- hdr_addr.boffset, limit_undo_no);
- }
+ if (undo_trx_no >= limit_trx_no) {
+ if (undo_trx_no == limit_trx_no) {
+ trx_undo_truncate_start(rseg, rseg->space,
+ hdr_addr.page,
+ hdr_addr.boffset,
+ limit_undo_no);
+ }
- if (cmp >= 0) {
mutex_enter(&kernel_mutex);
ut_a(trx_sys->rseg_history_len >= n_removed_logs);
trx_sys->rseg_history_len -= n_removed_logs;
@@ -614,7 +612,7 @@ trx_purge_truncate_history(void)
trx_purge_arr_get_biggest(purge_sys->arr, &limit_trx_no,
&limit_undo_no);
- if (ut_dulint_is_zero(limit_trx_no)) {
+ if (limit_trx_no == 0) {
limit_trx_no = purge_sys->purge_trx_no;
limit_undo_no = purge_sys->purge_undo_no;
@@ -623,13 +621,12 @@ trx_purge_truncate_history(void)
/* We play safe and set the truncate limit at most to the purge view
low_limit number, though this is not necessary */
- if (ut_dulint_cmp(limit_trx_no, purge_sys->view->low_limit_no) >= 0) {
+ if (limit_trx_no >= purge_sys->view->low_limit_no) {
limit_trx_no = purge_sys->view->low_limit_no;
- limit_undo_no = ut_dulint_zero;
+ limit_undo_no = 0;
}
- ut_ad((ut_dulint_cmp(limit_trx_no,
- purge_sys->view->low_limit_no) <= 0));
+ ut_ad(limit_trx_no <= purge_sys->view->low_limit_no);
rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
@@ -684,8 +681,8 @@ trx_purge_rseg_get_next_history_log(
ut_a(rseg->last_page_no != FIL_NULL);
- purge_sys->purge_trx_no = ut_dulint_add(rseg->last_trx_no, 1);
- purge_sys->purge_undo_no = ut_dulint_zero;
+ purge_sys->purge_trx_no = rseg->last_trx_no + 1;
+ purge_sys->purge_undo_no = 0;
purge_sys->next_stored = FALSE;
mtr_start(&mtr);
@@ -787,7 +784,7 @@ trx_purge_choose_next_log(void)
rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
- min_trx_no = ut_dulint_max;
+ min_trx_no = IB_ULONGLONG_MAX;
min_rseg = NULL;
@@ -796,9 +793,8 @@ trx_purge_choose_next_log(void)
if (rseg->last_page_no != FIL_NULL) {
- if ((min_rseg == NULL)
- || (ut_dulint_cmp(min_trx_no,
- rseg->last_trx_no) > 0)) {
+ if (min_rseg == NULL
+ || min_trx_no > rseg->last_trx_no) {
min_rseg = rseg;
min_trx_no = rseg->last_trx_no;
@@ -848,7 +844,7 @@ trx_purge_choose_next_log(void)
if (rec == &trx_purge_dummy_rec) {
- purge_sys->purge_undo_no = ut_dulint_zero;
+ purge_sys->purge_undo_no = 0;
purge_sys->page_no = page_no;
purge_sys->offset = 0;
} else {
@@ -1041,8 +1037,7 @@ trx_purge_fetch_next_rec(
return(NULL);
}
- if (ut_dulint_cmp(purge_sys->purge_trx_no,
- purge_sys->view->low_limit_no) >= 0) {
+ if (purge_sys->purge_trx_no >= purge_sys->view->low_limit_no) {
purge_sys->state = TRX_STOP_PURGE;
trx_purge_truncate_if_arr_empty();
@@ -1052,10 +1047,10 @@ trx_purge_fetch_next_rec(
return(NULL);
}
- /* fprintf(stderr, "Thread %lu purging trx %lu undo record %lu\n",
+ /* fprintf(stderr, "Thread %lu purging trx %llu undo record %llu\n",
os_thread_get_curr_id(),
- ut_dulint_get_low(purge_sys->purge_trx_no),
- ut_dulint_get_low(purge_sys->purge_undo_no)); */
+ (ullint) purge_sys->purge_trx_no,
+ (ullint) purge_sys->purge_undo_no); */
*roll_ptr = trx_undo_build_roll_ptr(FALSE, (purge_sys->rseg)->id,
purge_sys->page_no,
@@ -1064,8 +1059,7 @@ trx_purge_fetch_next_rec(
*cell = trx_purge_arr_store_info(purge_sys->purge_trx_no,
purge_sys->purge_undo_no);
- ut_ad(ut_dulint_cmp(purge_sys->purge_trx_no,
- (purge_sys->view)->low_limit_no) < 0);
+ ut_ad(purge_sys->purge_trx_no < purge_sys->view->low_limit_no);
/* The following call will advance the stored values of purge_trx_no
and purge_undo_no, therefore we had to store them first */
@@ -1157,7 +1151,7 @@ trx_purge(
}
}
- purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero,
+ purge_sys->view = read_view_oldest_copy_or_open_new(0,
purge_sys->heap);
mutex_exit(&kernel_mutex);
@@ -1215,8 +1209,8 @@ trx_purge_sys_print(void)
fprintf(stderr, "InnoDB: Purge trx n:o " TRX_ID_FMT
", undo n:o " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(purge_sys->purge_trx_no),
- TRX_ID_PREP_PRINTF(purge_sys->purge_undo_no));
+ (ullint) purge_sys->purge_trx_no,
+ (ullint) purge_sys->purge_undo_no);
fprintf(stderr,
"InnoDB: Purge next stored %lu, page_no %lu, offset %lu,\n"
"InnoDB: Purge hdr_page_no %lu, hdr_offset %lu\n",
diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c
index f50e10ed756..e7e9a008db4 100644
--- a/storage/innobase/trx/trx0rec.c
+++ b/storage/innobase/trx/trx0rec.c
@@ -242,8 +242,8 @@ trx_undo_page_report_insert(
/* Store first some general parameters to the undo log */
*ptr++ = TRX_UNDO_INSERT_REC;
- ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
- ptr += mach_dulint_write_much_compressed(ptr, index->table->id);
+ ptr += mach_ull_write_much_compressed(ptr, trx->undo_no);
+ ptr += mach_ull_write_much_compressed(ptr, index->table->id);
/*----------------------------------------*/
/* Store then the fields required to uniquely determine the record
to be inserted in the clustered index */
@@ -289,7 +289,7 @@ trx_undo_rec_get_pars(
ibool* updated_extern, /*!< out: TRUE if we updated an
externally stored fild */
undo_no_t* undo_no, /*!< out: undo log record number */
- dulint* table_id) /*!< out: table id */
+ table_id_t* table_id) /*!< out: table id */
{
byte* ptr;
ulint type_cmpl;
@@ -309,11 +309,11 @@ trx_undo_rec_get_pars(
*type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1);
*cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT;
- *undo_no = mach_dulint_read_much_compressed(ptr);
- ptr += mach_dulint_get_much_compressed_size(*undo_no);
+ *undo_no = mach_ull_read_much_compressed(ptr);
+ ptr += mach_ull_get_much_compressed_size(*undo_no);
- *table_id = mach_dulint_read_much_compressed(ptr);
- ptr += mach_dulint_get_much_compressed_size(*table_id);
+ *table_id = mach_ull_read_much_compressed(ptr);
+ ptr += mach_ull_get_much_compressed_size(*table_id);
return(ptr);
}
@@ -598,9 +598,9 @@ trx_undo_page_report_modify(
type_cmpl_ptr = ptr;
*ptr++ = (byte) type_cmpl;
- ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
+ ptr += mach_ull_write_much_compressed(ptr, trx->undo_no);
- ptr += mach_dulint_write_much_compressed(ptr, table->id);
+ ptr += mach_ull_write_much_compressed(ptr, table->id);
/*----------------------------------------*/
/* Store the state of the info bits */
@@ -620,16 +620,16 @@ trx_undo_page_report_modify(
by some other trx as it must have committed by now for us to
allow an over-write. */
if (ignore_prefix) {
- ignore_prefix = ut_dulint_cmp(trx_id, trx->id) != 0;
+ ignore_prefix = (trx_id != trx->id);
}
- ptr += mach_dulint_write_compressed(ptr, trx_id);
+ ptr += mach_ull_write_compressed(ptr, trx_id);
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(
index, DATA_ROLL_PTR), &flen);
ut_ad(flen == DATA_ROLL_PTR_LEN);
- ptr += mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field));
+ ptr += mach_ull_write_compressed(ptr, trx_read_roll_ptr(field));
/*----------------------------------------*/
/* Store then the fields required to uniquely determine the
@@ -848,11 +848,11 @@ trx_undo_update_rec_get_sys_cols(
/* Read the values of the system columns */
- *trx_id = mach_dulint_read_compressed(ptr);
- ptr += mach_dulint_get_compressed_size(*trx_id);
+ *trx_id = mach_ull_read_compressed(ptr);
+ ptr += mach_ull_get_compressed_size(*trx_id);
- *roll_ptr = mach_dulint_read_compressed(ptr);
- ptr += mach_dulint_get_compressed_size(*roll_ptr);
+ *roll_ptr = mach_ull_read_compressed(ptr);
+ ptr += mach_ull_get_compressed_size(*roll_ptr);
return(ptr);
}
@@ -1168,7 +1168,7 @@ trx_undo_report_row_operation(
index, otherwise NULL */
roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the
inserted undo log record,
- ut_dulint_zero if BTR_NO_UNDO_LOG
+ 0 if BTR_NO_UNDO_LOG
flag was specified */
{
trx_t* trx;
@@ -1186,7 +1186,7 @@ trx_undo_report_row_operation(
if (flags & BTR_NO_UNDO_LOG_FLAG) {
- *roll_ptr = ut_dulint_zero;
+ *roll_ptr = 0;
return(DB_SUCCESS);
}
@@ -1284,7 +1284,7 @@ trx_undo_report_row_operation(
undo->top_undo_no = trx->undo_no;
undo->guess_block = undo_block;
- UT_DULINT_INC(trx->undo_no);
+ trx->undo_no++;
mutex_exit(&trx->undo_mutex);
@@ -1433,7 +1433,7 @@ trx_undo_prev_version_build(
trx_id_t rec_trx_id;
ulint type;
undo_no_t undo_no;
- dulint table_id;
+ table_id_t table_id;
trx_id_t trx_id;
roll_ptr_t roll_ptr;
roll_ptr_t old_roll_ptr;
@@ -1523,7 +1523,7 @@ trx_undo_prev_version_build(
roll_ptr, info_bits,
NULL, heap, &update);
- if (ut_dulint_cmp(table_id, index->table->id) != 0) {
+ if (UNIV_UNLIKELY(table_id != index->table->id)) {
ptr = NULL;
fprintf(stderr,
@@ -1544,16 +1544,14 @@ trx_undo_prev_version_build(
fprintf(stderr,
"InnoDB: table %s, index %s, n_uniq %lu\n"
"InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
- "InnoDB: undo rec table id %lu %lu,"
- " index table id %lu %lu\n"
+ "InnoDB: undo rec table id %llu,"
+ " index table id %llu\n"
"InnoDB: dump of 150 bytes in undo rec: ",
index->table_name, index->name,
(ulong) dict_index_get_n_unique(index),
undo_rec, (ulong) type, (ulong) cmpl_info,
- (ulong) ut_dulint_get_high(table_id),
- (ulong) ut_dulint_get_low(table_id),
- (ulong) ut_dulint_get_high(index->table->id),
- (ulong) ut_dulint_get_low(index->table->id));
+ (ullint) table_id,
+ (ullint) index->table->id);
ut_print_buf(stderr, undo_rec, 150);
fputs("\n"
"InnoDB: index record ", stderr);
@@ -1564,14 +1562,10 @@ trx_undo_prev_version_build(
fprintf(stderr, "\n"
"InnoDB: Record trx id " TRX_ID_FMT
", update rec trx id " TRX_ID_FMT "\n"
- "InnoDB: Roll ptr in rec %lu %lu, in update rec"
- " %lu %lu\n",
- TRX_ID_PREP_PRINTF(rec_trx_id),
- TRX_ID_PREP_PRINTF(trx_id),
- (ulong) ut_dulint_get_high(old_roll_ptr),
- (ulong) ut_dulint_get_low(old_roll_ptr),
- (ulong) ut_dulint_get_high(roll_ptr),
- (ulong) ut_dulint_get_low(roll_ptr));
+ "InnoDB: Roll ptr in rec " TRX_ID_FMT
+ ", in update rec" TRX_ID_FMT "\n",
+ (ullint) rec_trx_id, (ullint) trx_id,
+ (ullint) old_roll_ptr, (ullint) roll_ptr);
trx_purge_sys_print();
return(DB_ERROR);
diff --git a/storage/innobase/trx/trx0roll.c b/storage/innobase/trx/trx0roll.c
index 4f1a71a5531..42b8a8685ad 100644
--- a/storage/innobase/trx/trx0roll.c
+++ b/storage/innobase/trx/trx0roll.c
@@ -52,7 +52,7 @@ static trx_t* trx_roll_crash_recv_trx = NULL;
/** In crash recovery we set this to the undo n:o of the current trx to be
rolled back. Then we can print how many % the rollback has progressed. */
-static ib_int64_t trx_roll_max_undo_no;
+static undo_no_t trx_roll_max_undo_no;
/** Auxiliary variable which tells the previous progress % we printed */
static ulint trx_roll_progress_printed_pct;
@@ -443,7 +443,7 @@ trx_rollback_active(
ut_a(thr == que_fork_start_command(fork));
trx_roll_crash_recv_trx = trx;
- trx_roll_max_undo_no = ut_conv_dulint_to_longlong(trx->undo_no);
+ trx_roll_max_undo_no = trx->undo_no;
trx_roll_progress_printed_pct = 0;
rows_to_undo = trx_roll_max_undo_no;
@@ -456,7 +456,7 @@ trx_rollback_active(
fprintf(stderr,
" InnoDB: Rolling back trx with id " TRX_ID_FMT ", %lu%s"
" rows to undo\n",
- TRX_ID_PREP_PRINTF(trx->id),
+ (ullint) trx->id,
(ulong) rows_to_undo, unit);
mutex_exit(&kernel_mutex);
@@ -478,8 +478,9 @@ trx_rollback_active(
mutex_exit(&kernel_mutex);
fprintf(stderr,
- "InnoDB: Waiting for rollback of trx id %lu to end\n",
- (ulong) ut_dulint_get_low(trx->id));
+ "InnoDB: Waiting for rollback of trx id "
+ TRX_ID_FMT " to end\n",
+ (ullint) trx->id);
os_thread_sleep(100000);
mutex_enter(&kernel_mutex);
@@ -488,16 +489,15 @@ trx_rollback_active(
mutex_exit(&kernel_mutex);
if (trx_get_dict_operation(trx) != TRX_DICT_OP_NONE
- && !ut_dulint_is_zero(trx->table_id)) {
+ && trx->table_id != 0) {
/* If the transaction was for a dictionary operation, we
drop the relevant table, if it still exists */
fprintf(stderr,
- "InnoDB: Dropping table with id %lu %lu"
+ "InnoDB: Dropping table with id %llu"
" in recovery if it exists\n",
- (ulong) ut_dulint_get_high(trx->table_id),
- (ulong) ut_dulint_get_low(trx->table_id));
+ (ullint) trx->table_id);
table = dict_table_get_on_id_low(trx->table_id);
@@ -521,7 +521,7 @@ trx_rollback_active(
fprintf(stderr, "\nInnoDB: Rolling back of trx id " TRX_ID_FMT
" completed\n",
- TRX_ID_PREP_PRINTF(trx->id));
+ (ullint) trx->id);
mem_heap_free(heap);
trx_roll_crash_recv_trx = NULL;
@@ -574,7 +574,7 @@ loop:
fprintf(stderr,
"InnoDB: Cleaning up trx with id "
TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(trx->id));
+ (ullint) trx->id);
trx_cleanup_at_db_startup(trx);
goto loop;
@@ -710,7 +710,7 @@ trx_undo_arr_store_info(
} else {
n++;
- if (0 == ut_dulint_cmp(cell->undo_no, undo_no)) {
+ if (cell->undo_no == undo_no) {
if (stored_here) {
stored_here->in_use = FALSE;
@@ -754,7 +754,7 @@ trx_undo_arr_remove_info(
cell = trx_undo_arr_get_nth_info(arr, i);
if (cell->in_use
- && 0 == ut_dulint_cmp(cell->undo_no, undo_no)) {
+ && cell->undo_no == undo_no) {
cell->in_use = FALSE;
@@ -769,7 +769,7 @@ trx_undo_arr_remove_info(
/*******************************************************************//**
Gets the biggest undo number in an array.
-@return biggest value, ut_dulint_zero if the array is empty */
+@return biggest value, 0 if the array is empty */
static
undo_no_t
trx_undo_arr_get_biggest(
@@ -784,14 +784,14 @@ trx_undo_arr_get_biggest(
n = 0;
n_used = arr->n_used;
- biggest = ut_dulint_zero;
+ biggest = 0;
for (i = 0;; i++) {
cell = trx_undo_arr_get_nth_info(arr, i);
if (cell->in_use) {
n++;
- if (ut_dulint_cmp(cell->undo_no, biggest) > 0) {
+ if (cell->undo_no > biggest) {
biggest = cell->undo_no;
}
@@ -827,9 +827,9 @@ trx_roll_try_truncate(
if (arr->n_used > 0) {
biggest = trx_undo_arr_get_biggest(arr);
- if (ut_dulint_cmp(biggest, limit) >= 0) {
+ if (biggest >= limit) {
- limit = ut_dulint_add(biggest, 1);
+ limit = biggest + 1;
}
}
@@ -865,9 +865,9 @@ trx_roll_pop_top_rec(
undo->top_page_no, mtr);
offset = undo->top_offset;
- /* fprintf(stderr, "Thread %lu undoing trx %lu undo record %lu\n",
- os_thread_get_curr_id(), ut_dulint_get_low(trx->id),
- ut_dulint_get_low(undo->top_undo_no)); */
+ /* fprintf(stderr, "Thread %lu undoing trx " TRX_ID_FMT
+ " undo record " TRX_ID_FMT "\n",
+ os_thread_get_curr_id(), trx->id, undo->top_undo_no); */
prev_rec = trx_undo_get_prev_rec(undo_page + offset,
undo->hdr_page_no, undo->hdr_offset,
@@ -938,15 +938,14 @@ try_again:
undo = upd_undo;
} else if (!upd_undo || upd_undo->empty) {
undo = ins_undo;
- } else if (ut_dulint_cmp(upd_undo->top_undo_no,
- ins_undo->top_undo_no) > 0) {
+ } else if (upd_undo->top_undo_no > ins_undo->top_undo_no) {
undo = upd_undo;
} else {
undo = ins_undo;
}
if (!undo || undo->empty
- || (ut_dulint_cmp(limit, undo->top_undo_no) > 0)) {
+ || limit > undo->top_undo_no) {
if ((trx->undo_no_arr)->n_used == 0) {
/* Rollback is ending */
@@ -978,7 +977,7 @@ try_again:
undo_no = trx_undo_rec_get_undo_no(undo_rec);
- ut_ad(ut_dulint_cmp(ut_dulint_add(undo_no, 1), trx->undo_no) == 0);
+ ut_ad(undo_no + 1 == trx->undo_no);
/* We print rollback progress info if we are in a crash recovery
and the transaction has at least 1000 row operations to undo. */
@@ -986,8 +985,7 @@ try_again:
if (trx == trx_roll_crash_recv_trx && trx_roll_max_undo_no > 1000) {
progress_pct = 100 - (ulint)
- ((ut_conv_dulint_to_longlong(undo_no) * 100)
- / trx_roll_max_undo_no);
+ ((undo_no * 100) / trx_roll_max_undo_no);
if (progress_pct != trx_roll_progress_printed_pct) {
if (trx_roll_progress_printed_pct == 0) {
fprintf(stderr,
@@ -1090,22 +1088,21 @@ trx_rollback(
/* Initialize the rollback field in the transaction */
- if (sig->type == TRX_SIG_TOTAL_ROLLBACK) {
-
- trx->roll_limit = ut_dulint_zero;
-
- } else if (sig->type == TRX_SIG_ROLLBACK_TO_SAVEPT) {
-
+ switch (sig->type) {
+ case TRX_SIG_TOTAL_ROLLBACK:
+ trx->roll_limit = 0;
+ break;
+ case TRX_SIG_ROLLBACK_TO_SAVEPT:
trx->roll_limit = (sig->savept).least_undo_no;
-
- } else if (sig->type == TRX_SIG_ERROR_OCCURRED) {
-
+ break;
+ case TRX_SIG_ERROR_OCCURRED:
trx->roll_limit = trx->last_sql_stat_start.least_undo_no;
- } else {
+ break;
+ default:
ut_error;
}
- ut_a(ut_dulint_cmp(trx->roll_limit, trx->undo_no) <= 0);
+ ut_a(trx->roll_limit <= trx->undo_no);
trx->pages_undone = 0;
@@ -1269,8 +1266,8 @@ trx_finish_rollback_off_kernel(
#ifdef UNIV_DEBUG
if (lock_print_waits) {
- fprintf(stderr, "Trx %lu rollback finished\n",
- (ulong) ut_dulint_get_low(trx->id));
+ fprintf(stderr, "Trx " TRX_ID_FMT " rollback finished\n",
+ (ullint) trx->id);
}
#endif /* UNIV_DEBUG */
diff --git a/storage/innobase/trx/trx0rseg.c b/storage/innobase/trx/trx0rseg.c
index b458364b05d..740320f68c1 100644
--- a/storage/innobase/trx/trx0rseg.c
+++ b/storage/innobase/trx/trx0rseg.c
@@ -236,8 +236,8 @@ trx_rseg_mem_create(
node_addr.page,
mtr) + node_addr.boffset;
- rseg->last_trx_no = mtr_read_dulint(
- undo_log_hdr + TRX_UNDO_TRX_NO, mtr);
+ rseg->last_trx_no = mach_read_from_8(
+ undo_log_hdr + TRX_UNDO_TRX_NO);
rseg->last_del_marks = mtr_read_ulint(
undo_log_hdr + TRX_UNDO_DEL_MARKS, MLOG_2BYTES, mtr);
} else {
diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c
index e2f0ff6d532..640412c4572 100644
--- a/storage/innobase/trx/trx0sys.c
+++ b/storage/innobase/trx/trx0sys.c
@@ -664,8 +664,8 @@ trx_sys_flush_max_trx_id(void)
sys_header = trx_sysf_get(&mtr);
- mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE,
- trx_sys->max_trx_id, &mtr);
+ mlog_write_ull(sys_header + TRX_SYS_TRX_ID_STORE,
+ trx_sys->max_trx_id, &mtr);
mtr_commit(&mtr);
}
@@ -912,8 +912,7 @@ trx_sysf_create(
sys_header = trx_sysf_get(mtr);
/* Start counting transaction ids from number 1 up */
- mach_write_to_8(sys_header + TRX_SYS_TRX_ID_STORE,
- ut_dulint_create(0, 1));
+ 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
@@ -950,7 +949,7 @@ trx_sys_init_at_db_start(void)
/*==========================*/
{
trx_sysf_t* sys_header;
- ib_int64_t rows_to_undo = 0;
+ ib_uint64_t rows_to_undo = 0;
const char* unit = "";
trx_t* trx;
mtr_t mtr;
@@ -976,12 +975,10 @@ trx_sys_init_at_db_start(void)
to the disk-based header! Thus trx id values will not overlap when
the database is repeatedly started! */
- trx_sys->max_trx_id = ut_dulint_add(
- ut_dulint_align_up(mtr_read_dulint(
- sys_header
- + TRX_SYS_TRX_ID_STORE, &mtr),
- TRX_SYS_TRX_ID_WRITE_MARGIN),
- 2 * TRX_SYS_TRX_ID_WRITE_MARGIN);
+ trx_sys->max_trx_id = 2 * TRX_SYS_TRX_ID_WRITE_MARGIN
+ + ut_uint64_align_up(mach_read_from_8(sys_header
+ + TRX_SYS_TRX_ID_STORE),
+ TRX_SYS_TRX_ID_WRITE_MARGIN);
UT_LIST_INIT(trx_sys->mysql_trx_list);
trx_dummy_sess = sess_open();
@@ -992,9 +989,8 @@ trx_sys_init_at_db_start(void)
for (;;) {
- if ( trx->conc_state != TRX_PREPARED) {
- rows_to_undo += ut_conv_dulint_to_longlong(
- trx->undo_no);
+ if (trx->conc_state != TRX_PREPARED) {
+ rows_to_undo += trx->undo_no;
}
trx = UT_LIST_GET_NEXT(trx_list, trx);
@@ -1017,7 +1013,7 @@ trx_sys_init_at_db_start(void)
(ulong) rows_to_undo, unit);
fprintf(stderr, "InnoDB: Trx id counter is " TRX_ID_FMT "\n",
- TRX_ID_PREP_PRINTF(trx_sys->max_trx_id));
+ (ullint) trx_sys->max_trx_id);
}
UT_LIST_INIT(trx_sys->view_list);
@@ -1061,7 +1057,7 @@ trx_sys_file_format_max_write(
mtr_t mtr;
byte* ptr;
buf_block_t* block;
- ulint tag_value_low;
+ ib_uint64_t tag_value;
mtr_start(&mtr);
@@ -1072,17 +1068,13 @@ trx_sys_file_format_max_write(
file_format_max.name = trx_sys_file_format_id_to_name(format_id);
ptr = buf_block_get_frame(block) + TRX_SYS_FILE_FORMAT_TAG;
- tag_value_low = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW;
+ tag_value = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N;
if (name) {
*name = file_format_max.name;
}
- mlog_write_dulint(
- ptr,
- ut_dulint_create(TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH,
- tag_value_low),
- &mtr);
+ mlog_write_ull(ptr, tag_value, &mtr);
mtr_commit(&mtr);
@@ -1100,8 +1092,7 @@ trx_sys_file_format_max_read(void)
mtr_t mtr;
const byte* ptr;
const buf_block_t* block;
- ulint format_id;
- dulint file_format_id;
+ ib_id_t file_format_id;
/* Since this is called during the startup phase it's safe to
read the value without a covering mutex. */
@@ -1115,16 +1106,15 @@ trx_sys_file_format_max_read(void)
mtr_commit(&mtr);
- format_id = file_format_id.low - TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW;
+ file_format_id -= TRX_SYS_FILE_FORMAT_TAG_MAGIC_N;
- if (file_format_id.high != TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH
- || format_id >= FILE_FORMAT_NAME_N) {
+ if (file_format_id >= FILE_FORMAT_NAME_N) {
/* Either it has never been tagged, or garbage in it. */
return(ULINT_UNDEFINED);
}
- return(format_id);
+ return((ulint) file_format_id);
}
/*****************************************************************//**
@@ -1416,7 +1406,7 @@ trx_sys_read_file_format_id(
byte buf[UNIV_PAGE_SIZE * 2];
page_t* page = ut_align(buf, UNIV_PAGE_SIZE);
const byte* ptr;
- dulint file_format_id;
+ ib_id_t file_format_id;
*format_id = ULINT_UNDEFINED;
@@ -1430,9 +1420,9 @@ trx_sys_read_file_format_id(
if (!success) {
/* The following call prints an error message */
os_file_get_last_error(TRUE);
-
+
ut_print_timestamp(stderr);
-
+
fprintf(stderr,
" ibbackup: Error: trying to read system tablespace file format,\n"
" ibbackup: but could not open the tablespace file %s!\n",
@@ -1449,9 +1439,9 @@ trx_sys_read_file_format_id(
if (!success) {
/* The following call prints an error message */
os_file_get_last_error(TRUE);
-
+
ut_print_timestamp(stderr);
-
+
fprintf(stderr,
" ibbackup: Error: trying to read system table space file format,\n"
" ibbackup: but failed to read the tablespace file %s!\n",
@@ -1465,17 +1455,16 @@ trx_sys_read_file_format_id(
/* get the file format from the page */
ptr = page + TRX_SYS_FILE_FORMAT_TAG;
file_format_id = mach_read_from_8(ptr);
+ file_format_id -= TRX_SYS_FILE_FORMAT_TAG_MAGIC_N;
- *format_id = file_format_id.low - TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW;
-
- if (file_format_id.high != TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH
- || *format_id >= FILE_FORMAT_NAME_N) {
+ if (file_format_id >= FILE_FORMAT_NAME_N) {
/* Either it has never been tagged, or garbage in it. */
- *format_id = ULINT_UNDEFINED;
return(TRUE);
}
-
+
+ *format_id = (ulint) file_format_id;
+
return(TRUE);
}
diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c
index c794671f7be..19e3eb26421 100644
--- a/storage/innobase/trx/trx0trx.c
+++ b/storage/innobase/trx/trx0trx.c
@@ -109,8 +109,8 @@ trx_create(
trx->isolation_level = TRX_ISO_REPEATABLE_READ;
- trx->id = ut_dulint_zero;
- trx->no = ut_dulint_max;
+ trx->id = 0;
+ trx->no = IB_ULONGLONG_MAX;
trx->support_xa = TRUE;
@@ -121,7 +121,7 @@ trx_create(
trx->must_flush_log_later = FALSE;
trx->dict_operation = TRX_DICT_OP_NONE;
- trx->table_id = ut_dulint_zero;
+ trx->table_id = 0;
trx->mysql_thd = NULL;
trx->active_trans = 0;
@@ -137,8 +137,8 @@ trx_create(
trx->rseg = NULL;
- trx->undo_no = ut_dulint_zero;
- trx->last_sql_stat_start.least_undo_no = ut_dulint_zero;
+ trx->undo_no = 0;
+ trx->last_sql_stat_start.least_undo_no = 0;
trx->insert_undo = NULL;
trx->update_undo = NULL;
trx->undo_no_arr = NULL;
@@ -392,9 +392,9 @@ trx_list_insert_ordered(
trx2 = UT_LIST_GET_FIRST(trx_sys->trx_list);
while (trx2 != NULL) {
- if (ut_dulint_cmp(trx->id, trx2->id) >= 0) {
+ if (trx->id >= trx2->id) {
- ut_ad(ut_dulint_cmp(trx->id, trx2->id) == 1);
+ ut_ad(trx->id > trx2->id);
break;
}
trx2 = UT_LIST_GET_NEXT(trx_list, trx2);
@@ -463,7 +463,7 @@ trx_lists_init_at_db_start(void)
TRX_ID_FMT
" was in the"
" XA prepared state.\n",
- TRX_ID_PREP_PRINTF(trx->id));
+ (ullint) trx->id);
if (srv_force_recovery == 0) {
@@ -495,9 +495,9 @@ trx_lists_init_at_db_start(void)
trx->conc_state = TRX_ACTIVE;
/* A running transaction always has the number
- field inited to ut_dulint_max */
+ field inited to IB_ULONGLONG_MAX */
- trx->no = ut_dulint_max;
+ trx->no = IB_ULONGLONG_MAX;
}
if (undo->dict_operation) {
@@ -507,8 +507,7 @@ trx_lists_init_at_db_start(void)
}
if (!undo->empty) {
- trx->undo_no = ut_dulint_add(undo->top_undo_no,
- 1);
+ trx->undo_no = undo->top_undo_no + 1;
}
trx_list_insert_ordered(trx);
@@ -539,8 +538,7 @@ trx_lists_init_at_db_start(void)
"InnoDB: Transaction "
TRX_ID_FMT " was in the"
" XA prepared state.\n",
- TRX_ID_PREP_PRINTF(
- trx->id));
+ (ullint) trx->id);
if (srv_force_recovery == 0) {
@@ -571,9 +569,9 @@ trx_lists_init_at_db_start(void)
/* A running transaction always has
the number field inited to
- ut_dulint_max */
+ IB_ULONGLONG_MAX */
- trx->no = ut_dulint_max;
+ trx->no = IB_ULONGLONG_MAX;
}
trx->rseg = rseg;
@@ -589,11 +587,9 @@ trx_lists_init_at_db_start(void)
trx->update_undo = undo;
if ((!undo->empty)
- && (ut_dulint_cmp(undo->top_undo_no,
- trx->undo_no) >= 0)) {
+ && undo->top_undo_no >= trx->undo_no) {
- trx->undo_no = ut_dulint_add(undo->top_undo_no,
- 1);
+ trx->undo_no = undo->top_undo_no + 1;
}
undo = UT_LIST_GET_NEXT(undo_list, undo);
@@ -655,7 +651,7 @@ trx_start_low(
ut_ad(trx->rseg == NULL);
if (trx->is_purge) {
- trx->id = ut_dulint_zero;
+ trx->id = 0;
trx->conc_state = TRX_ACTIVE;
trx->start_time = time(NULL);
@@ -673,10 +669,10 @@ trx_start_low(
trx->id = trx_sys_get_new_trx_id();
- /* The initial value for trx->no: ut_dulint_max is used in
+ /* The initial value for trx->no: IB_ULONGLONG_MAX is used in
read_view_open_now: */
- trx->no = ut_dulint_max;
+ trx->no = IB_ULONGLONG_MAX;
trx->rseg = rseg;
@@ -941,8 +937,8 @@ trx_commit_off_kernel(
trx->conc_state = TRX_NOT_STARTED;
trx->rseg = NULL;
- trx->undo_no = ut_dulint_zero;
- trx->last_sql_stat_start.least_undo_no = ut_dulint_zero;
+ trx->undo_no = 0;
+ trx->last_sql_stat_start.least_undo_no = 0;
ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);
ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0);
@@ -967,8 +963,8 @@ trx_cleanup_at_db_startup(
trx->conc_state = TRX_NOT_STARTED;
trx->rseg = NULL;
- trx->undo_no = ut_dulint_zero;
- trx->last_sql_stat_start.least_undo_no = ut_dulint_zero;
+ trx->undo_no = 0;
+ trx->last_sql_stat_start.least_undo_no = 0;
UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
}
@@ -1631,7 +1627,7 @@ trx_mark_sql_stat_end(
ut_a(trx);
if (trx->conc_state == TRX_NOT_STARTED) {
- trx->undo_no = ut_dulint_zero;
+ trx->undo_no = 0;
}
trx->last_sql_stat_start.least_undo_no = trx->undo_no;
@@ -1651,7 +1647,7 @@ trx_print(
{
ibool newline;
- fprintf(f, "TRANSACTION " TRX_ID_FMT, TRX_ID_PREP_PRINTF(trx->id));
+ fprintf(f, "TRANSACTION " TRX_ID_FMT, (ullint) trx->id);
switch (trx->conc_state) {
case TRX_NOT_STARTED:
@@ -1735,10 +1731,10 @@ trx_print(
fputs(", holds adaptive hash latch", f);
}
- if (!ut_dulint_is_zero(trx->undo_no)) {
+ if (trx->undo_no != 0) {
newline = TRUE;
- fprintf(f, ", undo log entries %lu",
- (ulong) ut_dulint_get_low(trx->undo_no));
+ fprintf(f, ", undo log entries %llu",
+ (ullint) trx->undo_no);
}
if (newline) {
@@ -1754,11 +1750,11 @@ trx_print(
Compares the "weight" (or size) of two transactions. Transactions that
have edited non-transactional tables are considered heavier than ones
that have not.
-@return <0, 0 or >0; similar to strcmp(3) */
+@return TRUE if weight(a) >= weight(b) */
UNIV_INTERN
-int
-trx_weight_cmp(
-/*===========*/
+ibool
+trx_weight_ge(
+/*==========*/
const trx_t* a, /*!< in: the first transaction to be compared */
const trx_t* b) /*!< in: the second transaction to be compared */
{
@@ -1769,19 +1765,14 @@ trx_weight_cmp(
not edited non-transactional tables. */
a_notrans_edit = a->mysql_thd != NULL
- && thd_has_edited_nontrans_tables(a->mysql_thd);
+ && thd_has_edited_nontrans_tables(a->mysql_thd);
b_notrans_edit = b->mysql_thd != NULL
- && thd_has_edited_nontrans_tables(b->mysql_thd);
-
- if (a_notrans_edit && !b_notrans_edit) {
-
- return(1);
- }
+ && thd_has_edited_nontrans_tables(b->mysql_thd);
- if (!a_notrans_edit && b_notrans_edit) {
+ if (a_notrans_edit != b_notrans_edit) {
- return(-1);
+ return(a_notrans_edit);
}
/* Either both had edited non-transactional tables or both had
@@ -1792,13 +1783,11 @@ trx_weight_cmp(
fprintf(stderr,
"%s TRX_WEIGHT(a): %lld+%lu, TRX_WEIGHT(b): %lld+%lu\n",
__func__,
- ut_conv_dulint_to_longlong(a->undo_no),
- UT_LIST_GET_LEN(a->trx_locks),
- ut_conv_dulint_to_longlong(b->undo_no),
- UT_LIST_GET_LEN(b->trx_locks));
+ a->undo_no, UT_LIST_GET_LEN(a->trx_locks),
+ b->undo_no, UT_LIST_GET_LEN(b->trx_locks));
#endif
- return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b)));
+ return(TRX_WEIGHT(a) >= TRX_WEIGHT(b));
}
/****************************************************************//**
@@ -1980,14 +1969,13 @@ trx_recover_for_mysql(
fprintf(stderr,
" InnoDB: Transaction " TRX_ID_FMT " in"
" prepared state after recovery\n",
- TRX_ID_PREP_PRINTF(trx->id));
+ (ullint) trx->id);
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Transaction contains changes"
- " to %lu rows\n",
- (ulong) ut_conv_dulint_to_longlong(
- trx->undo_no));
+ " to %llu rows\n",
+ (ullint) trx->undo_no);
count++;
@@ -2036,7 +2024,7 @@ trx_get_trx_by_xid(
while (trx) {
/* Compare two X/Open XA transaction id's: their
length should be the same and binary comparison
- of gtrid_lenght+bqual_length bytes should be
+ of gtrid_length+bqual_length bytes should be
the same */
if (xid->gtrid_length == trx->xid.gtrid_length
diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c
index eb5112c4d31..90fc98f419d 100644
--- a/storage/innobase/trx/trx0undo.c
+++ b/storage/innobase/trx/trx0undo.c
@@ -515,7 +515,7 @@ trx_undo_header_create_log(
{
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_CREATE, mtr);
- mlog_catenate_dulint_compressed(mtr, trx_id);
+ mlog_catenate_ull_compressed(mtr, trx_id);
}
#else /* !UNIV_HOTBACKUP */
# define trx_undo_header_create_log(undo_page,trx_id,mtr) ((void) 0)
@@ -687,7 +687,7 @@ trx_undo_insert_header_reuse_log(
{
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_REUSE, mtr);
- mlog_catenate_dulint_compressed(mtr, trx_id);
+ mlog_catenate_ull_compressed(mtr, trx_id);
}
#else /* !UNIV_HOTBACKUP */
# define trx_undo_insert_header_reuse_log(undo_page,trx_id,mtr) ((void) 0)
@@ -707,8 +707,14 @@ trx_undo_parse_page_header(
mtr_t* mtr) /*!< in: mtr or NULL */
{
trx_id_t trx_id;
+ /* Silence a GCC warning about possibly uninitialized variable
+ when mach_ull_parse_compressed() is not inlined. */
+ ut_d(trx_id = 0);
+ /* Declare the variable uninitialized in Valgrind, so that the
+ above initialization will not mask any bugs. */
+ UNIV_MEM_INVALID(&trx_id, sizeof trx_id);
- ptr = mach_dulint_parse_compressed(ptr, end_ptr, &trx_id);
+ ptr = mach_ull_parse_compressed(ptr, end_ptr, &trx_id);
if (ptr == NULL) {
@@ -1098,8 +1104,7 @@ trx_undo_truncate_end(
break;
}
- if (ut_dulint_cmp(trx_undo_rec_get_undo_no(rec), limit)
- >= 0) {
+ if (trx_undo_rec_get_undo_no(rec) >= limit) {
/* Truncate at least this record off, maybe
more */
trunc_here = rec;
@@ -1152,7 +1157,7 @@ trx_undo_truncate_start(
ut_ad(mutex_own(&(rseg->mutex)));
- if (ut_dulint_is_zero(limit)) {
+ if (!limit) {
return;
}
@@ -1174,7 +1179,7 @@ loop:
last_rec = trx_undo_page_get_last_rec(undo_page, hdr_page_no,
hdr_offset);
- if (ut_dulint_cmp(trx_undo_rec_get_undo_no(last_rec), limit) >= 0) {
+ if (trx_undo_rec_get_undo_no(last_rec) >= limit) {
mtr_commit(&mtr);
@@ -1296,7 +1301,7 @@ trx_undo_mem_create_at_db_start(
undo_header = undo_page + offset;
- trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr);
+ trx_id = mach_read_from_8(undo_header + TRX_UNDO_TRX_ID);
xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS,
MLOG_1BYTE, mtr);
@@ -1320,7 +1325,7 @@ trx_undo_mem_create_at_db_start(
undo->dict_operation = mtr_read_ulint(
undo_header + TRX_UNDO_DICT_TRANS, MLOG_1BYTE, mtr);
- undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr);
+ undo->table_id = mach_read_from_8(undo_header + TRX_UNDO_TABLE_ID);
undo->state = state;
undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr);
@@ -1709,7 +1714,7 @@ trx_undo_mark_as_dict_operation(
ut_error;
case TRX_DICT_OP_INDEX:
/* Do not discard the table on recovery. */
- undo->table_id = ut_dulint_zero;
+ undo->table_id = 0;
break;
case TRX_DICT_OP_TABLE:
undo->table_id = trx->table_id;
@@ -1720,8 +1725,8 @@ trx_undo_mark_as_dict_operation(
+ TRX_UNDO_DICT_TRANS,
TRUE, MLOG_1BYTE, mtr);
- mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
- undo->table_id, mtr);
+ mlog_write_ull(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
+ undo->table_id, mtr);
undo->dict_operation = TRUE;
}
diff --git a/storage/innobase/ut/ut0byte.c b/storage/innobase/ut/ut0byte.c
index 4e093f72ce2..535f74b8907 100644
--- a/storage/innobase/ut/ut0byte.c
+++ b/storage/innobase/ut/ut0byte.c
@@ -28,28 +28,3 @@ Created 5/11/1994 Heikki Tuuri
#ifdef UNIV_NONINL
#include "ut0byte.ic"
#endif
-
-/** Zero value for a dulint */
-UNIV_INTERN const dulint ut_dulint_zero = {0, 0};
-
-/** Maximum value for a dulint */
-UNIV_INTERN const dulint ut_dulint_max = {0xFFFFFFFFUL, 0xFFFFFFFFUL};
-
-#ifdef notdefined /* unused code */
-#include "ut0sort.h"
-
-/************************************************************//**
-Sort function for dulint arrays. */
-UNIV_INTERN
-void
-ut_dulint_sort(
-/*===========*/
- dulint* arr, /*!< in/out: array to be sorted */
- dulint* aux_arr,/*!< in/out: auxiliary array (same size as arr) */
- ulint low, /*!< in: low bound of sort interval, inclusive */
- ulint high) /*!< in: high bound of sort interval, noninclusive */
-{
- UT_SORT_FUNCTION_BODY(ut_dulint_sort, arr, aux_arr, low, high,
- ut_dulint_cmp);
-}
-#endif /* notdefined */
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 33c1e092a00..b54b4c6ce49 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -92,6 +92,8 @@ static double *nwghts=_nwghts+5; /* nwghts[i] = -0.5*1.5**i */
#define FTB_FLAG_NO 4
#define FTB_FLAG_WONLY 8
+#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
+
typedef struct st_ftb_expr FTB_EXPR;
struct st_ftb_expr
{
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 7d9b13b7714..937bb6ffe19 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -197,7 +197,8 @@ static int walk_and_push(FT_SUPERDOC *from,
static int FT_DOC_cmp(void *unused __attribute__((unused)),
FT_DOC *a, FT_DOC *b)
{
- return sgn(b->weight - a->weight);
+ double c= b->weight - a->weight;
+ return ((c < 0) ? -1 : (c > 0) ? 1 : 0);
}
diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c
index 8f5779b04ee..663d7869f71 100644
--- a/storage/myisam/ft_parser.c
+++ b/storage/myisam/ft_parser.c
@@ -39,7 +39,7 @@ static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
{
word->weight=LWS_IN_USE;
docstat->sum+=word->weight;
- memcpy_fixed((docstat->list)++,word,sizeof(FT_WORD));
+ memcpy((docstat->list)++, word, sizeof(FT_WORD));
return 0;
}
diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c
index d1548e32870..a2ddb49ecf0 100644
--- a/storage/myisam/ft_update.c
+++ b/storage/myisam/ft_update.c
@@ -83,8 +83,7 @@ uint _mi_ft_segiterator(register FT_SEG_ITERATOR *ftsi)
if (ftsi->seg->flag & HA_BLOB_PART)
{
ftsi->len=_mi_calc_blob_length(ftsi->seg->bit_start,ftsi->pos);
- memcpy_fixed((char*) &ftsi->pos, ftsi->pos+ftsi->seg->bit_start,
- sizeof(char*));
+ memcpy(&ftsi->pos, ftsi->pos+ftsi->seg->bit_start, sizeof(char*));
DBUG_RETURN(1);
}
ftsi->len=ftsi->seg->length;
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 13427130069..6bf01cd63c7 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -52,11 +52,6 @@
#endif
#include "rt_index.h"
-#ifndef USE_RAID
-#define my_raid_create(K, A, B, C, D, E, F, G) mysql_file_create(K, A, B, C, G)
-#define my_raid_delete(K, A, B, C) mysql_file_delete(K, A, B)
-#endif
-
/* Functions defined in this file */
static int check_k_link(MI_CHECK *param, MI_INFO *info,uint nr);
@@ -1577,15 +1572,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file= my_raid_create(mi_key_file_datatmp,
- fn_format(param->temp_filename,
- share->data_file_name, "",
- DATA_TMP_EXT, 2+4),
- 0, param->tmpfile_createflag,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(0))) < 0)
+ if ((new_file= mysql_file_create(mi_key_file_datatmp,
+ fn_format(param->temp_filename,
+ share->data_file_name, "",
+ DATA_TMP_EXT, 2+4),
+ 0, param->tmpfile_createflag,
+ MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
@@ -1751,8 +1743,7 @@ err:
(size_t) info->s->mmaped_length);
info->s->file_map= NULL;
}
- if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
- DATA_TMP_EXT, share->base.raid_chunks,
+ if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1))
@@ -1767,9 +1758,8 @@ err:
if (new_file >= 0)
{
(void) mysql_file_close(new_file, MYF(0));
- (void) my_raid_delete(mi_key_file_datatmp,
- param->temp_filename, info->s->base.raid_chunks,
- MYF(MY_WME));
+ (void) mysql_file_delete(mi_key_file_datatmp,
+ param->temp_filename, MYF(MY_WME));
info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */
}
mi_mark_crashed_on_repair(info);
@@ -2011,7 +2001,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
(void) mysql_file_close(share->kfile, MYF(MY_WME));
share->kfile = -1;
(void) mysql_file_close(new_file, MYF(MY_WME));
- if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0,
+ if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT,
MYF(0)) ||
mi_open_keyfile(share))
goto err2;
@@ -2141,18 +2131,9 @@ err:
*/
int change_to_newfile(const char * filename, const char * old_ext,
- const char * new_ext,
- uint raid_chunks __attribute__((unused)),
- myf MyFlags)
+ const char * new_ext, myf MyFlags)
{
char old_filename[FN_REFLEN],new_filename[FN_REFLEN];
-#ifdef USE_RAID
- if (raid_chunks)
- return my_raid_redel(fn_format(old_filename,filename,"",old_ext,2+4),
- fn_format(new_filename,filename,"",new_ext,2+4),
- raid_chunks,
- MYF(MY_WME | MY_LINK_WARNING | MyFlags));
-#endif
/* Get real path to filename */
(void) fn_format(old_filename,filename,"",old_ext,2+4+32);
return my_redel(old_filename,
@@ -2293,15 +2274,12 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file= my_raid_create(mi_key_file_datatmp,
- fn_format(param->temp_filename,
- share->data_file_name, "",
- DATA_TMP_EXT, 2+4),
- 0, param->tmpfile_createflag,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(0))) < 0)
+ if ((new_file= mysql_file_create(mi_key_file_datatmp,
+ fn_format(param->temp_filename,
+ share->data_file_name, "",
+ DATA_TMP_EXT, 2+4),
+ 0, param->tmpfile_createflag,
+ MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
@@ -2527,7 +2505,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
skr < share->base.reloc*share->base.min_pack_length)
skr=share->base.reloc*share->base.min_pack_length;
#endif
- if (skr != sort_info.filelength && !info->s->base.raid_type)
+ if (skr != sort_info.filelength)
if (mysql_file_chsize(info->dfile, skr, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of datafile, error: %d",
@@ -2565,8 +2543,7 @@ err:
{
mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1;
- if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
- DATA_TMP_EXT, share->base.raid_chunks,
+ if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1))
@@ -2580,9 +2557,8 @@ err:
if (new_file >= 0)
{
(void) mysql_file_close(new_file, MYF(0));
- (void) my_raid_delete(mi_key_file_datatmp,
- param->temp_filename, share->base.raid_chunks,
- MYF(MY_WME));
+ (void) mysql_file_delete(mi_key_file_datatmp,
+ param->temp_filename, MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
if (unlikely(mi_open_datafile(info, share, name, -1)))
param->retry_repair= 0; /* Safety */
@@ -2751,16 +2727,12 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file= my_raid_create(mi_key_file_datatmp,
- fn_format(param->temp_filename,
- share->data_file_name, "",
- DATA_TMP_EXT,
- 2+4),
- 0, param->tmpfile_createflag,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(0))) < 0)
+ if ((new_file= mysql_file_create(mi_key_file_datatmp,
+ fn_format(param->temp_filename,
+ share->data_file_name, "",
+ DATA_TMP_EXT, 2+4),
+ 0, param->tmpfile_createflag,
+ MYF(0))) < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
param->temp_filename);
@@ -3055,7 +3027,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
skr < share->base.reloc*share->base.min_pack_length)
skr=share->base.reloc*share->base.min_pack_length;
#endif
- if (skr != sort_info.filelength && !info->s->base.raid_type)
+ if (skr != sort_info.filelength)
if (mysql_file_chsize(info->dfile, skr, 0, MYF(0)))
mi_check_print_warning(param,
"Can't change size of datafile, error: %d",
@@ -3105,8 +3077,7 @@ err:
{
mysql_file_close(new_file, MYF(0));
info->dfile=new_file= -1;
- if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
- DATA_TMP_EXT, share->base.raid_chunks,
+ if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
mi_open_datafile(info,share,name,-1))
@@ -3120,9 +3091,8 @@ err:
if (new_file >= 0)
{
(void) mysql_file_close(new_file, MYF(0));
- (void) my_raid_delete(mi_key_file_datatmp,
- param->temp_filename, share->base.raid_chunks,
- MYF(MY_WME));
+ (void) mysql_file_delete(mi_key_file_datatmp,
+ param->temp_filename, MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
if (unlikely(mi_open_datafile(info, share, name, -1)))
param->retry_repair= 0; /* Safety */
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index 4a91c2d939b..46c61eb4709 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -549,11 +549,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.base.pack_bits=packed;
share.base.fields=fields;
share.base.pack_fields=packed;
-#ifdef USE_RAID
- share.base.raid_type=ci->raid_type;
- share.base.raid_chunks=ci->raid_chunks;
- share.base.raid_chunksize=ci->raid_chunksize;
-#endif
/* max_data_file_length and max_key_file_length are recalculated on open */
if (options & HA_OPTION_TMP_TABLE)
@@ -642,20 +637,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (!(flags & HA_DONT_TOUCH_DATA))
{
-#ifdef USE_RAID
- if (share.base.raid_type)
- {
- (void) fn_format(filename, name, "", MI_NAME_DEXT,
- MY_UNPACK_FILENAME | MY_APPEND_EXT);
- if ((dfile=my_raid_create(filename, 0, create_mode,
- share.base.raid_type,
- share.base.raid_chunks,
- share.base.raid_chunksize,
- MYF(MY_WME | MY_RAID))) < 0)
- goto err;
- }
- else
-#endif
{
if (ci->data_file_name)
{
@@ -841,7 +822,6 @@ err:
(void) mysql_file_close(dfile, MYF(0));
/* fall through */
case 2:
- /* QQ: Tõnu should add a call to my_raid_delete() here */
if (! (flags & HA_DONT_TOUCH_DATA))
mysql_file_delete_with_symlink(mi_key_file_dfile,
fn_format(filename, name, "", MI_NAME_DEXT,
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c
index 58a60a760aa..a05a2ad6237 100644
--- a/storage/myisam/mi_delete_table.c
+++ b/storage/myisam/mi_delete_table.c
@@ -22,40 +22,11 @@
int mi_delete_table(const char *name)
{
char from[FN_REFLEN];
-#ifdef USE_RAID
- uint raid_type=0,raid_chunks=0;
-#endif
DBUG_ENTER("mi_delete_table");
#ifdef EXTRA_DEBUG
check_table_is_closed(name,"delete");
#endif
-#ifdef USE_RAID
- {
- MI_INFO *info;
- /*
- When built with RAID support, we need to determine if this table
- makes use of the raid feature. If yes, we need to remove all raid
- chunks. This is done with my_raid_delete(). Unfortunately it is
- necessary to open the table just to check this. We use
- 'open_for_repair' to be able to open even a crashed table. If even
- this open fails, we assume no raid configuration for this table
- and try to remove the normal data file only. This may however
- leave the raid chunks behind.
- */
- if (!(info= mi_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
- raid_type= 0;
- else
- {
- raid_type= info->s->base.raid_type;
- raid_chunks= info->s->base.raid_chunks;
- mi_close(info);
- }
- }
-#ifdef EXTRA_DEBUG
- check_table_is_closed(name,"delete");
-#endif
-#endif /* USE_RAID */
fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
@@ -73,10 +44,6 @@ int mi_delete_table(const char *name)
DBUG_RETURN(my_errno);
}
fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-#ifdef USE_RAID
- if (raid_type)
- DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0);
-#endif
if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
{
/*
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 59b895b5e64..f429edd2759 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -283,13 +283,6 @@ int _mi_write_blob_record(MI_INFO *info, const uchar *record)
MI_DYN_DELETE_BLOCK_HEADER+1);
reclength= (info->s->base.pack_reclength +
_my_calc_total_blob_length(info,record)+ extra);
-#ifdef NOT_USED /* We now support big rows */
- if (reclength > MI_DYN_MAX_ROW_LENGTH)
- {
- my_errno=HA_ERR_TO_BIG_ROW;
- return -1;
- }
-#endif
if (!(rec_buff=(uchar*) my_alloca(reclength)))
{
my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */
@@ -317,13 +310,6 @@ int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const uchar *record)
MI_DYN_DELETE_BLOCK_HEADER);
reclength= (info->s->base.pack_reclength+
_my_calc_total_blob_length(info,record)+ extra);
-#ifdef NOT_USED /* We now support big rows */
- if (reclength > MI_DYN_MAX_ROW_LENGTH)
- {
- my_errno=HA_ERR_TO_BIG_ROW;
- return -1;
- }
-#endif
if (!(rec_buff=(uchar*) my_alloca(reclength)))
{
my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */
@@ -1009,7 +995,7 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to,
char *temp_pos;
size_t tmp_length=length-portable_sizeof_char_ptr;
memcpy((uchar*) to,from,tmp_length);
- memcpy_fixed(&temp_pos,from+tmp_length,sizeof(char*));
+ memcpy(&temp_pos,from+tmp_length,sizeof(char*));
memcpy(to+tmp_length,temp_pos,(size_t) blob->length);
to+=tmp_length+blob->length;
}
@@ -1324,9 +1310,9 @@ ulong _mi_rec_unpack(register MI_INFO *info, register uchar *to, uchar *from,
from_left - size_length < blob_length ||
from_left - size_length - blob_length < min_pack_length)
goto err;
- memcpy((uchar*) to,(uchar*) from,(size_t) size_length);
+ memcpy(to, from, (size_t) size_length);
from+=size_length;
- memcpy_fixed((uchar*) to+size_length,(uchar*) &from,sizeof(char*));
+ memcpy(to+size_length, &from, sizeof(char*));
from+=blob_length;
}
else
diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c
index 3f445ebf44d..bce42b64e99 100644
--- a/storage/myisam/mi_key.c
+++ b/storage/myisam/mi_key.c
@@ -139,7 +139,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
else if (keyseg->flag & HA_BLOB_PART)
{
uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
- memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*));
+ memcpy(&pos,pos+keyseg->bit_start,sizeof(char*));
set_if_smaller(length,tmp_length);
FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length);
diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c
index f6bbaab1f87..5af4a057a95 100644
--- a/storage/myisam/mi_log.c
+++ b/storage/myisam/mi_log.c
@@ -149,7 +149,7 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info,
blob != end ;
blob++)
{
- memcpy_fixed((uchar*) &pos, record+blob->offset+blob->pack_length,
+ memcpy(&pos, record+blob->offset+blob->pack_length,
sizeof(char*));
(void) mysql_file_write(myisam_log_file, pos, blob->length, MYF(0));
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 5b3da9841b8..e3c29909067 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -260,25 +260,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
set_if_smaller(max_data_file_length, INT_MAX32);
set_if_smaller(max_key_file_length, INT_MAX32);
#endif
-#if USE_RAID && SYSTEM_SIZEOF_OFF_T == 4
- set_if_smaller(max_key_file_length, INT_MAX32);
- if (!share->base.raid_type)
- {
- set_if_smaller(max_data_file_length, INT_MAX32);
- }
- else
- {
- set_if_smaller(max_data_file_length,
- (ulonglong) share->base.raid_chunks << 31);
- }
-#elif !defined(USE_RAID)
- if (share->base.raid_type)
- {
- DBUG_PRINT("error",("Table uses RAID but we don't have RAID support"));
- my_errno=HA_ERR_UNSUPPORTED;
- goto err;
- }
-#endif
share->base.max_data_file_length=(my_off_t) max_data_file_length;
share->base.max_key_file_length=(my_off_t) max_key_file_length;
@@ -877,7 +858,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
key_blocks=state->header.max_block_size_index;
DBUG_ENTER("mi_state_info_write");
- memcpy_fixed(ptr,&state->header,sizeof(state->header));
+ memcpy(ptr, &state->header, sizeof(state->header));
ptr+=sizeof(state->header);
/* open_count must be first because of _mi_mark_file_changed ! */
@@ -936,7 +917,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite)
uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state)
{
uint i,keys,key_parts,key_blocks;
- memcpy_fixed(&state->header,ptr, sizeof(state->header));
+ memcpy(&state->header, ptr, sizeof(state->header));
ptr +=sizeof(state->header);
keys=(uint) state->header.keys;
key_parts=mi_uint2korr(state->header.key_parts);
@@ -1036,10 +1017,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base)
mi_int2store(ptr,base->max_key_length); ptr +=2;
mi_int2store(ptr,base->extra_alloc_bytes); ptr +=2;
*ptr++= base->extra_alloc_procent;
- *ptr++= base->raid_type;
- mi_int2store(ptr,base->raid_chunks); ptr +=2;
- mi_int4store(ptr,base->raid_chunksize); ptr +=4;
- bzero(ptr,6); ptr +=6; /* extra */
+ bzero(ptr,13); ptr +=13; /* extra */
return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
@@ -1070,17 +1048,8 @@ uchar *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base)
base->max_key_length = mi_uint2korr(ptr); ptr +=2;
base->extra_alloc_bytes = mi_uint2korr(ptr); ptr +=2;
base->extra_alloc_procent = *ptr++;
- base->raid_type= *ptr++;
- base->raid_chunks= mi_uint2korr(ptr); ptr +=2;
- base->raid_chunksize= mi_uint4korr(ptr); ptr +=4;
- /* TO BE REMOVED: Fix for old RAID files */
- if (base->raid_type == 0)
- {
- base->raid_chunks=0;
- base->raid_chunksize=0;
- }
- ptr+=6;
+ ptr+=13;
return ptr;
}
@@ -1223,7 +1192,7 @@ uchar *mi_recinfo_read(uchar *ptr, MI_COLUMNDEF *recinfo)
}
/**************************************************************************
-Open data file with or without RAID
+Open data file.
We can't use dup() here as the data file descriptors need to have different
active seek-positions.
@@ -1251,20 +1220,8 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name,
data_name= real_data_name;
}
}
-#ifdef USE_RAID
- if (share->base.raid_type)
- {
- info->dfile=my_raid_open(data_name,
- share->mode | O_SHARE,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(MY_WME | MY_RAID));
- }
- else
-#endif
- info->dfile= mysql_file_open(mi_key_file_dfile,
- data_name, share->mode | O_SHARE, MYF(MY_WME));
+ info->dfile= mysql_file_open(mi_key_file_dfile,
+ data_name, share->mode | O_SHARE, MYF(MY_WME));
return info->dfile >= 0 ? 0 : 1;
}
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index 0ba495fdd68..d8d892a5bc9 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -1051,8 +1051,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff,
}
decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length);
_my_store_blob_length((uchar*) to,pack_length,length);
- memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos,
- sizeof(char*));
+ memcpy((char*) to+pack_length, &bit_buff->blob_pos, sizeof(char*));
bit_buff->blob_pos+=length;
}
}
diff --git a/storage/myisam/mi_rename.c b/storage/myisam/mi_rename.c
index 56ccb333d03..455d45cecfe 100644
--- a/storage/myisam/mi_rename.c
+++ b/storage/myisam/mi_rename.c
@@ -22,28 +22,12 @@
int mi_rename(const char *old_name, const char *new_name)
{
char from[FN_REFLEN],to[FN_REFLEN];
-#ifdef USE_RAID
- uint raid_type=0,raid_chunks=0;
-#endif
DBUG_ENTER("mi_rename");
#ifdef EXTRA_DEBUG
check_table_is_closed(old_name,"rename old_table");
check_table_is_closed(new_name,"rename new table2");
#endif
-#ifdef USE_RAID
- {
- MI_INFO *info;
- if (!(info=mi_open(old_name, O_RDONLY, 0)))
- DBUG_RETURN(my_errno);
- raid_type = info->s->base.raid_type;
- raid_chunks = info->s->base.raid_chunks;
- mi_close(info);
- }
-#ifdef EXTRA_DEBUG
- check_table_is_closed(old_name,"rename raidcheck");
-#endif
-#endif /* USE_RAID */
fn_format(from,old_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
@@ -51,11 +35,6 @@ int mi_rename(const char *old_name, const char *new_name)
DBUG_RETURN(my_errno);
fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-#ifdef USE_RAID
- if (raid_type)
- DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno :
- 0);
-#endif
DBUG_RETURN(mysql_file_rename_with_symlink(mi_key_file_dfile,
from, to,
MYF(MY_WME)) ? my_errno : 0);
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index baa01a507eb..073b127f1a3 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -38,7 +38,6 @@ uint myisam_concurrent_insert= 2;
uint myisam_concurrent_insert= 0;
#endif
ulonglong myisam_max_temp_length= MAX_FILE_SIZE;
-ulong myisam_bulk_insert_tree_size=8192*1024;
ulong myisam_data_pointer_size=4;
ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0;
diff --git a/storage/myisam/mi_statrec.c b/storage/myisam/mi_statrec.c
index 74fca5902f5..f83afa3c886 100644
--- a/storage/myisam/mi_statrec.c
+++ b/storage/myisam/mi_statrec.c
@@ -273,7 +273,12 @@ int _mi_read_rnd_static_record(MI_INFO *info, uchar *buf,
DBUG_RETURN(error);
}
- /* Read record with cacheing */
+ /*
+ Read record with caching. If my_b_read() returns TRUE, less than the
+ requested bytes have been read. In this case rec_cache.error is
+ either -1 for a read error, or contains the number of bytes copied
+ into the buffer.
+ */
error=my_b_read(&info->rec_cache,(uchar*) buf,share->base.reclength);
if (info->s->base.pack_reclength != info->s->base.reclength && !error)
{
@@ -293,8 +298,17 @@ int _mi_read_rnd_static_record(MI_INFO *info, uchar *buf,
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
DBUG_RETURN(0);
}
- /* my_errno should be set if rec_cache.error == -1 */
+ /* error is TRUE. my_errno should be set if rec_cache.error == -1 */
if (info->rec_cache.error != -1 || my_errno == 0)
- my_errno=HA_ERR_WRONG_IN_RECORD;
+ {
+ /*
+ If we could not get a full record, we either have a broken record,
+ or are at end of file.
+ */
+ if (info->rec_cache.error == 0)
+ my_errno= HA_ERR_END_OF_FILE;
+ else
+ my_errno= HA_ERR_WRONG_IN_RECORD;
+ }
DBUG_RETURN(my_errno); /* Something wrong (EOF?) */
}
diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c
index 742864fe241..f89f2a8d21d 100644
--- a/storage/myisam/mi_test1.c
+++ b/storage/myisam/mi_test1.c
@@ -411,7 +411,7 @@ static void create_record(uchar *record,uint rownr)
tmp=strlen((char*) blob_key);
int4store(pos,tmp);
ptr=blob_key;
- memcpy_fixed(pos+4,&ptr,sizeof(char*));
+ memcpy(pos+4, &ptr, sizeof(char*));
pos+=recinfo[1].length;
}
else if (recinfo[1].type == FIELD_VARCHAR)
@@ -439,7 +439,7 @@ static void create_record(uchar *record,uint rownr)
tmp=strlen((char*) blob_record);
int4store(pos,tmp);
ptr=blob_record;
- memcpy_fixed(pos+4,&ptr,sizeof(char*));
+ memcpy(pos+4, &ptr, sizeof(char*));
}
else if (recinfo[2].type == FIELD_VARCHAR)
{
@@ -468,10 +468,10 @@ static void update_record(uchar *record)
uchar *column,*ptr;
int length;
length=uint4korr(pos); /* Long blob */
- memcpy_fixed(&column,pos+4,sizeof(char*));
+ memcpy(&column, pos+4, sizeof(char*));
memcpy(blob_key,column,length); /* Move old key */
ptr=blob_key;
- memcpy_fixed(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */
+ memcpy(pos+4, &ptr, sizeof(char*)); /* Store pointer to new key */
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
default_charset_info->cset->casedn(default_charset_info,
(char*) blob_key, length,
@@ -501,13 +501,13 @@ static void update_record(uchar *record)
uchar *column;
int length;
length=uint4korr(pos);
- memcpy_fixed(&column,pos+4,sizeof(char*));
+ memcpy(&column, pos+4, sizeof(char*));
memcpy(blob_record,column,length);
bfill(blob_record+length,20,'.'); /* Make it larger */
length+=20;
int4store(pos,length);
column= blob_record;
- memcpy_fixed(pos+4,&column,sizeof(char*));
+ memcpy(pos+4, &column, sizeof(char*));
}
else if (recinfo[2].type == FIELD_VARCHAR)
{
diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
index 513b390ee68..127d93b5433 100644
--- a/storage/myisam/mi_test2.c
+++ b/storage/myisam/mi_test2.c
@@ -1030,7 +1030,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer)
for (i=0 ; i < length ; i++)
(*blob_buffer)[i]=(char) (length+i);
int4store(blob_pos,length);
- memcpy_fixed(blob_pos+4,(char*) blob_buffer,sizeof(char*));
+ memcpy(blob_pos+4, blob_buffer, sizeof(char*));
}
else
{
diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c
index bf36d8df7f4..c03a34df227 100644
--- a/storage/myisam/mi_test3.c
+++ b/storage/myisam/mi_test3.c
@@ -458,7 +458,7 @@ int test_update(MI_INFO *file,int id,int lock_type)
}
}
}
- memcpy_fixed(new_record.id,record.id,sizeof(record.id));
+ memcpy(new_record.id, record.id, sizeof(record.id));
tmp=rnd(20000)+40000;
int4store(new_record.nr,tmp);
if (!mi_update(file,record.id,new_record.id))
diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c
index fdba84a2e67..cee159951de 100644
--- a/storage/myisam/mi_unique.c
+++ b/storage/myisam/mi_unique.c
@@ -111,7 +111,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *record)
else if (keyseg->flag & HA_BLOB_PART)
{
uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
- memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*));
+ memcpy(&pos, pos+keyseg->bit_start, sizeof(char*));
if (!length || length > tmp_length)
length=tmp_length; /* The whole blob */
}
@@ -206,8 +206,8 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b,
set_if_smaller(a_length, keyseg->length);
set_if_smaller(b_length, keyseg->length);
}
- memcpy_fixed((uchar*) &pos_a,pos_a+keyseg->bit_start,sizeof(char*));
- memcpy_fixed((uchar*) &pos_b,pos_b+keyseg->bit_start,sizeof(char*));
+ memcpy(&pos_a, pos_a+keyseg->bit_start, sizeof(char*));
+ memcpy(&pos_b, pos_b+keyseg->bit_start, sizeof(char*));
}
if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 ||
type == HA_KEYTYPE_VARTEXT2)
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index f2d43585eef..bd56bb04f65 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -61,11 +61,6 @@ int mi_write(MI_INFO *info, uchar *record)
if (_mi_readinfo(info,F_WRLCK,1))
DBUG_RETURN(my_errno);
dont_break(); /* Dont allow SIGHUP or SIGINT */
-#if !defined(NO_LOCKING) && defined(USE_RECORD_LOCK)
- if (!info->locked && my_lock(info->dfile,F_WRLCK,0L,F_TO_EOF,
- MYF(MY_SEEK_NOT_DONE) | info->lock_wait))
- goto err;
-#endif
filepos= ((share->state.dellink != HA_OFFSET_ERROR &&
!info->append_insert_at_end) ?
share->state.dellink :
diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c
index 4718abc3481..1c534fe8d02 100644
--- a/storage/myisam/myisam_ftdump.c
+++ b/storage/myisam/myisam_ftdump.c
@@ -46,7 +46,7 @@ static struct my_option my_long_options[] =
{"stats", 's', "Report global stats.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Be verbose.",
- (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ &verbose, &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index e1cedf6bc31..4df76e31872 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -27,12 +27,6 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
-SET_STACK_SIZE(9000) /* Minimum stack size for program */
-
-#ifndef USE_RAID
-#define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G)
-#define my_raid_delete(A,B,C) my_delete(A,B)
-#endif
static uint decode_bits;
static char **default_argv;
@@ -782,7 +776,6 @@ static int myisamchk(MI_CHECK *param, char * filename)
{
int error,lock_type,recreate;
int rep_quick= param->testflag & (T_QUICK | T_FORCE_UNIQUENESS);
- uint raid_chunks;
MI_INFO *info;
File datafile;
char llbuff[22],llbuff2[22];
@@ -844,7 +837,6 @@ static int myisamchk(MI_CHECK *param, char * filename)
share->options&= ~HA_OPTION_READ_ONLY_DATA; /* We are modifing it */
share->tot_locks-= share->r_locks;
share->r_locks=0;
- raid_chunks=share->base.raid_chunks;
/*
Skip the checking of the file if:
@@ -1013,9 +1005,7 @@ static int myisamchk(MI_CHECK *param, char * filename)
if (param->out_flag & O_NEW_DATA)
{ /* Change temp file to org file */
(void) my_close(info->dfile,MYF(MY_WME)); /* Close new file */
- error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT,
- raid_chunks,
- MYF(0));
+ error|=change_to_newfile(filename, MI_NAME_DEXT, DATA_TMP_EXT, MYF(0));
if (mi_open_datafile(info,info->s, NULL, -1))
error=1;
param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
@@ -1146,12 +1136,10 @@ end2:
{
if (param->out_flag & O_NEW_DATA)
error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT,
- raid_chunks,
((param->testflag & T_BACKUP_DATA) ?
MYF(MY_REDEL_MAKE_BACKUP) : MYF(0)));
if (param->out_flag & O_NEW_INDEX)
- error|=change_to_newfile(filename,MI_NAME_IEXT,INDEX_TMP_EXT,0,
- MYF(0));
+ error|=change_to_newfile(filename, MI_NAME_IEXT, INDEX_TMP_EXT, MYF(0));
}
(void) fflush(stdout); (void) fflush(stderr);
if (param->error_printed)
@@ -1247,16 +1235,9 @@ static void descript(MI_CHECK *param, register MI_INFO *info, char * name)
share->base.auto_key,
llstr(share->state.auto_increment,llbuff));
}
- if (share->base.raid_type)
- {
- printf("RAID: Type: %u Chunks: %u Chunksize: %lu\n",
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize);
- }
if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
printf("Checksum: %23s\n",llstr(info->state->checksum,llbuff));
-;
+
if (share->options & HA_OPTION_DELAY_KEY_WRITE)
printf("Keys are only flushed at close\n");
@@ -1527,14 +1508,11 @@ static int mi_sort_records(MI_CHECK *param,
goto err;
}
fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32);
- new_file=my_raid_create(fn_format(param->temp_filename,
- param->temp_filename,"",
- DATA_TMP_EXT,2+4),
- 0,param->tmpfile_createflag,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(0));
+ new_file= my_create(fn_format(param->temp_filename,
+ param->temp_filename, "",
+ DATA_TMP_EXT, 2+4),
+ 0, param->tmpfile_createflag,
+ MYF(0));
if (new_file < 0)
{
mi_check_print_error(param,"Can't create new tempfile: '%s'",
@@ -1609,8 +1587,7 @@ err:
{
(void) end_io_cache(&info->rec_cache);
(void) my_close(new_file,MYF(MY_WME));
- (void) my_raid_delete(param->temp_filename, share->base.raid_chunks,
- MYF(MY_WME));
+ (void) my_delete(param->temp_filename, MYF(MY_WME));
}
if (temp_buff)
{
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 130a96bc9e0..c7f0cb27a40 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -26,8 +26,9 @@
#endif
#include <mysql/psi/mysql_file.h>
-#if defined(my_write) && !defined(MAP_TO_USE_RAID)
-#undef my_write /* undef map from my_nosys; We need test-if-disk full */
+/* undef map from my_nosys; We need test-if-disk full */
+#if defined(my_write)
+#undef my_write
#endif
typedef struct st_mi_status_info
@@ -130,9 +131,6 @@ typedef struct st_mi_base_info
/* Extra allocation when using dynamic record format */
uint extra_alloc_bytes;
uint extra_alloc_procent;
- /* Info about raid */
- uint raid_type,raid_chunks;
- ulong raid_chunksize;
/* The following are from the header */
uint key_parts,all_key_parts;
} MI_BASE_INFO;
@@ -544,10 +542,6 @@ void _mi_store_static_key(MI_KEYDEF *keyinfo, uchar *key_pos,
MI_KEY_PARAM *s_temp);
void _mi_store_var_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos,
MI_KEY_PARAM *s_temp);
-#ifdef NOT_USED
-void _mi_store_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos,
- MI_KEY_PARAM *s_temp);
-#endif
void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos,
MI_KEY_PARAM *s_temp);
diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
index d3da0eab22c..84743b8da51 100644
--- a/storage/myisam/myisamlog.c
+++ b/storage/myisam/myisamlog.c
@@ -619,7 +619,7 @@ static int examine_log(char * file_name, char **table_names)
case MI_LOG_LOCK:
if (my_b_read(&cache,(uchar*) head,sizeof(lock_command)))
goto err;
- memcpy_fixed(&lock_command,head,sizeof(lock_command));
+ memcpy(&lock_command, head, sizeof(lock_command));
if (verbose && !record_pos_file &&
(!table_names[0] || (curr_file_info && curr_file_info->used)))
printf_log("%s: %s(%d) -> %d\n",FILENAME(curr_file_info),
@@ -728,7 +728,7 @@ static void fix_blob_pointers(MI_INFO *info, uchar *record)
blob != end ;
blob++)
{
- memcpy_fixed(record+blob->offset+blob->pack_length,&pos,sizeof(char*));
+ memcpy(record+blob->offset+blob->pack_length, &pos, sizeof(char*));
pos+=_mi_calc_blob_length(blob->pack_length,record+blob->offset);
}
}
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index 4cd305fdc69..84a7f2a1ba9 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -1040,7 +1040,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
{
uint field_length=count->field_length -portable_sizeof_char_ptr;
ulong blob_length= _mi_calc_blob_length(field_length, start_pos);
- memcpy_fixed((char*) &pos, start_pos+field_length,sizeof(char*));
+ memcpy(&pos, start_pos+field_length, sizeof(char*));
end_pos=pos+blob_length;
tot_blob_length+=blob_length;
set_if_bigger(count->max_length,blob_length);
@@ -1889,7 +1889,7 @@ static uint join_same_trees(HUFF_COUNTS *huff_counts, uint trees)
i->tree->tree_pack_length+j->tree->tree_pack_length+
ALLOWED_JOIN_DIFF)
{
- memcpy_fixed((uchar*) i->counts,(uchar*) count.counts,
+ memcpy(i->counts, count.counts,
sizeof(count.counts[0])*256);
my_free(j->tree->element_buffer);
j->tree->element_buffer=0;
@@ -2040,7 +2040,7 @@ static int write_header(PACK_MRG_INFO *mrg,uint head_length,uint trees,
uchar *buff= (uchar*) file_buffer.pos;
bzero(buff,HEAD_LENGTH);
- memcpy_fixed(buff,myisam_pack_file_magic,4);
+ memcpy(buff,myisam_pack_file_magic,4);
int4store(buff+4,head_length);
int4store(buff+8, mrg->min_pack_length);
int4store(buff+12,mrg->max_pack_length);
@@ -2697,8 +2697,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
DBUG_PRINT("fields", ("FIELD_BLOB %lu bytes, bits: %2u",
blob_length, count->length_bits));
write_bits(blob_length,count->length_bits);
- memcpy_fixed(&blob,end_pos-portable_sizeof_char_ptr,
- sizeof(char*));
+ memcpy(&blob, end_pos-portable_sizeof_char_ptr, sizeof(char*));
blob_end=blob+blob_length;
/* Encode the blob bytes. */
for ( ; blob < blob_end ; blob++)
diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c
index 4a9b61605d9..7233300c539 100644
--- a/storage/myisam/rt_test.c
+++ b/storage/myisam/rt_test.c
@@ -366,25 +366,6 @@ static int read_with_pos (MI_INFO * file,int silent)
}
-#ifdef NOT_USED
-static void bprint_record(char * record,
- my_off_t offs __attribute__((unused)),
- const char * tail)
-{
- int i;
- char * pos;
- i=(unsigned char)record[0];
- printf("%02X ",i);
-
- for( pos=record+1, i=0; i<32; i++,pos++){
- int b=(unsigned char)*pos;
- printf("%02X",b);
- }
- printf("%s",tail);
-}
-#endif
-
-
static void print_record(uchar * record,
my_off_t offs __attribute__((unused)),
const char * tail)
@@ -424,30 +405,6 @@ static void create_record1(uchar *record,uint rownr)
}
}
-#ifdef NOT_USED
-
-static void create_record0(uchar *record,uint rownr)
-{
- int i;
- char * pos;
- double c=rownr+10;
- double c0=0;
-
- bzero((char*) record,MAX_REC_LENGTH);
- record[0]=0x01; /* DEL marker */
-
- for ( pos=record+1, i=0; i<ndims; i++)
- {
- memcpy(pos,&c0,sizeof(c0));
- float8store(pos,c0);
- pos+=sizeof(c0);
- memcpy(pos,&c,sizeof(c));
- float8store(pos,c);
- pos+=sizeof(c);
- }
-}
-
-#endif
static void create_record(uchar *record,uint rownr)
{
diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c
index 3748a38ff81..bde0e1cb388 100644
--- a/storage/myisam/sp_key.c
+++ b/storage/myisam/sp_key.c
@@ -47,7 +47,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
pos = (uchar*)record + keyseg->start;
dlen = _mi_calc_blob_length(keyseg->bit_start, pos);
- memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*));
+ memcpy(&dptr, pos + keyseg->bit_start, sizeof(char*));
if (!dptr)
{
my_errno= HA_ERR_NULL_IN_SPATIAL;
diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c
index 069f43c320d..d86fdc03908 100644
--- a/storage/myisam/sp_test.c
+++ b/storage/myisam/sp_test.c
@@ -299,26 +299,6 @@ static int read_with_pos (MI_INFO * file,int silent)
}
-#ifdef NOT_USED
-static void bprint_record(uchar * record,
- my_off_t offs __attribute__((unused)),
- const char * tail)
-{
- int i;
- char * pos;
- i=(unsigned char)record[0];
- printf("%02X ",i);
-
- for( pos=record+1, i=0; i<32; i++,pos++)
- {
- int b=(unsigned char)*pos;
- printf("%02X",b);
- }
- printf("%s",tail);
-}
-#endif
-
-
static void print_record(uchar * record, my_off_t offs,const char * tail)
{
uchar *pos;
@@ -330,7 +310,7 @@ static void print_record(uchar * record, my_off_t offs,const char * tail)
len=sint4korr(pos);
pos+=4;
printf(" len=%d ",len);
- memcpy_fixed(&ptr,pos,sizeof(char*));
+ memcpy(&ptr, pos, sizeof(char*));
if (ptr)
rtree_PrintWKB((uchar*) ptr,SPDIMS);
else
@@ -340,34 +320,6 @@ static void print_record(uchar * record, my_off_t offs,const char * tail)
}
-#ifdef NOT_USED
-static void create_point(uchar *record,uint rownr)
-{
- uint tmp;
- char *ptr;
- char *pos=record;
- double x[200];
- int i;
-
- for(i=0;i<SPDIMS;i++)
- x[i]=rownr;
-
- bzero((char*) record,MAX_REC_LENGTH);
- *pos=0x01; /* DEL marker */
- pos++;
-
- memset(blob_key,0,sizeof(blob_key));
- tmp=rtree_CreatePointWKB(x,SPDIMS,blob_key);
-
- int4store(pos,tmp);
- pos+=4;
-
- ptr=blob_key;
- memcpy_fixed(pos,&ptr,sizeof(char*));
-}
-#endif
-
-
static void create_linestring(uchar *record,uint rownr)
{
uint tmp;
@@ -376,23 +328,23 @@ static void create_linestring(uchar *record,uint rownr)
double x[200];
int i,j;
int npoints=2;
-
+
for(j=0;j<npoints;j++)
for(i=0;i<SPDIMS;i++)
x[i+j*SPDIMS]=rownr*j;
-
+
bzero((char*) record,MAX_REC_LENGTH);
*pos=0x01; /* DEL marker */
pos++;
-
+
memset(blob_key,0,sizeof(blob_key));
tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key);
-
+
int4store(pos,tmp);
pos+=4;
-
+
ptr=blob_key;
- memcpy_fixed(pos,&ptr,sizeof(char*));
+ memcpy(pos, &ptr, sizeof(char*));
}
@@ -401,7 +353,7 @@ static void create_key(uchar *key,uint rownr)
double c=rownr;
uchar *pos;
uint i;
-
+
bzero(key,MAX_REC_LENGTH);
for (pos=key, i=0; i<2*SPDIMS; i++)
{
@@ -426,27 +378,6 @@ static void print_key(const uchar *key,const char * tail)
}
-#ifdef NOT_USED
-
-static int rtree_CreatePointWKB(double *ords, uint n_dims, uchar *wkb)
-{
- uint i;
-
- *wkb = wkbXDR;
- ++wkb;
- int4store(wkb, wkbPoint);
- wkb += 4;
-
- for (i=0; i < n_dims; ++i)
- {
- float8store(wkb, ords[i]);
- wkb += 8;
- }
- return 5 + n_dims * 8;
-}
-#endif
-
-
static int rtree_CreateLineStringWKB(double *ords, uint n_dims, uint n_points,
uchar *wkb)
{
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index bac8cb7a0b7..f62aff4e383 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -475,10 +475,7 @@ int ha_myisammrg::add_children_list(void)
child_l->parent_l= parent_l;
/* Copy select_lex. Used in unique_table() at least. */
child_l->select_lex= parent_l->select_lex;
- /*
- Set the expected table version, to not cause spurious re-prepare.
- @todo: revise after the fix for Bug#36171
- */
+ /* Set the expected table version, to not cause spurious re-prepare. */
child_l->set_table_ref_id(mrg_child_def->get_child_table_ref_type(),
mrg_child_def->get_child_def_version());
/* Link TABLE_LIST object into the children list. */
@@ -617,15 +614,17 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param)
param->need_compat_check= TRUE;
/*
- If parent is temporary, children must be temporary too and vice
- versa. This check must be done for every child on every open because
- the table def version can overlap between temporary and
- non-temporary tables. We need to detect the case where a
- non-temporary table has been replaced with a temporary table of the
- same version. Or vice versa. A very unlikely case, but it could
- happen.
+ If child is temporary, parent must be temporary as well. Other
+ parent/child combinations are allowed. This check must be done for
+ every child on every open because the table def version can overlap
+ between temporary and non-temporary tables. We need to detect the
+ case where a non-temporary table has been replaced with a temporary
+ table of the same version. Or vice versa. A very unlikely case, but
+ it could happen. (Note that the condition was different from
+ 5.1.23/6.0.4(Bug#19627) to 5.5.6 (Bug#36171): child->s->tmp_table !=
+ parent->s->tmp_table. Tables were required to have the same status.)
*/
- if (child->s->tmp_table != parent->s->tmp_table)
+ if (child->s->tmp_table && !parent->s->tmp_table)
{
DBUG_PRINT("error", ("temporary table mismatch parent: %d child: %d",
parent->s->tmp_table, child->s->tmp_table));
@@ -643,7 +642,7 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param)
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
}
DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx my_errno: %d",
- my_errno ? NULL : (long) myisam, my_errno));
+ my_errno ? 0L : (long) myisam, my_errno));
end:
DBUG_RETURN(myisam);
@@ -1321,6 +1320,8 @@ int ha_myisammrg::extra(enum ha_extra_function operation)
if (operation == HA_EXTRA_FORCE_REOPEN ||
operation == HA_EXTRA_PREPARE_FOR_DROP)
return 0;
+ if (operation == HA_EXTRA_MMAP && !opt_myisam_use_mmap)
+ return 0;
return myrg_extra(file,operation,0);
}
diff --git a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp
index 8126267f946..95dbf5204f1 100644
--- a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp
+++ b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp
@@ -203,7 +203,7 @@ Uint32 FsOpenReq::getVersion(const Uint32 fileNumber[]){
inline
void FsOpenReq::setVersion(Uint32 fileNumber[], Uint8 val){
const Uint32 t = fileNumber[3];
- fileNumber[3] = t & 0x00FFFFFF | (((Uint32)val) << 24);
+ fileNumber[3] = (t & 0x00FFFFFF) | (((Uint32)val) << 24);
}
inline
@@ -214,7 +214,7 @@ Uint32 FsOpenReq::getSuffix(const Uint32 fileNumber[]){
inline
void FsOpenReq::setSuffix(Uint32 fileNumber[], Uint8 val){
const Uint32 t = fileNumber[3];
- fileNumber[3] = t & 0xFF00FFFF | (((Uint32)val) << 16);
+ fileNumber[3] = (t & 0xFF00FFFF) | (((Uint32)val) << 16);
}
inline
@@ -225,7 +225,7 @@ Uint32 FsOpenReq::v1_getDisk(const Uint32 fileNumber[]){
inline
void FsOpenReq::v1_setDisk(Uint32 fileNumber[], Uint8 val){
const Uint32 t = fileNumber[3];
- fileNumber[3] = t & 0xFFFF00FF | (((Uint32)val) << 8);
+ fileNumber[3] = (t & 0xFFFF00FF) | (((Uint32)val) << 8);
}
inline
@@ -266,7 +266,7 @@ Uint32 FsOpenReq::v1_getP(const Uint32 fileNumber[]){
inline
void FsOpenReq::v1_setP(Uint32 fileNumber[], Uint8 val){
const Uint32 t = fileNumber[3];
- fileNumber[3] = t & 0xFFFFFF00 | val;
+ fileNumber[3] = (t & 0xFFFFFF00) | val;
}
/****************/
diff --git a/storage/ndb/include/util/ndb_opts.h b/storage/ndb/include/util/ndb_opts.h
index f18bb9646cc..59d9eaf4d33 100644
--- a/storage/ndb/include/util/ndb_opts.h
+++ b/storage/ndb/include/util/ndb_opts.h
@@ -58,40 +58,40 @@ const char *opt_debug= 0;
"Set connect string for connecting to ndb_mgmd. " \
"Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \
"Overrides specifying entries in NDB_CONNECTSTRING and my.cnf", \
- (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \
+ &opt_ndb_connectstring, &opt_ndb_connectstring, \
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
{ "ndb-mgmd-host", OPT_NDB_MGMD, \
"Set host and port for connecting to ndb_mgmd. " \
"Syntax: <hostname>[:<port>].", \
- (uchar**) &opt_ndb_mgmd, (uchar**) &opt_ndb_mgmd, 0, \
+ &opt_ndb_mgmd, &opt_ndb_mgmd, 0, \
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
{ "ndb-nodeid", OPT_NDB_NODEID, \
"Set node id for this node.", \
- (uchar**) &opt_ndb_nodeid, (uchar**) &opt_ndb_nodeid, 0, \
+ &opt_ndb_nodeid, &opt_ndb_nodeid, 0, \
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
{ "ndb-shm", OPT_NDB_SHM,\
"Allow optimizing using shared memory connections when available",\
- (uchar**) &opt_ndb_shm, (uchar**) &opt_ndb_shm, 0,\
+ &opt_ndb_shm, &opt_ndb_shm, 0,\
GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\
{"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\
"Select nodes for transactions in a more optimal way",\
- (uchar**) &opt_ndb_optimized_node_selection,\
- (uchar**) &opt_ndb_optimized_node_selection, 0,\
+ &opt_ndb_optimized_node_selection,\
+ &opt_ndb_optimized_node_selection, 0,\
GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\
{ "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\
- (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \
+ &opt_ndb_connectstring, &opt_ndb_connectstring, \
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
{ "core-file", OPT_WANT_CORE, "Write core on errors.",\
- (uchar**) &opt_core, (uchar**) &opt_core, 0,\
+ &opt_core, &opt_core, 0,\
GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0},\
{"character-sets-dir", OPT_CHARSETS_DIR,\
- "Directory where character sets are.", (uchar**) &charsets_dir,\
- (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\
+ "Directory where character sets are.", &charsets_dir,\
+ &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\
#ifndef DBUG_OFF
#define NDB_STD_OPTS(prog_name) \
{ "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \
- (uchar**) &opt_debug, (uchar**) &opt_debug, \
+ &opt_debug, &opt_debug, \
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \
NDB_STD_OPTS_COMMON
#else
diff --git a/storage/ndb/src/cw/cpcd/main.cpp b/storage/ndb/src/cw/cpcd/main.cpp
index d5c31d610cb..b750c00bc2a 100644
--- a/storage/ndb/src/cw/cpcd/main.cpp
+++ b/storage/ndb/src/cw/cpcd/main.cpp
@@ -39,22 +39,22 @@ static const char *user = 0;
static struct my_option my_long_options[] =
{
{ "work-dir", 'w', "Work directory",
- (uchar**) &work_dir, (uchar**) &work_dir, 0,
+ &work_dir, &work_dir, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "port", 'p', "TCP port to listen on",
- (uchar**) &port, (uchar**) &port, 0,
+ &port, &port, 0,
GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 },
{ "syslog", 'S', "Log events to syslog",
- (uchar**) &use_syslog, (uchar**) &use_syslog, 0,
+ &use_syslog, &use_syslog, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "logfile", 'L', "File to log events to",
- (uchar**) &logfile, (uchar**) &logfile, 0,
+ &logfile, &logfile, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "debug", 'D', "Enable debug mode",
- (uchar**) &debug, (uchar**) &debug, 0,
+ &debug, &debug, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "user", 'u', "Run as user",
- (uchar**) &user, (uchar**) &user, 0,
+ &user, &user, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
index 67ce7a1760a..3917d415575 100644
--- a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
+++ b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
@@ -840,13 +840,13 @@ Dbtux::TreeEnt::cmp(const TreeEnt ent) const
*/
const unsigned version_wrap_limit = (1 << (ZTUP_VERSION_BITS - 1));
if (m_tupVersion < ent.m_tupVersion) {
- if (ent.m_tupVersion - m_tupVersion < version_wrap_limit)
+ if (unsigned(ent.m_tupVersion - m_tupVersion) < version_wrap_limit)
return -1;
else
return +1;
}
if (m_tupVersion > ent.m_tupVersion) {
- if (m_tupVersion - ent.m_tupVersion < version_wrap_limit)
+ if (unsigned(m_tupVersion - ent.m_tupVersion) < version_wrap_limit)
return +1;
else
return -1;
diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp
index 72770d35cde..f1e608738e3 100644
--- a/storage/ndb/src/kernel/vm/Configuration.cpp
+++ b/storage/ndb/src/kernel/vm/Configuration.cpp
@@ -74,35 +74,35 @@ static struct my_option my_long_options[] =
{ "initial", OPT_INITIAL,
"Perform initial start of ndbd, including cleaning the file system. "
"Consult documentation before using this",
- (uchar**) &_initial, (uchar**) &_initial, 0,
+ &_initial, &_initial, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nostart", 'n',
"Don't start ndbd immediately. Ndbd will await command from ndb_mgmd",
- (uchar**) &_no_start, (uchar**) &_no_start, 0,
+ &_no_start, &_no_start, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "daemon", 'd', "Start ndbd as daemon (default)",
- (uchar**) &_daemon, (uchar**) &_daemon, 0,
+ &_daemon, &_daemon, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
{ "nodaemon", OPT_NODAEMON,
"Do not start ndbd as daemon, provided for testing purposes",
- (uchar**) &_no_daemon, (uchar**) &_no_daemon, 0,
+ &_no_daemon, &_no_daemon, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "foreground", OPT_FOREGROUND,
"Run real ndbd in foreground, provided for debugging purposes"
" (implies --nodaemon)",
- (uchar**) &_foreground, (uchar**) &_foreground, 0,
+ &_foreground, &_foreground, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nowait-nodes", OPT_NOWAIT_NODES,
"Nodes that will not be waited for during start",
- (uchar**) &_nowait_nodes, (uchar**) &_nowait_nodes, 0,
+ &_nowait_nodes, &_nowait_nodes, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "initial-start", OPT_INITIAL_START,
"Perform initial start",
- (uchar**) &_initialstart, (uchar**) &_initialstart, 0,
+ &_initialstart, &_initialstart, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "bind-address", OPT_NOWAIT_NODES,
"Local bind address",
- (uchar**) &_bind_address, (uchar**) &_bind_address, 0,
+ &_bind_address, &_bind_address, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp
index 980530953ad..7049bdd12e0 100644
--- a/storage/ndb/src/mgmclient/main.cpp
+++ b/storage/ndb/src/mgmclient/main.cpp
@@ -73,11 +73,11 @@ static struct my_option my_long_options[] =
NDB_STD_OPTS("ndb_mgm"),
{ "execute", 'e',
"execute command and exit",
- (uchar**) &opt_execute_str, (uchar**) &opt_execute_str, 0,
+ &opt_execute_str, &opt_execute_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "try-reconnect", 't',
"Specify number of tries for connecting to ndb_mgmd (0 = infinite)",
- (uchar**) &_try_reconnect, (uchar**) &_try_reconnect, 0,
+ &_try_reconnect, &_try_reconnect, 0,
GET_UINT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp
index 26198a44a23..e0d9a550cd2 100644
--- a/storage/ndb/src/mgmsrv/main.cpp
+++ b/storage/ndb/src/mgmsrv/main.cpp
@@ -142,29 +142,29 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_mgmd"),
{ "config-file", 'f', "Specify cluster configuration file",
- (uchar**) &opt_config_filename, (uchar**) &opt_config_filename, 0,
+ &opt_config_filename, &opt_config_filename, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "print-full-config", 'P', "Print full config and exit",
- (uchar**) &g_print_full_config, (uchar**) &g_print_full_config, 0,
+ &g_print_full_config, &g_print_full_config, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "daemon", 'd', "Run ndb_mgmd in daemon mode (default)",
- (uchar**) &opt_daemon, (uchar**) &opt_daemon, 0,
+ &opt_daemon, &opt_daemon, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
{ "interactive", OPT_INTERACTIVE,
"Run interactive. Not supported but provided for testing purposes",
- (uchar**) &opt_interactive, (uchar**) &opt_interactive, 0,
+ &opt_interactive, &opt_interactive, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-nodeid-checks", OPT_NO_NODEID_CHECKS,
"Do not provide any node id checks",
- (uchar**) &g_no_nodeid_checks, (uchar**) &g_no_nodeid_checks, 0,
+ &g_no_nodeid_checks, &g_no_nodeid_checks, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nodaemon", OPT_NO_DAEMON,
"Don't run as daemon, but don't read from stdin",
- (uchar**) &opt_non_interactive, (uchar**) &opt_non_interactive, 0,
+ &opt_non_interactive, &opt_non_interactive, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "mycnf", 256,
"Read cluster config from my.cnf",
- (uchar**) &opt_mycnf, (uchar**) &opt_mycnf, 0,
+ &opt_mycnf, &opt_mycnf, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/src/ndbapi/TransporterFacade.hpp b/storage/ndb/src/ndbapi/TransporterFacade.hpp
index 23fea8792f7..cbda9de6df1 100644
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp
@@ -366,8 +366,8 @@ bool
TransporterFacade::get_node_stopping(NodeId n) const {
const ClusterMgr::Node & node = theClusterMgr->getNodeInfo(n);
return (!node.m_state.getSingleUserMode() &&
- (node.m_state.startLevel == NodeState::SL_STOPPING_1) ||
- (node.m_state.startLevel == NodeState::SL_STOPPING_2));
+ ((node.m_state.startLevel == NodeState::SL_STOPPING_1) ||
+ (node.m_state.startLevel == NodeState::SL_STOPPING_2)));
}
inline
diff --git a/storage/ndb/test/ndbapi/testIndexStat.cpp b/storage/ndb/test/ndbapi/testIndexStat.cpp
index 559fade3132..3b3e593081b 100644
--- a/storage/ndb/test/ndbapi/testIndexStat.cpp
+++ b/storage/ndb/test/ndbapi/testIndexStat.cpp
@@ -1297,43 +1297,43 @@ my_long_options[] =
{
NDB_STD_OPTS("testIndexStat"),
{ "loglevel", 1001, "Logging level in this program 0-3 (default 0)",
- (uchar **)&g_opts.loglevel, (uchar **)&g_opts.loglevel, 0,
+ &g_opts.loglevel, &g_opts.loglevel, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "seed", 1002, "Random seed (0=loop number, default -1=random)",
- (uchar **)&g_opts.seed, (uchar **)&g_opts.seed, 0,
+ &g_opts.seed, &g_opts.seed, 0,
GET_INT, REQUIRED_ARG, -1, 0, 0, 0, 0, 0 },
{ "loop", 1003, "Number of test loops (default 1, 0=forever)",
- (uchar **)&g_opts.loop, (uchar **)&g_opts.loop, 0,
+ &g_opts.loop, &g_opts.loop, 0,
GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 },
{ "rows", 1004, "Number of rows (default 100000)",
- (uchar **)&g_opts.rows, (uchar **)&g_opts.rows, 0,
+ &g_opts.rows, &g_opts.rows, 0,
GET_UINT, REQUIRED_ARG, 100000, 0, 0, 0, 0, 0 },
{ "ops", 1005, "Number of index scans per loop (default 1000)",
- (uchar **)&g_opts.ops, (uchar **)&g_opts.ops, 0,
+ &g_opts.ops, &g_opts.ops, 0,
GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 },
{ "dupkeys", 1006, "Pct records per key (min 100, default 1000)",
- (uchar **)&g_opts.dupkeys, (uchar **)&g_opts.dupkeys, 0,
+ &g_opts.dupkeys, &g_opts.dupkeys, 0,
GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 },
{ "scanpct", 1007, "Preferred max pct of total rows per scan (default 5)",
- (uchar **)&g_opts.scanpct, (uchar **)&g_opts.scanpct, 0,
+ &g_opts.scanpct, &g_opts.scanpct, 0,
GET_UINT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 },
{ "nullkeys", 1008, "Pct nulls in each key attribute (default 10)",
- (uchar **)&g_opts.nullkeys, (uchar **)&g_opts.nullkeys, 0,
+ &g_opts.nullkeys, &g_opts.nullkeys, 0,
GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 },
{ "eqscans", 1009, "Pct scans for partial/full equality (default 50)",
- (uchar **)&g_opts.eqscans, (uchar **)&g_opts.eqscans, 0,
+ &g_opts.eqscans, &g_opts.eqscans, 0,
GET_UINT, REQUIRED_ARG, 50, 0, 0, 0, 0, 0 },
{ "dupscans", 1010, "Pct scans using same bounds (default 10)",
- (uchar **)&g_opts.dupscans, (uchar **)&g_opts.dupscans, 0,
+ &g_opts.dupscans, &g_opts.dupscans, 0,
GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 },
{ "keeptable", 1011, "Use existing table and data if any and do not drop",
- (uchar **)&g_opts.keeptable, (uchar **)&g_opts.keeptable, 0,
+ &g_opts.keeptable, &g_opts.keeptable, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-extra-checks", 1012, "Omit expensive consistency checks",
- (uchar **)&g_opts.nochecks, (uchar **)&g_opts.nochecks, 0,
+ &g_opts.nochecks, &g_opts.nochecks, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "abort-on-error", 1013, "Dump core on any error",
- (uchar **)&g_opts.abort, (uchar **)&g_opts.abort, 0,
+ &g_opts.abort, &g_opts.abort, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0,
0, 0, 0,
diff --git a/storage/ndb/test/ndbapi/test_event_merge.cpp b/storage/ndb/test/ndbapi/test_event_merge.cpp
index d40b985adc2..c4109a23119 100644
--- a/storage/ndb/test/ndbapi/test_event_merge.cpp
+++ b/storage/ndb/test/ndbapi/test_event_merge.cpp
@@ -2184,57 +2184,57 @@ my_long_options[] =
{
NDB_STD_OPTS("test_event_merge"),
{ "abort-on-error", 1001, "Do abort() on any error",
- (uchar **)&g_opts.abort_on_error, (uchar **)&g_opts.abort_on_error, 0,
+ &g_opts.abort_on_error, &g_opts.abort_on_error, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "loglevel", 1002, "Logging level in this program 0-3 (default 0)",
- (uchar **)&g_opts.loglevel, (uchar **)&g_opts.loglevel, 0,
+ &g_opts.loglevel, &g_opts.loglevel, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "loop", 1003, "Number of test loops (default 5, 0=forever)",
- (uchar **)&g_opts.loop, (uchar **)&g_opts.loop, 0,
+ &g_opts.loop, &g_opts.loop, 0,
GET_INT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 },
{ "maxops", 1004, "Approx number of PK operations per table (default 1000)",
- (uchar **)&g_opts.maxops, (uchar **)&g_opts.maxops, 0,
+ &g_opts.maxops, &g_opts.maxops, 0,
GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 },
{ "maxpk", 1005, "Number of different PK values (default 10, max 1000)",
- (uchar **)&g_opts.maxpk, (uchar **)&g_opts.maxpk, 0,
+ &g_opts.maxpk, &g_opts.maxpk, 0,
GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 },
{ "maxtab", 1006, "Number of tables (default 10, max 100)",
- (uchar **)&g_opts.maxtab, (uchar **)&g_opts.maxtab, 0,
+ &g_opts.maxtab, &g_opts.maxtab, 0,
GET_INT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 },
{ "no-blobs", 1007, "Omit blob attributes (5.0: true)",
- (uchar **)&g_opts.no_blobs, (uchar **)&g_opts.no_blobs, 0,
+ &g_opts.no_blobs, &g_opts.no_blobs, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-implicit-nulls", 1008, "Insert must include all attrs"
" i.e. no implicit NULLs",
- (uchar **)&g_opts.no_implicit_nulls, (uchar **)&g_opts.no_implicit_nulls, 0,
+ &g_opts.no_implicit_nulls, &g_opts.no_implicit_nulls, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-missing-update", 1009, "Update must include all non-PK attrs",
- (uchar **)&g_opts.no_missing_update, (uchar **)&g_opts.no_missing_update, 0,
+ &g_opts.no_missing_update, &g_opts.no_missing_update, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-multiops", 1010, "Allow only 1 operation per commit",
- (uchar **)&g_opts.no_multiops, (uchar **)&g_opts.no_multiops, 0,
+ &g_opts.no_multiops, &g_opts.no_multiops, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-nulls", 1011, "Create no NULL values",
- (uchar **)&g_opts.no_nulls, (uchar **)&g_opts.no_nulls, 0,
+ &g_opts.no_nulls, &g_opts.no_nulls, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "one-blob", 1012, "Only one blob attribute (default 2)",
- (uchar **)&g_opts.one_blob, (uchar **)&g_opts.one_blob, 0,
+ &g_opts.one_blob, &g_opts.one_blob, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "opstring", 1013, "Operations to run e.g. idiucdc (c is commit) or"
" iuuc:uudc (the : separates loops)",
- (uchar **)&g_opts.opstring, (uchar **)&g_opts.opstring, 0,
+ &g_opts.opstring, &g_opts.opstring, 0,
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "seed", 1014, "Random seed (0=loop number, default -1=random)",
- (uchar **)&g_opts.seed, (uchar **)&g_opts.seed, 0,
+ &g_opts.seed, &g_opts.seed, 0,
GET_INT, REQUIRED_ARG, -1, 0, 0, 0, 0, 0 },
{ "separate-events", 1015, "Do not combine events per GCI (5.0: true)",
- (uchar **)&g_opts.separate_events, (uchar **)&g_opts.separate_events, 0,
+ &g_opts.separate_events, &g_opts.separate_events, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "tweak", 1016, "Whatever the source says",
- (uchar **)&g_opts.tweak, (uchar **)&g_opts.tweak, 0,
+ &g_opts.tweak, &g_opts.tweak, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "use-table", 1017, "Use existing tables",
- (uchar **)&g_opts.use_table, (uchar **)&g_opts.use_table, 0,
+ &g_opts.use_table, &g_opts.use_table, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0,
0, 0, 0,
diff --git a/storage/ndb/test/ndbapi/test_event_multi_table.cpp b/storage/ndb/test/ndbapi/test_event_multi_table.cpp
index 36fb6f511ae..7fbd43ef5eb 100644
--- a/storage/ndb/test/ndbapi/test_event_multi_table.cpp
+++ b/storage/ndb/test/ndbapi/test_event_multi_table.cpp
@@ -258,7 +258,7 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS(""),
{ "database", 'd', "Name of database table is in",
- (gptr*) &_dbname, (gptr*) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/test/run-test/main.cpp b/storage/ndb/test/run-test/main.cpp
index b5c4385f5d3..397eaf8b77e 100644
--- a/storage/ndb/test/run-test/main.cpp
+++ b/storage/ndb/test/run-test/main.cpp
@@ -77,60 +77,60 @@ my_bool opt_core;
static struct my_option g_options[] =
{
{ "help", '?', "Display this help and exit.",
- (uchar **) &g_help, (uchar **) &g_help,
+ &g_help, &g_help,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "version", 'V', "Output version information and exit.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "clusters", 256, "Cluster",
- (uchar **) &g_clusters, (uchar **) &g_clusters,
+ &g_clusters, &g_clusters,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "replicate", 1024, "replicate",
- (uchar **) &g_dummy, (uchar **) &g_dummy,
+ &g_dummy, &g_dummy,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "log-file", 256, "log-file",
- (uchar **) &g_log_filename, (uchar **) &g_log_filename,
+ &g_log_filename, &g_log_filename,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "testcase-file", 'f', "testcase-file",
- (uchar **) &g_test_case_filename, (uchar **) &g_test_case_filename,
+ &g_test_case_filename, &g_test_case_filename,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "report-file", 'r', "report-file",
- (uchar **) &g_report_filename, (uchar **) &g_report_filename,
+ &g_report_filename, &g_report_filename,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "basedir", 256, "Base path",
- (uchar **) &g_basedir, (uchar **) &g_basedir,
+ &g_basedir, &g_basedir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "baseport", 256, "Base port",
- (uchar **) &g_baseport, (uchar **) &g_baseport,
+ &g_baseport, &g_baseport,
0, GET_INT, REQUIRED_ARG, g_baseport, 0, 0, 0, 0, 0},
{ "prefix", 256, "mysql install dir",
- (uchar **) &g_prefix, (uchar **) &g_prefix,
+ &g_prefix, &g_prefix,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "verbose", 'v', "Verbosity",
- (uchar **) &g_verbosity, (uchar **) &g_verbosity,
+ &g_verbosity, &g_verbosity,
0, GET_INT, REQUIRED_ARG, g_verbosity, 0, 0, 0, 0, 0},
{ "configure", 256, "configure",
- (uchar **) &g_do_setup, (uchar **) &g_do_setup,
+ &g_do_setup, &g_do_setup,
0, GET_INT, REQUIRED_ARG, g_do_setup, 0, 0, 0, 0, 0 },
{ "deploy", 256, "deploy",
- (uchar **) &g_do_deploy, (uchar **) &g_do_deploy,
+ &g_do_deploy, &g_do_deploy,
0, GET_INT, REQUIRED_ARG, g_do_deploy, 0, 0, 0, 0, 0 },
{ "sshx", 256, "sshx",
- (uchar **) &g_do_sshx, (uchar **) &g_do_sshx,
+ &g_do_sshx, &g_do_sshx,
0, GET_INT, REQUIRED_ARG, g_do_sshx, 0, 0, 0, 0, 0 },
{ "start", 256, "start",
- (uchar **) &g_do_start, (uchar **) &g_do_start,
+ &g_do_start, &g_do_start,
0, GET_INT, REQUIRED_ARG, g_do_start, 0, 0, 0, 0, 0 },
{ "fqpn", 256, "Fully qualified path-names ",
- (uchar **) &g_fqpn, (uchar **) &g_fqpn,
+ &g_fqpn, &g_fqpn,
0, GET_INT, REQUIRED_ARG, g_fqpn, 0, 0, 0, 0, 0 },
{ "default-ports", 256, "Use default ports when possible",
- (uchar **) &g_default_ports, (uchar **) &g_default_ports,
+ &g_default_ports, &g_default_ports,
0, GET_INT, REQUIRED_ARG, g_default_ports, 0, 0, 0, 0, 0 },
{ "mode", 256, "Mode 0=interactive 1=regression 2=bench",
- (uchar **) &g_mode, (uchar **) &g_mode,
+ &g_mode, &g_mode,
0, GET_INT, REQUIRED_ARG, g_mode, 0, 0, 0, 0, 0 },
{ "quit", 256, "Quit before starting tests",
- (uchar **) &g_mode, (uchar **) &g_do_quit,
+ &g_mode, &g_do_quit,
0, GET_BOOL, NO_ARG, g_do_quit, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp
index 69f3723ca75..b7b830af23d 100644
--- a/storage/ndb/test/src/NDBT_Test.cpp
+++ b/storage/ndb/test/src/NDBT_Test.cpp
@@ -1195,35 +1195,35 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS(""),
{ "print", OPT_PRINT, "Print execution tree",
- (uchar **) &opt_print, (uchar **) &opt_print, 0,
+ &opt_print, &opt_print, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_html", OPT_PRINT_HTML, "Print execution tree in html table format",
- (uchar **) &opt_print_html, (uchar **) &opt_print_html, 0,
+ &opt_print_html, &opt_print_html, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_cases", OPT_PRINT_CASES, "Print list of test cases",
- (uchar **) &opt_print_cases, (uchar **) &opt_print_cases, 0,
+ &opt_print_cases, &opt_print_cases, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "records", 'r', "Number of records",
- (uchar **) &opt_records, (uchar **) &opt_records, 0,
+ &opt_records, &opt_records, 0,
GET_INT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 },
{ "loops", 'l', "Number of loops",
- (uchar **) &opt_loops, (uchar **) &opt_loops, 0,
+ &opt_loops, &opt_loops, 0,
GET_INT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 },
{ "seed", 1024, "Random seed",
- (uchar **) &opt_seed, (uchar **) &opt_seed, 0,
+ &opt_seed, &opt_seed, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "testname", 'n', "Name of test to run",
- (uchar **) &opt_testname, (uchar **) &opt_testname, 0,
+ &opt_testname, &opt_testname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "remote_mgm", 'm',
"host:port to mgmsrv of remote cluster",
- (uchar **) &opt_remote_mgm, (uchar **) &opt_remote_mgm, 0,
+ &opt_remote_mgm, &opt_remote_mgm, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "timer", 't', "Print execution time",
- (uchar **) &opt_timer, (uchar **) &opt_timer, 0,
+ &opt_timer, &opt_timer, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "verbose", 'v', "Print verbose status",
- (uchar **) &opt_verbose, (uchar **) &opt_verbose, 0,
+ &opt_verbose, &opt_verbose, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/test/tools/connect.cpp b/storage/ndb/test/tools/connect.cpp
index 278dbe833ea..d12d1b7a608 100644
--- a/storage/ndb/test/tools/connect.cpp
+++ b/storage/ndb/test/tools/connect.cpp
@@ -31,14 +31,14 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "loop", 'l', "loops",
- (gptr*) &_loop, (gptr*) &_loop, 0,
+ &_loop, &_loop, 0,
GET_INT, REQUIRED_ARG, _loop, 0, 0, 0, 0, 0 },
{ "sleep", 's', "Sleep (ms) between connection attempt",
- (gptr*) &_sleep, (gptr*) &_sleep, 0,
+ &_sleep, &_sleep, 0,
GET_INT, REQUIRED_ARG, _sleep, 0, 0, 0, 0, 0 },
{ "drop", 'd',
"Drop event operations before disconnect (0 = no, 1 = yes, else rand",
- (gptr*) &_drop, (gptr*) &_drop, 0,
+ &_drop, &_drop, 0,
GET_INT, REQUIRED_ARG, _drop, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/delete_all.cpp b/storage/ndb/tools/delete_all.cpp
index 1bf89f5a32f..23d1ef387d2 100644
--- a/storage/ndb/tools/delete_all.cpp
+++ b/storage/ndb/tools/delete_all.cpp
@@ -36,16 +36,16 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "transactional", 't', "Single transaction (may run out of operations)",
- (uchar**) &_transactional, (uchar**) &_transactional, 0,
+ &_transactional, &_transactional, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "tupscan", 999, "Run tupscan",
- (uchar**) &_tupscan, (uchar**) &_tupscan, 0,
+ &_tupscan, &_tupscan, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "diskscan", 999, "Run diskcan",
- (uchar**) &_diskscan, (uchar**) &_diskscan, 0,
+ &_diskscan, &_diskscan, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/desc.cpp b/storage/ndb/tools/desc.cpp
index 831005139de..f31b4f6ae1b 100644
--- a/storage/ndb/tools/desc.cpp
+++ b/storage/ndb/tools/desc.cpp
@@ -39,16 +39,16 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "unqualified", 'u', "Use unqualified table names",
- (uchar**) &_unqualified, (uchar**) &_unqualified, 0,
+ &_unqualified, &_unqualified, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "extra-partition-info", 'p', "Print more info per partition",
- (uchar**) &_partinfo, (uchar**) &_partinfo, 0,
+ &_partinfo, &_partinfo, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "retries", 'r', "Retry every second for # retries",
- (uchar**) &_retries, (uchar**) &_retries, 0,
+ &_retries, &_retries, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/drop_index.cpp b/storage/ndb/tools/drop_index.cpp
index ec88f331a80..82dd595f7df 100644
--- a/storage/ndb/tools/drop_index.cpp
+++ b/storage/ndb/tools/drop_index.cpp
@@ -30,7 +30,7 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/drop_tab.cpp b/storage/ndb/tools/drop_tab.cpp
index 8d07afbbf50..1fba31b5c8a 100644
--- a/storage/ndb/tools/drop_tab.cpp
+++ b/storage/ndb/tools/drop_tab.cpp
@@ -30,7 +30,7 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/listTables.cpp b/storage/ndb/tools/listTables.cpp
index 45129cb34af..bd70587f77e 100644
--- a/storage/ndb/tools/listTables.cpp
+++ b/storage/ndb/tools/listTables.cpp
@@ -256,22 +256,22 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_show_tables"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "loops", 'l', "loops",
- (uchar**) &_loops, (uchar**) &_loops, 0,
+ &_loops, &_loops, 0,
GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 },
{ "type", 't', "type",
- (uchar**) &_type, (uchar**) &_type, 0,
+ &_type, &_type, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "unqualified", 'u', "Use unqualified table names",
- (uchar**) &_unqualified, (uchar**) &_unqualified, 0,
+ &_unqualified, &_unqualified, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "parsable", 'p', "Return output suitable for mysql LOAD DATA INFILE",
- (uchar**) &_parsable, (uchar**) &_parsable, 0,
+ &_parsable, &_parsable, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "show-temp-status", OPT_SHOW_TMP_STATUS, "Show table temporary flag",
- (uchar**) &show_temp_status, (uchar**) &show_temp_status, 0,
+ &show_temp_status, &show_temp_status, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/ndb_config.cpp b/storage/ndb/tools/ndb_config.cpp
index af36103f947..0df88dc0167 100644
--- a/storage/ndb/tools/ndb_config.cpp
+++ b/storage/ndb/tools/ndb_config.cpp
@@ -58,37 +58,37 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_config"),
{ "nodes", 256, "Print nodes",
- (uchar**) &g_nodes, (uchar**) &g_nodes,
+ &g_nodes, &g_nodes,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "connections", 256, "Print connections",
- (uchar**) &g_connections, (uchar**) &g_connections,
+ &g_connections, &g_connections,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "query", 'q', "Query option(s)",
- (uchar**) &g_query, (uchar**) &g_query,
+ &g_query, &g_query,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "host", 256, "Host",
- (uchar**) &g_host, (uchar**) &g_host,
+ &g_host, &g_host,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "type", 258, "Type of node/connection",
- (uchar**) &g_type, (uchar**) &g_type,
+ &g_type, &g_type,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "id", 258, "Nodeid",
- (uchar**) &g_nodeid, (uchar**) &g_nodeid,
+ &g_nodeid, &g_nodeid,
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "nodeid", 258, "Nodeid",
- (uchar**) &g_nodeid, (uchar**) &g_nodeid,
+ &g_nodeid, &g_nodeid,
0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "fields", 'f', "Field separator",
- (uchar**) &g_field_delimiter, (uchar**) &g_field_delimiter,
+ &g_field_delimiter, &g_field_delimiter,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "rows", 'r', "Row separator",
- (uchar**) &g_row_delimiter, (uchar**) &g_row_delimiter,
+ &g_row_delimiter, &g_row_delimiter,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "config-file", 256, "Path to config.ini",
- (uchar**) &g_config_file, (uchar**) &g_config_file,
+ &g_config_file, &g_config_file,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "mycnf", 256, "Read config from my.cnf",
- (uchar**) &g_mycnf, (uchar**) &g_mycnf,
+ &g_mycnf, &g_mycnf,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp
index 7db77524ad8..966c539cee9 100644
--- a/storage/ndb/tools/restore/restore_main.cpp
+++ b/storage/ndb/tools/restore/restore_main.cpp
@@ -100,99 +100,99 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_restore"),
{ "connect", 'c', "same as --connect-string",
- (uchar**) &opt_connect_str, (uchar**) &opt_connect_str, 0,
+ &opt_connect_str, &opt_connect_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "nodeid", 'n', "Backup files from node with id",
- (uchar**) &ga_nodeId, (uchar**) &ga_nodeId, 0,
+ &ga_nodeId, &ga_nodeId, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "backupid", 'b', "Backup id",
- (uchar**) &ga_backupId, (uchar**) &ga_backupId, 0,
+ &ga_backupId, &ga_backupId, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "restore_data", 'r',
"Restore table data/logs into NDB Cluster using NDBAPI",
- (uchar**) &_restore_data, (uchar**) &_restore_data, 0,
+ &_restore_data, &_restore_data, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "restore_meta", 'm',
"Restore meta data into NDB Cluster using NDBAPI",
- (uchar**) &_restore_meta, (uchar**) &_restore_meta, 0,
+ &_restore_meta, &_restore_meta, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-upgrade", 'u',
"Don't upgrade array type for var attributes, which don't resize VAR data and don't change column attributes",
- (uchar**) &ga_no_upgrade, (uchar**) &ga_no_upgrade, 0,
+ &ga_no_upgrade, &ga_no_upgrade, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-restore-disk-objects", 'd',
"Dont restore disk objects (tablespace/logfilegroups etc)",
- (uchar**) &_no_restore_disk, (uchar**) &_no_restore_disk, 0,
+ &_no_restore_disk, &_no_restore_disk, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "restore_epoch", 'e',
"Restore epoch info into the status table. Convenient on a MySQL Cluster "
"replication slave, for starting replication. The row in "
NDB_REP_DB "." NDB_APPLY_TABLE " with id 0 will be updated/inserted.",
- (uchar**) &ga_restore_epoch, (uchar**) &ga_restore_epoch, 0,
+ &ga_restore_epoch, &ga_restore_epoch, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "skip-table-check", 's', "Skip table structure check during restore of data",
- (uchar**) &ga_skip_table_check, (uchar**) &ga_skip_table_check, 0,
+ &ga_skip_table_check, &ga_skip_table_check, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 'p',
"No of parallel transactions during restore of data."
"(parallelism can be 1 to 1024)",
- (uchar**) &ga_nParallelism, (uchar**) &ga_nParallelism, 0,
+ &ga_nParallelism, &ga_nParallelism, 0,
GET_INT, REQUIRED_ARG, 128, 1, 1024, 0, 1, 0 },
{ "print", OPT_PRINT, "Print metadata, data and log to stdout",
- (uchar**) &_print, (uchar**) &_print, 0,
+ &_print, &_print, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_data", OPT_PRINT_DATA, "Print data to stdout",
- (uchar**) &_print_data, (uchar**) &_print_data, 0,
+ &_print_data, &_print_data, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_meta", OPT_PRINT_META, "Print meta data to stdout",
- (uchar**) &_print_meta, (uchar**) &_print_meta, 0,
+ &_print_meta, &_print_meta, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_log", OPT_PRINT_LOG, "Print log to stdout",
- (uchar**) &_print_log, (uchar**) &_print_log, 0,
+ &_print_log, &_print_log, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "backup_path", OPT_BACKUP_PATH, "Path to backup files",
- (uchar**) &ga_backupPath, (uchar**) &ga_backupPath, 0,
+ &ga_backupPath, &ga_backupPath, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "dont_ignore_systab_0", 'f',
"Experimental. Do not ignore system table during restore.",
- (uchar**) &ga_dont_ignore_systab_0, (uchar**) &ga_dont_ignore_systab_0, 0,
+ &ga_dont_ignore_systab_0, &ga_dont_ignore_systab_0, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "ndb-nodegroup-map", OPT_NDB_NODEGROUP_MAP,
"Nodegroup map for ndbcluster. Syntax: list of (source_ng, dest_ng)",
- (uchar**) &opt_nodegroup_map_str,
- (uchar**) &opt_nodegroup_map_str,
+ &opt_nodegroup_map_str,
+ &opt_nodegroup_map_str,
0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "fields-enclosed-by", OPT_FIELDS_ENCLOSED_BY,
"Fields are enclosed by ...",
- (uchar**) &opt_fields_enclosed_by, (uchar**) &opt_fields_enclosed_by, 0,
+ &opt_fields_enclosed_by, &opt_fields_enclosed_by, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "fields-terminated-by", OPT_FIELDS_TERMINATED_BY,
"Fields are terminated by ...",
- (uchar**) &opt_fields_terminated_by,
- (uchar**) &opt_fields_terminated_by, 0,
+ &opt_fields_terminated_by,
+ &opt_fields_terminated_by, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "fields-optionally-enclosed-by", OPT_FIELDS_OPTIONALLY_ENCLOSED_BY,
"Fields are optionally enclosed by ...",
- (uchar**) &opt_fields_optionally_enclosed_by,
- (uchar**) &opt_fields_optionally_enclosed_by, 0,
+ &opt_fields_optionally_enclosed_by,
+ &opt_fields_optionally_enclosed_by, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "hex", OPT_HEX_FORMAT, "print binary types in hex format",
- (uchar**) &opt_hex_format, (uchar**) &opt_hex_format, 0,
+ &opt_hex_format, &opt_hex_format, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "tab", 'T', "Creates tab separated textfile for each table to "
"given path. (creates .txt files)",
- (uchar**) &tab_path, (uchar**) &tab_path, 0,
+ &tab_path, &tab_path, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "append", OPT_APPEND, "for --tab append data to file",
- (uchar**) &opt_append, (uchar**) &opt_append, 0,
+ &opt_append, &opt_append, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "lines-terminated-by", OPT_LINES_TERMINATED_BY, "",
- (uchar**) &opt_lines_terminated_by, (uchar**) &opt_lines_terminated_by, 0,
+ &opt_lines_terminated_by, &opt_lines_terminated_by, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "verbose", OPT_VERBOSE,
"verbosity",
- (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
+ &opt_verbose, &opt_verbose, 0,
GET_INT, REQUIRED_ARG, 1, 0, 255, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/select_all.cpp b/storage/ndb/tools/select_all.cpp
index 23d5f95f3f7..95dfeab9eed 100644
--- a/storage/ndb/tools/select_all.cpp
+++ b/storage/ndb/tools/select_all.cpp
@@ -54,43 +54,43 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 'p', "parallelism",
- (uchar**) &_parallelism, (uchar**) &_parallelism, 0,
+ &_parallelism, &_parallelism, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)",
- (uchar**) &_lock, (uchar**) &_lock, 0,
+ &_lock, &_lock, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "order", 'o', "Sort resultset according to index",
- (uchar**) &_order, (uchar**) &_order, 0,
+ &_order, &_order, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "descending", 'z', "Sort descending (requires order flag)",
- (uchar**) &_descending, (uchar**) &_descending, 0,
+ &_descending, &_descending, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "header", 'h', "Print header",
- (uchar**) &_header, (uchar**) &_header, 0,
+ &_header, &_header, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
{ "useHexFormat", 'x', "Output numbers in hexadecimal format",
- (uchar**) &_useHexFormat, (uchar**) &_useHexFormat, 0,
+ &_useHexFormat, &_useHexFormat, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "delimiter", 'D', "Column delimiter",
- (uchar**) &_delimiter, (uchar**) &_delimiter, 0,
+ &_delimiter, &_delimiter, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "disk", 256, "Dump disk ref",
- (uchar**) &_dumpDisk, (uchar**) &_dumpDisk, 0,
+ &_dumpDisk, &_dumpDisk, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "rowid", 256, "Dump rowid",
- (uchar**) &use_rowid, (uchar**) &use_rowid, 0,
+ &use_rowid, &use_rowid, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "gci", 256, "Dump gci",
- (uchar**) &use_gci, (uchar**) &use_gci, 0,
+ &use_gci, &use_gci, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "tupscan", 't', "Scan in tup order",
- (uchar**) &_tup, (uchar**) &_tup, 0,
+ &_tup, &_tup, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nodata", 256, "Dont print data",
- (uchar**) &nodata, (uchar**) &nodata, 0,
+ &nodata, &nodata, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/select_count.cpp b/storage/ndb/tools/select_count.cpp
index 73982e886b5..6bdc682c16a 100644
--- a/storage/ndb/tools/select_count.cpp
+++ b/storage/ndb/tools/select_count.cpp
@@ -43,13 +43,13 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "database", 'd', "Name of database table is in",
- (uchar**) &_dbname, (uchar**) &_dbname, 0,
+ &_dbname, &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 'p', "parallelism",
- (uchar**) &_parallelism, (uchar**) &_parallelism, 0,
+ &_parallelism, &_parallelism, 0,
GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 },
{ "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)",
- (uchar**) &_lock, (uchar**) &_lock, 0,
+ &_lock, &_lock, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp
index fc2a4b368b1..26c86e6d196 100644
--- a/storage/ndb/tools/waiter.cpp
+++ b/storage/ndb/tools/waiter.cpp
@@ -44,17 +44,17 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "no-contact", 'n', "Wait for cluster no contact",
- (uchar**) &_no_contact, (uchar**) &_no_contact, 0,
+ &_no_contact, &_no_contact, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "not-started", OPT_WAIT_STATUS_NOT_STARTED, "Wait for cluster not started",
- (uchar**) &_not_started, (uchar**) &_not_started, 0,
+ &_not_started, &_not_started, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "single-user", OPT_WAIT_STATUS_SINGLE_USER,
"Wait for cluster to enter single user mode",
- (uchar**) &_single_user, (uchar**) &_single_user, 0,
+ &_single_user, &_single_user, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "timeout", 't', "Timeout to wait in seconds",
- (uchar**) &_timeout, (uchar**) &_timeout, 0,
+ &_timeout, &_timeout, 0,
GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/storage/perfschema/pfs_events_waits.cc b/storage/perfschema/pfs_events_waits.cc
index aae8f9dc8c1..e32a77512cc 100644
--- a/storage/perfschema/pfs_events_waits.cc
+++ b/storage/perfschema/pfs_events_waits.cc
@@ -39,7 +39,6 @@ bool flag_events_waits_summary_by_thread_by_event_name= true;
bool flag_events_waits_summary_by_event_name= true;
/** Consumer flag for table EVENTS_WAITS_SUMMARY_BY_INSTANCE. */
bool flag_events_waits_summary_by_instance= true;
-bool flag_events_locks_summary_by_thread_by_event_name= true;
bool flag_events_locks_summary_by_event_name= true;
bool flag_events_locks_summary_by_instance= true;
/** Consumer flag for table FILE_SUMMARY_BY_EVENT_NAME. */
@@ -96,9 +95,8 @@ static void copy_events_waits(PFS_events_waits *dest,
/* Signal readers they are about to read garbage ... */
dest->m_wait_class= NO_WAIT_CLASS;
/* ... that this can generate. */
- memcpy_fixed(dest_body,
- source_body,
- sizeof(PFS_events_waits) - sizeof(events_waits_class));
+ memcpy(dest_body, source_body,
+ sizeof(PFS_events_waits) - sizeof(events_waits_class));
/* Signal readers the record is now clean again. */
dest->m_wait_class= source->m_wait_class;
}
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index abc03302b64..e1e14f20218 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -15,15 +15,19 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-SET(STRINGS_SOURCES bchange.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c
+SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c
ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c
ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c
ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c
- is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c
+ is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c
str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
- strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
- my_strchr.c strcont.c strinstr.c strnlen.c strappend.c)
+ strxmov.c strxnmov.c xml.c
+ my_strchr.c strcont.c strappend.c)
+IF(NOT HAVE_STRNLEN)
+ # OSX does not have strnlen
+ SET(STRINGS_SOURCES ${STRINGS_SOURCES} strnlen.c)
+ENDIF()
# Avoid dependencies on perschema data defined in mysys
ADD_DEFINITIONS(-DDISABLE_MYSQL_THREAD_H)
ADD_CONVENIENCE_LIBRARY(strings ${STRINGS_SOURCES})
diff --git a/strings/Makefile.am b/strings/Makefile.am
index fd884a1296a..3a051e38899 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -30,20 +30,13 @@ pkglib_LIBRARIES = libmystrings.a
# Exact one of ASSEMBLER_X
if ASSEMBLER_x86
ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c
-else
-if ASSEMBLER_sparc32
-# These file MUST all be on the same line!! Otherwise automake
-# generats a very broken makefile
-ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
-CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c strmov.c
+CSRCS = bfill.c bmove.c bchange.c strxnmov.c int2str.c str2int.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c
else
#no assembler
ASRCS =
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
-CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c
-endif
+CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bchange.c strxnmov.c int2str.c str2int.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c
endif
libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
@@ -57,11 +50,8 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc
longlong2str.c longlong2str-x86.s longlong2str_asm.c \
my_strtoll10.c my_strtoll10-x86.s \
strxmov.c bmove_upp.c strappend.c strcont.c strend.c \
- strfill.c strcend.c is_prefix.c strstr.c strinstr.c \
+ strfill.c strcend.c is_prefix.c strstr.c \
strmake.c strnmov.c strmov.c strnlen.c \
- bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \
- strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
- strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
t_ctype.h my_strchr.c CMakeLists.txt \
CHARSET_INFO.txt
diff --git a/strings/bfill.c b/strings/bfill.c
index 2750553f48a..ccc063f59e3 100644
--- a/strings/bfill.c
+++ b/strings/bfill.c
@@ -23,10 +23,6 @@
bfill(dst, len, fill) moves "len" fill characters to "dst".
Thus to set a buffer to 80 spaces, do bfill(buff, 80, ' ').
-
- Note: the "b" routines are there to exploit certain VAX order codes,
- but the MOVC5 instruction will only move 65535 characters. The asm
- code is presented for your interest and amusement.
*/
#include <my_global.h>
@@ -34,58 +30,6 @@
#if !defined(bfill) && !defined(HAVE_BFILL)
-#if VaxAsm
-
-void bfill(dst, len, fill)
-char *dst;
-uint len;
-int fill; /* actually char */
-{
- asm("movc5 $0,*4(ap),12(ap),8(ap),*4(ap)");
-}
-
-#elif defined(MC68000) && defined(DS90)
-
-void bfill(dst, len,fill) /* Optimized with long-fill */
-char *dst;
-uint len;
-pchar fill;
-{
-asm(" movl 8.(a7),d1 ");
-asm(" jeq .L9 ");
-asm(" movl 4.(a7),a0 ");
-asm(" moveq #0,d0 ");
-asm(" movb 15.(a7),d0 ");
-asm(" movl d2,a1 ");
-asm(" movw d0,d2 ");
-asm(" aslw #8,d0 ");
-asm(" orw d2,d0 ");
-asm(" movl d0,d2 ");
-asm(" swap d0 ");
-asm(" orl d2,d0 ");
-asm(" movl a0,d2 ");
-asm(" btst #0,d2 ");
-asm(" jeq .L1 ");
-asm(" movb d0,(a0)+ ");
-asm(" subql #1,d1 ");
-asm(".L1: movl d1,d2 ");
-asm(" lsrl #2,d2 ");
-asm(" jcc .L2 ");
-asm(" movw d0,(a0)+ ");
-asm(" jra .L2 ");
-asm(".L3: movl d0,(a0)+ ");
-asm(".L2: dbra d2,.L3 ");
-asm(" addqw #1,d2 ");
-asm(" subql #1,d2 ");
-asm(" jcc .L3 ");
-asm(" andl #1,d1 ");
-asm(" jeq .L8 ");
-asm(" movb d0,(a0) ");
-asm(".L8: movl a1,d2 ");
-asm(".L9: rts ");
-}
-#else
-
void bfill(dst, len, fill)
register byte *dst;
register uint len;
@@ -95,4 +39,3 @@ register pchar fill;
}
#endif
-#endif
diff --git a/strings/bmove.c b/strings/bmove.c
index ae9641a5d58..0aa825558ca 100644
--- a/strings/bmove.c
+++ b/strings/bmove.c
@@ -30,10 +30,6 @@
has its first two arguments the other way around you may find this a
bit easier to get right.
No value is returned.
-
- Note: the "b" routines are there to exploit certain VAX order codes,
- but the MOVC3 instruction will only move 65535 characters. The asm
- code is presented for your interest and amusement.
*/
#include <my_global.h>
@@ -41,33 +37,6 @@
#if !defined(HAVE_BMOVE) && !defined(bmove)
-#if VaxAsm
-
-void bmove(dst, src, len)
- char *dst, *src;
- uint len;
- {
- asm("movc3 12(ap),*8(ap),*4(ap)");
- }
-
-#else
-#if defined(MC68000) && defined(DS90)
-
-void bmove(dst, src, len)
-char *dst,*src;
-uint len; /* 0 <= len <= 65535 */
-{
-asm(" movl 12(a7),d0 ");
-asm(" subql #1,d0 ");
-asm(" blt .L5 ");
-asm(" movl 4(a7),a1 ");
-asm(" movl 8(a7),a0 ");
-asm(".L4: movb (a0)+,(a1)+ ");
-asm(" dbf d0,.L4 ");
-asm(".L5: ");
-}
-#else
-
void bmove(dst, src, len)
register char *dst;
register const char *src;
@@ -75,6 +44,5 @@ register uint len;
{
while (len-- != 0) *dst++ = *src++;
}
-#endif
-#endif
+
#endif
diff --git a/strings/bmove512.c b/strings/bmove512.c
deleted file mode 100644
index c3f0446ead6..00000000000
--- a/strings/bmove512.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* File : bmove512.c
- Author : Michael Widenius;
- Defines: bmove512()
-
- bmove512(dst, src, len) moves exactly "len" bytes from the source "src"
- to the destination "dst". "src" and "dst" must be alligned on long
- boundory and len must be a mutliple of 512 byte. If len is not a
- multiple of 512 byte len/512*512+1 bytes is copyed.
- bmove512 is moustly used to copy IO_BLOCKS. bmove512 should be the
- fastest way to move a mutiple of 512 byte.
-*/
-
-#include <my_global.h>
-#include "m_string.h"
-
-#ifndef bmove512
-
-#ifdef HAVE_LONG_LONG
-#define LONG ulonglong
-#else
-#define LONG ulonglong
-#endif
-
-void bmove512(uchar *to, const uchar *from, register size_t length)
-{
- reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length);
-
- f= (LONG*) from;
- t= (LONG*) to;
-
-#if defined(m88k) || defined(sparc) || defined(HAVE_LONG_LONG)
- do {
- t[0]=f[0]; t[1]=f[1]; t[2]=f[2]; t[3]=f[3];
- t[4]=f[4]; t[5]=f[5]; t[6]=f[6]; t[7]=f[7];
- t[8]=f[8]; t[9]=f[9]; t[10]=f[10]; t[11]=f[11];
- t[12]=f[12]; t[13]=f[13]; t[14]=f[14]; t[15]=f[15];
- t[16]=f[16]; t[17]=f[17]; t[18]=f[18]; t[19]=f[19];
- t[20]=f[20]; t[21]=f[21]; t[22]=f[22]; t[23]=f[23];
- t[24]=f[24]; t[25]=f[25]; t[26]=f[26]; t[27]=f[27];
- t[28]=f[28]; t[29]=f[29]; t[30]=f[30]; t[31]=f[31];
- t[32]=f[32]; t[33]=f[33]; t[34]=f[34]; t[35]=f[35];
- t[36]=f[36]; t[37]=f[37]; t[38]=f[38]; t[39]=f[39];
- t[40]=f[40]; t[41]=f[41]; t[42]=f[42]; t[43]=f[43];
- t[44]=f[44]; t[45]=f[45]; t[46]=f[46]; t[47]=f[47];
- t[48]=f[48]; t[49]=f[49]; t[50]=f[50]; t[51]=f[51];
- t[52]=f[52]; t[53]=f[53]; t[54]=f[54]; t[55]=f[55];
- t[56]=f[56]; t[57]=f[57]; t[58]=f[58]; t[59]=f[59];
- t[60]=f[60]; t[61]=f[61]; t[62]=f[62]; t[63]=f[63];
-#ifdef HAVE_LONG_LONG
- t+=64; f+=64;
-#else
- t[64]=f[64]; t[65]=f[65]; t[66]=f[66]; t[67]=f[67];
- t[68]=f[68]; t[69]=f[69]; t[70]=f[70]; t[71]=f[71];
- t[72]=f[72]; t[73]=f[73]; t[74]=f[74]; t[75]=f[75];
- t[76]=f[76]; t[77]=f[77]; t[78]=f[78]; t[79]=f[79];
- t[80]=f[80]; t[81]=f[81]; t[82]=f[82]; t[83]=f[83];
- t[84]=f[84]; t[85]=f[85]; t[86]=f[86]; t[87]=f[87];
- t[88]=f[88]; t[89]=f[89]; t[90]=f[90]; t[91]=f[91];
- t[92]=f[92]; t[93]=f[93]; t[94]=f[94]; t[95]=f[95];
- t[96]=f[96]; t[97]=f[97]; t[98]=f[98]; t[99]=f[99];
- t[100]=f[100]; t[101]=f[101]; t[102]=f[102]; t[103]=f[103];
- t[104]=f[104]; t[105]=f[105]; t[106]=f[106]; t[107]=f[107];
- t[108]=f[108]; t[109]=f[109]; t[110]=f[110]; t[111]=f[111];
- t[112]=f[112]; t[113]=f[113]; t[114]=f[114]; t[115]=f[115];
- t[116]=f[116]; t[117]=f[117]; t[118]=f[118]; t[119]=f[119];
- t[120]=f[120]; t[121]=f[121]; t[122]=f[122]; t[123]=f[123];
- t[124]=f[124]; t[125]=f[125]; t[126]=f[126]; t[127]=f[127];
- t+=128; f+=128;
-#endif
- } while (f < end);
-#else
- do {
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++;
- } while (f < end);
-#endif
- return;
-} /* bmove512 */
-
-#endif /* bmove512 */
diff --git a/strings/bmove_upp-sparc.s b/strings/bmove_upp-sparc.s
deleted file mode 100644
index f745f0fc613..00000000000
--- a/strings/bmove_upp-sparc.s
+++ /dev/null
@@ -1,40 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "bmove_upp-sparc.s"
-.section ".text"
- .align 4
- .global bmove_upp
- .type bmove_upp,#function
- .proc 020
-bmove_upp:
- subcc %o2, 1, %o2 ! o2= len
- bcs .end
- nop
-.loop:
- sub %o1, 1, %o1
- ldub [%o1], %o3
- sub %o0, 1, %o0
- subcc %o2, 1, %o2
- bcc .loop
- stb %o3, [%o0]
-.end:
- retl
- nop
-.bmove_upp_end:
- .size bmove_upp,.bmove_upp_end-bmove_upp
- .ident "Matt Wagner & Monty"
diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c
index fb47bda2d1d..05e786837f4 100644
--- a/strings/bmove_upp.c
+++ b/strings/bmove_upp.c
@@ -25,26 +25,8 @@
#include <my_global.h>
#include "m_string.h"
-#if defined(MC68000) && defined(DS90)
-
-/* 0 <= len <= 65535 */
-void bmove_upp(byte *dst, const byte *src,uint len)
-{
-asm(" movl 12(a7),d0 ");
-asm(" subql #1,d0 ");
-asm(" blt .L5 ");
-asm(" movl 4(a7),a1 ");
-asm(" movl 8(a7),a0 ");
-asm(".L4: movb -(a0),-(a1) ");
-asm(" dbf d0,.L4 ");
-asm(".L5: ");
-}
-#else
-
void bmove_upp(register uchar *dst, register const uchar *src,
register size_t len)
{
while (len-- != 0) *--dst = *--src;
}
-
-#endif
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 8a3d3d7425c..2e5f78a30bf 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -335,10 +335,6 @@ long my_strntol_8bit(CHARSET_INFO *cs,
int overflow;
*err= 0; /* Initialize error indicator */
-#ifdef NOT_USED
- if (base < 0 || base == 1 || base > 36)
- base = 10;
-#endif
s = nptr;
e = nptr+l;
@@ -364,29 +360,6 @@ long my_strntol_8bit(CHARSET_INFO *cs,
else
negative = 0;
-#ifdef NOT_USED
- if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x'))
- s += 2;
-#endif
-
-#ifdef NOT_USED
- if (base == 0)
- {
- if (*s == '0')
- {
- if (s[1]=='X' || s[1]=='x')
- {
- s += 2;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
- }
-#endif
-
save = s;
cutoff = ((uint32)~0L) / (uint32) base;
cutlim = (uint) (((uint32)~0L) % (uint32) base);
@@ -458,10 +431,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
int overflow;
*err= 0; /* Initialize error indicator */
-#ifdef NOT_USED
- if (base < 0 || base == 1 || base > 36)
- base = 10;
-#endif
s = nptr;
e = nptr+l;
@@ -486,29 +455,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
else
negative = 0;
-#ifdef NOT_USED
- if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x'))
- s += 2;
-#endif
-
-#ifdef NOT_USED
- if (base == 0)
- {
- if (*s == '0')
- {
- if (s[1]=='X' || s[1]=='x')
- {
- s += 2;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
- }
-#endif
-
save = s;
cutoff = ((uint32)~0L) / (uint32) base;
cutlim = (uint) (((uint32)~0L) % (uint32) base);
@@ -571,10 +517,6 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
int overflow;
*err= 0; /* Initialize error indicator */
-#ifdef NOT_USED
- if (base < 0 || base == 1 || base > 36)
- base = 10;
-#endif
s = nptr;
e = nptr+l;
@@ -599,29 +541,6 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
else
negative = 0;
-#ifdef NOT_USED
- if (base == 16 && s[0] == '0' && (s[1]=='X'|| s[1]=='x'))
- s += 2;
-#endif
-
-#ifdef NOT_USED
- if (base == 0)
- {
- if (*s == '0')
- {
- if (s[1]=='X' || s[1]=='x')
- {
- s += 2;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
- }
-#endif
-
save = s;
cutoff = (~(ulonglong) 0) / (unsigned long int) base;
@@ -694,10 +613,6 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
int overflow;
*err= 0; /* Initialize error indicator */
-#ifdef NOT_USED
- if (base < 0 || base == 1 || base > 36)
- base = 10;
-#endif
s = nptr;
e = nptr+l;
@@ -722,29 +637,6 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
else
negative = 0;
-#ifdef NOT_USED
- if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x'))
- s += 2;
-#endif
-
-#ifdef NOT_USED
- if (base == 0)
- {
- if (*s == '0')
- {
- if (s[1]=='X' || s[1]=='x')
- {
- s += 2;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
- }
-#endif
-
save = s;
cutoff = (~(ulonglong) 0) / (unsigned long int) base;
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 3946f6a83b4..d3b0b93a939 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -134,11 +134,6 @@ my_strntol_mb2_or_mb4(CHARSET_INFO *cs,
bs:
-#ifdef NOT_USED
- if (base <= 0 || base == 1 || base > 36)
- base = 10;
-#endif
-
overflow= 0;
res= 0;
save= s;
@@ -250,11 +245,6 @@ my_strntoul_mb2_or_mb4(CHARSET_INFO *cs,
bs:
-#ifdef NOT_USED
- if (base <= 0 || base == 1 || base > 36)
- base = 10;
-#endif
-
overflow= 0;
res= 0;
save= s;
@@ -359,11 +349,6 @@ my_strntoll_mb2_or_mb4(CHARSET_INFO *cs,
bs:
-#ifdef NOT_USED
- if (base <= 0 || base == 1 || base > 36)
- base = 10;
-#endif
-
overflow = 0;
res = 0;
save = s;
@@ -474,11 +459,6 @@ my_strntoull_mb2_or_mb4(CHARSET_INFO *cs,
} while (1);
bs:
-
-#ifdef NOT_USED
- if (base <= 0 || base == 1 || base > 36)
- base = 10;
-#endif
overflow = 0;
res = 0;
diff --git a/strings/do_ctype.c b/strings/do_ctype.c
index d038d313a98..f87d55b6251 100644
--- a/strings/do_ctype.c
+++ b/strings/do_ctype.c
@@ -140,7 +140,7 @@ void init_case_convert()
to_upper[i]= sort_order[i]= to_lower[i]= (char) i;
#endif
-#if defined(HPUX10) && ASCII_BITS_USED == 8
+#if defined(HPUX10)
higher_pos= (uchar *) "\xd0\xd8\xda\xdb\xdc\xd3";
lower_pos= (uchar *) "\xd4\xcc\xce\xdf\xc9\xd7";
#else
@@ -166,7 +166,7 @@ void init_case_convert()
/* sets upp sortorder; higer_pos character (upper and lower) is */
/* changed to lower_pos character */
-#if defined(HPUX10) && ASCII_BITS_USED == 8
+#if defined(HPUX10)
higher_pos= lower_pos= (uchar *) ""; /* Tecknen i r{tt ordning */
#else
#ifdef USE_ISO_8859_1 /* As in USG5 ICL-386 */
diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c
deleted file mode 100644
index fb1e0c5a090..00000000000
--- a/strings/r_strinstr.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- Author : David
- strintstr(src, from, pat) looks for an instance of pat in src
- backwards from pos from. pat is not a regex(3) pattern, it is a literal
- string which must be matched exactly.
- The result 0 if the pattern was not found else it is the start char of
- the pattern counted from the begining of the string.
-*/
-
-#include <my_global.h>
-#include "m_string.h"
-
-size_t r_strinstr(reg1 const char * str, size_t from, reg4 const char * search)
-{
- reg2 const char *i, *j;
- size_t len = strlen(search);
- /* pointer to the last char of buff */
- const char * start = str + from - 1;
- /* pointer to the last char of search */
- const char * search_end = search + len - 1;
-
- skip:
- while (start >= str) /* Cant be != because the first char */
- {
- if (*start-- == *search_end)
- {
- i = start; j = search_end - 1;
- while (j >= search && start > str)
- if (*i-- != *j--)
- goto skip;
- return (size_t) ((start - len) - str + 3);
- }
- }
- return (0);
-}
diff --git a/strings/str_test.c b/strings/str_test.c
index 0814647472c..7e304fbd10a 100644
--- a/strings/str_test.c
+++ b/strings/str_test.c
@@ -73,8 +73,6 @@ int main(void)
test_arg("strstr(v1,v5)",(long) strstr(v1,v5),0L);
test_arg("strstr(v6,v8)",(long) strstr(v6,v8),0L);
- test_arg("strinstr(v1,v4)",(long) strinstr(v1,v4),4L);
- test_arg("strinstr(v1,v5)",(long) strinstr(v1,v5),0L);
test_arg("strlen(from)",(long) strlen(from),(long) F_LEN);
test_arg("strlen(\"\")",(long) strlen(""),0L);
#ifdef HAVE_STRNLEN
diff --git a/strings/strappend-sparc.s b/strings/strappend-sparc.s
deleted file mode 100644
index d5add816eb0..00000000000
--- a/strings/strappend-sparc.s
+++ /dev/null
@@ -1,49 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strappend-sparc.s"
-.section ".text"
- .align 4
- .global strappend
- .type strappend,#function
- .proc 020
-strappend:
- add %o0, %o1, %o3 ! o3 = endpos
- ldsb [%o0], %o4
-.loop1:
- add %o0, 1, %o0 ! find end of str
- cmp %o4, 0
- bne,a .loop1
- ldsb [%o0], %o4
-
- sub %o0, 1, %o0
- cmp %o0, %o3
- bgeu .end
- nop
-
- stb %o2, [%o0]
-.loop2:
- add %o0, 1, %o0
- cmp %o0, %o3
- blu,a .loop2
- stb %o2, [%o0]
-.end:
- retl
- stb %g0, [%o3]
-.strappend_end:
- .size strappend,.strappend_end-strappend
- .ident "Matt Wagner & Monty"
diff --git a/strings/strcend.c b/strings/strcend.c
index 56e31d5f994..e08ad2b1e75 100644
--- a/strings/strcend.c
+++ b/strings/strcend.c
@@ -25,23 +25,6 @@
#include <my_global.h>
#include "m_string.h"
-#if defined(MC68000) && defined(DS90)
-
-char *strcend(const char *s, pchar c)
-{
-asm(" movl 4(a7),a0 ");
-asm(" movl 8(a7),d1 ");
-asm(".L2: movb (a0)+,d0 ");
-asm(" cmpb d0,d1 ");
-asm(" beq .L1 ");
-asm(" tstb d0 ");
-asm(" bne .L2 ");
-asm(".L1: movl a0,d0 ");
-asm(" subql #1,d0 ");
-}
-
-#else
-
char *strcend(register const char *s, register pchar c)
{
for (;;)
@@ -51,4 +34,3 @@ char *strcend(register const char *s, register pchar c)
}
}
-#endif
diff --git a/strings/strend-sparc.s b/strings/strend-sparc.s
deleted file mode 100644
index f264fcef32f..00000000000
--- a/strings/strend-sparc.s
+++ /dev/null
@@ -1,35 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strend-sparc.s"
-.section ".text"
- .align 4
- .global strend
- .type strend,#function
- .proc 0102
-strend:
- ldsb [%o0], %o3 ! Handle first char differently to make
-.loop: ! a faster loop
- add %o0, 1, %o0
- cmp %o3, 0
- bne,a .loop
- ldsb [%o0], %o3
- retl
- sub %o0,1,%o0
-.strend_end:
- .size strend,.strend_end-strend
- .ident "Matt Wagner & Monty"
diff --git a/strings/strend.c b/strings/strend.c
index 4dadf0675dc..d70a5d648d5 100644
--- a/strings/strend.c
+++ b/strings/strend.c
@@ -24,27 +24,14 @@
is, strend(s)-s == strlen(s). This is useful for adding things at
the end of strings. It is redundant, because strchr(s,'\0') could
be used instead, but this is clearer and faster.
- Beware: the asm version works only if strlen(s) < 65535.
*/
#include <my_global.h>
#include "m_string.h"
-#if VaxAsm
-
-char *strend(s)
-const char *s;
-{
- asm("locc $0,$65535,*4(ap)");
- asm("movl r1,r0");
-}
-
-#else /* ~VaxAsm */
-
char *strend(register const char *s)
{
while (*s++);
return (char*) (s-1);
}
-#endif /* VaxAsm */
diff --git a/strings/string.doc b/strings/string.doc
index 954f7226759..fcd020b8c60 100644
--- a/strings/string.doc
+++ b/strings/string.doc
@@ -77,11 +77,6 @@ Speciella användbara nya string-rutiner:
The result is a pointer to the first character of the located instance,
or NullS if pat does not occur in src.
- strinstr(src, pat) looks for an instance of pat in src. pat is not a
- regex(3) pattern, it is a literal string which must be matched exactly.
- The result 0 if the pattern was not found else it is the start char of
- the pattern counted from the begining of the string.
-
strmake(dst,src,length) moves length characters, or until end, of src to
dst and appends a closing NUL to dst.
strmake() returns pointer to closing null;
diff --git a/strings/strings-not-used.h b/strings/strings-not-used.h
deleted file mode 100644
index 8311545f22f..00000000000
--- a/strings/strings-not-used.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef STRINGS_NOT_USED_INCLUDED
-#define STRINGS_NOT_USED_INCLUDED
-
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* File : strings.h
- Author : Richard A. O'Keefe.
- Updated: 1 June 1984
- Purpose: Header file for the "string(3C)" package.
-
- All the routines in this package are the original work of
- R.A.O'Keefe. Any resemblance between them and any routines in
- licensed software is due entirely to these routines having been
- written using the "man 3 string" UNIX manual page, or in some cases
- the "man 1 sort" manual page as a specification. See the READ-ME to
- find the conditions under which these routines may be used & copied.
-*/
-
-#ifndef NullS
-
-#include <my_global.h> /* Define standar vars */
-#include "m_string.h"
-
-#define NUL '\0'
-#define _AlphabetSize 256
-
-#endif /* NullS */
-#endif /* STRINGS_NOT_USED_INCLUDED */
diff --git a/strings/strings-x86.s b/strings/strings-x86.s
index db7bb0c1274..4872c566685 100644
--- a/strings/strings-x86.s
+++ b/strings/strings-x86.s
@@ -281,29 +281,6 @@ sf_fo: movl %edx,%eax # Char found here
.strstr_end:
.size strstr,.strstr_end-strstr
-
- # Find a substring in string, return index
- # Arg: str,search
-
-.globl strinstr
- .type strinstr,@function
-
-strinstr:
- pushl %ebp
- movl %esp,%ebp
- pushl 12(%ebp) # search
- pushl 8(%ebp) # str
- call strstr
- add $8,%esp
- or %eax,%eax
- jz si_99 # Not found, return NULL
- sub 8(%ebp),%eax # Pos from start
- inc %eax # And first pos = 1
-si_99: popl %ebp
- ret
-.strinstr_end:
- .size strinstr,.strinstr_end-strinstr
-
# Make a string of len length from another string
# Arg: dst,src,length
# ret: end of dst
diff --git a/strings/strinstr-sparc.s b/strings/strinstr-sparc.s
deleted file mode 100644
index 5278aff6aa7..00000000000
--- a/strings/strinstr-sparc.s
+++ /dev/null
@@ -1,43 +0,0 @@
-! Copyright (C) 2000 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strinstr-sparc.s"
-.section ".text"
- .align 4
- .global strinstr
- .type strinstr,#function
- .proc 0102
-strinstr:
- save %sp,-96,%sp
- or %g0,%i1,%o1
- call strstr,2 ! Result = %o0
- or %g0,%i0,%o0
- orcc %g0,%o0,%o0
- bne .end
- sub %o0,%i0,%i0
- ret
- restore %g0,%g0,%o0
-.end:
- ret
- restore %i0,1,%o0 ! Offset for return value is from 1
-
-.strinstr_end:
- .size strinstr,.strinstr_end-strinstr
- .ident "Matt Wagner & Monty"
-
-
-
diff --git a/strings/strinstr.c b/strings/strinstr.c
deleted file mode 100644
index dce498d61e8..00000000000
--- a/strings/strinstr.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- 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 Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* File : strinstr.c
- Author : Monty & David
- Updated: 1986.12.08
- Defines: strinstr()
-
- strinstr(src, pat) looks for an instance of pat in src. pat is not a
- regex(3) pattern, it is a literal string which must be matched exactly.
- The result 0 if the pattern was not found else it is the start char of
- the pattern counted from the beginning of the string, where the first
- char is 1.
-*/
-
-#include <my_global.h>
-#include "m_string.h"
-
-size_t strinstr(reg1 const char *str,reg4 const char *search)
-{
- reg2 const char *i, *j;
- const char *start= str;
-
- skip:
- while (*str != '\0')
- {
- if (*str++ == *search)
- {
- i= str; j= search+1;
- while (*j)
- if (*i++ != *j++) goto skip;
- return ((size_t) (str - start));
- }
- }
- return (0);
-}
diff --git a/strings/strmake-sparc.s b/strings/strmake-sparc.s
deleted file mode 100644
index 36db8efd402..00000000000
--- a/strings/strmake-sparc.s
+++ /dev/null
@@ -1,43 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strmake-sparc.s"
-.section ".text"
- .align 4
- .global strmake
- .type strmake,#function
- .proc 0102
-strmake:
- orcc %g0,%o2,%g0
- be,a .end
- nop
- ldsb [%o1],%o3
-.loop:
- stb %o3,[%o0]
- cmp %o3,0
- be .end ! Jump to end on end of string
- add %o1,1,%o1
- add %o0,1,%o0
- subcc %o2,1,%o2
- bne,a .loop
- ldsb [%o1],%o3
-.end:
- retl
- stb %g0,[%o0]
-.strmake_end:
- .size strmake,.strmake_end-strmake
- .ident "Matt Wagner & Monty"
diff --git a/strings/strmov-sparc.s b/strings/strmov-sparc.s
deleted file mode 100644
index f124da2dc9f..00000000000
--- a/strings/strmov-sparc.s
+++ /dev/null
@@ -1,36 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strmov-sparc.s"
-.section ".text"
- .align 4
- .global strmov
- .type strmov,#function
- .proc 0102
-strmov:
-.loop:
- ldub [%o1], %o3
- stb %o3, [%o0]
- add %o1, 1, %o1
- cmp %o3, 0
- bne,a .loop
- add %o0, 1, %o0
- retl
- nop
-.strmov_end:
- .size strmov,.strmov_end-strmov
- .ident "Matt Wagner"
diff --git a/strings/strmov.c b/strings/strmov.c
index eedf22a4ef1..4d4915d27a0 100644
--- a/strings/strmov.c
+++ b/strings/strmov.c
@@ -29,25 +29,9 @@
#define strmov strmov_overlapp
#endif
-#if !defined(MC68000) && !defined(DS90)
-
char *strmov(register char *dst, register const char *src)
{
while ((*dst++ = *src++)) ;
return dst-1;
}
-#else
-
-char *strmov(dst, src)
- char *dst, *src;
-{
- asm(" movl 4(a7),a1 ");
- asm(" movl 8(a7),a0 ");
- asm(".L4: movb (a0)+,(a1)+ ");
- asm(" jne .L4 ");
- asm(" movl a1,d0 ");
- asm(" subql #1,d0 ");
-}
-
-#endif
diff --git a/strings/strnmov-sparc.s b/strings/strnmov-sparc.s
deleted file mode 100644
index df0c4bebf03..00000000000
--- a/strings/strnmov-sparc.s
+++ /dev/null
@@ -1,43 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strnmov-sparc.s"
-.section ".text"
- .align 4
- .global strnmov
- .type strnmov,#function
- .proc 0102
-strnmov:
- orcc %g0,%o2,%g0
- be,a .end
- nop
- ldsb [%o1],%o3
-.loop:
- stb %o3,[%o0]
- cmp %o3,0
- be .end ! Jump to end on end of string
- add %o1,1,%o1
- add %o0,1,%o0
- subcc %o2,1,%o2
- bne,a .loop
- ldsb [%o1],%o3
-.end:
- retl
- nop
-.strnmov_end:
- .size strnmov,.strnmov_end-strnmov
- .ident "Matt Wagner"
diff --git a/strings/strstr-sparc.s b/strings/strstr-sparc.s
deleted file mode 100644
index 2a6590c9c93..00000000000
--- a/strings/strstr-sparc.s
+++ /dev/null
@@ -1,72 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
- .file "strstr-sparc.s"
-.section ".text"
- .align 4
- .global strstr
- .type strstr,#function
- .proc 0102
-strstr:
-
-!char *strstr(register const char *str,const char *search)
-!{
-! register char *i,*j;
-!skipp:
-! while (*str != '\0') {
-! if (*str++ == *search) {
-! i=(char*) str; j=(char*) search+1;
-
- ldsb [%o1],%o2 ! o2= First char of search
-.top:
- ldsb [%o0],%o4 ! o4= First char of rest of str
- cmp %o4,0
- be .abort ! Found end null ;
- cmp %o4,%o2
- bne .top
- add %o0,1,%o0
-
-.outloop1:
-
-! while (*j)
-! if (*i++ != *j++) goto skipp;
-
- or %g0,%o0,%o3
- add %o1,1,%o4 ! o4= search+1
- ldsb [%o0],%o5 ! o5= [current_str+1]
-
-.loop2:
- ldsb [%o4],%g4
- add %o4,1,%o4
- cmp %g4,0
- be .end
- cmp %o5,%g4
- bne .top
- add %o3,1,%o3
- ba .loop2
- ldsb [%o3],%o5
-
-.end:
- retl
- sub %o0,1,%o0
-.abort:
- retl
- or %g0,0,%o0
-
-.strstr_end:
- .size strstr,.strstr_end-strstr
- .ident "Matt Wagner & Monty"
diff --git a/strings/strxmov-sparc.s b/strings/strxmov-sparc.s
deleted file mode 100644
index 11ae49a876b..00000000000
--- a/strings/strxmov-sparc.s
+++ /dev/null
@@ -1,54 +0,0 @@
-! Copyright (C) 2000, 2002 MySQL AB
-!
-! This library is free software; you can redistribute it and/or
-! modify it under the terms of the GNU Library General Public
-! License as published by the Free Software Foundation; version 2
-! of the License.
-!
-! This library is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! Library General Public License for more details.
-!
-! You should have received a copy of the GNU Library General Public
-! License along with this library; if not, write to the Free
-! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-! MA 02111-1307, USA
-
-!
-! Note that this function only works on 32 bit sparc systems
-! on 64 bits the offsets to %sp are different !
-
- .file "strxmov-sparc.s"
-.section ".text"
- .align 4
- .global strxmov
- .type strxmov,#function
- .proc 0102
-
-strxmov:
- st %o2, [%sp+76] ! store 3rd param before other params
- st %o3, [%sp+80] ! store 4th param " "
- cmp %o1, 0 ! check if no from args
- st %o4, [%sp+84] ! store 5th param
- be .end
- st %o5, [%sp+88] ! store last
- add %sp, 76, %o4 ! put pointer to 3rd arg
-.loop:
- ldub [%o1], %o5 ! set values of src (o1)
- add %o1, 1, %o1 ! inc src
- stb %o5, [%o0] ! and dst (o2) equal
- cmp %o5, 0 ! second while cmp
- bne,a .loop
- add %o0, 1, %o0 ! inc dst
- ld [%o4], %o1 ! get next param
- cmp %o1, 0 ! check if last param
- bne .loop
- add %o4, 4, %o4 ! advance to next param
-.end:
- retl
- stb %g0, [%o0]
-.strxmov_end:
- .size strxmov,.strxmov_end-strxmov
- .ident "Matt Wagner & Monty"
-
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index f9adeb873bb..ef8ae8dd29a 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -5775,215 +5775,6 @@ static void test_set_variable()
mysql_stmt_close(stmt1);
}
-#if NOT_USED
-
-/* Insert meta info .. */
-
-static void test_insert_meta()
-{
- MYSQL_STMT *stmt;
- int rc;
- MYSQL_RES *result;
- MYSQL_FIELD *field;
-
- myheader("test_insert_meta");
-
- rc= mysql_autocommit(mysql, TRUE);
- myquery(rc);
-
- rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert");
- myquery(rc);
-
- rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \
- col2 varchar(50), col3 varchar(30))");
- myquery(rc);
-
- strmov(query, "INSERT INTO test_prep_insert VALUES(10, 'venu1', 'test')");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 0);
-
- result= mysql_param_result(stmt);
- mytest_r(result);
-
- mysql_stmt_close(stmt);
-
- strmov(query, "INSERT INTO test_prep_insert VALUES(?, 'venu', ?)");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 2);
-
- result= mysql_param_result(stmt);
- mytest(result);
-
- my_print_result_metadata(result);
-
- mysql_field_seek(result, 0);
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1");
- DIE_UNLESS(strcmp(field->name, "col1") == 0);
-
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3");
- DIE_UNLESS(strcmp(field->name, "col3") == 0);
-
- field= mysql_fetch_field(result);
- mytest_r(field);
-
- mysql_free_result(result);
- mysql_stmt_close(stmt);
-}
-
-
-/* Update meta info .. */
-
-static void test_update_meta()
-{
- MYSQL_STMT *stmt;
- int rc;
- MYSQL_RES *result;
- MYSQL_FIELD *field;
-
- myheader("test_update_meta");
-
- rc= mysql_autocommit(mysql, TRUE);
- myquery(rc);
-
- rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_update");
- myquery(rc);
-
- rc= mysql_query(mysql, "CREATE TABLE test_prep_update(col1 tinyint, \
- col2 varchar(50), col3 varchar(30))");
- myquery(rc);
-
- strmov(query, "UPDATE test_prep_update SET col1=10, col2='venu1' WHERE col3='test'");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 0);
-
- result= mysql_param_result(stmt);
- mytest_r(result);
-
- mysql_stmt_close(stmt);
-
- strmov(query, "UPDATE test_prep_update SET col1=?, col2='venu' WHERE col3=?");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 2);
-
- result= mysql_param_result(stmt);
- mytest(result);
-
- my_print_result_metadata(result);
-
- mysql_field_seek(result, 0);
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- {
- fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
- fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
- }
- DIE_UNLESS(strcmp(field->name, "col1") == 0);
- DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
-
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- {
- fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3");
- fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
- }
- DIE_UNLESS(strcmp(field->name, "col3") == 0);
- DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
-
- field= mysql_fetch_field(result);
- mytest_r(field);
-
- mysql_free_result(result);
- mysql_stmt_close(stmt);
-}
-
-
-/* Select meta info .. */
-
-static void test_select_meta()
-{
- MYSQL_STMT *stmt;
- int rc;
- MYSQL_RES *result;
- MYSQL_FIELD *field;
-
- myheader("test_select_meta");
-
- rc= mysql_autocommit(mysql, TRUE);
- myquery(rc);
-
- rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_select");
- myquery(rc);
-
- rc= mysql_query(mysql, "CREATE TABLE test_prep_select(col1 tinyint, \
- col2 varchar(50), col3 varchar(30))");
- myquery(rc);
-
- strmov(query, "SELECT * FROM test_prep_select WHERE col1=10");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 0);
-
- result= mysql_param_result(stmt);
- mytest_r(result);
-
- strmov(query, "SELECT col1, col3 from test_prep_select WHERE col1=? AND col3='test' AND col2= ?");
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- verify_param_count(stmt, 2);
-
- result= mysql_param_result(stmt);
- mytest(result);
-
- my_print_result_metadata(result);
-
- mysql_field_seek(result, 0);
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- {
- fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
- fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
- }
- DIE_UNLESS(strcmp(field->name, "col1") == 0);
- DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
-
- field= mysql_fetch_field(result);
- mytest(field);
- if (!opt_silent)
- {
- fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2");
- fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
- }
- DIE_UNLESS(strcmp(field->name, "col2") == 0);
- DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
-
- field= mysql_fetch_field(result);
- mytest_r(field);
-
- mysql_free_result(result);
- mysql_stmt_close(stmt);
-}
-#endif
-
-
/* Test FUNCTION field info / DATE_FORMAT() table_name . */
static void test_func_fields()
diff --git a/tests/thread_test.c b/tests/thread_test.c
index 1a3dd60c1fd..c243a3a7321 100644
--- a/tests/thread_test.c
+++ b/tests/thread_test.c
@@ -88,36 +88,36 @@ static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
- {"database", 'D', "Database to use", (uchar**) &database, (uchar**) &database,
+ {"database", 'D', "Database to use", &database, &database,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"host", 'h', "Connect to host", (uchar**) &host, (uchar**) &host, 0, GET_STR,
+ {"host", 'h', "Connect to host", &host, &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"user", 'u', "User for login if not current user", (uchar**) &user,
- (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"user", 'u', "User for login if not current user", &user,
+ &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"verbose", 'v', "Write some progress indicators", (uchar**) &verbose,
- (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"query", 'Q', "Query to execute in each threads", (uchar**) &query,
- (uchar**) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"verbose", 'v', "Write some progress indicators", &verbose,
+ &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"query", 'Q', "Query to execute in each threads", &query,
+ &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection or 0 for default to, in "
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
#if MYSQL_PORT_DEFAULT == 0
"/etc/services, "
#endif
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
- (uchar**) &tcp_port,
- (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
- {"socket", 'S', "Socket file to use for connection", (uchar**) &unix_socket,
- (uchar**) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ &tcp_port,
+ &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
+ {"socket", 'S', "Socket file to use for connection", &unix_socket,
+ &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"test-count", 'c', "Run test count times (default %d)",
- (uchar**) &number_of_tests, (uchar**) &number_of_tests, 0, GET_UINT,
+ &number_of_tests, &number_of_tests, 0, GET_UINT,
REQUIRED_ARG, 1000, 0, 0, 0, 0, 0},
{"thread-count", 't', "Number of threads to start",
- (uchar**) &number_of_threads, (uchar**) &number_of_threads, 0, GET_UINT,
+ &number_of_threads, &number_of_threads, 0, GET_UINT,
REQUIRED_ARG, 2, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c
index 9853d3cf964..95799be7bb1 100644
--- a/unittest/mysys/my_atomic-t.c
+++ b/unittest/mysys/my_atomic-t.c
@@ -15,13 +15,6 @@
#include "thr_template.c"
-/* at least gcc 3.4.5 and 3.4.6 (but not 3.2.3) on RHEL */
-#if __GNUC__ == 3 && __GNUC_MINOR__ == 4
-#define GCC_BUG_WORKAROUND volatile
-#else
-#define GCC_BUG_WORKAROUND
-#endif
-
volatile uint32 b32;
volatile int32 c32;
my_atomic_rwlock_t rwl;
@@ -29,8 +22,8 @@ my_atomic_rwlock_t rwl;
/* add and sub a random number in a loop. Must get 0 at the end */
pthread_handler_t test_atomic_add(void *arg)
{
- int m= (*(int *)arg)/2;
- GCC_BUG_WORKAROUND int32 x;
+ int m= (*(int *)arg)/2;
+ int32 x;
for (x= ((int)(intptr)(&m)); m ; m--)
{
x= (x*m+0x87654321) & INT_MAX32;
@@ -52,8 +45,8 @@ volatile int64 a64;
/* add and sub a random number in a loop. Must get 0 at the end */
pthread_handler_t test_atomic_add64(void *arg)
{
- int m= (*(int *)arg)/2;
- GCC_BUG_WORKAROUND int64 x;
+ int m= (*(int *)arg)/2;
+ int64 x;
for (x= ((int64)(intptr)(&m)); m ; m--)
{
x= (x*m+0xfdecba987654321LL) & INT_MAX64;
@@ -128,8 +121,8 @@ pthread_handler_t test_atomic_fas(void *arg)
*/
pthread_handler_t test_atomic_cas(void *arg)
{
- int m= (*(int *)arg)/2, ok= 0;
- GCC_BUG_WORKAROUND int32 x, y;
+ int m= (*(int *)arg)/2, ok= 0;
+ int32 x, y;
for (x= ((int)(intptr)(&m)); m ; m--)
{
my_atomic_rwlock_wrlock(&rwl);
diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c
index 2f1747d7167..7facb23e7e3 100644
--- a/unittest/mytap/tap.c
+++ b/unittest/mytap/tap.c
@@ -29,9 +29,9 @@
/*
Visual Studio 2003 does not know vsnprintf but knows _vsnprintf.
- We don't put this #define in config-win.h because we prefer
- my_vsnprintf everywhere instead, except when linking with libmysys
- is not desirable - the case here.
+ We don't put this #define elsewhere because we prefer my_vsnprintf
+ everywhere instead, except when linking with libmysys is not
+ desirable - the case here.
*/
#if defined(_MSC_VER) && ( _MSC_VER == 1310 )
#define vsnprintf _vsnprintf