mariadb/sql
Jon Olav Hauglid b20a409c38 Backport of revno: 2617.71.1
Bug#42546 Backup: RESTORE fails, thinking it finds an existing table

The problem occured when a MDL locking conflict happened for a non-existent 
table between a CREATE and a INSERT statement. The code for CREATE 
interpreted this lock conflict to mean that the table existed, 
which meant that the statement failed when it should not have.
The problem could occur for CREATE TABLE, CREATE TABLE LIKE and
ALTER TABLE RENAME.

This patch fixes the problem for CREATE TABLE and CREATE TABLE LIKE.
It is based on code backported from the mysql-6.1-fk tree written
by Dmitry Lenev. CREATE now uses normal open_and_lock_tables() code 
to acquire exclusive locks. This means that for the test case in the bug 
description, CREATE will wait until INSERT completes so that it can 
get the exclusive lock. This resolves the reported bug.

The patch also prohibits CREATE TABLE and CREATE TABLE LIKE under 
LOCK TABLES. Note that this is an incompatible change and must 
be reflected in the documentation. Affected test cases have been
updated.

mdl_sync.test contains tests for CREATE TABLE and CREATE TABLE LIKE.

Fixing the issue for ALTER TABLE RENAME is beyond the scope of this
patch. ALTER TABLE cannot be prohibited from working under LOCK TABLES
as this could seriously impact customers and a proper fix would require
a significant rewrite.
2009-12-10 11:53:20 +01:00
..
examples
share Backport of: 2009-12-09 18:48:42 +03:00
.cvsignore
add_errmsg
authors.h
client_settings.h Backport of WL#798 (MySQL IPv6 support) from 6.0. 2009-11-25 13:53:23 +03:00
CMakeLists.txt Backport of: 2009-12-03 21:37:38 +03:00
contributors.h
custom_conf.h
debug_sync.cc
debug_sync.h
derror.cc Backport of: 2009-11-24 16:54:59 +03:00
des_key_file.cc Backport of: 2009-11-24 16:54:59 +03:00
discover.cc Backport of: 2009-11-24 16:54:59 +03:00
event_data_objects.cc
event_data_objects.h
event_db_repository.cc Backport of: 2009-12-08 12:57:07 +03:00
event_db_repository.h
event_parse_data.cc
event_parse_data.h
event_queue.cc
event_queue.h
event_scheduler.cc
event_scheduler.h
events.cc Backport of: 2009-12-03 18:47:20 +03:00
events.h
field.cc Backport of: 2009-11-24 16:54:59 +03:00
field.h Backport of: 2009-12-02 18:22:15 +03:00
field_conv.cc
filesort.cc Backport of: 2009-11-24 16:54:59 +03:00
frm_crypt.cc
gen_lex_hash.cc
gstream.cc
gstream.h
ha_ndbcluster.cc ------------------------------------------------------------ 2009-12-04 01:46:14 +03:00
ha_ndbcluster.h
ha_ndbcluster_binlog.cc Backport of: 2009-12-08 12:57:07 +03:00
ha_ndbcluster_binlog.h
ha_ndbcluster_cond.cc
ha_ndbcluster_cond.h
ha_ndbcluster_tables.h
ha_partition.cc Backport of: 2009-12-03 02:09:22 +03:00
ha_partition.h Backport of: 2009-11-30 22:38:25 +03:00
handler.cc Backport of: 2009-12-03 21:37:38 +03:00
handler.h Backport of: 2009-12-03 21:37:38 +03:00
hash_filo.cc
hash_filo.h
hostname.cc Backport of WL#798 (MySQL IPv6 support) from 6.0. 2009-11-25 13:53:23 +03:00
init.cc Backport of: 2009-11-24 16:54:59 +03:00
item.cc Backport of: 2009-11-24 16:54:59 +03:00
item.h Manual resolving for the following files 2009-12-01 21:07:18 +02:00
item_buff.cc
item_cmpfunc.cc Backport of: 2009-11-24 16:54:59 +03:00
item_cmpfunc.h Manual resolving for the following files 2009-12-01 21:07:18 +02:00
item_create.cc
item_create.h
item_func.cc
item_func.h merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == build@mysql.com-20091104182209-iui387z35159aoyw 2009-11-30 14:34:39 +02:00
item_geofunc.cc
item_geofunc.h
item_row.cc
item_row.h
item_strfunc.cc Backport of: 2009-11-24 16:54:59 +03:00
item_strfunc.h
item_subselect.cc
item_subselect.h
item_sum.cc
item_sum.h
item_timefunc.cc
item_timefunc.h
item_xmlfunc.cc
item_xmlfunc.h
key.cc
lex.h Backport of: 2009-12-10 11:21:38 +03:00
lex_symbol.h
lock.cc Merge with next-4284. 2009-12-10 11:41:03 +03:00
log.cc Backport of: 2009-12-08 12:57:07 +03:00
log.h
log_event.cc Backport of: 2009-12-08 12:57:07 +03:00
log_event.h
log_event_old.cc Backport of: 2009-12-08 12:57:07 +03:00
log_event_old.h
Makefile.am Backport of: 2009-12-03 21:37:38 +03:00
mdl.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
mdl.h Backport of: 2009-12-10 11:21:38 +03:00
message.h
message.mc
message.rc
mf_iocache.cc
MSG00001.bin
my_decimal.cc
my_decimal.h
my_lock.c
mysql_priv.h Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
mysql_priv.h.pp
mysqld.cc Backport of: 2009-12-08 11:26:49 +03:00
mysqld_suffix.h
net_serv.cc
nt_servc.cc
nt_servc.h
opt_range.cc
opt_range.h Backport of: 2009-11-24 16:54:59 +03:00
opt_sum.cc
parse_file.cc
parse_file.h
partition_element.h
partition_info.cc
partition_info.h
password.c
procedure.cc
procedure.h
protocol.cc Backport of: 2009-11-24 16:54:59 +03:00
protocol.h
records.cc Backport of: 2009-11-24 16:54:59 +03:00
records.h
repl_failsafe.cc Manual resolving for the following files 2009-12-01 21:07:18 +02:00
repl_failsafe.h
replication.h
rpl_constants.h
rpl_filter.cc
rpl_filter.h
rpl_handler.cc
rpl_handler.h
rpl_injector.cc Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5, 2009-12-05 02:02:48 +03:00
rpl_injector.h
rpl_mi.cc
rpl_mi.h
rpl_record.cc
rpl_record.h
rpl_record_old.cc
rpl_record_old.h
rpl_reporting.cc
rpl_reporting.h
rpl_rli.cc Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5, 2009-12-05 02:02:48 +03:00
rpl_rli.h Merge next-mr -> next-4284 2009-12-03 14:37:42 +03:00
rpl_tblmap.cc
rpl_tblmap.h
rpl_utility.cc
rpl_utility.h
scheduler.cc
scheduler.h
set_var.cc Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5, 2009-12-05 02:02:48 +03:00
set_var.h Manual resolving for the following files 2009-12-01 21:07:18 +02:00
slave.cc Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5, 2009-12-05 02:02:48 +03:00
slave.h
sp.cc Backport of: 2009-12-10 11:21:38 +03:00
sp.h Backport of: 2009-12-09 19:11:26 +03:00
sp_cache.cc
sp_cache.h
sp_head.cc Backport of: 2009-12-10 11:21:38 +03:00
sp_head.h Backport of: 2009-12-09 19:11:26 +03:00
sp_pcontext.cc Backport of: 2009-11-24 16:54:59 +03:00
sp_pcontext.h
sp_rcontext.cc
sp_rcontext.h
spatial.cc
spatial.h
sql_acl.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_acl.h
sql_analyse.cc
sql_analyse.h
sql_array.h
sql_base.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_binlog.cc Initial import of WL#3726 "DDL locking for all metadata objects". 2009-11-30 18:55:03 +03:00
sql_bitmap.h
sql_builtin.cc.in
sql_cache.cc ------------------------------------------------------------ 2009-12-04 01:46:14 +03:00
sql_cache.h
sql_class.cc Backport of revno: 2617.68.13 2009-12-09 15:25:48 +01:00
sql_class.h Backport of revno: 2617.68.13 2009-12-09 15:25:48 +01:00
sql_client.cc
sql_connect.cc Backport of WL#798 (MySQL IPv6 support) from 6.0. 2009-11-25 13:53:23 +03:00
sql_crypt.cc
sql_crypt.h
sql_cursor.cc Backport of: 2009-12-01 17:39:03 +03:00
sql_cursor.h
sql_db.cc Backport of: 2009-12-02 18:22:15 +03:00
sql_delete.cc Backport of: 2009-12-10 11:21:38 +03:00
sql_derived.cc
sql_do.cc Backport of: 2009-12-03 21:37:38 +03:00
sql_error.cc
sql_error.h
sql_handler.cc Merge with next-4284. 2009-12-10 11:41:03 +03:00
sql_help.cc Backport of: 2009-12-08 12:57:07 +03:00
sql_insert.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_lex.cc
sql_lex.h Backport of: 2009-12-08 17:13:12 +03:00
sql_list.cc
sql_list.h
sql_load.cc Merge next-mr -> next-4284 2009-12-03 14:37:42 +03:00
sql_locale.cc
sql_manager.cc
sql_map.cc Backport of: 2009-11-24 16:54:59 +03:00
sql_map.h
sql_olap.cc
sql_parse.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_partition.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_partition.h
sql_plist.h Backport of: 2009-12-04 02:52:05 +03:00
sql_plugin.cc Backport of: 2009-12-08 12:57:07 +03:00
sql_plugin.h
sql_plugin_services.h
sql_prepare.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_prepare.h
sql_profile.cc Backport of: 2009-12-03 00:24:10 +03:00
sql_profile.h Backport of: 2009-12-03 00:24:10 +03:00
sql_rename.cc Backport of: 2009-12-01 22:13:01 +03:00
sql_repl.cc Manual resolving for the following files 2009-12-01 21:07:18 +02:00
sql_repl.h
sql_select.cc Backport of: 2009-12-01 17:39:03 +03:00
sql_select.h merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == build@mysql.com-20091104182209-iui387z35159aoyw 2009-11-30 14:34:39 +02:00
sql_servers.cc Backport of: 2009-12-08 12:57:07 +03:00
sql_servers.h
sql_show.cc Backport of: 2009-12-10 11:21:38 +03:00
sql_show.h
sql_signal.cc
sql_signal.h
sql_sort.h
sql_state.c
sql_string.cc Backport of: 2009-11-24 16:54:59 +03:00
sql_string.h
sql_table.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_tablespace.cc
sql_test.cc Initial import of WL#3726 "DDL locking for all metadata objects". 2009-11-30 18:55:03 +03:00
sql_trigger.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_trigger.h Backport of: 2009-12-08 17:13:12 +03:00
sql_udf.cc Backport of: 2009-12-08 12:57:07 +03:00
sql_udf.h
sql_union.cc
sql_update.cc Backport of: 2009-12-08 12:57:07 +03:00
sql_view.cc Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
sql_view.h
sql_yacc.yy Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
strfunc.cc
structs.h merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == build@mysql.com-20091104182209-iui387z35159aoyw 2009-11-30 14:34:39 +02:00
table.cc Backport of: 2009-12-10 11:21:38 +03:00
table.h Backport of revno: 2617.71.1 2009-12-10 11:53:20 +01:00
thr_malloc.cc
time.cc
transaction.cc Backport of revno ## 2617.31.1, 2617.31.3, 2617.31.4, 2617.31.5, 2009-12-05 02:02:48 +03:00
transaction.h Backport of: 2009-12-03 21:37:38 +03:00
tzfile.h
tztime.cc Backport of: 2009-12-08 12:57:07 +03:00
tztime.h
udf_example.c Backport of: 2009-11-24 16:54:59 +03:00
udf_example.def
uniques.cc Backport of: 2009-11-24 16:54:59 +03:00
unireg.cc Backport of: 2009-11-24 16:54:59 +03:00
unireg.h