diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake index e1c764692bc..9eccdd90c34 100644 --- a/cmake/os/FreeBSD.cmake +++ b/cmake/os/FreeBSD.cmake @@ -28,3 +28,6 @@ SET(EXECINFO_ROOT /usr/local CACHE INTERNAL "Where to find execinfo library and INCLUDE_DIRECTORIES(${EXECINFO_ROOT}/include) SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${EXECINFO_ROOT}/include) SET(ENV{LIB} "$ENV{LIB}:${EXECINFO_ROOT}/lib") + +# For all userspace dependencies +LINK_DIRECTORIES(/usr/local/lib) diff --git a/include/my_cpu.h b/include/my_cpu.h index e536ff285f9..003087dd94d 100644 --- a/include/my_cpu.h +++ b/include/my_cpu.h @@ -24,6 +24,7 @@ */ #ifdef _ARCH_PWR8 +#ifdef __GLIBC__ #include /* Very low priority */ #define HMT_very_low() __ppc_set_ppr_very_low() @@ -37,6 +38,18 @@ #define HMT_medium_high() __ppc_set_ppr_med_high() /* High priority */ #define HMT_high() asm volatile("or 3,3,3") +#else /* GLIBC */ +#if defined(__FreeBSD__) +#include +#include +#endif +#define HMT_very_low() __asm__ volatile ("or 31,31,31") +#define HMT_low() __asm__ volatile ("or 1,1,1") +#define HMT_medium_low() __asm__ volatile ("or 6,6,6") +#define HMT_medium() __asm__ volatile ("or 2,2,2") +#define HMT_medium_high() __asm__ volatile ("or 5,5,5") +#define HMT_high() asm volatile("or 3,3,3") +#endif /* GLIBC */ #else #define HMT_very_low() #define HMT_low() @@ -81,7 +94,13 @@ static inline void MY_RELAX_CPU(void) __asm__ __volatile__ ("pause"); #endif #elif defined(_ARCH_PWR8) - __ppc_get_timebase(); +#ifdef __FreeBSD__ + uint64_t __tb; + __asm__ volatile ("mfspr %0, 268" : "=r" (__tb)); +#else + /* Changed from __ppc_get_timebase for musl compatibility */ + __builtin_ppc_get_timebase(); +#endif #elif defined __GNUC__ && (defined __arm__ || defined __aarch64__) /* Mainly, prevent the compiler from optimizing away delay loops */ __asm__ __volatile__ ("":::"memory"); diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index e647c89b740..c5b1a744ebf 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -90,6 +90,243 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1; # End of 10.4 tests # +# MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1 +# +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); +PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +id value +1 1 +2 1 +3 NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +# Memory leak also could take place on running the DELETE statement +# with the LIMIT clause. Check it. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); +CREATE PROCEDURE p1(p1 INT) +DELETE FROM t1 LIMIT p1; +CALL p1(0); +CALL p1(1); +CALL p1(2); +# Clean up +DROP TABLE t1; +DROP PROCEDURE p1; +# +# MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning +# +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +id value +1 10 +2 10 +3 10 +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (null,1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +select * from t1; +a +1 +2 +1 +3 +deallocate prepare stmt; +drop table t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (null,1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using buffer +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +select * from t1; +a +1 +2 +3 +4 +deallocate prepare stmt; +drop table t1, t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +execute stmt using @var1, @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +deallocate prepare stmt; +DROP TABLE t1,t2; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); +CREATE PROCEDURE p1(p1 INT) +EXPLAIN DELETE FROM t1 LIMIT p1; +CALL p1(0); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +CALL p1(1); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +CALL p1(2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +# Clean up +DROP TABLE t1; +DROP PROCEDURE p1; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +select * from t1; +a +1 +2 +3 +deallocate prepare stmt; +drop table t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?'; +execute stmt using @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +select * from t1; +a +1 +2 +3 +4 +deallocate prepare stmt; +drop table t1, t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +execute stmt using @var1, @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL 3 Deleting all rows +deallocate prepare stmt; +DROP TABLE t1,t2; +# +# MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON +# +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?"; +EXECUTE stmt USING 0; +EXECUTE stmt USING 1; +DROP TABLE t; +# End of 10.5 tests +# # MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT # CREATE OR REPLACE TABLE t1(a INT); diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index 16a46596c94..b7d560e2016 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -5,6 +5,7 @@ # The cmake option -DWITH_PROTECT_STATEMENT_MEMROOT is used only # for debug build --source include/have_debug.inc +--source include/have_partition.inc --echo # --echo # MDEV-32369: Memory leak when executing PS for query with IN subquery @@ -111,6 +112,219 @@ DROP TABLE t1; --echo # End of 10.4 tests +--echo # +--echo # MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1 +--echo # +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); + +PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; + +--echo # Memory leak also could take place on running the DELETE statement +--echo # with the LIMIT clause. Check it. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); + +CREATE PROCEDURE p1(p1 INT) + DELETE FROM t1 LIMIT p1; + +CALL p1(0); +CALL p1(1); +CALL p1(2); + +--echo # Clean up +DROP TABLE t1; +DROP PROCEDURE p1; + +--echo # +--echo # MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning +--echo # +# same as the first MDEV-34444 testcase but with explain +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); + +PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +# we are testing 2nd ps assertion failure, not explain output, which +# may vary from version to version +--disable_result_log +EXECUTE stmt; +--enable_result_log +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +--disable_result_log +EXECUTE stmt; +--enable_result_log +SELECT * FROM t1; +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; + +# 2nd ps mem leak; partition pruning +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (null,1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# same but with explain +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (null,1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# top level impossible where +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# top level impossible where, with explain +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# Now we do delete instead of update + +# same as the second MDEV-34447 testcase but with explain +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); + +CREATE PROCEDURE p1(p1 INT) + EXPLAIN DELETE FROM t1 LIMIT p1; + +CALL p1(0); +CALL p1(1); +CALL p1(2); + +--echo # Clean up +DROP TABLE t1; +DROP PROCEDURE p1; + +# partition pruning +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# same but with explain +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# top level impossible where +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# top level impossible where, with explain +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON +--echo # + +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); # Optional, fails either way +PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?"; +EXECUTE stmt USING 0; +EXECUTE stmt USING 1; + +# CLeanup +DROP TABLE t; + +--echo # End of 10.5 tests + --echo # --echo # MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT --echo # diff --git a/mysql-test/main/show_check.result b/mysql-test/main/show_check.result index 10f3014a497..01a9c942db2 100644 --- a/mysql-test/main/show_check.result +++ b/mysql-test/main/show_check.result @@ -66,7 +66,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 8 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 8 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 1 N 4097 0 8 def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 8 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 @@ -652,7 +652,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 63 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 63 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 6 N 4097 0 63 def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 63 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 @@ -923,7 +923,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 192 2 N 4097 0 33 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 192 7 N 4097 0 33 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 192 1 N 4097 0 33 def information_schema STATISTICS STATISTICS COLLATION Collation 253 3 1 Y 4096 0 33 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index dbb620ed1df..daa2c7567a1 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -357,7 +357,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) select NEVER NULL def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(3) select NEVER NULL def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(10) select NEVER NULL -def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) select NEVER NULL +def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned select NEVER NULL def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select NEVER NULL def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL @@ -899,7 +899,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1) 3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) -NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2) +NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned 3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8mb3 utf8mb3_general_ci varchar(1) NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index 1f22c67a597..db2427732f2 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -357,7 +357,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) NEVER NULL def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(3) NEVER NULL def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(10) NEVER NULL -def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) NEVER NULL +def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned NEVER NULL def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) NEVER NULL def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL @@ -899,7 +899,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1) 3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) -NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2) +NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned 3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64) 3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8mb3 utf8mb3_general_ci varchar(1) NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21) diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result index 22f72114089..ade13583b71 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics.result +++ b/mysql-test/suite/funcs_1/r/is_statistics.result @@ -34,7 +34,7 @@ TABLE_NAME varchar(64) NO NULL NON_UNIQUE bigint(1) NO NULL INDEX_SCHEMA varchar(64) NO NULL INDEX_NAME varchar(64) NO NULL -SEQ_IN_INDEX bigint(2) NO NULL +SEQ_IN_INDEX int(2) unsigned NO NULL COLUMN_NAME varchar(64) NO NULL COLLATION varchar(1) YES NULL CARDINALITY bigint(21) YES NULL @@ -54,7 +54,7 @@ STATISTICS CREATE TEMPORARY TABLE `STATISTICS` ( `NON_UNIQUE` bigint(1) NOT NULL, `INDEX_SCHEMA` varchar(64) NOT NULL, `INDEX_NAME` varchar(64) NOT NULL, - `SEQ_IN_INDEX` bigint(2) NOT NULL, + `SEQ_IN_INDEX` int(2) unsigned NOT NULL, `COLUMN_NAME` varchar(64) NOT NULL, `COLLATION` varchar(1), `CARDINALITY` bigint(21), @@ -74,7 +74,7 @@ TABLE_NAME varchar(64) NO NULL NON_UNIQUE bigint(1) NO NULL INDEX_SCHEMA varchar(64) NO NULL INDEX_NAME varchar(64) NO NULL -SEQ_IN_INDEX bigint(2) NO NULL +SEQ_IN_INDEX int(2) unsigned NO NULL COLUMN_NAME varchar(64) NO NULL COLLATION varchar(1) YES NULL CARDINALITY bigint(21) YES NULL diff --git a/mysys/crc32/crc32c.cc b/mysys/crc32/crc32c.cc index 6de7af70db7..0d65d0027d4 100644 --- a/mysys/crc32/crc32c.cc +++ b/mysys/crc32/crc32c.cc @@ -455,7 +455,7 @@ static int arch_ppc_probe(void) { return arch_ppc_crc32; } -# elif defined __FreeBSD_version && __FreeBSD_version >= 1200000 +# elif defined __FreeBSD__ # include # include # include diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8c1def600b2..e1fed3c1a0a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -207,7 +207,7 @@ typedef fp_except fp_except_t; inline void setup_fpu() { -#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) +#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) && defined(FP_X_INV) /* We can't handle floating point exceptions with threads, so disable this on freebsd Don't fall for overflow, underflow,divide-by-zero or loss of precision. @@ -220,7 +220,7 @@ inline void setup_fpu() fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP)); #endif /* FP_X_DNML */ -#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT */ +#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT && FP_X_INV */ #ifdef HAVE_FEDISABLEEXCEPT fedisableexcept(FE_ALL_EXCEPT); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4237f7ed271..32c7aae01a0 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -519,6 +519,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (thd->lex->describe || thd->lex->analyze_stmt) goto produce_explain_and_leave; + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd, 0); DBUG_RETURN(0); } @@ -550,6 +556,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, */ if (unlikely(thd->is_error())) DBUG_RETURN(TRUE); + + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd, 0); DBUG_RETURN(0); // Nothing to delete } @@ -924,10 +937,10 @@ cleanup: query_cache_invalidate3(thd, table_list, 1); } - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } delete deltempfile; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d39bcf151c2..4d28c0e843c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1380,10 +1380,10 @@ values_loop_end: ::my_ok(thd, info.copied + info.deleted + updated, id, buff); } thd->abort_on_warning= 0; - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } my_free(readbuff); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c9e71c79bfa..86db0e972eb 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3052,6 +3052,7 @@ void st_select_lex::init_query() first_natural_join_processing= 1; first_cond_optimization= 1; first_rownum_optimization= true; + leaf_tables_saved= false; no_wrap_view_item= 0; exclude_from_table_unique_test= 0; in_tvc= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index ca9a727d35d..ee2d52a3566 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1192,6 +1192,10 @@ public: can be transformed into IN-subselect defined with TVC. */ List in_funcs; + /** + Flag to guard against double initialization of leaf tables list + */ + bool leaf_tables_saved; List leaf_tables; List leaf_tables_exec; List leaf_tables_prep; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3be4adb092f..97193e3e47d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2236,12 +2236,14 @@ JOIN::optimize_inner() add_table_function_dependencies(join_list, table_map(-1)); - if (thd->is_error() || select_lex->save_leaf_tables(thd)) + if (thd->is_error() || + (!select_lex->leaf_tables_saved && select_lex->save_leaf_tables(thd))) { if (arena) thd->restore_active_arena(arena, &backup); DBUG_RETURN(1); } + select_lex->leaf_tables_saved= true; build_bitmap_for_nested_joins(join_list, 0); sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index cc2fb88509a..e66f948c3a3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9416,7 +9416,7 @@ ST_FIELD_INFO stat_fields_info[]= Column("NON_UNIQUE", SLonglong(1),NOT_NULL, "Non_unique", OPEN_FRM_ONLY), Column("INDEX_SCHEMA", Name(), NOT_NULL, OPEN_FRM_ONLY), Column("INDEX_NAME", Name(), NOT_NULL, "Key_name", OPEN_FRM_ONLY), - Column("SEQ_IN_INDEX", SLonglong(2),NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY), + Column("SEQ_IN_INDEX", ULong(2), NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY), Column("COLUMN_NAME", Name(), NOT_NULL, "Column_name", OPEN_FRM_ONLY), Column("COLLATION", Varchar(1), NULLABLE, "Collation", OPEN_FULL_TABLE), Column("CARDINALITY", SLonglong(), NULLABLE, "Cardinality", OPEN_FULL_TABLE), diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 0a83957ec0b..4e6c580be21 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -569,6 +569,12 @@ int mysql_update(THD *thd, if (thd->is_error()) DBUG_RETURN(1); + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd); // No matching records DBUG_RETURN(0); } @@ -599,6 +605,13 @@ int mysql_update(THD *thd, { DBUG_RETURN(1); // Error in where } + + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd); // No matching records DBUG_RETURN(0); } @@ -1373,10 +1386,10 @@ update_end: } thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ thd->abort_on_warning= 0; - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } *found_return= found; *updated_return= updated; diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 899cb592257..87809f6c97b 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -20,6 +20,7 @@ endmacro() IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + SET(PCRE_INCLUDES "${PCRE_INCLUDE_DIRS}") add_subdirectory(columnstore) IF(TARGET columnstore) diff --git a/unittest/sql/my_apc-t.cc b/unittest/sql/my_apc-t.cc index e3f8293ffcb..83f894bedc5 100644 --- a/unittest/sql/my_apc-t.cc +++ b/unittest/sql/my_apc-t.cc @@ -190,6 +190,7 @@ int main(int args, char **argv) pthread_t request_thr[N_THREADS]; int i; + my_mutex_init(); my_thread_global_init(); mysql_mutex_init(0, &apc_counters_mutex, MY_MUTEX_INIT_FAST);