diff options
author | unknown <bell@sanja.is.com.ua> | 2003-08-11 11:51:33 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-08-11 11:51:33 +0300 |
commit | e64769909ce410eb052c26ed09875b34a653c1aa (patch) | |
tree | cc66619bf32dd812402d0ab049143317f87a272c | |
parent | 6181294dab759a6f5197573f164ee061668b1d18 (diff) | |
parent | b9aa175cb282ce92e733412a74e23ba750f8dd80 (diff) | |
download | mariadb-git-e64769909ce410eb052c26ed09875b34a653c1aa.tar.gz |
merge
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_strfunc.h:
Auto merged
sql/item_sum.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_derived.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_union.cc:
Auto merged
sql/table.h:
Auto merged
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rwxr-xr-x | Build-tools/Bootstrap | 19 | ||||
-rw-r--r-- | client/mysqldump.c | 2 | ||||
-rw-r--r-- | mysql-test/r/count_distinct3.result | 7 | ||||
-rw-r--r-- | mysql-test/r/derived.result | 2 | ||||
-rw-r--r-- | mysql-test/r/innodb.result | 10 | ||||
-rw-r--r-- | mysql-test/r/union.result | 13 | ||||
-rw-r--r-- | mysql-test/t/count_distinct3.test | 55 | ||||
-rw-r--r-- | mysql-test/t/union.test | 9 | ||||
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 12 | ||||
-rw-r--r-- | sql/item.cc | 23 | ||||
-rw-r--r-- | sql/item.h | 21 | ||||
-rw-r--r-- | sql/item_buff.cc | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 42 | ||||
-rw-r--r-- | sql/item_func.cc | 16 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 43 | ||||
-rw-r--r-- | sql/item_strfunc.h | 26 | ||||
-rw-r--r-- | sql/item_sum.cc | 2 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 8 | ||||
-rw-r--r-- | sql/item_timefunc.h | 20 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/records.cc | 8 | ||||
-rw-r--r-- | sql/set_var.h | 2 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 12 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_derived.cc | 10 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 | ||||
-rw-r--r-- | sql/sql_table.cc | 17 | ||||
-rw-r--r-- | sql/sql_union.cc | 18 | ||||
-rw-r--r-- | sql/table.h | 1 |
31 files changed, 270 insertions, 149 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 415461d735d..3c3e86142c5 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -23,6 +23,7 @@ davida@isil.mysql.com dlenev@mysql.com gluh@gluh.(none) gluh@gluh.mysql.r18.ru +greg@gcw.ath.cx greg@mysql.com guilhem@mysql.com gweir@build.mysql.com diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 9f5fc37736d..25c256d614b 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -42,6 +42,7 @@ $opt_suffix= ""; $opt_test= undef; $opt_skip_check= undef; $opt_skip_manual= undef; +$opt_win_dist= undef; $version= "unknown"; GetOptions( @@ -60,7 +61,8 @@ GetOptions( "skip-manual", "suffix=s", "test|t", - "verbose|v" + "verbose|v", + "win-dist|w" ) || print_help(""); # @@ -300,7 +302,17 @@ $command= "make dist"; &run_command($command, "make dist failed!"); # -# Run "make distcheck" to verify the source archive +# Package the Windows source +# +if ($opt_win_dist) +{ + &logger ("Creating Windows source package"); + $command= "./scripts/make_win_src_distibution"; + &run_command($command, "make_win_src_distribution failed!"); +} + +# +# Run "make distcheck" to verify the source archive # if (!$opt_skip_check) { @@ -327,7 +339,7 @@ sub print_help print "ERROR: $message\n"; } print <<EOF; - + Usage: Bootstrap [options] <bk repository> Checks out (exports) a clear-text version of the given local BitKeeper @@ -373,6 +385,7 @@ Options: (e.g. "-20020518"). -t, --test Run the test suite after build -v, --verbose Be verbose +-w, --win-dist Also make Windows source distribution Example: diff --git a/client/mysqldump.c b/client/mysqldump.c index 2c8628d10a8..b317c7e5d13 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -369,7 +369,7 @@ static void write_footer(FILE *sql_file) fprintf(sql_file,"</mysqldump>"); else { - fprintf(md_result_file,"\n + fprintf(md_result_file,"\n\ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n\ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n\ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n\ diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result new file mode 100644 index 00000000000..633bb2fa252 --- /dev/null +++ b/mysql-test/r/count_distinct3.result @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); +SELECT COUNT(*) FROM t1; +COUNT(*) +4181000 +SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; +DROP TABLE t1; diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 5f405d83fa5..61937ba9266 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -137,7 +137,7 @@ a t explain select count(*) from t1 as tt1, (select * from t1) as tt2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -2 DERIVED tt1 index NULL a 4 NULL 10000 Using index +2 DERIVED tt1 ALL NULL NULL NULL NULL 10000 drop table t1; SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b; (SELECT * FROM (SELECT 1 as a) as a ) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 01aad9dcd62..69268f1d5c5 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1322,10 +1322,10 @@ SELECT t2.id, t1.label FROM t2 INNER JOIN (SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); id label -3382 Fournisseur Test -102 Fournisseur Test -1794 Fournisseur Test -1822 Fournisseur Test -3524 Fournisseur Test +3382 Test +102 Le Pekin (Test) +1794 Test de resto +1822 Test 3 +3524 Societe Test 3525 Fournisseur Test drop table t1,t2; diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 5b7b26bc1bb..6d8bd263546 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -328,3 +328,16 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 2 UNION t1 ref b b 5 const 1 Using where drop table t1,t2; +create table t1 ( id int not null auto_increment, primary key (id) ,user_name text ); +create table t2 ( id int not null auto_increment, primary key (id) ,group_name text ); +create table t3 ( id int not null auto_increment, primary key (id) ,user_id int ,index user_idx (user_id) ,foreign key (user_id) references users(id) ,group_id int ,index group_idx (group_id) ,foreign key (group_id) references groups(id) ); +insert into t1 (user_name) values ('Tester'); +insert into t2 (group_name) values ('Group A'); +insert into t2 (group_name) values ('Group B'); +insert into t3 (user_id, group_id) values (1,1); +select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c; +is_in_group user_name group_name id +1 Tester Group A 1 +0 Tester Group A NULL +0 Tester Group B NULL +drop table t1, t2, t3; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test new file mode 100644 index 00000000000..e6cc98d47df --- /dev/null +++ b/mysql-test/t/count_distinct3.test @@ -0,0 +1,55 @@ +# +# this is a test for error 1032 in count(distinct) + group by, introduced in +# mysql-4.1 +# + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); + +--disable_query_log +SET @rnd_max= 2147483647; +let $1 = 1000; +while ($1) +{ + SET @rnd= RAND(); + SET @id = CAST(@rnd * @rnd_max AS UNSIGNED); + SET @id_rev= @rnd_max - @id; + SET @grp= CAST(128.0 * @rnd AS UNSIGNED); + INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); + dec $1; +} +CREATE TABLE t2 SELECT * FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +DROP TABLE t2; +--enable_query_log + +SELECT COUNT(*) FROM t1; + +# As t1 contains random numbers, results are different from test to test. +# That's okay, because we test only that select doesn't yield an +# error. Note, that --disable_result_log doesn't suppress error output. + +--disable_result_log +SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; +--enable_result_log +DROP TABLE t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 6d857a4b40f..aeea27ade0f 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -209,3 +209,12 @@ explain (select * from t1 where a=1) union (select * from t2 where a=1); explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); explain (select * from t1 where a=1) union (select * from t1 where b=1); drop table t1,t2; +create table t1 ( id int not null auto_increment, primary key (id) ,user_name text ); +create table t2 ( id int not null auto_increment, primary key (id) ,group_name text ); +create table t3 ( id int not null auto_increment, primary key (id) ,user_id int ,index user_idx (user_id) ,foreign key (user_id) references users(id) ,group_id int ,index group_idx (group_id) ,foreign key (group_id) references groups(id) ); +insert into t1 (user_name) values ('Tester'); +insert into t2 (group_name) values ('Group A'); +insert into t2 (group_name) values ('Group B'); +insert into t3 (user_id, group_id) values (1,1); +select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c; +drop table t1, t2, t3; diff --git a/sql/filesort.cc b/sql/filesort.cc index 2130bdaeb93..13989bdae8f 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -519,7 +519,7 @@ static void make_sortkey(register SORTPARAM *param, switch (sort_field->result_type) { case STRING_RESULT: { - CHARSET_INFO *cs=item->charset(); + CHARSET_INFO *cs=item->collation.collation; if ((maybe_null=item->maybe_null)) *to++=1; /* All item->str() to use some extra byte for end null.. */ @@ -1040,7 +1040,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) switch ((sortorder->result_type=sortorder->item->result_type())) { case STRING_RESULT: sortorder->length=sortorder->item->max_length; - if (use_strnxfrm((cs=sortorder->item->charset()))) + if (use_strnxfrm((cs=sortorder->item->collation.collation))) { sortorder->length= sortorder->length*cs->strxfrm_multiply; sortorder->need_strxnfrm= 1; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 4f1021232a4..70322cef6fd 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -767,12 +767,20 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) void ha_myisam::deactivate_non_unique_index(ha_rows rows) { MYISAM_SHARE* share = file->s; + bool do_warning=0; if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1) { if (!(specialflag & SPECIAL_SAFE_MODE)) { if (rows == HA_POS_ERROR) + { + uint orig_update= file->update; + file->update ^= HA_STATE_CHANGED; + uint check_update= file->update; mi_extra(file, HA_EXTRA_NO_KEYS, 0); + do_warning= (file->update == check_update) && file->state->records; + file->update= orig_update; + } else { /* @@ -797,6 +805,10 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows) } else enable_activate_all_index=0; + if (do_warning) + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA, + ER(ER_ILLEGAL_HA), table->table_name); } diff --git a/sql/item.cc b/sql/item.cc index 5604e709ff5..58c47025a6f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -42,7 +42,7 @@ Item::Item(): { marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; - set_charset(default_charset(), DERIVATION_COERCIBLE); + collation.set(default_charset(), DERIVATION_COERCIBLE); name= 0; decimals= 0; max_length= 0; THD *thd= current_thd; @@ -157,7 +157,7 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const { if (binary_cmp) return !sortcmp(&str_value, &item->str_value, &my_charset_bin); - return !sortcmp(&str_value, &item->str_value, charset()); + return !sortcmp(&str_value, &item->str_value, collation.collation); } return 0; } @@ -266,7 +266,7 @@ bool DTCollation::aggregate(DTCollation &dt) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) { set_field(f); - set_charset(DERIVATION_IMPLICIT); + collation.set(DERIVATION_IMPLICIT); fixed= 1; // This item is not needed in fix_fields } @@ -275,7 +275,7 @@ Item_field::Item_field(THD *thd, Item_field &item): Item_ident(thd, item), field(item.field), result_field(item.result_field) -{ set_charset(DERIVATION_IMPLICIT); } +{ collation.set(DERIVATION_IMPLICIT); } void Item_field::set_field(Field *field_par) { @@ -287,7 +287,7 @@ void Item_field::set_field(Field *field_par) field_name=field_par->field_name; db_name=field_par->table->table_cache_key; unsigned_flag=test(field_par->flags & UNSIGNED_FLAG); - set_charset(field_par->charset(), DERIVATION_IMPLICIT); + collation.set(field_par->charset(), DERIVATION_IMPLICIT); } const char *Item_ident::full_name() const @@ -956,7 +956,7 @@ void Item::init_make_field(Send_field *tmp_field, tmp_field->org_col_name= empty_name; tmp_field->table_name= empty_name; tmp_field->col_name= name; - tmp_field->charsetnr= charset()->number; + tmp_field->charsetnr= collation.collation->number; tmp_field->flags=maybe_null ? 0 : NOT_NULL_FLAG; tmp_field->type=field_type; tmp_field->length=max_length; @@ -1070,7 +1070,7 @@ int Item::save_in_field(Field *field, bool no_conversions) field->result_type() == STRING_RESULT) { String *result; - CHARSET_INFO *cs=charset(); + CHARSET_INFO *cs= collation.collation; char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns str_value.set_quick(buff,sizeof(buff),cs); result=val_str(&str_value); @@ -1107,7 +1107,8 @@ int Item_string::save_in_field(Field *field, bool no_conversions) if (null_value) return set_field_to_null(field); field->set_notnull(); - return (field->store(result->ptr(),result->length(),charset())) ? -1 : 0; + return (field->store(result->ptr(),result->length(),collation.collation)) ? + -1 : 0; } @@ -1161,7 +1162,7 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) str+=2; } *ptr=0; // Keep purify happy - set_charset(&my_charset_bin, DERIVATION_COERCIBLE); + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); } longlong Item_varbinary::val_int() @@ -1182,7 +1183,7 @@ int Item_varbinary::save_in_field(Field *field, bool no_conversions) field->set_notnull(); if (field->result_type() == STRING_RESULT) { - error=field->store(str_value.ptr(),str_value.length(),charset()); + error=field->store(str_value.ptr(),str_value.length(),collation.collation); } else { @@ -1675,7 +1676,7 @@ Item_cache* Item_cache::get_cache(Item_result type) void Item_cache_str::store(Item *item) { - value_buff.set(buffer, sizeof(buffer), item->charset()); + value_buff.set(buffer, sizeof(buffer), item->collation.collation); value= item->str_result(&value_buff); if ((null_value= item->null_value)) value= 0; diff --git a/sql/item.h b/sql/item.h index b29ad7fed22..82c61466200 100644 --- a/sql/item.h +++ b/sql/item.h @@ -171,21 +171,6 @@ public: virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); } CHARSET_INFO *default_charset() const; - Derivation derivation() const { return collation.derivation; } - CHARSET_INFO *charset() const { return collation.collation; } - void set_charset(CHARSET_INFO *cs) - { collation.collation= cs; } - void set_charset(Derivation dv) - { collation.derivation= dv; } - void set_charset(CHARSET_INFO *cs, Derivation dv) - { collation.collation= cs; collation.derivation= dv; } - void set_charset(Item &item) - { collation= item.collation; } - void set_charset(DTCollation *collation_arg) - { - collation.collation= collation_arg->collation; - collation.derivation= collation_arg->derivation; - } virtual bool walk(Item_processor processor, byte *arg) { @@ -237,7 +222,7 @@ public: Item_field(const char *db_par,const char *table_name_par, const char *field_name_par) :Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0) - { set_charset(DERIVATION_IMPLICIT); } + { collation.set(DERIVATION_IMPLICIT); } // Constructor need to process subselect with temporary tables (see Item) Item_field(THD *thd, Item_field &item); Item_field(Field *field); @@ -440,7 +425,7 @@ public: Item_string(const char *str,uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { - set_charset(cs, dv); + collation.set(cs, dv); str_value.set(str,length,cs); max_length=length; set_name(str, length, cs); @@ -449,7 +434,7 @@ public: Item_string(const char *name_par, const char *str, uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { - set_charset(cs, dv); + collation.set(cs, dv); str_value.set(str,length,cs); max_length=length; set_name(name_par,0,cs); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index c4431294dff..1559cfe958e 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -57,7 +57,7 @@ bool Item_str_buff::cmp(void) else if (null_value) return 0; // new and old value was null else - tmp= sortcmp(&value,res,item->charset()) != 0; + tmp= sortcmp(&value,res,item->collation.collation) != 0; if (tmp) value.copy(*res); // Remember for next cmp return tmp; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5b19e4b745b..c78e032c943 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -151,15 +151,17 @@ void Item_bool_func2::fix_length_and_dec() uint strong= 0; uint weak= 0; - if ((args[0]->derivation() < args[1]->derivation()) && - !my_charset_same(args[0]->charset(), args[1]->charset()) && - (args[0]->charset()->state & MY_CS_UNICODE)) + if ((args[0]->collation.derivation < args[1]->collation.derivation) && + !my_charset_same(args[0]->collation.collation, + args[1]->collation.collation) && + (args[0]->collation.collation->state & MY_CS_UNICODE)) { weak= 1; } - else if ((args[1]->derivation() < args[0]->derivation()) && - !my_charset_same(args[0]->charset(), args[1]->charset()) && - (args[1]->charset()->state & MY_CS_UNICODE)) + else if ((args[1]->collation.derivation < args[0]->collation.derivation) && + !my_charset_same(args[0]->collation.collation, + args[1]->collation.collation) && + (args[1]->collation.collation->state & MY_CS_UNICODE)) { strong= 1; } @@ -172,15 +174,15 @@ void Item_bool_func2::fix_length_and_dec() String tmp, cstr; String *ostr= args[weak]->val_str(&tmp); cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - args[strong]->charset()); + args[strong]->collation.collation); conv= new Item_string(cstr.ptr(),cstr.length(),cstr.charset(), - args[weak]->derivation()); + args[weak]->collation.derivation); ((Item_string*)conv)->str_value.copy(); } else { - conv= new Item_func_conv_charset(args[weak],args[strong]->charset()); - conv->collation.set(args[weak]->derivation()); + conv= new Item_func_conv_charset(args[weak],args[strong]->collation.collation); + conv->collation.set(args[weak]->collation.derivation); } args[weak]= conv ? conv : args[weak]; } @@ -730,13 +732,13 @@ Item_func_ifnull::val_str(String *str) if (!args[0]->null_value) { null_value=0; - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } res=args[1]->val_str(str); if ((null_value=args[1]->null_value)) return 0; - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } @@ -755,12 +757,12 @@ Item_func_if::fix_length_and_dec() if (null1) { cached_result_type= arg2_type; - set_charset(args[2]->charset()); + collation.set(args[2]->collation.collation); } else if (null2) { cached_result_type= arg1_type; - set_charset(args[1]->charset()); + collation.set(args[1]->collation.collation); } else { @@ -772,7 +774,7 @@ Item_func_if::fix_length_and_dec() } else { - set_charset(&my_charset_bin); // Number + collation.set(&my_charset_bin); // Number } } } @@ -802,7 +804,7 @@ Item_func_if::val_str(String *str) Item *arg= args[0]->val_int() ? args[1] : args[2]; String *res=arg->val_str(str); if (res) - res->set_charset(charset()); + res->set_charset(collation.collation); null_value=arg->null_value; return res; } @@ -1187,7 +1189,7 @@ void in_string::set(uint pos,Item *item) if (!str->charset()) { CHARSET_INFO *cs; - if (!(cs= item->charset())) + if (!(cs= item->collation.collation)) cs= &my_charset_bin; // Should never happen for STR items str->set_charset(cs); } @@ -1265,7 +1267,7 @@ cmp_item* cmp_item::get_comparator(Item *item) { switch (item->result_type()) { case STRING_RESULT: - return new cmp_item_sort_string(item->charset()); + return new cmp_item_sort_string(item->collation.collation); break; case INT_RESULT: return new cmp_item_int; @@ -1846,7 +1848,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) We could also do boyer-more for non-const items, but as we would have to recompute the tables for each row it's not worth it. */ - if (args[1]->const_item() && !use_strnxfrm(charset()) && + if (args[1]->const_item() && !use_strnxfrm(collation.collation) && !(specialflag & SPECIAL_NO_NEW_FUNC)) { String* res2 = args[1]->val_str(&tmp_value2); @@ -1867,7 +1869,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) { const char* tmp = first + 1; for (; *tmp != wild_many && *tmp != wild_one && *tmp != escape; tmp++) ; - canDoTurboBM = (tmp == last) && !use_mb(args[0]->charset()); + canDoTurboBM = (tmp == last) && !use_mb(args[0]->collation.collation); } if (canDoTurboBM) diff --git a/sql/item_func.cc b/sql/item_func.cc index db9a04dd2b5..660b623987c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -313,9 +313,9 @@ Field *Item_func::tmp_table_field(TABLE *t_arg) break; case STRING_RESULT: if (max_length > 255) - res= new Field_blob(max_length, maybe_null, name, t_arg, charset()); + res= new Field_blob(max_length, maybe_null, name, t_arg, collation.collation); else - res= new Field_string(max_length, maybe_null, name, t_arg, charset()); + res= new Field_string(max_length, maybe_null, name, t_arg, collation.collation); break; case ROW_RESULT: default: @@ -980,13 +980,13 @@ String *Item_func_min_max::val_str(String *str) res2= args[i]->val_str(res == str ? &tmp_value : str); if (res2) { - int cmp= sortcmp(res,res2,charset()); + int cmp= sortcmp(res,res2,collation.collation); if ((cmp_sign < 0 ? cmp : -cmp) < 0) res=res2; } } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } case ROW_RESULT: @@ -1104,7 +1104,7 @@ longlong Item_func_coercibility::val_int() return 0; } null_value= 0; - return (longlong) args[0]->derivation(); + return (longlong) args[0]->collation.derivation; } void Item_func_locate::fix_length_and_dec() @@ -1438,8 +1438,8 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, There is no a general rule for UDF. Everything depends on the particular user definted function. */ - if (item->charset()->state & MY_CS_BINSORT) - func->set_charset(&my_charset_bin); + if (item->collation.collation->state & MY_CS_BINSORT) + func->collation.set(&my_charset_bin); if (item->maybe_null) func->maybe_null=1; func->with_sum_func= func->with_sum_func || item->with_sum_func; @@ -2203,7 +2203,7 @@ Item_func_set_user_var::val_str(String *str) update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, DERIVATION_NONE); else update_hash((void*) res->ptr(), res->length(), STRING_RESULT, - res->charset(), args[0]->derivation()); + res->charset(), args[0]->collation.derivation); return res; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b4f4df6968d..b92839e6c1e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -310,7 +310,7 @@ String *Item_func_concat::val_str(String *str) } } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; null: @@ -596,7 +596,7 @@ String *Item_func_concat_ws::val_str(String *str) use_as_buff=str; } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; null: @@ -697,7 +697,7 @@ String *Item_func_reverse::val_str(String *str) void Item_func_reverse::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length = args[0]->max_length; } @@ -933,7 +933,7 @@ void Item_str_func::left_right_max_length() max_length=args[0]->max_length; if (args[1]->const_item()) { - int length=(int) args[1]->val_int()*charset()->mbmaxlen; + int length=(int) args[1]->val_int()*collation.collation->mbmaxlen; if (length <= 0) max_length=0; else @@ -944,7 +944,7 @@ void Item_str_func::left_right_max_length() void Item_func_left::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); left_right_max_length(); } @@ -971,7 +971,7 @@ String *Item_func_right::val_str(String *str) void Item_func_right::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); left_right_max_length(); } @@ -1006,7 +1006,7 @@ void Item_func_substr::fix_length_and_dec() { max_length=args[0]->max_length; - set_charset(*args[0]); + collation.set(args[0]->collation); if (args[1]->const_item()) { int32 start=(int32) args[1]->val_int()-1; @@ -1314,7 +1314,7 @@ void Item_func_trim::fix_length_and_dec() if (arg_count == 1) { collation.set(args[0]->collation); - remove.set_charset(charset()); + remove.set_charset(collation.collation); remove.set_ascii(" ",1); } else @@ -1535,7 +1535,7 @@ String *Item_func_user::val_str(String *str) void Item_func_soundex::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length=args[0]->max_length; set_if_bigger(max_length,4); } @@ -1567,7 +1567,7 @@ String *Item_func_soundex::val_str(String *str) { String *res =args[0]->val_str(str); char last_ch,ch; - CHARSET_INFO *cs= charset(); + CHARSET_INFO *cs= collation.collation; if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ @@ -1707,7 +1707,7 @@ String *Item_func_elt::val_str(String *str) } null_value=0; res= args[tmp]->val_str(str); - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } @@ -1813,7 +1813,7 @@ String *Item_func_char::val_str(String *str) int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) #ifdef USE_MB - if (use_mb(charset())) + if (use_mb(collation.collation)) { if (num&0xFF000000L) { str->append((char)(num>>24)); @@ -1860,7 +1860,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value, void Item_func_repeat::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); if (args[1]->const_item()) { max_length=(long) (args[0]->max_length * args[1]->val_int()); @@ -2109,7 +2109,7 @@ String *Item_func_conv_charset::val_str(String *str) void Item_func_conv_charset::fix_length_and_dec() { - set_charset(conv_charset, DERIVATION_IMPLICIT); + collation.set(conv_charset, DERIVATION_IMPLICIT); max_length = args[0]->max_length*conv_charset->mbmaxlen; } @@ -2192,7 +2192,7 @@ String *Item_func_set_collation::val_str(String *str) str=args[0]->val_str(str); if ((null_value=args[0]->null_value)) return 0; - str->set_charset(charset()); + str->set_charset(collation.collation); return str; } @@ -2203,7 +2203,7 @@ void Item_func_set_collation::fix_length_and_dec() String tmp, *str= args[1]->val_str(&tmp); colname= str->c_ptr(); if (colname == binary_keyword) - set_collation= get_charset_by_csname(args[0]->charset()->csname, + set_collation= get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT,MYF(0)); else { @@ -2214,13 +2214,14 @@ void Item_func_set_collation::fix_length_and_dec() } } - if (!set_collation || !my_charset_same(args[0]->charset(),set_collation)) + if (!set_collation || + !my_charset_same(args[0]->collation.collation,set_collation)) { my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - colname,args[0]->charset()->csname); + colname,args[0]->collation.collation->csname); return; } - set_charset(set_collation, DERIVATION_EXPLICIT); + collation.set(set_collation, DERIVATION_EXPLICIT); max_length= args[0]->max_length; } @@ -2237,7 +2238,7 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const func_name() != item_func->func_name()) return 0; Item_func_set_collation *item_func_sc=(Item_func_set_collation*) item; - if (charset() != item_func_sc->charset()) + if (collation.collation != item_func_sc->collation.collation) return 0; for (uint i=0; i < arg_count ; i++) if (!args[i]->eq(item_func_sc->args[i], binary_cmp)) @@ -2539,7 +2540,7 @@ String *Item_func_quote::val_str(String *str) } *to= '\''; str->length(new_length); - str->set_charset(charset()); + str->set_charset(collation.collation); return str; null: diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 4225dd43b12..f64a145b136 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -153,7 +153,7 @@ public: Item_str_conv(Item *item) :Item_str_func(item) {} void fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length = args[0]->max_length; } }; @@ -335,12 +335,11 @@ public: class Item_func_database :public Item_str_func { public: - Item_func_database() { set_charset(DERIVATION_IMPLICIT); } + Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); } String *val_str(String *); void fix_length_and_dec() { max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; - set_charset(system_charset_info); } const char *func_name() const { return "database"; } }; @@ -348,12 +347,11 @@ public: class Item_func_user :public Item_str_func { public: - Item_func_user() { set_charset(DERIVATION_IMPLICIT); } + Item_func_user() { collation.set(system_charset_info, DERIVATION_IMPLICIT); } String *val_str(String *); void fix_length_and_dec() { max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*system_charset_info->mbmaxlen; - set_charset(system_charset_info); } const char *func_name() const { return "user"; } }; @@ -418,7 +416,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length+(args[0]->max_length-args[0]->decimals)/3; } const char *func_name() const { return "format"; } @@ -432,7 +430,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=0; max_length=arg_count; } const char *func_name() const { return "char"; } @@ -482,7 +480,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=64; } }; @@ -497,7 +495,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=args[0]->max_length*2; } }; @@ -518,7 +516,7 @@ public: } void fix_length_and_dec() { - set_charset(&my_charset_bin); + collation.set(&my_charset_bin); max_length=args[0]->max_length; } void print(String *str) { print_op(str); } @@ -534,7 +532,7 @@ public: const char *func_name() const { return "load_file"; } void fix_length_and_dec() { - set_charset(&my_charset_bin, DERIVATION_COERCIBLE); + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); maybe_null=1; max_length=MAX_BLOB_WIDTH; } @@ -571,7 +569,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length= args[0]->max_length * 2 + 2; } }; @@ -616,7 +614,7 @@ public: void fix_length_and_dec() { max_length=40; // should be enough - set_charset(default_charset()); + collation.set(system_charset_info); }; }; @@ -629,6 +627,6 @@ public: void fix_length_and_dec() { max_length=40; // should be enough - set_charset(default_charset()); + collation.set(system_charset_info); }; }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 12f75f67b3c..7ab83c1e7b2 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -193,7 +193,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) max_length=float_length(decimals); }else { - cmp_charset= item->charset(); + cmp_charset= item->collation.collation; max_length=item->max_length; } decimals=item->decimals; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c2d1504e94a..62d8afd7ec0 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -574,7 +574,7 @@ void Item_func_curdate::fix_length_and_dec() struct tm tm_tmp,*start; time_t query_start=current_thd->query_start(); - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; localtime_r(&query_start,&tm_tmp); @@ -617,7 +617,7 @@ void Item_func_curtime::fix_length_and_dec() max_length=8*cs->mbmaxlen; localtime_r(&query_start,&tm_tmp); start=&tm_tmp; - set_charset(cs); + collation.set(cs); value=(longlong) ((ulong) ((uint) start->tm_hour)*10000L+ (ulong) (((uint) start->tm_min)*100L+ (uint) start->tm_sec)); @@ -644,7 +644,7 @@ void Item_func_now::fix_length_and_dec() decimals=0; max_length=19*cs->mbmaxlen; - set_charset(cs); + collation.set(cs); localtime_r(&query_start,&tm_tmp); start=&tm_tmp; value=((longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+ @@ -1130,7 +1130,7 @@ bool Item_func_from_unixtime::get_date(TIME *ltime, void Item_date_add_interval::fix_length_and_dec() { enum_field_types arg0_field_type; - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=1; max_length=26*MY_CHARSET_BIN_MB_MAXLEN; value.alloc(32); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 20b95f8e22d..a6fb9b11de4 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -93,7 +93,7 @@ public: enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=2*default_charset()->mbmaxlen; maybe_null=1; @@ -110,7 +110,7 @@ public: enum Item_result result_type () const { return STRING_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; maybe_null=1; @@ -254,7 +254,7 @@ public: enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=1*default_charset()->mbmaxlen; maybe_null=1; @@ -270,7 +270,7 @@ class Item_func_dayname :public Item_func_weekday enum Item_result result_type () const { return STRING_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=9*default_charset()->mbmaxlen; maybe_null=1; @@ -322,7 +322,7 @@ public: const char *func_name() const { return "date"; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; } @@ -440,7 +440,7 @@ class Item_func_from_unixtime :public Item_date_func const char *func_name() const { return "from_unixtime"; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=19*default_charset()->mbmaxlen; } @@ -457,7 +457,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=1; max_length=13*default_charset()->mbmaxlen; } @@ -529,12 +529,12 @@ public: String *tmp=args[0]->val_str(a); null_value=args[0]->null_value; if (tmp) - tmp->set_charset(charset()); + tmp->set_charset(collation.collation); return tmp; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length; } void print(String *str); @@ -547,7 +547,7 @@ public: Item_char_typecast(Item *a) :Item_typecast(a) {} void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length; } }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 18c465ffde3..935abac5146 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -930,7 +930,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, { bool like_error; char buff1[MAX_FIELD_WIDTH],*min_str,*max_str; - String tmp(buff1,sizeof(buff1),value->charset()),*res; + String tmp(buff1,sizeof(buff1),value->collation.collation),*res; uint length,offset,min_length,max_length; if (!field->optimize_range(param->real_keynr[key_part->key])) diff --git a/sql/records.cc b/sql/records.cc index 783ca663dfe..72a6d480356 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -73,7 +73,13 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, info->ref_pos=table->file->ref; table->file->rnd_init(0); - if (! (specialflag & SPECIAL_SAFE_MODE) && + /* + table->sort.addon_field is checked because if we use addon fields, + it doesn't make sense to use cache - we don't read from the table + and table->sort.io_cache is read sequentially + */ + if (!table->sort.addon_field && + ! (specialflag & SPECIAL_SAFE_MODE) && thd->variables.read_rnd_buff_size && !table->file->fast_key_read() && (table->db_stat & HA_READ_ONLY || diff --git a/sql/set_var.h b/sql/set_var.h index 978aba3384a..968687ad382 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -607,7 +607,7 @@ public: { Item_field *item= (Item_field*) value_arg; if (!(value=new Item_string(item->field_name, strlen(item->field_name), - item->charset()))) + item->collation.collation))) value=value_arg; /* Give error message later */ } else diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index ced5993e293..a6c24a25d6e 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -326,9 +326,9 @@ void field_str::add() if (length > max_length) max_length = length; - if (sortcmp(res, &min_arg,item->charset()) < 0) + if (sortcmp(res, &min_arg,item->collation.collation) < 0) min_arg.copy(*res); - if (sortcmp(res, &max_arg,item->charset()) > 0) + if (sortcmp(res, &max_arg,item->collation.collation) > 0) max_arg.copy(*res); } @@ -736,7 +736,7 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows) { if (must_be_blob) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("TINYBLOB", 8); else answer->append("TINYTEXT", 8); @@ -754,21 +754,21 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows) } else if (max_length < (1L << 16)) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("BLOB", 4); else answer->append("TEXT", 4); } else if (max_length < (1L << 24)) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("MEDIUMBLOB", 10); else answer->append("MEDIUMTEXT", 10); } else { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("LONGBLOB", 8); else answer->append("LONGTEXT", 8); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c9f51938538..f33533d9eb7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -787,6 +787,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, DBUG_RETURN(0); } table->query_id=thd->query_id; + table->clear_query_id=1; thd->tmp_table_used= 1; goto reset; } @@ -2039,8 +2040,9 @@ bool setup_tables(TABLE_LIST *tables) table->keys_in_use_for_query &= ~map; } table->used_keys &= table->keys_in_use_for_query; - if (table_list->shared) + if (table_list->shared || table->clear_query_id) { + table->clear_query_id= 0; /* Clear query_id that may have been set by previous select */ for (Field **ptr=table->field ; *ptr ; ptr++) (*ptr)->query_id=0; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 436d9412063..d7a88ecd53e 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -122,6 +122,16 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, res= -1; goto exit; } + + /* + This is done in order to redo all field optimisations when any of the + involved tables is used in the outer query + */ + if (tables) + { + for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) + cursor->table->clear_query_id= 1; + } item_list= select_cursor->item_list; select_cursor->with_wild= 0; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3e44d1d1afb..6c92f1f5dcf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4254,9 +4254,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case STRING_RESULT: if (item_sum->max_length > 255) return new Field_blob(item_sum->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); return new Field_string(item_sum->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); case ROW_RESULT: default: // This case should never be choosen @@ -4313,10 +4313,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case STRING_RESULT: if (item->max_length > 255) new_field= new Field_blob(item->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); else new_field= new Field_string(item->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); break; case ROW_RESULT: default: diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2e6585583ba..e16d7a0067d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1858,10 +1858,19 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, /* COND_refresh will be signaled in close_thread_tables() */ break; case DISABLE: - VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table); - VOID(pthread_mutex_unlock(&LOCK_open)); - table->file->deactivate_non_unique_index(HA_POS_ERROR); + if (table->db_type == DB_TYPE_MYISAM) + { + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table); + VOID(pthread_mutex_unlock(&LOCK_open)); + table->file->deactivate_non_unique_index(HA_POS_ERROR); + } + else + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA, + ER(ER_ILLEGAL_HA), table->table_name); + break; + /* COND_refresh will be signaled in close_thread_tables() */ break; } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index cf338be16aa..0d50348f199 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -136,7 +136,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, found_rows_for_union= first_select()->options & OPTION_FOUND_ROWS && global_parameters->select_limit; if (found_rows_for_union) - first_select()->options ^= OPTION_FOUND_ROWS; + first_select()->options&= ~OPTION_FOUND_ROWS; } if (t_and_f) { @@ -154,8 +154,6 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, goto err; List_iterator<Item> it(select_cursor->item_list); Item *item; - while((item=it++)) - item->maybe_null=1; item_list= select_cursor->item_list; select_cursor->with_wild= 0; if (setup_ref_array(thd, &select_cursor->ref_pointer_array, @@ -167,6 +165,12 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, item_list, 0, 0, 1)) goto err; t_and_f= 1; + while((item=it++)) + { + item->maybe_null=1; + if (item->type() == Item::FIELD_ITEM) + ((class Item_field *)item)->field->table->maybe_null=1; + } } tmp_table_param.field_count=item_list.elements; @@ -241,7 +245,6 @@ err: int st_select_lex_unit::exec() { - int do_print_slow= 0; SELECT_LEX *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor=first_select_in_union(); DBUG_ENTER("st_select_lex_unit::exec"); @@ -312,7 +315,6 @@ int st_select_lex_unit::exec() thd->lex.current_select= lex_select_save; DBUG_RETURN(res); } - do_print_slow|= select_cursor->options; } } optimized= 1; @@ -373,12 +375,6 @@ int st_select_lex_unit::exec() Mark for slow query log if any of the union parts didn't use indexes efficiently */ - select_cursor->options= ((select_cursor->options & - ~(QUERY_NO_INDEX_USED | - QUERY_NO_GOOD_INDEX_USED)) | - do_print_slow & - (QUERY_NO_INDEX_USED | - QUERY_NO_GOOD_INDEX_USED)); } } thd->lex.current_select= lex_select_save; diff --git a/sql/table.h b/sql/table.h index 1a3277661f1..fce2d97e393 100644 --- a/sql/table.h +++ b/sql/table.h @@ -116,6 +116,7 @@ struct st_table { my_bool crashed; my_bool is_view; my_bool no_keyread; + my_bool clear_query_id; /* To reset query_id for tables and cols */ my_bool auto_increment_field_not_null; Field *next_number_field, /* Set if next_number is activated */ *found_next_number_field, /* Set on open */ |