From ec62aba3f054b6fd3eabe774fac0da825a8baf33 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Mar 2008 11:12:12 +0100 Subject: Bug#34731: highest possible value for INT erroneously filtered by WHERE WHERE f1 < n ignored row if f1 was indexed integer column and f1 = TYPE_MAX ^ n = TYPE_MAX+1. The latter value when treated as TYPE overflowed (obviously). This was not handled, it is now. mysql-test/r/range.result: show that on an index int column, we no longer disregard a field val of TYPE_MAX in SELECT ... WHERE ... < TYPE_MAX+1 mysql-test/t/range.test: show that on an index int column, we no longer disregard a field val of TYPE_MAX in SELECT ... WHERE ... < TYPE_MAX+1 sql/opt_range.cc: Handle overflowing of int-types in range-optimizer. Unfortunately requires re-indentation of entire block. Overflow (err == 1) was handled, but only if field->cmp_type() != value->result_type(), which it just wasn't in our case. --- mysql-test/r/range.result | 39 ++++++++++++++++++++ mysql-test/t/range.test | 47 +++++++++++++++++++++++++ sql/opt_range.cc | 90 ++++++++++++++++++++++++++++------------------- 3 files changed, 140 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index e0084b53320..f666030465e 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -1153,3 +1153,42 @@ explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range dateval dateval 4 NULL 2 Using where drop table t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 87ba3510326..95e0d31ff8f 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -955,4 +955,51 @@ explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= ' drop table t1; + +# +# Bug #34731: highest possible value for INT erroneously filtered by WHERE +# + +# test UNSIGNED. only occurs when indexed. +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); + +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); + +# test upper bound +# count 5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256; +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0; +# count 4 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255; + +# show we don't fiddle with lower bound on UNSIGNED +# count 0 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1; +# count 5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1; + +DROP TABLE t1; + + +# test signed. only occurs when index. +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); + +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); + +# test upper bound +# count 5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128; +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0; +# count 4 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127; + +# test lower bound +# count 5 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129; +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0; +# count 4 +SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128; + +DROP TABLE t1; + # End of 5.0 tests diff --git a/sql/opt_range.cc b/sql/opt_range.cc index a8cf0f67635..c3eddbd0abf 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4405,52 +4405,70 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, field->type() == FIELD_TYPE_DATETIME)) field->table->in_use->variables.sql_mode|= MODE_INVALID_DATES; err= value->save_in_field_no_warnings(field, 1); - if (err > 0 && field->cmp_type() != value->result_type()) + if (err > 0) { - if ((type == Item_func::EQ_FUNC || type == Item_func::EQUAL_FUNC) && - value->result_type() == item_cmp_type(field->result_type(), - value->result_type())) - + if (field->cmp_type() != value->result_type()) { - tree= new (alloc) SEL_ARG(field, 0, 0); - tree->type= SEL_ARG::IMPOSSIBLE; - goto end; - } - else - { - /* - TODO: We should return trees of the type SEL_ARG::IMPOSSIBLE - for the cases like int_field > 999999999999999999999999 as well. - */ - tree= 0; - if (err == 3 && field->type() == FIELD_TYPE_DATE && - (type == Item_func::GT_FUNC || type == Item_func::GE_FUNC || - type == Item_func::LT_FUNC || type == Item_func::LE_FUNC) ) + if ((type == Item_func::EQ_FUNC || type == Item_func::EQUAL_FUNC) && + value->result_type() == item_cmp_type(field->result_type(), + value->result_type())) + { + tree= new (alloc) SEL_ARG(field, 0, 0); + tree->type= SEL_ARG::IMPOSSIBLE; + goto end; + } + else { /* - We were saving DATETIME into a DATE column, the conversion went ok - but a non-zero time part was cut off. + TODO: We should return trees of the type SEL_ARG::IMPOSSIBLE + for the cases like int_field > 999999999999999999999999 as well. + */ + tree= 0; + if (err == 3 && field->type() == FIELD_TYPE_DATE && + (type == Item_func::GT_FUNC || type == Item_func::GE_FUNC || + type == Item_func::LT_FUNC || type == Item_func::LE_FUNC) ) + { + /* + We were saving DATETIME into a DATE column, the conversion went ok + but a non-zero time part was cut off. - In MySQL's SQL dialect, DATE and DATETIME are compared as datetime - values. Index over a DATE column uses DATE comparison. Changing - from one comparison to the other is possible: + In MySQL's SQL dialect, DATE and DATETIME are compared as datetime + values. Index over a DATE column uses DATE comparison. Changing + from one comparison to the other is possible: - datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10' - datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10' + datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10' + datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10' - datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10' - datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10' + datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10' + datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10' - but we'll need to convert '>' to '>=' and '<' to '<='. This will - be done together with other types at the end of this function - (grep for field_is_equal_to_item) - */ + but we'll need to convert '>' to '>=' and '<' to '<='. This will + be done together with other types at the end of this function + (grep for field_is_equal_to_item) + */ + } + else + goto end; } - else - goto end; } - } - if (err < 0) + + /* + guaranteed at this point: err > 0; field and const of same type + If an integer got bounded (e.g. to within 0..255 / -128..127) + for < or >, set flags as for <= or >= (no NEAR_MAX / NEAR_MIN) + */ + else if (err == 1 && field->result_type() == INT_RESULT) + { + if (type == Item_func::LT_FUNC && (value->val_int() > 0)) + type = Item_func::LE_FUNC; + else if (type == Item_func::GT_FUNC && + !((Field_num*)field)->unsigned_flag && + !((Item_int*)value)->unsigned_flag && + (value->val_int() < 0)) + type = Item_func::GE_FUNC; + } + } + else if (err < 0) { field->table->in_use->variables.sql_mode= orig_sql_mode; /* This happens when we try to insert a NULL field in a not null column */ -- cgit v1.2.1 From 2d5a444d1fac9dc1866231355ea791ea0545fdd8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Mar 2008 18:18:58 +0200 Subject: Fix for Bug #27944 Filtering THD::client capabilities The server used to trust blindly information from the client about its capabilities. During the connection handshake the server sends information about what it supports and then the client sends back a set of capabilities which cover all of the server's or less. Before this changeset the server didn't check whether the flags sent by the client were valid for the server. For example, if the server doesn't support compressed protocol but the client does and sends that bit turned on, the server didn't check it. The change make the server code less error prone to problems related to the value of THD::client_capabilities. Clearly there is no vulnerability being fixed but this is a maintainenance fix to prevent misusage in the future. include/mysql_com.h: List all CLIENT flags in a common defition. Add also a definition which excludes flags, which are optoinal. sql/sql_connect.cc: Renamed client_flags to server_capabilities to reflect what the server supports. Only allow from the client the flags the server supports. --- include/mysql_com.h | 31 +++++++++++++++++++++++++++++++ sql/sql_connect.cc | 23 ++++++++++++++++------- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index cea98cebc61..25bf58e58ba 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -148,6 +148,37 @@ enum enum_server_command #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) #define CLIENT_REMEMBER_OPTIONS (1UL << 31) +/* Gather all possible capabilites (flags) supported by the server */ +#define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \ + CLIENT_FOUND_ROWS | \ + CLIENT_LONG_FLAG | \ + CLIENT_CONNECT_WITH_DB | \ + CLIENT_NO_SCHEMA | \ + CLIENT_COMPRESS | \ + CLIENT_ODBC | \ + CLIENT_LOCAL_FILES | \ + CLIENT_IGNORE_SPACE | \ + CLIENT_PROTOCOL_41 | \ + CLIENT_INTERACTIVE | \ + CLIENT_SSL | \ + CLIENT_IGNORE_SIGPIPE | \ + CLIENT_TRANSACTIONS | \ + CLIENT_RESERVED | \ + CLIENT_SECURE_CONNECTION | \ + CLIENT_MULTI_STATEMENTS | \ + CLIENT_MULTI_RESULTS | \ + CLIENT_SSL_VERIFY_SERVER_CERT | \ + CLIENT_REMEMBER_OPTIONS) + +/* + Switch off the flags that are optional and depending on build flags + If any of the optional flags is supported by the build it will be switched + on before sending to the client during the connection handshake. +*/ +#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \ + & ~CLIENT_COMPRESS) \ + & ~CLIENT_SSL_VERIFY_SERVER_CERT) + #define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index b22a33e3e92..b3acfd99991 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -700,20 +700,24 @@ static int check_connection(THD *thd) bzero((char*) &thd->remote, sizeof(thd->remote)); } vio_keepalive(net->vio, TRUE); + + ulong server_capabilites; { /* buff[] needs to big enough to hold the server_version variable */ char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64]; - ulong client_flags = (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB | - CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION); + server_capabilites= CLIENT_BASIC_FLAGS; if (opt_using_transactions) - client_flags|=CLIENT_TRANSACTIONS; + server_capabilites|= CLIENT_TRANSACTIONS; #ifdef HAVE_COMPRESS - client_flags |= CLIENT_COMPRESS; + server_capabilites|= CLIENT_COMPRESS; #endif /* HAVE_COMPRESS */ #ifdef HAVE_OPENSSL if (ssl_acceptor_fd) - client_flags |= CLIENT_SSL; /* Wow, SSL is available! */ + { + server_capabilites |= CLIENT_SSL; /* Wow, SSL is available! */ + server_capabilites |= CLIENT_SSL_VERIFY_SERVER_CERT; + } #endif /* HAVE_OPENSSL */ end= strnmov(buff, server_version, SERVER_VERSION_LENGTH) + 1; @@ -732,7 +736,7 @@ static int check_connection(THD *thd) */ end= strmake(end, thd->scramble, SCRAMBLE_LENGTH_323) + 1; - int2store(end, client_flags); + int2store(end, server_capabilites); /* write server characteristics: up to 16 bytes allowed */ end[2]=(char) default_charset_info->number; int2store(end+3, thd->server_status); @@ -762,7 +766,7 @@ static int check_connection(THD *thd) if (thd->packet.alloc(thd->variables.net_buffer_length)) return 1; /* The error is set by alloc(). */ - thd->client_capabilities=uint2korr(net->read_pos); + thd->client_capabilities= uint2korr(net->read_pos); if (thd->client_capabilities & CLIENT_PROTOCOL_41) { thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16; @@ -777,6 +781,11 @@ static int check_connection(THD *thd) thd->max_client_packet_length= uint3korr(net->read_pos+2); end= (char*) net->read_pos+5; } + /* + Disable those bits which are not supported by the server. + This is a precautionary measure, if the client lies. See Bug#27944. + */ + thd->client_capabilities&= server_capabilites; if (thd->client_capabilities & CLIENT_IGNORE_SPACE) thd->variables.sql_mode|= MODE_IGNORE_SPACE; -- cgit v1.2.1 From c3641cd5136f7bb0b79475b0bcb0b97f20150e14 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Mar 2008 15:53:57 -0300 Subject: Bug#35272: @@global.key_buffer_size = 4294967295 let the server crash When trying to get the requested amount of memory for the keybuffer, the out of memory could be signaled if one of the tentative allocations fail. Later the server would crash (debug assert) when trying to send a ok packet with a error set. The solution is only to signal the error if all tentative allocations for the keybuffer fail. mysql-test/r/key_cache.result: Add test case result for Bug#35272 mysql-test/t/key_cache.test: Add test case for Bug#35272 mysys/mf_keycache.c: Don't set error on my_large_malloc if allocation fails. Set the error if all tentative allocations failed. --- mysql-test/r/key_cache.result | 5 +++++ mysql-test/t/key_cache.test | 25 +++++++++++++++++++++++++ mysys/mf_keycache.c | 4 +++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 9ada5dc0784..6f30480d6b1 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -368,3 +368,8 @@ Variable_name Value key_cache_block_size 1536 SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; +SET @save_key_buffer = @@global.key_buffer_size; +SET @@global.key_buffer_size = 4294967295; +SET @@global.key_buffer_size = 9223372036854775807; +SET @@global.key_buffer_size = @save_key_buffer; +End of 5.1 tests diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 4c14dc96aaa..f588a964584 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -247,3 +247,28 @@ SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; # End of 4.1 tests + +# +# Bug#35272: @@global.key_buffer_size = 4294967295 let the server crash +# + +SET @save_key_buffer = @@global.key_buffer_size; + +# Wee try to force Out Of Memory here. key_buffer_size is ULL, so +# on a 32 bit machine, 4GB is the most we can ask for before the +# server complains about value/variable mismatch. At the off chance +# of one of our 64-bit machines actually offering us 4GB, we also +# accept "no error" (in addition to the expected "out of memory"). +--error 0,ER_OUTOFMEMORY +SET @@global.key_buffer_size = 4294967295; + +# on 32-bit, we get "out of range", on 64-bit, "out of memory". +--error 0,ER_WRONG_ARGUMENTS,ER_OUTOFMEMORY +--disable_warnings +SET @@global.key_buffer_size = 9223372036854775807; +--enable_warnings + +# restore normal value, just in case we got the 4GB or something. +SET @@global.key_buffer_size = @save_key_buffer; + +--echo End of 5.1 tests diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index a03d71f32d8..8001c61a6b9 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -102,6 +102,7 @@ */ #include "mysys_priv.h" +#include "mysys_err.h" #include #include "my_static.h" #include @@ -430,7 +431,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, /* Allocate memory for cache page buffers */ if ((keycache->block_mem= my_large_malloc((size_t) blocks * keycache->key_cache_block_size, - MYF(MY_WME)))) + MYF(0)))) { /* Allocate memory for blocks, hash_links and hash entries; @@ -445,6 +446,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, if (blocks < 8) { my_errno= ENOMEM; + my_error(EE_OUTOFMEMORY, MYF(0), blocks * keycache->key_cache_block_size); goto err; } blocks= blocks / 4*3; -- cgit v1.2.1 From b4b72fb306a1f816c0a39fe4a1eb70fa894ed70b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Mar 2008 19:37:36 +0300 Subject: Fix for bug #34928: Confusion by having Primary Key and Index The bug is a regression introduced in 5.1 by the patch for bug28404. Under some circumstances test_if_skip_sort_order() could leave some data structures in an inconsistent state so that some parts of code could assume the selected execution strategy for GROUP BY/DISTINCT as a loose index scan (e.g. JOIN_TAB::is_using_loose_index_scan()), while the actual strategy chosen was an ordered index scan, which led to wrong data being returned. Fixed test_if_skip_sort_order() so that when changing the type for a join table, select->quick is reset not only for EXPLAIN, but for the actual join execution as well, to not confuse code that depends on its value to determine the chosen GROUP BY/DISTINCT strategy. mysql-test/r/distinct.result: Added a test case for bug #34928. mysql-test/t/distinct.test: Added a test case for bug #34928. sql/sql_select.cc: When changing the table's join type to JT_NEXT in test_if_skip_sort_order(), also reset select->quick because other code may depend on its value to determine the GROUP BY/DISTINCT execution strategy. --- mysql-test/r/distinct.result | 23 +++++++++++++++++++++++ mysql-test/t/distinct.test | 23 +++++++++++++++++++++++ sql/sql_select.cc | 10 +++++----- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index b2a9eb04c04..15e4c3f15b3 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -682,3 +682,26 @@ a a b 1 1 3 DROP TABLE t1; End of 5.0 tests +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, +PRIMARY KEY(a,b,c,d,e), +KEY(a,b,d,c) +); +INSERT INTO t1(a, b, c) VALUES (1, 1, 1), +(1, 1, 2), +(1, 1, 3), +(1, 2, 1), +(1, 2, 2), +(1, 2, 3); +EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 16 NULL 6 Using index +SELECT DISTINCT a, b, d, c FROM t1; +a b d c +1 1 0 1 +1 1 0 2 +1 1 0 3 +1 2 0 1 +1 2 0 2 +1 2 0 3 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index bfdb5f8b9f8..559dde44b81 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -553,3 +553,26 @@ SELECT DISTINCT a, a, b FROM t1; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug #34928: Confusion by having Primary Key and Index +# +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, + PRIMARY KEY(a,b,c,d,e), + KEY(a,b,d,c) +); + +INSERT INTO t1(a, b, c) VALUES (1, 1, 1), + (1, 1, 2), + (1, 1, 3), + (1, 2, 1), + (1, 2, 2), + (1, 2, 3); + +EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; + +SELECT DISTINCT a, b, d, c FROM t1; + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 57bcb0b5942..1117df942dd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13158,6 +13158,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, tab->read_first_record= best_key_direction > 0 ? join_read_first:join_read_last; tab->type=JT_NEXT; // Read with index_first(), index_next() + if (select && select->quick) + { + delete select->quick; + select->quick= 0; + } if (table->covering_keys.is_set(best_key)) { table->key_read=1; @@ -13168,11 +13173,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, { tab->ref.key= -1; tab->ref.key_parts= 0; - if (select && select->quick) - { - delete select->quick; - select->quick= 0; - } if (select_limit < table_records) tab->limit= select_limit; } -- cgit v1.2.1 From f8653a79e96dc1e553b5c73b733a34fef343e15b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Mar 2008 09:37:20 -0300 Subject: Patch clean up. Fixed interference between tests: Users were added but not properly removed. This caused later tests to fail. mysql-test/r/grant.result: Fixed interference between tests: Users were added but not properly removed. This caused later tests to fail. mysql-test/t/grant.test: Fixed interference between tests: Users were added but not properly removed. This caused later tests to fail. --- mysql-test/r/grant.result | 4 ++-- mysql-test/t/grant.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 98a21b14585..d56020c3090 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1146,8 +1146,8 @@ select col1 from test limit 1 into tmp; return '1'; end| create view v1 as select test.* from test where test.col1=test_function(); -grant update (col1) on v1 to 'greg'; -revoke all privileges on v1 from 'greg'; +grant update (col1) on v1 to 'greg'@'localhost'; +drop user 'greg'@'localhost'; drop view v1; drop table test; drop function test_function; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 43548094a33..e4b95502143 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1169,8 +1169,8 @@ begin end| delimiter ;| create view v1 as select test.* from test where test.col1=test_function(); -grant update (col1) on v1 to 'greg'; -revoke all privileges on v1 from 'greg'; +grant update (col1) on v1 to 'greg'@'localhost'; +drop user 'greg'@'localhost'; drop view v1; drop table test; drop function test_function; -- cgit v1.2.1 From f6013e63b8d286a5f29cd4973c7bfe9ca4053fe8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Mar 2008 17:43:17 +0100 Subject: Bug#35272: @@global.key_buffer_size = 4294967295 let the server crash reverting test that has been obsoleted by changes to the code mysql-test/r/key_cache.result: reverting test that has been obsoleted by changes to the code mysql-test/t/key_cache.test: reverting test that has been obsoleted by changes to the code --- mysql-test/r/key_cache.result | 5 ----- mysql-test/t/key_cache.test | 25 ------------------------- 2 files changed, 30 deletions(-) diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 6f30480d6b1..9ada5dc0784 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -368,8 +368,3 @@ Variable_name Value key_cache_block_size 1536 SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; -SET @save_key_buffer = @@global.key_buffer_size; -SET @@global.key_buffer_size = 4294967295; -SET @@global.key_buffer_size = 9223372036854775807; -SET @@global.key_buffer_size = @save_key_buffer; -End of 5.1 tests diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index f588a964584..4c14dc96aaa 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -247,28 +247,3 @@ SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size; DROP TABLE t1; # End of 4.1 tests - -# -# Bug#35272: @@global.key_buffer_size = 4294967295 let the server crash -# - -SET @save_key_buffer = @@global.key_buffer_size; - -# Wee try to force Out Of Memory here. key_buffer_size is ULL, so -# on a 32 bit machine, 4GB is the most we can ask for before the -# server complains about value/variable mismatch. At the off chance -# of one of our 64-bit machines actually offering us 4GB, we also -# accept "no error" (in addition to the expected "out of memory"). ---error 0,ER_OUTOFMEMORY -SET @@global.key_buffer_size = 4294967295; - -# on 32-bit, we get "out of range", on 64-bit, "out of memory". ---error 0,ER_WRONG_ARGUMENTS,ER_OUTOFMEMORY ---disable_warnings -SET @@global.key_buffer_size = 9223372036854775807; ---enable_warnings - -# restore normal value, just in case we got the 4GB or something. -SET @@global.key_buffer_size = @save_key_buffer; - ---echo End of 5.1 tests -- cgit v1.2.1 From 77fbeeab2464d5f035a7393eb11953604a4ac3f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Mar 2008 19:39:21 +0200 Subject: Bug #35206: select query result different if the key is indexed or not The code for executing indexed ORDER BY was not setting all the internal fields correctly when selecting to execute ORDER BY over and index. Fixed by change the access method to one that will use the quick indexed access if one is selected while selecting indexed ORDER BY. mysql-test/r/order_by.result: Bug #35206: test case mysql-test/t/order_by.test: Bug #35206: test case sql/sql_select.cc: Bug #35206: Change the access method when selecting a quick indexed access. --- mysql-test/r/order_by.result | 30 +++ mysql-test/t/order_by.test | 462 +++++++++++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 17 ++ 3 files changed, 509 insertions(+) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 4320a7764de..faab8e49880 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1428,3 +1428,33 @@ set session max_sort_length= 2180; select * from t1 order by b; ERROR HY001: Out of sort memory; increase server sort buffer size drop table t1; +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, +UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)); +CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b)); +CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b)); +INSERT INTO t3 SELECT * FROM t1; +EXPLAIN +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1limit= select_limit; } } + else if (tab->type != JT_ALL) + { + /* + We're about to use a quick access to the table. + We need to change the access method so as the quick access + method is actually used. + */ + DBUG_ASSERT(tab->select->quick); + tab->type=JT_ALL; + tab->use_quick=1; + tab->ref.key= -1; + tab->ref.key_parts=0; // Don't use ref key. + tab->read_first_record= join_init_read_record; + /* + TODO: update the number of records in join->best_positions[tablenr] + */ + } } used_key_parts= best_key_parts; order_direction= best_key_direction; -- cgit v1.2.1