From 2722db0f022b88ef647b40b40b385367aba3c80b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Dec 2005 23:43:37 +0300 Subject: [PATCH 1/5] Fixes bug #11892. When MyODBC or any other client do my_init()/my_end() several times, it was causing corruption of charset data stored in once_mem_pool. my_end() deallocated once_mem pool, but did not put a flag that charsets have to be reloaded. The fix addresses this problem. --- mysys/my_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mysys/my_init.c b/mysys/my_init.c index f28f47e090e..c2bfdde0ddd 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -152,6 +152,7 @@ void my_end(int infoflag) DBUG_PRINT("error",("%s",errbuff[0])); } } + free_charsets(); my_once_free(); if ((infoflag & MY_GIVE_INFO) || print_info) From 6b2718d16f15484e985b119981d94a537a006feb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Jan 2006 21:43:41 -0800 Subject: [PATCH 2/5] Complaint from a user who was getting sick of repairing their tables do to their lousy setup (their words). All crashed archive tables will now be repaired on open. sql/ha_archive.cc: Fix for repair table. --- sql/ha_archive.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 68219151186..cfdaba0672c 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -477,7 +477,7 @@ const char **ha_archive::bas_ext() const Init out lock. We open the file we will read from. */ -int ha_archive::open(const char *name, int mode, uint test_if_locked) +int ha_archive::open(const char *name, int mode, uint open_options) { DBUG_ENTER("ha_archive::open"); @@ -492,7 +492,10 @@ int ha_archive::open(const char *name, int mode, uint test_if_locked) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } - DBUG_RETURN(0); + if (open_options & HA_OPEN_FOR_REPAIR) + DBUG_RETURN(0); + + DBUG_RETURN(share->crashed ? HA_ERR_CRASHED_ON_USAGE : 0); } @@ -1067,7 +1070,8 @@ int ha_archive::delete_all_rows() */ bool ha_archive::is_crashed() const { - return share->crashed; + DBUG_ENTER("ha_archive::is_crashed"); + DBUG_RETURN(share->crashed); } /* @@ -1129,13 +1133,6 @@ bool ha_archive::check_and_repair(THD *thd) check_opt.init(); - if (check(thd, &check_opt) == HA_ADMIN_CORRUPT) - { - DBUG_RETURN(repair(thd, &check_opt)); - } - else - { - DBUG_RETURN(HA_ADMIN_OK); - } + DBUG_RETURN(repair(thd, &check_opt)); } #endif /* HAVE_ARCHIVE_DB */ From a334c72371c766176ed5579951c4156f5624e3a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Jan 2006 16:14:27 +0100 Subject: [PATCH 3/5] BUG#16487: New test for ignored table and multi-update mysql-test/r/rpl_ignore_table.result: New result file mysql-test/t/rpl_ignore_table-slave.opt: New option file mysql-test/t/rpl_ignore_table.test: New test for ignored table and multi-update --- mysql-test/r/rpl_ignore_table.result | 16 ++++++++++++++ mysql-test/t/rpl_ignore_table-slave.opt | 1 + mysql-test/t/rpl_ignore_table.test | 28 +++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 mysql-test/r/rpl_ignore_table.result create mode 100644 mysql-test/t/rpl_ignore_table-slave.opt create mode 100644 mysql-test/t/rpl_ignore_table.test diff --git a/mysql-test/r/rpl_ignore_table.result b/mysql-test/r/rpl_ignore_table.result new file mode 100644 index 00000000000..356a9dcb2f8 --- /dev/null +++ b/mysql-test/r/rpl_ignore_table.result @@ -0,0 +1,16 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +**** Test case for BUG#16487 **** +**** Master **** +CREATE TABLE test.t4 (a int); +CREATE TABLE test.t1 (a int); +UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5; +**** Slave **** +SELECT * FROM t4; +a +DROP TABLE t1; +DROP TABLE t4; diff --git a/mysql-test/t/rpl_ignore_table-slave.opt b/mysql-test/t/rpl_ignore_table-slave.opt new file mode 100644 index 00000000000..cb49119bfcb --- /dev/null +++ b/mysql-test/t/rpl_ignore_table-slave.opt @@ -0,0 +1 @@ +--replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3 diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test new file mode 100644 index 00000000000..bc651779208 --- /dev/null +++ b/mysql-test/t/rpl_ignore_table.test @@ -0,0 +1,28 @@ +source include/master-slave.inc; + +# +# BUG#16487 +# +# Requirement: +# Multi-updates on ignored tables should not fail even if the slave does +# not have the ignored tables. +# +# Note table t1, t2, and t3 are ignored in the option file to this test. +# + +--echo **** Test case for BUG#16487 **** +--echo **** Master **** +connection master; +CREATE TABLE test.t4 (a int); +CREATE TABLE test.t1 (a int); + +# Expect: The row must *not* by updated on slave, since t1 is ignored +UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5; + +--echo **** Slave **** +sync_slave_with_master; +SELECT * FROM t4; + +connection master; +DROP TABLE t1; +DROP TABLE t4; From 6bfbba34c7ebee4ee21547afd648d6da1ed7966f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Jan 2006 21:20:28 -0800 Subject: [PATCH 4/5] Fixed bug #16260. The problem has manifested itself in the cases when we have a nested outer join for which it can be inferred that one of the inner tables is a single row table. mysql-test/r/join_nested.result: Added a test case for bug #16260. mysql-test/t/join_nested.test: Added a test case for bug #16260. sql/sql_select.cc: Fixed bug #16260. The problem has manifested itself in the cases when we have a nested outer join for which it can be inferred that one of the inner tables is a single row table. A table is never considered as a const table if it is used in a nested join that serves as an inner operand of an outer join. --- mysql-test/r/join_nested.result | 23 +++++++++++++++++++++++ mysql-test/t/join_nested.test | 28 ++++++++++++++++++++++++++++ sql/sql_select.cc | 3 ++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result index faad969fcd1..dfcfa35d31d 100644 --- a/mysql-test/r/join_nested.result +++ b/mysql-test/r/join_nested.result @@ -1481,3 +1481,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref a a 5 test.t1.a 1 1 SIMPLE t3 ref a a 5 test.t2.a 1 drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index 145edded486..8adcf05be93 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -914,3 +914,31 @@ explain select * from t1 left join on (t1.a = t2.a); drop table t1, t2, t3; +# +# Bug #16260: single row table in the inner nest of an outer join +# + +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, + id int NOT NULL, + pid int NOT NULL); + +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); + +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) + ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) + LEFT JOIN t2 ON (t3.pid=t2.pid) + WHERE p.id=1; + +CREATE VIEW v1 AS + SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; + +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id + LEFT JOIN t2 ON v1.pid=t2.pid + WHERE p.id=1; + +DROP VIEW v1; +DROP TABLE t1,t2,t3; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 95da0e6263a..63d46934555 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2172,7 +2172,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (eq_part.is_prefix(table->key_info[key].key_parts) && ((table->key_info[key].flags & (HA_NOSAME | HA_END_SPACE_KEY)) == HA_NOSAME) && - !table->fulltext_searched) + !table->fulltext_searched && + !table->pos_in_table_list->embedding) { if (const_ref == eq_part) { // Found everything for ref. From ef0cd2f58a785113cda84bb774f39428b99de0ef Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Jan 2006 19:44:51 -0600 Subject: [PATCH 5/5] information_schema_db.result, information_schema.result: Fix test result. table.h, sql_show.cc: Put I_S tables in lexical order. sql/sql_show.cc: Put I_S tables in lexical order. sql/table.h: Put I_S tables in lexical order. mysql-test/r/information_schema.result: Fix test result. mysql-test/r/information_schema_db.result: Fix test result. --- mysql-test/r/information_schema.result | 2 +- mysql-test/r/information_schema_db.result | 2 +- sql/sql_show.cc | 4 ++-- sql/table.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 08d698092e2..d3576e24a44 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -50,8 +50,8 @@ TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES TRIGGERS -VIEWS USER_PRIVILEGES +VIEWS columns_priv db func diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index d3ff310b812..0229fdef2d5 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -15,8 +15,8 @@ TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES TRIGGERS -VIEWS USER_PRIVILEGES +VIEWS show tables from INFORMATION_SCHEMA like 'T%'; Tables_in_information_schema (T%) TABLES diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1f776d815df..1b854a005ce 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4198,12 +4198,12 @@ ST_SCHEMA_TABLE schema_tables[]= fill_schema_table_privileges, 0, 0, -1, -1, 0}, {"TRIGGERS", triggers_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0}, + {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, + fill_schema_user_privileges, 0, 0, -1, -1, 0}, {"VARIABLES", variables_fields_info, create_schema_table, fill_variables, make_old_format, 0, -1, -1, 1}, {"VIEWS", view_fields_info, create_schema_table, get_all_tables, 0, get_schema_views_record, 1, 2, 0}, - {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, - fill_schema_user_privileges, 0, 0, -1, -1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0} }; diff --git a/sql/table.h b/sql/table.h index 947316e253f..78a942ef301 100644 --- a/sql/table.h +++ b/sql/table.h @@ -309,9 +309,9 @@ enum enum_schema_tables SCH_TABLE_NAMES, SCH_TABLE_PRIVILEGES, SCH_TRIGGERS, + SCH_USER_PRIVILEGES, SCH_VARIABLES, - SCH_VIEWS, - SCH_USER_PRIVILEGES + SCH_VIEWS };