From: Date: February 2 2006 5:43am Subject: bk commit into 5.0 tree (igor:1.2026) BUG#16382 List-Archive: http://lists.mysql.com/commits/2039 X-Bug: 16382 Message-Id: <20060202044354.8737521DB64@rurik.mysql.com> Below is the list of changes that have just been committed into a local 5.0 repository of igor. When igor does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2026 06/02/01 20:43:43 igor@stripped +3 -0 Fixed bug #16382. When an ambiguous field name is used in a group by clause a warning is issued in the find_order_in_list function by a call to push_warning_printf. An expression that was not always valid was passed to this call as the field name parameter. sql/sql_select.cc 1.390 06/02/01 20:43:37 igor@stripped +2 -1 Fixed bug #16382. When an ambiguous field name is used in a group by clause a warning is issued in the find_order_in_list function by a call to push_warning_printf. An expression that was not always valid was passed to this call as the field name parameter. mysql-test/t/view.test 1.134 06/02/01 20:43:37 igor@stripped +17 -0 Added a test case for bug #16382. mysql-test/r/view.result 1.145 06/02/01 20:43:37 igor@stripped +34 -0 Added a test case for bug #16382. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: igor # Host: rurik.mysql.com # Root: /home/igor/dev/mysql-5.0-0 --- 1.389/sql/sql_select.cc 2006-01-27 21:20:09 -08:00 +++ 1.390/sql/sql_select.cc 2006-02-01 20:43:37 -08:00 @@ -12381,7 +12381,8 @@ overshadows the column reference from the SELECT list. */ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR, - ER(ER_NON_UNIQ_ERROR), from_field->field_name, + ER(ER_NON_UNIQ_ERROR), + ((Item_ident*) order_item)->field_name, current_thd->where); } } --- 1.144/mysql-test/r/view.result 2006-01-23 23:36:39 -08:00 +++ 1.145/mysql-test/r/view.result 2006-02-01 20:43:37 -08:00 @@ -2504,3 +2504,37 @@ 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +IF(x IS NULL, 'blank', 'not blank') +blank +not blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +x +blank +not blank +not blank +blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +y +blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +DROP VIEW v1; +DROP TABLE t1; --- 1.133/mysql-test/t/view.test 2006-01-23 23:36:39 -08:00 +++ 1.134/mysql-test/t/view.test 2006-02-01 20:43:37 -08:00 @@ -2363,3 +2363,20 @@ DROP VIEW v1; DROP TABLE t1; + +# +# Bug#16382: grouping name is resolved against a view column name +# which coincides with a select column name + +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; + +DROP VIEW v1; +DROP TABLE t1;