MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:April 16 2009 3:24pm
Subject:bzr commit into mysql-5.0-bugteam branch (gshchepa:2726) Bug#40825
View as plain text  
#At file:///home/uchum/work/bzr/40825-5.0/ based on revid:staale.smedseng@stripped

 2726 Gleb Shchepa	2009-04-16
      Bug#40825: Error 1356 while selecting from a view 
                 with a "HAVING" clause though query works
      
      SELECT from views defined like:
      
        CREATE VIEW v1 (view_column) 
          AS SELECT c AS alias FROM t1 HAVING alias
          
      fails with an error 1356: 
        View '...' references invalid table(s) or column(s) 
        or function(s) or definer/invoker of view lack rights 
        to use them
        
        
      CREATE VIEW form with a (column list) substitutes
      SELECT column names/aliases with new aliases.
      However, alias references in HAVING clause was
      not substituted.
      
      
      The Item_ref::print function has been modified
      to write correct aliased names of underlying
      items into VIEW definition generation/.frm file.
     @ mysql-test/r/view.result
        Added test file for bug #40825.
     @ mysql-test/t/view.test
        Added test file for bug #40825.
     @ sql/item.cc
        Bug#40825: Error 1356 while selecting from a view 
                   with a "HAVING" clause though query works
        
        The Item_ref::print function has been modified
        to write correct aliased names of underlying
        items into VIEW definition generation/.frm file.

    modified:
      mysql-test/r/view.result
      mysql-test/t/view.test
      sql/item.cc
=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2009-03-03 20:34:18 +0000
+++ b/mysql-test/r/view.result	2009-04-16 15:24:07 +0000
@@ -3705,5 +3705,21 @@ ERROR HY000: Key 'c2' doesn't exist in t
 DROP VIEW v1;
 DROP TABLE t1;
 # -----------------------------------------------------------------
+# -- Bug#40825: Error 1356 while selecting from a view 
+# --            with a "HAVING" clause though query works
+# -----------------------------------------------------------------
+
+CREATE TABLE t1 (c INT);
+
+CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias;
+SELECT * FROM v1;
+view_column
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+# -- End of test case for Bug#40825
+
+# -----------------------------------------------------------------
 # -- End of 5.0 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2009-03-03 20:34:18 +0000
+++ b/mysql-test/t/view.test	2009-04-16 15:24:07 +0000
@@ -3681,5 +3681,27 @@ DROP VIEW v1;
 DROP TABLE t1;
 
 --echo # -----------------------------------------------------------------
+--echo # -- Bug#40825: Error 1356 while selecting from a view 
+--echo # --            with a "HAVING" clause though query works
+--echo # -----------------------------------------------------------------
+--echo
+
+CREATE TABLE t1 (c INT);
+
+--echo
+
+CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias;
+SELECT * FROM v1;
+
+--echo
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo
+--echo # -- End of test case for Bug#40825
+--echo
+
+--echo # -----------------------------------------------------------------
 --echo # -- End of 5.0 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-04-01 11:02:26 +0000
+++ b/sql/item.cc	2009-04-16 15:24:07 +0000
@@ -5648,7 +5648,8 @@ void Item_ref::print(String *str)
         !table_name && name && alias_name_used)
     {
       THD *thd= current_thd;
-      append_identifier(thd, str, name, (uint) strlen(name));
+      Item *item= (*ref)->real_item();
+      append_identifier(thd, str, item->name, item->name_length);
     }
     else
       (*ref)->print(str);


Attachment: [text/bzr-bundle] bzr/gshchepa@mysql.com-20090416152407-6ygbtt0pbdh67e00.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (gshchepa:2726) Bug#40825Gleb Shchepa16 Apr
  • Re: bzr commit into mysql-5.0-bugteam branch (gshchepa:2726) Bug#40825Timour Katchaounov18 May