From 48ef39ee65d871f5df0417fe0b9ceee536f36d4b Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 28 Nov 2003 01:54:34 +0300 Subject: [PATCH 1/3] cleanup: no need to set rpl_parse, rpl_probe and rpl_pivot to zero as whole mysql structure is bzeroed in mysql_init(0) few lines before --- libmysql/libmysql.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 5d809adf36a..d5fe2cddc48 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2276,8 +2276,6 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, else if (parent->options.db) child->options.db = my_strdup(parent->options.db, MYF(0)); - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; - return child; } From 3b9eb09276eba4542f13175a16e6d9a528cd5439 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Fri, 28 Nov 2003 01:57:05 +0300 Subject: [PATCH 2/3] no need to zero-initialize mysql->master->{rpl_pivot, options.rpl_parse, options.rpl_probe} as they are zero-initialized in spawn_init() --- libmysql/libmysql.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index d5fe2cddc48..0c9c68f4505 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2289,9 +2289,6 @@ STDCALL mysql_set_master(MYSQL* mysql, const char* host, mysql_close(mysql->master); if (!(mysql->master = spawn_init(mysql, host, port, user, passwd))) return 1; - mysql->master->rpl_pivot = 0; - mysql->master->options.rpl_parse = 0; - mysql->master->options.rpl_probe = 0; return 0; } From 4f42a47408c316edbae8965fc1aef9979ead2026 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 Nov 2003 15:45:34 +0200 Subject: [PATCH 3/3] Fixed range optimzier bug (Bug #1828) --- mysql-test/r/range.result | 10 ++++++++++ mysql-test/t/range.test | 13 ++++++++++++- sql/opt_range.cc | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 68987009598..e87df9a6c24 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -290,3 +290,13 @@ t1 range a,b a 5 NULL 2 Using where SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index e09fa73256b..364ea2d4195 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -231,9 +231,20 @@ INSERT INTO t1 VALUES (21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +# we expect that optimizer will choose index on A EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5; DROP TABLE t1; -# we expect that optimizer will choose index on A +# +# Test error with +# + +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +# -- First reports 3; second reports 6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +DROP TABLE t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e932b2c46d6..63850709285 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -70,7 +70,7 @@ public: {} inline bool is_same(SEL_ARG *arg) { - if (type != arg->type) + if (type != arg->type || part != arg->part) return 0; if (type != KEY_RANGE) return 1;