Skip to content

Commit 4c7a743

Browse files
committed
Merge 10.3 into 10.4
2 parents de9e393 + 29df100 commit 4c7a743

File tree

10 files changed

+65
-41
lines changed

10 files changed

+65
-41
lines changed

mysql-test/suite/versioning/r/truncate.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,17 @@ truncate t1;
130130
truncate t2;
131131
ERROR HY000: System-versioned tables do not support TRUNCATE TABLE
132132
unlock tables;
133+
#
134+
# MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
135+
#
136+
create or replace table t1 (
137+
f varchar(1),
138+
row_start SYS_TYPE as row start,
139+
row_end SYS_TYPE as row end,
140+
period for system_time (row_start, row_end))
141+
with system versioning;
142+
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
143+
delete from t1;
144+
delete history from t1;
133145
drop database test;
134146
create database test;

mysql-test/suite/versioning/t/truncate.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,19 @@ truncate t2;
145145

146146
unlock tables;
147147

148+
--echo #
149+
--echo # MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
150+
--echo #
151+
--replace_result $sys_datatype_expl SYS_TYPE
152+
eval create or replace table t1 (
153+
f varchar(1),
154+
row_start $sys_datatype_expl as row start,
155+
row_end $sys_datatype_expl as row end,
156+
period for system_time (row_start, row_end))
157+
with system versioning;
158+
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
159+
delete from t1;
160+
delete history from t1;
161+
148162
drop database test;
149163
create database test;

mysys/thr_mutex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
237237
int error;
238238
DBUG_PRINT("mutex", ("%s (0x%lx) locking", mp->name ? mp->name : "Null",
239239
(ulong) mp));
240+
241+
pthread_mutex_lock(&mp->global);
240242
if (!mp->file)
241243
{
242244
fprintf(stderr,
@@ -245,8 +247,6 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
245247
fflush(stderr);
246248
abort();
247249
}
248-
249-
pthread_mutex_lock(&mp->global);
250250
if (mp->count > 0)
251251
{
252252
/*

plugin/server_audit/server_audit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
#define PLUGIN_VERSION 0x104
19-
#define PLUGIN_STR_VERSION "1.4.7"
19+
#define PLUGIN_STR_VERSION "1.4.8"
2020

2121
#define _my_thread_var loc_thread_var
2222

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

22632263

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

22892289
#ifdef __linux__
22902290
*name= *(char **) (((char *) thd) + db_off);
2291-
*len= *((int *) (((char*) thd) + db_len_off));
2291+
*len= *((size_t *) (((char*) thd) + db_len_off));
22922292
if (*name && (*name)[*len] != 0)
22932293
return 1;
22942294
return 0;

plugin/server_audit/test_audit_v4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum enum_server_command{ SERVCOM_A, SERVCOM_B };
1616
#include "plugin_audit_v4.h"
1717

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

2121

2222
struct mysql_event_general_302
@@ -35,7 +35,7 @@ struct mysql_event_general_302
3535
unsigned long long general_rows;
3636
unsigned long long query_id;
3737
char *database;
38-
int database_length;
38+
size_t database_length;
3939
};
4040

4141

sql/sql_delete.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
351351

352352
THD_STAGE_INFO(thd, stage_init_update);
353353

354-
bool truncate_history= table_list->vers_conditions.is_set();
355-
if (truncate_history)
354+
bool delete_history= table_list->vers_conditions.is_set();
355+
if (delete_history)
356356
{
357357
DBUG_ASSERT(!table_list->period_conditions.is_set());
358358

@@ -401,7 +401,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
401401
select_lex->item_list, &conds,
402402
&delete_while_scanning))
403403
DBUG_RETURN(TRUE);
404-
404+
405+
if (delete_history)
406+
table->vers_write= false;
407+
405408
if (with_select)
406409
(void) result->prepare(select_lex->item_list, NULL);
407410

@@ -752,7 +755,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
752755
while (!(error=info.read_record()) && !thd->killed &&
753756
! thd->is_error())
754757
{
755-
if (record_should_be_deleted(thd, table, select, explain, truncate_history))
758+
if (record_should_be_deleted(thd, table, select, explain, delete_history))
756759
{
757760
table->file->position(table->record[0]);
758761
if (unlikely((error=
@@ -801,10 +804,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
801804
{
802805
if (delete_while_scanning)
803806
delete_record= record_should_be_deleted(thd, table, select, explain,
804-
truncate_history);
807+
delete_history);
805808
if (delete_record)
806809
{
807-
if (!truncate_history && table->triggers &&
810+
if (!delete_history && table->triggers &&
808811
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
809812
TRG_ACTION_BEFORE, FALSE))
810813
{
@@ -840,7 +843,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
840843
if (likely(!error))
841844
{
842845
deleted++;
843-
if (!truncate_history && table->triggers &&
846+
if (!delete_history && table->triggers &&
844847
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
845848
TRG_ACTION_AFTER, FALSE))
846849
{

storage/innobase/btr/btr0cur.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ throughput clearly from about 100000. */
9898
#define BTR_CUR_FINE_HISTORY_LENGTH 100000
9999

100100
/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
101-
ulint btr_cur_n_non_sea;
101+
Atomic_counter<ulint> btr_cur_n_non_sea;
102102
/** Old value of btr_cur_n_non_sea. Copied by
103103
srv_refresh_innodb_monitor_stats(). Referenced by
104104
srv_printf_innodb_monitor(). */

storage/innobase/include/btr0cur.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ inherited external field. */
10341034
#define BTR_EXTERN_INHERITED_FLAG 64U
10351035

10361036
/** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
1037-
extern ulint btr_cur_n_non_sea;
1037+
extern Atomic_counter<ulint> btr_cur_n_non_sea;
10381038
/** Old value of btr_cur_n_non_sea. Copied by
10391039
srv_refresh_innodb_monitor_stats(). Referenced by
10401040
srv_printf_innodb_monitor(). */

storage/innobase/include/row0upd.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,14 +571,6 @@ struct upd_node_t{
571571
/* column assignment list */
572572
ulint magic_n;
573573

574-
/** Also set row_start = CURRENT_TIMESTAMP/trx->id
575-
@param[in] trx transaction */
576-
void make_versioned_update(const trx_t* trx);
577-
/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
578-
Do not touch other fields at all.
579-
@param[in] trx transaction */
580-
void make_versioned_delete(const trx_t* trx);
581-
582574
private:
583575
/** Appends row_start or row_end field to update vector and sets a
584576
CURRENT_TIMESTAMP/trx->id value to it.
@@ -587,6 +579,24 @@ struct upd_node_t{
587579
@param[in] trx transaction
588580
@param[in] vers_sys_idx table->row_start or table->row_end */
589581
void make_versioned_helper(const trx_t* trx, ulint idx);
582+
583+
public:
584+
/** Also set row_start = CURRENT_TIMESTAMP/trx->id
585+
@param[in] trx transaction */
586+
void make_versioned_update(const trx_t* trx)
587+
{
588+
make_versioned_helper(trx, table->vers_start);
589+
}
590+
591+
/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
592+
Do not touch other fields at all.
593+
@param[in] trx transaction */
594+
void make_versioned_delete(const trx_t* trx)
595+
{
596+
update->n_fields = 0;
597+
is_delete = VERSIONED_DELETE;
598+
make_versioned_helper(trx, table->vers_end);
599+
}
590600
};
591601

592602
#define UPD_NODE_MAGIC_N 1579975

storage/innobase/row/row0upd.cc

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,8 @@ void upd_node_t::make_versioned_helper(const trx_t* trx, ulint idx)
34763476

34773477
dict_index_t* clust_index = dict_table_get_first_index(table);
34783478

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

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

3499-
/** Also set row_start = CURRENT_TIMESTAMP/trx->id
3500-
@param[in] trx transaction */
3501-
void upd_node_t::make_versioned_update(const trx_t* trx)
3502-
{
3503-
make_versioned_helper(trx, table->vers_start);
3504-
}
3505-
3506-
/** Only set row_end = CURRENT_TIMESTAMP/trx->id.
3507-
Do not touch other fields at all.
3508-
@param[in] trx transaction */
3509-
void upd_node_t::make_versioned_delete(const trx_t* trx)
3510-
{
3511-
update->n_fields = 0;
3512-
is_delete = VERSIONED_DELETE;
3513-
make_versioned_helper(trx, table->vers_end);
3514-
}

0 commit comments

Comments
 (0)