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-10-26 12:40:58+03:00, gkodinov@stripped +5 -0
Bug #30788: Inconsistent retrieval of char/varchar
When using indexed search the server constructs a key image
from the right arguments of the sargable conditions.
String truncations during the creation of that image were
not checked for and reported. Also error checking when
using index for a subquery execution was not considering
such errors as fatal and was continuing to search with the
truncated string.
Fixed the error processing to include and handle the truncation
errors.
mysql-test/r/key.result@stripped, 2007-10-26 12:40:55+03:00, gkodinov@stripped +14 -0
Bug #30788: test case
mysql-test/t/key.test@stripped, 2007-10-26 12:40:55+03:00, gkodinov@stripped +14 -0
Bug #30788: test case
sql/field.cc@stripped, 2007-10-26 12:40:55+03:00, gkodinov@stripped +1 -1
Bug #30788: Check for data truncation errors (and
return the appropriate error).
The condition about not counting the cutted fields
is checked later.
sql/item_subselect.cc@stripped, 2007-10-26 12:40:56+03:00, gkodinov@stripped +9 -3
Bug #30788: Don't search the index when there are fatal
errors creating the key search image.
sql/sql_select.h@stripped, 2007-10-26 12:40:56+03:00, gkodinov@stripped +1 -1
Bug #30788: Treat truncation errors (2) as fatal key image creation
errors.
diff -Nrup a/mysql-test/r/key.result b/mysql-test/r/key.result
--- a/mysql-test/r/key.result 2007-09-20 11:54:44 +03:00
+++ b/mysql-test/r/key.result 2007-10-26 12:40:55 +03:00
@@ -462,4 +462,18 @@ EXPLAIN SELECT MAX(a) FROM t1 FORCE INDE
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
+INSERT INTO t1 VALUES ('a', 'aa');
+INSERT INTO t1 VALUES ('a', 'aaa');
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+a b
+CREATE INDEX I1 ON t1 (a);
+CREATE INDEX I2 ON t1 (b);
+EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+a b
+DROP TABLE t1;
End of 5.0 tests.
diff -Nrup a/mysql-test/t/key.test b/mysql-test/t/key.test
--- a/mysql-test/t/key.test 2007-05-22 15:58:29 +03:00
+++ b/mysql-test/t/key.test 2007-10-26 12:40:55 +03:00
@@ -443,4 +443,18 @@ ALTER TABLE t1 DISABLE KEYS;
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
DROP TABLE t1;
+#
+# Bug #30788: Inconsistent retrieval of char/varchar
+#
+
+CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
+INSERT INTO t1 VALUES ('a', 'aa');
+INSERT INTO t1 VALUES ('a', 'aaa');
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+CREATE INDEX I1 ON t1 (a);
+CREATE INDEX I2 ON t1 (b);
+EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+DROP TABLE t1;
+
--echo End of 5.0 tests.
diff -Nrup a/sql/field.cc b/sql/field.cc
--- a/sql/field.cc 2007-10-23 16:48:55 +03:00
+++ b/sql/field.cc 2007-10-26 12:40:55 +03:00
@@ -5907,7 +5907,7 @@ int Field_string::store(const char *from
Check if we lost any important data (anything in a binary string,
or any non-space in others).
*/
- if ((from_end_pos < from + length) &&
table->in_use->count_cuted_fields)
+ if (from_end_pos < from + length)
{
if (test_if_important_data(field_charset, from_end_pos, from + length))
{
diff -Nrup a/sql/item_subselect.cc b/sql/item_subselect.cc
--- a/sql/item_subselect.cc 2007-06-29 10:39:15 +03:00
+++ b/sql/item_subselect.cc 2007-10-26 12:40:56 +03:00
@@ -2173,6 +2173,7 @@ int subselect_indexsubquery_engine::exec
DBUG_ENTER("subselect_indexsubquery_engine::exec");
int error;
bool null_finding= 0;
+ bool impossible_key;
TABLE *table= tab->table;
((Item_in_subselect *) item)->value= 0;
@@ -2190,14 +2191,19 @@ int subselect_indexsubquery_engine::exec
if (copy_ref_key())
DBUG_RETURN(1);
+ impossible_key= (tab->ref.key_err & 1);
+
if (null_keypart)
DBUG_RETURN(scan_table());
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key);
- error= table->file->index_read(table->record[0],
- tab->ref.key_buff,
- tab->ref.key_length,HA_READ_KEY_EXACT);
+ if (!impossible_key)
+ error= table->file->index_read(table->record[0],
+ tab->ref.key_buff,
+ tab->ref.key_length,HA_READ_KEY_EXACT);
+ else
+ error= HA_ERR_KEY_NOT_FOUND;
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
error= report_error(table, error);
diff -Nrup a/sql/sql_select.h b/sql/sql_select.h
--- a/sql/sql_select.h 2007-10-10 16:26:00 +03:00
+++ b/sql/sql_select.h 2007-10-26 12:40:56 +03:00
@@ -615,7 +615,7 @@ public:
{
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);
+ return (err != 0 || res > 1 ? STORE_KEY_FATAL : (store_key_result) res);
}
};
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2549) BUG#30788 | kgeorge | 26 Oct |