Skip to content
Permalink
Browse files

Merge 10.3 into 10.4

  • Loading branch information...
kevgs committed Jul 26, 2019
2 parents de9e393 + 29df100 commit 4c7a74396497ae28779016b5bd59283aeee0b6f4
@@ -130,5 +130,17 @@ truncate t1;
truncate t2;
ERROR HY000: System-versioned tables do not support TRUNCATE TABLE
unlock tables;
#
# MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
#
create or replace table t1 (
f varchar(1),
row_start SYS_TYPE as row start,
row_end SYS_TYPE as row end,
period for system_time (row_start, row_end))
with system versioning;
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
delete from t1;
delete history from t1;
drop database test;
create database test;
@@ -145,5 +145,19 @@ truncate t2;

unlock tables;

--echo #
--echo # MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
--echo #
--replace_result $sys_datatype_expl SYS_TYPE
eval create or replace table t1 (
f varchar(1),
row_start $sys_datatype_expl as row start,
row_end $sys_datatype_expl as row end,
period for system_time (row_start, row_end))
with system versioning;
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
delete from t1;
delete history from t1;

drop database test;
create database test;
@@ -237,6 +237,8 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
int error;
DBUG_PRINT("mutex", ("%s (0x%lx) locking", mp->name ? mp->name : "Null",
(ulong) mp));

pthread_mutex_lock(&mp->global);
if (!mp->file)
{
fprintf(stderr,
@@ -245,8 +247,6 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
fflush(stderr);
abort();
}

pthread_mutex_lock(&mp->global);
if (mp->count > 0)
{
/*
@@ -16,7 +16,7 @@


#define PLUGIN_VERSION 0x104
#define PLUGIN_STR_VERSION "1.4.7"
#define PLUGIN_STR_VERSION "1.4.8"

#define _my_thread_var loc_thread_var

@@ -2261,7 +2261,7 @@ static void auditing_v13(MYSQL_THD thd, unsigned int *ev_v0)
}


int get_db_mysql57(MYSQL_THD thd, char **name, int *len)
int get_db_mysql57(MYSQL_THD thd, char **name, size_t *len)
{
int db_off;
int db_len_off;
@@ -2288,7 +2288,7 @@ int get_db_mysql57(MYSQL_THD thd, char **name, int *len)

#ifdef __linux__
*name= *(char **) (((char *) thd) + db_off);
*len= *((int *) (((char*) thd) + db_len_off));
*len= *((size_t *) (((char*) thd) + db_len_off));
if (*name && (*name)[*len] != 0)
return 1;
return 0;
@@ -16,7 +16,7 @@ enum enum_server_command{ SERVCOM_A, SERVCOM_B };
#include "plugin_audit_v4.h"

extern void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev);
extern int get_db_mysql57(MYSQL_THD thd, char **name, int *len);
extern int get_db_mysql57(MYSQL_THD thd, char **name, size_t *len);


struct mysql_event_general_302
@@ -35,7 +35,7 @@ struct mysql_event_general_302
unsigned long long general_rows;
unsigned long long query_id;
char *database;
int database_length;
size_t database_length;
};


@@ -351,8 +351,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,

THD_STAGE_INFO(thd, stage_init_update);

bool truncate_history= table_list->vers_conditions.is_set();
if (truncate_history)
bool delete_history= table_list->vers_conditions.is_set();
if (delete_history)
{
DBUG_ASSERT(!table_list->period_conditions.is_set());

@@ -401,7 +401,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
select_lex->item_list, &conds,
&delete_while_scanning))
DBUG_RETURN(TRUE);


if (delete_history)
table->vers_write= false;

if (with_select)
(void) result->prepare(select_lex->item_list, NULL);

@@ -752,7 +755,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
while (!(error=info.read_record()) && !thd->killed &&
! thd->is_error())
{
if (record_should_be_deleted(thd, table, select, explain, truncate_history))
if (record_should_be_deleted(thd, table, select, explain, delete_history))
{
table->file->position(table->record[0]);
if (unlikely((error=
@@ -801,10 +804,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
if (delete_while_scanning)
delete_record= record_should_be_deleted(thd, table, select, explain,
truncate_history);
delete_history);
if (delete_record)
{
if (!truncate_history && table->triggers &&
if (!delete_history && table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, FALSE))
{
@@ -840,7 +843,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (likely(!error))
{
deleted++;
if (!truncate_history && table->triggers &&
if (!delete_history && table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, FALSE))
{
@@ -98,7 +98,7 @@ throughput clearly from about 100000. */
#define BTR_CUR_FINE_HISTORY_LENGTH 100000

/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
ulint btr_cur_n_non_sea;
Atomic_counter<ulint> btr_cur_n_non_sea;
/** Old value of btr_cur_n_non_sea. Copied by
srv_refresh_innodb_monitor_stats(). Referenced by
srv_printf_innodb_monitor(). */
@@ -1034,7 +1034,7 @@ inherited external field. */
#define BTR_EXTERN_INHERITED_FLAG 64U

/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
extern ulint btr_cur_n_non_sea;
extern Atomic_counter<ulint> btr_cur_n_non_sea;
/** Old value of btr_cur_n_non_sea. Copied by
srv_refresh_innodb_monitor_stats(). Referenced by
srv_printf_innodb_monitor(). */
@@ -571,14 +571,6 @@ struct upd_node_t{
/* column assignment list */
ulint magic_n;

/** Also set row_start = CURRENT_TIMESTAMP/trx->id
@param[in] trx transaction */
void make_versioned_update(const trx_t* trx);
/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
Do not touch other fields at all.
@param[in] trx transaction */
void make_versioned_delete(const trx_t* trx);

private:
/** Appends row_start or row_end field to update vector and sets a
CURRENT_TIMESTAMP/trx->id value to it.
@@ -587,6 +579,24 @@ struct upd_node_t{
@param[in] trx transaction
@param[in] vers_sys_idx table->row_start or table->row_end */
void make_versioned_helper(const trx_t* trx, ulint idx);

public:
/** Also set row_start = CURRENT_TIMESTAMP/trx->id
@param[in] trx transaction */
void make_versioned_update(const trx_t* trx)
{
make_versioned_helper(trx, table->vers_start);
}

/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
Do not touch other fields at all.
@param[in] trx transaction */
void make_versioned_delete(const trx_t* trx)
{
update->n_fields = 0;
is_delete = VERSIONED_DELETE;
make_versioned_helper(trx, table->vers_end);
}
};

#define UPD_NODE_MAGIC_N 1579975
@@ -3476,7 +3476,8 @@ void upd_node_t::make_versioned_helper(const trx_t* trx, ulint idx)

dict_index_t* clust_index = dict_table_get_first_index(table);

/* row_create_update_node_for_mysql() pre-allocated this much */
/* row_create_update_node_for_mysql() pre-allocated this much.
At least one PK column always remains unchanged. */
ut_ad(update->n_fields < ulint(table->n_cols + table->n_v_cols));

update->n_fields++;
@@ -3496,19 +3497,3 @@ void upd_node_t::make_versioned_helper(const trx_t* trx, ulint idx)
dfield_set_data(&ufield->new_val, update->vers_sys_value, col->len);
}

/** Also set row_start = CURRENT_TIMESTAMP/trx->id
@param[in] trx transaction */
void upd_node_t::make_versioned_update(const trx_t* trx)
{
make_versioned_helper(trx, table->vers_start);
}

/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
Do not touch other fields at all.
@param[in] trx transaction */
void upd_node_t::make_versioned_delete(const trx_t* trx)
{
update->n_fields = 0;
is_delete = VERSIONED_DELETE;
make_versioned_helper(trx, table->vers_end);
}

0 comments on commit 4c7a743

Please sign in to comment.
You can’t perform that action at this time.