summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/user_var.result33
-rw-r--r--mysql-test/t/user_var.test22
2 files changed, 53 insertions, 2 deletions
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 2cd132ce03c..2d91835d723 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -121,8 +121,8 @@ select @a:=0;
select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
@a+0 @a:=@a+0+count(*) count(*) @a+0
0 1 1 0
-1 3 2 0
-3 6 3 0
+0 2 2 0
+0 3 3 0
set @a=0;
select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
@a @a:="hello" @a @a:=3 @a @a:="hello again"
@@ -370,4 +370,33 @@ select @rownum := @rownum + 1 as row,
@prev_score := a as score
from t1 order by score desc;
drop table t1;
+create table t1(b bigint);
+insert into t1 (b) values (10), (30), (10);
+set @var := 0;
+select if(b=@var, 999, b) , @var := b from t1 order by b;
+if(b=@var, 999, b) @var := b
+10 10
+999 10
+30 30
+drop table t1;
+create temporary table t1 (id int);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+@lastid != id @lastid @lastid := id
+1 -1 2
+1 2 3
+0 3 3
+1 3 4
+drop table t1;
+create temporary table t1 (id bigint);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+@lastid != id @lastid @lastid := id
+1 -1 2
+1 2 3
+0 3 3
+1 3 4
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index f2699ab03d3..5d916e410e3 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -263,4 +263,26 @@ from t1 order by score desc;
--enable_result_log
drop table t1;
+#
+# Bug#26020: User-Defined Variables are not consistent with columns data types
+#
+
+create table t1(b bigint);
+insert into t1 (b) values (10), (30), (10);
+set @var := 0;
+select if(b=@var, 999, b) , @var := b from t1 order by b;
+drop table t1;
+
+create temporary table t1 (id int);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+drop table t1;
+
+create temporary table t1 (id bigint);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+drop table t1;
+
--echo End of 5.1 tests