MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:July 25 2006 3:43pm
Subject:bk commit into 5.0 tree (gkodinov:1.2216) BUG#21086
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 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-07-25 18:42:49+03:00, gkodinov@stripped +4 -0
  Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE clause is called
    When executing INSERT over a view with calculated columns it was assuming all
    elements of the fields collection are actually Item_field instances.
    This may not be true when inserting into a view and that view has columns that are 
    such expressions that allow updating (like setting a collation for example).
    Corrected to access field information through the filed_for_view_update() function and 
    retrieve correctly the field info even for "update-friendly" non-Item_field items.

  mysql-test/r/view.result@stripped, 2006-07-25 18:42:40+03:00, gkodinov@stripped +13 -0
    Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE clause is called
     - test suite

  mysql-test/t/view.test@stripped, 2006-07-25 18:42:41+03:00, gkodinov@stripped +19 -0
    Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE clause is called
     - test suite

  sql/item_strfunc.h@stripped, 2006-07-25 18:42:42+03:00, gkodinov@stripped +1 -1
    Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE clause is called
     - obvious typo fixed

  sql/sql_base.cc@stripped, 2006-07-25 18:42:42+03:00, gkodinov@stripped +7 -2
    Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE clause is called
     - must access field information through the filed_for_view_update() function to retrieve
       correctly the field info even for "update-friendly" non-Item_field items.

# 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/B21086-5.0-opt

--- 1.111/sql/item_strfunc.h	2006-07-25 18:43:05 +03:00
+++ 1.112/sql/item_strfunc.h	2006-07-25 18:43:05 +03:00
@@ -728,7 +728,7 @@ public:
   void fix_length_and_dec();
   bool eq(const Item *item, bool binary_cmp) const;
   const char *func_name() const { return "collate"; }
-  enum Functype func_type() const { return COLLATE_FUNC; }
+  enum Functype functype() const { return COLLATE_FUNC; }
   void print(String *str);
   Item_field *filed_for_view_update()
   {

--- 1.345/sql/sql_base.cc	2006-07-25 18:43:05 +03:00
+++ 1.346/sql/sql_base.cc	2006-07-25 18:43:05 +03:00
@@ -4959,12 +4959,17 @@ fill_record(THD * thd, List<Item> &field
             bool ignore_errors)
 {
   List_iterator_fast<Item> f(fields),v(values);
-  Item *value;
+  Item *value, *fld;
   Item_field *field;
   DBUG_ENTER("fill_record");
 
-  while ((field=(Item_field*) f++))
+  while ((fld= f++))
   {
+    if (!(field= fld->filed_for_view_update()))
+    {
+      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+      DBUG_RETURN(TRUE);
+    }
     value=v++;
     Field *rfield= field->field;
     TABLE *table= rfield->table;

--- 1.166/mysql-test/r/view.result	2006-07-25 18:43:06 +03:00
+++ 1.167/mysql-test/r/view.result	2006-07-25 18:43:06 +03:00
@@ -2807,3 +2807,16 @@ yadda
 yad
 DROP VIEW v1;
 DROP TABLE t1;
+CREATE TABLE t1 (s1 char);
+INSERT INTO t1 VALUES ('Z');
+CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
+CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
+INSERT INTO v1 (col) VALUES ('b');
+INSERT INTO v2 (col) VALUES ('c');
+SELECT s1 FROM t1;
+s1
+Z
+b
+c
+DROP VIEW v1, v2;
+DROP TABLE t1;

--- 1.151/mysql-test/t/view.test	2006-07-25 18:43:06 +03:00
+++ 1.152/mysql-test/t/view.test	2006-07-25 18:43:06 +03:00
@@ -2667,3 +2667,22 @@ SELECT * FROM v1;
 DROP VIEW v1;
 
 DROP TABLE t1;
+
+#
+# Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE 
+# clause is called
+#
+CREATE TABLE t1 (s1 char);
+INSERT INTO t1 VALUES ('Z');
+
+CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
+
+CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
+
+# either of these statements will cause crash
+INSERT INTO v1 (col) VALUES ('b');
+INSERT INTO v2 (col) VALUES ('c');
+
+SELECT s1 FROM t1;
+DROP VIEW v1, v2;
+DROP TABLE t1;
Thread
bk commit into 5.0 tree (gkodinov:1.2216) BUG#21086kgeorge25 Jul