diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2007-02-19 14:39:37 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2007-02-19 14:39:37 +0200 |
commit | a97fd193715799843f02228a01bba24e8b98fa44 (patch) | |
tree | cf74708b8339ba17919b8f5210fe226d74f16433 /mysql-test/r/insert_update.result | |
parent | 24903ed56ca2cceb3b9cb9f690ab47cc95e072be (diff) | |
download | mariadb-git-a97fd193715799843f02228a01bba24e8b98fa44.tar.gz |
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.
mysql-test/r/insert_update.result:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- test case
mysql-test/t/insert_update.test:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- test case
sql/item.h:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- save_next_local is not referenced any more outside class methods
sql/sql_base.cc:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- removed a "catch-all" code to cater for correct context initialization
sql/sql_help.cc:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- fixed the name resolution context initialization
sql/sql_insert.cc:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- Fixed the context of resolving the values in INSERT SELECT ON UPDATE
sql/sql_prepare.cc:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- Correct context for name resolution of prepared INSERT .. SELECT
sql/sql_union.cc:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- fixed the name resolution context initialization
sql/sql_yacc.yy:
Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving.
- Set the context here instead of setup_tables()
Diffstat (limited to 'mysql-test/r/insert_update.result')
-rw-r--r-- | mysql-test/r/insert_update.result | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index 6be37450835..f658ff06624 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -219,3 +219,20 @@ SELECT * FROM t1; a b 45 2 DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +INSERT INTO t1 SELECT 1, j; +ERROR 42S22: Unknown column 'j' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, c INT); +INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3 +ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; +ERROR 42S22: Unknown column 'a' in 'field list' +DROP TABLE t1,t2; |