1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Merge 10.6 into 10.10

The MDEV-29693 conflict resolution is from Monty, as well as is
a bug fix where ANALYZE TABLE wrongly built histograms for
single-column PRIMARY KEY.
Also includes a fix for safe_malloc error reporting.

Other things:
- Copied main.log_slow from 10.4 to avoid mtr issue

Disabled test:
- spider/bugfix.mdev_27239 because we started to get
  +Error	1429 Unable to connect to foreign data source: localhost
  -Error	1158 Got an error reading communication packets
- main.delayed
  - Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
    This part is disabled for now as it fails randomly with different
    warnings/errors (no corruption).
This commit is contained in:
Marko Mäkelä
2023-10-13 15:14:37 +03:00
committed by Monty
436 changed files with 13299 additions and 28179 deletions

View File

@@ -447,7 +447,8 @@ private:
class Key :public Sql_alloc, public DDL_options {
public:
enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY};
enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY,
IGNORE_KEY};
enum Keytype type;
KEY_CREATE_INFO key_create_info;
List<Key_part_spec> columns;
@@ -702,6 +703,7 @@ typedef struct system_variables
ulonglong log_slow_verbosity;
ulonglong log_slow_disabled_statements;
ulonglong log_disabled_statements;
ulonglong note_verbosity;
ulonglong bulk_insert_buff_size;
ulonglong join_buff_size;
ulonglong sortbuff_size;
@@ -754,6 +756,8 @@ typedef struct system_variables
ulong optimizer_search_depth;
ulong optimizer_selectivity_sampling_limit;
ulong optimizer_use_condition_selectivity;
ulong optimizer_max_sel_arg_weight;
ulong optimizer_max_sel_args;
ulong use_stat_tables;
double sample_percentage;
ulong histogram_size;
@@ -775,6 +779,7 @@ typedef struct system_variables
ulong trans_alloc_block_size;
ulong trans_prealloc_size;
ulong log_warnings;
ulong log_slow_max_warnings;
/* Flags for slow log filtering */
ulong log_slow_rate_limit;
ulong binlog_format; ///< binlog format for this thd (see enum_binlog_format)
@@ -881,7 +886,7 @@ typedef struct system_variables
uint column_compression_threshold;
uint column_compression_zlib_level;
uint in_subquery_conversion_threshold;
ulong optimizer_max_sel_arg_weight;
ulonglong max_rowid_filter_size;
vers_asof_timestamp_t vers_asof_timestamp;
@@ -1176,11 +1181,21 @@ public:
Prepared statement: STMT_INITIALIZED -> STMT_PREPARED -> STMT_EXECUTED.
Stored procedure: STMT_INITIALIZED_FOR_SP -> STMT_EXECUTED.
Other statements: STMT_CONVENTIONAL_EXECUTION never changes.
Special case for stored procedure arguments: STMT_SP_QUERY_ARGUMENTS
This state never changes and used for objects
whose lifetime is whole duration of function call
(sp_rcontext, it's tables and items. etc). Such objects
should be deallocated after every execution of a stored
routine. Caller's arena/memroot can't be used for
placing such objects since memory allocated on caller's
arena not freed until termination of user's session.
*/
enum enum_state
{
STMT_INITIALIZED= 0, STMT_INITIALIZED_FOR_SP= 1, STMT_PREPARED= 2,
STMT_CONVENTIONAL_EXECUTION= 3, STMT_EXECUTED= 4, STMT_ERROR= -1
STMT_CONVENTIONAL_EXECUTION= 3, STMT_EXECUTED= 4,
STMT_SP_QUERY_ARGUMENTS= 5, STMT_ERROR= -1
};
enum_state state;
@@ -1959,11 +1974,17 @@ private:
/**
Implements the trivial error handler which cancels all error states
and prevents an SQLSTATE to be set.
Remembers the first error
*/
class Dummy_error_handler : public Internal_error_handler
{
uint m_unhandled_errors;
uint first_error;
public:
Dummy_error_handler()
: m_unhandled_errors(0), first_error(0)
{}
bool handle_condition(THD *thd,
uint sql_errno,
const char* sqlstate,
@@ -1971,13 +1992,15 @@ public:
const char* msg,
Sql_condition ** cond_hdl)
{
/* Ignore error */
return TRUE;
m_unhandled_errors++;
if (!first_error)
first_error= sql_errno;
return TRUE; // Ignore error
}
Dummy_error_handler() = default; /* Remove gcc warning */
bool any_error() { return m_unhandled_errors != 0; }
uint got_error() { return first_error; }
};
/**
Implements the trivial error handler which counts errors as they happen.
*/
@@ -2316,6 +2339,19 @@ struct wait_for_commit
group commit as T1.
*/
bool commit_started;
/*
Set to temporarily ignore calls to wakeup_subsequent_commits(). The
caller must arrange that another wakeup_subsequent_commits() gets called
later after wakeup_blocked has been set back to false.
This is used for parallel replication with temporary tables.
Temporary tables require strict single-threaded operation. The normal
optimization, of doing wakeup_subsequent_commits early and overlapping
part of the commit with the following transaction, is not safe. Thus
when temporary tables are replicated, wakeup is blocked until the
event group is fully done.
*/
bool wakeup_blocked;
void register_wait_for_prior_commit(wait_for_commit *waitee);
int wait_for_prior_commit(THD *thd, bool allow_kill=true)
@@ -4468,6 +4504,17 @@ public:
inline Query_arena *activate_stmt_arena_if_needed(Query_arena *backup)
{
if (state == Query_arena::STMT_SP_QUERY_ARGUMENTS)
/*
Caller uses the arena with state STMT_SP_QUERY_ARGUMENTS for stored
routine's parameters. Lifetime of these objects spans a lifetime of
stored routine call and freed every time the stored routine execution
has been completed. That is the reason why switching to statement's
arena is not performed for arguments, else we would observe increasing
of memory usage while a stored routine be called over and over again.
*/
return NULL;
/*
Use the persistent arena if we are in a prepared statement or a stored
procedure statement and we have not already changed to use this arena.
@@ -5625,6 +5672,14 @@ public:
return (variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE) ||
lex->analyze_stmt;
}
/* Return true if we should create a note when an unusable key is found */
bool give_notes_for_unusable_keys()
{
return ((variables.note_verbosity & (NOTE_VERBOSITY_UNUSABLE_KEYS)) ||
(lex->describe && // Is EXPLAIN
(variables.note_verbosity & NOTE_VERBOSITY_EXPLAIN)));
}
};