summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-04-07 11:04:46 +0200
committerunknown <msvensson@neptunus.(none)>2006-04-07 11:04:46 +0200
commitf3de57d982df777be94d4952a0545854e75f1509 (patch)
treea0b486292d922e6ecc339c4bb79709616433feca /sql
parent224b63e3782fcf66c365f3d297985ecca0b2cccd (diff)
parent2f2607faeffb09d946e09a5f090a24449e73742b (diff)
downloadmariadb-git-f3de57d982df777be94d4952a0545854e75f1509.tar.gz
Merge bk-internal:/home/bk/mysql-5.0
into neptunus.(none):/home/msvensson/mysql/mysql-5.0 mysql-test/mysql-test-run.pl: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h9
-rw-r--r--sql/item_sum.cc5
-rw-r--r--sql/opt_sum.cc35
-rw-r--r--sql/sql_delete.cc3
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_update.cc5
6 files changed, 31 insertions, 28 deletions
diff --git a/sql/field.h b/sql/field.h
index 1bd72d79ce3..a4bdcc4da02 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -986,20 +986,23 @@ public:
class Field_string :public Field_longstr {
public:
+ bool can_alter_field_type;
Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg, CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, table_arg, cs) {};
+ unireg_check_arg, field_name_arg, table_arg, cs),
+ can_alter_field_type(1) {};
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, CHARSET_INFO *cs)
:Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, table_arg, cs) {};
+ NONE, field_name_arg, table_arg, cs),
+ can_alter_field_type(1) {};
enum_field_types type() const
{
- return ((orig_table &&
+ return ((can_alter_field_type && orig_table &&
orig_table->s->db_create_options & HA_OPTION_PACK_RECORD &&
field_length >= 4) &&
orig_table->s->frm_version < FRM_VER_TRUE_VARCHAR ?
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1cd1741cea6..8826144266e 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3226,7 +3226,10 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
}
if (agg_item_charsets(collation, func_name(),
- args, arg_count, MY_COLL_ALLOW_CONV))
+ args,
+ /* skip charset aggregation for order columns */
+ arg_count - arg_count_order,
+ MY_COLL_ALLOW_CONV))
return 1;
result.set_charset(collation.collation);
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index ed8e694dcb7..373753a7b80 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -96,8 +96,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
*/
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
{
+ TABLE_LIST *embedded;
+ for (embedded= tl ; embedded; embedded= embedded->embedding)
+ {
+ if (embedded->on_expr)
+ break;
+ }
+ if (embedded)
/* Don't replace expression on a table that is part of an outer join */
- if (tl->on_expr)
{
outer_tables|= tl->table->map;
@@ -117,8 +123,11 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
If the storage manager of 'tl' gives exact row count, compute the total
number of rows. If there are no outer table dependencies, this count
may be used as the real count.
+ Schema tables are filled after this function is invoked, so we can't
+ get row count
*/
- if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT)
+ if ((tl->table->file->table_flags() & HA_NOT_EXACT_COUNT) ||
+ tl->schema_table)
{
is_exact_count= FALSE;
count= 1; // ensure count != 0
@@ -143,31 +152,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
switch (item_sum->sum_func()) {
case Item_sum::COUNT_FUNC:
/*
- If the expr in count(expr) can never be null we can change this
+ If the expr in COUNT(expr) can never be null we can change this
to the number of rows in the tables if this number is exact and
there are no outer joins.
*/
if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null &&
!outer_tables && is_exact_count)
{
- longlong count= 1;
- TABLE_LIST *table;
- for (table= tables; table; table= table->next_leaf)
- {
- if (outer_tables || (table->table->file->table_flags() &
- HA_NOT_EXACT_COUNT) || table->schema_table)
- {
- const_result= 0; // Can't optimize left join
- break;
- }
- tables->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
- count*= table->table->file->records;
- }
- if (!table)
- {
- ((Item_sum_count*) item)->make_const(count);
- recalc_const_item= 1;
- }
+ ((Item_sum_count*) item)->make_const(count);
+ recalc_const_item= 1;
}
else
const_result= 0;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 56dbd423b69..37c4f9a3256 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -842,8 +842,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
table_list->db, table_list->table_name);
DBUG_RETURN(TRUE);
}
- if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)
- || thd->lex->sphead)
+ if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
goto trunc_by_del;
if (lock_and_wait_for_table_name(thd, table_list))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index f9d04fc873e..2f589f48c57 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3350,7 +3350,7 @@ end_with_restore_list:
Don't allow this within a transaction because we want to use
re-generate table
*/
- if ((thd->locked_tables && !lex->sphead) || thd->active_transaction())
+ if (thd->locked_tables || thd->active_transaction())
{
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index bfdd986f576..dfe23c9a503 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1093,6 +1093,11 @@ multi_update::initialize_tables(JOIN *join)
/* ok to be on stack as this is not referenced outside of this func */
Field_string offset(table->file->ref_length, 0, "offset",
table, &my_charset_bin);
+ /*
+ The field will be converted to varstring when creating tmp table if
+ table to be updated was created by mysql 4.1. Deny this.
+ */
+ offset.can_alter_field_type= 0;
if (!(ifield= new Item_field(((Field *) &offset))))
DBUG_RETURN(1);
ifield->maybe_null= 0;