MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:October 16 2006 10:10am
Subject:bk commit into 4.1 tree (gkodinov:1.2573) BUG#14019
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of kgeorge. When kgeorge 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@stripped, 2006-10-16 13:10:25+03:00, gkodinov@stripped +5 -0
  BUG#14019 : group by converts literal string to column name
     When resolving unqualified name references MySQL was not
     checking what is the item type for the reference. Thus
     e.g a string literal item that has by convention a name
     equal to its string value will also work as a reference to 
     a SELECT list item or a table field.
     Fixed by allowing only Item_ref or Item_field to referenced by
     (unqualified) name.

  mysql-test/r/func_gconcat.result@stripped, 2006-10-16 13:10:18+03:00, gkodinov@stripped +0 -5
    Bug #14019: group by converts literal string to column name
     - removed undeterministic testcase : order by a constant 
       means no order.

  mysql-test/r/group_by.result@stripped, 2006-10-16 13:10:18+03:00, gkodinov@stripped +45 -0
    Bug #14019: group by converts literal string to column name
     - test case

  mysql-test/t/func_gconcat.test@stripped, 2006-10-16 13:10:19+03:00, gkodinov@stripped +0 -1
    Bug #14019: group by converts literal string to column name
     - removed undeterministic testcase : order by a constant 
       means no order.

  mysql-test/t/group_by.test@stripped, 2006-10-16 13:10:19+03:00, gkodinov@stripped +23 -0
    Bug #14019: group by converts literal string to column name
     - test case

  sql/sql_base.cc@stripped, 2006-10-16 13:10:20+03:00, gkodinov@stripped +9 -2
    Bug #14019: group by converts literal string to column name
     - resolve unqualified by name refs only for real references

# 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:	gkodinov
# Host:	macbook.gmz
# Root:	/Users/kgeorge/mysql/work/B14019-4.1-opt

--- 1.272/sql/sql_base.cc	2006-10-16 13:10:35 +03:00
+++ 1.273/sql/sql_base.cc	2006-10-16 13:10:35 +03:00
@@ -2284,12 +2284,19 @@ find_item_in_list(Item *find, List<Item>
   const char *field_name=0;
   const char *table_name=0;
   bool found_unaliased_non_uniq= 0;
+  /*
+    true if the item that we search for is a valid name reference
+    (and not an item that happens to have a name).
+  */
+  bool is_ref_by_name= 0;
   uint unaliased_counter;
 
   LINT_INIT(unaliased_counter);
   *unaliased= FALSE;
 
-  if (find->type() == Item::FIELD_ITEM	|| find->type() == Item::REF_ITEM)
+  is_ref_by_name= (find->type() == Item::FIELD_ITEM  || 
+                   find->type() == Item::REF_ITEM);
+  if (is_ref_by_name)
   {
     field_name= ((Item_ident*) find)->field_name;
     table_name= ((Item_ident*) find)->table_name;
@@ -2401,7 +2408,7 @@ find_item_in_list(Item *find, List<Item>
       }
     }
     else if (!table_name && (item->eq(find,0) ||
-			     find->name && item->name &&
+			     is_ref_by_name && find->name && item->name &&
 			     !my_strcasecmp(system_charset_info, 
 					    item->name,find->name)))
     {

--- 1.52/mysql-test/r/group_by.result	2006-10-16 13:10:36 +03:00
+++ 1.53/mysql-test/r/group_by.result	2006-10-16 13:10:36 +03:00
@@ -773,3 +773,48 @@ select sql_buffer_result max(f1)+1 from 
 max(f1)+1
 3
 drop table t1;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT a FROM t1 GROUP BY 'a';
+a
+1
+SELECT a FROM t1 GROUP BY "a";
+a
+1
+SELECT a FROM t1 GROUP BY `a`;
+a
+1
+2
+set sql_mode=ANSI_QUOTES;
+SELECT a FROM t1 GROUP BY "a";
+a
+1
+2
+SELECT a FROM t1 GROUP BY 'a';
+a
+1
+SELECT a FROM t1 GROUP BY `a`;
+a
+1
+2
+set sql_mode='';
+SELECT a FROM t1 HAVING 'a' > 1;
+a
+SELECT a FROM t1 HAVING "a" > 1;
+a
+SELECT a FROM t1 HAVING `a` > 1;
+a
+2
+SELECT a FROM t1 ORDER BY 'a' DESC;
+a
+1
+2
+SELECT a FROM t1 ORDER BY "a" DESC;
+a
+1
+2
+SELECT a FROM t1 ORDER BY `a` DESC;
+a
+2
+1
+DROP TABLE t1;

--- 1.43/mysql-test/t/group_by.test	2006-10-16 13:10:36 +03:00
+++ 1.44/mysql-test/t/group_by.test	2006-10-16 13:10:36 +03:00
@@ -610,4 +610,27 @@ select sql_buffer_result max(f1) is null
 select sql_buffer_result max(f1)+1 from t1;
 drop table t1;
 
+#
+# BUG#14019-4.1-opt
+#
+CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1),(2);
+
+SELECT a FROM t1 GROUP BY 'a';
+SELECT a FROM t1 GROUP BY "a";
+SELECT a FROM t1 GROUP BY `a`;
+
+set sql_mode=ANSI_QUOTES;
+SELECT a FROM t1 GROUP BY "a";
+SELECT a FROM t1 GROUP BY 'a';
+SELECT a FROM t1 GROUP BY `a`;
+set sql_mode='';
+
+SELECT a FROM t1 HAVING 'a' > 1;
+SELECT a FROM t1 HAVING "a" > 1;
+SELECT a FROM t1 HAVING `a` > 1;
+
+SELECT a FROM t1 ORDER BY 'a' DESC;
+SELECT a FROM t1 ORDER BY "a" DESC;
+SELECT a FROM t1 ORDER BY `a` DESC;
+DROP TABLE t1;
 # End of 4.1 tests

--- 1.47/mysql-test/r/func_gconcat.result	2006-10-16 13:10:36 +03:00
+++ 1.48/mysql-test/r/func_gconcat.result	2006-10-16 13:10:36 +03:00
@@ -74,11 +74,6 @@ grp	group_concat(c order by 1)
 1	a
 2	b,c
 3	C,D,d,d,D,E
-select grp,group_concat(c order by "c") from t1 group by grp;
-grp	group_concat(c order by "c")
-1	a
-2	b,c
-3	C,D,d,d,D,E
 select grp,group_concat(distinct c order by c) from t1 group by grp;
 grp	group_concat(distinct c order by c)
 1	a

--- 1.37/mysql-test/t/func_gconcat.test	2006-10-16 13:10:36 +03:00
+++ 1.38/mysql-test/t/func_gconcat.test	2006-10-16 13:10:36 +03:00
@@ -32,7 +32,6 @@ select grp,group_concat(d order by a des
 select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
 select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
 select grp,group_concat(c order by 1) from t1 group by grp;
-select grp,group_concat(c order by "c") from t1 group by grp;
 select grp,group_concat(distinct c order by c) from t1 group by grp;
 select grp,group_concat(distinct c order by c desc) from t1 group by grp;
 explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
Thread
bk commit into 4.1 tree (gkodinov:1.2573) BUG#14019kgeorge16 Oct