MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:March 9 2007 9:12am
Subject:bk commit into 5.0 tree (igor:1.2433) BUG#26661
View as plain text  
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@stripped, 2007-03-09 01:12:08-08:00, igor@stripped +3 -0
  Fixed bug #26661: crash when order by clause in a union
  construct references invalid name.
  Derived tables currently cannot use outer references.
  Thus there is no outer context for them.
  The 4.1 code takes this fact into account while the 
  Item_field::fix_outer_field code of 5.0 lost the check that blocks
  any attempts to resolve names in outer context for derived tables.

  mysql-test/r/union.result@stripped, 2007-03-09 01:12:04-08:00, igor@stripped +11 -0
    Added a test case for bug #26661.

  mysql-test/t/union.test@stripped, 2007-03-09 01:12:04-08:00, igor@stripped +13 -0
    Added a test case for bug #26661.

  sql/item.cc@stripped, 2007-03-09 01:12:04-08:00, igor@stripped +8 -0
    Fixed bug #26661.
    Derived tables currently cannot use outer references.
    Thus there is no outer context for them.
    The 4.1 code takes this fact into account while the 
    Item_field::fix_outer_field code of 5.0 lost the check that blocks
    any attempts to resolve names in outer context for derived tables.

# 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:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug26661

--- 1.252/sql/item.cc	2007-03-09 01:12:14 -08:00
+++ 1.253/sql/item.cc	2007-03-09 01:12:14 -08:00
@@ -3441,7 +3441,15 @@
   */
   Name_resolution_context *last_checked_context= context;
   Item **ref= (Item **) not_found_item;
+#if 0
   Name_resolution_context *outer_context= context->outer_context;
+#else
+  SELECT_LEX *current_sel= (SELECT_LEX *) thd->lex->current_select;
+  Name_resolution_context *outer_context= 0;
+  if (current_sel->master_unit()->first_select()->linkage !=
+      DERIVED_TABLE_TYPE)
+    outer_context= context->outer_context;
+#endif
   for (;
        outer_context;
        outer_context= outer_context->outer_context)

--- 1.87/mysql-test/r/union.result	2007-03-09 01:12:14 -08:00
+++ 1.88/mysql-test/r/union.result	2007-03-09 01:12:14 -08:00
@@ -1370,4 +1370,15 @@
 12
 12
 12345
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
+SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
+a
+1
+2
+3
+4
+SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
+ERROR 42S22: Unknown column 'c' in 'order clause'
+DROP TABLE t1;
 End of 5.0 tests

--- 1.97/mysql-test/t/union.test	2007-03-09 01:12:14 -08:00
+++ 1.98/mysql-test/t/union.test	2007-03-09 01:12:14 -08:00
@@ -855,4 +855,17 @@
 #
 select _utf8'12' union select _latin1'12345';
 
+#
+# Bug #26661: UNION with ORDER BY undefined column in FROM list
+#
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
+
+SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
+--error 1054 
+SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
+
+DROP TABLE t1;
+
 --echo End of 5.0 tests
Thread
bk commit into 5.0 tree (igor:1.2433) BUG#26661igor9 Mar