summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ibabaev@bk-internal.mysql.com>2007-05-28 06:25:03 +0200
committerunknown <ibabaev@bk-internal.mysql.com>2007-05-28 06:25:03 +0200
commitecebc55042fc76a4eeb54c326a4673792da07627 (patch)
treededeeb2e328311c46256740fa901059742ffb8f4
parentc9d7c8f9fb8c32a07fb7ddaf18069d46c3f8b3dd (diff)
parent343a1677dedaa262610e02d4f704b0db5d10d0bf (diff)
downloadmariadb-git-ecebc55042fc76a4eeb54c326a4673792da07627.tar.gz
Merge bk-internal.mysql.com:/data0/bk/mysql-5.1
into bk-internal.mysql.com:/data0/bk/mysql-5.1-opt BitKeeper/deleted/.del-ps_6bdb.result: Auto merged client/mysqldump.c: Auto merged mysql-test/r/mysqldump.result: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/ps_7ndb.result: Auto merged sql/field.h: Auto merged sql/item_func.cc: Auto merged sql/my_decimal.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_table.cc: Auto merged
-rw-r--r--client/mysqldump.c7
-rw-r--r--mysql-test/r/alter_table.result19
-rw-r--r--mysql-test/r/func_gconcat.result47
-rw-r--r--mysql-test/r/join_outer.result15
-rw-r--r--mysql-test/r/kill.result82
-rw-r--r--mysql-test/r/myisam.result26
-rw-r--r--mysql-test/r/mysqldump.result11
-rw-r--r--mysql-test/r/ps_2myisam.result32
-rw-r--r--mysql-test/r/ps_3innodb.result32
-rw-r--r--mysql-test/r/ps_4heap.result32
-rw-r--r--mysql-test/r/ps_5merge.result64
-rw-r--r--mysql-test/r/ps_7ndb.result32
-rw-r--r--mysql-test/r/subselect3.result18
-rw-r--r--mysql-test/r/type_newdecimal.result6
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/t/alter_table.test24
-rw-r--r--mysql-test/t/func_gconcat.test30
-rw-r--r--mysql-test/t/join_outer.test16
-rw-r--r--mysql-test/t/kill.test132
-rw-r--r--mysql-test/t/myisam.test18
-rw-r--r--mysql-test/t/mysqldump.test7
-rw-r--r--mysql-test/t/subselect3.test18
-rw-r--r--mysql-test/t/type_newdecimal.test13
-rw-r--r--mysql-test/t/view.test19
-rw-r--r--sql/field.h5
-rw-r--r--sql/field_conv.cc14
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/item_subselect.cc81
-rw-r--r--sql/item_sum.cc14
-rw-r--r--sql/my_decimal.h10
-rw-r--r--sql/sp_head.cc3
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_select.cc38
-rw-r--r--sql/sql_table.cc73
-rw-r--r--strings/decimal.c3
35 files changed, 832 insertions, 123 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 149e07ded90..4b08c4166e5 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -2693,15 +2693,18 @@ static void dump_table(char *table, char *db)
plus 2 bytes for '0x' prefix.
- In non-HEX mode we need up to 2 bytes per character,
plus 2 bytes for leading and trailing '\'' characters.
+ Also we need to reserve 1 byte for terminating '\0'.
*/
- dynstr_realloc_checked(&extended_row,length * 2+2);
+ dynstr_realloc_checked(&extended_row,length * 2 + 2 + 1);
if (opt_hex_blob && is_blob)
{
dynstr_append_checked(&extended_row, "0x");
extended_row.length+= mysql_hex_string(extended_row.str +
extended_row.length,
row[i], length);
- extended_row.str[extended_row.length]= '\0';
+ DBUG_ASSERT(extended_row.length+1 <= extended_row.max_length);
+ /* mysql_hex_string() already terminated string by '\0' */
+ DBUG_ASSERT(extended_row.str[extended_row.length] == '\0');
}
else
{
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 4481b56791f..3fa12f2997a 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -846,6 +846,25 @@ id
50
51
drop table t1;
+set @orig_sql_mode = @@sql_mode;
+set sql_mode="no_zero_date";
+create table t1(f1 int);
+alter table t1 add column f2 datetime not null, add column f21 date not null;
+insert into t1 values(1,'2000-01-01','2000-01-01');
+alter table t1 add column f3 datetime not null;
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'f3' at row 1
+alter table t1 add column f3 date not null;
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'f3' at row 1
+alter table t1 add column f4 datetime not null default '2002-02-02',
+add column f41 date not null;
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'f41' at row 1
+alter table t1 add column f4 datetime not null default '2002-02-02',
+add column f41 date not null default '2002-02-02';
+select * from t1;
+f1 f2 f21 f4 f41
+1 2000-01-01 00:00:00 2000-01-01 2002-02-02 00:00:00 2002-02-02
+drop table t1;
+set sql_mode= @orig_sql_mode;
create table t1 (v varchar(32));
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index bb09217d9d7..3fd204c84c9 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -769,4 +769,51 @@ Warnings:
Warning 1260 1 line(s) were cut by GROUP_CONCAT()
SET group_concat_max_len = DEFAULT;
DROP TABLE t1;
+SET group_concat_max_len= 65535;
+CREATE TABLE t1( a TEXT, b INTEGER );
+INSERT INTO t1 VALUES ( 'a', 0 ), ( 'b', 1 );
+SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1;
+GROUP_CONCAT( a ORDER BY b )
+a,b
+SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
+GROUP_CONCAT(DISTINCT a ORDER BY b)
+a,b
+SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
+GROUP_CONCAT(DISTINCT a)
+a,b
+SET group_concat_max_len= 10;
+SELECT GROUP_CONCAT(a ORDER BY b) FROM t1;
+GROUP_CONCAT(a ORDER BY b)
+a,b
+SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
+GROUP_CONCAT(DISTINCT a ORDER BY b)
+a,b
+SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
+GROUP_CONCAT(DISTINCT a)
+a,b
+SET group_concat_max_len= 65535;
+CREATE TABLE t2( a TEXT );
+INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
+INSERT INTO t2 VALUES( REPEAT( 'b', 5000 ) );
+INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
+SELECT LENGTH( GROUP_CONCAT( DISTINCT a ) ) FROM t2;
+LENGTH( GROUP_CONCAT( DISTINCT a ) )
+10001
+CREATE TABLE t3( a TEXT, b INT );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65534 ), 1 );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65535 ), 2 );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65536 ), 3 );
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 1;
+LENGTH( GROUP_CONCAT( a ) )
+65534
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 2;
+LENGTH( GROUP_CONCAT( a ) )
+65535
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 3;
+LENGTH( GROUP_CONCAT( a ) )
+65535
+SET group_concat_max_len= DEFAULT;
+DROP TABLE t1, t2, t3;
End of 5.0 tests
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 62dfb36bb52..1e4fc91b8bd 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -1239,3 +1239,18 @@ Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 6
DROP TABLE t1,t2;
+CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL);
+INSERT INTO t1 VALUES (1,0), (2,1);
+CREATE TABLE t2 (d int PRIMARY KEY);
+INSERT INTO t2 VALUES (1), (2), (3);
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 3 Using where; Using index; Not exists
+SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL;
+c e d
+1 0 NULL
+SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL;
+c e d
+1 0 NULL
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result
index d198c943496..85b6bc65bcb 100644
--- a/mysql-test/r/kill.result
+++ b/mysql-test/r/kill.result
@@ -41,3 +41,85 @@ select 1;
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
+create table t1(f1 int);
+create function bug27563() returns int(11)
+deterministic
+begin
+declare continue handler for sqlstate '70100' set @a:= 'killed';
+declare continue handler for sqlexception set @a:= 'exception';
+set @a= get_lock("lock27563", 10);
+return 1;
+end|
+select get_lock("lock27563",10);
+get_lock("lock27563",10)
+1
+insert into t1 values (bug27563());
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+select * from t1;
+f1
+insert into t1 values(0);
+update t1 set f1= bug27563();
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+select * from t1;
+f1
+0
+insert into t1 values(1);
+delete from t1 where bug27563() is null;
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+select * from t1;
+f1
+0
+1
+select * from t1 where f1= bug27563();
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+create procedure proc27563()
+begin
+declare continue handler for sqlstate '70100' set @a:= 'killed';
+declare continue handler for sqlexception set @a:= 'exception';
+select get_lock("lock27563",10);
+select "shouldn't be selected";
+end|
+call proc27563();
+get_lock("lock27563",10)
+NULL
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+create table t2 (f2 int);
+create trigger trg27563 before insert on t1 for each row
+begin
+declare continue handler for sqlstate '70100' set @a:= 'killed';
+declare continue handler for sqlexception set @a:= 'exception';
+set @a:= get_lock("lock27563",10);
+insert into t2 values(1);
+end|
+insert into t1 values(2),(3);
+ERROR 70100: Query execution was interrupted
+select @a;
+@a
+NULL
+select * from t1;
+f1
+0
+1
+select * from t2;
+f2
+select release_lock("lock27563");
+release_lock("lock27563")
+1
+drop table t1, t2;
+drop function bug27563;
+drop procedure proc27563;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index e9d798d998d..06ed1430059 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -1768,6 +1768,32 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1
drop table t1, t2, t3;
+CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
+INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+ALTER TABLE t1 DISABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
+a
+1
+SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
+b
+1
+SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
+b
+1
+SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
+a
+1
+ALTER TABLE t1 ENABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+DROP TABLE t1;
End of 5.0 tests
create table t1 (a int not null, key `a` (a) key_block_size=1024);
show create table t1;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 657f364f53b..b6a0e506eda 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -3309,6 +3309,17 @@ drop user user1;
drop user user2;
drop database mysqldump_test_db;
#
+# Bug #28522: buffer overrun by '\0' byte using --hex-blob.
+#
+CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
+INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
+CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` longblob
+);
+INSERT INTO `t1` VALUES (11,0x7171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171);
+DROP TABLE t1;
+#
# End of 5.0 tests
#
drop table if exists t1;
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 2ce35dae092..544528e3c60 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -1927,8 +1927,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1974,8 +1974,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2024,8 +2024,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2064,8 +2064,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2112,8 +2112,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2156,8 +2156,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2202,8 +2202,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2240,8 +2240,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 70181ecccdc..472a0c6000e 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -1910,8 +1910,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1957,8 +1957,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2007,8 +2007,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2047,8 +2047,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2095,8 +2095,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2139,8 +2139,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2185,8 +2185,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2223,8 +2223,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 19be5a2707e..e5e64eb8f86 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1911,8 +1911,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1958,8 +1958,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2008,8 +2008,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2048,8 +2048,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2096,8 +2096,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2140,8 +2140,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2186,8 +2186,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2224,8 +2224,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index ebdc5c8c9fd..daf6986552b 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -1847,8 +1847,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1894,8 +1894,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1944,8 +1944,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1984,8 +1984,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2032,8 +2032,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2076,8 +2076,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2122,8 +2122,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2160,8 +2160,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -4868,8 +4868,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -4915,8 +4915,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -4965,8 +4965,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -5005,8 +5005,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -5053,8 +5053,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -5097,8 +5097,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -5143,8 +5143,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -5181,8 +5181,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index 2cffb698fc0..b39dcf82142 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -1910,8 +1910,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -1957,8 +1957,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2007,8 +2007,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2047,8 +2047,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2095,8 +2095,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2139,8 +2139,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2185,8 +2185,8 @@ def @arg07 253 23 1 Y 128 31 63
def @arg08 253 23 1 Y 128 31 63
def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
-def @arg11 253 67 6 Y 128 30 63
-def @arg12 253 67 6 Y 128 30 63
+def @arg11 253 83 6 Y 128 30 63
+def @arg12 253 83 6 Y 128 30 63
def @arg13 253 16777216 10 Y 128 31 63
def @arg14 253 16777216 19 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
@@ -2223,8 +2223,8 @@ def @arg07 253 23 0 Y 128 31 63
def @arg08 253 23 0 Y 128 31 63
def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
-def @arg11 253 67 0 Y 128 30 63
-def @arg12 253 67 0 Y 128 30 63
+def @arg11 253 83 0 Y 128 30 63
+def @arg12 253 83 0 Y 128 30 63
def @arg13 253 16777216 0 Y 128 31 63
def @arg14 253 16777216 0 Y 128 31 63
def @arg15 253 16777216 19 Y 128 31 63
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index eca6cd3315c..79ce5bbb3a7 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -742,3 +742,21 @@ x
0
0
DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (a INT NOT NULL);
+INSERT INTO t1 VALUES (1),(-1), (65),(66);
+CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY);
+INSERT INTO t2 VALUES (65),(66);
+SELECT a FROM t1 WHERE a NOT IN (65,66);
+a
+1
+-1
+SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
+a
+1
+-1
+EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
+DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 855c452cb21..fc6955f11d2 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1475,6 +1475,12 @@ Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
+create table t1 (s varchar(100));
+insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
+drop table t1;
+SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
+a b
+0.9999999999999800000000000000 0.9999999999999800000000000000
End of 5.0 tests
select cast(143.481 as decimal(4,1));
cast(143.481 as decimal(4,1))
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index d1098020b25..db488aa4876 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3139,6 +3139,16 @@ code COUNT(DISTINCT country)
100 2
DROP VIEW v1;
DROP TABLE t1;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int DEFAULT 0);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+CREATE VIEW v1 AS
+SELECT t2.c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+UPDATE v1 SET c=1;
+DROP VIEW v1;
+DROP TABLE t1,t2;
DROP VIEW IF EXISTS v1;
SELECT * FROM (SELECT 1) AS t;
1
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 965528642bf..70fd1dfa898 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -631,6 +631,30 @@ insert into t1 values (null);
select * from t1;
drop table t1;
+
+#
+# Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the
+# NO_ZERO_DATE mode.
+#
+set @orig_sql_mode = @@sql_mode;
+set sql_mode="no_zero_date";
+create table t1(f1 int);
+alter table t1 add column f2 datetime not null, add column f21 date not null;
+insert into t1 values(1,'2000-01-01','2000-01-01');
+--error 1292
+alter table t1 add column f3 datetime not null;
+--error 1292
+alter table t1 add column f3 date not null;
+--error 1292
+alter table t1 add column f4 datetime not null default '2002-02-02',
+ add column f41 date not null;
+alter table t1 add column f4 datetime not null default '2002-02-02',
+ add column f41 date not null default '2002-02-02';
+select * from t1;
+drop table t1;
+set sql_mode= @orig_sql_mode;
+
+#
# Some additional tests for new, faster alter table. Note that most of the
# whole alter table code is being tested all around the test suite already.
#
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 4e965d7e8c9..b24015ebb99 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -520,5 +520,35 @@ SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1;
SELECT GROUP_CONCAT( DISTINCT a ORDER BY b ) FROM t1;
SET group_concat_max_len = DEFAULT;
DROP TABLE t1;
+# Bug #23856:GROUP_CONCAT and ORDER BY: junk from previous rows for query on I_S
+#
+SET group_concat_max_len= 65535;
+CREATE TABLE t1( a TEXT, b INTEGER );
+INSERT INTO t1 VALUES ( 'a', 0 ), ( 'b', 1 );
+SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1;
+SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
+SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
+SET group_concat_max_len= 10;
+SELECT GROUP_CONCAT(a ORDER BY b) FROM t1;
+SELECT GROUP_CONCAT(DISTINCT a ORDER BY b) FROM t1;
+SELECT GROUP_CONCAT(DISTINCT a) FROM t1;
+
+SET group_concat_max_len= 65535;
+CREATE TABLE t2( a TEXT );
+INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
+INSERT INTO t2 VALUES( REPEAT( 'b', 5000 ) );
+INSERT INTO t2 VALUES( REPEAT( 'a', 5000 ) );
+SELECT LENGTH( GROUP_CONCAT( DISTINCT a ) ) FROM t2;
+
+CREATE TABLE t3( a TEXT, b INT );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65534 ), 1 );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65535 ), 2 );
+INSERT INTO t3 VALUES( REPEAT( 'a', 65536 ), 3 );
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 1;
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 2;
+SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 3;
+
+SET group_concat_max_len= DEFAULT;
+DROP TABLE t1, t2, t3;
--echo End of 5.0 tests
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index 0a29b4cb325..708a618f10f 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -851,3 +851,19 @@ SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
show status like 'Handler_read%';
DROP TABLE t1,t2;
+
+#
+# Bug 28571: outer join with false on condition over constant tables
+#
+
+CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL);
+INSERT INTO t1 VALUES (1,0), (2,1);
+CREATE TABLE t2 (d int PRIMARY KEY);
+INSERT INTO t2 VALUES (1), (2), (3);
+
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL;
+SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL;
+SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL;
+
+DROP TABLE t1,t2;
+
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index cf0895f63c4..f3ec9dd3430 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -117,3 +117,135 @@ reap;
select 1;
connection con1;
select RELEASE_LOCK("a");
+
+#
+# Bug#27563: Stored functions and triggers wasn't throwing an error when killed.
+#
+create table t1(f1 int);
+delimiter |;
+create function bug27563() returns int(11)
+deterministic
+begin
+ declare continue handler for sqlstate '70100' set @a:= 'killed';
+ declare continue handler for sqlexception set @a:= 'exception';
+ set @a= get_lock("lock27563", 10);
+ return 1;
+end|
+delimiter ;|
+# Test stored functions
+# Test INSERT
+connection con1;
+select get_lock("lock27563",10);
+connection con2;
+let $ID= `select connection_id()`;
+send insert into t1 values (bug27563());
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+connection con1;
+select * from t1;
+
+# Test UPDATE
+insert into t1 values(0);
+connection con2;
+send update t1 set f1= bug27563();
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+connection con1;
+select * from t1;
+
+# Test DELETE
+insert into t1 values(1);
+connection con2;
+send delete from t1 where bug27563() is null;
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+connection con1;
+select * from t1;
+
+# Test SELECT
+connection con2;
+send select * from t1 where f1= bug27563();
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+
+# Test PROCEDURE
+connection con2;
+delimiter |;
+create procedure proc27563()
+begin
+ declare continue handler for sqlstate '70100' set @a:= 'killed';
+ declare continue handler for sqlexception set @a:= 'exception';
+ select get_lock("lock27563",10);
+ select "shouldn't be selected";
+end|
+delimiter ;|
+send call proc27563();
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+
+# Test TRIGGERS
+connection con2;
+create table t2 (f2 int);
+delimiter |;
+create trigger trg27563 before insert on t1 for each row
+begin
+ declare continue handler for sqlstate '70100' set @a:= 'killed';
+ declare continue handler for sqlexception set @a:= 'exception';
+ set @a:= get_lock("lock27563",10);
+ insert into t2 values(1);
+end|
+delimiter ;|
+send insert into t1 values(2),(3);
+real_sleep 2;
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+--error 1317
+reap;
+select @a;
+connection con1;
+select * from t1;
+select * from t2;
+
+# Cleanup
+select release_lock("lock27563");
+drop table t1, t2;
+drop function bug27563;
+drop procedure proc27563;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 8f7357d1c98..e66534f0cb9 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1129,8 +1129,26 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
drop table t1, t2, t3;
+
+#
+# Bug#28476: force index on a disabled myisam index gives error 124
+#
+CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
+INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
+SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
+SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
+SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
+ALTER TABLE t1 ENABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
+
#
# Test of key_block_size
#
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index a6f93e759dc..487e16bbe46 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1528,7 +1528,14 @@ drop user user2;
drop database mysqldump_test_db;
+--echo #
+--echo # Bug #28522: buffer overrun by '\0' byte using --hex-blob.
+--echo #
+CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
+INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
+--exec $MYSQL_DUMP --skip-create --compact --hex-blob test t1
+DROP TABLE t1;
--echo #
--echo # End of 5.0 tests
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index 65556012588..0302e2cede6 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -571,3 +571,21 @@ SELECT (t1.id IN (SELECT t2.id FROM t2,t3
FROM t1;
DROP TABLE t1,t2,t3;
+
+#
+# Bug #22855: Optimizer doesn't rewrite NOT IN subselects to a correlated
+# subquery
+#
+CREATE TABLE t1 (a INT NOT NULL);
+INSERT INTO t1 VALUES (1),(-1), (65),(66);
+
+CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY);
+INSERT INTO t2 VALUES (65),(66);
+
+SELECT a FROM t1 WHERE a NOT IN (65,66);
+SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
+EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 0a52bdaa8e6..e052ecfa82b 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1159,6 +1159,19 @@ select cast(a as DECIMAL(3,2)), count(*)
UNION select 12.1234
) t group by 1;
+#
+# Bug #28361 Buffer overflow in DECIMAL code on Windows
+#
+
+create table t1 (s varchar(100));
+insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
+drop table t1;
+
+#
+# Bug #27984 Long Decimal Maths produces truncated results
+#
+
+SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 51c862f692d..0eebdcf2a22 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3055,6 +3055,25 @@ DROP VIEW v1;
DROP TABLE t1;
#
+#
+# Bug #28561: update on multi-table view with CHECK OPTION and
+# a subquery in WHERE condition
+#
+
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int DEFAULT 0);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+
+CREATE VIEW v1 AS
+ SELECT t2.c FROM t1, t2
+ WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+
+UPDATE v1 SET c=1;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
# BUG#25897: Some queries are no longer possible after a CREATE VIEW
# fails
#
diff --git a/sql/field.h b/sql/field.h
index 2c2640a8262..52b83192ffa 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1171,6 +1171,11 @@ public:
class Field_varstring :public Field_longstr {
public:
+ /*
+ The maximum space available in a Field_varstring, in bytes. See
+ length_bytes.
+ */
+ static const uint MAX_SIZE= UINT_MAX16;
/* Store number of bytes used to store length (1 or 2) */
uint32 length_bytes;
Field_varstring(char *ptr_arg,
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 9771cbc12b1..e042c0ad76d 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -529,7 +529,21 @@ void Copy_field::set(char *to,Field *from)
}
+/*
+ To do:
+
+ If 'save\ is set to true and the 'from' is a blob field, do_copy is set to
+ do_save_blob rather than do_conv_blob. The only differences between them
+ appears to be:
+ - do_save_blob allocates and uses an intermediate buffer before calling
+ Field_blob::store. Is this in order to trigger the call to
+ well_formed_copy_nchars, by changing the pointer copy->tmp.ptr()?
+ That call will take place anyway in all known cases.
+
+ - The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
+ effect? Truncation is handled by well_formed_copy_nchars anyway.
+ */
void Copy_field::set(Field *to,Field *from,bool save)
{
if (to->type() == MYSQL_TYPE_NULL)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 271b4d784e7..906a87730be 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5318,6 +5318,8 @@ Item_func_sp::execute()
{
null_value= 1;
context->process_error(thd);
+ if (thd->killed)
+ thd->send_kill_message();
return TRUE;
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index ab4b4eb6796..f6ea315cbb5 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -818,6 +818,11 @@ bool Item_in_subselect::val_bool()
if (exec())
{
reset();
+ /*
+ Must mark the IN predicate as NULL so as to make sure an enclosing NOT
+ predicate will return FALSE. See the comments in
+ subselect_uniquesubquery_engine::copy_ref_key for further details.
+ */
null_value= 1;
return 0;
}
@@ -1979,10 +1984,38 @@ int subselect_uniquesubquery_engine::scan_table()
DESCRIPTION
Copy ref key and check for null parts in it.
+ Depending on the nullability and conversion problems this function
+ recognizes and processes the following states :
+ 1. Partial match on top level. This means IN has a value of FALSE
+ regardless of the data in the subquery table.
+ Detected by finding a NULL in the left IN operand of a top level
+ expression.
+ We may actually skip reading the subquery, so return TRUE to skip
+ the table scan in subselect_uniquesubquery_engine::exec and make
+ the value of the IN predicate a NULL (that is equal to FALSE on
+ top level).
+ 2. No exact match when IN is nested inside another predicate.
+ Detected by finding a NULL in the left IN operand when IN is not
+ a top level predicate.
+ We cannot have an exact match. But we must proceed further with a
+ table scan to find out if it's a partial match (and IN has a value
+ of NULL) or no match (and IN has a value of FALSE).
+ So we return FALSE to continue with the scan and see if there are
+ any record that would constitute a partial match (as we cannot
+ determine that from the index).
+ 3. Error converting the left IN operand to the column type of the
+ right IN operand. This counts as no match (and IN has the value of
+ FALSE). We mark the subquery table cursor as having no more rows
+ (to ensure that the processing that follows will not find a match)
+ and return FALSE, so IN is not treated as returning NULL.
+
RETURN
- FALSE - ok, index lookup key without keys copied.
- TRUE - an error occured while copying the key
+ FALSE - The value of the IN predicate is not known. Proceed to find the
+ value of the IN predicate using the determined values of
+ null_keypart and table->status.
+ TRUE - IN predicate has a value of NULL. Stop the processing right there
+ and return NULL to the outer predicates.
*/
bool subselect_uniquesubquery_engine::copy_ref_key()
@@ -2002,13 +2035,37 @@ bool subselect_uniquesubquery_engine::copy_ref_key()
function.
*/
null_keypart= (*copy)->null_key;
- bool top_level= ((Item_in_subselect *) item)->is_top_level_item();
- if (null_keypart && !top_level)
- break;
- if ((tab->ref.key_err) & 1 || (null_keypart && top_level))
+ if (null_keypart)
+ {
+ bool top_level= ((Item_in_subselect *) item)->is_top_level_item();
+ if (top_level)
+ {
+ /* Partial match on top level */
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ /* No exact match when IN is nested inside another predicate */
+ break;
+ }
+ }
+
+ /*
+ Check if the error is equal to STORE_KEY_FATAL. This is not expressed
+ using the store_key::store_key_result enum because ref.key_err is a
+ boolean and we want to detect both TRUE and STORE_KEY_FATAL from the
+ space of the union of the values of [TRUE, FALSE] and
+ store_key::store_key_result.
+ TODO: fix the variable an return types.
+ */
+ if (tab->ref.key_err & 1)
{
+ /*
+ Error converting the left IN operand to the column type of the right
+ IN operand.
+ */
tab->table->status= STATUS_NOT_FOUND;
- DBUG_RETURN(1);
+ break;
}
}
DBUG_RETURN(0);
@@ -2051,10 +2108,20 @@ int subselect_uniquesubquery_engine::exec()
int error;
TABLE *table= tab->table;
empty_result_set= TRUE;
+ table->status= 0;
/* TODO: change to use of 'full_scan' here? */
if (copy_ref_key())
DBUG_RETURN(1);
+ if (table->status)
+ {
+ /*
+ We know that there will be no rows even if we scan.
+ Can be set in copy_ref_key.
+ */
+ ((Item_in_subselect *) item)->value= 0;
+ DBUG_RETURN(0);
+ }
if (null_keypart)
DBUG_RETURN(scan_table());
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index f962d067e17..9fe92236fa1 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -431,7 +431,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table,
break;
case STRING_RESULT:
if (max_length/collation.collation->mbmaxlen <= 255 ||
- convert_blob_length >=UINT_MAX16 ||
+ convert_blob_length > Field_varstring::MAX_SIZE ||
!convert_blob_length)
return make_string_field(table);
field= new Field_varstring(convert_blob_length, maybe_null,
@@ -3290,14 +3290,20 @@ bool Item_func_group_concat::setup(THD *thd)
tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
/*
+ Currently we have to force conversion of BLOB values to VARCHAR's
+ if we are to store them in TREE objects used for ORDER BY and
+ DISTINCT. This leads to truncation if the BLOB's size exceeds
+ Field_varstring::MAX_SIZE.
+ */
+ if (arg_count_order > 0 || distinct)
+ set_if_smaller(tmp_table_param->convert_blob_length,
+ Field_varstring::MAX_SIZE);
+ /*
We have to create a temporary table to get descriptions of fields
(types, sizes and so on).
Note that in the table, we first have the ORDER BY fields, then the
field list.
-
- We need to set set_sum_field in true for storing value of blob in buffer
- of a record instead of a pointer of one.
*/
if (!(table= create_tmp_table(thd, tmp_table_param, all_fields,
(ORDER*) 0, 0, TRUE,
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 17eb75cfdc5..d2e9006c1eb 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -36,13 +36,17 @@ C_MODE_END
/* maximum length of buffer in our big digits (uint32) */
#define DECIMAL_BUFF_LENGTH 9
+
+/* the number of digits that my_decimal can possibly contain */
+#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
+
/*
maximum guaranteed precision of number in decimal digits (number of our
digits * number of decimal digits in one our big digit - number of decimal
- digits in one our big digit decreased on 1 (because we always put decimal
+ digits in one our big digit decreased by 1 (because we always put decimal
point on the border of our big digits))
*/
-#define DECIMAL_MAX_PRECISION ((DECIMAL_BUFF_LENGTH * 9) - 8*2)
+#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
#define DECIMAL_MAX_SCALE 30
#define DECIMAL_NOT_SPECIFIED 31
@@ -50,7 +54,7 @@ C_MODE_END
maximum length of string representation (number of maximum decimal
digits + 1 position for sign + 1 position for decimal point)
*/
-#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_PRECISION + 2)
+#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
/*
maximum size of packet length
*/
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2f78f0b24dd..4e8d399dbd9 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1350,6 +1350,9 @@ err_with_cleanup:
free_root(&call_mem_root, MYF(0));
thd->spcont= octx;
+ if (thd->killed)
+ thd->send_kill_message();
+
DBUG_RETURN(err_status);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 14edd460bc4..e9e40b25994 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -6777,7 +6777,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
table= (*ptr)->table;
table->auto_increment_field_not_null= FALSE;
}
- while ((field = *ptr++))
+ while ((field = *ptr++) && !thd->net.report_error)
{
value=v++;
table= field->table;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ab0437dd7b5..6123b4fa303 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6099,13 +6099,39 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
/*
- Push down all predicates from on expressions.
- Each of these predicated are guarded by a variable
+ Push down conditions from all on expressions.
+ Each of these conditions are guarded by a variable
that turns if off just before null complemented row for
- outer joins is formed. Thus, the predicates from an
+ outer joins is formed. Thus, the condition from an
'on expression' are guaranteed not to be checked for
the null complemented row.
*/
+
+ /* First push down constant conditions from on expressions */
+ for (JOIN_TAB *join_tab= join->join_tab+join->const_tables;
+ join_tab < join->join_tab+join->tables ; join_tab++)
+ {
+ if (*join_tab->on_expr_ref)
+ {
+ JOIN_TAB *cond_tab= join_tab->first_inner;
+ COND *tmp= make_cond_for_table(*join_tab->on_expr_ref,
+ join->const_table_map,
+ (table_map) 0);
+ if (!tmp)
+ continue;
+ tmp= new Item_func_trig_cond(tmp, &cond_tab->not_null_compl);
+ if (!tmp)
+ DBUG_RETURN(1);
+ tmp->quick_fix_field();
+ cond_tab->select_cond= !cond_tab->select_cond ? tmp :
+ new Item_cond_and(cond_tab->select_cond,tmp);
+ if (!cond_tab->select_cond)
+ DBUG_RETURN(1);
+ cond_tab->select_cond->quick_fix_field();
+ }
+ }
+
+ /* Push down non-constant conditions from on expressions */
JOIN_TAB *last_tab= tab;
while (first_inner_tab && first_inner_tab->last_inner == last_tab)
{
@@ -6558,7 +6584,6 @@ void JOIN::cleanup(bool full)
for (tab= join_tab, end= tab+tables; tab != end; tab++)
tab->cleanup();
table= 0;
- tables= 0;
}
else
{
@@ -8997,7 +9022,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
Make sure that the blob fits into a Field_varstring which has
2-byte lenght.
*/
- if (convert_blob_length && convert_blob_length < UINT_MAX16 &&
+ if (convert_blob_length && convert_blob_length <= Field_varstring::MAX_SIZE &&
(org_field->flags & BLOB_FLAG))
new_field= new Field_varstring(convert_blob_length,
org_field->maybe_null(),
@@ -9090,7 +9115,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
2-byte lenght.
*/
else if (item->max_length/item->collation.collation->mbmaxlen > 255 &&
- convert_blob_length < UINT_MAX16 && convert_blob_length)
+ convert_blob_length <= Field_varstring::MAX_SIZE &&
+ convert_blob_length)
new_field= new Field_varstring(convert_blob_length, maybe_null,
item->name, table->s,
item->collation.collation);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 60d5286674b..a4dfe12f70d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -37,7 +37,8 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
List<create_field> &create, bool ignore,
uint order_num, ORDER *order,
ha_rows *copied,ha_rows *deleted,
- enum enum_enable_or_disable keys_onoff);
+ enum enum_enable_or_disable keys_onoff,
+ bool error_if_not_empty);
static bool prepare_blob_field(THD *thd, create_field *sql_field);
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
@@ -5410,6 +5411,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
legacy_db_type table_type;
HA_CREATE_INFO *create_info;
frm_type_enum frm_type;
+ /*
+ Throw an error if the table to be altered isn't empty.
+ Used in DATE/DATETIME fields default value checking.
+ */
+ bool error_if_not_empty= FALSE;
+ /*
+ A field used for error reporting in DATE/DATETIME fields default
+ value checking.
+ */
+ create_field *new_datetime_field= 0;
uint need_copy_table= 0;
bool no_table_reopen= FALSE, varchar= FALSE;
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -5884,6 +5895,22 @@ view_err:
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table_name);
goto err;
}
+ /*
+ Check that the DATE/DATETIME not null field we are going to add is
+ either has a default value or the '0000-00-00' is allowed by the
+ set sql mode.
+ If the '0000-00-00' value isn't allowed then raise the error_if_not_empty
+ flag to allow ALTER TABLE only if the table to be altered is empty.
+ */
+ if ((def->sql_type == MYSQL_TYPE_DATE ||
+ def->sql_type == MYSQL_TYPE_NEWDATE ||
+ def->sql_type == MYSQL_TYPE_DATETIME) && !new_datetime_field &&
+ !(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
+ thd->variables.sql_mode & MODE_NO_ZERO_DATE)
+ {
+ new_datetime_field= def;
+ error_if_not_empty= TRUE;
+ }
if (!def->after)
create_list.push_back(def);
else if (def->after == first_keyword)
@@ -6374,7 +6401,8 @@ view_err:
new_table->next_number_field=new_table->found_next_number_field;
error=copy_data_between_tables(table, new_table, create_list, ignore,
order_num, order, &copied, &deleted,
- alter_info->keys_onoff);
+ alter_info->keys_onoff,
+ error_if_not_empty);
}
else
{
@@ -6861,6 +6889,38 @@ err1:
VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
err:
+ /*
+ No default value was provided for a DATE/DATETIME field, the
+ current sql_mode doesn't allow the '0000-00-00' value and
+ the table to be altered isn't empty.
+ Report error here.
+ */
+ if (error_if_not_empty && thd->row_count)
+ {
+ const char *f_val= 0;
+ enum enum_mysql_timestamp_type t_type= MYSQL_TIMESTAMP_DATE;
+ switch (new_datetime_field->sql_type)
+ {
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_NEWDATE:
+ f_val= "0000-00-00";
+ t_type= MYSQL_TIMESTAMP_DATE;
+ break;
+ case MYSQL_TYPE_DATETIME:
+ f_val= "0000-00-00 00:00:00";
+ t_type= MYSQL_TIMESTAMP_DATETIME;
+ break;
+ default:
+ /* Shouldn't get here. */
+ DBUG_ASSERT(0);
+ }
+ bool save_abort_on_warning= thd->abort_on_warning;
+ thd->abort_on_warning= TRUE;
+ make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ f_val, strlength(f_val), t_type,
+ new_datetime_field->field_name);
+ thd->abort_on_warning= save_abort_on_warning;
+ }
if (name_lock)
{
pthread_mutex_lock(&LOCK_open);
@@ -6878,7 +6938,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
uint order_num, ORDER *order,
ha_rows *copied,
ha_rows *deleted,
- enum enum_enable_or_disable keys_onoff)
+ enum enum_enable_or_disable keys_onoff,
+ bool error_if_not_empty)
{
int error;
Copy_field *copy,*copy_end;
@@ -6990,6 +7051,12 @@ copy_data_between_tables(TABLE *from,TABLE *to,
break;
}
thd->row_count++;
+ /* Return error if source table isn't empty. */
+ if (error_if_not_empty)
+ {
+ error= 1;
+ break;
+ }
if (to->next_number_field)
{
if (auto_increment_field_copied)
diff --git a/strings/decimal.c b/strings/decimal.c
index 0768c8cd4ca..09d535f3f22 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1523,9 +1523,10 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
dec1 *p0= buf0+intg0+max(frac1, frac0);
dec1 *p1= buf1+intg1+max(frac1, frac0);
- to->buf[0]= 0;
while (buf0 < p0)
*(--p1) = *(--p0);
+ if (unlikely(intg1 > intg0))
+ to->buf[0]= 0;
intg0= intg1;
buf0=to->buf;