diff options
author | unknown <timour/timka@lamia.home> | 2006-09-13 15:24:06 +0300 |
---|---|---|
committer | unknown <timour/timka@lamia.home> | 2006-09-13 15:24:06 +0300 |
commit | a1c85e65f0615c57f30d3c20fbdaeb60679ff9bb (patch) | |
tree | 8f02ee23dfe417cd983e0b773685472e8731acc9 /sql | |
parent | 2214e282a3f37419aeb791350e461b07662845b8 (diff) | |
parent | 900e66f89567d740c4290963825206ac8a672df8 (diff) | |
download | mariadb-git-a1c85e65f0615c57f30d3c20fbdaeb60679ff9bb.tar.gz |
Merge lamia.home:/home/timka/mysql/src/5.0-bug-21774-sm
into lamia.home:/home/timka/mysql/src/5.0-dbg
sql/sql_base.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 15 | ||||
-rw-r--r-- | sql/sql_insert.cc | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3a12477bc15..c29c610b200 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4453,7 +4453,20 @@ bool setup_tables(THD *thd, Name_resolution_context *context, uint tablenr= 0; DBUG_ENTER("setup_tables"); - context->table_list= context->first_name_resolution_table= tables; + /* + Due to the various call paths that lead to setup_tables() it may happen + that context->table_list and context->first_name_resolution_table can be + NULL (this is typically done when creating TABLE_LISTs internally). + TODO: + Investigate all cases when this my happen, initialize the name resolution + context correctly in all those places, and remove the context reset below. + */ + if (!context->table_list || !context->first_name_resolution_table) + { + /* Test whether the context is in a consistent state. */ + DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list); + context->table_list= context->first_name_resolution_table= tables; + } /* this is used for INSERT ... SELECT. diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c08deedea72..b70d11e4b26 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -411,6 +411,15 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, table= table_list->table; context= &thd->lex->select_lex.context; + /* + These three asserts test the hypothesis that the resetting of the name + resolution context below is not necessary at all since the list of local + tables for INSERT always consists of one table. + */ + DBUG_ASSERT(!table_list->next_local); + DBUG_ASSERT(!context->table_list->next_local); + DBUG_ASSERT(!context->first_name_resolution_table->next_name_resolution_table); + /* Save the state of the current name resolution context. */ ctx_state.save_state(context, table_list); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e2c147e4cf7..d809c1b2cb0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3344,8 +3344,6 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; - /* Skip first table, which is the table we are inserting in */ - select_lex->context.table_list= first_table->next_local; if (!thd->locked_tables && !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) |