Commit 3302f3dd authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.1

into  mysql.com:/data0/knielsen/tmp-5.1
parents 888be349 961a272c
...@@ -202,35 +202,6 @@ select count(*) from t1 where id not in (1,2); ...@@ -202,35 +202,6 @@ select count(*) from t1 where id not in (1,2);
count(*) count(*)
1 1
drop table t1; drop table t1;
create table t1 (f1 char(1), f2 int);
insert into t1 values (1,0),('a',1),('z',2);
select f1 from t1 where f1 in (1,'z');
f1
1
z
select f2 from t1 where f2 in (1,'z');
f2
0
1
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'z'
select f1 from t1 where 'z' in (1,f1);
f1
z
select * from t1 where 'z' in (f2,f1);
f1 f2
1 0
a 1
z 2
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'z'
Warning 1292 Truncated incorrect DOUBLE value: 'z'
Warning 1292 Truncated incorrect DOUBLE value: 'z'
select * from t1 where 1 in (f2,f1);
f1 f2
1 0
a 1
drop table t1;
CREATE TABLE t1 (a int PRIMARY KEY); CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 VALUES (44), (45), (46); INSERT INTO t1 VALUES (44), (45), (46);
SELECT * FROM t1 WHERE a IN (45); SELECT * FROM t1 WHERE a IN (45);
......
...@@ -785,8 +785,8 @@ select f1 from t1 where "2006-1-1" between f1 and 'zzz'; ...@@ -785,8 +785,8 @@ select f1 from t1 where "2006-1-1" between f1 and 'zzz';
f1 f1
Warnings: Warnings:
Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1 Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1
Warning 1292 Truncated incorrect INTEGER value: 'zzz' Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
Warning 1292 Truncated incorrect INTEGER value: 'zzz' Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3); select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1 f1
2006-01-01 2006-01-01
......
...@@ -74,3 +74,25 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock ...@@ -74,3 +74,25 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock
UNLOCK TABLES; UNLOCK TABLES;
DROP DATABASE mysqltest_1; DROP DATABASE mysqltest_1;
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
unlock tables;
drop table t1;
use mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
use mysql;
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
OPTIMIZE TABLES columns_priv, db, host, user;
Table Op Msg_type Msg_text
mysql.columns_priv optimize status OK
mysql.db optimize status OK
mysql.host optimize status OK
mysql.user optimize status OK
UNLOCK TABLES;
Select_priv
N
use test;
use test;
...@@ -109,18 +109,6 @@ select count(*) from t1 where id not in (1); ...@@ -109,18 +109,6 @@ select count(*) from t1 where id not in (1);
select count(*) from t1 where id not in (1,2); select count(*) from t1 where id not in (1,2);
drop table t1; drop table t1;
#
# Bug#18360 Incorrect type coercion in IN() results in false comparison
#
create table t1 (f1 char(1), f2 int);
insert into t1 values (1,0),('a',1),('z',2);
select f1 from t1 where f1 in (1,'z');
select f2 from t1 where f2 in (1,'z');
select f1 from t1 where 'z' in (1,f1);
select * from t1 where 'z' in (f2,f1);
select * from t1 where 1 in (f2,f1);
drop table t1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -191,4 +191,59 @@ disconnect con2; ...@@ -191,4 +191,59 @@ disconnect con2;
--error ER_DB_DROP_EXISTS --error ER_DB_DROP_EXISTS
DROP DATABASE mysqltest_1; DROP DATABASE mysqltest_1;
#
# Bug #17264: MySQL Server freeze
#
connection locker;
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
connection writer;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection reader;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection locker;
--sleep 2
unlock tables;
connection writer;
reap;
connection reader;
reap;
connection locker;
drop table t1;
# End of 5.0 tests # End of 5.0 tests
# Bug#16986 - Deadlock condition with MyISAM tables
#
connection locker;
use mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
--sleep 1
#
connection reader;
use mysql;
#NOTE: This must be a multi-table select, otherwise the deadlock will not occur
send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
--sleep 1
#
connection locker;
# Make test case independent from earlier grants.
--replace_result "Table is already up to date" "OK"
OPTIMIZE TABLES columns_priv, db, host, user;
UNLOCK TABLES;
#
connection reader;
reap;
use test;
#
connection locker;
use test;
#
connection default;
...@@ -19,7 +19,7 @@ static int nope = 0; /* for use in asserts; shuts lint up */ ...@@ -19,7 +19,7 @@ static int nope = 0; /* for use in asserts; shuts lint up */
/* macros for manipulating states, small version */ /* macros for manipulating states, small version */
#define states long #define states long
#define states1 states /* for later use in regexec() decision */ #define states1 long /* for later use in regexec() decision. Ensure Win64 definition is correct.*/
#define CLEAR(v) ((v) = 0) #define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~((states) 1 << (n))) #define SET0(v, n) ((v) &= ~((states) 1 << (n)))
#define SET1(v, n) ((v) |= (states) 1 << (n)) #define SET1(v, n) ((v) |= (states) 1 << (n))
......
...@@ -6910,17 +6910,28 @@ ha_innobase::store_lock( ...@@ -6910,17 +6910,28 @@ ha_innobase::store_lock(
stored function call (MySQL does have thd->in_lock_tables stored function call (MySQL does have thd->in_lock_tables
TRUE there). */ TRUE there). */
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
&& lock_type <= TL_WRITE) && lock_type <= TL_WRITE)
&& !(thd->in_lock_tables && !(thd->in_lock_tables
&& thd->lex->sql_command == SQLCOM_LOCK_TABLES) && thd->lex->sql_command == SQLCOM_LOCK_TABLES)
&& !thd->tablespace_op && !thd->tablespace_op
&& thd->lex->sql_command != SQLCOM_TRUNCATE && thd->lex->sql_command != SQLCOM_TRUNCATE
&& thd->lex->sql_command != SQLCOM_OPTIMIZE && thd->lex->sql_command != SQLCOM_OPTIMIZE
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) { #ifdef __WIN__
/*
for alter table on win32 for succesfull operation
completion it is used TL_WRITE(=10) lock instead of
TL_WRITE_ALLOW_READ(=6), however here in innodb handler
TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
race condition when several clients do alter table
simultaneously (bug #17264). This fix avoids the problem.
*/
&& thd->lex->sql_command != SQLCOM_ALTER_TABLE
#endif
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
lock_type = TL_WRITE_ALLOW_WRITE; lock_type = TL_WRITE_ALLOW_WRITE;
} }
/* In queries of type INSERT INTO t1 SELECT ... FROM t2 ... /* In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
MySQL would use the lock TL_READ_NO_INSERT on t2, and that MySQL would use the lock TL_READ_NO_INSERT on t2, and that
......
...@@ -80,9 +80,6 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) ...@@ -80,9 +80,6 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
NOTES NOTES
Aggregation rules: Aggregation rules:
If all items are constants the type will be aggregated from all items.
If there are some non-constant items then only types of non-constant
items will be used for aggregation.
If there are DATE/TIME fields/functions in the list and no string If there are DATE/TIME fields/functions in the list and no string
fields/functions in the list then: fields/functions in the list then:
The INT_RESULT type will be used for aggregation instead of original The INT_RESULT type will be used for aggregation instead of original
...@@ -169,34 +166,29 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) ...@@ -169,34 +166,29 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
} }
} }
} }
/* Reset to 0 on first occurence of non-const item. 1 otherwise */
bool is_const= items[0]->const_item();
/* /*
If the first item is a date/time function then its result should be If the first item is a date/time function then its result should be
compared as int compared as int
*/ */
if (field) if (field)
{ /* Suppose we are comparing dates */
/* Suppose we are comparing dates and some non-constant items are present. */
type[0]= INT_RESULT; type[0]= INT_RESULT;
is_const= 0;
}
else else
type[0]= items[0]->result_type(); type[0]= items[0]->result_type();
for (i= 0; i < nitems ; i++) for (i= 0; i < nitems ; i++)
{ {
if (!items[i]->const_item()) Item_result result= items[i]->result_type();
{ /*
Item_result result= field && items[i]->result_as_longlong() ? Use INT_RESULT as result type for DATE/TIME fields/functions and
INT_RESULT : items[i]->result_type(); for constants successfully converted to DATE/TIME
type[0]= is_const ? result : item_cmp_type(type[0], result); */
is_const= 0; if (field &&
} ((!items[i]->const_item() && items[i]->result_as_longlong()) ||
else if (is_const) (items[i]->const_item() && convert_constant_item(thd, field,
type[0]= item_cmp_type(type[0], items[i]->result_type()); &items[i]))))
else if (field) result= INT_RESULT;
convert_constant_item(thd, field, &items[i]); type[0]= item_cmp_type(type[0], result);
} }
if (res == Item::FUNC_ITEM && field) if (res == Item::FUNC_ITEM && field)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment