mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 03:21:53 +01:00
Merge stella.local:/home2/mydev/mysql-5.1-amain
into stella.local:/home2/mydev/mysql-5.1-axmrg
This commit is contained in:
commit
6d80b70182
33 changed files with 458 additions and 83 deletions
|
@ -419,7 +419,7 @@ connection master;
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
--echo
|
||||
--echo ** Delete from Master **
|
||||
|
|
|
@ -723,20 +723,6 @@ set @@sort_buffer_size=default;
|
|||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug #32815: query with ORDER BY and a possible ref_or_null access
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES
|
||||
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
# Test of behaviour with CREATE ... SELECT
|
||||
#
|
||||
|
||||
|
@ -1091,6 +1077,19 @@ desc t1;
|
|||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #32815: query with ORDER BY and a possible ref_or_null access
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES
|
||||
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
|
||||
|
@ -1383,4 +1382,32 @@ create table t1 (a int auto_increment primary key) engine=innodb;
|
|||
alter table t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #33697: ORDER BY primary key DESC vs. ref access + filesort
|
||||
# (reproduced only with InnoDB tables)
|
||||
#
|
||||
|
||||
CREATE TABLE t1
|
||||
(vid integer NOT NULL,
|
||||
tid integer NOT NULL,
|
||||
idx integer NOT NULL,
|
||||
name varchar(128) NOT NULL,
|
||||
type varchar(128) NULL,
|
||||
PRIMARY KEY(idx, vid, tid),
|
||||
UNIQUE(vid, tid, name)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL),
|
||||
(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL),
|
||||
(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL),
|
||||
(4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
|
||||
(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
||||
|
||||
SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
|
|
@ -108,6 +108,7 @@ execute stmt1 using @arg00, @arg01;
|
|||
select a,b from t1 where a=@arg00;
|
||||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
--error 1048
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
select a,b from t1 order by a;
|
||||
set @arg00=0;
|
||||
|
|
|
@ -231,8 +231,7 @@ a b
|
|||
204 7
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=6;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
update t1 set a=300 where b=7;
|
||||
SET SQL_MODE='';
|
||||
insert into t1(a,b)values(NULL,8);
|
||||
|
@ -247,7 +246,7 @@ a b
|
|||
1 1
|
||||
200 2
|
||||
201 4
|
||||
0 6
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
|
@ -263,6 +262,7 @@ a b
|
|||
1 1
|
||||
200 2
|
||||
201 4
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
|
@ -273,20 +273,20 @@ a b
|
|||
405 14
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=13;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
update t1 set a=500 where b=14;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
203 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
0 13
|
||||
404 13
|
||||
500 14
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
|
|
|
@ -1478,3 +1478,39 @@ NULL
|
|||
1
|
||||
2
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
c (SELECT a FROM t1 WHERE b = c)
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
c (SELECT a FROM t1 WHERE b = c)
|
||||
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
ERROR 42S22: Reference 'c' not supported (reference to group function)
|
||||
SET @old_sql_mode = @@sql_mode;
|
||||
SET @@sql_mode='ONLY_FULL_GROUP_BY';
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
c (SELECT a FROM t1 WHERE b = c)
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
ERROR 42000: non-grouping field 'b' is used in HAVING clause
|
||||
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
ERROR 42S22: Reference 'c' not supported (reference to group function)
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
c (SELECT a FROM t1 WHERE b = c)
|
||||
1 1
|
||||
INSERT INTO t1 VALUES (2, 1);
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
DROP TABLE t1;
|
||||
SET @@sql_mode = @old_sql_mode;
|
||||
|
|
|
@ -1349,7 +1349,7 @@ INSERT INTO t1 VALUES
|
|||
(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
|
||||
EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where; Using filesort
|
||||
1 SIMPLE t1 ALL idx NULL NULL NULL 4 Using where; Using filesort
|
||||
SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
|
||||
id type d
|
||||
191 member 1
|
||||
|
@ -1609,4 +1609,29 @@ alter table t1 order by a;
|
|||
Warnings:
|
||||
Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1'
|
||||
drop table t1;
|
||||
CREATE TABLE t1
|
||||
(vid integer NOT NULL,
|
||||
tid integer NOT NULL,
|
||||
idx integer NOT NULL,
|
||||
name varchar(128) NOT NULL,
|
||||
type varchar(128) NULL,
|
||||
PRIMARY KEY(idx, vid, tid),
|
||||
UNIQUE(vid, tid, name)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES
|
||||
(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL),
|
||||
(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL),
|
||||
(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL),
|
||||
(4,1,3,'pk',NULL),(5,1,3,'c2',NULL),
|
||||
(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL);
|
||||
EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index vid PRIMARY 12 NULL 16 Using where
|
||||
SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC;
|
||||
vid tid idx name type
|
||||
3 1 4 c_extra NULL
|
||||
3 1 3 c2 NULL
|
||||
3 1 2 c1 NULL
|
||||
3 1 1 pk NULL
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests
|
||||
|
|
|
@ -93,11 +93,9 @@ INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
|
|||
Warnings:
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
UPDATE t1 SET d=1/NULL;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
ERROR 23000: Column 'd' cannot be null
|
||||
UPDATE t1 SET d=NULL;
|
||||
Warnings:
|
||||
Warning 1048 Column 'd' cannot be null
|
||||
ERROR 23000: Column 'd' cannot be null
|
||||
INSERT INTO t1 (a) values (null);
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
INSERT INTO t1 (a) values (1/null);
|
||||
|
@ -132,7 +130,7 @@ Warning 1048 Column 'd' cannot be null
|
|||
Warning 1048 Column 'd' cannot be null
|
||||
select * from t1;
|
||||
a b c d
|
||||
0 0000-00-00 00:00:00 0
|
||||
0 0000-00-00 00:00:00 2003
|
||||
0 0000-00-00 00:00:00 0
|
||||
0 0000-00-00 00:00:00 0
|
||||
0 0000-00-00 00:00:00 0
|
||||
|
|
|
@ -1303,12 +1303,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
|
|
@ -1286,12 +1286,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
|
|
@ -1287,12 +1287,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
|
|
@ -1329,12 +1329,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
@ -4351,12 +4350,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
|
|
@ -4291,6 +4291,54 @@ select count(*) from t1 where f12 =
|
|||
count(*)
|
||||
3
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t4 (
|
||||
f7 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f10 varchar(32) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f7)
|
||||
);
|
||||
INSERT INTO t4 VALUES(1,1), (2,null);
|
||||
CREATE TABLE t2 (
|
||||
f4 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f2 varchar(50) collate utf8_bin default NULL,
|
||||
f3 varchar(10) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f4),
|
||||
UNIQUE KEY uk1 (f2)
|
||||
);
|
||||
INSERT INTO t2 VALUES(1,1,null), (2,2,null);
|
||||
CREATE TABLE t1 (
|
||||
f8 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f1 varchar(10) collate utf8_bin default NULL,
|
||||
f9 varchar(32) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f8)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,'P',1), (2,'P',1), (3,'R',2);
|
||||
CREATE TABLE t3 (
|
||||
f6 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f5 varchar(50) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f6)
|
||||
);
|
||||
INSERT INTO t3 VALUES (1,null), (2,null);
|
||||
SELECT
|
||||
IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
|
||||
IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,
|
||||
SUM(
|
||||
IF(
|
||||
(SELECT VPC.f2
|
||||
FROM t2 VPC, t4 a2, t2 a3
|
||||
WHERE
|
||||
VPC.f4 = a2.f10 AND a3.f2 = a4
|
||||
LIMIT 1) IS NULL,
|
||||
0,
|
||||
t3.f5
|
||||
)
|
||||
) AS a6
|
||||
FROM
|
||||
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
|
||||
GROUP BY a4;
|
||||
a4 f3 a6
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
End of 5.0 tests.
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
|
||||
|
|
|
@ -794,7 +794,7 @@ dps tinyint(3) unsigned default NULL
|
|||
INSERT INTO t1 VALUES (1.1325,3);
|
||||
SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
|
||||
ROUND(qty,3) dps ROUND(qty,dps)
|
||||
1.133 3 1.133
|
||||
1.133 3 1.133000
|
||||
DROP TABLE t1;
|
||||
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
|
||||
%
|
||||
|
@ -885,4 +885,65 @@ c
|
|||
1000
|
||||
1234567890
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
CREATE TABLE t1( a DECIMAL(4, 3), b INT );
|
||||
INSERT INTO t1 VALUES ( 1, 5 ), ( 2, 4 ), ( 3, 3 ), ( 4, 2 ), ( 5, 1 );
|
||||
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c;
|
||||
a b c
|
||||
1.000 5 1.000
|
||||
2.000 4 2.000
|
||||
3.000 3 3.000
|
||||
4.000 2 4.000
|
||||
5.000 1 5.000
|
||||
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c DESC;
|
||||
a b c
|
||||
5.000 1 5.000
|
||||
4.000 2 4.000
|
||||
3.000 3 3.000
|
||||
2.000 4 2.000
|
||||
1.000 5 1.000
|
||||
CREATE TABLE t2 ( a INT, b INT, c DECIMAL(5, 4) );
|
||||
INSERT INTO t2 VALUES ( 0, 1, 1.2345 ), ( 1, 2, 1.2345 ),
|
||||
( 3, 3, 1.2345 ), ( 2, 4, 1.2345 );
|
||||
SELECT a, b, MAX(ROUND(c, a))
|
||||
FROM t2
|
||||
GROUP BY a, b
|
||||
ORDER BY b;
|
||||
a b MAX(ROUND(c, a))
|
||||
0 1 1.0000
|
||||
1 2 1.2000
|
||||
3 3 1.2350
|
||||
2 4 1.2300
|
||||
SELECT a, b, ROUND(c, a)
|
||||
FROM t2;
|
||||
a b ROUND(c, a)
|
||||
0 1 1.0000
|
||||
1 2 1.2000
|
||||
3 3 1.2350
|
||||
2 4 1.2300
|
||||
CREATE TABLE t3( a INT, b DECIMAL(6, 3) );
|
||||
INSERT INTO t3 VALUES( 0, 1.5 );
|
||||
SELECT ROUND( b, a ) FROM t3;
|
||||
ROUND( b, a )
|
||||
2.000
|
||||
CREATE TABLE t4( a INT, b DECIMAL( 12, 0) );
|
||||
INSERT INTO t4 VALUES( -9, 1.5e9 );
|
||||
SELECT ROUND( b, a ) FROM t4;
|
||||
ROUND( b, a )
|
||||
2000000000
|
||||
CREATE TABLE t5( a INT, b DECIMAL( 13, 12 ) );
|
||||
INSERT INTO t5 VALUES( 0, 1.5 );
|
||||
INSERT INTO t5 VALUES( 9, 1.5e-9 );
|
||||
SELECT ROUND( b, a ) FROM t5;
|
||||
ROUND( b, a )
|
||||
2.000000000000
|
||||
0.000000002000
|
||||
CREATE TABLE t6( a INT );
|
||||
INSERT INTO t6 VALUES( 6 / 8 );
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT ROUND(20061108085411.000002);
|
||||
ROUND(20061108085411.000002)
|
||||
20061108085411
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6;
|
||||
End of 5.0 tests
|
||||
|
|
|
@ -3597,6 +3597,22 @@ DROP VIEW v1;
|
|||
DROP VIEW v2;
|
||||
DROP VIEW v3;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#29477: Not all fields of the target table were checked to have
|
||||
# a default value when inserting into a view.
|
||||
#
|
||||
create table t1(f1 int, f2 int not null);
|
||||
create view v1 as select f1 from t1;
|
||||
insert into v1 values(1);
|
||||
Warnings:
|
||||
Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value
|
||||
set @old_mode=@@sql_mode;
|
||||
set @@sql_mode=traditional;
|
||||
insert into v1 values(1);
|
||||
ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value
|
||||
set @@sql_mode=@old_mode;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
End of 5.0 tests.
|
||||
DROP DATABASE IF EXISTS `d-1`;
|
||||
CREATE DATABASE `d-1`;
|
||||
|
|
|
@ -98,8 +98,7 @@ Warning 1265 Data truncated for column 'c' at row 1
|
|||
Warning 1265 Data truncated for column 'c' at row 2
|
||||
alter table t1 add d char(2);
|
||||
update t1 set a=NULL where a=10;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
update t1 set c='mysql ab' where c='test';
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c' at row 4
|
||||
|
|
|
@ -1286,12 +1286,11 @@ a b
|
|||
set @arg00=NULL;
|
||||
set @arg01=2;
|
||||
execute stmt1 using @arg00, @arg01;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
ERROR 23000: Column 'a' cannot be null
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
0 two
|
||||
1 one
|
||||
2 two
|
||||
3 three
|
||||
4 four
|
||||
set @arg00=0;
|
||||
|
|
|
@ -454,9 +454,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
@ -1595,9 +1593,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
@ -2736,9 +2732,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
|
|
@ -454,9 +454,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
@ -1595,9 +1593,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
@ -2736,9 +2732,7 @@ f1 f2 f3 f4
|
|||
update t31 set f5=555555555555555 where f3=6;
|
||||
update t31 set f2=2 where f3=2;
|
||||
update t31 set f1=NULL where f3=1;
|
||||
update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
|
||||
Warnings:
|
||||
Warning 1048 Column 'f3' cannot be null
|
||||
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
|
||||
|
||||
** Delete from Master **
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ kill @id;
|
|||
drop table t2,t3;
|
||||
insert into t4 values (3),(4);
|
||||
connection master;
|
||||
--error 0,1053,2013
|
||||
--error 0,1053,2013,1048
|
||||
reap;
|
||||
connection master1;
|
||||
save_master_pos;
|
||||
|
|
|
@ -149,6 +149,7 @@ delete from t1 where a=0;
|
|||
update t1 set a=0 where b=5;
|
||||
select * from t1 order by b;
|
||||
delete from t1 where a=0;
|
||||
--error 1048
|
||||
update t1 set a=NULL where b=6;
|
||||
update t1 set a=300 where b=7;
|
||||
SET SQL_MODE='';
|
||||
|
@ -164,6 +165,7 @@ delete from t1 where a=0;
|
|||
update t1 set a=0 where b=12;
|
||||
select * from t1 order by b;
|
||||
delete from t1 where a=0;
|
||||
--error 1048
|
||||
update t1 set a=NULL where b=13;
|
||||
update t1 set a=500 where b=14;
|
||||
select * from t1 order by b;
|
||||
|
|
|
@ -789,8 +789,6 @@ select t1.f1,t.* from t1, t1 t group by 1;
|
|||
drop table t1;
|
||||
SET SQL_MODE = '';
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
# Bug #32202: ORDER BY not working with GROUP BY
|
||||
#
|
||||
|
@ -824,6 +822,7 @@ SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC;
|
|||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
# Bug #21174: Index degrades sort performance and
|
||||
# optimizer does not honor IGNORE INDEX.
|
||||
|
@ -946,3 +945,51 @@ EXPLAIN SELECT b from t2 GROUP BY b;
|
|||
SELECT b from t2 GROUP BY b;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING
|
||||
#
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
|
||||
--error ER_ILLEGAL_REFERENCE
|
||||
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
|
||||
SET @old_sql_mode = @@sql_mode;
|
||||
SET @@sql_mode='ONLY_FULL_GROUP_BY';
|
||||
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
|
||||
--error ER_NON_GROUPING_FIELD_USED
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
|
||||
--error ER_ILLEGAL_REFERENCE
|
||||
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1
|
||||
HAVING b = 10;
|
||||
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
|
||||
INSERT INTO t1 VALUES (2, 1);
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT b c, (SELECT a FROM t1 WHERE b = c)
|
||||
FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
SET @@sql_mode = @old_sql_mode;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ drop table t1;
|
|||
#
|
||||
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
|
||||
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
|
||||
--error 1048
|
||||
UPDATE t1 SET d=1/NULL;
|
||||
--error 1048
|
||||
UPDATE t1 SET d=NULL;
|
||||
--error 1048
|
||||
INSERT INTO t1 (a) values (null);
|
||||
|
|
|
@ -3159,6 +3159,60 @@ select count(*) from t1 where f12 =
|
|||
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# BUG#33794 "MySQL crashes executing specific query on specific dump"
|
||||
#
|
||||
CREATE TABLE t4 (
|
||||
f7 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f10 varchar(32) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f7)
|
||||
);
|
||||
INSERT INTO t4 VALUES(1,1), (2,null);
|
||||
|
||||
CREATE TABLE t2 (
|
||||
f4 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f2 varchar(50) collate utf8_bin default NULL,
|
||||
f3 varchar(10) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f4),
|
||||
UNIQUE KEY uk1 (f2)
|
||||
);
|
||||
INSERT INTO t2 VALUES(1,1,null), (2,2,null);
|
||||
|
||||
CREATE TABLE t1 (
|
||||
f8 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f1 varchar(10) collate utf8_bin default NULL,
|
||||
f9 varchar(32) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f8)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,'P',1), (2,'P',1), (3,'R',2);
|
||||
|
||||
CREATE TABLE t3 (
|
||||
f6 varchar(32) collate utf8_bin NOT NULL default '',
|
||||
f5 varchar(50) collate utf8_bin default NULL,
|
||||
PRIMARY KEY (f6)
|
||||
);
|
||||
INSERT INTO t3 VALUES (1,null), (2,null);
|
||||
|
||||
SELECT
|
||||
IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
|
||||
IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,
|
||||
SUM(
|
||||
IF(
|
||||
(SELECT VPC.f2
|
||||
FROM t2 VPC, t4 a2, t2 a3
|
||||
WHERE
|
||||
VPC.f4 = a2.f10 AND a3.f2 = a4
|
||||
LIMIT 1) IS NULL,
|
||||
0,
|
||||
t3.f5
|
||||
)
|
||||
) AS a6
|
||||
FROM
|
||||
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
|
||||
GROUP BY a4;
|
||||
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
||||
#
|
||||
|
@ -3194,3 +3248,4 @@ CREATE TABLE t1 (s1 char(1));
|
|||
INSERT INTO t1 VALUES ('a');
|
||||
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
|
||||
DROP TABLE t1;
|
||||
|
||||
|
|
|
@ -478,4 +478,47 @@ select round(a,b) as c from t1 order by c;
|
|||
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
|
||||
#
|
||||
# Bug #33143: Incorrect ORDER BY for ROUND()/TRUNCATE() result
|
||||
#
|
||||
|
||||
CREATE TABLE t1( a DECIMAL(4, 3), b INT );
|
||||
INSERT INTO t1 VALUES ( 1, 5 ), ( 2, 4 ), ( 3, 3 ), ( 4, 2 ), ( 5, 1 );
|
||||
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c;
|
||||
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c DESC;
|
||||
|
||||
CREATE TABLE t2 ( a INT, b INT, c DECIMAL(5, 4) );
|
||||
|
||||
INSERT INTO t2 VALUES ( 0, 1, 1.2345 ), ( 1, 2, 1.2345 ),
|
||||
( 3, 3, 1.2345 ), ( 2, 4, 1.2345 );
|
||||
|
||||
SELECT a, b, MAX(ROUND(c, a))
|
||||
FROM t2
|
||||
GROUP BY a, b
|
||||
ORDER BY b;
|
||||
|
||||
SELECT a, b, ROUND(c, a)
|
||||
FROM t2;
|
||||
|
||||
CREATE TABLE t3( a INT, b DECIMAL(6, 3) );
|
||||
INSERT INTO t3 VALUES( 0, 1.5 );
|
||||
SELECT ROUND( b, a ) FROM t3;
|
||||
|
||||
CREATE TABLE t4( a INT, b DECIMAL( 12, 0) );
|
||||
INSERT INTO t4 VALUES( -9, 1.5e9 );
|
||||
SELECT ROUND( b, a ) FROM t4;
|
||||
|
||||
CREATE TABLE t5( a INT, b DECIMAL( 13, 12 ) );
|
||||
INSERT INTO t5 VALUES( 0, 1.5 );
|
||||
INSERT INTO t5 VALUES( 9, 1.5e-9 );
|
||||
SELECT ROUND( b, a ) FROM t5;
|
||||
|
||||
CREATE TABLE t6( a INT );
|
||||
INSERT INTO t6 VALUES( 6 / 8 );
|
||||
SELECT * FROM t6;
|
||||
|
||||
SELECT ROUND(20061108085411.000002);
|
||||
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
|
|
@ -3453,6 +3453,20 @@ DROP VIEW v2;
|
|||
DROP VIEW v3;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#29477: Not all fields of the target table were checked to have
|
||||
--echo # a default value when inserting into a view.
|
||||
--echo #
|
||||
create table t1(f1 int, f2 int not null);
|
||||
create view v1 as select f1 from t1;
|
||||
insert into v1 values(1);
|
||||
set @old_mode=@@sql_mode;
|
||||
set @@sql_mode=traditional;
|
||||
--error ER_NO_DEFAULT_FOR_VIEW_FIELD
|
||||
insert into v1 values(1);
|
||||
set @@sql_mode=@old_mode;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
|
|||
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
|
||||
alter table t1 modify c char(4);
|
||||
alter table t1 add d char(2);
|
||||
--error 1048
|
||||
update t1 set a=NULL where a=10;
|
||||
update t1 set c='mysql ab' where c='test';
|
||||
update t1 set d=c;
|
||||
|
|
|
@ -3408,7 +3408,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
|
|||
resolve_ref_in_select_and_group()
|
||||
thd current thread
|
||||
ref column reference being resolved
|
||||
select the sub-select that ref is resolved against
|
||||
select the select that ref is resolved against
|
||||
|
||||
DESCRIPTION
|
||||
Resolve a column reference (usually inside a HAVING clause) against the
|
||||
|
@ -3479,6 +3479,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
|
|||
}
|
||||
|
||||
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
|
||||
select->having_fix_field &&
|
||||
select_ref != not_found_item && !group_by_ref)
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -2006,7 +2006,7 @@ void Item_func_round::fix_length_and_dec()
|
|||
int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
|
||||
|
||||
precision-= decimals_delta - length_increase;
|
||||
decimals= decimals_to_set;
|
||||
decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
|
||||
max_length= my_decimal_precision_to_length(precision, decimals,
|
||||
unsigned_flag);
|
||||
break;
|
||||
|
@ -2105,18 +2105,18 @@ my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
|
|||
{
|
||||
my_decimal val, *value= args[0]->val_decimal(&val);
|
||||
longlong dec= args[1]->val_int();
|
||||
if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
|
||||
{
|
||||
if (dec >= 0 || args[1]->unsigned_flag)
|
||||
dec= min((ulonglong) dec, decimals);
|
||||
decimals= (uint8) dec; // to get correct output
|
||||
}
|
||||
else if (dec < INT_MIN)
|
||||
dec= INT_MIN;
|
||||
|
||||
if (!(null_value= (args[0]->null_value || args[1]->null_value ||
|
||||
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
|
||||
truncate, decimal_value) > 1)))
|
||||
truncate, decimal_value) > 1)))
|
||||
{
|
||||
decimal_value->frac= decimals;
|
||||
return decimal_value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -619,7 +619,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
|||
if (mysql_prepare_insert(thd, table_list, table, fields, values,
|
||||
update_fields, update_values, duplic, &unused_conds,
|
||||
FALSE,
|
||||
(fields.elements || !value_count),
|
||||
(fields.elements || !value_count ||
|
||||
table_list->view != 0),
|
||||
!ignore && (thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES))))
|
||||
|
|
|
@ -5552,7 +5552,8 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
|
|||
(keyuse->val->type() == Item::REF_ITEM &&
|
||||
((Item_ref*)keyuse->val)->ref_type() == Item_ref::OUTER_REF &&
|
||||
(*(Item_ref**)((Item_ref*)keyuse->val)->ref)->ref_type() ==
|
||||
Item_ref::DIRECT_REF) )
|
||||
Item_ref::DIRECT_REF &&
|
||||
keyuse->val->real_item()->type() == Item::FIELD_ITEM))
|
||||
return new store_key_field(thd,
|
||||
key_part->field,
|
||||
key_buff + maybe_null,
|
||||
|
@ -13122,7 +13123,8 @@ check_reverse_order:
|
|||
select->quick=tmp;
|
||||
}
|
||||
}
|
||||
else if (tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
|
||||
else if (tab->type != JT_NEXT &&
|
||||
tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
|
||||
{
|
||||
/*
|
||||
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
|
||||
|
|
|
@ -526,7 +526,9 @@ int mysql_update(THD *thd,
|
|||
init_read_record(&info,thd,table,select,0,1);
|
||||
|
||||
updated= found= 0;
|
||||
thd->count_cuted_fields= CHECK_FIELD_WARN; /* calc cuted fields */
|
||||
/* Generate an error when trying to set a NOT NULL field to NULL. */
|
||||
thd->count_cuted_fields= ignore ? CHECK_FIELD_WARN
|
||||
: CHECK_FIELD_ERROR_FOR_NULL;
|
||||
thd->cuted_fields=0L;
|
||||
thd->proc_info="Updating";
|
||||
|
||||
|
|
|
@ -1601,9 +1601,21 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
|
|||
x+=10;
|
||||
*buf1=powers10[pos]*(x-y);
|
||||
}
|
||||
if (frac0 < 0)
|
||||
/*
|
||||
In case we're rounding e.g. 1.5e9 to 2.0e9, the decimal_digit_t's inside
|
||||
the buffer are as follows.
|
||||
|
||||
Before <1, 5e8>
|
||||
After <2, 5e8>
|
||||
|
||||
Hence we need to set the 2nd field to 0.
|
||||
The same holds if we round 1.5e-9 to 2e-9.
|
||||
*/
|
||||
if (frac0 < frac1)
|
||||
{
|
||||
dec1 *end=to->buf+intg0, *buf=buf1+1;
|
||||
dec1 *buf= to->buf + ((scale == 0 && intg0 == 0) ? 1 : intg0 + frac0);
|
||||
dec1 *end= to->buf + len;
|
||||
|
||||
while (buf < end)
|
||||
*buf++=0;
|
||||
}
|
||||
|
|
|
@ -15674,7 +15674,7 @@ static void test_mysql_insert_id()
|
|||
myquery(rc);
|
||||
res= mysql_insert_id(mysql);
|
||||
DIE_UNLESS(res == 0);
|
||||
rc= mysql_query(mysql, "update t2 set f1=NULL where f1=14");
|
||||
rc= mysql_query(mysql, "update t2 set f1=0 where f1=14");
|
||||
myquery(rc);
|
||||
res= mysql_insert_id(mysql);
|
||||
DIE_UNLESS(res == 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue