Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/r/bug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# MDEV-27569 Valgrind/MSAN errors in ha_partition::swap_blobs
#
create table t (id int, a int, b text, key(a), primary key (id)) engine=innodb
partition by hash(id) partitions 2;
insert into t (id,a) select seq, seq%10 from seq_1_to_20;
select * from t where id >= 1900 or a in (2,4) limit 1;
id a b
2 2 NULL
drop table t;
# End of 10.11 tests
18 changes: 18 additions & 0 deletions mysql-test/suite/innodb/t/bug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--source include/have_partition.inc
--source include/have_innodb.inc
--source include/have_sequence.inc

# TODO (newbie): compile all innodb_bug*.test into this file

--echo #
--echo # MDEV-27569 Valgrind/MSAN errors in ha_partition::swap_blobs
--echo #
create table t (id int, a int, b text, key(a), primary key (id)) engine=innodb
partition by hash(id) partitions 2;
insert into t (id,a) select seq, seq%10 from seq_1_to_20;
select * from t where id >= 1900 or a in (2,4) limit 1;
Comment thread
midenok marked this conversation as resolved.

# cleanup
drop table t;

--echo # End of 10.11 tests
6 changes: 3 additions & 3 deletions mysql-test/suite/sql_sequence/other.result
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ DROP SEQUENCE s1;
#
CREATE SEQUENCE s1 nocache engine=myisam;
CREATE table t1 (a int check (next value for s1 > 0));
ERROR HY000: Function or expression 'nextval()' cannot be used in the CHECK clause of `a`
ERROR 42000: CHECK does not support subqueries or stored functions
CREATE table t1 (a int check (previous value for s1 > 0));
ERROR HY000: Function or expression 'lastval()' cannot be used in the CHECK clause of `a`
ERROR 42000: CHECK does not support subqueries or stored functions
CREATE table t1 (a int check (setval(s1,10)));
ERROR HY000: Function or expression 'setval()' cannot be used in the CHECK clause of `a`
ERROR 42000: CHECK does not support subqueries or stored functions
CREATE TABLE t1 (a int, b int as (next value for s1 > 0));
ERROR HY000: Function or expression 'nextval()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop sequence s1;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/sql_sequence/other.test
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ DROP SEQUENCE s1;
--echo #

CREATE SEQUENCE s1 nocache engine=myisam;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
--error ER_SUBQUERIES_NOT_SUPPORTED
CREATE table t1 (a int check (next value for s1 > 0));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
--error ER_SUBQUERIES_NOT_SUPPORTED
CREATE table t1 (a int check (previous value for s1 > 0));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
--error ER_SUBQUERIES_NOT_SUPPORTED
CREATE table t1 (a int check (setval(s1,10)));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a int, b int as (next value for s1 > 0));
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -3586,6 +3586,19 @@ x
1
drop table t1;
#
# MDEV-36362 MariaDB crashes when parsing fuzzer generated PARTITION
#
create table t
partition by system_time
interval setval(a, 1) second_microsecond;
ERROR 42000: INTERVAL does not support subqueries or stored functions
create table t (x int) with system versioning
partition by system_time interval nextval(s) hour;
ERROR 42000: INTERVAL does not support subqueries or stored functions
create table t (x int) with system versioning
partition by system_time interval lastval(s) hour;
ERROR 42000: INTERVAL does not support subqueries or stored functions
#
# MDEV-33289 INTERVAL partitioning by system time does not work close to
# the end of timestamp range
#
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/versioning/r/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,11 @@ nid nstate check_row(row_start, row_end)
commit;
drop tables t1;
# End of 10.4 tests
#
# MDEV-38854 Assertion table->vers_write fails upon ODKU into table with versioned column
#
create table t (a int, b int, c int with system versioning, unique(b));
insert into t (b) values (1);
insert into t (b) values (1),(1) on duplicate key update a = 3;
drop table t;
# End of 10.11 tests
16 changes: 16 additions & 0 deletions mysql-test/suite/versioning/t/partition.test
Original file line number Diff line number Diff line change
Expand Up @@ -2813,6 +2813,22 @@ Select * from t1 for system_time as of '2000-01-01 00:59:59';

drop table t1;

--echo #
--echo # MDEV-36362 MariaDB crashes when parsing fuzzer generated PARTITION
--echo #
--error ER_SUBQUERIES_NOT_SUPPORTED
create table t
partition by system_time
interval setval(a, 1) second_microsecond;

--error ER_SUBQUERIES_NOT_SUPPORTED
create table t (x int) with system versioning
partition by system_time interval nextval(s) hour;

--error ER_SUBQUERIES_NOT_SUPPORTED
create table t (x int) with system versioning
partition by system_time interval lastval(s) hour;

--echo #
--echo # MDEV-33289 INTERVAL partitioning by system time does not work close to
--echo # the end of timestamp range
Expand Down
10 changes: 10 additions & 0 deletions mysql-test/suite/versioning/t/update.test
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,14 @@ drop tables t1;

--echo # End of 10.4 tests

--echo #
--echo # MDEV-38854 Assertion table->vers_write fails upon ODKU into table with versioned column
--echo #
create table t (a int, b int, c int with system versioning, unique(b));
insert into t (b) values (1);
insert into t (b) values (1),(1) on duplicate key update a = 3;
drop table t;

--echo # End of 10.11 tests

source suite/versioning/common_finish.inc;
2 changes: 1 addition & 1 deletion sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5350,7 +5350,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds()

table_name.str= tmp_table->alias.c_ptr();
table_name.length= tmp_table->alias.length(),
tmp_table_ref->init_one_table(&empty_clex_str, &table_name, NULL, TL_READ);
tmp_table_ref->init_one_tab_r(&empty_clex_str, &table_name, NULL, TL_READ);
tmp_table_ref->table= tmp_table;

context= new Name_resolution_context(tmp_table_ref);
Expand Down
2 changes: 1 addition & 1 deletion sql/log_event_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6991,7 +6991,7 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi)
LEX_CSTRING tmp_db_name= {db_mem, db_mem_length };
LEX_CSTRING tmp_tbl_name= {tname_mem, tname_mem_length };

table_list->init_one_table(&tmp_db_name, &tmp_tbl_name, 0, TL_WRITE);
table_list->init_one_tab_r(&tmp_db_name, &tmp_tbl_name, 0, TL_WRITE);
table_list->table_id= DBUG_IF("inject_tblmap_same_id_maps_diff_table") ? 0 : m_table_id;
table_list->updating= 1;
table_list->required_type= TABLE_TYPE_NORMAL;
Expand Down
2 changes: 2 additions & 0 deletions sql/mdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ void MDL_request::init_with_source(MDL_key::enum_mdl_namespace mdl_namespace,
uint src_line)
{
key.mdl_key_init(mdl_namespace, db_arg, name_arg);
DBUG_ASSERT(mdl_type_arg != MDL_NOT_INITIALIZED);
type= mdl_type_arg;
duration= mdl_duration_arg;
ticket= NULL;
Expand All @@ -1041,6 +1042,7 @@ void MDL_request::init_by_key_with_source(const MDL_key *key_arg,
uint src_line)
{
key.mdl_key_init(key_arg);
DBUG_ASSERT(mdl_type_arg != MDL_NOT_INITIALIZED);
type= mdl_type_arg;
duration= mdl_duration_arg;
ticket= NULL;
Expand Down
6 changes: 0 additions & 6 deletions sql/mdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class MDL_context_owner

enum enum_mdl_type {
/* This means that the MDL_request is not initialized */
/*
TODO (newbie): should be MDL_NOT_INITIALIZED= 0, as it is strange
that not-inited request has MDL_INTENTION_EXCLUSIVE.
Must fix tests, as at least mysql_rm_table_no_locks() depends on this.
*/
MDL_NOT_INITIALIZED= -1,
/*
An intention exclusive metadata lock (IX). Used only for scoped locks.
Expand Down Expand Up @@ -615,7 +610,6 @@ class MDL_request
/* Do nothing, in particular, don't try to copy the key. */
return *this;
}
/* Another piece of ugliness for TABLE_LIST constructor */
MDL_request(): type(MDL_NOT_INITIALIZED), ticket(NULL) {}

MDL_request(const MDL_request *rhs)
Expand Down
1 change: 0 additions & 1 deletion sql/partition_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,6 @@ void partition_info::print_no_partition_found(TABLE *table_arg, myf errflag)
TABLE_LIST table_list;
THD *thd= current_thd;

table_list.reset();
table_list.db= table_arg->s->db;
table_list.table_name= table_arg->s->table_name;

Expand Down
2 changes: 1 addition & 1 deletion sql/sp_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5276,7 +5276,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
LEX_CSTRING alias= { table_name.str + table_name.length + 1,
strlen(table_name.str + table_name.length + 1) };

table->init_one_table_for_prelocking(&db_name,
table->init_one_table_for_prelockn_r(&db_name,
&table_name,
&alias,
stab->lock_type,
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ class Grant_tables
TABLE_LIST *tl= tables + i;
if (which_tables & (1 << i))
{
tl->init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME[i],
tl->init_one_tab_r(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME[i],
NULL, lock_type);
tl->open_type= OT_BASE_ONLY;
tl->i_s_requested_object= OPEN_TABLE_ONLY;
Expand Down Expand Up @@ -2068,7 +2068,7 @@ class Grant_tables
TABLE *backup_open_tables= thd->open_tables;
thd->set_open_tables(NULL);

tl->init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME_USER,
tl->init_one_tab_r(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME_USER,
NULL, lock_type);
tl->open_type= OT_BASE_ONLY;
tl->i_s_requested_object= OPEN_TABLE_ONLY;
Expand Down
8 changes: 4 additions & 4 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,7 @@ Locked_tables_list::init_locked_tables(THD *thd)
memcpy((char*) table_name.str, table->s->table_name.str,
table_name.length + 1);
memcpy((char*) alias.str, table->alias.c_ptr(), alias.length + 1);
dst_table_list->init_one_table(&db, &table_name,
dst_table_list->init_one_tab_r(&db, &table_name,
&alias, table->reginfo.lock_type);
dst_table_list->table= table;
dst_table_list->mdl_request.ticket= src_table_list->mdl_request.ticket;
Expand Down Expand Up @@ -3448,7 +3448,7 @@ request_backoff_action(enum_open_table_action action_arg,
m_failed_table= (TABLE_LIST*) m_thd->alloc(sizeof(TABLE_LIST));
if (m_failed_table == NULL)
return TRUE;
m_failed_table->init_one_table(&table->db, &table->table_name, &table->alias, TL_WRITE);
m_failed_table->init_one_tab_r(&table->db, &table->table_name, &table->alias, TL_WRITE);
m_failed_table->open_strategy= table->open_strategy;
m_failed_table->mdl_request.set_type(MDL_EXCLUSIVE);
m_failed_table->vers_skip_create= table->vers_skip_create;
Expand Down Expand Up @@ -5056,7 +5056,7 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx,
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
if (!tl)
DBUG_RETURN(TRUE);
tl->init_one_table_for_prelocking(&tables->db,
tl->init_one_table_for_prelockn_r(&tables->db,
&tables->table_name,
NULL, tables->lock_type,
TABLE_LIST::PRELOCK_NONE,
Expand Down Expand Up @@ -5131,7 +5131,7 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx,
continue;

TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
tl->init_one_table_for_prelocking(fk->foreign_db,
tl->init_one_table_for_prelockn_r(fk->foreign_db,
fk->foreign_table,
NULL, lock_type,
TABLE_LIST::PRELOCK_FK,
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5035,7 +5035,7 @@ TABLE *open_purge_table(THD *thd, const char *db, size_t dblen,
LEX_CSTRING db_name= {db, dblen };
LEX_CSTRING table_name= { tb, tblen };

tl->init_one_table(&db_name, &table_name, 0, TL_READ);
tl->init_one_tab_r(&db_name, &table_name, 0, TL_READ);
tl->i_s_requested_object= OPEN_TABLE_ONLY;

bool error= open_table(thd, tl, &ot_ctx);
Expand Down
26 changes: 16 additions & 10 deletions sql/sql_insert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2247,18 +2247,25 @@ int Write_record::insert_on_duplicate_update(ha_rows *inserted,
if (error != HA_ERR_RECORD_IS_THE_SAME)
{
++*updated;
if (table->versioned() &&
table->vers_check_update(*info->update_fields))
if (table->versioned())
{
if (versioned)
if (table->vers_check_update(*info->update_fields))
{
store_record(table, record[2]);
error= vers_insert_history_row(table);
restore_record(table, record[2]);
if (unlikely(error))
return on_ha_error(error);
if (versioned)
{
store_record(table, record[2]);
error= vers_insert_history_row(table);
restore_record(table, record[2]);
if (unlikely(error))
return on_ha_error(error);
}
++*inserted;
}
++*inserted;
/*
INSERT will need it in the next bulk iteration
(see vers_check_update() and MDEV-25644).
*/
table->vers_write= true;
}
}
/*
Expand Down Expand Up @@ -5208,7 +5215,6 @@ static int binlog_show_create_table_(THD *thd, TABLE *table,
int result;
TABLE_LIST tmp_table_list;

tmp_table_list.reset();
tmp_table_list.table = table;

result= show_create_table(thd, &tmp_table_list, &query,
Expand Down
Loading