Commit f421d8f5 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.8 into 10.9

parents 707f2aa2 3a66c015
...@@ -324,7 +324,14 @@ ENDIF() ...@@ -324,7 +324,14 @@ ENDIF()
CHECK_FUNCTION_EXISTS (accept4 HAVE_ACCEPT4) CHECK_FUNCTION_EXISTS (accept4 HAVE_ACCEPT4)
CHECK_FUNCTION_EXISTS (access HAVE_ACCESS) CHECK_FUNCTION_EXISTS (access HAVE_ACCESS)
CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM) CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM)
CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC) IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT WITH_ASAN)
# When an old custom memory allocator library is used, aligned_alloc()
# could invoke the built-in allocator in libc, not matching
# the overriden free() in the custom memory allocator.
SET(HAVE_ALIGNED_ALLOC 0)
ELSE()
CHECK_FUNCTION_EXISTS (aligned_alloc HAVE_ALIGNED_ALLOC)
ENDIF()
SET(HAVE_ALLOCA 1) SET(HAVE_ALLOCA 1)
CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE) CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE)
CHECK_FUNCTION_EXISTS (backtrace_symbols HAVE_BACKTRACE_SYMBOLS) CHECK_FUNCTION_EXISTS (backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
......
...@@ -14,12 +14,19 @@ ...@@ -14,12 +14,19 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifdef HAVE_ALIGNED_ALLOC
#elif defined __linux__
# include <malloc.h>
#endif
inline void *aligned_malloc(size_t size, size_t alignment) inline void *aligned_malloc(size_t size, size_t alignment)
{ {
#ifdef _WIN32 #ifdef _WIN32
return _aligned_malloc(size, alignment); return _aligned_malloc(size, alignment);
#elif defined HAVE_ALIGNED_ALLOC #elif defined HAVE_ALIGNED_ALLOC
return aligned_alloc(alignment, size); return aligned_alloc(alignment, size);
#elif defined __linux__
return memalign(alignment, size);
#else #else
void *result; void *result;
if (posix_memalign(&result, alignment, size)) if (posix_memalign(&result, alignment, size))
......
...@@ -8322,3 +8322,34 @@ histogram ...@@ -8322,3 +8322,34 @@ histogram
] ]
} }
drop table t1; drop table t1;
#
# MDEV-28882: Assertion `tmp >= 0' failed in best_access_path
#
CREATE TABLE t1 (a varchar(1));
INSERT INTO t1 VALUES ('o'),('s'),('j'),('s'),('y'),('s'),('l'),
('q'),('x'),('m'),('t'),('d'),('v'),('j'),('p'),('t'),('b'),('q');
set histogram_type=json_hb;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# filtered must not be negative:
explain format=json select * from t1 where a > 'y';
EXPLAIN
{
"query_block": {
"select_id": 1,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 18,
"filtered": 5.555555344,
"attached_condition": "t1.a > 'y'"
}
}
]
}
}
drop table t1;
...@@ -460,3 +460,19 @@ from mysql.column_stats where table_name='t1' and db_name=database(); ...@@ -460,3 +460,19 @@ from mysql.column_stats where table_name='t1' and db_name=database();
drop table t1; drop table t1;
--echo #
--echo # MDEV-28882: Assertion `tmp >= 0' failed in best_access_path
--echo #
CREATE TABLE t1 (a varchar(1));
INSERT INTO t1 VALUES ('o'),('s'),('j'),('s'),('y'),('s'),('l'),
('q'),('x'),('m'),('t'),('d'),('v'),('j'),('p'),('t'),('b'),('q');
set histogram_type=json_hb;
analyze table t1 persistent for all;
--echo # filtered must not be negative:
explain format=json select * from t1 where a > 'y';
drop table t1;
...@@ -959,9 +959,16 @@ std::string& Histogram_json_hb::get_end_value(int idx) ...@@ -959,9 +959,16 @@ std::string& Histogram_json_hb::get_end_value(int idx)
@param field The table field histogram is for. We don't care about the @param field The table field histogram is for. We don't care about the
field's current value, we only need its virtual functions to field's current value, we only need its virtual functions to
perform various operations perform various operations
@param min_endp Left endpoint, or NULL if there is none @param min_endp Left endpoint, or NULL if there is none
@param max_endp Right endpoint, or NULL if there is none @param max_endp Right endpoint, or NULL if there is none
@param avg_sel Average selectivity of "field=const" equality for this field
@return
Range selectivity: a number between 0.0 and 1.0.
@note
This may return 0.0. Adjustments to avoid multiply-by-zero meltdown are
made elsewhere.
*/ */
double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp, double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp,
...@@ -1062,6 +1069,18 @@ double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp, ...@@ -1062,6 +1069,18 @@ double Histogram_json_hb::range_selectivity(Field *field, key_range *min_endp,
else else
max= 1.0; max= 1.0;
if (min > max)
{
/*
This can happen due to rounding errors.
What is the acceptable error size? Json_writer::add_double() uses
%.11lg format. This gives 9 digits after the dot. A histogram may have
hundreds of buckets, let's multiply the error by 1000. 9-3=6
*/
DBUG_ASSERT(max < min + 1e-6);
max= min;
}
return max - min; return max - min;
} }
......
...@@ -544,9 +544,19 @@ static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot) ...@@ -544,9 +544,19 @@ static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot)
buffer be bigger than input buffer. Adjust the allocated size. */ buffer be bigger than input buffer. Adjust the allocated size. */
ulint size= srv_page_size; ulint size= srv_page_size;
if (provider_service_lzo->is_loaded) if (provider_service_lzo->is_loaded)
size+= LZO1X_1_15_MEM_COMPRESS; {
size= LZO1X_1_15_MEM_COMPRESS;
#ifdef HAVE_ALIGNED_ALLOC
size= MY_ALIGN(size, srv_page_size);
#endif
}
else if (provider_service_snappy->is_loaded) else if (provider_service_snappy->is_loaded)
{
size= snappy_max_compressed_length(size); size= snappy_max_compressed_length(size);
#ifdef HAVE_ALIGNED_ALLOC
size= MY_ALIGN(size, srv_page_size);
#endif
}
slot->comp_buf= static_cast<byte*>(aligned_malloc(size, srv_page_size)); slot->comp_buf= static_cast<byte*>(aligned_malloc(size, srv_page_size));
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <pfs_global.h> #include <pfs_global.h>
#include <string.h> #include <string.h>
#include "aligned.h" #include "aligned.h"
#include "assume_aligned.h"
bool pfs_initialized= false; bool pfs_initialized= false;
size_t pfs_allocated_memory_size= 0; size_t pfs_allocated_memory_size= 0;
...@@ -47,9 +48,10 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf) ...@@ -47,9 +48,10 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf)
if (--stub_alloc_fails_after_count <= 0) if (--stub_alloc_fails_after_count <= 0)
return NULL; return NULL;
size= MY_ALIGN(size, CPU_LEVEL1_DCACHE_LINESIZE);
void *ptr= aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE); void *ptr= aligned_malloc(size, CPU_LEVEL1_DCACHE_LINESIZE);
if (ptr != NULL) if (ptr != NULL)
memset(ptr, 0, size); memset_aligned<CPU_LEVEL1_DCACHE_LINESIZE>(ptr, 0, size);
return ptr; return ptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment