diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2008-03-28 10:41:52 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2008-03-28 10:41:52 +0200 |
commit | 1c734848abd3739d2021138cd74002696b1f9e3c (patch) | |
tree | aff9a153698fcfbb202ced06d596144ce1bfbb4c /sql | |
parent | 099c888967557c164e11cb0ca7d895898be6edc9 (diff) | |
parent | c1af64e04f25a8dc01861c161b80be328de8f7d3 (diff) | |
download | mariadb-git-1c734848abd3739d2021138cd74002696b1f9e3c.tar.gz |
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.1
into magare.gmz:/home/kgeorge/mysql/work/merge-5.1-bugteam
mysql-test/r/grant.result:
Auto merged
mysql-test/t/grant.test:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_connect.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_range.cc | 90 | ||||
-rw-r--r-- | sql/sql_connect.cc | 23 | ||||
-rw-r--r-- | sql/sql_select.cc | 27 |
3 files changed, 92 insertions, 48 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b8bdb604eea..793742f9e7a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5726,52 +5726,70 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, field->type() == MYSQL_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 */ diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6f8cd6494cd..d9fb586eb77 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -701,20 +701,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; @@ -733,7 +737,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); @@ -763,7 +767,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; @@ -778,6 +782,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; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 57bcb0b5942..debd79a50e3 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,15 +13173,27 @@ 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; } } + 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; |