Skip to content

Commit bed80b9

Browse files
author
Marc Alff
committed
Merge mysql-next-mr (revno 2958) --> mysql-next-mr-marc
2 parents 67a48e1 + 357496c commit bed80b9

38 files changed

+515
-120
lines changed

client/mysqltest.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
#define QUERY_SEND_FLAG 1
7373
#define QUERY_REAP_FLAG 2
7474

75+
#ifndef HAVE_SETENV
76+
#error implement our portable setenv replacement in mysys
77+
#endif
78+
7579
enum {
7680
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
7781
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
@@ -216,7 +220,6 @@ typedef struct
216220
int alloced_len;
217221
int int_dirty; /* do not update string if int is updated until first read */
218222
int alloced;
219-
char *env_s;
220223
} VAR;
221224

222225
/*Perl/shell-like variable registers */
@@ -1924,13 +1927,20 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
19241927
+ name_len+1, MYF(MY_WME))))
19251928
die("Out of memory");
19261929

1927-
tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0;
1930+
if (name != NULL)
1931+
{
1932+
tmp_var->name= reinterpret_cast<char*>(tmp_var) + sizeof(*tmp_var);
1933+
memcpy(tmp_var->name, name, name_len);
1934+
tmp_var->name[name_len]= 0;
1935+
}
1936+
else
1937+
tmp_var->name= NULL;
1938+
19281939
tmp_var->alloced = (v == 0);
19291940

19301941
if (!(tmp_var->str_val = (char*)my_malloc(val_alloc_len+1, MYF(MY_WME))))
19311942
die("Out of memory");
19321943

1933-
memcpy(tmp_var->name, name, name_len);
19341944
if (val)
19351945
{
19361946
memcpy(tmp_var->str_val, val, val_len);
@@ -1941,7 +1951,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
19411951
tmp_var->alloced_len = val_alloc_len;
19421952
tmp_var->int_val = (val) ? atoi(val) : 0;
19431953
tmp_var->int_dirty = 0;
1944-
tmp_var->env_s = 0;
19451954
return tmp_var;
19461955
}
19471956

@@ -2069,20 +2078,15 @@ void var_set(const char *var_name, const char *var_name_end,
20692078

20702079
if (env_var)
20712080
{
2072-
char buf[1024], *old_env_s= v->env_s;
20732081
if (v->int_dirty)
20742082
{
20752083
sprintf(v->str_val, "%d", v->int_val);
20762084
v->int_dirty= 0;
20772085
v->str_val_len= strlen(v->str_val);
20782086
}
2079-
my_snprintf(buf, sizeof(buf), "%.*s=%.*s",
2080-
v->name_len, v->name,
2081-
v->str_val_len, v->str_val);
2082-
if (!(v->env_s= my_strdup(buf, MYF(MY_WME))))
2083-
die("Out of memory");
2084-
putenv(v->env_s);
2085-
my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR));
2087+
/* setenv() expects \0-terminated strings */
2088+
DBUG_ASSERT(v->name[v->name_len] == 0);
2089+
setenv(v->name, v->str_val, 1);
20862090
}
20872091
DBUG_VOID_RETURN;
20882092
}

include/config-win.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ inline ulonglong double2ulonglong(double d)
318318
#define strcasecmp stricmp
319319
#define strncasecmp strnicmp
320320

321-
#define HAVE_SNPRINTF /* Gave link error */
321+
#define HAVE_SNPRINTF 1
322322
#define snprintf _snprintf
323323

324+
#define HAVE_SETENV 1
325+
#define setenv(VAR,VAL,X) _putenv_s(VAR,VAL)
326+
324327
#ifdef _MSC_VER
325328
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
326329
#define HAVE_ANSI_INCLUDE

libmysqld/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobj
155155
if DARWIN_MWCC
156156
mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
157157
else
158-
-rm -f libmysqld.a
159-
if test "$(host_os)" = "netware" ; \
158+
-rm -f libmysqld.a
159+
if test "$(host_os)" = "netware" ; \
160160
then \
161161
$(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
162162
else \

mysql-test/include/mysqld--help.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help
1111

1212
perl;
1313
@skipvars=qw/basedir open-files-limit general-log-file log
14-
log-slow-queries pid-file slow-query-log-file/;
14+
log-slow-queries pid-file slow-query-log-file
15+
datadir slave-load-tmpdir tmpdir/;
1516
@plugins=qw/innodb ndb ndbcluster safemalloc debug temp-pool ssl des-key-file
1617
thread-concurrency super-large-pages mutex-deadlock-detector/;
1718
@env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_SHAREDIR/;

mysql-test/lib/v1/mysql-test-run.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,7 +3911,7 @@ ($$$$)
39113911

39123912
if ( $opt_valgrind_mysqld )
39133913
{
3914-
mtr_add_arg($args, "%s--skip-safemalloc", $prefix);
3914+
mtr_add_arg($args, "%s--loose-skip-safemalloc", $prefix);
39153915

39163916
if ( $mysql_version_id < 50100 )
39173917
{
@@ -5208,7 +5208,6 @@ sub valgrind_arguments {
52085208
else
52095209
{
52105210
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
5211-
mtr_add_arg($args, "--alignment=8");
52125211
mtr_add_arg($args, "--leak-check=yes");
52135212
mtr_add_arg($args, "--num-callers=16");
52145213
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)

mysql-test/r/events_scheduling.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,24 @@ DROP TABLE table_1;
8282
DROP TABLE table_2;
8383
DROP TABLE table_3;
8484
DROP TABLE table_4;
85+
86+
Bug #50087 Interval arithmetic for Event_queue_element is not portable.
87+
88+
CREATE TABLE t1(a int);
89+
CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH
90+
STARTS NOW() - INTERVAL 1 MONTH
91+
ENDS NOW() + INTERVAL 2 MONTH
92+
ON COMPLETION PRESERVE
93+
DO
94+
INSERT INTO t1 VALUES (1);
95+
CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH
96+
STARTS NOW()
97+
ENDS NOW() + INTERVAL 11 MONTH
98+
ON COMPLETION PRESERVE
99+
DO
100+
INSERT INTO t1 VALUES (1);
101+
DROP TABLE t1;
102+
DROP EVENT e1;
103+
DROP EVENT e2;
85104
DROP DATABASE events_test;
86105
SET GLOBAL event_scheduler=@event_scheduler;

mysql-test/r/index_merge_myisam.result

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,19 +1419,19 @@ drop table t1;
14191419
#
14201420
select @@optimizer_switch;
14211421
@@optimizer_switch
1422-
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1422+
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14231423
set optimizer_switch='index_merge=off,index_merge_union=off';
14241424
select @@optimizer_switch;
14251425
@@optimizer_switch
1426-
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on
1426+
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14271427
set optimizer_switch='index_merge_union=on';
14281428
select @@optimizer_switch;
14291429
@@optimizer_switch
1430-
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1430+
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14311431
set optimizer_switch='default,index_merge_sort_union=off';
14321432
select @@optimizer_switch;
14331433
@@optimizer_switch
1434-
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on
1434+
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,engine_condition_pushdown=on
14351435
set optimizer_switch=4;
14361436
set optimizer_switch=NULL;
14371437
ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'NULL'
@@ -1457,21 +1457,21 @@ set optimizer_switch=default;
14571457
set optimizer_switch='index_merge=off,index_merge_union=off,default';
14581458
select @@optimizer_switch;
14591459
@@optimizer_switch
1460-
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on
1460+
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14611461
set optimizer_switch=default;
14621462
select @@global.optimizer_switch;
14631463
@@global.optimizer_switch
1464-
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1464+
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14651465
set @@global.optimizer_switch=default;
14661466
select @@global.optimizer_switch;
14671467
@@global.optimizer_switch
1468-
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1468+
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14691469
#
14701470
# Check index_merge's @@optimizer_switch flags
14711471
#
14721472
select @@optimizer_switch;
14731473
@@optimizer_switch
1474-
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1474+
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
14751475
create table t0 (a int);
14761476
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
14771477
create table t1 (a int, b int, c int, filler char(100),
@@ -1581,5 +1581,5 @@ id select_type table type possible_keys key key_len ref rows Extra
15811581
set optimizer_switch=default;
15821582
show variables like 'optimizer_switch';
15831583
Variable_name Value
1584-
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
1584+
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
15851585
drop table t0, t1;

mysql-test/r/mysqld--help-notwin.result

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ The following options may be given as the first argument:
132132
on that value
133133
--enable-locking Deprecated option, use --external-locking instead.
134134
--engine-condition-pushdown
135-
Push supported query conditions to the storage engine
135+
Push supported query conditions to the storage engine.
136+
Deprecated, use --optimizer-switch instead.
136137
(Defaults to on; use --skip-engine-condition-pushdown to disable.)
137138
--event-scheduler[=name]
138139
Enable the event scheduler. Possible values are ON, OFF,
@@ -413,8 +414,9 @@ The following options may be given as the first argument:
413414
--optimizer-switch=name
414415
optimizer_switch=option=val[,option=val...], where option
415416
is one of {index_merge, index_merge_union,
416-
index_merge_sort_union, index_merge_intersection} and val
417-
is one of {on, off, default}
417+
index_merge_sort_union, index_merge_intersection,
418+
engine_condition_pushdown} and val is one of {on, off,
419+
default}
418420
--partition[=name] Enable or disable partition plugin. Possible values are
419421
ON, OFF, FORCE (don't start if the plugin fails to load).
420422
--performance-schema
@@ -774,7 +776,6 @@ completion-type NO_CHAIN
774776
concurrent-insert AUTO
775777
connect-timeout 10
776778
console FALSE
777-
datadir MYSQLTEST_VARDIR/install.db/
778779
date-format %Y-%m-%d
779780
datetime-format %Y-%m-%d %H:%i:%s
780781
default-character-set latin1
@@ -885,7 +886,7 @@ old-passwords FALSE
885886
old-style-user-limits FALSE
886887
optimizer-prune-level 1
887888
optimizer-search-depth 62
888-
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
889+
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
889890
partition ON
890891
performance-schema FALSE
891892
performance-schema-events-waits-history-long-size 10000
@@ -944,7 +945,6 @@ skip-show-database FALSE
944945
skip-slave-start FALSE
945946
slave-compressed-protocol FALSE
946947
slave-exec-mode STRICT
947-
slave-load-tmpdir MYSQLTEST_VARDIR/tmp/
948948
slave-net-timeout 3600
949949
slave-skip-errors (No default value)
950950
slave-transaction-retries 10
@@ -972,7 +972,6 @@ thread-stack 262144
972972
time-format %H:%i:%s
973973
timed-mutexes FALSE
974974
tmp-table-size 16777216
975-
tmpdir MYSQLTEST_VARDIR/tmp/
976975
transaction-alloc-block-size 8192
977976
transaction-isolation REPEATABLE-READ
978977
transaction-prealloc-size 4096

mysql-test/r/mysqld--help-win.result

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ The following options may be given as the first argument:
132132
on that value
133133
--enable-locking Deprecated option, use --external-locking instead.
134134
--engine-condition-pushdown
135-
Push supported query conditions to the storage engine
135+
Push supported query conditions to the storage engine.
136+
Deprecated, use --optimizer-switch instead.
136137
(Defaults to on; use --skip-engine-condition-pushdown to disable.)
137138
--event-scheduler[=name]
138139
Enable the event scheduler. Possible values are ON, OFF,
@@ -413,8 +414,9 @@ The following options may be given as the first argument:
413414
--optimizer-switch=name
414415
optimizer_switch=option=val[,option=val...], where option
415416
is one of {index_merge, index_merge_union,
416-
index_merge_sort_union, index_merge_intersection} and val
417-
is one of {on, off, default}
417+
index_merge_sort_union, index_merge_intersection,
418+
engine_condition_pushdown} and val is one of {on, off,
419+
default}
418420
--partition[=name] Enable or disable partition plugin. Possible values are
419421
ON, OFF, FORCE (don't start if the plugin fails to load).
420422
--performance-schema
@@ -778,7 +780,6 @@ completion-type NO_CHAIN
778780
concurrent-insert AUTO
779781
connect-timeout 10
780782
console FALSE
781-
datadir MYSQLTEST_VARDIR/install.db/
782783
date-format %Y-%m-%d
783784
datetime-format %Y-%m-%d %H:%i:%s
784785
default-character-set latin1
@@ -889,7 +890,7 @@ old-passwords FALSE
889890
old-style-user-limits FALSE
890891
optimizer-prune-level 1
891892
optimizer-search-depth 62
892-
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
893+
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
893894
partition ON
894895
performance-schema FALSE
895896
performance-schema-events-waits-history-long-size 10000
@@ -950,7 +951,6 @@ skip-show-database FALSE
950951
skip-slave-start FALSE
951952
slave-compressed-protocol FALSE
952953
slave-exec-mode STRICT
953-
slave-load-tmpdir MYSQLTEST_VARDIR/tmp/
954954
slave-net-timeout 3600
955955
slave-skip-errors (No default value)
956956
slave-transaction-retries 10
@@ -978,7 +978,6 @@ thread-stack 262144
978978
time-format %H:%i:%s
979979
timed-mutexes FALSE
980980
tmp-table-size 16777216
981-
tmpdir MYSQLTEST_VARDIR/tmp/
982981
transaction-alloc-block-size 8192
983982
transaction-isolation REPEATABLE-READ
984983
transaction-prealloc-size 4096
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
select @@session.engine_condition_pushdown,
2+
@@global.engine_condition_pushdown,
3+
@@session.optimizer_switch, @@global.optimizer_switch;
4+
@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch
5+
1 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
select @@session.engine_condition_pushdown,
2+
@@global.engine_condition_pushdown,
3+
@@session.optimizer_switch, @@global.optimizer_switch;
4+
@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch
5+
0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off

mysql-test/r/subselect3.result

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,3 +964,53 @@ Variable_name Value
964964
Handler_read_rnd_next 18
965965
DROP TABLE t1,t2;
966966
End of 5.1 tests
967+
#
968+
# BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery
969+
# in the select list
970+
#
971+
972+
CREATE TABLE t1 (
973+
i int(11) DEFAULT NULL,
974+
v varchar(1) DEFAULT NULL
975+
);
976+
977+
INSERT INTO t1 VALUES (8,'v');
978+
INSERT INTO t1 VALUES (9,'r');
979+
INSERT INTO t1 VALUES (NULL,'y');
980+
981+
CREATE TABLE t2 (
982+
i int(11) DEFAULT NULL,
983+
v varchar(1) DEFAULT NULL,
984+
KEY i_key (i)
985+
);
986+
987+
INSERT INTO t2 VALUES (NULL,'r');
988+
INSERT INTO t2 VALUES (0,'c');
989+
INSERT INTO t2 VALUES (0,'o');
990+
INSERT INTO t2 VALUES (2,'v');
991+
INSERT INTO t2 VALUES (7,'c');
992+
993+
SELECT i, v, (SELECT COUNT(DISTINCT i)
994+
FROM t1
995+
WHERE v = t2.v) as subsel
996+
FROM t2;
997+
i v subsel
998+
NULL r 1
999+
0 c 0
1000+
0 o 0
1001+
2 v 1
1002+
7 c 0
1003+
1004+
EXPLAIN EXTENDED
1005+
SELECT i, v, (SELECT COUNT(DISTINCT i)
1006+
FROM t1
1007+
WHERE v = t2.v) as subsel
1008+
FROM t2;
1009+
id select_type table type possible_keys key key_len ref rows filtered Extra
1010+
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00
1011+
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1012+
Warnings:
1013+
Note 1276 Field or reference 'test.t2.v' of SELECT #2 was resolved in SELECT #1
1014+
Note 1003 select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,(select count(distinct `test`.`t1`.`i`) AS `COUNT(DISTINCT i)` from `test`.`t1` where (`test`.`t1`.`v` = `test`.`t2`.`v`)) AS `subsel` from `test`.`t2`
1015+
DROP TABLE t1,t2;
1016+
End of 5.6 tests

0 commit comments

Comments
 (0)