MDEV-34919 post-fix

* add Aria truncate checks
* do store_lock() with a correct TL_xxx level
* remove InnoDB workaround for missing store_lock (from MDEV-35032)
* don't start transaction in temp tables (for Aria, with a test case)
This commit is contained in:
Sergei Golubchik 2024-10-25 15:58:06 +02:00
parent 1cc7ef52e3
commit f6de9a379a
6 changed files with 71 additions and 11 deletions

View File

@ -43,7 +43,40 @@
drop table t1, t2; drop table t1, t2;
db.opt db.opt
# Test insert ... select with vector index # Test insert ... select with vector index
@@ -401,33 +401,39 @@ @@ -388,8 +388,32 @@ db.opt
create table t1 (id int auto_increment primary key, v vector(5) not null, vector index (v));
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
truncate table t1;
+Aria file: datadir/test/t1#i#01
+Record format: Block
+Crashsafe: yes
+Character set: utf8mb4_uca1400_ai_ci (2304)
+Data records: 0 Deleted blocks: 0
+Block_size: 8192
+Recordlength: 36
+
+Table description:
+Key Start Len Index Type
+1 3 5 unique varbin NULL
+2 2 1 multip. int8
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
truncate table t1;
+Aria file: datadir/test/t1#i#01
+Record format: Block
+Crashsafe: yes
+Character set: utf8mb4_uca1400_ai_ci (2304)
+Data records: 0 Deleted blocks: 0
+Block_size: 8192
+Recordlength: 36
+
+Table description:
+Key Start Len Index Type
+1 3 5 unique varbin NULL
+2 2 1 multip. int8
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
select id, hex(v) from t1;
id hex(v)
@@ -401,33 +425,39 @@ t1 CREATE TABLE `t1` (
`v` vector(5) NOT NULL, `v` vector(5) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
VECTOR KEY `v` (`v`) VECTOR KEY `v` (`v`)

View File

@ -165,12 +165,20 @@ if ($MTR_COMBINATION_MYISAM) {
--replace_result $datadir datadir --replace_result $datadir datadir
--exec $MYISAMCHK -d $datadir/test/t1#i#01 --exec $MYISAMCHK -d $datadir/test/t1#i#01
} }
if ($MTR_COMBINATION_ARIA) {
--replace_result $datadir datadir
--exec $MARIA_CHK -d $datadir/test/t1#i#01
}
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d'); insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
truncate table t1; truncate table t1;
if ($MTR_COMBINATION_MYISAM) { if ($MTR_COMBINATION_MYISAM) {
--replace_result $datadir datadir --replace_result $datadir datadir
--exec $MYISAMCHK -d $datadir/test/t1#i#01 --exec $MYISAMCHK -d $datadir/test/t1#i#01
} }
if ($MTR_COMBINATION_ARIA) {
--replace_result $datadir datadir
--exec $MARIA_CHK -d $datadir/test/t1#i#01
}
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d'); insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
select id, hex(v) from t1; select id, hex(v) from t1;
replace_result InnoDB MyISAM; replace_result InnoDB MyISAM;

View File

@ -0,0 +1,10 @@
#
# Aria, ALTER TABLE
#
create table t (a int primary key, f vector(1) not null) engine=Aria;
insert into t values (1, 0x30303030),(2, 0x31313131);
alter table t add vector(f);
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
drop table t;

View File

@ -0,0 +1,8 @@
--echo #
--echo # Aria, ALTER TABLE
--echo #
create table t (a int primary key, f vector(1) not null) engine=Aria;
insert into t values (1, 0x30303030),(2, 0x31313131);
alter table t add vector(f);
check table t extended;
drop table t;

View File

@ -9897,18 +9897,21 @@ int TABLE::hlindex_open(uint nr)
hlindex->in_use= in_use; // mark in use for this query hlindex->in_use= in_use; // mark in use for this query
hlindex->use_all_columns(); hlindex->use_all_columns();
THR_LOCK_DATA *lock_data;
DBUG_ASSERT(hlindex->file->lock_count() <= 1);
hlindex->file->store_lock(in_use, &lock_data, reginfo.lock_type);
int res= hlindex->file->ha_external_lock(in_use, int res= hlindex->file->ha_external_lock(in_use,
reginfo.lock_type < TL_FIRST_WRITE ? F_RDLCK : F_WRLCK); reginfo.lock_type < TL_FIRST_WRITE ? F_RDLCK : F_WRLCK);
/* if (hlindex->file->lock_count() > 0)
This code is here mostly for Aria. It requires start_trans() call to handle
transaction logging.
*/
if (res == 0 && hlindex->file->lock_count() == 1)
{ {
THR_LOCK_DATA *lock_data; /*
hlindex->file->store_lock(in_use, &lock_data, TL_IGNORE); This code is here mostly for Aria. It requires start_trans() call
if (lock_data->lock->start_trans) to handle transaction logging.
*/
if (res == 0 && !s->tmp_table && lock_data->lock->start_trans)
lock_data->lock->start_trans(lock_data->status_param); lock_data->lock->start_trans(lock_data->status_param);
lock_data->type= TL_UNLOCK;
} }
return res; return res;
} }

View File

@ -16148,8 +16148,6 @@ ha_innobase::external_lock(
DEBUG_SYNC_C("ha_innobase_end_statement"); DEBUG_SYNC_C("ha_innobase_end_statement");
/* MySQL is releasing a table lock */ /* MySQL is releasing a table lock */
m_prebuilt->select_lock_type = LOCK_NONE;
m_prebuilt->stored_select_lock_type = LOCK_NONE;
trx->n_mysql_tables_in_use--; trx->n_mysql_tables_in_use--;
m_mysql_has_locked = false; m_mysql_has_locked = false;