Below is the list of changes that have just been committed into a local
4.1 repository of psergey. When psergey 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
1.2102 05/03/24 03:20:26 sergefp@stripped +2 -0
Cleanup in the code that removes checks in conditions
* Don't set HA_PART_KEY_SEG for columns that may be NULL, make it
mean what its name implies.
* Added check in test_if_ref, as now HA_PART_KEY_SEG means what one expects it to.
sql/table.cc
1.127 05/03/24 03:20:23 sergefp@stripped +0 -7
Don't set HA_PART_KEY_SEG for columns that may be NULL, make it mean what
is name implies (the corresponding test was adjusted accordingly)
sql/sql_select.cc
1.386 05/03/24 03:20:23 sergefp@stripped +28 -3
Cleanup in the code that removes conditions that are guaranteed to be true from
the WHERE clause:
* Made HA_PART_KEY_SEG mean what one expects it to, adjusted the test for it
ccordingly
* Added comments
# 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: sergefp
# Host: newbox.mylan
# Root: /home/psergey/mysql-4.1-nulls-scan-t3
--- 1.385/sql/sql_select.cc 2005-03-08 21:45:49 +03:00
+++ 1.386/sql/sql_select.cc 2005-03-24 03:20:23 +03:00
@@ -6798,15 +6798,39 @@
in sorted order.
*****************************************************************************/
-/* Return 1 if right_item is used removable reference key on left_item */
+/*
+ Check if validity of condition "left_item = right_item" is guaranteed by
+ use of ref/eq_ref method on left_item's underlying table. If it is, the
+ condition can be removed from the WHERE clause.
+
+ NOTES
+ The join structures are assumed to have been set accordingly.
+ The criteria is as follows:
+ * condition has form "t1.field1 = t2.field" or "t1.field1 = const_expr"
+ * condition is "same" as one used for ref/eq_ref scan.
+ * condition is NULL-rejecting (as 'ref' guarantees validity of '<=>')
+ * No value truncation/conversion is performed when obtaining key value
+ for ref scan.
+
+ RETURN
+ 1 - The ref/eq_ref access method is used for left_item underlying table
+ and the condition validity is guaranteed for all rows returned by the
+ access method.
+ 0 - Otherwise
+*/
static bool test_if_ref(Item_field *left_item,Item *right_item)
{
Field *field=left_item->field;
- // No need to change const test. We also have to keep tests on LEFT JOIN
+ /*
+ No need to change test if left_item refers to const table.
+ We also have to keep tests on LEFT JOIN
+ SergeyP: the latter seems to be redundant?
+ */
if (!field->table->const_table && !field->table->maybe_null)
{
Item *ref_item=part_of_refkey(field->table,field);
+ /* value of ref_item will be used as field value in ref/eq_ref access */
if (ref_item && ref_item->eq(right_item,1))
{
if (right_item->type() == Item::FIELD_ITEM)
@@ -6941,7 +6965,8 @@
for (uint part=0 ; part < ref_parts ; part++,key_part++)
if (field->eq(key_part->field) &&
- !(key_part->key_part_flag & HA_PART_KEY_SEG))
+ !(key_part->key_part_flag & HA_PART_KEY_SEG) &&
+ !key_part->field->real_maybe_null())
return table->reginfo.join_tab->ref.items[part];
}
return (Item*) 0;
--- 1.126/sql/table.cc 2005-03-04 00:51:18 +03:00
+++ 1.127/sql/table.cc 2005-03-24 03:20:23 +03:00
@@ -664,13 +664,6 @@
field->field_length=key_part->length;
}
}
- /*
- If the field can be NULL, don't optimize away the test
- key_part_column = expression from the WHERE clause
- as we need to test for NULL = NULL.
- */
- if (field->real_maybe_null())
- key_part->key_part_flag|= HA_PART_KEY_SEG;
}
else
{ // Error: shorten key
| Thread |
|---|
| • bk commit into 4.1 tree (sergefp:1.2102) | Sergey Petrunia | 24 Mar |