#At file:///opt/local/work/mysql-6.1-fk-stage/
2695 Konstantin Osipov 2008-12-17
WL#148, Milestone 8, Part 2.
Interim commit.
modified:
sql/sp_head.cc
sql/sql_class.cc
sql/sql_class.h
=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc 2008-12-16 00:16:58 +0000
+++ b/sql/sp_head.cc 2008-12-16 21:49:29 +0000
@@ -4089,14 +4089,11 @@ bool walk_view_tables(THD *thd, TABLE_LI
bool walk_fks_tables(THD *thd, TABLE_LIST *table, Table_walker *walker)
{
- bool is_insert= (table->trg_event_map &
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_INSERT)));
- bool is_update= (table->trg_event_map &
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_UPDATE)));
- bool is_delete= (table->trg_event_map &
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_DELETE)));
+ uint8 trg_map_insert= (uint8) (1 << (int)TRG_EVENT_INSERT);
+ uint8 trg_map_update= (uint8) (1 << (int)TRG_EVENT_UPDATE);
+ uint8 trg_map_delete= (uint8) (1 << (int)TRG_EVENT_DELETE);
- if (is_insert || is_update)
+ if (table->trg_event_map & (trg_map_insert | trg_map_update))
{
List_iterator<Foreign_key_child_share> it(table->table->s->fkeys_child);
Foreign_key_child_share *fk;
@@ -4108,13 +4105,13 @@ bool walk_fks_tables(THD *thd, TABLE_LIS
return TRUE;
}
}
- if (is_update || is_delete)
+ if (table->trg_event_map & (trg_map_update | trg_map_delete))
{
List_iterator<Foreign_key_parent_share> it(table->table->s->fkeys_parent);
Foreign_key_parent_share *fk;
while ((fk= it++))
{
- if (is_update)
+ if (table->trg_event_map & trg_map_update)
{
if (walker->visit_one_table(fk->child_table_db.str,
fk->child_table_name.str,
@@ -4129,13 +4126,13 @@ bool walk_fks_tables(THD *thd, TABLE_LIS
TABLE_LIST *tl= find_prelocked_table(thd, fk->child_table_db.str,
fk->child_table_name.str,
TL_WRITE,
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_UPDATE)));
+ trg_map_update);
if (tl && walk_view_triggers_fks_tables(thd, tl, FALSE, walker))
return TRUE;
}
}
- if (is_delete)
+ if (table->trg_event_map & trg_map_delete)
{
if (walker->visit_one_table(fk->child_table_db.str,
fk->child_table_name.str,
@@ -4148,16 +4145,18 @@ bool walk_fks_tables(THD *thd, TABLE_LIS
if (fk->delete_opt == FK_OPTION_CASCADE)
{
TABLE_LIST *tl= find_prelocked_table(thd, fk->child_table_db.str,
- fk->child_table_name.str, TL_WRITE,
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_DELETE)));
+ fk->child_table_name.str,
+ TL_WRITE, trg_map_delete);
if (tl && walk_view_triggers_fks_tables(thd, tl, FALSE, walker))
return TRUE;
}
- else if (fk->delete_opt == FK_OPTION_SET_NULL || fk->delete_opt == FK_OPTION_DEFAULT)
+ else if (fk->delete_opt == FK_OPTION_SET_NULL ||
+ fk->delete_opt == FK_OPTION_DEFAULT)
{
TABLE_LIST *tl= find_prelocked_table(thd, fk->child_table_db.str,
- fk->child_table_name.str, TL_WRITE,
- static_cast<uint8>(1 << static_cast<int>(TRG_EVENT_UPDATE)));
+ fk->child_table_name.str,
+ TL_WRITE,
+ trg_map_update);
if (tl && walk_view_triggers_fks_tables(thd, tl, FALSE, walker))
return TRUE;
}
@@ -4247,8 +4246,9 @@ public:
Table_is_used_walker(const char *db_arg, const char *table_name_arg)
: db(db_arg), table_name(table_name_arg)
{ }
- virtual bool visit_one_table(const char *db_arg, const char *table_name_arg,
- thr_lock_type lock_type_arg)
+ virtual bool do_visit_one_table(const char *db_arg,
+ const char *table_name_arg,
+ thr_lock_type lock_type_arg)
{
return (!strcmp(db, db_arg) && !strcmp(table_name, table_name_arg));
}
@@ -4263,16 +4263,16 @@ public:
Check_if_table_being_updated_used_elsewhere_walker(THD *thd_arg, LEX *lex_arg)
: m_thd(thd_arg), m_lex(lex_arg)
{ }
- virtual bool visit_one_table(const char *db_arg,
- const char *table_name_arg,
- thr_lock_type lock_type_arg);
+ virtual bool do_visit_one_table(const char *db_arg,
+ const char *table_name_arg,
+ thr_lock_type lock_type_arg);
};
bool
Check_if_table_being_updated_used_elsewhere_walker::
-visit_one_table(const char *db_arg, const char *table_name_arg,
- thr_lock_type lock_type_arg)
+do_visit_one_table(const char *db_arg, const char *table_name_arg,
+ thr_lock_type lock_type_arg)
{
if (lock_type_arg < TL_WRITE_ALLOW_WRITE)
@@ -4509,5 +4509,7 @@ fk_check_if_cascade_has_conflict(THD *th
Check_if_table_being_updated_used_elsewhere_walker
cascade_affects_walker(thd, lex);
+ printf("fk_dmitri_check()\n");
+
return walk_fks_tables(thd, table, &cascade_affects_walker);
}
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2008-12-10 11:42:31 +0000
+++ b/sql/sql_class.cc 2008-12-16 21:49:29 +0000
@@ -225,6 +225,24 @@ bool foreign_key_prefix(Key *a, Key *b)
}
+bool
+Table_walker::visit_one_table(const char *db, const char *table_name,
+ thr_lock_type lock_type)
+{
+ printf("Visited: ");
+ for (const Recursion_sentry *sentry= m_last_sentry; sentry;
+ sentry= sentry->prev_sentry())
+ {
+ printf("-");
+ }
+ printf(">%s.%s\n", db, table_name);
+ return do_visit_one_table(db, table_name, lock_type);
+}
+
+Table_walker::~Table_walker()
+{
+}
+
/****************************************************************************
** Thread specific functions
****************************************************************************/
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2008-12-16 00:16:58 +0000
+++ b/sql/sql_class.h 2008-12-16 21:49:29 +0000
@@ -1266,13 +1266,17 @@ show_system_thread(enum_thread_type thre
class Table_walker
{
public:
- virtual bool visit_one_table(const char *db_arg,
- const char *table_name_arg,
- thr_lock_type lock_type_arg) = 0;
+
+ bool visit_one_table(const char *db, const char *table_name,
+ thr_lock_type lock_type);
Table_walker() :m_last_sentry(NULL) {}
- virtual ~Table_walker() {};
+ virtual ~Table_walker();
class Recursion_sentry;
+protected:
+ virtual bool do_visit_one_table(const char *db,
+ const char *table_name,
+ thr_lock_type lock_type) = 0;
private:
Recursion_sentry *m_last_sentry;
};
@@ -1316,6 +1320,7 @@ public:
}
return FALSE;
}
+ const Recursion_sentry *prev_sentry() const { return m_prev_sentry; }
private:
Table_walker *m_walker;
Recursion_sentry *m_prev_sentry;
| Thread |
|---|
| • bzr commit into mysql-6.1-fk branch (kostja:2695) WL#148 | Konstantin Osipov | 16 Dec |