Skip to content

Commit 9654228

Browse files
committed
Merge branch '10.11' into bb-10.11-release
2 parents 264843a + 8f434a1 commit 9654228

32 files changed

Lines changed: 344 additions & 128 deletions

client/mysqltest.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,12 +1534,12 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query,
15341534
}
15351535
else
15361536
{
1537-
if (!(v= var_get(p, &p, 0, 0)))
1537+
if (!(v= var_get(p, &p, 0, 0)) || !v->str_val)
15381538
{
15391539
report_or_die( "Bad variable in eval");
15401540
DBUG_VOID_RETURN;
15411541
}
1542-
dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
1542+
dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
15431543
}
15441544
break;
15451545
case '\\':
@@ -9228,8 +9228,9 @@ void do_block(enum block_cmd cmd, struct st_command* command)
92289228

92299229
/* Parse and evaluate test expression */
92309230
expr_start= strchr(p, '(');
9231-
if (!expr_start++)
9231+
if (!expr_start)
92329232
die("missing '(' in %s", cmd_name);
9233+
expr_start++;
92339234

92349235
while (my_isspace(charset_info, *expr_start))
92359236
expr_start++;

debian/mariadb-test-data.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
usr/lib/mysql/plugin/test_pam_modules
12
usr/share/mysql/mysql-test/collections
23
usr/share/mysql/mysql-test/include
34
usr/share/mysql/mysql-test/main

include/my_sys.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
861861
size_t init_alloc,size_t alloc_increment);
862862
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
863863
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
864-
size_t length);
864+
size_t length) __attribute__((nonnull(2)));
865865
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
866866
...);
867867
extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str,

mysql-test/main/case.result

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,c
158158
SHOW CREATE TABLE t1;
159159
Table Create Table
160160
t1 CREATE TABLE `t1` (
161-
`COALESCE(1)` int(1) NOT NULL,
161+
`COALESCE(1)` int(2) NOT NULL,
162162
`COALESCE(1.0)` decimal(2,1) NOT NULL,
163163
`COALESCE('a')` varchar(1) NOT NULL,
164164
`COALESCE(1,1.0)` decimal(2,1) NOT NULL,
@@ -589,4 +589,40 @@ case 'X' when 1/0 then 1 when 'X' then 2 else 3 end
589589
Warnings:
590590
Warning 1292 Truncated incorrect DOUBLE value: 'X'
591591
Warning 1365 Division by 0
592+
#
593+
# MDEV-23278: Incorrect Calculation with AVG() Function
594+
#
595+
create table avg_calc_test (
596+
id int(11) not null auto_increment,
597+
name varchar(255) default null,
598+
primary key (id)
599+
) auto_increment=1 default charset=latin1;
600+
insert into avg_calc_test (name) values ('orange'), ('blue'), ('black'), ('orange'), ('black');
601+
select * from (
602+
select
603+
avg(case when name = 'orange' then 3 when name = 'blue' then 2 when name = 'black' then 1 else 0 end) as metric_val
604+
from avg_calc_test
605+
) t;
606+
metric_val
607+
2.0000
608+
create table t1 as
609+
select
610+
avg(case when name = 'orange' then 3 when name = 'blue' then 2 when name = 'black' then 1 else 0 end) as metric_val
611+
from avg_calc_test;
612+
select * from t1;
613+
metric_val
614+
2.0000
615+
create or replace table t1 as
616+
select
617+
avg(least(1,2)) as metric_val
618+
from avg_calc_test;
619+
select * from t1;
620+
metric_val
621+
1.0000
622+
create or replace table t1 as
623+
select avg(coalesce(1,2)) as metric_val from avg_calc_test;
624+
select * from t1;
625+
metric_val
626+
1.0000
627+
drop table avg_calc_test, t1;
592628
# End of 10.11 test

mysql-test/main/case.test

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,41 @@ select case 'X' when null then 1 when 'X' then 2 else 3 end;
416416
select case 'X' when 1/1 then 1 when 'X' then 2 else 3 end;
417417
select case 'X' when 1/0 then 1 when 'X' then 2 else 3 end;
418418

419+
--echo #
420+
--echo # MDEV-23278: Incorrect Calculation with AVG() Function
421+
--echo #
422+
create table avg_calc_test (
423+
id int(11) not null auto_increment,
424+
name varchar(255) default null,
425+
primary key (id)
426+
) auto_increment=1 default charset=latin1;
427+
insert into avg_calc_test (name) values ('orange'), ('blue'), ('black'), ('orange'), ('black');
428+
429+
select * from (
430+
select
431+
avg(case when name = 'orange' then 3 when name = 'blue' then 2 when name = 'black' then 1 else 0 end) as metric_val
432+
from avg_calc_test
433+
) t;
434+
435+
create table t1 as
436+
select
437+
avg(case when name = 'orange' then 3 when name = 'blue' then 2 when name = 'black' then 1 else 0 end) as metric_val
438+
from avg_calc_test;
439+
440+
select * from t1;
441+
442+
create or replace table t1 as
443+
select
444+
avg(least(1,2)) as metric_val
445+
from avg_calc_test;
446+
447+
select * from t1;
448+
449+
create or replace table t1 as
450+
select avg(coalesce(1,2)) as metric_val from avg_calc_test;
451+
452+
select * from t1;
453+
454+
drop table avg_calc_test, t1;
455+
419456
--echo # End of 10.11 test

mysql-test/main/cte_recursive.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5052,7 +5052,7 @@ Warning 1264 Out of range value for column 'mid' at row 5
50525052
show create table t2;
50535053
Table Create Table
50545054
t2 CREATE TABLE `t2` (
5055-
`level` int(1) DEFAULT NULL,
5055+
`level` int(2) DEFAULT NULL,
50565056
`id` int(11) DEFAULT NULL,
50575057
`mid` int(11) DEFAULT NULL,
50585058
`name` text DEFAULT NULL,
@@ -5133,7 +5133,7 @@ Warning 1264 Out of range value for column 'mid' at row 5
51335133
show create table t2;
51345134
Table Create Table
51355135
t2 CREATE TABLE `t2` (
5136-
`level` int(1) DEFAULT NULL,
5136+
`level` int(2) DEFAULT NULL,
51375137
`id` int(11) DEFAULT NULL,
51385138
`mid` int(11) DEFAULT NULL,
51395139
`name` text DEFAULT NULL,

mysql-test/main/ctype_binary.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ create table t1 as select concat(least(1,2)) as c1;
607607
show create table t1;
608608
Table Create Table
609609
t1 CREATE TABLE `t1` (
610-
`c1` varbinary(1) DEFAULT NULL
610+
`c1` varbinary(2) DEFAULT NULL
611611
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
612612
drop table t1;
613613
select hex(concat(greatest(1,2)));
@@ -617,7 +617,7 @@ create table t1 as select concat(greatest(1,2)) as c1;
617617
show create table t1;
618618
Table Create Table
619619
t1 CREATE TABLE `t1` (
620-
`c1` varbinary(1) DEFAULT NULL
620+
`c1` varbinary(2) DEFAULT NULL
621621
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
622622
drop table t1;
623623
select hex(concat(case when 11 then 22 else 33 end));
@@ -627,7 +627,7 @@ create table t1 as select concat(case when 11 then 22 else 33 end) as c1;
627627
show create table t1;
628628
Table Create Table
629629
t1 CREATE TABLE `t1` (
630-
`c1` varbinary(2) DEFAULT NULL
630+
`c1` varbinary(3) DEFAULT NULL
631631
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
632632
drop table t1;
633633
select hex(concat(coalesce(1,2)));
@@ -637,7 +637,7 @@ create table t1 as select concat(coalesce(1,2)) as c1;
637637
show create table t1;
638638
Table Create Table
639639
t1 CREATE TABLE `t1` (
640-
`c1` varbinary(1) DEFAULT NULL
640+
`c1` varbinary(2) DEFAULT NULL
641641
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
642642
drop table t1;
643643
select hex(concat_ws(1,2,3));
@@ -1068,7 +1068,7 @@ create table t1 as select concat(ifnull(1,1)) as c1;
10681068
show create table t1;
10691069
Table Create Table
10701070
t1 CREATE TABLE `t1` (
1071-
`c1` varbinary(1) DEFAULT NULL
1071+
`c1` varbinary(2) DEFAULT NULL
10721072
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
10731073
drop table t1;
10741074
select hex(concat(ifnull(1.1,1.1)));
@@ -1108,7 +1108,7 @@ create table t1 as select concat(if(1,1,1)) as c1;
11081108
show create table t1;
11091109
Table Create Table
11101110
t1 CREATE TABLE `t1` (
1111-
`c1` varbinary(1) DEFAULT NULL
1111+
`c1` varbinary(2) DEFAULT NULL
11121112
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
11131113
drop table t1;
11141114
select hex(concat(nullif(1,2)));

mysql-test/main/ctype_cp1251.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ create table t1 as select concat(least(1,2)) as c1;
10191019
show create table t1;
10201020
Table Create Table
10211021
t1 CREATE TABLE `t1` (
1022-
`c1` varchar(1) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1022+
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
10231023
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
10241024
drop table t1;
10251025
select hex(concat(greatest(1,2)));
@@ -1029,7 +1029,7 @@ create table t1 as select concat(greatest(1,2)) as c1;
10291029
show create table t1;
10301030
Table Create Table
10311031
t1 CREATE TABLE `t1` (
1032-
`c1` varchar(1) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1032+
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
10331033
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
10341034
drop table t1;
10351035
select hex(concat(case when 11 then 22 else 33 end));
@@ -1039,7 +1039,7 @@ create table t1 as select concat(case when 11 then 22 else 33 end) as c1;
10391039
show create table t1;
10401040
Table Create Table
10411041
t1 CREATE TABLE `t1` (
1042-
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1042+
`c1` varchar(3) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
10431043
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
10441044
drop table t1;
10451045
select hex(concat(coalesce(1,2)));
@@ -1049,7 +1049,7 @@ create table t1 as select concat(coalesce(1,2)) as c1;
10491049
show create table t1;
10501050
Table Create Table
10511051
t1 CREATE TABLE `t1` (
1052-
`c1` varchar(1) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1052+
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
10531053
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
10541054
drop table t1;
10551055
select hex(concat_ws(1,2,3));
@@ -1480,7 +1480,7 @@ create table t1 as select concat(ifnull(1,1)) as c1;
14801480
show create table t1;
14811481
Table Create Table
14821482
t1 CREATE TABLE `t1` (
1483-
`c1` varchar(1) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1483+
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
14841484
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
14851485
drop table t1;
14861486
select hex(concat(ifnull(1.1,1.1)));
@@ -1520,7 +1520,7 @@ create table t1 as select concat(if(1,1,1)) as c1;
15201520
show create table t1;
15211521
Table Create Table
15221522
t1 CREATE TABLE `t1` (
1523-
`c1` varchar(1) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
1523+
`c1` varchar(2) CHARACTER SET cp1251 COLLATE cp1251_general_ci DEFAULT NULL
15241524
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
15251525
drop table t1;
15261526
select hex(concat(nullif(1,2)));

mysql-test/main/ctype_latin1.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ create table t1 as select concat(least(1,2)) as c1;
13281328
show create table t1;
13291329
Table Create Table
13301330
t1 CREATE TABLE `t1` (
1331-
`c1` varchar(1) DEFAULT NULL
1331+
`c1` varchar(2) DEFAULT NULL
13321332
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
13331333
drop table t1;
13341334
select hex(concat(greatest(1,2)));
@@ -1338,7 +1338,7 @@ create table t1 as select concat(greatest(1,2)) as c1;
13381338
show create table t1;
13391339
Table Create Table
13401340
t1 CREATE TABLE `t1` (
1341-
`c1` varchar(1) DEFAULT NULL
1341+
`c1` varchar(2) DEFAULT NULL
13421342
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
13431343
drop table t1;
13441344
select hex(concat(case when 11 then 22 else 33 end));
@@ -1348,7 +1348,7 @@ create table t1 as select concat(case when 11 then 22 else 33 end) as c1;
13481348
show create table t1;
13491349
Table Create Table
13501350
t1 CREATE TABLE `t1` (
1351-
`c1` varchar(2) DEFAULT NULL
1351+
`c1` varchar(3) DEFAULT NULL
13521352
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
13531353
drop table t1;
13541354
select hex(concat(coalesce(1,2)));
@@ -1358,7 +1358,7 @@ create table t1 as select concat(coalesce(1,2)) as c1;
13581358
show create table t1;
13591359
Table Create Table
13601360
t1 CREATE TABLE `t1` (
1361-
`c1` varchar(1) DEFAULT NULL
1361+
`c1` varchar(2) DEFAULT NULL
13621362
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
13631363
drop table t1;
13641364
select hex(concat_ws(1,2,3));
@@ -1789,7 +1789,7 @@ create table t1 as select concat(ifnull(1,1)) as c1;
17891789
show create table t1;
17901790
Table Create Table
17911791
t1 CREATE TABLE `t1` (
1792-
`c1` varchar(1) DEFAULT NULL
1792+
`c1` varchar(2) DEFAULT NULL
17931793
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
17941794
drop table t1;
17951795
select hex(concat(ifnull(1.1,1.1)));
@@ -1829,7 +1829,7 @@ create table t1 as select concat(if(1,1,1)) as c1;
18291829
show create table t1;
18301830
Table Create Table
18311831
t1 CREATE TABLE `t1` (
1832-
`c1` varchar(1) DEFAULT NULL
1832+
`c1` varchar(2) DEFAULT NULL
18331833
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
18341834
drop table t1;
18351835
select hex(concat(nullif(1,2)));

mysql-test/main/ctype_ucs.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ create table t1 as select concat(least(1,2)) as c1;
22112211
show create table t1;
22122212
Table Create Table
22132213
t1 CREATE TABLE `t1` (
2214-
`c1` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2214+
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
22152215
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
22162216
drop table t1;
22172217
select hex(concat(greatest(1,2)));
@@ -2221,7 +2221,7 @@ create table t1 as select concat(greatest(1,2)) as c1;
22212221
show create table t1;
22222222
Table Create Table
22232223
t1 CREATE TABLE `t1` (
2224-
`c1` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2224+
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
22252225
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
22262226
drop table t1;
22272227
select hex(concat(case when 11 then 22 else 33 end));
@@ -2231,7 +2231,7 @@ create table t1 as select concat(case when 11 then 22 else 33 end) as c1;
22312231
show create table t1;
22322232
Table Create Table
22332233
t1 CREATE TABLE `t1` (
2234-
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2234+
`c1` varchar(3) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
22352235
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
22362236
drop table t1;
22372237
select hex(concat(coalesce(1,2)));
@@ -2241,7 +2241,7 @@ create table t1 as select concat(coalesce(1,2)) as c1;
22412241
show create table t1;
22422242
Table Create Table
22432243
t1 CREATE TABLE `t1` (
2244-
`c1` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2244+
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
22452245
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
22462246
drop table t1;
22472247
select hex(concat_ws(1,2,3));
@@ -2672,7 +2672,7 @@ create table t1 as select concat(ifnull(1,1)) as c1;
26722672
show create table t1;
26732673
Table Create Table
26742674
t1 CREATE TABLE `t1` (
2675-
`c1` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2675+
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
26762676
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
26772677
drop table t1;
26782678
select hex(concat(ifnull(1.1,1.1)));
@@ -2712,7 +2712,7 @@ create table t1 as select concat(if(1,1,1)) as c1;
27122712
show create table t1;
27132713
Table Create Table
27142714
t1 CREATE TABLE `t1` (
2715-
`c1` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
2715+
`c1` varchar(2) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
27162716
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
27172717
drop table t1;
27182718
select hex(concat(nullif(1,2)));

0 commit comments

Comments
 (0)