MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:March 22 2007 4:44pm
Subject:bk commit into 5.0 tree (gkodinov:1.2425) BUG#26207
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, 2007-03-22 18:44:16+02:00, gkodinov@stripped +3 -0
  Bug #26207: When making the key image to use
   in index search MySQL was not explicitly
   suppressing warnings. And if the context 
   happens to enable warnings (e.g. INSERT ..
   SELECT) the warnings resulting from converting 
   the data the key is compared to are 
   reported to the client.
   Fixed by suppressing warnings when converting
   the data to the same type as the key parts.

  mysql-test/r/insert_select.result@stripped, 2007-03-22 18:44:15+02:00, gkodinov@stripped +29 -0
    Bug #26207: test case

  mysql-test/t/insert_select.test@stripped, 2007-03-22 18:44:15+02:00, gkodinov@stripped +26 -1
    Bug #26207: test case

  sql/sql_select.h@stripped, 2007-03-22 18:44:15+02:00, gkodinov@stripped +41 -12
    Bug #26207: supress warnings when converting
      data of the same type to key buffer format.

# 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:	magare.gmz
# Root:	/home/kgeorge/mysql/work/B26207-5.0-opt

--- 1.115/sql/sql_select.h	2007-01-12 22:22:37 +02:00
+++ 1.116/sql/sql_select.h	2007-03-22 18:44:15 +02:00
@@ -488,15 +488,11 @@ extern "C" int refpos_order_cmp(void* ar
 
 class store_key :public Sql_alloc
 {
- protected:
-  Field *to_field;				// Store data here
-  char *null_ptr;
-  char err;
 public:
   bool null_key; /* TRUE <=> the value of the key has a null part */
   enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
   store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
-    :null_ptr(null), err(0), null_key(0)
+    :null_key(0), null_ptr(null), err(0)
   {
     if (field_arg->type() == FIELD_TYPE_BLOB)
     {
@@ -510,8 +506,35 @@ public:
                                         ptr, (uchar*) null, 1);
   }
   virtual ~store_key() {}			/* Not actually needed */
-  virtual enum store_key_result copy()=0;
   virtual const char *name() const=0;
+
+  /**
+    @brief sets ignore truncation warnings mode and calls the real copy method
+
+    @details this function makes sure truncation warnings when preparing the
+    key buffers don't end up as errors (because of an enclosing INSERT/UPDATE).
+  */
+  enum store_key_result copy()
+  {
+    enum store_key_result result;
+    enum_check_fields saved_count_cuted_fields= 
+      to_field->table->in_use->count_cuted_fields;
+
+    to_field->table->in_use->count_cuted_fields= CHECK_FIELD_IGNORE;
+
+    result= copy_inner();
+
+    to_field->table->in_use->count_cuted_fields= saved_count_cuted_fields;
+
+    return result;
+  }
+
+ protected:
+  Field *to_field;				// Store data here
+  char *null_ptr;
+  char err;
+
+  virtual enum store_key_result copy_inner()=0;
 };
 
 
@@ -531,13 +554,15 @@ class store_key_field: public store_key
       copy_field.set(to_field,from_field,0);
     }
   }
-  enum store_key_result copy()
+  const char *name() const { return field_name; }
+
+ protected: 
+  enum store_key_result copy_inner()
   {
     copy_field.do_copy(&copy_field);
     null_key= to_field->is_null();
     return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
   }
-  const char *name() const { return field_name; }
 };
 
 
@@ -552,13 +577,15 @@ public:
 	       null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
 	       &err : NullS, length), item(item_arg)
   {}
-  enum store_key_result copy()
+  const char *name() const { return "func"; }
+
+ protected:  
+  enum store_key_result copy_inner()
   {
     int res= item->save_in_field(to_field, 1);
     null_key= to_field->is_null() || item->null_value;
     return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res); 
   }
-  const char *name() const { return "func"; }
 };
 
 
@@ -574,7 +601,10 @@ public:
 		    &err : NullS, length, item_arg), inited(0)
   {
   }
-  enum store_key_result copy()
+  const char *name() const { return "const"; }
+
+protected:  
+  enum store_key_result copy_inner()
   {
     int res;
     if (!inited)
@@ -589,7 +619,6 @@ public:
     null_key= to_field->is_null() || item->null_value;
     return (err > 2 ?  STORE_KEY_FATAL : (store_key_result) err);
   }
-  const char *name() const { return "const"; }
 };
 
 bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref);

--- 1.45/mysql-test/r/insert_select.result	2007-02-16 18:38:47 +02:00
+++ 1.46/mysql-test/r/insert_select.result	2007-03-22 18:44:15 +02:00
@@ -744,3 +744,32 @@ f1	f2
 2	2
 10	10
 DROP TABLE t1, t2;
+SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
+CREATE TABLE t2 (d VARCHAR(10));
+INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters');
+EXPLAIN
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+2	SUBQUERY	t1	ref	ix_c	ix_c	13	const	1	Using where
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')
+13
+13
+INSERT INTO t2 (d) 
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+INSERT INTO t2 (d) 
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
+INSERT INTO t2 (d)
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1)) 
+FROM t1;
+SELECT * FROM t2;
+d
+13
+13
+7
+7
+20
+20
+DROP TABLE t1,t2;

--- 1.37/mysql-test/t/insert_select.test	2007-02-16 18:38:50 +02:00
+++ 1.38/mysql-test/t/insert_select.test	2007-03-22 18:44:15 +02:00
@@ -306,4 +306,29 @@ INSERT INTO t2 (f1, f2)
 SELECT * FROM t2;
 DROP TABLE t1, t2;
 
- 
+#
+# Bug #26207: inserts don't work with shortened index
+#
+SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+
+CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
+CREATE TABLE t2 (d VARCHAR(10)); 
+INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters'); 
+
+EXPLAIN
+  SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+
+SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+
+INSERT INTO t2 (d) 
+  SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
+
+INSERT INTO t2 (d) 
+  SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
+
+INSERT INTO t2 (d)
+  SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1)) 
+  FROM t1;
+
+SELECT * FROM t2;
+DROP TABLE t1,t2;
Thread
bk commit into 5.0 tree (gkodinov:1.2425) BUG#26207kgeorge22 Mar