5.3 merge

This commit is contained in:
Sergei Golubchik 2013-03-27 10:03:28 +01:00
commit 6599fd3e9c
38 changed files with 878 additions and 294 deletions

View file

@ -268,37 +268,37 @@ cast(010203101112.121314 as datetime)
0001-02-03 10:11:12
select cast(120010203101112.121314 as datetime);
cast(120010203101112.121314 as datetime)
NULL
0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '120010203101112.121314'
select cast(cast(1.1 as decimal) as datetime);
cast(cast(1.1 as decimal) as datetime)
NULL
0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '1'
select cast(cast(-1.1 as decimal) as datetime);
cast(cast(-1.1 as decimal) as datetime)
NULL
0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '-1'
select cast('0' as date);
cast('0' as date)
NULL
0000-00-00
Warnings:
Warning 1292 Incorrect datetime value: '0'
select cast('' as date);
cast('' as date)
NULL
0000-00-00
Warnings:
Warning 1292 Incorrect datetime value: ''
select cast('0' as datetime);
cast('0' as datetime)
NULL
0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '0'
select cast('' as datetime);
cast('' as datetime)
NULL
0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: ''
select cast('0' as time);
@ -306,7 +306,7 @@ cast('0' as time)
00:00:00
select cast('' as time);
cast('' as time)
NULL
00:00:00
Warnings:
Warning 1292 Truncated incorrect time value: ''
select cast(NULL as DATE);
@ -323,13 +323,13 @@ cast(NULL as BINARY)
NULL
select cast(cast(120010203101112.121314 as double) as datetime);
cast(cast(120010203101112.121314 as double) as datetime)
NULL
0000-00-00 00:00:00
select cast(cast(1.1 as double) as datetime);
cast(cast(1.1 as double) as datetime)
0000-00-00 00:00:01
select cast(cast(-1.1 as double) as datetime);
cast(cast(-1.1 as double) as datetime)
NULL
0000-00-00 00:00:00
explain extended select cast(10 as double(5,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used

View file

@ -521,7 +521,7 @@ TIME_FORMAT("25:00:00", '%l %p')
1 AM
SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896)
NULL
1151414896
Warnings:
Warning 1292 Incorrect datetime value: '%Y-%m-%d %H:%i:%s'
select str_to_date('04 /30/2004', '%m /%d/%Y');

View file

@ -182,13 +182,13 @@ select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212 AS unsigned int),1) as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int)`
Note 1003 select column_get(column_create(1,1212 AS unsigned int),1 as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int)`
explain extended
select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212 AS unsigned int),1) as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned)`
Note 1003 select column_get(column_create(1,1212 AS unsigned int),1 as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned)`
select column_get(column_create(1, 1212 AS decimal), 1 as unsigned int);
column_get(column_create(1, 1212 AS decimal), 1 as unsigned int)
1212
@ -261,13 +261,13 @@ select column_get(column_create(1, 1212 AS int), 1 as int);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212 AS int),1) as signed) AS `column_get(column_create(1, 1212 AS int), 1 as int)`
Note 1003 select column_get(column_create(1,1212 AS int),1 as signed) AS `column_get(column_create(1, 1212 AS int), 1 as int)`
explain extended
select column_get(column_create(1, 1212 AS int), 1 as signed int);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212 AS int),1) as signed) AS `column_get(column_create(1, 1212 AS int), 1 as signed int)`
Note 1003 select column_get(column_create(1,1212 AS int),1 as signed) AS `column_get(column_create(1, 1212 AS int), 1 as signed int)`
select column_get(column_create(1, -1212 AS int), 1 as int);
column_get(column_create(1, -1212 AS int), 1 as int)
-1212
@ -368,7 +368,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,'1212' AS char charset utf8 ),1) as char charset utf8) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8)`
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset utf8) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8)`
select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8);
column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8)
1212
@ -428,7 +428,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,'1212' AS char charset utf8 ),1) as char charset binary) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary)`
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset binary) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary)`
#
# column get real
#
@ -440,13 +440,13 @@ select column_get(column_create(1, 1212.12 AS double), 1 as double);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as double) AS `column_get(column_create(1, 1212.12 AS double), 1 as double)`
Note 1003 select column_get(column_create(1,1212.12 AS double),1 as double) AS `column_get(column_create(1, 1212.12 AS double), 1 as double)`
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as double(6,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as double(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as double(6,2))`
Note 1003 select column_get(column_create(1,1212.12 AS double),1 as double(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as double(6,2))`
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double);
column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double)
1.8446744073709552e19
@ -521,13 +521,13 @@ select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as decimal(10,0)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal)`
Note 1003 select column_get(column_create(1,1212.12 AS double),1 as decimal(10,0)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal)`
explain extended
select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as decimal(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2))`
Note 1003 select column_get(column_create(1,1212.12 AS double),1 as decimal(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2))`
select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0));
column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0))
18446744073709551615
@ -1335,3 +1335,74 @@ hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal))
select hex(COLUMN_CREATE(0, 0.0 as decimal));
hex(COLUMN_CREATE(0, 0.0 as decimal))
000100000004
#
# MDEV-4292: parse error when selecting on views using dynamic column
#
create table t1 (i int, d blob);
create view v1 as select i, column_get(d, 1 as binary) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as char charset binary) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as int) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as signed) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as unsigned int) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as unsigned) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as date) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as date) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as time) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as time) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as datetime) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as datetime) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as decimal) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as decimal(10,0)) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as double) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as double) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
create view v1 as select i, column_get(d, 1 as char) as a from t1;
select * from v1;
i a
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i`,column_get(`t1`.`d`,1 as char charset latin1) AS `a` from `t1` latin1 latin1_swedish_ci
drop view v1;
drop table t1;
#
# end of 5.3 tests
#

View file

@ -2090,6 +2090,13 @@ set @@optimizer_switch=@save_optimizer_switch;
# Cleanup for BUG#46680
#
DROP TABLE IF EXISTS t1,t2,t3,empty1;
create table t1 (i int, d date);
insert into t1 values (1, '2008-10-02'), (2, '2010-12-12');
select avg(export_set( 3, 'y', sha(i))), group_concat(d) from t1 group by d order by i;
avg(export_set( 3, 'y', sha(i))) group_concat(d)
0 2008-10-02
0 2010-12-12
drop table t1;
#
# Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),
# file .\item_sum.cc, line 587

View file

@ -217,7 +217,20 @@ SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
member_id_to COUNT(*)
518491 2
DROP TABLE t1;
# End of test BUG#12713907
#
# MDEV-4269: crash when grouping by values()
#
SELECT @@storage_engine INTO @old_engine;
set storage_engine=innodb;
create table y select 1 b;
select 1 from y group by b;
1
1
select 1 from y group by values(b);
1
1
drop table y;
SET storage_engine=@old_engine;
#
# Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
#

View file

@ -168,7 +168,7 @@ date("1997-12-31 23:59:59.000001")
1997-12-31
select date("1997-13-31 23:59:59.000001");
date("1997-13-31 23:59:59.000001")
NULL
0000-00-00
Warnings:
Warning 1292 Incorrect datetime value: '1997-13-31 23:59:59.000001'
select time("1997-12-31 23:59:59.000001");
@ -176,7 +176,7 @@ time("1997-12-31 23:59:59.000001")
23:59:59.000001
select time("1997-12-31 25:59:59.000001");
time("1997-12-31 25:59:59.000001")
NULL
00:00:00
Warnings:
Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001'
select microsecond("1997-12-31 23:59:59.000001");

View file

@ -2634,6 +2634,31 @@ SELECT * FROM t1;
a
aaaaaaaaaaaaaa
DROP TABLE t1;
SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
SUBSTRING('1', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
LEFT('1', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
RIGHT('1', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
REPEAT('1', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
NULL
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
NULL
create table t1 (i int);
insert into t1 values (null),(8);
select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field;
group_concat( i ) field
NULL NULL
8
drop table t1;
End of 5.1 tests
Start of 5.4 tests
SELECT format(12345678901234567890.123, 3);

View file

@ -1781,7 +1781,7 @@ Warnings:
Warning 1441 Datetime function: time field overflow
select cast('131415.123e0' as time);
cast('131415.123e0' as time)
NULL
00:00:00
Warnings:
Warning 1292 Truncated incorrect time value: '131415.123e0'
select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
@ -1801,12 +1801,12 @@ unix_timestamp(null)
NULL
select truncate(date('2010-40-10'), 6);
truncate(date('2010-40-10'), 6)
NULL
0.000000
Warnings:
Warning 1292 Incorrect datetime value: '2010-40-10'
select extract(month from '2010-40-50');
extract(month from '2010-40-50')
NULL
0
Warnings:
Warning 1292 Incorrect datetime value: '2010-40-50'
select subtime('0000-00-10 10:10:10', '30 10:00:00');
@ -1924,3 +1924,15 @@ microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010')
123456 10
select now(258);
ERROR 42000: Too big precision 258 specified for 'now'. Maximum is 6.
SELECT 1 FROM DUAL WHERE YEAR(TIMEDIFF(NULL, '12:12:12'));
1
SELECT 1 FROM DUAL WHERE MONTH(TIMEDIFF(NULL, '12:12:12'));
1
SELECT 1 FROM DUAL WHERE DAYOFMONTH(TIMEDIFF(NULL, '12:12:12'));
1
SELECT 1 FROM DUAL WHERE HOUR(TIMEDIFF(NULL, '12:12:12'));
1
SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
1
SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));
1

View file

@ -406,20 +406,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second
first second w c o e d t i r
120 120 1 1 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0
120 122 0 1 NULL 0 NULL 0 NULL 0
120 123 0 1 NULL 0 NULL 0 NULL 0
120 122 NULL NULL NULL NULL NULL NULL NULL NULL
120 123 NULL NULL NULL NULL NULL NULL NULL NULL
121 120 0 0 1 0 0 0 1 0
121 121 1 1 0 1 0 1 1 0
121 122 0 1 NULL 0 NULL 0 NULL 0
121 123 0 1 NULL 0 NULL 0 NULL 0
122 120 1 0 NULL 0 NULL 0 NULL 0
122 121 1 0 NULL 0 NULL 0 NULL 0
122 122 1 1 NULL 1 NULL 0 NULL 0
122 123 1 1 NULL 1 NULL 0 NULL 0
123 120 1 0 NULL 0 NULL 0 NULL 0
123 121 1 0 NULL 0 NULL 0 NULL 0
123 122 1 1 NULL 1 NULL 0 NULL 0
123 123 1 1 NULL 1 NULL 0 NULL 0
121 122 NULL NULL NULL NULL NULL NULL NULL NULL
121 123 NULL NULL NULL NULL NULL NULL NULL NULL
122 120 NULL NULL NULL NULL NULL NULL NULL NULL
122 121 NULL NULL NULL NULL NULL NULL NULL NULL
122 122 NULL NULL NULL NULL NULL NULL NULL NULL
122 123 NULL NULL NULL NULL NULL NULL NULL NULL
123 120 NULL NULL NULL NULL NULL NULL NULL NULL
123 121 NULL NULL NULL NULL NULL NULL NULL NULL
123 122 NULL NULL NULL NULL NULL NULL NULL NULL
123 123 NULL NULL NULL NULL NULL NULL NULL NULL
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
@ -1063,6 +1063,84 @@ create table t1(a char(32) not null) engine=myisam;
create spatial index i on t1 (a);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
drop table t1;
CREATE TABLE t0 (a BINARY(32) NOT NULL);
CREATE SPATIAL INDEX i on t0 (a);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
INSERT INTO t0 VALUES (1);
CREATE TABLE t1(
col0 BINARY NOT NULL,
col2 TIMESTAMP,
SPATIAL INDEX i1 (col0)
) ENGINE=MyISAM;
ERROR HY000: Incorrect arguments to SPATIAL INDEX
CREATE TABLE t1 (
col0 BINARY NOT NULL,
col2 TIMESTAMP
) ENGINE=MyISAM;
CREATE SPATIAL INDEX idx0 ON t1(col0);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
ALTER TABLE t1 ADD SPATIAL INDEX i1 (col0);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
CREATE TABLE t2 (
col0 INTEGER NOT NULL,
col1 POINT,
col2 POINT
);
CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
CREATE TABLE t3 (
col0 INTEGER NOT NULL,
col1 POINT,
col2 LINESTRING,
SPATIAL INDEX i1 (col1, col2)
);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
DROP TABLE t0, t1, t2;
#
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
#
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
NULL
#
# BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
# GEOMETRY FUNCTION ARGUMENTS
#
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
ERROR 22007: Illegal non geometric '' value found during parsing
#
# MDEV-4252 geometry query crashes server
#
select astext(0x0100000000030000000100000000000010);
astext(0x0100000000030000000100000000000010)
NULL
select astext(st_centroid(0x0100000000030000000100000000000010));
astext(st_centroid(0x0100000000030000000100000000000010))
NULL
select astext(st_exteriorring(0x0100000000030000000100000000000010));
astext(st_exteriorring(0x0100000000030000000100000000000010))
NULL
select envelope(0x0100000000030000000100000000000010);
envelope(0x0100000000030000000100000000000010)
NULL
select geometryn(0x0100000000070000000100000001030000000200000000000000ffff0000, 1);
geometryn(0x0100000000070000000100000001030000000200000000000000ffff0000, 1)
NULL
select geometryn(0x0100000000070000000100000001030000000200000000000000ffffff0f, 1);
geometryn(0x0100000000070000000100000001030000000200000000000000ffffff0f, 1)
NULL
#
# MDEV-4296 Assertion `n_linear_rings > 0' fails in Gis_polygon::centroid_xy
#
SELECT Centroid( AsBinary( LineString(Point(0,0), Point(0,0), Point(0,0) )));
Centroid( AsBinary( LineString(Point(0,0), Point(0,0), Point(0,0) )))
NULL
#
# MDEV-4295 Server crashes in get_point on a query with Area, AsBinary, MultiPoint
#
SELECT Area(AsBinary(MultiPoint(Point(0,9), Point(0,1), Point(2,2))));
Area(AsBinary(MultiPoint(Point(0,9), Point(0,1), Point(2,2))))
NULL
End of 5.1 tests
select ST_AREA(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'));
ST_AREA(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'))
@ -1428,6 +1506,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
count(*)
1
DROP DATABASE gis_ogs;
USE test;
#
# BUG #1043845 st_distance() results are incorrect depending on variable order
#
@ -1451,20 +1530,23 @@ geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
-95.9673057475387 36.1344478941074,
-95.9673063519371 36.
0.008148695928146028
USE test;
#
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
# MDEV-4310 geometry function equals hangs forever.
#
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
create table t1(a geometry not null)engine=myisam;
insert into t1 values(geomfromtext("POINT(0 0)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
select equals(`a`,convert(`a` using utf8)) from `t1`;
equals(`a`,convert(`a` using utf8))
1
NULL
#
# BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
# GEOMETRY FUNCTION ARGUMENTS
#
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
ERROR 22007: Illegal non geometric '' value found during parsing
End of 5.1 tests
NULL
Warnings:
Warning 1300 Invalid utf8 character string: 'E043'
Warning 1300 Invalid utf8 character string: 'E043'
drop table t1;
End of 5.3 tests
#
# Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE
#
@ -1498,19 +1580,4 @@ create table t1 (pt point);
insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))'));
ERROR 22007: Incorrect POINT value: 'POLYGON' for column 'pt' at row 1
drop table t1;
#
# TODO-424 geometry query crashes server
#
select astext(0x0100000000030000000100000000000010);
astext(0x0100000000030000000100000000000010)
NULL
select st_area(0x0100000000030000000100000000000010);
st_area(0x0100000000030000000100000000000010)
NULL
select astext(st_exteriorring(0x0100000000030000000100000000000010));
astext(st_exteriorring(0x0100000000030000000100000000000010))
NULL
select astext(st_centroid(0x0100000000030000000100000000000010));
astext(st_centroid(0x0100000000030000000100000000000010))
NULL
End of 5.5 tests

View file

@ -16,7 +16,7 @@ cast(convert(0x0030 using ucs2) as decimal(5.2)) cast(concat(convert(0x0030 usin
0 0
select cast(convert(_ucs2 0x0030 using latin1) as date), cast(concat(convert(_ucs2 0x0030 using latin1)) as date);
cast(convert(_ucs2 0x0030 using latin1) as date) cast(concat(convert(_ucs2 0x0030 using latin1)) as date)
NULL NULL
0000-00-00 0000-00-00
Warnings:
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '0'

View file

@ -580,25 +580,25 @@ select max(b) from t1 where a = 2;
max(b)
1
drop table t3,t1,t2;
CREATE TABLE t1 (c1 INT NOT NULL);
CREATE TABLE t2 (c1 INT NOT NULL);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
SELECT * FROM t3;
c1
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
insert into t2 values (2);
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
a
1
2
CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
INSERT INTO t4 VALUES (4);
INSERT INTO t5 VALUES (5);
CREATE TEMPORARY TABLE t6 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t4,t5);
SELECT * FROM t6;
c1
4
5
DROP TABLE t6, t3, t1, t2, t4, t5;
create temporary table t4 (a int not null);
create temporary table t5 (a int not null);
insert into t4 values (1);
insert into t5 values (2);
create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
select * from t6;
a
1
2
drop table t6, t3, t1, t2, t4, t5;
create temporary table t1 (a int not null);
create temporary table t2 (a int not null);
insert into t1 values (1);
@ -996,11 +996,6 @@ m1 CREATE TABLE `m1` (
`a` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, m1;
CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge;
SELECT MAX(a) FROM t1;
MAX(a)
NULL
DROP TABLE t1;
CREATE TABLE t1(a INT);
CREATE TABLE t2(a VARCHAR(10));
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
@ -1935,9 +1930,9 @@ ALTER TABLE t2 UNION=(t3,t1);
SELECT * FROM t2;
ERROR HY000: Table 't3' is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, t2, t3;
CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2);
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
SELECT * FROM t3;
@ -2400,6 +2395,142 @@ Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
DROP TABLE m1, t1;
End of 5.1 tests
#
# MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg
#
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 ( i int ) engine=myisam;
insert into t2 values (1),(2);
create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam;
create table t4 like t3;
insert into t3
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a < 5;
insert into t4
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a >= 5;
create table t5 like t3;
alter table t5 engine=merge;
alter table t5 union(t3, t4);
update t5 set b=999, a=999 where b>950;
explain
select * from t2, t5 where t5.a=999 and t5.b=999;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t5 index_merge a,b a,b 5,5 NULL 6 Using intersect(a,b); Using where; Using join buffer (flat, BNL join)
select * from t2, t5 where t5.a=999 and t5.b=999;
i a b filler
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
drop table t5;
drop table t1,t2,t3,t4;
End of 5.3 tests
CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge;
SELECT MAX(a) FROM t1;
MAX(a)
NULL
DROP TABLE t1;
#
# An additional test case for Bug#27430 Crash in subquery code
# when in PS and table DDL changed after PREPARE

View file

@ -2235,9 +2235,10 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL);
# test with an invalid date, which lead to item->null_value is set.
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1 SIMPLE t1 p20090401 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Warning 1292 Incorrect datetime value: '2009-04-99'
Warning 1292 Incorrect datetime value: '2009-04-99'
DROP TABLE t1;
CREATE TABLE t1
(a INT NOT NULL AUTO_INCREMENT,

View file

@ -0,0 +1,12 @@
create table t1 (a int);
insert into t1 values (4),(8);
select distinct 100 mod timestampadd( week, a, '2002-05-20' ) from t1;
100 mod timestampadd( week, a, '2002-05-20' )
100
drop table t1;
create table t1 (i int);
insert into t1 values (2),(4);
select distinct convert_tz( '2001-03-21', 'utc', 'met' ) mod i from t1;
convert_tz( '2001-03-21', 'utc', 'met' ) mod i
0
drop table t1;

View file

@ -136,7 +136,7 @@ select @d:=1311;
1311
select year(@d), month(@d), day(@d), cast(@d as date);
year(@d) month(@d) day(@d) cast(@d as date)
NULL NULL NULL NULL
0 0 0 0000-00-00
Warnings:
Warning 1292 Incorrect datetime value: '1311'
Warning 1292 Incorrect datetime value: '1311'

View file

@ -573,7 +573,7 @@ CAST('NULL' AS DATE) < CAST('2008-01-01' AS DATE) n7,
CAST('2008-01-01' AS DATE) < CAST('NULL' AS DATE) n8,
CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9;
n1 n2 n3 n4 n5 n6 n7 n8 n9
0 0 1 NULL NULL NULL NULL NULL NULL
0 0 1 1 1 0 1 0 0
Warnings:
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
@ -585,6 +585,8 @@ Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
End of 5.0 tests
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
@ -651,6 +653,19 @@ SELECT * FROM t1;
dt1
DROP TABLE t1;
End of 5.1 tests
create table t1 (d date, t time) engine=myisam;
insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31');
select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond;
cond group_concat( d )
0000-00-00 00:00:00 2000-12-03
0000-00-00 00:00:00 2008-05-03
Warnings:
Warning 1292 Incorrect datetime value: '22:55:23'
Warning 1292 Incorrect datetime value: '10:19:31'
Warning 1292 Incorrect datetime value: '22:55:23'
Warning 1292 Incorrect datetime value: '10:19:31'
drop table t1;
End of 5.3 tests
#
# Start of 5.5 tests
#

View file

@ -550,3 +550,60 @@ select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0))));
select hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal)));
select hex(COLUMN_CREATE(0, 0.0 as decimal));
--echo #
--echo # MDEV-4292: parse error when selecting on views using dynamic column
--echo #
create table t1 (i int, d blob);
create view v1 as select i, column_get(d, 1 as binary) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as int) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as unsigned int) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as date) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as time) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as datetime) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as decimal) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as double) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as char) as a from t1;
select * from v1;
show create view v1;
drop view v1;
drop table t1;
--echo #
--echo # end of 5.3 tests
--echo #

View file

@ -1372,7 +1372,16 @@ set @@optimizer_switch=@save_optimizer_switch;
--echo #
DROP TABLE IF EXISTS t1,t2,t3,empty1;
###
#
# MDEV-4286 Server crashes in Protocol_text::store, stack smashing detected
#
create table t1 (i int, d date);
insert into t1 values (1, '2008-10-02'), (2, '2010-12-12');
select avg(export_set( 3, 'y', sha(i))), group_concat(d) from t1 group by d order by i;
drop table t1;
#### End of 5.3 tests
--echo #
--echo # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),
--echo # file .\item_sum.cc, line 587

View file

@ -159,7 +159,20 @@ SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
DROP TABLE t1;
--echo # End of test BUG#12713907
--echo #
--echo # MDEV-4269: crash when grouping by values()
--echo #
SELECT @@storage_engine INTO @old_engine;
set storage_engine=innodb;
create table y select 1 b;
select 1 from y group by b;
select 1 from y group by values(b);
drop table y;
SET storage_engine=@old_engine;
### End of 5.1 tests
--echo #
--echo # Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN

View file

@ -1385,6 +1385,24 @@ LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
#
# MDEV-759 lp:998340 - Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1))
#
SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
#
# MDEV-4289 Assertion `0' fails in make_sortkey with GROUP_CONCAT, MAKE_SET, GROUP BY
#
create table t1 (i int);
insert into t1 values (null),(8);
select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field;
drop table t1;
--echo End of 5.1 tests
--echo Start of 5.4 tests

View file

@ -1174,3 +1174,13 @@ select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010')
--error ER_TOO_BIG_PRECISION
select now(258);
#
# MDEV-4293 Valgrind warnings (Conditional jump or move depends on uninitialised value) in remove_eq_conds on time functions with NULL argument in WHERE
#
SELECT 1 FROM DUAL WHERE YEAR(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE MONTH(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE DAYOFMONTH(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE HOUR(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));

View file

@ -759,6 +759,87 @@ create spatial index i on t1 (a);
drop table t1;
#
# Bug#11767480 - SPATIAL INDEXES ON NON-SPATIAL COLUMNS CAUSE CRASHES.
#
CREATE TABLE t0 (a BINARY(32) NOT NULL);
--error ER_WRONG_ARGUMENTS
CREATE SPATIAL INDEX i on t0 (a);
INSERT INTO t0 VALUES (1);
--error ER_WRONG_ARGUMENTS
CREATE TABLE t1(
col0 BINARY NOT NULL,
col2 TIMESTAMP,
SPATIAL INDEX i1 (col0)
) ENGINE=MyISAM;
# Test other ways to add indices
CREATE TABLE t1 (
col0 BINARY NOT NULL,
col2 TIMESTAMP
) ENGINE=MyISAM;
--error ER_WRONG_ARGUMENTS
CREATE SPATIAL INDEX idx0 ON t1(col0);
--error ER_WRONG_ARGUMENTS
ALTER TABLE t1 ADD SPATIAL INDEX i1 (col0);
CREATE TABLE t2 (
col0 INTEGER NOT NULL,
col1 POINT,
col2 POINT
);
--error ER_WRONG_ARGUMENTS
CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
--error ER_WRONG_ARGUMENTS
CREATE TABLE t3 (
col0 INTEGER NOT NULL,
col1 POINT,
col2 LINESTRING,
SPATIAL INDEX i1 (col1, col2)
);
# cleanup
DROP TABLE t0, t1, t2;
--echo #
--echo # BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
--echo #
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
--echo #
--echo # BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
--echo # GEOMETRY FUNCTION ARGUMENTS
--echo #
--replace_regex /non geometric .* value/non geometric '' value/
--error ER_ILLEGAL_VALUE_FOR_TYPE
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
--echo #
--echo # MDEV-4252 geometry query crashes server
--echo #
select astext(0x0100000000030000000100000000000010);
select astext(st_centroid(0x0100000000030000000100000000000010));
select astext(st_exteriorring(0x0100000000030000000100000000000010));
select envelope(0x0100000000030000000100000000000010);
select geometryn(0x0100000000070000000100000001030000000200000000000000ffff0000, 1);
select geometryn(0x0100000000070000000100000001030000000200000000000000ffffff0f, 1);
--echo #
--echo # MDEV-4296 Assertion `n_linear_rings > 0' fails in Gis_polygon::centroid_xy
--echo #
SELECT Centroid( AsBinary( LineString(Point(0,0), Point(0,0), Point(0,0) )));
--echo #
--echo # MDEV-4295 Server crashes in get_point on a query with Area, AsBinary, MultiPoint
--echo #
SELECT Area(AsBinary(MultiPoint(Point(0,9), Point(0,1), Point(2,2))));
--echo End of 5.1 tests
#bug 850775 ST_AREA does not work on GEOMETRYCOLLECTIONs in maria-5.3-gis
@ -1293,6 +1374,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
#WHERE lakes.name = 'Blue Lake';
DROP DATABASE gis_ogs;
USE test;
--echo #
--echo # BUG #1043845 st_distance() results are incorrect depending on variable order
@ -1308,25 +1390,18 @@ select st_distance(geomfromtext('point(-95.96269500000000000000 36.1418183333333
-95.9673057475387 36.1344478941074,
-95.9673063519371 36.134484524621,
-95.9673049102515 36.1343976584193) ')) ;
USE test;
--echo #
--echo # BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
--echo # MDEV-4310 geometry function equals hangs forever.
--echo #
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
--echo #
--echo # BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
--echo # GEOMETRY FUNCTION ARGUMENTS
--echo #
--replace_regex /non geometric .* value/non geometric '' value/
--error ER_ILLEGAL_VALUE_FOR_TYPE
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
--echo End of 5.1 tests
create table t1(a geometry not null)engine=myisam;
insert into t1 values(geomfromtext("POINT(0 0)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
select equals(`a`,convert(`a` using utf8)) from `t1`;
drop table t1;
--echo End of 5.3 tests
--echo #
--echo # Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE
@ -1367,11 +1442,4 @@ create table t1 (pt point);
insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))'));
drop table t1;
--echo #
--echo # TODO-424 geometry query crashes server
--echo #
select astext(0x0100000000030000000100000000000010);
select st_area(0x0100000000030000000100000000000010);
select astext(st_exteriorring(0x0100000000030000000100000000000010));
select astext(st_centroid(0x0100000000030000000100000000000010));
--echo End of 5.5 tests

View file

@ -226,19 +226,19 @@ drop table t3,t1,t2;
#
# temporary merge tables
#
CREATE TABLE t1 (c1 INT NOT NULL);
CREATE TABLE t2 (c1 INT NOT NULL);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
SELECT * FROM t3;
CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
INSERT INTO t4 VALUES (4);
INSERT INTO t5 VALUES (5);
CREATE TEMPORARY TABLE t6 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t4,t5);
SELECT * FROM t6;
DROP TABLE t6, t3, t1, t2, t4, t5;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
insert into t2 values (2);
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
create temporary table t4 (a int not null);
create temporary table t5 (a int not null);
insert into t4 values (1);
insert into t5 values (2);
create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
select * from t6;
drop table t6, t3, t1, t2, t4, t5;
#
# Bug#19627 - temporary merge table locking
# MERGE table and its children must match in temporary type.
@ -621,14 +621,6 @@ ALTER TABLE m1 UNION=();
SHOW CREATE TABLE m1;
DROP TABLE t1, m1;
#
# BUG#35274 - merge table doesn't need any base tables, gives error 124 when
# key accessed
#
CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge;
SELECT MAX(a) FROM t1;
DROP TABLE t1;
#
# BUG#32047 - 'Spurious' errors while opening MERGE tables
#
@ -1306,9 +1298,9 @@ DROP TABLE t1, t2, t3;
# Truncate failed with error message when table was in use by MERGE.
#
# Show that truncate of child table after use of parent table works.
CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2);
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
SELECT * FROM t3;
@ -1840,6 +1832,51 @@ DROP TABLE m1, t1;
--echo End of 5.1 tests
--echo #
--echo # MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg
--echo #
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 ( i int ) engine=myisam;
insert into t2 values (1),(2);
create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam;
create table t4 like t3;
insert into t3
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a < 5;
insert into t4
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a >= 5;
create table t5 like t3;
alter table t5 engine=merge;
alter table t5 union(t3, t4);
update t5 set b=999, a=999 where b>950;
explain
select * from t2, t5 where t5.a=999 and t5.b=999;
select * from t2, t5 where t5.a=999 and t5.b=999;
drop table t5;
drop table t1,t2,t3,t4;
--echo End of 5.3 tests
#
# BUG#35274 - merge table doesn't need any base tables, gives error 124 when
# key accessed
#
CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge;
SELECT MAX(a) FROM t1;
DROP TABLE t1;
--echo #
--echo # An additional test case for Bug#27430 Crash in subquery code
--echo # when in PS and table DDL changed after PREPARE
@ -2845,3 +2882,4 @@ eval set global storage_engine=$default;
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc

View file

@ -0,0 +1,13 @@
#
# MDEV-4283 Assertion `scale <= precision' fails in strings/decimal.c
#
create table t1 (a int);
insert into t1 values (4),(8);
select distinct 100 mod timestampadd( week, a, '2002-05-20' ) from t1;
drop table t1;
create table t1 (i int);
insert into t1 values (2),(4);
select distinct convert_tz( '2001-03-21', 'utc', 'met' ) mod i from t1;
drop table t1;

View file

@ -463,6 +463,16 @@ DROP TABLE t1;
--echo End of 5.1 tests
#
# MDEV-4281 Assertion `maybe_null && item->null_value' fails in make_sortkey on CASE with different return types, GROUP_CONCAT, GROUP BY
#
create table t1 (d date, t time) engine=myisam;
insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31');
select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond;
drop table t1;
--echo End of 5.3 tests
--echo #
--echo # Start of 5.5 tests
--echo #

View file

@ -875,7 +875,10 @@ static void make_sortkey(register SORTPARAM *param,
{
MYSQL_TIME buf;
if (item->get_date_result(&buf, TIME_FUZZY_DATE | TIME_INVALID_DATES))
DBUG_ASSERT(maybe_null && item->null_value);
{
DBUG_ASSERT(maybe_null);
DBUG_ASSERT(item->null_value);
}
else
value= pack_time(&buf);
}

View file

@ -1272,11 +1272,15 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
DBUG_ASSERT(0);
}
return 0;
return null_value= 0;
err:
/*
if the item was not null and convertion failed, we return a zero date
if allowed, otherwise - null.
*/
bzero((char*) ltime,sizeof(*ltime));
return 1;
return null_value|= (fuzzydate & (TIME_NO_ZERO_DATE|TIME_NO_ZERO_IN_DATE));
}
bool Item::get_seconds(ulonglong *sec, ulong *sec_part)

View file

@ -4373,8 +4373,7 @@ Create_func_make_set::create_native(THD *thd, LEX_STRING name,
return NULL;
}
Item *param_1= item_list->pop();
return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
return new (thd->mem_root) Item_func_make_set(*item_list);
}

View file

@ -769,13 +769,14 @@ void Item_num_op::find_num_type(void)
{
hybrid_type= DECIMAL_RESULT;
result_precision();
fix_decimals();
}
else
{
DBUG_ASSERT(r0 == INT_RESULT && r1 == INT_RESULT);
decimals= 0;
hybrid_type=INT_RESULT;
result_precision();
decimals= 0;
}
DBUG_PRINT("info", ("Type: %s",
(hybrid_type == REAL_RESULT ? "REAL_RESULT" :
@ -1708,6 +1709,7 @@ void Item_func_div::fix_length_and_dec()
break;
case DECIMAL_RESULT:
result_precision();
fix_decimals();
break;
case STRING_RESULT:
case ROW_RESULT:

View file

@ -431,6 +431,13 @@ public:
void fix_num_length_and_dec();
virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
inline void fix_decimals()
{
DBUG_ASSERT(result_type() == DECIMAL_RESULT);
if (decimals == NOT_FIXED_DEC)
set_if_smaller(decimals, max_length - 1);
}
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal *);

View file

@ -561,8 +561,8 @@ longlong Item_func_spatial_mbr_rel::val_int()
args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &dummy) ||
g2->get_mbr(&mbr2, &dummy))))
g1->get_mbr(&mbr1, &dummy) || !mbr1.valid() ||
g2->get_mbr(&mbr2, &dummy) || !mbr2.valid())))
return 0;
switch (spatial_rel) {
@ -687,12 +687,11 @@ longlong Item_func_spatial_rel::val_int()
if ((null_value=
(args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())))))
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) || !mbr1.valid() ||
g2->get_mbr(&mbr2, &c_end) || !mbr2.valid())))
goto exit;
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
umbr= mbr1;
umbr.add_mbr(&mbr2);
collector.set_extent(umbr.xmin, umbr.xmax, umbr.ymin, umbr.ymax);
@ -826,14 +825,14 @@ String *Item_func_spatial_operation::val_str(String *str_value)
if ((null_value=
(args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())))))
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) || !mbr1.valid() ||
g2->get_mbr(&mbr2, &c_end) || !mbr2.valid())))
{
str_value= 0;
goto exit;
}
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
mbr1.add_mbr(&mbr2);
collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax);
@ -1358,11 +1357,11 @@ longlong Item_func_issimple::val_int()
DBUG_ENTER("Item_func_issimple::val_int");
DBUG_ASSERT(fixed == 1);
if ((null_value= args[0]->null_value) ||
!(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))
if ((null_value= (args[0]->null_value ||
!(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
g->get_mbr(&mbr, &c_end))))
DBUG_RETURN(0);
g->get_mbr(&mbr, &c_end);
collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax);
if (g->get_class_info()->m_type_id == Geometry::wkb_point)
@ -1598,11 +1597,11 @@ double Item_func_distance::val_real()
if ((null_value= (args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())))))
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) ||
g2->get_mbr(&mbr2, &c_end))))
goto mem_error;
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
mbr1.add_mbr(&mbr2);
collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax);

View file

@ -2460,38 +2460,16 @@ String *Item_func_elt::val_str(String *str)
}
void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields)
{
item->split_sum_func2(thd, ref_pointer_array, fields, &item, TRUE);
Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
}
void Item_func_make_set::fix_length_and_dec()
{
uint32 char_length= arg_count - 1; /* Separators */
uint32 char_length= arg_count - 2; /* Separators */
if (agg_arg_charsets_for_string_result(collation, args, arg_count))
if (agg_arg_charsets_for_string_result(collation, args + 1, arg_count - 1))
return;
for (uint i=0 ; i < arg_count ; i++)
for (uint i=1 ; i < arg_count ; i++)
char_length+= args[i]->max_char_length();
fix_char_length(char_length);
used_tables_cache|= item->used_tables();
not_null_tables_cache&= item->not_null_tables();
const_item_cache&= item->const_item();
with_sum_func= with_sum_func || item->with_sum_func;
with_field= with_field || item->with_field;
}
void Item_func_make_set::update_used_tables()
{
Item_func::update_used_tables();
item->update_used_tables();
used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item();
}
@ -2500,15 +2478,15 @@ String *Item_func_make_set::val_str(String *str)
DBUG_ASSERT(fixed == 1);
ulonglong bits;
bool first_found=0;
Item **ptr=args;
Item **ptr=args+1;
String *result=&my_empty_string;
bits=item->val_int();
if ((null_value=item->null_value))
bits=args[0]->val_int();
if ((null_value=args[0]->null_value))
return NULL;
if (arg_count < 64)
bits &= ((ulonglong) 1 << arg_count)-1;
if (arg_count < 65)
bits &= ((ulonglong) 1 << (arg_count-1))-1;
for (; bits; bits >>= 1, ptr++)
{
@ -2548,39 +2526,6 @@ String *Item_func_make_set::val_str(String *str)
}
Item *Item_func_make_set::transform(Item_transformer transformer, uchar *arg)
{
DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
Item *new_item= item->transform(transformer, arg);
if (!new_item)
return 0;
/*
THD::change_item_tree() should be called only if the tree was
really transformed, i.e. when a new item has been created.
Otherwise we'll be allocating a lot of unnecessary memory for
change records at each execution.
*/
if (item != new_item)
current_thd->change_item_tree(&item, new_item);
return Item_str_func::transform(transformer, arg);
}
void Item_func_make_set::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("make_set("));
item->print(str, query_type);
if (arg_count)
{
str->append(',');
print_args(str, 0, query_type);
}
str->append(')');
}
String *Item_func_char::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@ -4497,11 +4442,16 @@ null:
void Item_dyncol_get::print(String *str, enum_query_type query_type)
{
/* see create_func_dyncol_get */
DBUG_ASSERT(str->length() >= 5);
DBUG_ASSERT(strncmp(str->ptr() + str->length() - 5, "cast(", 5) == 0);
str->length(str->length() - 5); // removing "cast("
str->append(STRING_WITH_LEN("column_get("));
args[0]->print(str, query_type);
str->append(',');
args[1]->print(str, query_type);
str->append(')');
/* let the parent cast item add " as <type>)" */
}

View file

@ -544,31 +544,13 @@ public:
class Item_func_make_set :public Item_str_func
{
Item *item;
String tmp_str;
public:
Item_func_make_set(Item *a,List<Item> &list) :Item_str_func(list),item(a) {}
Item_func_make_set(List<Item> &list) :Item_str_func(list) {}
String *val_str(String *str);
bool fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed == 0);
return ((!item->fixed && item->fix_fields(thd, &item)) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, ref));
}
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
void fix_length_and_dec();
void update_used_tables();
const char *func_name() const { return "make_set"; }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
{
return item->walk(processor, walk_subquery, arg) ||
Item_str_func::walk(processor, walk_subquery, arg);
}
Item *transform(Item_transformer transformer, uchar *arg);
virtual void print(String *str, enum_query_type query_type);
};

View file

@ -1581,9 +1581,10 @@ void Item_sum_avg::fix_length_and_dec()
f_scale= args[0]->decimals;
dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
}
else {
else
{
decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
max_length= args[0]->max_length + prec_increment;
max_length= min(args[0]->max_length + prec_increment, float_length(decimals));
}
}

View file

@ -923,16 +923,14 @@ longlong Item_func_dayofmonth::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.day;
return get_arg0_date(&ltime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.day;
}
longlong Item_func_month::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.month;
return get_arg0_date(&ltime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.month;
}
@ -983,16 +981,14 @@ longlong Item_func_hour::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.hour;
return get_arg0_time(&ltime) ? 0 : ltime.hour;
}
longlong Item_func_minute::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.minute;
return get_arg0_time(&ltime) ? 0 : ltime.minute;
}
/**
@ -1002,8 +998,7 @@ longlong Item_func_second::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_time(&ltime);
return ltime.second;
return get_arg0_time(&ltime) ? 0 : ltime.second;
}
@ -1120,8 +1115,7 @@ longlong Item_func_year::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
(void) get_arg0_date(&ltime, TIME_FUZZY_DATE);
return (longlong) ltime.year;
return get_arg0_date(&ltime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.year;
}

View file

@ -312,6 +312,9 @@ bool Geometry::envelope(String *result) const
const char *end;
if (get_mbr(&mbr, &end))
return 1;
if (!mbr.valid())
{
/* Empty geometry */
if (result->reserve(1 + 4*2))
@ -444,18 +447,19 @@ const char *Geometry::append_points(String *txt, uint32 n_points,
const char *Geometry::get_mbr_for_points(MBR *mbr, const char *data,
uint offset) const
{
uint32 points;
uint32 n_points;
/* read number of points */
if (no_data(data, 4))
return 0;
points= uint4korr(data);
n_points= uint4korr(data);
data+= 4;
if (no_data(data, (POINT_DATA_SIZE + offset) * points))
if (n_points > max_n_points ||
no_data(data, (POINT_DATA_SIZE + offset) * n_points))
return 0;
/* Calculate MBR for points */
while (points--)
while (n_points--)
{
data+= offset;
mbr->add_xy(data, data + SIZEOF_STORED_DOUBLE);
@ -559,9 +563,12 @@ const Geometry::Class_info *Gis_point::get_class_info() const
uint32 Gis_line_string::get_data_size() const
{
if (no_data(m_data, 4))
uint32 n_points, size;
if (no_data(m_data, 4) ||
(n_points= uint4korr(m_data)) > max_n_points ||
no_data(m_data, (size= 4 + n_points * POINT_DATA_SIZE)))
return GET_SIZE_ERROR;
return 4 + uint4korr(m_data) * POINT_DATA_SIZE;
return size;
}
@ -754,6 +761,9 @@ int Gis_line_string::end_point(String *result) const
if (no_data(m_data, 4))
return 1;
n_points= uint4korr(m_data);
if (n_points == 0 || n_points > max_n_points ||
no_data(m_data, POINT_DATA_SIZE * n_points))
return 1;
return create_point(result, m_data + 4 + (n_points - 1) * POINT_DATA_SIZE);
}
@ -763,11 +773,14 @@ int Gis_line_string::point_n(uint32 num, String *result) const
uint32 n_points;
if (no_data(m_data, 4))
return 1;
num--;
n_points= uint4korr(m_data);
if ((uint32) (num - 1) >= n_points) // means (num > n_points || num < 1)
if (num >= n_points ||
num > max_n_points || // means (num > n_points || num < 1)
no_data(m_data, num * POINT_DATA_SIZE))
return 1;
return create_point(result, m_data + 4 + (num - 1) * POINT_DATA_SIZE);
return create_point(result, m_data + 4 + num*POINT_DATA_SIZE);
}
@ -817,6 +830,7 @@ const Geometry::Class_info *Gis_line_string::get_class_info() const
uint32 Gis_polygon::get_data_size() const
{
uint32 n_linear_rings;
uint32 n_points;
const char *data= m_data;
if (no_data(data, 4))
@ -826,10 +840,13 @@ uint32 Gis_polygon::get_data_size() const
while (n_linear_rings--)
{
if (no_data(data, 4))
if (no_data(data, 4) ||
(n_points= uint4korr(data)) > max_n_points)
return GET_SIZE_ERROR;
data+= 4 + uint4korr(data)*POINT_DATA_SIZE;
data+= 4 + n_points*POINT_DATA_SIZE;
}
if (no_data(data, 0))
return GET_SIZE_ERROR;
return (uint32) (data - m_data);
}
@ -1022,7 +1039,8 @@ int Gis_polygon::area(double *ar, const char **end_of_data) const
if (no_data(data, 4))
return 1;
n_points= uint4korr(data);
if (n_points > max_n_points || no_data(data, POINT_DATA_SIZE * n_points))
if (n_points == 0 || n_points > max_n_points ||
no_data(data, POINT_DATA_SIZE * n_points))
return 1;
get_point(&prev_x, &prev_y, data+4);
data+= (4+POINT_DATA_SIZE);
@ -1126,13 +1144,11 @@ int Gis_polygon::centroid_xy(double *x, double *y) const
const char *data= m_data;
bool first_loop= 1;
if (no_data(data, 4))
if (no_data(data, 4) ||
(n_linear_rings= uint4korr(data)) == 0)
return 1;
n_linear_rings= uint4korr(data);
data+= 4;
DBUG_ASSERT(n_linear_rings > 0);
while (n_linear_rings--)
{
uint32 n_points, org_n_points;
@ -1145,7 +1161,8 @@ int Gis_polygon::centroid_xy(double *x, double *y) const
return 1;
org_n_points= n_points= uint4korr(data);
data+= 4;
if (n_points > max_n_points || no_data(data, POINT_DATA_SIZE * n_points))
if (n_points == 0 || n_points > max_n_points ||
no_data(data, POINT_DATA_SIZE * n_points))
return 1;
get_point(&prev_x, &prev_y, data);
data+= POINT_DATA_SIZE;
@ -1273,9 +1290,14 @@ const Geometry::Class_info *Gis_polygon::get_class_info() const
uint32 Gis_multi_point::get_data_size() const
{
if (no_data(m_data, 4))
return GET_SIZE_ERROR;
return 4 + uint4korr(m_data)*(POINT_DATA_SIZE + WKB_HEADER_SIZE);
uint32 n_points;
uint32 size;
if (no_data(m_data, 4) ||
(n_points= uint4korr(m_data)) > max_n_points ||
no_data(m_data, (size= 4 + n_points*(POINT_DATA_SIZE + WKB_HEADER_SIZE))))
return GET_SIZE_ERROR;
return size;
}
@ -1369,8 +1391,8 @@ bool Gis_multi_point::get_data_as_wkt(String *txt, const char **end) const
return 1;
n_points= uint4korr(m_data);
if (no_data(m_data+4,
n_points * (POINT_DATA_SIZE + WKB_HEADER_SIZE)) ||
if (n_points > max_n_points ||
no_data(m_data+4, n_points * (POINT_DATA_SIZE + WKB_HEADER_SIZE)) ||
txt->reserve(((MAX_DIGITS_IN_DOUBLE + 1) * 2 + 1) * n_points))
return 1;
*end= append_points(txt, n_points, m_data+4, WKB_HEADER_SIZE);
@ -1451,6 +1473,7 @@ const Geometry::Class_info *Gis_multi_point::get_class_info() const
uint32 Gis_multi_line_string::get_data_size() const
{
uint32 n_line_strings;
uint32 n_points;
const char *data= m_data;
if (no_data(data, 4))
@ -1460,11 +1483,13 @@ uint32 Gis_multi_line_string::get_data_size() const
while (n_line_strings--)
{
if (no_data(data, WKB_HEADER_SIZE + 4))
if (no_data(data, WKB_HEADER_SIZE + 4) ||
(n_points= uint4korr(data + WKB_HEADER_SIZE)) > max_n_points)
return GET_SIZE_ERROR;
data+= (WKB_HEADER_SIZE + 4 + uint4korr(data + WKB_HEADER_SIZE) *
POINT_DATA_SIZE);
data+= (WKB_HEADER_SIZE + 4 + n_points*POINT_DATA_SIZE);
}
if (no_data(data, 0))
return GET_SIZE_ERROR;
return (uint32) (data - m_data);
}
@ -1649,7 +1674,7 @@ int Gis_multi_line_string::geometry_n(uint32 num, String *result) const
return 1;
n_points= uint4korr(data + WKB_HEADER_SIZE);
length= WKB_HEADER_SIZE + 4+ POINT_DATA_SIZE * n_points;
if (no_data(data, length))
if (n_points > max_n_points || no_data(data, length))
return 1;
if (!--num)
break;
@ -1760,6 +1785,7 @@ const Geometry::Class_info *Gis_multi_line_string::get_class_info() const
uint32 Gis_multi_polygon::get_data_size() const
{
uint32 n_polygons;
uint32 n_points;
const char *data= m_data;
if (no_data(data, 4))
@ -1778,11 +1804,14 @@ uint32 Gis_multi_polygon::get_data_size() const
while (n_linear_rings--)
{
if (no_data(data, 4))
if (no_data(data, 4) ||
(n_points= uint4korr(data)) > max_n_points)
return GET_SIZE_ERROR;
data+= 4 + uint4korr(data) * POINT_DATA_SIZE;
data+= 4 + n_points * POINT_DATA_SIZE;
}
}
if (no_data(data, 0))
return GET_SIZE_ERROR;
return (uint32) (data - m_data);
}
@ -2325,7 +2354,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
n_objects= uint4korr(data);
data+= 4;
if (n_objects == 0)
return 1;
goto exit;
while (n_objects--)
{
@ -2342,6 +2371,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
if (geom->get_mbr(mbr, &data))
return 1;
}
exit:
*end= data;
return 0;
}
@ -2359,10 +2389,11 @@ int Gis_geometry_collection::area(double *ar, const char **end) const
return 1;
n_objects= uint4korr(data);
data+= 4;
if (n_objects == 0)
return 1;
result= 0.0;
if (n_objects == 0)
goto exit;
while (n_objects--)
{
uint32 wkb_type;
@ -2379,6 +2410,7 @@ int Gis_geometry_collection::area(double *ar, const char **end) const
return 1;
result+= *ar;
}
exit:
*end= data;
*ar= result;
return 0;
@ -2397,10 +2429,11 @@ int Gis_geometry_collection::geom_length(double *len, const char **end) const
return 1;
n_objects= uint4korr(data);
data+= 4;
if (n_objects == 0)
return 1;
result= 0.0;
if (n_objects == 0)
goto exit;
while (n_objects--)
{
uint32 wkb_type;
@ -2417,6 +2450,8 @@ int Gis_geometry_collection::geom_length(double *len, const char **end) const
return 1;
result+= *len;
}
exit:
*end= data;
*len= result;
return 0;

View file

@ -200,6 +200,9 @@ struct MBR
return (d == intersection.dimension());
}
int valid() const
{ return xmin <= xmax && ymin <= ymax; }
};
@ -212,7 +215,7 @@ class Geometry
public:
// Maximum number of points in feature that can fit into String
static const uint32 max_n_points=
(uint32) (UINT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) /
(uint32) (INT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) /
POINT_DATA_SIZE;
Geometry() {} /* Remove gcc warning */

View file

@ -14076,6 +14076,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
}
case Item::FIELD_ITEM:
case Item::DEFAULT_VALUE_ITEM:
case Item::INSERT_VALUE_ITEM:
{
Item_field *field= (Item_field*) item;
bool orig_modify= modify_item;

View file

@ -331,6 +331,19 @@ extern "C" int myisammrg_parent_open_callback(void *callback_param,
CPP_UNNAMED_NS_END
/*
Set external_ref for the child MyISAM tables. They need this to be set in
order to check for killed status.
*/
static void myrg_set_external_ref(MYRG_INFO *m_info, void *ext_ref_arg)
{
int i;
for (i= 0; i < (int)m_info->tables; i++)
{
m_info->open_tables[i].table->external_ref= ext_ref_arg;
}
}
/**
Open a MERGE parent table, but not its children.
@ -394,6 +407,7 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
}
file->children_attached= TRUE;
myrg_set_external_ref(file, (void*)table);
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
}