Merge mysql.com:/home/gluh/MySQL/Merge/5.1

into  mysql.com:/home/gluh/MySQL/Merge/5.1-opt


BitKeeper/etc/ignore:
  auto-union
client/mysql.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysqld/lib_sql.cc:
  Auto merged
mysql-test/r/archive.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/delayed.result:
  Auto merged
mysql-test/r/func_misc.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/r/type_date.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/func_misc.test:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/type_date.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
mysys/queues.c:
  Auto merged
sql/events.cc:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_string.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_check.c:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
mysql-test/lib/mtr_report.pl:
  manual merge
mysql-test/r/myisam.result:
  manual merge
mysql-test/r/partition.result:
  manual merge
mysql-test/r/user_var.result:
  manual merge
mysql-test/t/myisam.test:
  manual merge
mysql-test/t/partition.test:
  manual merge
mysql-test/t/user_var.test:
  manual merge
sql/item.h:
  manual merge
sql/item_func.cc:
  manual merge
storage/myisammrg/ha_myisammrg.cc:
  manual merge
This commit is contained in:
unknown 2007-12-13 15:56:04 +04:00
commit 9a10c20ba9
133 changed files with 2674 additions and 678 deletions

View file

@ -24,7 +24,8 @@
#include <m_ctype.h>
#include "sql_select.h"
static bool convert_constant_item(THD *thd, Field *field, Item **item);
static bool convert_constant_item(THD *thd, Item_field *field_item,
Item **item);
static Item_result item_store_type(Item_result a, Item *item,
my_bool unsigned_flag)
@ -351,7 +352,7 @@ longlong Item_func_nop_all::val_int()
SYNOPSIS
convert_constant_item()
thd thread handle
field item will be converted using the type of this field
field_item item will be converted using the type of this field
item [in/out] reference to the item to convert
DESCRIPTION
@ -374,8 +375,10 @@ longlong Item_func_nop_all::val_int()
1 Item was replaced with an integer version of the item
*/
static bool convert_constant_item(THD *thd, Field *field, Item **item)
static bool convert_constant_item(THD *thd, Item_field *field_item,
Item **item)
{
Field *field= field_item->field;
int result= 0;
if (!(*item)->with_subselect && (*item)->const_item())
@ -385,6 +388,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
my_bitmap_map *old_write_map;
my_bitmap_map *old_read_map;
ulonglong orig_field_val; /* original field value if valid */
LINT_INIT(old_write_map);
LINT_INIT(old_read_map);
@ -398,7 +402,14 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
/*
Store the value of the field if it references an outer field because
the call to save_in_field below overrides that value.
*/
if (field_item->depended_from)
orig_field_val= field->val_int();
if (!(*item)->is_null() && !(*item)->save_in_field(field, 1))
{
Item *tmp= new Item_int_with_ref(field->val_int(), *item,
test(field->flags & UNSIGNED_FLAG));
@ -406,6 +417,13 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
thd->change_item_tree(item, tmp);
result= 1; // Item was replaced
}
/* Restore the original field value. */
if (field_item->depended_from)
{
result= field->store(orig_field_val, TRUE);
/* orig_field_val must be a valid value that can be restored back. */
DBUG_ASSERT(!result);
}
thd->variables.sql_mode= orig_sql_mode;
thd->count_cuted_fields= orig_count_cuted_fields;
if (table)
@ -462,15 +480,14 @@ void Item_bool_func2::fix_length_and_dec()
thd= current_thd;
if (!thd->is_context_analysis_only())
{
Item *arg_real_item= args[0]->real_item();
if (arg_real_item->type() == FIELD_ITEM)
if (args[0]->real_item()->type() == FIELD_ITEM)
{
Field *field=((Item_field*) arg_real_item)->field;
if (field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
Item_field *field_item= (Item_field*) (args[0]->real_item());
if (field_item->field->can_be_compared_as_longlong() &&
!(field_item->is_datetime() &&
args[1]->result_type() == STRING_RESULT))
{
if (convert_constant_item(thd, field,&args[1]))
if (convert_constant_item(thd, field_item, &args[1]))
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
@ -479,15 +496,14 @@ void Item_bool_func2::fix_length_and_dec()
}
}
}
arg_real_item= args[1]->real_item();
if (arg_real_item->type() == FIELD_ITEM)
if (args[1]->real_item()->type() == FIELD_ITEM)
{
Field *field=((Item_field*) arg_real_item)->field;
if (field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
Item_field *field_item= (Item_field*) (args[1]->real_item());
if (field_item->field->can_be_compared_as_longlong() &&
!(field_item->is_datetime() &&
args[0]->result_type() == STRING_RESULT))
{
if (convert_constant_item(thd, field,&args[0]))
if (convert_constant_item(thd, field_item, &args[0]))
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
@ -1959,16 +1975,16 @@ void Item_func_between::fix_length_and_dec()
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
{
Field *field=((Item_field*) (args[0]->real_item()))->field;
if (field->can_be_compared_as_longlong())
Item_field *field_item= (Item_field*) (args[0]->real_item());
if (field_item->field->can_be_compared_as_longlong())
{
/*
The following can't be recoded with || as convert_constant_item
changes the argument
*/
if (convert_constant_item(thd, field,&args[1]))
if (convert_constant_item(thd, field_item, &args[1]))
cmp_type=INT_RESULT; // Works for all types.
if (convert_constant_item(thd, field,&args[2]))
if (convert_constant_item(thd, field_item, &args[2]))
cmp_type=INT_RESULT; // Works for all types.
}
}
@ -3603,13 +3619,13 @@ void Item_func_in::fix_length_and_dec()
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
cmp_type != INT_RESULT)
{
Field *field= ((Item_field*) (args[0]->real_item()))->field;
if (field->can_be_compared_as_longlong())
Item_field *field_item= (Item_field*) (args[0]->real_item());
if (field_item->field->can_be_compared_as_longlong())
{
bool all_converted= TRUE;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
{
if (!convert_constant_item (thd, field, &arg[0]))
if (!convert_constant_item (thd, field_item, &arg[0]))
all_converted= FALSE;
}
if (all_converted)