MDEV-21907: Fix some -Wconversion outside InnoDB
Some .c and .cc files are compiled as part of Mariabackup. Enabling -Wconversion for InnoDB would also enable it for Mariabackup. The .h files are being included during InnoDB or Mariabackup compilation. Notably, GCC 5 (but not GCC 4 or 6 or later versions) would report -Wconversion for x|=y when the type is unsigned char. So, we will either write x=(uchar)(x|y) or disable the -Wconversion warning for GCC 5. bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit(), bitmap_is_set(): Always implement as inline functions.
This commit is contained in:
parent
c7920fa8ff
commit
d82ac8d374
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
|
/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
|
||||||
Copyright (c) 2009, 2017, MariaDB Corporation.
|
Copyright (c) 2009, 2020, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -50,7 +50,7 @@ static inline CONSTEXPR uint my_bit_log2_hex_digit(uint8 value)
|
|||||||
}
|
}
|
||||||
static inline CONSTEXPR uint my_bit_log2_uint8(uint8 value)
|
static inline CONSTEXPR uint my_bit_log2_uint8(uint8 value)
|
||||||
{
|
{
|
||||||
return value & 0xF0 ? my_bit_log2_hex_digit(value >> 4) + 4:
|
return value & 0xF0 ? my_bit_log2_hex_digit((uint8) (value >> 4)) + 4:
|
||||||
my_bit_log2_hex_digit(value);
|
my_bit_log2_hex_digit(value);
|
||||||
}
|
}
|
||||||
static inline CONSTEXPR uint my_bit_log2_uint16(uint16 value)
|
static inline CONSTEXPR uint my_bit_log2_uint16(uint16 value)
|
||||||
@ -162,14 +162,13 @@ static inline uchar last_byte_mask(uint bits)
|
|||||||
/* Get the number of used bits-1 (0..7) in the last byte */
|
/* Get the number of used bits-1 (0..7) in the last byte */
|
||||||
unsigned int const used = (bits - 1U) & 7U;
|
unsigned int const used = (bits - 1U) & 7U;
|
||||||
/* Return bitmask for the significant bits */
|
/* Return bitmask for the significant bits */
|
||||||
return ((2U << used) - 1);
|
return (uchar) ((2U << used) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_FIND_FIRST_BIT_END sizeof(ulonglong)*8
|
|
||||||
/*
|
/*
|
||||||
Find the position of the first(least significant) bit set in
|
Find the position of the first(least significant) bit set in
|
||||||
the argument. Returns 64 if the argument was 0.
|
the argument. Returns 64 if the argument was 0.
|
||||||
@ -177,7 +176,7 @@ static inline uchar last_byte_mask(uint bits)
|
|||||||
static inline uint my_find_first_bit(ulonglong n)
|
static inline uint my_find_first_bit(ulonglong n)
|
||||||
{
|
{
|
||||||
if(!n)
|
if(!n)
|
||||||
return MY_FIND_FIRST_BIT_END;
|
return 64;
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
return __builtin_ctzll(n);
|
return __builtin_ctzll(n);
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2001, 2011, Oracle and/or its affiliates.
|
/* Copyright (c) 2001, 2011, Oracle and/or its affiliates.
|
||||||
Copyright (c) 2009-2011, Monty Program Ab
|
Copyright (c) 2009, 2020, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -89,56 +89,35 @@ extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit);
|
|||||||
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
|
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
|
||||||
#define no_words_in_map(map) (((map)->n_bits + 31)/32)
|
#define no_words_in_map(map) (((map)->n_bits + 31)/32)
|
||||||
#define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
|
#define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
|
||||||
#define _bitmap_set_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
/* The following functions must be compatible with create_last_word_mask()! */
|
||||||
|= (1 << ((BIT) & 7)))
|
|
||||||
#define _bitmap_flip_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
||||||
^= (1 << ((BIT) & 7)))
|
|
||||||
#define _bitmap_clear_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
||||||
&= ~ (1 << ((BIT) & 7)))
|
|
||||||
#define _bitmap_is_set(MAP, BIT) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
||||||
& (1 << ((BIT) & 7)))
|
|
||||||
/*
|
|
||||||
WARNING!
|
|
||||||
|
|
||||||
The below symbols are inline functions in DEBUG builds and macros in
|
|
||||||
non-DEBUG builds. The latter evaluate their 'bit' argument twice.
|
|
||||||
|
|
||||||
NEVER use an increment/decrement operator with the 'bit' argument.
|
|
||||||
It would work with DEBUG builds, but fails later in production builds!
|
|
||||||
|
|
||||||
FORBIDDEN: bitmap_set_bit($my_bitmap, (field++)->field_index);
|
|
||||||
*/
|
|
||||||
#ifndef DBUG_OFF
|
|
||||||
static inline void
|
static inline void
|
||||||
bitmap_set_bit(MY_BITMAP *map,uint bit)
|
bitmap_set_bit(MY_BITMAP *map,uint bit)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(bit < (map)->n_bits);
|
uchar *b= (uchar*) map->bitmap + bit / 8;
|
||||||
_bitmap_set_bit(map,bit);
|
DBUG_ASSERT(bit < map->n_bits);
|
||||||
|
*b= (uchar) (*b | 1U << (bit & 7));
|
||||||
}
|
}
|
||||||
static inline void
|
static inline void
|
||||||
bitmap_flip_bit(MY_BITMAP *map,uint bit)
|
bitmap_flip_bit(MY_BITMAP *map,uint bit)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(bit < (map)->n_bits);
|
uchar *b= (uchar*) map->bitmap + bit / 8;
|
||||||
_bitmap_flip_bit(map,bit);
|
DBUG_ASSERT(bit < map->n_bits);
|
||||||
|
*b= (uchar) (*b ^ 1U << (bit & 7));
|
||||||
}
|
}
|
||||||
static inline void
|
static inline void
|
||||||
bitmap_clear_bit(MY_BITMAP *map,uint bit)
|
bitmap_clear_bit(MY_BITMAP *map,uint bit)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(bit < (map)->n_bits);
|
uchar *b= (uchar*) map->bitmap + bit / 8;
|
||||||
_bitmap_clear_bit(map,bit);
|
DBUG_ASSERT(bit < map->n_bits);
|
||||||
|
*b= (uchar) (*b & ~(1U << (bit & 7)));
|
||||||
}
|
}
|
||||||
static inline uint
|
static inline uint
|
||||||
bitmap_is_set(const MY_BITMAP *map,uint bit)
|
bitmap_is_set(const MY_BITMAP *map,uint bit)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(bit < (map)->n_bits);
|
const uchar *b= (const uchar*) map->bitmap + bit / 8;
|
||||||
return _bitmap_is_set(map,bit);
|
DBUG_ASSERT(bit < map->n_bits);
|
||||||
|
return !!(*b & (1U << (bit & 7)));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define bitmap_set_bit(MAP, BIT) _bitmap_set_bit(MAP, BIT)
|
|
||||||
#define bitmap_flip_bit(MAP, BIT) _bitmap_flip_bit(MAP, BIT)
|
|
||||||
#define bitmap_clear_bit(MAP, BIT) _bitmap_clear_bit(MAP, BIT)
|
|
||||||
#define bitmap_is_set(MAP, BIT) _bitmap_is_set(MAP, BIT)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
|
static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2011, Oracle and/or its affiliates.
|
/* Copyright (c) 2011, Oracle and/or its affiliates.
|
||||||
Copyright (c) Monty Program Ab; 1991-2011
|
Copyright (c) 1991, 2020, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -95,15 +95,16 @@ static inline uchar get_rec_bits(const uchar *ptr, uchar ofs, uint len)
|
|||||||
{
|
{
|
||||||
uint16 val= ptr[0];
|
uint16 val= ptr[0];
|
||||||
if (ofs + len > 8)
|
if (ofs + len > 8)
|
||||||
val|= (uint16)(ptr[1]) << 8;
|
val|= (uint16)((uint16)(ptr[1]) << 8);
|
||||||
return (val >> ofs) & ((1 << len) - 1);
|
return (uchar) ((val >> ofs) & ((1 << len) - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
|
static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
|
||||||
{
|
{
|
||||||
ptr[0]= (ptr[0] & ~(((1 << len) - 1) << ofs)) | (bits << ofs);
|
ptr[0]= (uchar) ((ptr[0] & ~(((1 << len) - 1) << ofs)) | (bits << ofs));
|
||||||
if (ofs + len > 8)
|
if (ofs + len > 8)
|
||||||
ptr[1]= (ptr[1] & ~((1 << (len - 8 + ofs)) - 1)) | (bits >> (8 - ofs));
|
ptr[1]= (uchar) ((ptr[1] & ~((1 << (len - 8 + ofs)) - 1)) |
|
||||||
|
bits >> (8 - ofs));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
||||||
|
@ -353,10 +353,10 @@ size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize);
|
|||||||
#endif /* !cmp_timespec */
|
#endif /* !cmp_timespec */
|
||||||
|
|
||||||
#ifndef set_timespec_time_nsec
|
#ifndef set_timespec_time_nsec
|
||||||
#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
|
#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
|
||||||
ulonglong _now_= (NSEC); \
|
ulonglong _now_= (NSEC); \
|
||||||
(ABSTIME).MY_tv_sec= (_now_ / 1000000000ULL); \
|
(ABSTIME).MY_tv_sec= (time_t) (_now_ / 1000000000ULL); \
|
||||||
(ABSTIME).MY_tv_nsec= (_now_ % 1000000000ULL); \
|
(ABSTIME).MY_tv_nsec= (ulong) (_now_ % 1000000000UL); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#endif /* !set_timespec_time_nsec */
|
#endif /* !set_timespec_time_nsec */
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||||
Copyright (c) 2010, 2019, MariaDB Corporation.
|
Copyright (c) 2010, 2020, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -959,7 +959,7 @@ extern ulonglong my_interval_timer(void);
|
|||||||
extern ulonglong my_getcputime(void);
|
extern ulonglong my_getcputime(void);
|
||||||
|
|
||||||
#define microsecond_interval_timer() (my_interval_timer()/1000)
|
#define microsecond_interval_timer() (my_interval_timer()/1000)
|
||||||
#define hrtime_to_time(X) ((X).val/HRTIME_RESOLUTION)
|
#define hrtime_to_time(X) ((time_t)((X).val/HRTIME_RESOLUTION))
|
||||||
#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION))
|
#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION))
|
||||||
#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
|
#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
|
||||||
#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
|
#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
|
||||||
|
@ -411,7 +411,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||||||
mysql->db= saved_db;
|
mysql->db= saved_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
|
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
|
||||||
@ -839,7 +839,8 @@ MYSQL_FIELD *cli_list_fields(MYSQL *mysql)
|
|||||||
|
|
||||||
mysql->field_count= (uint) query->rows;
|
mysql->field_count= (uint) query->rows;
|
||||||
return unpack_fields(mysql, query,&mysql->field_alloc,
|
return unpack_fields(mysql, query,&mysql->field_alloc,
|
||||||
mysql->field_count, 1, mysql->server_capabilities);
|
mysql->field_count, 1,
|
||||||
|
(uint) mysql->server_capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -898,7 +899,7 @@ mysql_list_processes(MYSQL *mysql)
|
|||||||
protocol_41(mysql) ? 7 : 5)))
|
protocol_41(mysql) ? 7 : 5)))
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc,field_count,0,
|
if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc,field_count,0,
|
||||||
mysql->server_capabilities)))
|
(uint) mysql->server_capabilities)))
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
mysql->status=MYSQL_STATUS_GET_RESULT;
|
mysql->status=MYSQL_STATUS_GET_RESULT;
|
||||||
mysql->field_count=field_count;
|
mysql->field_count=field_count;
|
||||||
@ -1488,12 +1489,12 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
|||||||
if (!(fields_data= (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,7)))
|
if (!(fields_data= (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,7)))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
if (!(stmt->fields= unpack_fields(mysql, fields_data,&stmt->mem_root,
|
if (!(stmt->fields= unpack_fields(mysql, fields_data,&stmt->mem_root,
|
||||||
field_count,0,
|
field_count,0,
|
||||||
mysql->server_capabilities)))
|
(uint) mysql->server_capabilities)))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
stmt->field_count= field_count;
|
stmt->field_count= field_count;
|
||||||
stmt->param_count= (ulong) param_count;
|
stmt->param_count= (uint) param_count;
|
||||||
DBUG_PRINT("exit",("field_count: %u param_count: %u warning_count: %u",
|
DBUG_PRINT("exit",("field_count: %u param_count: %u warning_count: %u",
|
||||||
field_count, param_count, (uint) mysql->warning_count));
|
field_count, param_count, (uint) mysql->warning_count));
|
||||||
|
|
||||||
@ -2024,7 +2025,10 @@ static void net_store_datetime(NET *net, MYSQL_TIME *tm)
|
|||||||
static void store_param_date(NET *net, MYSQL_BIND *param)
|
static void store_param_date(NET *net, MYSQL_BIND *param)
|
||||||
{
|
{
|
||||||
MYSQL_TIME tm= *((MYSQL_TIME *) param->buffer);
|
MYSQL_TIME tm= *((MYSQL_TIME *) param->buffer);
|
||||||
tm.hour= tm.minute= tm.second= tm.second_part= 0;
|
tm.hour= 0;
|
||||||
|
tm.minute= 0;
|
||||||
|
tm.second= 0;
|
||||||
|
tm.second_part= 0;
|
||||||
net_store_datetime(net, &tm);
|
net_store_datetime(net, &tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2061,7 +2065,14 @@ static void store_param_str(NET *net, MYSQL_BIND *param)
|
|||||||
static void store_param_null(NET *net, MYSQL_BIND *param)
|
static void store_param_null(NET *net, MYSQL_BIND *param)
|
||||||
{
|
{
|
||||||
uint pos= param->param_number;
|
uint pos= param->param_number;
|
||||||
|
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 5
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 needs this */
|
||||||
|
#endif
|
||||||
net->buff[pos/8]|= (uchar) (1 << (pos & 7));
|
net->buff[pos/8]|= (uchar) (1 << (pos & 7));
|
||||||
|
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 5
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3082,14 +3093,14 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
|
|||||||
static void read_binary_time(MYSQL_TIME *tm, uchar **pos)
|
static void read_binary_time(MYSQL_TIME *tm, uchar **pos)
|
||||||
{
|
{
|
||||||
/* net_field_length will set pos to the first byte of data */
|
/* net_field_length will set pos to the first byte of data */
|
||||||
uint length= net_field_length(pos);
|
ulong length= net_field_length(pos);
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
uchar *to= *pos;
|
uchar *to= *pos;
|
||||||
tm->neg= to[0];
|
tm->neg= to[0];
|
||||||
|
|
||||||
tm->day= (ulong) sint4korr(to+1);
|
tm->day= (uint) sint4korr(to+1);
|
||||||
tm->hour= (uint) to[5];
|
tm->hour= (uint) to[5];
|
||||||
tm->minute= (uint) to[6];
|
tm->minute= (uint) to[6];
|
||||||
tm->second= (uint) to[7];
|
tm->second= (uint) to[7];
|
||||||
@ -3111,7 +3122,7 @@ static void read_binary_time(MYSQL_TIME *tm, uchar **pos)
|
|||||||
|
|
||||||
static void read_binary_datetime(MYSQL_TIME *tm, uchar **pos)
|
static void read_binary_datetime(MYSQL_TIME *tm, uchar **pos)
|
||||||
{
|
{
|
||||||
uint length= net_field_length(pos);
|
ulong length= net_field_length(pos);
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
@ -3141,7 +3152,7 @@ static void read_binary_datetime(MYSQL_TIME *tm, uchar **pos)
|
|||||||
|
|
||||||
static void read_binary_date(MYSQL_TIME *tm, uchar **pos)
|
static void read_binary_date(MYSQL_TIME *tm, uchar **pos)
|
||||||
{
|
{
|
||||||
uint length= net_field_length(pos);
|
ulong length= net_field_length(pos);
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
@ -3382,7 +3393,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
|
|||||||
uchar *end= (uchar*) longlong10_to_str(value, (char*) buff,
|
uchar *end= (uchar*) longlong10_to_str(value, (char*) buff,
|
||||||
is_unsigned ? 10: -10);
|
is_unsigned ? 10: -10);
|
||||||
/* Resort to string conversion which supports all typecodes */
|
/* Resort to string conversion which supports all typecodes */
|
||||||
uint length= (uint) (end-buff);
|
size_t length= end-buff;
|
||||||
|
|
||||||
if (field->flags & ZEROFILL_FLAG && length < field->length &&
|
if (field->flags & ZEROFILL_FLAG && length < field->length &&
|
||||||
field->length < 21)
|
field->length < 21)
|
||||||
@ -3906,8 +3917,10 @@ static my_bool is_binary_compatible(enum enum_field_types type1,
|
|||||||
my_bool type1_found= FALSE, type2_found= FALSE;
|
my_bool type1_found= FALSE, type2_found= FALSE;
|
||||||
for (type= *range; *type != MYSQL_TYPE_NULL; type++)
|
for (type= *range; *type != MYSQL_TYPE_NULL; type++)
|
||||||
{
|
{
|
||||||
type1_found|= type1 == *type;
|
if (type1 == *type)
|
||||||
type2_found|= type2 == *type;
|
type1_found= TRUE;
|
||||||
|
if (type2 == *type)
|
||||||
|
type2_found= TRUE;
|
||||||
}
|
}
|
||||||
if (type1_found || type2_found)
|
if (type1_found || type2_found)
|
||||||
return type1_found && type2_found;
|
return type1_found && type2_found;
|
||||||
|
11
sql/field.h
11
sql/field.h
@ -1369,7 +1369,7 @@ public:
|
|||||||
void set_null_ptr(uchar *p_null_ptr, uint p_null_bit)
|
void set_null_ptr(uchar *p_null_ptr, uint p_null_bit)
|
||||||
{
|
{
|
||||||
null_ptr= p_null_ptr;
|
null_ptr= p_null_ptr;
|
||||||
null_bit= p_null_bit;
|
null_bit= static_cast<uchar>(p_null_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool stored_in_db() const { return !vcol_info || vcol_info->stored_in_db; }
|
bool stored_in_db() const { return !vcol_info || vcol_info->stored_in_db; }
|
||||||
@ -4921,7 +4921,8 @@ public:
|
|||||||
explicitly using the field_length.
|
explicitly using the field_length.
|
||||||
*/
|
*/
|
||||||
return Binlog_type_info(type(),
|
return Binlog_type_info(type(),
|
||||||
field_length % 8 + ((field_length / 8) << 8), 2);
|
static_cast<uint16>((field_length & 7) |
|
||||||
|
((field_length / 8) << 8)), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -5558,9 +5559,9 @@ public:
|
|||||||
uint32 max_char_length(CHARSET_INFO *cs) const
|
uint32 max_char_length(CHARSET_INFO *cs) const
|
||||||
{
|
{
|
||||||
return type_handler()->field_type() >= MYSQL_TYPE_TINY_BLOB &&
|
return type_handler()->field_type() >= MYSQL_TYPE_TINY_BLOB &&
|
||||||
type_handler()->field_type() <= MYSQL_TYPE_BLOB ?
|
type_handler()->field_type() <= MYSQL_TYPE_BLOB
|
||||||
length / cs->mbminlen :
|
? static_cast<uint32>(length / cs->mbminlen)
|
||||||
length / cs->mbmaxlen;
|
: static_cast<uint32>(length / cs->mbmaxlen);
|
||||||
}
|
}
|
||||||
uint32 max_octet_length(CHARSET_INFO *from, CHARSET_INFO *to) const
|
uint32 max_octet_length(CHARSET_INFO *from, CHARSET_INFO *to) const
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define HANDLER_INCLUDED
|
#define HANDLER_INCLUDED
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
|
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
|
||||||
Copyright (c) 2009, 2019, MariaDB
|
Copyright (c) 2009, 2020, MariaDB
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
@ -2664,18 +2664,18 @@ public:
|
|||||||
double idx_cpu_cost; /* cost of operations in CPU for index */
|
double idx_cpu_cost; /* cost of operations in CPU for index */
|
||||||
double import_cost; /* cost of remote operations */
|
double import_cost; /* cost of remote operations */
|
||||||
double mem_cost; /* cost of used memory */
|
double mem_cost; /* cost of used memory */
|
||||||
|
|
||||||
enum { IO_COEFF=1 };
|
static constexpr double IO_COEFF= 1;
|
||||||
enum { CPU_COEFF=1 };
|
static constexpr double CPU_COEFF= 1;
|
||||||
enum { MEM_COEFF=1 };
|
static constexpr double MEM_COEFF= 1;
|
||||||
enum { IMPORT_COEFF=1 };
|
static constexpr double IMPORT_COEFF= 1;
|
||||||
|
|
||||||
Cost_estimate()
|
Cost_estimate()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
double total_cost()
|
double total_cost() const
|
||||||
{
|
{
|
||||||
return IO_COEFF*io_count*avg_io_cost +
|
return IO_COEFF*io_count*avg_io_cost +
|
||||||
IO_COEFF*idx_io_count*idx_avg_io_cost +
|
IO_COEFF*idx_io_count*idx_avg_io_cost +
|
||||||
@ -2696,7 +2696,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool is_zero() const
|
bool is_zero() const
|
||||||
{
|
{
|
||||||
return io_count == 0.0 && idx_io_count && cpu_cost == 0.0 &&
|
return io_count == 0.0 && idx_io_count == 0.0 && cpu_cost == 0.0 &&
|
||||||
import_cost == 0.0 && mem_cost == 0.0;
|
import_cost == 0.0 && mem_cost == 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2719,7 +2719,7 @@ public:
|
|||||||
|
|
||||||
void add(const Cost_estimate* cost)
|
void add(const Cost_estimate* cost)
|
||||||
{
|
{
|
||||||
if (cost->io_count)
|
if (cost->io_count != 0.0)
|
||||||
{
|
{
|
||||||
double io_count_sum= io_count + cost->io_count;
|
double io_count_sum= io_count + cost->io_count;
|
||||||
avg_io_cost= (io_count * avg_io_cost +
|
avg_io_cost= (io_count * avg_io_cost +
|
||||||
@ -2727,7 +2727,7 @@ public:
|
|||||||
/io_count_sum;
|
/io_count_sum;
|
||||||
io_count= io_count_sum;
|
io_count= io_count_sum;
|
||||||
}
|
}
|
||||||
if (cost->idx_io_count)
|
if (cost->idx_io_count != 0.0)
|
||||||
{
|
{
|
||||||
double idx_io_count_sum= idx_io_count + cost->idx_io_count;
|
double idx_io_count_sum= idx_io_count + cost->idx_io_count;
|
||||||
idx_avg_io_cost= (idx_io_count * idx_avg_io_cost +
|
idx_avg_io_cost= (idx_io_count * idx_avg_io_cost +
|
||||||
|
@ -411,7 +411,6 @@ my_bool net_flush(NET *net)
|
|||||||
my_bool my_net_write(NET *net, const uchar *packet, size_t len)
|
my_bool my_net_write(NET *net, const uchar *packet, size_t len)
|
||||||
{
|
{
|
||||||
uchar buff[NET_HEADER_SIZE];
|
uchar buff[NET_HEADER_SIZE];
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (unlikely(!net->vio)) /* nowhere to write */
|
if (unlikely(!net->vio)) /* nowhere to write */
|
||||||
return 0;
|
return 0;
|
||||||
@ -448,7 +447,7 @@ my_bool my_net_write(NET *net, const uchar *packet, size_t len)
|
|||||||
#ifndef DEBUG_DATA_PACKETS
|
#ifndef DEBUG_DATA_PACKETS
|
||||||
DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
|
DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
|
||||||
#endif
|
#endif
|
||||||
rc= MY_TEST(net_write_buff(net, packet, len));
|
my_bool rc= MY_TEST(net_write_buff(net, packet, len));
|
||||||
MYSQL_NET_WRITE_DONE(rc);
|
MYSQL_NET_WRITE_DONE(rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -489,7 +488,7 @@ net_write_command(NET *net,uchar command,
|
|||||||
size_t length=len+1+head_len; /* 1 extra byte for command */
|
size_t length=len+1+head_len; /* 1 extra byte for command */
|
||||||
uchar buff[NET_HEADER_SIZE+1];
|
uchar buff[NET_HEADER_SIZE+1];
|
||||||
uint header_size=NET_HEADER_SIZE+1;
|
uint header_size=NET_HEADER_SIZE+1;
|
||||||
int rc;
|
my_bool rc;
|
||||||
DBUG_ENTER("net_write_command");
|
DBUG_ENTER("net_write_command");
|
||||||
DBUG_PRINT("enter",("length: %lu", (ulong) len));
|
DBUG_PRINT("enter",("length: %lu", (ulong) len));
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2015 MariaDB Corporation Ab
|
Copyright (c) 2015, 2020, MariaDB Corporation.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -90,7 +90,8 @@ public:
|
|||||||
double get_time_ms() const
|
double get_time_ms() const
|
||||||
{
|
{
|
||||||
// convert 'cycles' to milliseconds.
|
// convert 'cycles' to milliseconds.
|
||||||
return 1000 * ((double)cycles) / sys_timer_info.cycles.frequency;
|
return 1000.0 * static_cast<double>(cycles) /
|
||||||
|
static_cast<double>(sys_timer_info.cycles.frequency);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,7 +115,8 @@ public:
|
|||||||
double get_time_ms() const
|
double get_time_ms() const
|
||||||
{
|
{
|
||||||
// convert 'cycles' to milliseconds.
|
// convert 'cycles' to milliseconds.
|
||||||
return 1000 * ((double)cycles) / sys_timer_info.cycles.frequency;
|
return 1000.0 * static_cast<double>(cycles) /
|
||||||
|
static_cast<double>(sys_timer_info.cycles.frequency);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,24 +180,23 @@ public:
|
|||||||
ha_rows r_rows; /* How many rows we've got after that */
|
ha_rows r_rows; /* How many rows we've got after that */
|
||||||
ha_rows r_rows_after_where; /* Rows after applying attached part of WHERE */
|
ha_rows r_rows_after_where; /* Rows after applying attached part of WHERE */
|
||||||
|
|
||||||
bool has_scans() { return (r_scans != 0); }
|
bool has_scans() const { return (r_scans != 0); }
|
||||||
ha_rows get_loops() { return r_scans; }
|
ha_rows get_loops() const { return r_scans; }
|
||||||
double get_avg_rows()
|
double get_avg_rows() const
|
||||||
{
|
{
|
||||||
return r_scans ? ((double)r_rows / r_scans): 0;
|
return r_scans
|
||||||
|
? static_cast<double>(r_rows) / static_cast<double>(r_scans)
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_filtered_after_where()
|
double get_filtered_after_where() const
|
||||||
{
|
{
|
||||||
double r_filtered;
|
return r_rows > 0
|
||||||
if (r_rows > 0)
|
? static_cast<double>(r_rows_after_where) /
|
||||||
r_filtered= (double)r_rows_after_where / r_rows;
|
static_cast<double>(r_rows)
|
||||||
else
|
: 1.0;
|
||||||
r_filtered= 1.0;
|
|
||||||
|
|
||||||
return r_filtered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void on_scan_init() { r_scans++; }
|
inline void on_scan_init() { r_scans++; }
|
||||||
inline void on_record_read() { r_rows++; }
|
inline void on_record_read() { r_rows++; }
|
||||||
inline void on_record_after_where() { r_rows_after_where++; }
|
inline void on_record_after_where() { r_rows_after_where++; }
|
||||||
@ -278,25 +279,27 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void get_data_format(String *str);
|
void get_data_format(String *str);
|
||||||
|
|
||||||
/* Functions to get the statistics */
|
/* Functions to get the statistics */
|
||||||
void print_json_members(Json_writer *writer);
|
void print_json_members(Json_writer *writer);
|
||||||
|
|
||||||
ulonglong get_r_loops() const { return time_tracker.get_loops(); }
|
ulonglong get_r_loops() const { return time_tracker.get_loops(); }
|
||||||
double get_avg_examined_rows()
|
double get_avg_examined_rows() const
|
||||||
{
|
|
||||||
return ((double)r_examined_rows) / get_r_loops();
|
|
||||||
}
|
|
||||||
double get_avg_returned_rows()
|
|
||||||
{
|
|
||||||
return ((double)r_output_rows) / get_r_loops();
|
|
||||||
}
|
|
||||||
double get_r_filtered()
|
|
||||||
{
|
{
|
||||||
if (r_examined_rows > 0)
|
return static_cast<double>(r_examined_rows) /
|
||||||
return ((double)r_sorted_rows / r_examined_rows);
|
static_cast<double>(get_r_loops());
|
||||||
else
|
}
|
||||||
return 1.0;
|
double get_avg_returned_rows() const
|
||||||
|
{
|
||||||
|
return static_cast<double>(r_output_rows) /
|
||||||
|
static_cast<double>(get_r_loops());
|
||||||
|
}
|
||||||
|
double get_r_filtered() const
|
||||||
|
{
|
||||||
|
return r_examined_rows > 0
|
||||||
|
? static_cast<double>(r_sorted_rows) /
|
||||||
|
static_cast<double>(r_examined_rows)
|
||||||
|
: 1.0;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Time_and_counter_tracker time_tracker;
|
Time_and_counter_tracker time_tracker;
|
||||||
@ -397,7 +400,7 @@ public:
|
|||||||
return &time_tracker;
|
return &time_tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_time_fill_container_ms()
|
double get_time_fill_container_ms() const
|
||||||
{
|
{
|
||||||
return time_tracker.get_time_ms();
|
return time_tracker.get_time_ms();
|
||||||
}
|
}
|
||||||
@ -411,13 +414,14 @@ public:
|
|||||||
|
|
||||||
inline void increment_container_elements_count() { container_elements++; }
|
inline void increment_container_elements_count() { container_elements++; }
|
||||||
|
|
||||||
uint get_container_elements() { return container_elements; }
|
uint get_container_elements() const { return container_elements; }
|
||||||
|
|
||||||
double get_r_selectivity_pct()
|
double get_r_selectivity_pct() const
|
||||||
{
|
{
|
||||||
return (double)n_positive_checks/(double)n_checks;
|
return static_cast<double>(n_positive_checks) /
|
||||||
|
static_cast<double>(n_checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_container_buff_size() { return container_buff_size; }
|
size_t get_container_buff_size() const { return container_buff_size; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -960,9 +960,10 @@ typedef struct system_status_var
|
|||||||
#define last_system_status_var questions
|
#define last_system_status_var questions
|
||||||
#define last_cleared_system_status_var local_memory_used
|
#define last_cleared_system_status_var local_memory_used
|
||||||
|
|
||||||
/* Number of contiguous global status variables. */
|
/** Number of contiguous global status variables */
|
||||||
const int COUNT_GLOBAL_STATUS_VARS= (offsetof(STATUS_VAR, last_system_status_var) /
|
constexpr int COUNT_GLOBAL_STATUS_VARS= int(offsetof(STATUS_VAR,
|
||||||
sizeof(ulong)) + 1;
|
last_system_status_var) /
|
||||||
|
sizeof(ulong)) + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Global status variables
|
Global status variables
|
||||||
|
@ -721,7 +721,7 @@ public:
|
|||||||
if (m_error)
|
if (m_error)
|
||||||
return true;
|
return true;
|
||||||
to_hh24mmssff(ltime, MYSQL_TIMESTAMP_TIME);
|
to_hh24mmssff(ltime, MYSQL_TIMESTAMP_TIME);
|
||||||
ltime->hour+= to_days_abs() * 24;
|
ltime->hour+= static_cast<unsigned>(to_days_abs() * 24);
|
||||||
return adjust_time_range_with_warn(thd, ltime, decimals);
|
return adjust_time_range_with_warn(thd, ltime, decimals);
|
||||||
}
|
}
|
||||||
bool to_datetime(MYSQL_TIME *ltime) const
|
bool to_datetime(MYSQL_TIME *ltime) const
|
||||||
@ -906,7 +906,8 @@ protected:
|
|||||||
my_decimal *to_decimal(my_decimal *to) const;
|
my_decimal *to_decimal(my_decimal *to) const;
|
||||||
static double to_double(bool negate, ulonglong num, ulong frac)
|
static double to_double(bool negate, ulonglong num, ulong frac)
|
||||||
{
|
{
|
||||||
double d= (double) num + frac / (double) TIME_SECOND_PART_FACTOR;
|
double d= static_cast<double>(num) + static_cast<double>(frac) /
|
||||||
|
TIME_SECOND_PART_FACTOR;
|
||||||
return negate ? -d : d;
|
return negate ? -d : d;
|
||||||
}
|
}
|
||||||
longlong to_packed() const { return ::pack_time(this); }
|
longlong to_packed() const { return ::pack_time(this); }
|
||||||
@ -1034,7 +1035,7 @@ protected:
|
|||||||
{
|
{
|
||||||
return ::check_date(this, flags, warn);
|
return ::check_date(this, flags, warn);
|
||||||
}
|
}
|
||||||
void time_hhmmssff_set_max(ulong max_hour)
|
void time_hhmmssff_set_max(uint max_hour)
|
||||||
{
|
{
|
||||||
hour= max_hour;
|
hour= max_hour;
|
||||||
minute= TIME_MAX_MINUTE;
|
minute= TIME_MAX_MINUTE;
|
||||||
@ -3201,7 +3202,7 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
uchar *ptr() const { return m_ptr; }
|
uchar *ptr() const { return m_ptr; }
|
||||||
uchar offs() const { return m_offs; }
|
uchar offs() const { return m_offs; }
|
||||||
uchar bit() const { return m_ptr ? ((uchar) 1) << m_offs : 0; }
|
uchar bit() const { return static_cast<uchar>(m_ptr ? 1U << m_offs : 0); }
|
||||||
void inc()
|
void inc()
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(m_ptr);
|
DBUG_ASSERT(m_ptr);
|
||||||
|
43
sql/table.h
43
sql/table.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef TABLE_INCLUDED
|
#ifndef TABLE_INCLUDED
|
||||||
#define TABLE_INCLUDED
|
#define TABLE_INCLUDED
|
||||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
||||||
Copyright (c) 2009, 2019, MariaDB
|
Copyright (c) 2009, 2020, MariaDB
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -2564,22 +2564,10 @@ struct TABLE_LIST
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set of functions returning/setting state of a derived table/view. */
|
/* Set of functions returning/setting state of a derived table/view. */
|
||||||
inline bool is_non_derived()
|
bool is_non_derived() const { return (!derived_type); }
|
||||||
{
|
bool is_view_or_derived() const { return derived_type; }
|
||||||
return (!derived_type);
|
bool is_view() const { return (derived_type & DTYPE_VIEW); }
|
||||||
}
|
bool is_derived() const { return (derived_type & DTYPE_TABLE); }
|
||||||
inline bool is_view_or_derived()
|
|
||||||
{
|
|
||||||
return (derived_type);
|
|
||||||
}
|
|
||||||
inline bool is_view()
|
|
||||||
{
|
|
||||||
return (derived_type & DTYPE_VIEW);
|
|
||||||
}
|
|
||||||
inline bool is_derived()
|
|
||||||
{
|
|
||||||
return (derived_type & DTYPE_TABLE);
|
|
||||||
}
|
|
||||||
bool is_with_table();
|
bool is_with_table();
|
||||||
bool is_recursive_with_table();
|
bool is_recursive_with_table();
|
||||||
bool is_with_table_recursive_reference();
|
bool is_with_table_recursive_reference();
|
||||||
@ -2595,22 +2583,19 @@ struct TABLE_LIST
|
|||||||
{
|
{
|
||||||
derived_type= DTYPE_TABLE;
|
derived_type= DTYPE_TABLE;
|
||||||
}
|
}
|
||||||
inline bool is_merged_derived()
|
bool is_merged_derived() const { return (derived_type & DTYPE_MERGE); }
|
||||||
{
|
|
||||||
return (derived_type & DTYPE_MERGE);
|
|
||||||
}
|
|
||||||
inline void set_merged_derived()
|
inline void set_merged_derived()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("set_merged_derived");
|
DBUG_ENTER("set_merged_derived");
|
||||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||||
(alias.str ? alias.str : "<NULL>"),
|
(alias.str ? alias.str : "<NULL>"),
|
||||||
get_unit()));
|
get_unit()));
|
||||||
derived_type= ((derived_type & DTYPE_MASK) |
|
derived_type= static_cast<uint8>((derived_type & DTYPE_MASK) |
|
||||||
DTYPE_TABLE | DTYPE_MERGE);
|
DTYPE_TABLE | DTYPE_MERGE);
|
||||||
set_check_merged();
|
set_check_merged();
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
inline bool is_materialized_derived()
|
bool is_materialized_derived() const
|
||||||
{
|
{
|
||||||
return (derived_type & DTYPE_MATERIALIZE);
|
return (derived_type & DTYPE_MATERIALIZE);
|
||||||
}
|
}
|
||||||
@ -2621,15 +2606,13 @@ struct TABLE_LIST
|
|||||||
(alias.str ? alias.str : "<NULL>"),
|
(alias.str ? alias.str : "<NULL>"),
|
||||||
get_unit()));
|
get_unit()));
|
||||||
derived= get_unit();
|
derived= get_unit();
|
||||||
derived_type= ((derived_type & (derived ? DTYPE_MASK : DTYPE_VIEW)) |
|
derived_type= static_cast<uint8>((derived_type &
|
||||||
DTYPE_TABLE | DTYPE_MATERIALIZE);
|
(derived ? DTYPE_MASK : DTYPE_VIEW)) |
|
||||||
|
DTYPE_TABLE | DTYPE_MATERIALIZE);
|
||||||
set_check_materialized();
|
set_check_materialized();
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
inline bool is_multitable()
|
bool is_multitable() const { return (derived_type & DTYPE_MULTITABLE); }
|
||||||
{
|
|
||||||
return (derived_type & DTYPE_MULTITABLE);
|
|
||||||
}
|
|
||||||
inline void set_multitable()
|
inline void set_multitable()
|
||||||
{
|
{
|
||||||
derived_type|= DTYPE_MULTITABLE;
|
derived_type|= DTYPE_MULTITABLE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user