Skip to content

Commit f74649b

Browse files
committed
Merge branch '10.1' into 10.2
2 parents c6838cc + a77f80b commit f74649b

File tree

8 files changed

+277
-87
lines changed

8 files changed

+277
-87
lines changed

mysql-test/r/bigint.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,14 @@ DROP TABLE t1;
510510
SELECT 100 BETWEEN 1 AND 9223372036854775808;
511511
100 BETWEEN 1 AND 9223372036854775808
512512
1
513+
#
514+
# MDEV-17724 Wrong result for BETWEEN 0 AND 18446744073709551615
515+
#
516+
CREATE TABLE t1 (c1 bigint(20) unsigned NOT NULL);
517+
INSERT INTO t1 VALUES (0),(101),(255);
518+
SELECT * FROM t1 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1;
519+
c1
520+
0
521+
101
522+
255
523+
DROP TABLE t1;

mysql-test/suite/engines/iuds/r/insert_number.result

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31586,8 +31586,33 @@ c1 c2 c3 c4 c5 c6 c7
3158631586
0 -9223372036854775808 1 2 3 4 5
3158731587
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6;
3158831588
c1 c2 c3 c4 c5 c6 c7
31589+
0 NULL 5 6 NULL 0 NULL
31590+
0 -9223372036854775808 1 2 3 4 5
31591+
0 0 17 18 19 20 21
31592+
0 124 22 23 24 25 26
31593+
0 124 27 28 29 30 31
31594+
0 -9223372036854775808 31 32 33 34 35
31595+
0 0 32 32 34 35 36
31596+
101 0 37 38 39 40 41
31597+
101 -102 103 104 105 106 107
31598+
102 -109 110 111 112 113 114
31599+
103 -109 110 111 112 113 114
31600+
105 NULL 102 103 104 105 106
31601+
108 -109 110 111 112 101 114
31602+
108 -109 110 111 112 102 114
31603+
108 -109 110 111 112 113 114
31604+
115 -116 117 118 119 120 121
31605+
122 -123 124 125 126 127 128
31606+
255 -2147483648 6 7 8 9 10
31607+
65535 -8388608 11 12 13 14 15
31608+
16777215 -32768 16 17 18 19 20
31609+
4294967295 -128 21 22 23 24 25
31610+
18446744073709551615 9223372036854775807 26 27 28 29 30
31611+
18446744073709551615 9223372036854775807 36 37 38 39 40
3158931612
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 LIMIT 2;
3159031613
c1 c2 c3 c4 c5 c6 c7
31614+
0 NULL 5 6 NULL 0 NULL
31615+
0 -9223372036854775808 1 2 3 4 5
3159131616
SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6;
3159231617
c1 c2 c3 c4 c5 c6 c7
3159331618
0 NULL 5 6 NULL 0 NULL
@@ -31747,8 +31772,33 @@ c1 c2 c3 c4 c5 c6 c7
3174731772
0 -9223372036854775808 31 32 33 34 35
3174831773
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC;
3174931774
c1 c2 c3 c4 c5 c6 c7
31775+
0 0 32 32 34 35 36
31776+
0 -9223372036854775808 31 32 33 34 35
31777+
0 124 27 28 29 30 31
31778+
0 124 22 23 24 25 26
31779+
0 0 17 18 19 20 21
31780+
0 -9223372036854775808 1 2 3 4 5
31781+
0 NULL 5 6 NULL 0 NULL
31782+
101 -102 103 104 105 106 107
31783+
101 0 37 38 39 40 41
31784+
102 -109 110 111 112 113 114
31785+
103 -109 110 111 112 113 114
31786+
105 NULL 102 103 104 105 106
31787+
108 -109 110 111 112 113 114
31788+
108 -109 110 111 112 102 114
31789+
108 -109 110 111 112 101 114
31790+
115 -116 117 118 119 120 121
31791+
122 -123 124 125 126 127 128
31792+
255 -2147483648 6 7 8 9 10
31793+
65535 -8388608 11 12 13 14 15
31794+
16777215 -32768 16 17 18 19 20
31795+
4294967295 -128 21 22 23 24 25
31796+
18446744073709551615 9223372036854775807 36 37 38 39 40
31797+
18446744073709551615 9223372036854775807 26 27 28 29 30
3175031798
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC LIMIT 2;
3175131799
c1 c2 c3 c4 c5 c6 c7
31800+
0 0 32 32 34 35 36
31801+
0 -9223372036854775808 31 32 33 34 35
3175231802
SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6 DESC;
3175331803
c1 c2 c3 c4 c5 c6 c7
3175431804
0 0 32 32 34 35 36
@@ -32014,8 +32064,33 @@ c1 c2 c3 c4 c5 c6 c7
3201432064
18446744073709551615 9223372036854775807 36 37 38 39 40
3201532065
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6;
3201632066
c1 c2 c3 c4 c5 c6 c7
32067+
0 NULL 5 6 NULL 0 NULL
32068+
0 -9223372036854775808 1 2 3 4 5
32069+
0 0 17 18 19 20 21
32070+
0 124 22 23 24 25 26
32071+
0 124 27 28 29 30 31
32072+
0 -9223372036854775808 31 32 33 34 35
32073+
0 0 32 32 34 35 36
32074+
101 0 37 38 39 40 41
32075+
101 -102 103 104 105 106 107
32076+
102 -109 110 111 112 113 114
32077+
103 -109 110 111 112 113 114
32078+
105 NULL 102 103 104 105 106
32079+
108 -109 110 111 112 101 114
32080+
108 -109 110 111 112 102 114
32081+
108 -109 110 111 112 113 114
32082+
115 -116 117 118 119 120 121
32083+
122 -123 124 125 126 127 128
32084+
255 -2147483648 6 7 8 9 10
32085+
65535 -8388608 11 12 13 14 15
32086+
16777215 -32768 16 17 18 19 20
32087+
4294967295 -128 21 22 23 24 25
32088+
18446744073709551615 9223372036854775807 26 27 28 29 30
32089+
18446744073709551615 9223372036854775807 36 37 38 39 40
3201732090
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 LIMIT 2;
3201832091
c1 c2 c3 c4 c5 c6 c7
32092+
0 NULL 5 6 NULL 0 NULL
32093+
0 -9223372036854775808 1 2 3 4 5
3201932094
SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6;
3202032095
c1 c2 c3 c4 c5 c6 c7
3202132096
0 NULL 5 6 NULL 0 NULL
@@ -32175,8 +32250,33 @@ c1 c2 c3 c4 c5 c6 c7
3217532250
18446744073709551615 9223372036854775807 26 27 28 29 30
3217632251
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC;
3217732252
c1 c2 c3 c4 c5 c6 c7
32253+
0 0 32 32 34 35 36
32254+
0 -9223372036854775808 31 32 33 34 35
32255+
0 124 27 28 29 30 31
32256+
0 124 22 23 24 25 26
32257+
0 0 17 18 19 20 21
32258+
0 -9223372036854775808 1 2 3 4 5
32259+
0 NULL 5 6 NULL 0 NULL
32260+
101 -102 103 104 105 106 107
32261+
101 0 37 38 39 40 41
32262+
102 -109 110 111 112 113 114
32263+
103 -109 110 111 112 113 114
32264+
105 NULL 102 103 104 105 106
32265+
108 -109 110 111 112 113 114
32266+
108 -109 110 111 112 102 114
32267+
108 -109 110 111 112 101 114
32268+
115 -116 117 118 119 120 121
32269+
122 -123 124 125 126 127 128
32270+
255 -2147483648 6 7 8 9 10
32271+
65535 -8388608 11 12 13 14 15
32272+
16777215 -32768 16 17 18 19 20
32273+
4294967295 -128 21 22 23 24 25
32274+
18446744073709551615 9223372036854775807 36 37 38 39 40
32275+
18446744073709551615 9223372036854775807 26 27 28 29 30
3217832276
SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC LIMIT 2;
3217932277
c1 c2 c3 c4 c5 c6 c7
32278+
0 0 32 32 34 35 36
32279+
0 -9223372036854775808 31 32 33 34 35
3218032280
SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6 DESC;
3218132281
c1 c2 c3 c4 c5 c6 c7
3218232282
0 0 32 32 34 35 36

mysql-test/suite/engines/iuds/r/update_delete_number.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,8 +3768,25 @@ c1 c2 c3
37683768
-12 18446744073709551615 12
37693769
SELECT * FROM t2 WHERE c2 BETWEEN 0 AND 18446744073709551615 ORDER BY c2,c1;
37703770
c1 c2 c3
3771+
-4 4 4
3772+
-9 9 9
3773+
0 255 13
3774+
-9223372036854775808 18446744073709551615 12
3775+
-12 18446744073709551615 12
3776+
-11 18446744073709551615 11
3777+
-8 18446744073709551615 8
3778+
-7 18446744073709551615 7
3779+
-6 18446744073709551615 6
3780+
-5 18446744073709551615 5
3781+
-3 18446744073709551615 3
3782+
-2 18446744073709551615 2
3783+
-1 18446744073709551615 1
3784+
50 18446744073709551615 10
3785+
9223372036854775807 18446744073709551615 14
37713786
SELECT * FROM t2 WHERE c2 BETWEEN 0 AND 18446744073709551615 ORDER BY c2,c1 DESC LIMIT 2;
37723787
c1 c2 c3
3788+
-4 4 4
3789+
-9 9 9
37733790
SELECT * FROM t2 WHERE c2 IN(0,18446744073709551615) ORDER BY c2,c1 DESC;
37743791
c1 c2 c3
37753792
9223372036854775807 18446744073709551615 14

mysql-test/t/bigint.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,12 @@ DROP TABLE t1;
416416
--echo # MDEV-9372 select 100 between 1 and 9223372036854775808 returns false
417417
--echo #
418418
SELECT 100 BETWEEN 1 AND 9223372036854775808;
419+
420+
--echo #
421+
--echo # MDEV-17724 Wrong result for BETWEEN 0 AND 18446744073709551615
422+
--echo #
423+
424+
CREATE TABLE t1 (c1 bigint(20) unsigned NOT NULL);
425+
INSERT INTO t1 VALUES (0),(101),(255);
426+
SELECT * FROM t1 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1;
427+
DROP TABLE t1;

sql/item.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,10 @@ class Item: public Value_source,
995995
Values of non-integer data types are adjusted to the UNSIGNED range.
996996
*/
997997
virtual longlong val_int_unsigned_typecast();
998+
Longlong_hybrid to_longlong_hybrid()
999+
{
1000+
return Longlong_hybrid(val_int(), unsigned_flag);
1001+
}
9981002
/*
9991003
This is just a shortcut to avoid the cast. You should still use
10001004
unsigned_flag to check the sign of the item.

0 commit comments

Comments
 (0)