From e10d3ed1290f4b1645c674406bb86bf1c8c9989d Mon Sep 17 00:00:00 2001 From: "nick@mysql.com" <> Date: Tue, 29 Oct 2002 12:28:14 -0700 Subject: [PATCH 1/9] moved RAND initialization from mysqld.cc to sql_class.cc:THD::THD() --- sql/mysqld.cc | 12 ++---------- sql/sql_class.cc | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b5c789548e7..01053ba0f28 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -249,7 +249,7 @@ extern int init_master_info(MASTER_INFO* mi); // and are treated as aliases for each other static bool kill_in_progress=FALSE; -static struct rand_struct sql_rand; +struct rand_struct sql_rand; // used by sql_class.cc:THD::THD() static int cleanup_done; static char **defaults_argv,time_zone[30]; static const char *default_table_type_name; @@ -2257,15 +2257,7 @@ static void create_new_thread(THD *thd) for (uint i=0; i < 8 ; i++) // Generate password teststring thd->scramble[i]= (char) (rnd(&sql_rand)*94+33); thd->scramble[8]=0; - /* - We need good random number initialization for new thread - Just coping global one will not work - */ - { - ulong tmp=(ulong) (rnd(&sql_rand) * 3000000); - randominit(&(thd->rand), tmp + (ulong) start_time, - tmp + (ulong) thread_id); - } + thd->real_id=pthread_self(); // Keep purify happy /* Start a new thread to handle connection */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ace7c291ed3..eada94e3d40 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -35,6 +35,8 @@ #include #endif +extern struct rand_struct sql_rand; + /***************************************************************************** ** Instansiate templates *****************************************************************************/ @@ -147,6 +149,18 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), transaction.trans_log.end_of_file= max_binlog_cache_size; } #endif + + /* + We need good random number initialization for new thread + Just coping global one will not work + */ + { + pthread_mutex_lock(&LOCK_thread_count); + ulong tmp=(ulong) (rnd(&sql_rand) * 3000000); + randominit(&rand, tmp + (ulong) start_time, + tmp + (ulong) thread_id); + pthread_mutex_unlock(&LOCK_thread_count); + } } /* Do operations that may take a long time */ From c104f57df02d64472dd81486101917d2b60c99ce Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Tue, 29 Oct 2002 21:30:34 +0200 Subject: [PATCH 2/9] Updated changelog --- Docs/manual.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Docs/manual.texi b/Docs/manual.texi index cb0f2236bb9..2314c51a92a 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -47012,6 +47012,11 @@ Changed initialisation of @code{RND()} to make it less predicatable. Fixed problem with @code{GROUP BY} on result with expression that created a @code{BLOB} field. @item +Fixed problem with @code{GROUP BY} on columns that have NULL values. To +solve this we now create an MyISAM temporary table when doing a group by +on a possible NULL item. In MySQL 4.0.5 we can again use in memory HEAP +tables for this case. +@item Fixed problem with privilege tables when downgrading from 4.0.2 to 3.23. @item Fixed thread bug in @code{SLAVE START}, @code{SLAVE STOP} and automatic repair From 3d33dd1e6853ee88b0619af14d744fad98788dda Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 30 Oct 2002 16:45:11 +0100 Subject: [PATCH 3/9] - Do-compile: added a fast test run with dynamic-row tables - Do-compile: fix small (cosmetical, not critical) typo --- Build-tools/Do-compile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index bdec06a5f9f..067b88888ac 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -381,13 +381,15 @@ if ($opt_stage <= 9 && !$opt_no_test) log_system("rm -f output/*"); $tmp= $opt_fast_benchmark ? "--fast --user root --small-test" : ""; check_system("perl ./run-all-tests --log --die-on-errors $connect_option $tmp","RUN-mysql"); + # Run additional fast test with dynamic-row tables + check_system("perl ./run-all-tests --log --suffix=\"_dynamic_rows\" --die-on-errors $connect_option --fast --user=root --small-test --create-options=\"row_format=dynamic\"","RUN-mysql"); if ($opt_innodb) { - check_system("perl ./run-all-tests --log --suffix=\"_innodb\" --die-on-errors $connect_option $tmp --create-option=\"type=innodb\"","RUN-mysql"); + check_system("perl ./run-all-tests --log --suffix=\"_innodb\" --die-on-errors $connect_option $tmp --create-options=\"type=innodb\"","RUN-mysql"); } if ($opt_bdb) { - check_system("perl ./run-all-tests --log --suffix=\"_bdb\" --die-on-errors $connect_option $tmp --create-option=\"type=bdb\"","RUN-mysql"); + check_system("perl ./run-all-tests --log --suffix=\"_bdb\" --die-on-errors $connect_option $tmp --create-options=\"type=bdb\"","RUN-mysql"); } } From be932e7345571f4fc92dd236c1b4ca36520986f4 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 30 Oct 2002 21:55:56 +0100 Subject: [PATCH 4/9] - Applied fix made in 4.0 tree to fix a bug when comparing a datetime column with timestamp values with BETWEEN clause --- sql/field.h | 1 + sql/item_cmpfunc.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/sql/field.h b/sql/field.h index e822f6a71d6..92e098c75c4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -533,6 +533,7 @@ public: enum Item_result result_type () const { return field_length == 8 || field_length == 14 ? INT_RESULT : STRING_RESULT; } enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } + enum Item_result cmp_type () const { return INT_RESULT; } void store(const char *to,uint length); void store(double nr); void store(longlong nr); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 36ecde337a7..4650b770299 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -354,6 +354,7 @@ void Item_func_between::fix_length_and_dec() if (args[0]->type() == FIELD_ITEM) { Field *field=((Item_field*) args[0])->field; + cmp_type=field->cmp_type(); if (field->store_for_compare()) { if (convert_constant_item(field,&args[1])) From 629576aff69b30f45b3007aaed4be0520327f106 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 31 Oct 2002 00:30:19 +0200 Subject: [PATCH 5/9] ha_innobase.cc: Backport from 4.0: Fix bug in MySQL-3.23 ORDER BY from a table with no PRIMARY KEY and where the user had added UNIQUE indexes with CREATE INDEX pars0grm.y: Move inclusion of math.h after univ.i also in the .y file; this fix is already done in 4.0 --- innobase/pars/pars0grm.y | 3 +-- sql/ha_innobase.cc | 36 ++++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/innobase/pars/pars0grm.y b/innobase/pars/pars0grm.y index 67289222594..eedc42bee57 100644 --- a/innobase/pars/pars0grm.y +++ b/innobase/pars/pars0grm.y @@ -14,9 +14,8 @@ the InnoDB parser. /* The value of the semantic attribute is a pointer to a query tree node que_node_t */ -#include - #include "univ.i" +#include #include "pars0pars.h" #include "mem0mem.h" #include "que0types.h" diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 13912ad5919..6b5ba7d841e 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -993,7 +993,10 @@ how you can resolve the problem.\n", ((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len = table->reclength; - primary_key = MAX_KEY; + /* Looks like MySQL-3.23 sometimes has primary key number != 0 */ + + primary_key = table->primary_key; + key_used_on_scan = primary_key; /* Allocate a buffer for a 'row reference'. A row reference is a string of bytes of length ref_length which uniquely specifies @@ -1002,21 +1005,30 @@ how you can resolve the problem.\n", of length ref_length! */ if (!row_table_got_default_clust_index(ib_table)) { + if (primary_key >= MAX_KEY) { + fprintf(stderr, + "InnoDB: Error: table %s has a primary key in InnoDB\n" + "InnoDB: data dictionary, but not in MySQL!\n", name); + } ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = FALSE; - - primary_key = 0; - key_used_on_scan = 0; - - /* MySQL allocates the buffer for ref. key_info->key_length - includes space for all key columns + one byte for each column - that may be NULL. ref_length must be as exact as possible to - save space, because all row reference buffers are allocated - based on ref_length. */ - - ref_length = table->key_info->key_length; + /* + MySQL allocates the buffer for ref. key_info->key_length + includes space for all key columns + one byte for each column + that may be NULL. ref_length must be as exact as possible to + save space, because all row reference buffers are allocated + based on ref_length. + */ + + ref_length = table->key_info[primary_key].key_length; } else { + if (primary_key != MAX_KEY) { + fprintf(stderr, + "InnoDB: Error: table %s has no primary key in InnoDB\n" + "InnoDB: data dictionary, but has one in MySQL!\n", name); + } + ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = TRUE; From f7da25ec71ed879ceb909ed90fda71cd905d7e5a Mon Sep 17 00:00:00 2001 From: "serg@sergbook.mysql.com" <> Date: Sat, 2 Nov 2002 20:35:32 +0100 Subject: [PATCH 6/9] fixed a bug where "MATCH ... AGAINST () >=0" was treated as if it was > --- sql/sql_select.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 49502a7a116..0c3c19c6e69 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1371,15 +1371,15 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array, *arg1=(Item_func *)(func->arguments()[1]); if ((functype == Item_func::GE_FUNC || functype == Item_func::GT_FUNC) && - arg0->type() == Item::FUNC_ITEM && + arg0->type() == Item::FUNC_ITEM && arg0->functype() == Item_func::FT_FUNC && - arg1->const_item() && arg1->val()>=0) + arg1->const_item() && arg1->val()>0) cond_func=(Item_func_match *) arg0; else if ((functype == Item_func::LE_FUNC || functype == Item_func::LT_FUNC) && arg1->type() == Item::FUNC_ITEM && arg1->functype() == Item_func::FT_FUNC && - arg0->const_item() && arg0->val()>=0) + arg0->const_item() && arg0->val()>0) cond_func=(Item_func_match *) arg1; } } From 685dba5baca8ff37ff5819300704bb1aac350844 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 5 Nov 2002 00:04:36 +0200 Subject: [PATCH 7/9] Fix to get core file on Linux --- BUILD/compile-pentium-valgrind-max | 13 +++++++++++++ Docs/manual.texi | 2 ++ sql/mysqld.cc | 4 ++++ sql/stacktrace.c | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 BUILD/compile-pentium-valgrind-max diff --git a/BUILD/compile-pentium-valgrind-max b/BUILD/compile-pentium-valgrind-max new file mode 100755 index 00000000000..d58ee723aee --- /dev/null +++ b/BUILD/compile-pentium-valgrind-max @@ -0,0 +1,13 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium_cflags $debug_cflags -DHAVE_purify" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" +extra_configs="$pentium_configs $debug_configs" + +extra_configs="$extra_configs" + +. "$path/FINISH.sh" diff --git a/Docs/manual.texi b/Docs/manual.texi index 2314c51a92a..7291abae07e 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46930,6 +46930,8 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.54 @itemize @item +Fixed that @code{--core-file} works on Linux (at least on kernel 2.4.18). +@item Fixed a problem with BDB and @code{ALTER TABLE}. @item Fixed reference to freed memory when doing complicated @code{GROUP BY diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f7be5525e34..71b832f24f4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1326,7 +1326,11 @@ information that should help you find out what is causing the crash\n"); #endif /* HAVE_STACKTRACE */ if (test_flags & TEST_CORE_ON_SIGNAL) + { + fprintf(stderr, "Writing a core file\n"); + fflush(stderr); write_core(sig); + } exit(1); } diff --git a/sql/stacktrace.c b/sql/stacktrace.c index f4415571f1b..d5711bcd78e 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -206,7 +206,7 @@ resolve it\n"); /* Produce a core for the thread */ -#ifdef HAVE_LINUXTHREADS +#ifdef NOT_USED /* HAVE_LINUXTHREADS */ void write_core(int sig) { signal(sig, SIG_DFL); From 537f1c2f1e69ac6f965b0823f422592dbbd4dc10 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 5 Nov 2002 00:24:59 +0200 Subject: [PATCH 8/9] Removed wrong bug fix for problem with timestamp and BETWEEN. Will be properly fixed in 4.1 and 5.0 --- sql/field.h | 1 - sql/item_cmpfunc.cc | 1 - 2 files changed, 2 deletions(-) diff --git a/sql/field.h b/sql/field.h index 92e098c75c4..e822f6a71d6 100644 --- a/sql/field.h +++ b/sql/field.h @@ -533,7 +533,6 @@ public: enum Item_result result_type () const { return field_length == 8 || field_length == 14 ? INT_RESULT : STRING_RESULT; } enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } - enum Item_result cmp_type () const { return INT_RESULT; } void store(const char *to,uint length); void store(double nr); void store(longlong nr); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4650b770299..36ecde337a7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -354,7 +354,6 @@ void Item_func_between::fix_length_and_dec() if (args[0]->type() == FIELD_ITEM) { Field *field=((Item_field*) args[0])->field; - cmp_type=field->cmp_type(); if (field->store_for_compare()) { if (convert_constant_item(field,&args[1])) From 27d07047bbfdfa22424185ae97cb55c747a080ea Mon Sep 17 00:00:00 2001 From: "serg@sergbook.mysql.com" <> Date: Tue, 5 Nov 2002 00:00:51 +0100 Subject: [PATCH 9/9] TEMPORARY MERGE tables are allowed --- mysql-test/r/merge.result | 6 ++++++ mysql-test/t/merge.test | 19 +++++++++++++++++++ sql/ha_myisammrg.cc | 23 ++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 653e25af799..bdde202b335 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -130,3 +130,9 @@ a a b 1 1 1 2 +a +1 +2 +a +1 +2 diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 238dd599664..6ea9ecc269f 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -114,3 +114,22 @@ insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6); flush tables; select * from t3 where a=1 order by b limit 2; drop table t3,t1,t2; + +# +# temporary merge tables +# +drop table if exists t1, t2, t3, t4, t5, t6; +create table t1 (a int not null); +create table t2 (a int not null); +insert into t1 values (1); +insert into t2 values (2); +create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2); +select * from t3; +create temporary table t4 (a int not null); +create temporary table t5 (a int not null); +insert into t4 values (1); +insert into t5 values (2); +create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5); +select * from t6; +drop table if exists t1, t2, t3, t4, t5, t6; + diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index e5fb0310a36..e9b6a048264 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -264,7 +264,28 @@ int ha_myisammrg::create(const char *name, register TABLE *form, sizeof(char*)))) DBUG_RETURN(1); for (pos=table_names ; tables ; tables=tables->next) - *pos++= tables->real_name; + { + char *table_name; + if (create_info->options & HA_LEX_CREATE_TMP_TABLE) + { + TABLE **tbl=find_temporary_table(current_thd, + tables->db, tables->real_name); + if (!tbl) + { + table_name=sql_alloc(1+ + my_snprintf(buff,FN_REFLEN,"%s/%s/%s",mysql_real_data_home, + tables->db, tables->real_name)); + if (!table_name) + DBUG_RETURN(1); + strcpy(table_name, buff); + } + else + table_name=(*tbl)->path; + } + else + table_name=tables->real_name; + *pos++= table_name; + } *pos=0; DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16), (const char **) table_names, (my_bool) 0));