1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixes during review of new code

- Mostly indentation fixes
- Added missing test
- Ensure that Item_func_case() checks for stack overruns
- Use real_item() instead of (Item_ref*) item
- Fixed wrong error handling


myisam/mi_unique.c:
  Improved comments
myisam/myisampack.c:
  Updated version number
mysql-test/r/group_by.result:
  Added test that was lost during earlier merge
mysql-test/r/information_schema.result:
  Safety fix: Drop procedures before used
mysql-test/t/group_by.test:
  Added test that was lost during earlier merge
mysql-test/t/information_schema.test:
  Safety fix: Drop procedures before used
mysys/hash.c:
  Updated comment
sql/field.cc:
  false -> FALSE
sql/ha_ndbcluster.cc:
  Fix some style issues
  - No () around argument to 'case'
  - Space before ( in switch and if
  - Removed 'goto'
  - Added {}
  - Added () to make expressions easier to read
  - my_snprintf -> strmov
sql/handler.cc:
  if( -> if (
sql/item.cc:
  Indentation changes
sql/item.h:
  false -> FALSE
sql/item_cmpfunc.cc:
  Ensure that Item_func_case() check for stack overrun properly
sql/item_cmpfunc.h:
  Ensure that Item_func_case() check for stack overrun properly
sql/item_func.cc:
  Indentation fixes
  Fixed wrong goto label
sql/mysqld.cc:
  Remove test for opt_disable_networking as this flag can never be set here
sql/opt_range.cc:
  Simplify code
sql/sql_class.h:
  Move define out from middle of class definition
sql/sql_parse.cc:
  Remove extra empty lines
sql/sql_select.cc:
  use real_item() instead of (Item_ref*) item
  Modifed function comment to be align with others
  Simple optimization
sql/sql_union.cc:
  Portability fix:
  Don't use 'bool_variable|=...'
sql/sql_view.cc:
  Move List_iterator_fast out from loops (rewind is faster than creating a new itearator)
strings/ctype-utf8.c:
  if( -> if (
strings/ctype.c:
  Remove disabled code
strings/decimal.c:
  Indentation fixes
strings/xml.c:
  Indentation fixes
This commit is contained in:
unknown
2005-07-04 03:42:33 +03:00
parent 1aa6343fe8
commit 306ebf7b1c
26 changed files with 443 additions and 313 deletions

View File

@ -7978,9 +7978,11 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
convert_blob_length);
}
case Item::REF_ITEM:
if ( item->real_item()->type() == Item::FIELD_ITEM)
{
Item *tmp_item;
if ((tmp_item= item->real_item())->type() == Item::FIELD_ITEM)
{
Item_field *field= (Item_field*) *((Item_ref*)item)->ref;
Item_field *field= (Item_field*) tmp_item;
Field *new_field= create_tmp_field_from_field(thd,
(*from_field= field->field),
item->name, table,
@ -7990,6 +7992,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
item->set_result_field(new_field);
return new_field;
}
}
case Item::FUNC_ITEM:
case Item::COND_ITEM:
case Item::FIELD_AVG_ITEM:
@ -11791,14 +11794,13 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
SYNOPSIS
find_order_in_list()
thd [in] Pointer to current thread structure
ref_pointer_array [in/out] All select, group and order by fields
tables [in] List of tables to search in (usually FROM clause)
order [in] Column reference to be resolved
fields [in] List of fields to search in (usually SELECT list)
all_fields [in/out] All select, group and order by fields
is_group_field [in] True if order is a GROUP field, false if
ORDER by field
thd Pointer to current thread structure
ref_pointer_array All select, group and order by fields
tables List of tables to search in (usually FROM clause)
order Column reference to be resolved
fields List of fields to search in (usually SELECT list)
all_fields All select, group and order by fields
is_group_field True if order is a GROUP field, false if ORDER by field
DESCRIPTION
Given a column reference (represented by 'order') from a GROUP BY or ORDER
@ -11815,6 +11817,8 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
RETURN
FALSE if OK
TRUE if error occurred
ref_pointer_array and all_fields are updated
*/
static bool
@ -11866,20 +11870,18 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
/* Lookup the current GROUP field in the FROM clause. */
order_item_type= order_item->type();
from_field= (Field*) not_found_field;
if (is_group_field &&
order_item_type == Item::FIELD_ITEM ||
order_item_type == Item::REF_ITEM)
{
from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables,
&view_ref, IGNORE_ERRORS, TRUE);
if(!from_field)
from_field= (Field*) not_found_field;
if (!from_field)
from_field= (Field*) not_found_field;
}
else
from_field= (Field*) not_found_field;
if (from_field == not_found_field ||
from_field &&
(from_field != view_ref_found ?
/* it is field of base table => check that fields are same */
((*select_item)->type() == Item::FIELD_ITEM &&
@ -11892,37 +11894,40 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
view_ref->type() == Item::REF_ITEM &&
((Item_ref *) (*select_item))->ref ==
((Item_ref *) view_ref)->ref)))
/*
If there is no such field in the FROM clause, or it is the same field as
the one found in the SELECT clause, then use the Item created for the
SELECT field. As a result if there was a derived field that 'shadowed'
a table field with the same name, the table field will be chosen over
the derived field.
*/
{
/*
If there is no such field in the FROM clause, or it is the same field
as the one found in the SELECT clause, then use the Item created for
the SELECT field. As a result if there was a derived field that
'shadowed' a table field with the same name, the table field will be
chosen over the derived field.
*/
order->item= ref_pointer_array + counter;
order->in_field_list=1;
return FALSE;
}
else
{
/*
There is a field with the same name in the FROM clause. This is the field
that will be chosen. In this case we issue a warning so the user knows
that the field from the FROM clause overshadows the column reference from
the SELECT list.
There is a field with the same name in the FROM clause. This
is the field that will be chosen. In this case we issue a
warning so the user knows that the field from the FROM clause
overshadows the column reference from the SELECT list.
*/
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR,
ER(ER_NON_UNIQ_ERROR), from_field->field_name,
current_thd->where);
}
}
order->in_field_list=0;
/*
The call to order_item->fix_fields() means that here we resolve 'order_item'
to a column from a table in the list 'tables', or to a column in some outer
query. Exactly because of the second case we come to this point even if
(select_item == not_found_item), inspite of that fix_fields() calls
find_item_in_list() one more time.
The call to order_item->fix_fields() means that here we resolve
'order_item' to a column from a table in the list 'tables', or to
a column in some outer query. Exactly because of the second case
we come to this point even if (select_item == not_found_item),
inspite of that fix_fields() calls find_item_in_list() one more
time.
We check order_item->fixed because Item_func_group_concat can put
arguments for which fix_fields already was called.