Commit 0ed4d7e8 authored by unknown's avatar unknown

Merge gleb.loc:/home/uchum/work/bk/5.0-opt

into  gleb.loc:/home/uchum/work/bk/5.1-opt


mysql-test/r/create_not_windows.result:
  Auto merged
mysql-test/r/join_nested.result:
  Auto merged
mysql-test/r/symlink.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/type_time.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/create_not_windows.test:
  Auto merged
mysql-test/t/symlink.test:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/create.result:
  Merge with 5.0-opt.
mysql-test/r/type_enum.result:
  Merge with 5.0-opt.
mysql-test/t/type_enum.test:
  Merge with 5.0-opt.
sql/field_conv.cc:
  Merge with 5.0-opt.
parents 8b55336f 539ce171
...@@ -1516,23 +1516,6 @@ t1 CREATE TABLE `t1` ( ...@@ -1516,23 +1516,6 @@ t1 CREATE TABLE `t1` (
`c17` int(11) DEFAULT NULL `c17` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
CREATE DATABASE db1;
CREATE DATABASE db2;
USE db2;
INSERT INTO db2.t1 VALUES (1);
SELECT * FROM db2.t1;
b
1
RESET QUERY CACHE;
USE db1;
SET SESSION keep_files_on_create = TRUE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
SET SESSION keep_files_on_create = DEFAULT;
DROP TABLE db2.t1;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
End of 5.0 tests End of 5.0 tests
CREATE TABLE t1 (a int, b int); CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(1,2); insert into t1 values (1,1),(1,2);
......
...@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1); ...@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1);
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
ERROR 23000: Column 'a' in from clause is ambiguous ERROR 23000: Column 'a' in from clause is ambiguous
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
CREATE TABLE t1 (
carrier char(2) default NULL,
id int NOT NULL auto_increment PRIMARY KEY
);
INSERT INTO t1 VALUES
('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
CREATE TABLE t2 (
scan_date date default NULL,
package_id int default NULL,
INDEX scan_date(scan_date),
INDEX package_id(package_id)
);
INSERT INTO t2 VALUES
('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
CREATE TABLE t3 (
package_id int default NULL,
INDEX package_id(package_id)
);
INSERT INTO t3 VALUES
(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
CREATE TABLE t4 (
carrier char(2) NOT NULL default '' PRIMARY KEY,
id int(11) default NULL,
INDEX id(id)
);
INSERT INTO t4 VALUES
('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
CREATE TABLE t5 (
carrier_id int default NULL,
INDEX carrier_id(carrier_id)
);
INSERT INTO t5 VALUES
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
SELECT COUNT(*)
FROM((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id);
COUNT(*)
6
EXPLAIN
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
LEFT JOIN
(t5 JOIN t4 ON t5.carrier_id = t4.id)
ON t4.carrier = t1.carrier;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index package_id package_id 5 NULL 45 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1
1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1
1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
1 SIMPLE t3 ref package_id package_id 5 test.t1.id 1 Using where; Using index
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
LEFT JOIN
(t5 JOIN t4 ON t5.carrier_id = t4.id)
ON t4.carrier = t1.carrier;
COUNT(*)
6
DROP TABLE t1,t2,t3,t4,t5;
End of 5.0 tests End of 5.0 tests
...@@ -133,4 +133,26 @@ a ...@@ -133,4 +133,26 @@ a
42 42
drop table t1; drop table t1;
End of 4.1 tests End of 4.1 tests
CREATE DATABASE db1;
CREATE DATABASE db2;
USE db2;
INSERT INTO db2.t1 VALUES (1);
SELECT * FROM db2.t1;
b
1
RESET QUERY CACHE;
USE db1;
SET SESSION keep_files_on_create = TRUE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
CREATE TABLE t3 (a INT) Engine=MyISAM;
INSERT INTO t3 VALUES (1),(2),(3);
TRUNCATE TABLE t3;
SELECT * from t3;
a
SET SESSION keep_files_on_create = DEFAULT;
DROP TABLE db2.t1, db1.t3;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
End of 5.0 tests End of 5.0 tests
...@@ -1809,4 +1809,24 @@ f1 ...@@ -1809,4 +1809,24 @@ f1
drop table t1; drop table t1;
CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
INSERT INTO t1 (c1) VALUES ('b');
INSERT INTO t1 (c1) VALUES ('');
INSERT INTO t1 (c1) VALUES (0);
Warnings:
Warning 1265 Data truncated for column 'c1' at row 1
INSERT INTO t1 (c1) VALUES ('');
SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
c1 + 0 COUNT(c1)
0 1
2 2
3 1
CREATE TABLE t2 SELECT * FROM t1;
SELECT c1 + 0 FROM t2;
c1 + 0
3
2
0
2
DROP TABLE t1,t2;
End of 5.1 tests End of 5.1 tests
......
...@@ -208,10 +208,6 @@ options flags ...@@ -208,10 +208,6 @@ options flags
one one one one
drop table t2; drop table t2;
create table t2 select * from t1; create table t2 select * from t1;
Warnings:
Warning 1265 Data truncated for column 'options' at row 4
Warning 1265 Data truncated for column 'options' at row 5
Warning 1265 Data truncated for column 'options' at row 6
update t2 set string="changed" where auto=16; update t2 set string="changed" where auto=16;
show full columns from t1; show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
......
...@@ -85,3 +85,27 @@ sec_to_time(time_to_sec(t)) ...@@ -85,3 +85,27 @@ sec_to_time(time_to_sec(t))
13:00:00 13:00:00
09:00:00 09:00:00
drop table t1; drop table t1;
select cast('100:55:50' as time) < cast('24:00:00' as time);
cast('100:55:50' as time) < cast('24:00:00' as time)
0
select cast('100:55:50' as time) < cast('024:00:00' as time);
cast('100:55:50' as time) < cast('024:00:00' as time)
0
select cast('300:55:50' as time) < cast('240:00:00' as time);
cast('300:55:50' as time) < cast('240:00:00' as time)
0
select cast('100:55:50' as time) > cast('24:00:00' as time);
cast('100:55:50' as time) > cast('24:00:00' as time)
1
select cast('100:55:50' as time) > cast('024:00:00' as time);
cast('100:55:50' as time) > cast('024:00:00' as time)
1
select cast('300:55:50' as time) > cast('240:00:00' as time);
cast('300:55:50' as time) > cast('240:00:00' as time)
1
create table t1(f1 time, f2 time);
insert into t1 values('20:00:00','150:00:00');
select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
1
1
drop table t1;
...@@ -1122,37 +1122,6 @@ show create table t1; ...@@ -1122,37 +1122,6 @@ show create table t1;
drop table t1; drop table t1;
#
# Bug #29325: create table overwrites .MYD file of other table (datadir)
#
CREATE DATABASE db1;
CREATE DATABASE db2;
USE db2;
--disable_query_log
eval CREATE TABLE t1 (b INT) ENGINE MYISAM
DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
--enable_query_log
INSERT INTO db2.t1 VALUES (1);
SELECT * FROM db2.t1;
RESET QUERY CACHE;
USE db1;
#no warning from create table
SET SESSION keep_files_on_create = TRUE;
--disable_abort_on_error
CREATE TABLE t1 (a INT) ENGINE MYISAM;
--enable_abort_on_error
SET SESSION keep_files_on_create = DEFAULT;
DROP TABLE db2.t1;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
--echo End of 5.0 tests --echo End of 5.0 tests
......
...@@ -17,6 +17,7 @@ primary key (_id) ...@@ -17,6 +17,7 @@ primary key (_id)
show create table `about:text`; show create table `about:text`;
drop table `about:text`; drop table `about:text`;
# End of 5.0 tests # End of 5.0 tests
# #
......
...@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); ...@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# BUG#29604: inner nest of left join interleaves with outer tables
#
CREATE TABLE t1 (
carrier char(2) default NULL,
id int NOT NULL auto_increment PRIMARY KEY
);
INSERT INTO t1 VALUES
('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
CREATE TABLE t2 (
scan_date date default NULL,
package_id int default NULL,
INDEX scan_date(scan_date),
INDEX package_id(package_id)
);
INSERT INTO t2 VALUES
('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
CREATE TABLE t3 (
package_id int default NULL,
INDEX package_id(package_id)
);
INSERT INTO t3 VALUES
(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
CREATE TABLE t4 (
carrier char(2) NOT NULL default '' PRIMARY KEY,
id int(11) default NULL,
INDEX id(id)
);
INSERT INTO t4 VALUES
('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
CREATE TABLE t5 (
carrier_id int default NULL,
INDEX carrier_id(carrier_id)
);
INSERT INTO t5 VALUES
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
SELECT COUNT(*)
FROM((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id);
EXPLAIN
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
LEFT JOIN
(t5 JOIN t4 ON t5.carrier_id = t4.id)
ON t4.carrier = t1.carrier;
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
LEFT JOIN
(t5 JOIN t4 ON t5.carrier_id = t4.id)
ON t4.carrier = t1.carrier;
DROP TABLE t1,t2,t3,t4,t5;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -174,4 +174,42 @@ drop table t1; ...@@ -174,4 +174,42 @@ drop table t1;
--echo End of 4.1 tests --echo End of 4.1 tests
#
# Bug #29325: create table overwrites .MYD file of other table (datadir)
#
CREATE DATABASE db1;
CREATE DATABASE db2;
USE db2;
--disable_query_log
eval CREATE TABLE t1 (b INT) ENGINE MYISAM
DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
--enable_query_log
INSERT INTO db2.t1 VALUES (1);
SELECT * FROM db2.t1;
RESET QUERY CACHE;
USE db1;
#no warning from create table
SET SESSION keep_files_on_create = TRUE;
--disable_abort_on_error
CREATE TABLE t1 (a INT) ENGINE MYISAM;
--enable_abort_on_error
CREATE TABLE t3 (a INT) Engine=MyISAM;
INSERT INTO t3 VALUES (1),(2),(3);
TRUNCATE TABLE t3;
SELECT * from t3;
SET SESSION keep_files_on_create = DEFAULT;
DROP TABLE db2.t1, db1.t3;
DROP DATABASE db1;
DROP DATABASE db2;
USE test;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -183,4 +183,21 @@ insert into t1 values(''),(''),('a'),('b'); ...@@ -183,4 +183,21 @@ insert into t1 values(''),(''),('a'),('b');
select * from t1 where f1=''; select * from t1 where f1='';
drop table t1; drop table t1;
#
# Bug#29360: Confluence of the special 0 enum value with the normal empty string
# value during field to field copy.
#
CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
INSERT INTO t1 (c1) VALUES ('b');
INSERT INTO t1 (c1) VALUES ('');
INSERT INTO t1 (c1) VALUES (0);
INSERT INTO t1 (c1) VALUES ('');
SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
CREATE TABLE t2 SELECT * FROM t1;
SELECT c1 + 0 FROM t2;
DROP TABLE t1,t2;
--echo End of 5.1 tests --echo End of 5.1 tests
......
...@@ -40,3 +40,21 @@ drop table t1; ...@@ -40,3 +40,21 @@ drop table t1;
# ########################################################## # ##########################################################
# End of 4.1 tests # End of 4.1 tests
#
# Bug#29555: Comparing time values as strings may lead to a wrong result.
#
select cast('100:55:50' as time) < cast('24:00:00' as time);
select cast('100:55:50' as time) < cast('024:00:00' as time);
select cast('300:55:50' as time) < cast('240:00:00' as time);
select cast('100:55:50' as time) > cast('24:00:00' as time);
select cast('100:55:50' as time) > cast('024:00:00' as time);
select cast('300:55:50' as time) > cast('240:00:00' as time);
#
# Bug#29739: Incorrect time comparison in BETWEEN.
#
create table t1(f1 time, f2 time);
insert into t1 values('20:00:00','150:00:00');
select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
drop table t1;
...@@ -795,7 +795,14 @@ int field_conv(Field *to,Field *from) ...@@ -795,7 +795,14 @@ int field_conv(Field *to,Field *from)
blob->value.copy(); blob->value.copy();
return blob->store(blob->value.ptr(),blob->value.length(),from->charset()); return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
} }
if ((from->result_type() == STRING_RESULT && if (from->real_type() == MYSQL_TYPE_ENUM &&
to->real_type() == MYSQL_TYPE_ENUM &&
from->val_int() == 0)
{
((Field_enum *)(to))->store_type(0);
return 0;
}
else if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT || (to->result_type() == STRING_RESULT ||
(from->real_type() != MYSQL_TYPE_ENUM && (from->real_type() != MYSQL_TYPE_ENUM &&
from->real_type() != MYSQL_TYPE_SET))) || from->real_type() != MYSQL_TYPE_SET))) ||
......
...@@ -759,6 +759,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg, ...@@ -759,6 +759,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
func= &Arg_comparator::compare_datetime; func= &Arg_comparator::compare_datetime;
return 0; return 0;
} }
else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
(*b)->field_type() == MYSQL_TYPE_TIME)
{
/* Compare TIME values as integers. */
thd= current_thd;
owner= owner_arg;
func= ((test(owner && owner->functype() == Item_func::EQUAL_FUNC)) ?
&Arg_comparator::compare_e_int :
&Arg_comparator::compare_int_unsigned);
return 0;
}
return set_compare_func(owner_arg, type); return set_compare_func(owner_arg, type);
} }
...@@ -1771,6 +1783,7 @@ void Item_func_between::fix_length_and_dec() ...@@ -1771,6 +1783,7 @@ void Item_func_between::fix_length_and_dec()
max_length= 1; max_length= 1;
int i; int i;
bool datetime_found= FALSE; bool datetime_found= FALSE;
int time_items_found= 0;
compare_as_dates= TRUE; compare_as_dates= TRUE;
THD *thd= current_thd; THD *thd= current_thd;
...@@ -1791,6 +1804,8 @@ void Item_func_between::fix_length_and_dec() ...@@ -1791,6 +1804,8 @@ void Item_func_between::fix_length_and_dec()
At least one of items should be a DATE/DATETIME item and other items At least one of items should be a DATE/DATETIME item and other items
should return the STRING result. should return the STRING result.
*/ */
if (cmp_type == STRING_RESULT)
{
for (i= 0; i < 3; i++) for (i= 0; i < 3; i++)
{ {
if (args[i]->is_datetime()) if (args[i]->is_datetime())
...@@ -1798,10 +1813,10 @@ void Item_func_between::fix_length_and_dec() ...@@ -1798,10 +1813,10 @@ void Item_func_between::fix_length_and_dec()
datetime_found= TRUE; datetime_found= TRUE;
continue; continue;
} }
if (args[i]->result_type() == STRING_RESULT) if (args[i]->field_type() == MYSQL_TYPE_TIME &&
continue; args[i]->result_as_longlong())
compare_as_dates= FALSE; time_items_found++;
break; }
} }
if (!datetime_found) if (!datetime_found)
compare_as_dates= FALSE; compare_as_dates= FALSE;
...@@ -1811,6 +1826,11 @@ void Item_func_between::fix_length_and_dec() ...@@ -1811,6 +1826,11 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1); ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2); le_cmp.set_datetime_cmp_func(args, args + 2);
} }
else if (time_items_found == 3)
{
/* Compare TIME items as integers. */
cmp_type= INT_RESULT;
}
else if (args[0]->real_item()->type() == FIELD_ITEM && else if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW && thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE) thd->lex->sql_command != SQLCOM_SHOW_CREATE)
......
...@@ -8703,9 +8703,15 @@ static void restore_prev_nj_state(JOIN_TAB *last) ...@@ -8703,9 +8703,15 @@ static void restore_prev_nj_state(JOIN_TAB *last)
{ {
TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding; TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
JOIN *join= last->join; JOIN *join= last->join;
while (last_emb && !(--last_emb->nested_join->counter)) while (last_emb)
{ {
join->cur_embedding_map &= last_emb->nested_join->nj_map; if (!(--last_emb->nested_join->counter))
join->cur_embedding_map&= ~last_emb->nested_join->nj_map;
else if (last_emb->nested_join->join_list.elements-1 ==
last_emb->nested_join->counter)
join->cur_embedding_map|= last_emb->nested_join->nj_map;
else
break;
last_emb= last_emb->embedding; last_emb= last_emb->embedding;
} }
} }
......
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