List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:April 7 2011 10:31am
Subject:bzr commit into mysql-5.1 branch (gleb.shchepa:3648) Bug#11829681
View as plain text  
#At file:///mnt/sda7/work/bug11829681-5.1/ based on revid:georgi.kodinov@stripped

 3648 Gleb Shchepa	2011-04-07
      Bug #11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
      
      Select from a view with the underlying HAVING clause failed with a
      message: "1356: View '...' references invalid table(s) or column(s)
      or function(s) or definer/invoker of view lack rights to use them"
      
      The bug is a regression of the fix for bug 11750328 - 40825 (similar
      case, but the HAVING cause references an aliased field).
      In the old fix for bug 40825 the Item_field::name_length value has
      been used in place of the real length of Item_field::name. However,
      in some cases Item_field::name_length was not initialized by the actual
      length -- that has been fixed.
     @ mysql-test/r/view.result
        Test case for bug #11829681
     @ mysql-test/t/view.test
        Test case for bug #11829681
     @ sql/item.cc
        Bug #11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
        
        Item_ident::Item_ident constructors have been modified to update
        name_length fields with actual name length.

    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	2011-02-22 21:03:32 +0000
+++ b/mysql-test/r/view.result	2011-04-07 10:31:20 +0000
@@ -3897,6 +3897,15 @@ DROP TABLE t1;
 #
 CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
 DROP VIEW v1;
+#
+# Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+#
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+SELECT * FROM v1;
+a
+DROP VIEW v1;
+DROP TABLE t1;
 # -----------------------------------------------------------------
 # -- End of 5.1 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2011-02-22 21:03:32 +0000
+++ b/mysql-test/t/view.test	2011-04-07 10:31:20 +0000
@@ -3941,6 +3941,18 @@ DROP TABLE t1;
 CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
 DROP VIEW v1;
 
+--echo #
+--echo # Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+
+SELECT * FROM v1; 
+
+DROP VIEW v1;
+DROP TABLE t1;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.1 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-03-31 18:59:11 +0000
+++ b/sql/item.cc	2011-04-07 10:31:20 +0000
@@ -551,7 +551,8 @@ Item_ident::Item_ident(Name_resolution_c
    alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
    cached_table(0), depended_from(0)
 {
-  name = (char*) field_name_arg;
+  if ((name= (char*) field_name_arg))
+    name_length= strlen(name);
 }
 
 
@@ -563,7 +564,8 @@ Item_ident::Item_ident(TABLE_LIST *view_
    alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
    cached_table(NULL), depended_from(NULL)
 {
-  name = (char*) field_name_arg;
+  if ((name= (char*) field_name_arg))
+    name_length= strlen(name);
 }
 
 


Attachment: [text/bzr-bundle] bzr/gleb.shchepa@oracle.com-20110407103120-3p7bxmjgm5hszue3.bundle
Thread
bzr commit into mysql-5.1 branch (gleb.shchepa:3648) Bug#11829681Gleb Shchepa7 Apr