Skip to content

Commit c6d29cd

Browse files
author
Jan Lindström
committed
Merge branch '10.1' of github.com:MariaDB/server into 10.1
2 parents 3e59948 + be885eb commit c6d29cd

17 files changed

+263
-168
lines changed

CMakeLists.txt

Lines changed: 26 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -175,72 +175,21 @@ OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
175175
MARK_AS_ADVANCED(CYBOZU)
176176

177177
OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF)
178-
179-
include(CheckCSourceCompiles)
180-
include(CheckCXXSourceCompiles)
181-
# We need some extra FAIL_REGEX patterns
182-
# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link.
183-
MACRO (MY_CHECK_C_COMPILER_FLAG FLAG RESULT)
184-
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
185-
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
186-
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
187-
FAIL_REGEX "argument unused during compilation"
188-
FAIL_REGEX "unsupported .*option"
189-
FAIL_REGEX "unknown .*option"
190-
FAIL_REGEX "unrecognized .*option"
191-
FAIL_REGEX "ignoring unknown option"
192-
FAIL_REGEX "[Ww]arning: [Oo]ption"
193-
)
194-
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
195-
ENDMACRO()
196-
197-
MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT)
198-
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
199-
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
200-
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
201-
FAIL_REGEX "argument unused during compilation"
202-
FAIL_REGEX "unsupported .*option"
203-
FAIL_REGEX "unknown .*option"
204-
FAIL_REGEX "unrecognized .*option"
205-
FAIL_REGEX "ignoring unknown option"
206-
FAIL_REGEX "[Ww]arning: [Oo]ption"
207-
)
208-
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
209-
ENDMACRO()
178+
179+
INCLUDE(check_compiler_flag)
210180

211181
OPTION(WITH_ASAN "Enable address sanitizer" OFF)
212182
IF (WITH_ASAN)
213183
# gcc 4.8.1 and new versions of clang
214-
MY_CHECK_C_COMPILER_FLAG("-fsanitize=address" HAVE_C_FSANITIZE)
215-
MY_CHECK_CXX_COMPILER_FLAG("-fsanitize=address" HAVE_CXX_FSANITIZE)
216-
184+
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -O1 -Wno-error -fPIC"
185+
DEBUG RELWITHDEBINFO)
217186
IF(HAVE_C_FSANITIZE AND HAVE_CXX_FSANITIZE)
218-
# We switch on basic optimization also for debug builds.
219-
# With optimization we may get some warnings, so we switch off -Werror
220-
SET(CMAKE_C_FLAGS_DEBUG
221-
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC")
222-
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
223-
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC")
224-
SET(CMAKE_CXX_FLAGS_DEBUG
225-
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC")
226-
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
227-
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC")
228187
SET(WITH_ASAN_OK 1)
229188
ELSE()
230189
# older versions of clang
231-
MY_CHECK_C_COMPILER_FLAG("-faddress-sanitizer" HAVE_C_FADDRESS)
232-
MY_CHECK_CXX_COMPILER_FLAG("-faddress-sanitizer" HAVE_CXX_FFADDRESS)
233-
234-
IF(HAVE_C_FADDRESS AND HAVE_CXX_FFADDRESS)
235-
# We switch on basic optimization also for debug builds.
236-
SET(CMAKE_C_FLAGS_DEBUG
237-
"${CMAKE_C_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC")
238-
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
239-
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC")
240-
SET(CMAKE_CXX_FLAGS_DEBUG
241-
"${CMAKE_CXX_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC")
242-
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
243-
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC")
190+
MY_CHECK_AND_SET_COMPILER_FLAG("-faddress-sanitizer -O1 -fPIC"
191+
DEBUG RELWITHDEBINFO)
192+
IF(HAVE_C_FADDRESS AND HAVE_CXX_FADDRESS)
244193
SET(WITH_ASAN_OK 1)
245194
ENDIF()
246195
ENDIF()
@@ -250,6 +199,22 @@ IF (WITH_ASAN)
250199
ENDIF()
251200
ENDIF()
252201

202+
# enable security hardening features, like most distributions do
203+
# in our benchmarks that costs about ~1% of performance, depending on the load
204+
OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ON)
205+
IF(SECURITY_HARDENED)
206+
# security-enhancing flags
207+
MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
208+
MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
209+
MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")
210+
211+
# sometimes _FORTIFY_SOURCE is predefined
212+
INCLUDE(CheckSymbolExists)
213+
CHECK_SYMBOL_EXISTS(_FORTIFY_SOURCE "" HAVE_FORTIFY_SOURCE)
214+
IF(NOT HAVE_FORTIFY_SOURCE)
215+
ADD_DEFINITIONS(-D_FORTIFY_SOURCE=2)
216+
ENDIF()
217+
ENDIF()
253218

254219
OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON)
255220
IF(ENABLE_DEBUG_SYNC)
@@ -258,15 +223,11 @@ IF(ENABLE_DEBUG_SYNC)
258223
ENDIF()
259224

260225
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)
261-
IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
262-
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
263-
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
264-
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov")
226+
IF (ENABLE_GCOV)
227+
MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG)
265228
ENDIF()
266229

267-
MY_CHECK_C_COMPILER_FLAG(-ggdb3 HAVE_GGDB3)
268-
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3")
269-
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
230+
MY_CHECK_AND_SET_COMPILER_FLAG(-ggdb3 DEBUG)
270231

271232
OPTION(ENABLED_LOCAL_INFILE
272233
"If we should should enable LOAD DATA LOCAL by default" ${IF_WIN})

cmake/check_compiler_flag.cmake

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
include(CheckCSourceCompiles)
2+
include(CheckCXXSourceCompiles)
3+
# We need some extra FAIL_REGEX patterns
4+
# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link.
5+
SET(fail_patterns
6+
FAIL_REGEX "argument unused during compilation"
7+
FAIL_REGEX "unsupported .*option"
8+
FAIL_REGEX "unknown .*option"
9+
FAIL_REGEX "unrecognized .*option"
10+
FAIL_REGEX "ignoring unknown option"
11+
FAIL_REGEX "warning:.*ignored"
12+
FAIL_REGEX "[Ww]arning: [Oo]ption"
13+
)
14+
15+
MACRO (MY_CHECK_C_COMPILER_FLAG flag result)
16+
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
17+
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
18+
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result}
19+
${fail_patterns})
20+
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
21+
ENDMACRO()
22+
23+
MACRO (MY_CHECK_CXX_COMPILER_FLAG flag result)
24+
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
25+
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
26+
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result}
27+
${fail_patterns})
28+
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
29+
ENDMACRO()
30+
31+
FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag)
32+
# At the moment this is gcc-only.
33+
# Let's avoid expensive compiler tests on Windows:
34+
IF(WIN32)
35+
RETURN()
36+
ENDIF()
37+
MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag})
38+
MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag})
39+
IF (HAVE_C_${flag} AND HAVE_CXX_${flag})
40+
IF(ARGN)
41+
FOREACH(type ${ARGN})
42+
SET(CMAKE_C_FLAGS_${type} "${CMAKE_C_FLAGS_${type}} ${flag}" PARENT_SCOPE)
43+
SET(CMAKE_CXX_FLAGS_${type} "${CMAKE_CXX_FLAGS_${type}} ${flag}" PARENT_SCOPE)
44+
ENDFOREACH()
45+
ELSE()
46+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
47+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
48+
ENDIF()
49+
ENDIF()
50+
ENDFUNCTION()
51+

cmake/install_macros.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,7 @@ FUNCTION(INSTALL_SCRIPT)
124124
SET(COMP)
125125
ENDIF()
126126

127-
INSTALL(FILES
128-
${script}
129-
DESTINATION ${ARG_DESTINATION}
130-
PERMISSIONS OWNER_READ OWNER_WRITE
131-
OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
132-
WORLD_READ WORLD_EXECUTE ${COMP}
133-
)
127+
INSTALL(PROGRAMS ${script} DESTINATION ${ARG_DESTINATION} ${COMP})
134128
INSTALL_MANPAGE(${script})
135129
ENDFUNCTION()
136130

cmake/os/Windows.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ INCLUDE (CheckCXXSourceCompiles)
2020
INCLUDE (CheckStructHasMember)
2121
INCLUDE (CheckLibraryExists)
2222
INCLUDE (CheckFunctionExists)
23-
INCLUDE (CheckCCompilerFlag)
2423
INCLUDE (CheckCSourceRuns)
2524
INCLUDE (CheckSymbolExists)
2625
INCLUDE (CheckTypeSize)

cmake/os/WindowsCache.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,5 +370,4 @@ SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
370370
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
371371
SET(HAVE_UCONTEXT_H CACHE INTERNAL "")
372372
SET(HAVE_SOCKPEERCRED CACHE INTERNAL "")
373-
SET(HAVE_GGDB3 CACHE INTERNAL "")
374373
ENDIF(MSVC)

mysql-test/r/analyze_stmt.result

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1616
# ANALYZE DELETE will delete rows:
1717
analyze delete from t1 where a in (2,3,4);
1818
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
19-
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
19+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
2020
select * from t1;
2121
a
2222
0
@@ -32,7 +32,7 @@ create table t1(a int, b int);
3232
insert into t1 select a,a from t0;
3333
analyze update t1 set b=100+b where a in (6,7,8);
3434
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
35-
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
35+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
3636
select * from t1;
3737
a b
3838
0 0
@@ -197,3 +197,57 @@ select * from t1;
197197
a b
198198
6 6
199199
drop table t0, t1;
200+
#
201+
# MDEV-6393: ANALYZE SELECT crashes in Explain_query::print_explain with a non-existing column
202+
#
203+
create table t1 (i int);
204+
insert into t1 values (1),(2);
205+
analyze select a from t1;
206+
ERROR 42S22: Unknown column 'a' in 'field list'
207+
analyze delete from t1 where a=2;
208+
ERROR 42S22: Unknown column 'a' in 'where clause'
209+
analyze update t1 set a=2;
210+
ERROR 42S22: Unknown column 'a' in 'field list'
211+
create table t2 like t1;
212+
insert into t2 select * from t1;
213+
analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
214+
ERROR 42S22: Unknown column 't2.a' in 'where clause'
215+
analyze delete t1 from t2,t1 where t2.a=t1.a;
216+
ERROR 42S22: Unknown column 't2.a' in 'where clause'
217+
drop table t1, t2;
218+
#
219+
# MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
220+
#
221+
create table t1 (a int, b int, key(a));
222+
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
223+
analyze delete from t1 where 1 > 2;
224+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
225+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
226+
analyze delete from t1 where a > 30 and a < 10;
227+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
228+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
229+
analyze update t1 set b=12345 where 1 > 2;
230+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
231+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
232+
analyze update t1 set b=12345 where a > 30 and a < 10;
233+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
234+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
235+
drop table t1;
236+
#
237+
# MDEV-6398: ANALYZE UPDATE does not populate r_rows
238+
#
239+
create table t1 (i int);
240+
insert into t1 values (1),(2),(3),(4);
241+
analyze update t1 set i=8;
242+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
243+
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4 100.00 100.00
244+
drop table t1;
245+
#
246+
# Check ANALYZE SELECT INTO
247+
#
248+
create table t1 (i int);
249+
insert into t1 values (1);
250+
analyze select * from t1 into @var;
251+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
252+
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL
253+
drop table t1;

mysql-test/t/analyze_stmt.test

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Tests for "ANALYZE $statement" feature (PostgreSQL's analog is called EXPLAIN ANALYZE)
2+
# Tests for "ANALYZE $statement" feature
33
#
44
--disable_warnings
55
drop table if exists t0,t1,t2,t3;
@@ -146,3 +146,55 @@ select * from t1;
146146

147147
drop table t0, t1;
148148

149+
--echo #
150+
--echo # MDEV-6393: ANALYZE SELECT crashes in Explain_query::print_explain with a non-existing column
151+
--echo #
152+
create table t1 (i int);
153+
insert into t1 values (1),(2);
154+
--error ER_BAD_FIELD_ERROR
155+
analyze select a from t1;
156+
157+
--error ER_BAD_FIELD_ERROR
158+
analyze delete from t1 where a=2;
159+
160+
--error ER_BAD_FIELD_ERROR
161+
analyze update t1 set a=2;
162+
163+
create table t2 like t1;
164+
insert into t2 select * from t1;
165+
166+
--error ER_BAD_FIELD_ERROR
167+
analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
168+
169+
--error ER_BAD_FIELD_ERROR
170+
analyze delete t1 from t2,t1 where t2.a=t1.a;
171+
172+
drop table t1, t2;
173+
--echo #
174+
--echo # MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
175+
--echo #
176+
create table t1 (a int, b int, key(a));
177+
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
178+
179+
analyze delete from t1 where 1 > 2;
180+
analyze delete from t1 where a > 30 and a < 10;
181+
182+
analyze update t1 set b=12345 where 1 > 2;
183+
analyze update t1 set b=12345 where a > 30 and a < 10;
184+
185+
drop table t1;
186+
--echo #
187+
--echo # MDEV-6398: ANALYZE UPDATE does not populate r_rows
188+
--echo #
189+
create table t1 (i int);
190+
insert into t1 values (1),(2),(3),(4);
191+
analyze update t1 set i=8;
192+
drop table t1;
193+
194+
--echo #
195+
--echo # Check ANALYZE SELECT INTO
196+
--echo #
197+
create table t1 (i int);
198+
insert into t1 values (1);
199+
analyze select * from t1 into @var;
200+
drop table t1;

packaging/solaris/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ FOREACH(script postinstall-solaris)
3030
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh
3131
${CMAKE_CURRENT_BINARY_DIR}/${script} COPYONLY )
3232

33-
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${script}
34-
DESTINATION ${inst_location}/solaris COMPONENT Server_Scripts
35-
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
33+
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script}
34+
DESTINATION ${inst_location}/solaris COMPONENT Server_Scripts)
3635
ENDFOREACH()

sql/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,5 @@ ENDIF(WIN32)
364364

365365
INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
366366
FILES_MATCHING PATTERN "*.h"
367-
PATTERN examples EXCLUDE
368367
PATTERN share EXCLUDE
369368
PATTERN CMakeFiles EXCLUDE)

sql/examples/CMakeLists.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)