summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/bdb-crash.result7
-rw-r--r--mysql-test/r/myisam.result12
-rw-r--r--mysql-test/r/order_by.result105
-rw-r--r--mysql-test/t/order_by.test2
-rw-r--r--sql/field_conv.cc2
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_cmpfunc.cc6
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_acl.cc8
-rw-r--r--sql/sql_cache.cc5
-rw-r--r--sql/sql_help.cc6
-rw-r--r--sql/sql_olap.cc2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_select.cc29
-rw-r--r--sql/sql_table.cc24
-rw-r--r--sql/sql_test.cc12
18 files changed, 165 insertions, 67 deletions
diff --git a/mysql-test/r/bdb-crash.result b/mysql-test/r/bdb-crash.result
index e414934b07c..778890e85e3 100644
--- a/mysql-test/r/bdb-crash.result
+++ b/mysql-test/r/bdb-crash.result
@@ -37,10 +37,3 @@ analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Operation need committed state
drop table t1;
-create table t1 (a int) engine=bdb;
-set autocommit=0;
-insert into t1 values(1);
-analyze table t1;
-Table Op Msg_type Msg_text
-test.t1 analyze status Operation need committed state
-drop table t1;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 5dc4803137e..d210048a5c7 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -474,13 +474,13 @@ select sql_big_result distinct t1.a from t1,t2;
a
1
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
-table type possible_keys key key_len ref rows Extra
-t1 system NULL NULL NULL NULL 1 Using temporary
-t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
explain select distinct t1.a from t1,t2 order by t2.a;
-table type possible_keys key key_len ref rows Extra
-t1 system NULL NULL NULL NULL 1 Using temporary
-t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
drop table t1,t2;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX'
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 2e9fe1995d0..1a10c9c6ce9 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -546,3 +546,108 @@ a b
1 2
5 NULL
DROP TABLE t1;
+create table t1(id int not null auto_increment primary key, t char(12));
+explain select id,t from t1 order by id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 Using filesort
+explain select id,t from t1 force index (primary) order by id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 1000
+drop table t1;
+CREATE TABLE t1 (
+FieldKey varchar(36) NOT NULL default '',
+LongVal bigint(20) default NULL,
+StringVal mediumtext,
+KEY FieldKey (FieldKey),
+KEY LongField (FieldKey,LongVal),
+KEY StringField (FieldKey,StringVal(32))
+);
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref FieldKey,LongField,StringField LongField 36 const 3 Using where
+SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+FieldKey LongVal StringVal
+1 0 2
+1 1 3
+1 2 1
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range FieldKey,LongField,StringField FieldKey 36 NULL 4 Using where; Using filesort
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+FieldKey LongVal StringVal
+3 1 2
+3 2 1
+3 3 3
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range FieldKey,LongField,StringField LongField 36 NULL 4 Using where
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+FieldKey LongVal StringVal
+3 1 2
+3 2 1
+3 3 3
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT);
+SET @id=0;
+UPDATE t1 SET a=0 ORDER BY (a=@id), b;
+DROP TABLE t1;
+CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (11384, 2),(11392, 2);
+SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
+id
+11392
+drop table t1;
+create table t1(a int, b int, index(b));
+insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2);
+explain select * from t1 where b=1 or b is null order by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null b b 5 const 3 Using where; Using filesort
+select * from t1 where b=1 or b is null order by a;
+a b
+1 1
+2 1
+3 NULL
+4 NULL
+explain select * from t1 where b=2 or b is null order by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null b b 5 const 4 Using where; Using filesort
+select * from t1 where b=2 or b is null order by a;
+a b
+3 NULL
+4 NULL
+5 2
+6 2
+drop table t1;
+create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null,
+key(a,b,d), key(c,b,a));
+create table t2 like t1;
+insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3);
+insert into t2 select null, b, c, d from t1;
+insert into t1 select null, b, c, d from t2;
+insert into t2 select null, b, c, d from t1;
+insert into t1 select null, b, c, d from t2;
+insert into t2 select null, b, c, d from t1;
+insert into t1 select null, b, c, d from t2;
+insert into t2 select null, b, c, d from t1;
+insert into t1 select null, b, c, d from t2;
+insert into t2 select null, b, c, d from t1;
+insert into t1 select null, b, c, d from t2;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+set @row=10;
+insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10;
+select * from t1 where a=1 and b in (1) order by c, b, a;
+a b c d
+1 1 2 0
+1 1 12 -1
+1 1 52 -5
+1 1 92 -9
+select * from t1 where a=1 and b in (1);
+a b c d
+1 1 92 -9
+1 1 52 -5
+1 1 12 -1
+1 1 2 0
+drop table t1, t2;
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index aa3e7429bf2..27c3fb28bb0 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -361,7 +361,7 @@ while ($1)
enable_query_log;
explain select id,t from t1 order by id;
explain select id,t from t1 force index (primary) order by id;
-drop table t1;s
+drop table t1;
#
# Test of test_if_subkey() function
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 3272c2faf48..5632c63c521 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -173,7 +173,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
field->reset();
if (field == field->table->next_number_field)
{
- field->table->auto_increment_field_not_null= false;
+ field->table->auto_increment_field_not_null= FALSE;
return 0; // field is set in handler.cc
}
if (current_thd->count_cuted_fields == CHECK_FIELD_WARN)
diff --git a/sql/handler.cc b/sql/handler.cc
index d69836dadfa..38b95424637 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -879,11 +879,11 @@ void handler::update_auto_increment()
table->auto_increment_field_not_null &&
current_thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
{
- table->auto_increment_field_not_null= false;
+ table->auto_increment_field_not_null= FALSE;
auto_increment_column_changed=0;
DBUG_VOID_RETURN;
}
- table->auto_increment_field_not_null= false;
+ table->auto_increment_field_not_null= FALSE;
thd=current_thd;
if ((nr=thd->next_insert_id))
thd->next_insert_id=0; // Clear after use
diff --git a/sql/item.cc b/sql/item.cc
index 36b263f62cf..48e35f06ec3 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -637,7 +637,7 @@ void Item_param::set_time(TIME *tm, timestamp_type type)
ltime.time_type= type;
- item_is_time= true;
+ item_is_time= TRUE;
item_type= STRING_ITEM;
value_is_set= 1;
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 9175f12a60c..24d60b51eab 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -770,11 +770,13 @@ longlong Item_func_between::val_int()
null_value=1;
else if (args[1]->null_value)
{
- null_value= sortcmp(value,b,cmp_collation.collation) <= 0; // not null if false range.
+ // Set to not null if false range.
+ null_value= sortcmp(value,b,cmp_collation.collation) <= 0;
}
else
{
- null_value= sortcmp(value,a,cmp_collation.collation) >= 0; // not null if false range.
+ // Set to not null if false range.
+ null_value= sortcmp(value,a,cmp_collation.collation) >= 0;
}
}
else if (cmp_type == INT_RESULT)
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 807585f696d..113ef0e1922 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1759,7 +1759,7 @@ void Item_func_group_concat::clear()
result.length(0);
result.copy();
null_value= TRUE;
- warning_for_row= false;
+ warning_for_row= FALSE;
if (table)
{
table->file->extra(HA_EXTRA_NO_CACHE);
diff --git a/sql/slave.cc b/sql/slave.cc
index 5493d422d37..be9a5795233 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2681,7 +2681,7 @@ bool st_relay_log_info::is_until_satisfied()
/* Probably error so we aborting */
sql_print_error("Slave SQL thread is stopped because UNTIL "
"condition is bad.");
- return true;
+ return TRUE;
}
}
else
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 9284b1cd574..ef5036bb9f1 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1293,20 +1293,20 @@ bool hostname_requires_resolving(const char *hostname)
{
char cur;
if (!hostname)
- return false;
+ return FALSE;
int namelen= strlen(hostname);
int lhlen= strlen(my_localhost);
if ((namelen == lhlen) &&
!my_strnncoll(&my_charset_latin1, (const uchar *)hostname, namelen,
(const uchar *)my_localhost, strlen(my_localhost)))
- return false;
+ return FALSE;
for (; (cur=*hostname); hostname++)
{
if ((cur != '%') && (cur != '_') && (cur != '.') &&
((cur < '0') || (cur > '9')))
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
}
/*
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 52b0b05a757..66422a5ed3a 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -883,9 +883,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
DBUG_PRINT("qcache", ("Another thread process same query"));
}
}
- else
- if (thd->lex.sql_command == SQLCOM_SELECT)
- statistic_increment(refused, &structure_guard_mutex);
+ else if (thd->lex->sql_command == SQLCOM_SELECT)
+ statistic_increment(refused, &structure_guard_mutex);
end:
DBUG_VOID_RETURN;
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index f6bae67c3b6..980ed4047f3 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -731,12 +731,12 @@ int mysqld_help(THD *thd, const char *mask)
&categories_list,&category_id);
if (!count_categories)
{
- if (send_header_2(protocol,false))
+ if (send_header_2(protocol,FALSE))
goto end;
}
else if (count_categories > 1)
{
- if (send_header_2(protocol,false) ||
+ if (send_header_2(protocol,FALSE) ||
send_variant_2_list(mem_root,protocol,&categories_list,"Y",0))
goto end;
}
@@ -780,7 +780,7 @@ int mysqld_help(THD *thd, const char *mask)
else
{
/* First send header and functions */
- if (send_header_2(protocol, false) ||
+ if (send_header_2(protocol, FALSE) ||
send_variant_2_list(mem_root,protocol, &topics_list, "N", 0))
goto end;
search_categories(thd, tables[1].table, used_fields,
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index 026ddbae7c7..46f1e6c156e 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -64,7 +64,7 @@ static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new
while ((item=list_it++))
{
- bool not_found=true;
+ bool not_found= TRUE;
if (item->type()==Item::FIELD_ITEM)
{
Item_field *iif = (Item_field *)item;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 54d878eb760..68ef195cdc4 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1389,7 +1389,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
/* Clear variables that are allocated */
thd->user_connect= 0;
- int res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, false);
+ int res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, FALSE);
if (res)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2ac1b116635..63fe8d77f1a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1089,7 +1089,7 @@ JOIN::exec()
if (!tables_list)
{ // Only test of functions
if (select_options & SELECT_DESCRIBE)
- select_describe(this, false, false, false,
+ select_describe(this, FALSE, FALSE, FALSE,
(zero_result_cause?zero_result_cause:"No tables used"));
else
{
@@ -4112,7 +4112,7 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
if (select_options & SELECT_DESCRIBE)
{
- select_describe(join, false, false, false, info);
+ select_describe(join, FALSE, FALSE, FALSE, info);
DBUG_RETURN(0);
}
@@ -7161,8 +7161,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
/* check if we can use a key to resolve the group */
/* Tables using JT_NEXT are handled here */
uint nr;
- key_map keys_to_use, keys;
- keys_to_use.set_all();
+ key_map keys;
/*
If not used with LIMIT, only use keys if the whole query can be
@@ -7170,18 +7169,18 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
retrieving all rows through an index.
*/
if (select_limit >= table->file->records)
+ {
+ keys= *table->file->keys_to_use_for_scanning();
+ keys.merge(table->used_keys);
-nning();
-
-
-
-ified in FORCE INDEX clause,
-
-n ORDER BY.
-
-
-ry);
-
+ /*
+ We are adding here also the index speified in FORCE INDEX clause,
+ if any.
+ This is to allow users to use index in ORDER BY.
+ */
+ if (table->force_index)
+ keys.merge(table->keys_in_use_for_query);
+ keys.intersect(usable_keys);
}
else
keys= usable_keys;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b3728f4833e..db6f9043ec4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1669,13 +1669,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
case HA_ADMIN_REJECT:
protocol->store("status", 6, system_charset_info);
protocol->store("Operation need committed state",30, system_charset_info);
- open_for_modify= false;
- break;
-
- case HA_ADMIN_REJECT:
- net_store_data(packet,"status");
- net_store_data(packet,"Operation need committed state");
- open_for_modify= false;
+ open_for_modify= FALSE;
break;
case HA_ADMIN_ALREADY_DONE:
@@ -2081,9 +2075,10 @@ int mysql_discard_or_import_tablespace(THD *thd,
err:
close_thread_tables(thd);
thd->tablespace_op=FALSE;
- if (error == 0) {
+ if (error == 0)
+ {
send_ok(thd);
- DBUG_RETURN(0);
+ DBUG_RETURN(0);
}
DBUG_RETURN(error);
}
@@ -2878,13 +2873,14 @@ copy_data_between_tables(TABLE *from,TABLE *to,
goto err;
};
- /* Turn off recovery logging since rollback of an
- alter table is to delete the new table so there
- is no need to log the changes to it. */
- error = ha_recovery_logging(thd,FALSE);
+ /*
+ Turn off recovery logging since rollback of an alter table is to
+ delete the new table so there is no need to log the changes to it.
+ */
+ error= ha_recovery_logging(thd,FALSE);
if (error)
{
- error = 1;
+ error= 1;
goto err;
}
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 6763181ce4a..cc3d30e5983 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -276,10 +276,14 @@ static void display_table_locks(void)
THR_LOCK *lock=(THR_LOCK*) list->data;
VOID(pthread_mutex_lock(&lock->mutex));
- push_locks_into_array(&saved_table_locks, lock->write.data, false, "Locked - write");
- push_locks_into_array(&saved_table_locks, lock->write_wait.data, true, "Waiting - write");
- push_locks_into_array(&saved_table_locks, lock->read.data, false, "Locked - read");
- push_locks_into_array(&saved_table_locks, lock->read_wait.data, true, "Waiting - read");
+ push_locks_into_array(&saved_table_locks, lock->write.data, FALSE,
+ "Locked - write");
+ push_locks_into_array(&saved_table_locks, lock->write_wait.data, TRUE,
+ "Waiting - write");
+ push_locks_into_array(&saved_table_locks, lock->read.data, FALSE,
+ "Locked - read");
+ push_locks_into_array(&saved_table_locks, lock->read_wait.data, TRUE,
+ "Waiting - read");
VOID(pthread_mutex_unlock(&lock->mutex));
}
VOID(pthread_mutex_unlock(&THR_LOCK_lock));