List:Internals« Previous MessageNext Message »
From:eugene Date:July 12 2005 6:49pm
Subject:bk commit into 5.0 tree (evgen:1.1913)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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.1913 05/07/12 20:49:43 evgen@stripped +3 -0
  Merge

  mysql-test/t/view.test
    1.80 05/07/12 20:49:42 evgen@stripped +0 -0
    SCCS merged

  mysql-test/r/view.result
    1.85 05/07/12 20:49:42 evgen@stripped +0 -0
    SCCS merged

  sql/sql_base.cc
    1.265 05/07/12 20:47:38 evgen@stripped +0 -0
    Auto merged

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/mysql-5.0-bug-11399/RESYNC

--- 1.264/sql/sql_base.cc	2005-07-09 21:55:09 +04:00
+++ 1.265/sql/sql_base.cc	2005-07-12 20:47:38 +04:00
@@ -2400,9 +2400,11 @@
     name			name of field
     item_name                   name of item if it will be created (VIEW)
     length			length of name
-    ref				expression substituted in VIEW should be
+    ref	[in/out]		expression substituted in VIEW should be
 				  passed using this reference (return
 				  view_ref_found)
+                                  (*ref != NULL) only if *ref contains
+                                  the item that we need to replace.
     check_grants_table		do check columns grants for table?
     check_grants_view		do check columns grants for view?
     allow_rowid			do allow finding of "_rowid" field?
@@ -2440,11 +2442,6 @@
     {
       if (!my_strcasecmp(system_charset_info, field_it.name(), name))
       {
-        Item *item= field_it.create_item(thd);
-        if (!item)
-        {
-          DBUG_RETURN(0);
-        }
         if (table_list->schema_table_reformed)
         {
           /*
@@ -2463,6 +2460,19 @@
 			       name, length))
 	  DBUG_RETURN(WRONG_GRANT);
 #endif
+        Item *item= field_it.create_item(thd);
+        if (!item)
+        {
+          DBUG_RETURN(0);
+        }
+        /*
+          *ref != NULL means that *ref contains the item that we need to
+          replace. If the item was aliased by the user, set the alias to
+          the replacing item.
+         */
+        if (*ref && !(*ref)->is_autogenerated_name)
+          item->set_name((*ref)->name, (*ref)->name_length,
+                         system_charset_info);
         if (register_tree_change)
           thd->change_item_tree(ref, item);
         else

--- 1.84/mysql-test/r/view.result	2005-07-06 19:28:55 +04:00
+++ 1.85/mysql-test/r/view.result	2005-07-12 20:49:42 +04:00
@@ -1923,6 +1923,14 @@
 set sql_mode=default;
 drop view v2,v1;
 drop table t1;
+create table t1 (f1 int);
+insert into t1 values (1);
+create view v1 as select f1 from t1;
+select f1 as alias from v1;
+alias
+1
+drop view v1;
+drop table t1;
 CREATE TABLE t1 (s1 int, s2 int);
 INSERT  INTO t1 VALUES (1,2);
 CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;

--- 1.79/mysql-test/t/view.test	2005-07-06 19:28:29 +04:00
+++ 1.80/mysql-test/t/view.test	2005-07-12 20:49:42 +04:00
@@ -1763,6 +1763,16 @@
 drop table t1;
 
 #
+# Bug#11399 Use an alias in a select statement on a view
+#
+create table t1 (f1 int);
+insert into t1 values (1);
+create view v1 as select f1 from t1;
+select f1 as alias from v1;
+drop view v1;
+drop table t1;
+
+#
 # Test for bug #6120: SP cache to be invalidated when altering a view
 #
 
Thread
bk commit into 5.0 tree (evgen:1.1913)eugene12 Jul