summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2009-12-10 14:26:00 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2009-12-10 14:26:00 +0100
commit2945f773f21cfefa3f8c4805dffc459697dcc118 (patch)
tree00d340ae6900aafeda4f27e206cbebd7ab3012c8 /sql/table.h
parent28b0eeff28f9ae8c834719bb852094f64f7157da (diff)
downloadmariadb-git-2945f773f21cfefa3f8c4805dffc459697dcc118.tar.gz
Backport of revno: 2617.68.37
Bug #46654 False deadlock on concurrent DML/DDL with partitions, inconsistent behavior The problem was that if one connection is running a multi-statement transaction which involves a single partitioned table, and another connection attempts to alter the table, the first connection gets ER_LOCK_DEADLOCK and cannot proceed anymore, even when the ALTER TABLE statement in another connection has timed out or failed. The reason for this was that the prepare phase for ALTER TABLE for partitioned tables removed all instances of the table from the table definition cache before it started waiting on the lock. The transaction running in the first connection would notice this and report ER_LOCK_DEADLOCK. This patch changes the prep_alter_part_table() ALTER TABLE code so that tdc_remove_table() is no longer called. Instead, only the TABLE instance changed by prep_alter_part_table() is marked as needing reopen. The patch also removes an unnecessary call to tdc_remove_table() from mysql_unpack_partition() as the changed TABLE object is destroyed by the caller at a later point. Test case added in partition_sync.test.
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/sql/table.h b/sql/table.h
index b44c2e9f3be..4b85d8a64f4 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -294,6 +294,8 @@ TABLE_CATEGORY get_table_category(const LEX_STRING *db,
struct TABLE_share;
+extern ulong refresh_version;
+
/*
This structure is shared between different table objects. There is one
instance of table share per one table in the database.
@@ -503,6 +505,14 @@ struct TABLE_SHARE
return table_map_id;
}
+
+ /*
+ Must all TABLEs be reopened?
+ */
+ inline bool needs_reopen()
+ {
+ return version != refresh_version;
+ }
/**
Convert unrelated members of TABLE_SHARE to one enum
representing its type.
@@ -605,8 +615,6 @@ struct TABLE_SHARE
};
-extern ulong refresh_version;
-
/* Information for one open table */
enum index_hint_type
{
@@ -804,6 +812,7 @@ public:
my_bool insert_or_update; /* Can be used by the handler */
my_bool alias_name_used; /* true if table_name is alias */
my_bool get_fields_in_item_tree; /* Signal to fix_field */
+ my_bool m_needs_reopen;
REGINFO reginfo; /* field connections */
MEM_ROOT mem_root;
@@ -853,7 +862,7 @@ public:
Is this instance of the table should be reopen?
*/
inline bool needs_reopen()
- { return s->version != refresh_version; }
+ { return !db_stat || m_needs_reopen; }
};