From 97562d74c993f0d3972f92927069429b2c6c950e Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Tue, 13 Jun 2006 16:01:54 +0500 Subject: [PATCH 01/11] Fix for bug #12728: Very strange behaviour of ELT --- mysql-test/r/func_str.result | 7 +++++++ mysql-test/t/func_str.test | 8 ++++++++ sql/item_strfunc.cc | 11 +++++++++++ sql/item_strfunc.h | 1 + 4 files changed, 27 insertions(+) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 6fefbb16353..1feda854014 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -436,3 +436,10 @@ id aes_decrypt(str, 'bar') 1 foo 2 NULL DROP TABLE t1, t2; +create table t1(a varchar(8), primary key(a)); +insert into t1 values('bar'), ('foo'); +select a from t1 where a=elt(1, 'foo', 'bar') or a=elt(2, 'foo', 'bar'); +a +bar +foo +drop table t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 81d5daaf0ba..0e7ab70940a 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -254,3 +254,11 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id DROP TABLE t1, t2; +# +# Bug #12728: strange elt() behavior +# + +create table t1(a varchar(8), primary key(a)); +insert into t1 values('bar'), ('foo'); +select a from t1 where a=elt(1, 'foo', 'bar') or a=elt(2, 'foo', 'bar'); +drop table t1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f070382e5c1..2ea693e94a3 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1599,6 +1599,17 @@ String *Item_func_elt::val_str(String *str) } +bool Item_func_elt::eq(const Item *par_item, bool binary_cmp) const +{ + /* + We can use (Item_func_elt*) typecast here because the check is done + in the Item_func::eq(). + */ + return Item_func::eq(par_item, binary_cmp) && + item->eq(((Item_func_elt*) par_item)->item, binary_cmp); +} + + void Item_func_make_set::split_sum_func(List &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index ece15484fd9..482a941c55b 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -372,6 +372,7 @@ public: void fix_length_and_dec(); void update_used_tables(); const char *func_name() const { return "elt"; } + bool eq(const Item *par_item, bool binary_cmp) const; unsigned int size_of() { return sizeof(*this);} }; From 49797c23b3750b0aa86bb3400a353e652bc1cd1c Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Mon, 19 Jun 2006 13:03:29 +0500 Subject: [PATCH 02/11] Fix for bug #20496: func_time.test failure --- mysql-test/r/func_time.result | 13 ++++++++++--- mysql-test/t/func_time.test | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index e7a00b71961..c90a4258036 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -671,7 +671,14 @@ select f1 from t1 where makedate(2006,2) between date(f1) and date(f3); f1 2006-01-02 drop table t1; -select now() - now() + 0, curtime() - curtime() + 0, +create table t1 select now() - now(), curtime() - curtime(), sec_to_time(1) + 0, from_unixtime(1) + 0; -now() - now() + 0 curtime() - curtime() + 0 sec_to_time(1) + 0 from_unixtime(1) + 0 -0.000000 0.000000 1.000000 19700101030001.000000 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `now() - now()` double(23,6) NOT NULL default '0.000000', + `curtime() - curtime()` double(23,6) NOT NULL default '0.000000', + `sec_to_time(1) + 0` double(23,6) default NULL, + `from_unixtime(1) + 0` double(23,6) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 23e3b9d982a..d69545712c8 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -347,7 +347,9 @@ drop table t1; # Bug #16546 # -select now() - now() + 0, curtime() - curtime() + 0, - sec_to_time(1) + 0, from_unixtime(1) + 0; +create table t1 select now() - now(), curtime() - curtime(), + sec_to_time(1) + 0, from_unixtime(1) + 0; +show create table t1; +drop table t1; # End of 4.1 tests From c5ed7a87f42259ddf853d9a9c16e0596f7aa9983 Mon Sep 17 00:00:00 2001 From: "gkodinov@mysql.com" <> Date: Mon, 19 Jun 2006 13:22:42 +0300 Subject: [PATCH 03/11] * Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big tables Currently in INSERT ... SELECT ... LIMIT ... the compiler uses a temporary table to store the results of SELECT ... LIMIT .. and then uses that table as a source for INSERT. The problem is that in some cases it actually skips the LIMIT clause in doing that and materializes the whole SELECT result set regardless of the LIMIT. This fix is limiting the process of filling up the temp table with only that much rows that will be actually used by propagating the LIMIT value. --- mysql-test/r/insert_select.result | 4 ++++ mysql-test/t/insert_select.test | 13 +++++++++++++ sql/sql_select.cc | 12 ++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 028b40ac3b6..1d7aef256e1 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -686,3 +686,7 @@ ERROR 42S22: Unknown column 'z' in 'field list' insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x); ERROR 42S02: Unknown table 't2' in field list drop table t1,t2; +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 values (1), (2); +INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; +DROP TABLE t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 48acdf1cbc5..fcea489fcff 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -226,4 +226,17 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z); insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x); drop table t1,t2; +# +# Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big +# tables +# + +#Note: not an exsaustive test : just a check of the code path. +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 values (1), (2); + +INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; + +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5a7e9e52aed..709ff9726bb 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -888,8 +888,9 @@ JOIN::optimize() group_list ? 0 : select_distinct, group_list && simple_group, select_options, - (order == 0 || skip_sort_order) ? select_limit : - HA_POS_ERROR, + (order == 0 || skip_sort_order || + test(select_options & OPTION_BUFFER_RESULT)) ? + select_limit : HA_POS_ERROR, (char *) ""))) DBUG_RETURN(1); @@ -5530,6 +5531,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, keyinfo->key_length+= key_part_info->length; } } + else + { + set_if_smaller(table->max_rows, rows_limit); + param->end_write_records= rows_limit; + } if (distinct && field_count != param->hidden_field_count) { @@ -5544,8 +5550,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, null_pack_length-=hidden_null_pack_length; keyinfo->key_parts= ((field_count-param->hidden_field_count)+ test(null_pack_length)); - set_if_smaller(table->max_rows, rows_limit); - param->end_write_records= rows_limit; table->distinct=1; table->keys=1; if (blob_count) From e57e87980b687d42649818e61164b8f3e7a77941 Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Tue, 20 Jun 2006 20:46:45 +0200 Subject: [PATCH 04/11] Bug#19437 (Connection refused by server: "2002 Can't connect... /master.sock"): Clearing active VIO before calling mysql_close() in the slave I/O thread. --- sql/slave.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sql/slave.cc b/sql/slave.cc index caeefc1ad3c..2b31d722f26 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1653,6 +1653,15 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, if (connect_to_master(thd, mysql, mi)) { my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql)); + /* + We need to clear the active VIO since, theoretically, somebody + might issue an awake() on this thread. If we are then in the + middle of closing and destroying the VIO inside the + mysql_close(), we will have a problem. + */ +#ifdef SIGNAL_WITH_VIO_CLOSE + thd->clear_active_vio(); +#endif mysql_close(mysql); DBUG_RETURN(1); } @@ -3709,6 +3718,17 @@ err: VOID(pthread_mutex_unlock(&LOCK_thread_count)); if (mysql) { + /* + Here we need to clear the active VIO before closing the + connection with the master. The reason is that THD::awake() + might be called from terminate_slave_thread() because somebody + issued a STOP SLAVE. If that happends, the close_active_vio() + can be called in the middle of closing the VIO associated with + the 'mysql' object, causing a crash. + */ +#ifdef SIGNAL_WITH_VIO_CLOSE + thd->clear_active_vio(); +#endif mysql_close(mysql); mi->mysql=0; } From ae6970e6bc4cf01a2c91ddaabf8ec31b4377e04c Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Jun 2006 23:05:55 +0400 Subject: [PATCH 05/11] select.result: Added test case for bug#18759 Incorrect string to numeric conversion. select.test: Added test case for bug#18759 Incorrect string to numeric conversion. item_cmpfunc.cc: Cleanup after fix for bug#18360 removal --- mysql-test/r/select.result | 6 ++++++ mysql-test/t/select.test | 19 +++++++++++++++++++ sql/item_cmpfunc.cc | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 7808e787e39..c7df11ab018 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2738,3 +2738,9 @@ ERROR HY000: Key 'a' doesn't exist in table 't1' EXPLAIN SELECT * FROM t1 FORCE INDEX (a); ERROR HY000: Key 'a' doesn't exist in table 't1' DROP TABLE t1; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01) i in ('1e+01') +0 1 1 1 +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index f7b5a2fbcb6..4cdfc220350 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2278,4 +2278,23 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a); DROP TABLE t1; +# +# Bug #18759 "Incorrect string to numeric conversion" +# +# This test is here so that the behavior will not be changed to 4.1 +# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string +# will be converted internally to real (double) value and it is not +# as accurate as bigint (longlong) for integers. Thus the results may +# vary. In 5.1 internally it is decimal, which is a string type and +# will be more accurate. Due to rather big changes needed to fix this +# in 4.1 or 5.0 it is not desired to do it in the stable versions. +# +# This test is here only to make sure that behavior is not changed in +# 4.1 and 5.0 +# +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1; +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5055b5f4197..f14efc7187b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -136,7 +136,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } continue; } - if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM) + if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM && + items[i]->result_type() != INT_RESULT) { field= ((Item_field *)items[i]->real_item())->field; break; From 8c0aa3560cba5f0053407a10d5af81c985e26763 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Wed, 21 Jun 2006 01:14:53 +0400 Subject: [PATCH 06/11] field.cc, field.h: Additional fix for #16377 for bigendian platforms sql_select.cc, select.result, select.test: After merge fix --- mysql-test/r/select.result | 12 +++++------ mysql-test/t/select.test | 2 +- sql/field.cc | 44 +++++++++++++++++++------------------- sql/field.h | 2 +- sql/sql_select.cc | 2 +- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index a9381f7c942..e6c590489a0 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2730,6 +2730,12 @@ ERROR HY000: Key 'a' doesn't exist in table 't1' EXPLAIN SELECT * FROM t1 FORCE INDEX (a); ERROR HY000: Key 'a' doesn't exist in table 't1' DROP TABLE t1; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +0 1 1 1 +DROP TABLE t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', @@ -3389,9 +3395,3 @@ a t1.b + 0 t1.c + 0 a t2.b + 0 c d 1 0 1 1 0 1 NULL 2 0 1 NULL NULL NULL NULL drop table t1,t2; -CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); -INSERT INTO t1 VALUES (10); -SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1; -i='1e+01' i=1e+01 i in (1e+01) i in ('1e+01') -0 1 1 1 -DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 707892a5b16..b75d0dd8bb6 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2301,7 +2301,7 @@ DROP TABLE t1; # CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); INSERT INTO t1 VALUES (10); -SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1; +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; DROP TABLE t1; # End of 4.1 tests diff --git a/sql/field.cc b/sql/field.cc index 33fc5ab3128..7c25e4ad9f7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4566,7 +4566,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) } #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int4store(ptr,tmp); } @@ -4632,7 +4632,7 @@ int Field_timestamp::store(longlong nr, bool unsigned_val) nr, MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int4store(ptr,timestamp); } @@ -4656,7 +4656,7 @@ longlong Field_timestamp::val_int(void) THD *thd= table ? table->in_use : current_thd; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); else #endif @@ -4686,7 +4686,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) val_buffer->length(field_length); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); else #endif @@ -4751,7 +4751,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate) long temp; THD *thd= table ? table->in_use : current_thd; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); else #endif @@ -4788,7 +4788,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr) { int32 a,b; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { a=sint4korr(a_ptr); b=sint4korr(b_ptr); @@ -4806,7 +4806,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr) void Field_timestamp::sort_string(char *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN - if (!table->s->db_low_byte_first) + if (!table || !table->s->db_low_byte_first) { to[0] = ptr[0]; to[1] = ptr[1]; @@ -4836,7 +4836,7 @@ void Field_timestamp::set_time() long tmp= (long) thd->query_start(); set_notnull(); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int4store(ptr,tmp); } @@ -5238,7 +5238,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) from, len, MYSQL_TIMESTAMP_DATE, 1); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int4store(ptr,tmp); } @@ -5299,7 +5299,7 @@ int Field_date::store(longlong nr, bool unsigned_val) MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int4store(ptr, nr); } @@ -5325,7 +5325,7 @@ double Field_date::val_real(void) { int32 j; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) j=sint4korr(ptr); else #endif @@ -5338,7 +5338,7 @@ longlong Field_date::val_int(void) { int32 j; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) j=sint4korr(ptr); else #endif @@ -5354,7 +5354,7 @@ String *Field_date::val_str(String *val_buffer, val_buffer->alloc(field_length); int32 tmp; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) tmp=sint4korr(ptr); else #endif @@ -5372,7 +5372,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr) { int32 a,b; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { a=sint4korr(a_ptr); b=sint4korr(b_ptr); @@ -5390,7 +5390,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr) void Field_date::sort_string(char *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN - if (!table->s->db_low_byte_first) + if (!table || !table->s->db_low_byte_first) { to[0] = ptr[0]; to[1] = ptr[1]; @@ -5630,7 +5630,7 @@ int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs) from, len, MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int8store(ptr,tmp); } @@ -5683,7 +5683,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val) MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int8store(ptr,nr); } @@ -5712,7 +5712,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { int8store(ptr,tmp); } @@ -5739,7 +5739,7 @@ longlong Field_datetime::val_int(void) { longlong j; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) j=sint8korr(ptr); else #endif @@ -5759,7 +5759,7 @@ String *Field_datetime::val_str(String *val_buffer, int part3; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) tmp=sint8korr(ptr); else #endif @@ -5824,7 +5824,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr) { longlong a,b; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) { a=sint8korr(a_ptr); b=sint8korr(b_ptr); @@ -5842,7 +5842,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr) void Field_datetime::sort_string(char *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN - if (!table->s->db_low_byte_first) + if (!table || !table->s->db_low_byte_first) { to[0] = ptr[0]; to[1] = ptr[1]; diff --git a/sql/field.h b/sql/field.h index e7b7aa45c27..ed13372df71 100644 --- a/sql/field.h +++ b/sql/field.h @@ -813,7 +813,7 @@ public: if ((*null_value= is_null())) return 0; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) + if (table && table->s->db_low_byte_first) return sint4korr(ptr); #endif long tmp; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7d7975436a5..9f317842d98 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8817,7 +8817,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, } else { - set_if_smaller(table->max_rows, rows_limit); + set_if_smaller(table->s->max_rows, rows_limit); param->end_write_records= rows_limit; } From c22e7f2dfd568e9f1b98abe442587c96722d14e3 Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Wed, 21 Jun 2006 02:23:18 +0300 Subject: [PATCH 07/11] Fix for Bug#18246 "compilation error with tcp_wrapper" --- include/Makefile.am | 2 +- include/my_libwrap.h | 19 +++++++++++++++++++ mysys/Makefile.am | 2 +- mysys/my_libwrap.c | 39 +++++++++++++++++++++++++++++++++++++++ sql/mysqld.cc | 6 +++--- 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 include/my_libwrap.h create mode 100644 mysys/my_libwrap.c diff --git a/include/Makefile.am b/include/Makefile.am index 07c32e3127b..2dbea3fe07f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -31,7 +31,7 @@ noinst_HEADERS = config-win.h config-os2.h config-netware.h \ my_aes.h my_tree.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h md5.h base64.h \ mysql_version.h.in my_handler.h my_time.h decimal.h \ - my_user.h + my_user.h my_libwrap.h # mysql_version.h are generated CLEANFILES = mysql_version.h my_config.h readline openssl diff --git a/include/my_libwrap.h b/include/my_libwrap.h new file mode 100644 index 00000000000..a5cc9879e4f --- /dev/null +++ b/include/my_libwrap.h @@ -0,0 +1,19 @@ +/* Copyright (C) 2000 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +extern void my_fromhost(struct request_info *req); +extern int my_hosts_access(struct request_info *req); +extern char *my_eval_client(struct request_info *req); diff --git a/mysys/Makefile.am b/mysys/Makefile.am index d046b2fa3f8..bc84f44cd29 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -56,7 +56,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ my_handler.c my_netware.c my_largepage.c \ my_memmem.c \ - my_windac.c my_access.c base64.c + my_windac.c my_access.c base64.c my_libwrap.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c libmysys_a_LIBADD = @THREAD_LOBJECTS@ diff --git a/mysys/my_libwrap.c b/mysys/my_libwrap.c new file mode 100644 index 00000000000..29a0ecf3fc6 --- /dev/null +++ b/mysys/my_libwrap.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#ifdef HAVE_LIBWRAP +#include +#include +#ifdef NEED_SYS_SYSLOG_H +#include +#endif /* NEED_SYS_SYSLOG_H */ +#endif + +void my_fromhost(struct request_info *req) +{ + fromhost(req); +} + +int my_hosts_access(struct request_info *req) +{ + hosts_access(req); +} + +char *my_eval_client(struct request_info *req) +{ + eval_client(req); +} diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d7a38d6b715..262a5352ed9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4072,8 +4072,8 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused))) struct request_info req; signal(SIGCHLD, SIG_DFL); request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, new_sock, NULL); - fromhost(&req); - if (!hosts_access(&req)) + my_fromhost(&req); + if (!my_hosts_access(&req)) { /* This may be stupid but refuse() includes an exit(0) @@ -4081,7 +4081,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused))) clean_exit() - same stupid thing ... */ syslog(deny_severity, "refused connect from %s", - eval_client(&req)); + my_eval_client(&req)); /* C++ sucks (the gibberish in front just translates the supplied From 8167b2c8efa1cfb267f4e631a39c111a1abf02f5 Mon Sep 17 00:00:00 2001 From: "knielsen@mysql.com" <> Date: Wed, 21 Jun 2006 12:52:59 +0200 Subject: [PATCH 08/11] BUG#20578 Backport Valgrind suppression from mysql-5.1: D 1.4 05/11/23 22:44:54+02:00 monty@mysql.com 5 4 12/0/154 P mysql-test/valgrind.supp C Remove warning that may happens becasue threads dies in different order --- mysql-test/valgrind.supp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index 65c5a82db36..24426727968 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -133,6 +133,18 @@ fun:gzflush } +# +# Warning from my_thread_init becasue mysqld dies before kill thread exists +# + +{ + my_thread_init kill thread memory loss second + Memcheck:Leak + fun:calloc + fun:my_thread_init + fun:kill_server_thread +} + # # Leaks reported in _dl_* internal functions on Linux amd64 / glibc2.3.2. # From 8b98be2844adca02e81a70f1588dc8cdaf6c60b2 Mon Sep 17 00:00:00 2001 From: "svoj@may.pils.ru" <> Date: Wed, 21 Jun 2006 17:30:59 +0500 Subject: [PATCH 09/11] BUG#20357 - Got error 124 from storage engine using MIN and MAX functions in queries Using MAX()/MIN() on table with disabled indexes (by ALTER TABLE) results in error 124 (wrong index) from storage engine. The problem was that optimizer use disabled index to optimize MAX()/MIN(). Normally it must skip disabled index and perform table scan. This patch skips disabled indexes for min/max optimization. --- mysql-test/r/myisam.result | 13 +++++++++++++ mysql-test/t/myisam.test | 12 ++++++++++++ sql/opt_sum.cc | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 3b4519e5444..91a5bb08c0f 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -748,3 +748,16 @@ select count(id1) from t1 where id2 = 10; count(id1) 5 drop table t1; +CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES(1); +SELECT MAX(a) FROM t1 IGNORE INDEX(a); +MAX(a) +1 +ALTER TABLE t1 DISABLE KEYS; +SELECT MAX(a) FROM t1; +MAX(a) +1 +SELECT MAX(a) FROM t1 IGNORE INDEX(a); +MAX(a) +1 +DROP TABLE t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 7e4cc324b12..06f913111d3 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -705,4 +705,16 @@ select count(*) from t1 where id2 = 10; select count(id1) from t1 where id2 = 10; drop table t1; +# +# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions +# in queries +# +CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 VALUES(1); +SELECT MAX(a) FROM t1 IGNORE INDEX(a); +ALTER TABLE t1 DISABLE KEYS; +SELECT MAX(a) FROM t1; +SELECT MAX(a) FROM t1 IGNORE INDEX(a); +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index cfb5b3695a3..63373a8579a 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -673,6 +673,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, { KEY_PART_INFO *part,*part_end; key_part_map key_part_to_use= 0; + /* + Perform a check if index is not disabled by ALTER TABLE + or IGNORE INDEX. + */ + if (!table->keys_in_use_for_query.is_set(idx)) + continue; uint jdx= 0; *prefix_len= 0; for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ; From 5f46cb7e1a0004343ddd8e06d381c9a985d1f918 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Wed, 21 Jun 2006 16:41:07 +0200 Subject: [PATCH 10/11] added missing MYSQLTEST_VARDIR declaration --- mysql-test/mysql-test-run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index fb3484c212e..93f741aecff 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -171,7 +171,8 @@ BASEDIR=`pwd` cd $CWD MYSQL_TEST_DIR=$BASEDIR/mysql-test MYSQL_TEST_WINDIR=$MYSQL_TEST_DIR -export MYSQL_TEST_DIR MYSQL_TEST_WINDIR +MYSQLTEST_VARDIR=$MYSQL_TEST_DIR/var +export MYSQL_TEST_DIR MYSQL_TEST_WINDIR MYSQLTEST_VARDIR STD_DATA=$MYSQL_TEST_DIR/std_data hostname=`hostname` # Installed in the mysql privilege table From f57cf654f450cac2cc94b8f9aad8e50eb264cb5c Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Wed, 21 Jun 2006 18:35:19 +0300 Subject: [PATCH 11/11] Cleanup to patch for Bug#18246, "compilation error with tcp_wrapper" --- include/my_libwrap.h | 9 +++++++++ mysys/my_libwrap.c | 15 +++++++++------ sql/mysqld.cc | 13 +++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/my_libwrap.h b/include/my_libwrap.h index a5cc9879e4f..6437cbaed84 100644 --- a/include/my_libwrap.h +++ b/include/my_libwrap.h @@ -14,6 +14,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_LIBWRAP +#include +#include +#ifdef NEED_SYS_SYSLOG_H +#include +#endif /* NEED_SYS_SYSLOG_H */ + extern void my_fromhost(struct request_info *req); extern int my_hosts_access(struct request_info *req); extern char *my_eval_client(struct request_info *req); + +#endif /* HAVE_LIBWRAP */ diff --git a/mysys/my_libwrap.c b/mysys/my_libwrap.c index 29a0ecf3fc6..be8adbab0a1 100644 --- a/mysys/my_libwrap.c +++ b/mysys/my_libwrap.c @@ -14,14 +14,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + This is needed to be able to compile with original libwrap header + files that don't have the prototypes +*/ + #include +#include + #ifdef HAVE_LIBWRAP -#include -#include -#ifdef NEED_SYS_SYSLOG_H -#include -#endif /* NEED_SYS_SYSLOG_H */ -#endif void my_fromhost(struct request_info *req) { @@ -37,3 +38,5 @@ char *my_eval_client(struct request_info *req) { eval_client(req); } + +#endif /* HAVE_LIBWRAP */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 262a5352ed9..b73cd350012 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -120,16 +120,7 @@ extern "C" { // Because of SCO 3.2V4.2 #include #endif /* __WIN__ */ -#ifdef HAVE_LIBWRAP -#include -#include -#ifdef NEED_SYS_SYSLOG_H -#include -#endif /* NEED_SYS_SYSLOG_H */ -int allow_severity = LOG_INFO; -int deny_severity = LOG_WARNING; - -#endif /* HAVE_LIBWRAP */ +#include #ifdef HAVE_SYS_MMAN_H #include @@ -591,6 +582,8 @@ static const char* default_dbug_option; #endif #ifdef HAVE_LIBWRAP const char *libwrapName= NULL; +int allow_severity = LOG_INFO; +int deny_severity = LOG_WARNING; #endif #ifdef HAVE_QUERY_CACHE static ulong query_cache_limit= 0;