diff options
author | unknown <bell@sanja.is.com.ua> | 2003-11-23 21:26:43 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-11-23 21:26:43 +0200 |
commit | 381a8db6a63aa70ddb49c3145bcff36d628da176 (patch) | |
tree | fc26a723bc704982f8240c2041552c93c9488f90 /sql/item.cc | |
parent | 105087127ed6f05c03b34f79402341cebfb8b71a (diff) | |
download | mariadb-git-381a8db6a63aa70ddb49c3145bcff36d628da176.tar.gz |
after review fixes
mysql-test/r/union.result:
new tests, more correct results for old one
mysql-test/t/union.test:
new tests, more correct results for old one
sql/field.cc:
new way to make field types csting
sql/field.h:
new way to make field types csting
sql/item.cc:
new way to make field types csting
sql/sql_derived.cc:
fixed typo
sql/sql_lex.h:
comment added
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/sql/item.cc b/sql/item.cc index e5a9f9db740..c26e00456b7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1996,12 +1996,13 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) :Item(thd, *item), item_type(item->result_type()) { DBUG_ASSERT(item->fixed); + + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ if (item->type() == Item::FIELD_ITEM) - { - Item_field *fitem= (Item_field*) item; - field_example= (Field*) thd->memdup((const char*)fitem->field, - fitem->field->size_of()); - } + field_example= ((Item_field*) item)->field; else field_example= 0; } @@ -2023,23 +2024,18 @@ void Item_type_holder::join_types(THD *thd, Item *item) if (field_example && item->type() == Item::FIELD_ITEM) { Field *field= ((Item_field *)item)->field; - - // is new field better - if ((change_field= - field_example->convert_order() < field->convert_order())) + if (field_example->field_cast_type() != field->field_cast_type()) { - // is it compatible? - if (field->convert_order_compatible(field_example->convert_order())) - skip_store_field= 1; - } - else - { - /* - if old field can't store value of 'worse' new field we will make - decision about result field tipe based only on Item result type - */ - if (field_example->convert_order_compatible(field->convert_order())) - skip_store_field= 1; + if (!(change_field= + field_example->field_cast_compatible(field->field_cast_type()))) + { + /* + if old field can't store value of 'worse' new field we will make + decision about result field type based only on Item result type + */ + if (!field->field_cast_compatible(field_example->field_cast_type())) + skip_store_field= 1; + } } } @@ -2057,19 +2053,15 @@ void Item_type_holder::join_types(THD *thd, Item *item) ((new_type == INT_RESULT) && (decimals > item->decimals)) || (maybe_null && !item->maybe_null)); + /* + It is safe assign pointer on field, because it will be used just after + all JOIN::prepare calls and before any SELECT execution + */ if (skip_store_field || item->type() != Item::FIELD_ITEM) field_example= 0; else - { - /* - we do not need following, because we use mem_root - if (field_example) - thd->free(field_example) - */ - Item_field *fitem= (Item_field*) item; - field_example= (Field*) thd->memdup((const char*)fitem->field, - fitem->field->size_of()); - } + field_example= ((Item_field*) item)->field; + max_length= max(max_length, item->max_length); decimals= max(decimals, item->decimals); maybe_null|= item->maybe_null; |