summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-10-12 11:29:32 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-10-12 11:29:32 +0300
commit977c385df36dcb751720dc838521b7cb5a328cb9 (patch)
tree039c8cf3e0f41bc0a1ab81eef17a4700111fbe59 /sql
parentfa0cada95baeb9fad5a2d6dad687bb13c93da9b6 (diff)
parent2aab7f2d0a6555f7ebb6dcde243639354ca5da53 (diff)
downloadmariadb-git-977c385df36dcb751720dc838521b7cb5a328cb9.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt11
-rw-r--r--sql/sql_alter.cc14
-rw-r--r--sql/sql_debug.h36
-rw-r--r--sql/sql_parse.cc8
-rw-r--r--sql/sql_type.h355
-rw-r--r--sql/wsrep_mysqld.cc15
-rw-r--r--sql/wsrep_thd.cc2
-rw-r--r--sql/wsrep_thd.h38
-rw-r--r--sql/wsrep_trans_observer.h2
-rw-r--r--sql/wsrep_var.cc20
10 files changed, 257 insertions, 244 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index c26d0450229..8143136b13b 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (c) 2006, 2014, Oracle and/or its affiliates.
-# Copyright (c) 2010, 2020, MariaDB Corporation.
+# Copyright (c) 2010, 2022, MariaDB Corporation.
#
# 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
@@ -176,7 +176,14 @@ SET (SQL_SOURCE
${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
-
+
+IF(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
+ NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0")
+ ADD_COMPILE_FLAGS(${CMAKE_CURRENT_BINARY_DIR}/yy_mariadb.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/yy_oracle.cc
+ COMPILE_FLAGS "-Wno-unused-but-set-variable")
+ENDIF()
+
IF ((CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "SunOS" OR
WIN32 OR
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index 65f5f347a0a..dee5ea2fe4b 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -509,8 +509,18 @@ bool Sql_cmd_alter_table::execute(THD *thd)
DBUG_RETURN(TRUE);
}
- thd->variables.auto_increment_offset = 1;
- thd->variables.auto_increment_increment = 1;
+ /*
+ It makes sense to set auto_increment_* to defaults in TOI operations.
+ Must be done before wsrep_TOI_begin() since Query_log_event encapsulating
+ TOI statement and auto inc variables for wsrep replication is constructed
+ there. Variables are reset back in THD::reset_for_next_command() before
+ processing of next command.
+ */
+ if (wsrep_auto_increment_control)
+ {
+ thd->variables.auto_increment_offset = 1;
+ thd->variables.auto_increment_increment = 1;
+ }
}
#endif
diff --git a/sql/sql_debug.h b/sql/sql_debug.h
index de28de06b2b..c5aa3b5f94e 100644
--- a/sql/sql_debug.h
+++ b/sql/sql_debug.h
@@ -63,23 +63,23 @@ public:
{
static const char *names[17]=
{
- "HA_NOSAME",
- "HA_PACK_KEY",
- "HA_SPACE_PACK_USED",
- "HA_VAR_LENGTH_KEY",
- "HA_AUTO_KEY",
- "HA_BINARY_PACK_KEY",
- "HA_NULL_PART_KEY",
- "HA_FULLTEXT",
- "HA_UNIQUE_CHECK",
- "HA_SORT_ALLOWS_SAME",
- "HA_SPATIAL",
- "HA_NULL_ARE_EQUAL",
- "HA_GENERATED_KEY",
- "HA_USES_COMMENT",
- "HA_USES_PARSER",
- "HA_USES_BLOCK_SIZE",
- "HA_KEY_HAS_PART_KEY_SEG"
+ "HA_NOSAME", // 1
+ "HA_PACK_KEY", // 2 - used in both HA_KEYSEG and KEY/MI_KEYDEF
+ "HA_SPACE_PACK_USED", // 4
+ "HA_VAR_LENGTH_KEY", // 8
+ "HA_AUTO_KEY", // 16
+ "HA_BINARY_PACK_KEY", // 32
+ "HA_NULL_PART_KEY", // 64
+ "HA_FULLTEXT", // 128
+ "HA_UNIQUE_CHECK", // 256
+ "HA_SORT_ALLOWS_SAME", // 512
+ "HA_SPATIAL", // 1024
+ "HA_NULL_ARE_EQUAL", // 2048
+ "HA_USES_COMMENT", // 4096
+ "HA_GENERATED_KEY", // 8192
+ "HA_USES_PARSER", // 16384
+ "HA_USES_BLOCK_SIZE", // 32768
+ "HA_KEY_HAS_PART_KEY_SEG" // 65536
};
return append_flag32_names((uint) flags, names, array_elements(names));
}
@@ -89,7 +89,7 @@ public:
static const char *names[]=
{
"HA_SPACE_PACK", // 1
- "??? 2 ???", // 2
+ "HA_PACK_KEY", // 2 - used in both HA_KEYSEG and KEY/MI_KEYDEF
"HA_PART_KEY_SEG", // 4
"HA_VAR_LENGTH_PART", // 8
"HA_NULL_PART", // 16
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 73be865ea5e..5c864894b97 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -9962,7 +9962,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
{
LEX *lex= thd->lex;
SELECT_LEX *select_lex= lex->first_select_lex();
- privilege_t want_priv(NO_ACL);
+ privilege_t want_priv{CREATE_ACL};
bool error= TRUE; // Error message is given
DBUG_ENTER("create_table_precheck");
@@ -9971,8 +9971,10 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
CREATE TABLE ... SELECT, also require INSERT.
*/
- want_priv= lex->tmp_table() ? CREATE_TMP_ACL :
- (CREATE_ACL | (select_lex->item_list.elements ? INSERT_ACL : NO_ACL));
+ if (lex->tmp_table())
+ want_priv= CREATE_TMP_ACL;
+ else if (select_lex->item_list.elements || select_lex->tvc)
+ want_priv|= INSERT_ACL;
/* CREATE OR REPLACE on not temporary tables require DROP_ACL */
if (lex->create_info.or_replace() && !lex->tmp_table())
diff --git a/sql/sql_type.h b/sql/sql_type.h
index c4e7765d0cb..8a3a3776b52 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -2,7 +2,7 @@
#define SQL_TYPE_H_INCLUDED
/*
Copyright (c) 2015 MariaDB Foundation.
- Copyright (c) 2015, 2021, MariaDB Corporation.
+ Copyright (c) 2015, 2022, MariaDB Corporation.
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
@@ -3807,8 +3807,8 @@ public:
{
return this;
}
- virtual bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const
+ virtual bool partition_field_check(const LEX_CSTRING &field_name, Item *)
+ const
{
partition_field_type_not_allowed(field_name);
return true;
@@ -4177,8 +4177,8 @@ public:
CHARSET_INFO *cs,
bool send_error) const
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
Item_literal *create_literal_item(THD *thd, const String *str,
bool send_error) const
@@ -4189,12 +4189,13 @@ public:
virtual Item *create_typecast_item(THD *thd, Item *item,
const Type_cast_attributes &attr) const
{
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
virtual Item_copy *create_item_copy(THD *thd, Item *item) const;
virtual int cmp_native(const Native &a, const Native &b) const
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
virtual bool set_comparator_func(Arg_comparator *cmp) const= 0;
@@ -4348,11 +4349,10 @@ class Type_handler_row: public Type_handler
public:
virtual ~Type_handler_row() {}
const Name &default_value() const override;
- bool validate_implicit_default_value(THD *thd,
- const Column_definition &def) const
- override
+ bool validate_implicit_default_value(THD *, const Column_definition &)
+ const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
const Type_collection *type_collection() const override;
@@ -4366,12 +4366,12 @@ public:
bool can_return_time() const override { return false; }
enum_field_types field_type() const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return MYSQL_TYPE_NULL;
};
protocol_send_type_t protocol_send_type() const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return PROTOCOL_SEND_STRING;
}
Item_result result_type() const override
@@ -4382,47 +4382,44 @@ public:
{
return ROW_RESULT;
}
- enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr)
+ enum_dynamic_column_type dyncol_type(const Type_all_attributes *)
const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return DYN_COL_NULL;
}
const Type_handler *type_handler_for_comparison() const override;
- int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const override
+ int stored_field_cmp_to_item(THD *, Field *, Item *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- bool subquery_type_allows_materialization(const Item *, const Item *,
- bool) const override
+ bool subquery_type_allows_materialization(const Item *, const Item *, bool)
+ const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return false;
}
- Field *make_num_distinct_aggregator_field(MEM_ROOT *, const Item *) const override
+ Field *make_num_distinct_aggregator_field(MEM_ROOT *, const Item *) const
+ override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
- Field *make_conversion_table_field(MEM_ROOT *root,
- TABLE *table,
- uint metadata,
- const Field *target) const override
+ Field *make_conversion_table_field(MEM_ROOT *, TABLE *, uint, const Field *)
+ const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
- bool Column_definition_fix_attributes(Column_definition *c) const override
+ bool Column_definition_fix_attributes(Column_definition *) const override
{
return false;
}
- void Column_definition_reuse_fix_attributes(THD *thd,
- Column_definition *c,
- const Field *field)
- const override
+ void Column_definition_reuse_fix_attributes(THD *, Column_definition *,
+ const Field *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
}
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
@@ -4432,28 +4429,25 @@ public:
const Column_derived_attributes
*derived_attr)
const override;
- bool Column_definition_redefine_stage1(Column_definition *def,
- const Column_definition *dup,
- const handler *file)
+ bool Column_definition_redefine_stage1(Column_definition *,
+ const Column_definition *,
+ const handler *)
const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Column_definition_prepare_stage2(Column_definition *c,
- handler *file,
- ulonglong table_flags) const override
+ bool Column_definition_prepare_stage2(Column_definition *, handler *,
+ ulonglong) const override
{
return false;
}
- Field *make_table_field(MEM_ROOT *root,
- const LEX_CSTRING *name,
- const Record_addr &addr,
- const Type_all_attributes &attr,
- TABLE_SHARE *share) const override
+ Field *make_table_field(MEM_ROOT *, const LEX_CSTRING *, const Record_addr &,
+ const Type_all_attributes &, TABLE_SHARE *)
+ const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
Field *make_table_field_from_def(TABLE_SHARE *share,
MEM_ROOT *mem_root,
@@ -4466,76 +4460,73 @@ public:
const SORT_FIELD_ATTR *sort_field,
Sort_param *param) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
}
- uint make_packed_sort_key_part(uchar *to, Item *item,
- const SORT_FIELD_ATTR *sort_field,
- Sort_param *param) const override
+ uint make_packed_sort_key_part(uchar *, Item *, const SORT_FIELD_ATTR *,
+ Sort_param *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- void sort_length(THD *thd, const Type_std_attributes *item,
- SORT_FIELD_ATTR *attr) const override
+ void sort_length(THD *, const Type_std_attributes *, SORT_FIELD_ATTR *)
+ const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
}
- uint32 max_display_length(const Item *item) const override
+ uint32 max_display_length(const Item *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- uint32 max_display_length_for_field(const Conv_source &src) const override
+ uint32 max_display_length_for_field(const Conv_source &) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- uint32 calc_pack_length(uint32 length) const override
+ uint32 calc_pack_length(uint32) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
bool Item_eq_value(THD *thd, const Type_cmp_attributes *attr,
Item *a, Item *b) const override;
- uint Item_decimal_precision(const Item *item) const override
+ uint Item_decimal_precision(const Item *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return DECIMAL_MAX_PRECISION;
}
- bool Item_save_in_value(THD *thd, Item *item, st_value *value) const override;
+ bool Item_save_in_value(THD *thd, Item *item, st_value *value) const
+ override;
bool Item_param_set_from_value(THD *thd,
Item_param *param,
const Type_all_attributes *attr,
const st_value *value) const override;
- bool Item_send(Item *item, Protocol *protocol, st_value *buf) const override
+ bool Item_send(Item *, Protocol *, st_value *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
void Item_update_null_value(Item *item) const override;
- int Item_save_in_field(Item *item, Field *field, bool no_conversions)
- const override
+ int Item_save_in_field(Item *, Field *, bool) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 1;
}
String *print_item_value(THD *thd, Item *item, String *str) const override;
- bool can_change_cond_ref_to_const(Item_bool_func2 *target,
- Item *target_expr, Item *target_value,
- Item_bool_func2 *source,
- Item *source_expr, Item *source_const)
- const override
+ bool can_change_cond_ref_to_const(Item_bool_func2 *, Item *, Item *,
+ Item_bool_func2 *, Item *, Item *)
+ const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return false;
}
- Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp)
- const override;
+ Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const
+ override;
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
- Item_copy *create_item_copy(THD *thd, Item *item) const override
+ Item_copy *create_item_copy(THD *, Item *) const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
bool set_comparator_func(Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
@@ -4545,188 +4536,187 @@ public:
Item **items, uint nitems)
const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const override
+ bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
bool Item_val_bool(Item *item) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return false;
}
- void Item_get_date(THD *thd, Item *item,
- Temporal::Warn *warn, MYSQL_TIME *ltime,
- date_mode_t fuzzydate) const override
+ void Item_get_date(THD *, Item *, Temporal::Warn *, MYSQL_TIME *ltime,
+ date_mode_t) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
set_zero_time(ltime, MYSQL_TIMESTAMP_NONE);
}
- longlong Item_val_int_signed_typecast(Item *item) const override
+ longlong Item_val_int_signed_typecast(Item *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- longlong Item_val_int_unsigned_typecast(Item *item) const override
+ longlong Item_val_int_unsigned_typecast(Item *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
- String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str)
- const override
+ String *Item_func_hex_val_str_ascii(Item_func_hex *, String *) const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *,
String *) const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
double Item_func_hybrid_field_type_val_real(Item_func_hybrid_field_type *)
const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0.0;
}
longlong Item_func_hybrid_field_type_val_int(Item_func_hybrid_field_type *)
const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
my_decimal *Item_func_hybrid_field_type_val_decimal(
Item_func_hybrid_field_type *,
my_decimal *) const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
void Item_func_hybrid_field_type_get_date(THD *,
Item_func_hybrid_field_type *,
Temporal::Warn *,
MYSQL_TIME *ltime,
- date_mode_t fuzzydate)
- const override
+ date_mode_t) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
set_zero_time(ltime, MYSQL_TIMESTAMP_NONE);
}
- String *Item_func_min_max_val_str(Item_func_min_max *, String *) const override
+ String *Item_func_min_max_val_str(Item_func_min_max *, String *) const
+ override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
double Item_func_min_max_val_real(Item_func_min_max *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
longlong Item_func_min_max_val_int(Item_func_min_max *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *,
my_decimal *) const override
{
- DBUG_ASSERT(0);
- return NULL;
+ MY_ASSERT_UNREACHABLE();
+ return nullptr;
}
- bool Item_func_min_max_get_date(THD *thd, Item_func_min_max*,
- MYSQL_TIME *, date_mode_t fuzzydate)
- const override
+ bool Item_func_min_max_get_date(THD *, Item_func_min_max*, MYSQL_TIME *,
+ date_mode_t) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_func_between_fix_length_and_dec(Item_func_between *func)
- const override
+ bool Item_func_between_fix_length_and_dec(Item_func_between *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
longlong Item_func_between_val_int(Item_func_between *func) const override;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override;
- in_vector *make_in_vector(THD *thd, const Item_func_in *f, uint nargs)
- const override;
- bool Item_func_in_fix_comparator_compatible_types(THD *thd, Item_func_in *)
- const override;
+ in_vector *make_in_vector(THD *thd, const Item_func_in *f, uint nargs) const
+ override;
+ bool Item_func_in_fix_comparator_compatible_types(THD *thd,
+ Item_func_in *) const
+ override;
bool Item_func_round_fix_length_and_dec(Item_func_round *) const override;
- bool Item_func_int_val_fix_length_and_dec(Item_func_int_val *) const override;
+ bool Item_func_int_val_fix_length_and_dec(Item_func_int_val *) const
+ override;
bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override;
bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const override;
bool Item_func_signed_fix_length_and_dec(Item_func_signed *) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const override
+ bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *)
- const override
+ bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *)
- const override
+ bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *)
- const override
+ bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *)
- const override
+ bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *)
- const override
+ bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
- bool Item_date_typecast_fix_length_and_dec(Item_date_typecast *)
- const override
+ bool Item_date_typecast_fix_length_and_dec(Item_date_typecast *) const
+ override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *)
- const override
+ const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return true;
}
@@ -4746,8 +4736,6 @@ class Type_handler_numeric: public Type_handler
public:
const Name &default_value() const override;
String *print_item_value(THD *thd, Item *item, String *str) const override;
- double Item_func_min_max_val_real(Item_func_min_max *) const override;
- longlong Item_func_min_max_val_int(Item_func_min_max *) const override;
bool Column_definition_prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
Column_definition *c,
@@ -4756,19 +4744,23 @@ public:
const Column_derived_attributes
*derived_attr)
const override;
+ double Item_func_min_max_val_real(Item_func_min_max *) const override;
+ longlong Item_func_min_max_val_int(Item_func_min_max *) const override;
my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *,
my_decimal *) const override;
bool Item_func_min_max_get_date(THD *thd, Item_func_min_max*,
- MYSQL_TIME *, date_mode_t fuzzydate)
- const override;
+ MYSQL_TIME *, date_mode_t fuzzydate) const
+ override;
virtual ~Type_handler_numeric() { }
bool can_change_cond_ref_to_const(Item_bool_func2 *target,
Item *target_expr, Item *target_value,
Item_bool_func2 *source,
- Item *source_expr, Item *source_const)
- const override;
- bool Item_func_between_fix_length_and_dec(Item_func_between *func) const override;
- bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const override;
+ Item *source_expr, Item *source_const) const
+ override;
+ bool Item_func_between_fix_length_and_dec(Item_func_between *func) const
+ override;
+ bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const
+ override;
};
@@ -5263,8 +5255,8 @@ public:
return type_limits_int()->char_length();
}
uint32 Item_decimal_notation_int_digits(const Item *item) const override;
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, INT_RESULT);
}
@@ -6102,8 +6094,8 @@ public:
const override;
bool Item_param_val_native(THD *thd, Item_param *item, Native *to)
const override;
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, STRING_RESULT);
}
@@ -6312,8 +6304,8 @@ public:
{
return true;
}
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, STRING_RESULT);
}
@@ -6442,8 +6434,8 @@ public:
{
return true;
}
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, STRING_RESULT);
}
@@ -6893,12 +6885,13 @@ public:
bool is_param_long_data_type() const override { return true; }
uint32 max_display_length_for_field(const Conv_source &src) const override;
uint32 calc_pack_length(uint32 length) const override { return length; }
- const Type_handler *type_handler_for_tmp_table(const Item *item) const override
+ const Type_handler *type_handler_for_tmp_table(const Item *item) const
+ override
{
return varstring_type_handler(item);
}
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, STRING_RESULT);
}
@@ -6985,7 +6978,8 @@ public:
{
return (length + (length < 256 ? 1: 2));
}
- const Type_handler *type_handler_for_tmp_table(const Item *item) const override
+ const Type_handler *type_handler_for_tmp_table(const Item *item) const
+ override
{
return varstring_type_handler(item);
}
@@ -6994,8 +6988,8 @@ public:
return varstring_type_handler(item);
}
bool is_param_long_data_type() const override { return true; }
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &, Item *item_expr)
+ const override
{
return partition_field_check_result_type(item_expr, STRING_RESULT);
}
@@ -7055,12 +7049,12 @@ public:
}
ulong KEY_pack_flags(uint column_nr) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
uint32 max_display_length_for_field(const Conv_source &src) const override;
- bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override
+ bool partition_field_check(const LEX_CSTRING &field_name, Item *)
+ const override
{
partition_field_type_not_allowed(field_name);
return true;
@@ -7140,7 +7134,7 @@ public:
void Item_param_setup_conversion(THD *thd, Item_param *) const override;
bool partition_field_check(const LEX_CSTRING &field_name,
- Item *item_expr) const override;
+ Item *item_expr) const override;
Field *make_schema_field(MEM_ROOT *root,
TABLE *table,
const Record_addr &addr,
@@ -7178,7 +7172,8 @@ class Type_handler_medium_blob: public Type_handler_blob_common
public:
virtual ~Type_handler_medium_blob() {}
uint length_bytes() const override { return 3; }
- enum_field_types field_type() const override { return MYSQL_TYPE_MEDIUM_BLOB; }
+ enum_field_types field_type() const override
+ { return MYSQL_TYPE_MEDIUM_BLOB; }
uint32 max_display_length_for_field(const Conv_source &src) const override;
uint32 calc_pack_length(uint32 length) const override;
Field *make_table_field(MEM_ROOT *root,
@@ -7235,7 +7230,7 @@ public:
}
ulong KEY_pack_flags(uint) const override
{
- DBUG_ASSERT(0);
+ MY_ASSERT_UNREACHABLE();
return 0;
}
uint32 max_display_length_for_field(const Conv_source &src) const override;
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index e52613492f0..134ab7c2a77 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -471,19 +471,20 @@ void wsrep_recover_sr_from_storage(THD *orig_thd)
if (!wsrep_schema)
{
WSREP_ERROR("Wsrep schema not initialized when trying to recover "
- "streaming transactions");
- unireg_abort(1);
+ "streaming transactions: wsrep_on %d", WSREP_ON);
+ trans_commit(orig_thd);
}
if (wsrep_schema->recover_sr_transactions(orig_thd))
{
- WSREP_ERROR("Failed to recover SR transactions from schema");
- unireg_abort(1);
+ WSREP_ERROR("Failed to recover SR transactions from schema: wsrep_on : %d", WSREP_ON);
+ trans_commit(orig_thd);
}
break;
default:
/* */
- WSREP_ERROR("Unsupported wsrep SR store type: %lu", wsrep_SR_store_type);
- unireg_abort(1);
+ WSREP_ERROR("Unsupported wsrep SR store type: %lu wsrep_on: %d",
+ wsrep_SR_store_type, WSREP_ON);
+ trans_commit(orig_thd);
break;
}
}
@@ -2355,7 +2356,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table,
ret,
(thd->db.str ? thd->db.str : "(null)"),
wsrep_thd_query(thd));
- my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED);
+ my_error(ER_UNKNOWN_ERROR, MYF(0), "Maximum writeset size exceeded");
break;
case wsrep::e_deadlock_error:
WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 62920e56105..915c7bbb5a5 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013-2021 Codership Oy <info@codership.com>
+/* Copyright (C) 2013-2022 Codership Oy <info@codership.com>
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
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index 73c949cb6d5..e55895ffbe8 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013-2021 Codership Oy <info@codership.com>
+/* Copyright (C) 2013-2022 Codership Oy <info@codership.com>
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
@@ -182,7 +182,7 @@ void wsrep_reset_threadvars(THD *);
so don't override those by default
*/
-static inline void wsrep_override_error(THD *thd, uint error)
+static inline void wsrep_override_error(THD *thd, uint error, const char *format= 0, ...)
{
DBUG_ASSERT(error != ER_ERROR_DURING_COMMIT);
Diagnostics_area *da= thd->get_stmt_da();
@@ -195,26 +195,11 @@ static inline void wsrep_override_error(THD *thd, uint error)
da->sql_errno() != ER_LOCK_DEADLOCK))
{
da->reset_diagnostics_area();
- my_error(error, MYF(0));
- }
-}
-
-/**
- Override error with additional wsrep status.
- */
-static inline void wsrep_override_error(THD *thd, uint error,
- enum wsrep::provider::status status)
-{
- Diagnostics_area *da= thd->get_stmt_da();
- if (da->is_ok() ||
- !da->is_set() ||
- (da->is_error() &&
- da->sql_errno() != error &&
- da->sql_errno() != ER_ERROR_DURING_COMMIT &&
- da->sql_errno() != ER_LOCK_DEADLOCK))
- {
- da->reset_diagnostics_area();
- my_error(error, MYF(0), status);
+ va_list args;
+ va_start(args, format);
+ if (!format) format= ER_THD(thd, error);
+ my_printv_error(error, format, MYF(0), args);
+ va_end(args);
}
}
@@ -226,7 +211,10 @@ static inline void wsrep_override_error(THD* thd,
switch (ce)
{
case wsrep::e_error_during_commit:
- wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, status);
+ if (status == wsrep::provider::error_size_exceeded)
+ wsrep_override_error(thd, ER_UNKNOWN_ERROR, "Maximum writeset size exceeded");
+ else
+ wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, 0, status);
break;
case wsrep::e_deadlock_error:
wsrep_override_error(thd, ER_LOCK_DEADLOCK);
@@ -235,11 +223,11 @@ static inline void wsrep_override_error(THD* thd,
wsrep_override_error(thd, ER_QUERY_INTERRUPTED);
break;
case wsrep::e_size_exceeded_error:
- wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, status);
+ wsrep_override_error(thd, ER_UNKNOWN_ERROR, "Maximum writeset size exceeded");
break;
case wsrep::e_append_fragment_error:
/* TODO: Figure out better error number */
- wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, status);
+ wsrep_override_error(thd, ER_ERROR_DURING_COMMIT, 0, status);
break;
case wsrep::e_not_supported_error:
wsrep_override_error(thd, ER_NOT_SUPPORTED_YET);
diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h
index f21eca47fa2..3c5cff2b741 100644
--- a/sql/wsrep_trans_observer.h
+++ b/sql/wsrep_trans_observer.h
@@ -1,4 +1,4 @@
-/* Copyright 2016-2019 Codership Oy <http://www.codership.com>
+/* Copyright 2016-2022 Codership Oy <http://www.codership.com>
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
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 3cb1351d754..ff687975d0a 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -1,4 +1,4 @@
-/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
+/* Copyright 2008-2022 Codership Oy <http://www.codership.com>
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
@@ -123,8 +123,7 @@ bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type)
if (wsrep_init())
{
- my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, my_error, "wsrep_init failed");
- //rcode= true;
+ my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, errno, "wsrep_init failed");
saved_wsrep_on= false;
}
@@ -803,11 +802,22 @@ bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type)
{
WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads);
res= wsrep_create_appliers(wsrep_slave_count_change, true);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
+ // Thread creation and execution is asyncronous, therefore we need
+ // wait them to be started or error produced
+ while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads)
+ {
+ my_sleep(1000);
+ }
+
+ mysql_mutex_lock(&LOCK_global_system_variables);
+
WSREP_DEBUG("Running %lu applier threads", wsrep_running_applier_threads);
wsrep_slave_count_change = 0;
}
-
- mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
+ else
+ mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
return res;
}