From d17ad7b3a40e23d08bc8398dda5d784cbb988b59 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@macbook.gmz" <> Date: Mon, 19 Feb 2007 14:39:37 +0200 Subject: Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. Several problems fixed: 1. There was a "catch-all" context initialization in setup_tables() that was causing the table that we insert into to be visible in the SELECT part of an INSERT .. SELECT .. statement with no tables in its FROM clause. This was making sure all the under-initialized contexts in various parts of the code are not left uninitialized. Fixed by removing the "catch-all" statement and initializing the context in the parser. 2. Incomplete name resolution context when resolving the right-hand values in the ON DUPLICATE KEY UPDATE ... part of an INSERT ... SELECT ... caused columns from NATURAL JOIN/JOIN USING table references in the FROM clause of the select to be unavailable. Fixed by establishing a proper name resolution context. 3. When setting up the special name resolution context for problem 2 there was no check for cases where an aggregate function without a GROUP BY effectively takes the column from the SELECT part of an INSERT ... SELECT unavailable for ON DUPLICATE KEY UPDATE. Fixed by checking for that condition when setting up the name resolution context. --- sql/sql_help.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/sql_help.cc') diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 78349a6ef0d..ba7f1a534ea 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -656,6 +656,8 @@ bool mysqld_help(THD *thd, const char *mask) Init tables and fields to be usable from items tables do not contain VIEWs => we can pass 0 as conds */ + thd->lex->select_lex.context.table_list= + thd->lex->select_lex.context.first_name_resolution_table= &tables[0]; setup_tables(thd, &thd->lex->select_lex.context, &thd->lex->select_lex.top_join_list, tables, 0, &leaves, FALSE); -- cgit v1.2.1