From 0bc6909f02abd8fc68ab90c8e7503596cf2b299e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 14 Dec 2002 15:32:36 +0200 Subject: [PATCH 1/5] Fix for a bug with mysql_select_db() on manually created database and lower case table names. --- sql/sql_db.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7fcda7948a2..e61a2aa60c5 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -323,6 +323,9 @@ bool mysql_change_db(THD *thd,const char *name) uint db_access; DBUG_ENTER("mysql_change_db"); + if (lower_case_table_names) + casedn_str(dbname); + if (!dbname || !(length=strip_sp(dbname))) { x_free(dbname); /* purecov: inspected */ From e003d42e4af56c5785010f1f2426bd5bfa778ba3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Dec 2002 22:16:57 +0200 Subject: [PATCH 2/5] fix for a bug in CASE ...WHEN ... sql/sql_db.cc: fix for lower case ... --- mysql-test/r/case.result | 4 ++++ mysql-test/t/case.test | 5 +++++ sql/item_cmpfunc.cc | 2 ++ sql/sql_db.cc | 2 -- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 073164aa035..9ba33daaa4d 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -40,3 +40,7 @@ fcase count(*) nothing 2 one 1 two 1 +color +orange +yellow +green diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 79511f5f546..f2b8d42e07c 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -30,3 +30,8 @@ insert into t1 values(1),(2),(3),(4); select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase; drop table t1; +drop table if exists t; +create table t1 (row int not null, col int not null, val varchar(255) not null); +insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small'); +select max(case col when 1 then val else null end) as color from t1 group by row; +drop table if exists t; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 07704e3385f..0d10b17ad87 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -687,6 +687,8 @@ String *Item_func_case::val_str(String *str) } if (!(res=item->val_str(str))) null_value=1; + else + null_value=item->null_value; return res; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index e61a2aa60c5..338d3161bd4 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -371,8 +371,6 @@ bool mysql_change_db(THD *thd,const char *name) } send_ok(&thd->net); x_free(thd->db); - if (lower_case_table_names) - casedn_str(dbname); thd->db=dbname; thd->db_access=db_access; DBUG_RETURN(0); From 05ef8a612a8a94a0bf64801867b805675192f049 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Dec 2002 20:58:07 +0200 Subject: [PATCH 3/5] ha_innobase.cc: Better error message to help users who created tables with < 3.23.54 where MySQL implicitly added a PRIMARY KEY definition sql/ha_innobase.cc: Better error message to help users who created tables with < 3.23.54 where MySQL implicitly added a PRIMARY KEY definition --- sql/ha_innobase.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 489c2fafd9b..c5b529a3881 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -1030,7 +1030,14 @@ how you can resolve the problem.\n", 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); + "InnoDB: data dictionary, but has one in MySQL!\n" + "InnoDB: If you created the table with a MySQL\n" + "InnoDB: version < 3.23.54 and did not define a primary\n" + "InnoDB: key, but defined a unique key with all non-NULL\n" + "InnoDB: columns, then MySQL internally treats that key\n" + "InnoDB: as the primary key. You can fix this error by\n" + "InnoDB: dump + DROP + CREATE + reimport of the table.\n", + name); } ((row_prebuilt_t*)innobase_prebuilt) From 35f6e920c5a0a991bbaae0107405230985cb7c81 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Dec 2002 20:55:51 +0200 Subject: [PATCH 4/5] btr0sea.c: Remove an assertion which can fail in a race of 3 threads innobase/btr/btr0sea.c: Remove an assertion which can fail in a race of 3 threads --- innobase/btr/btr0sea.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c index a798f28b4ab..421aafba1c5 100644 --- a/innobase/btr/btr0sea.c +++ b/innobase/btr/btr0sea.c @@ -453,8 +453,6 @@ btr_search_info_update_slow( } if (build_index) { - ut_a(block->n_fields + block->n_bytes > 0); - btr_search_build_page_hash_index(block->frame, block->n_fields, block->n_bytes, @@ -1028,7 +1026,10 @@ btr_search_build_page_hash_index( return; } - ut_a(n_fields + n_bytes > 0); + if (n_fields + n_bytes == 0) { + + return; + } /* Calculate and cache fold values and corresponding records into an array for fast insertion to the hash index */ From 5f1b9717c53f19ef4f7a5206f59a7678a025dbe2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 21 Dec 2002 10:45:06 +0200 Subject: [PATCH 5/5] Optimization of CASE bug fix --- sql/item_cmpfunc.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 0d10b17ad87..c3381eb76ea 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -685,10 +685,9 @@ String *Item_func_case::val_str(String *str) null_value=1; return 0; } + null_value= 0; if (!(res=item->val_str(str))) - null_value=1; - else - null_value=item->null_value; + null_value= 1; return res; }