mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
post-fixes for TRUNCATE
* fix the truncate-by-handler variant, used by InnoDB * test that insert works after truncate, meaning graph table was emptied * test that the vector index size is zero after truncate in MyISAM
This commit is contained in:
33
mysql-test/main/vector,myisam.rdiff
Normal file
33
mysql-test/main/vector,myisam.rdiff
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
--- a/mysql-test/main/vector.result
|
||||||
|
+++ b/mysql-test/main/vector.result
|
||||||
|
@@ -305,8 +305,30 @@
|
||||||
|
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
|
truncate table t1;
|
||||||
|
+
|
||||||
|
+MyISAM file: datadir/test/t1#i#01
|
||||||
|
+Record format: Packed
|
||||||
|
+Character set: ? (0)
|
||||||
|
+Data records: 0 Deleted blocks: 0
|
||||||
|
+Recordlength: 30
|
||||||
|
+
|
||||||
|
+table description:
|
||||||
|
+Key Start Len Index Type
|
||||||
|
+1 3 6 unique varbin NULL
|
||||||
|
+2 2 1 multip. int8
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
|
truncate table t1;
|
||||||
|
+
|
||||||
|
+MyISAM file: datadir/test/t1#i#01
|
||||||
|
+Record format: Packed
|
||||||
|
+Character set: ? (0)
|
||||||
|
+Data records: 0 Deleted blocks: 0
|
||||||
|
+Recordlength: 30
|
||||||
|
+
|
||||||
|
+table description:
|
||||||
|
+Key Start Len Index Type
|
||||||
|
+1 3 6 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)
|
@@ -303,11 +303,14 @@ id hex(v)
|
|||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
db.opt
|
db.opt
|
||||||
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
|
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
insert t1 (v) values (x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
select * from t1;
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
id v
|
select id, hex(v) from t1;
|
||||||
|
id hex(v)
|
||||||
|
1 E360D63EBE554F3FCDBC523F4522193F5236083D
|
||||||
show create table t1;
|
show create table t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
@@ -315,6 +318,6 @@ t1 CREATE TABLE `t1` (
|
|||||||
`v` blob NOT NULL,
|
`v` blob NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
VECTOR KEY `v` (`v`)
|
VECTOR KEY `v` (`v`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
|
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
|
||||||
drop table t1;
|
drop table t1;
|
||||||
db.opt
|
db.opt
|
||||||
|
@@ -103,10 +103,20 @@ drop table t1, t2;
|
|||||||
list_files $datadir/test;
|
list_files $datadir/test;
|
||||||
|
|
||||||
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
|
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
insert t1 (v) values (x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
if ($MTR_COMBINATION_MYISAM) {
|
||||||
|
--replace_result $datadir datadir
|
||||||
|
--exec $MYISAMCHK -d $datadir/test/t1#i#01
|
||||||
|
}
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
select * from t1;
|
if ($MTR_COMBINATION_MYISAM) {
|
||||||
|
--replace_result $datadir datadir
|
||||||
|
--exec $MYISAMCHK -d $datadir/test/t1#i#01
|
||||||
|
}
|
||||||
|
insert t1 (id, v) values (1, x'e360d63ebe554f3fcdbc523f4522193f5236083d');
|
||||||
|
select id, hex(v) from t1;
|
||||||
replace_result InnoDB MyISAM;
|
replace_result InnoDB MyISAM;
|
||||||
show create table t1;
|
show create table t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
@@ -5478,7 +5478,7 @@ handler::ha_delete_all_rows()
|
|||||||
|
|
||||||
int err= delete_all_rows();
|
int err= delete_all_rows();
|
||||||
if (!err)
|
if (!err)
|
||||||
err= table->hlindexes_on_delete_all();
|
err= table->hlindexes_on_delete_all(false);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -5497,7 +5497,14 @@ handler::ha_truncate()
|
|||||||
m_lock_type == F_WRLCK);
|
m_lock_type == F_WRLCK);
|
||||||
mark_trx_read_write();
|
mark_trx_read_write();
|
||||||
|
|
||||||
return truncate();
|
int err= truncate();
|
||||||
|
if (!err && table->s->hlindexes())
|
||||||
|
{
|
||||||
|
if (!(err= table->hlindex_open(table->s->keys)))
|
||||||
|
err= table->hlindexes_on_delete_all(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9952,11 +9952,11 @@ int TABLE::hlindexes_on_delete(const uchar *buf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TABLE::hlindexes_on_delete_all()
|
int TABLE::hlindexes_on_delete_all(bool truncate)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(s->hlindexes() == (hlindex != NULL));
|
DBUG_ASSERT(s->hlindexes() == (hlindex != NULL));
|
||||||
if (hlindex && hlindex->in_use)
|
if (hlindex && hlindex->in_use)
|
||||||
if (int err= mhnsw_delete_all(this, key_info + s->keys))
|
if (int err= mhnsw_delete_all(this, key_info + s->keys, truncate))
|
||||||
return err;
|
return err;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1801,7 +1801,7 @@ public:
|
|||||||
int hlindexes_on_insert();
|
int hlindexes_on_insert();
|
||||||
int hlindexes_on_update();
|
int hlindexes_on_update();
|
||||||
int hlindexes_on_delete(const uchar *buf);
|
int hlindexes_on_delete(const uchar *buf);
|
||||||
int hlindexes_on_delete_all();
|
int hlindexes_on_delete_all(bool truncate);
|
||||||
int reset_hlindexes();
|
int reset_hlindexes();
|
||||||
|
|
||||||
void prepare_triggers_for_insert_stmt_or_event();
|
void prepare_triggers_for_insert_stmt_or_event();
|
||||||
|
@@ -1250,7 +1250,7 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mhnsw_delete_all(TABLE *table, KEY *keyinfo)
|
int mhnsw_delete_all(TABLE *table, KEY *keyinfo, bool truncate)
|
||||||
{
|
{
|
||||||
TABLE *graph= table->hlindex;
|
TABLE *graph= table->hlindex;
|
||||||
|
|
||||||
@@ -1259,7 +1259,8 @@ int mhnsw_delete_all(TABLE *table, KEY *keyinfo)
|
|||||||
DBUG_ASSERT(keyinfo->algorithm == HA_KEY_ALG_VECTOR);
|
DBUG_ASSERT(keyinfo->algorithm == HA_KEY_ALG_VECTOR);
|
||||||
DBUG_ASSERT(keyinfo->usable_key_parts == 1);
|
DBUG_ASSERT(keyinfo->usable_key_parts == 1);
|
||||||
|
|
||||||
if (int err= graph->file->ha_delete_all_rows())
|
if (int err= truncate ? graph->file->truncate()
|
||||||
|
: graph->file->delete_all_rows())
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
MHNSW_Context *ctx;
|
MHNSW_Context *ctx;
|
||||||
|
@@ -26,7 +26,7 @@ int mhnsw_insert(TABLE *table, KEY *keyinfo);
|
|||||||
int mhnsw_read_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit);
|
int mhnsw_read_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit);
|
||||||
int mhnsw_read_next(TABLE *table);
|
int mhnsw_read_next(TABLE *table);
|
||||||
int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo);
|
int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo);
|
||||||
int mhnsw_delete_all(TABLE *table, KEY *keyinfo);
|
int mhnsw_delete_all(TABLE *table, KEY *keyinfo, bool truncate);
|
||||||
void mhnsw_free(TABLE_SHARE *share);
|
void mhnsw_free(TABLE_SHARE *share);
|
||||||
|
|
||||||
extern ulonglong mhnsw_cache_size;
|
extern ulonglong mhnsw_cache_size;
|
||||||
|
Reference in New Issue
Block a user