Skip to content

Commit 855aefb

Browse files
committed
mysqldump and mariadb-backup tests of vector indexes
1 parent eb4ab2c commit 855aefb

File tree

4 files changed

+172
-0
lines changed

4 files changed

+172
-0
lines changed

mysql-test/main/vector2_notembedded.result

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,70 @@
11
#
2+
# mysqldump
3+
#
4+
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
5+
insert t1 (v) values (Vec_Fromtext('[0.418,0.809,0.823,0.598,0.033]')),
6+
(Vec_Fromtext('[0.687,0.789,0.496,0.574,0.917]')),
7+
(Vec_Fromtext('[0.333,0.962,0.467,0.448,0.475]')),
8+
(Vec_Fromtext('[0.822,0.185,0.683,0.211,0.554]')),
9+
(Vec_Fromtext('[0.437,0.167,0.077,0.428,0.241]')),
10+
(Vec_Fromtext('[0.769,0.926,0.803,0.015,0.589]')),
11+
(Vec_Fromtext('[0.493,0.641,0.761,0.942,0.425]')),
12+
(Vec_Fromtext('[0.924,0.275,0.054,0.073,0.136]')),
13+
(Vec_Fromtext('[0.186,0.696,0.035,0.668,0.847]')),
14+
(Vec_Fromtext('[0.415,0.609,0.426,0.988,0.475]'));
15+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
16+
id
17+
8
18+
5
19+
4
20+
/*M!999999\- enable the sandbox mode */
21+
/*!40101 SET @saved_cs_client = @@character_set_client */;
22+
/*!40101 SET character_set_client = utf8 */;
23+
CREATE TABLE `t1` (
24+
`id` int(11) NOT NULL AUTO_INCREMENT,
25+
`v` blob NOT NULL,
26+
PRIMARY KEY (`id`),
27+
VECTOR KEY `v` (`v`)
28+
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
29+
/*!40101 SET character_set_client = @saved_cs_client */;
30+
INSERT INTO `t1` VALUES
31+
(1,0x1904D63EA01A4F3F21B0523F8716193F022B073D),
32+
(2,0x3BDF2F3FE7FB493FB6F3FD3EAAF1123F83C06A3F),
33+
(3,0xFA7EAA3EA245763FA01AEF3E4260E53E3333F33E),
34+
(4,0x986E523FA4703D3E17D92E3F6210583EF2D20D3F),
35+
(5,0x77BEDF3E0C022B3E2DB29D3DD122DB3EB4C8763E),
36+
(6,0x2FDD443F560E6D3F68914D3F8FC2753CB4C8163F),
37+
(7,0x7F6AFC3E9318243FE5D0423FE926713F9A99D93E),
38+
(8,0x448B6C3FCDCC8C3E1B2F5D3D0681953D96430B3E),
39+
(9,0xC9763E3E0E2D323F295C0F3D0C022B3FFED4583F),
40+
(10,0xE17AD43E6DE71B3FAC1CDA3E91ED7C3F3333F33E);
41+
show create table t1;
42+
Table Create Table
43+
t1 CREATE TABLE `t1` (
44+
`id` int(11) NOT NULL AUTO_INCREMENT,
45+
`v` blob NOT NULL,
46+
PRIMARY KEY (`id`),
47+
VECTOR KEY `v` (`v`)
48+
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
49+
select id, Vec_ToText(v) from t1;
50+
id Vec_ToText(v)
51+
1 [0.418000,0.809000,0.823000,0.598000,0.033000]
52+
2 [0.687000,0.789000,0.496000,0.574000,0.917000]
53+
3 [0.333000,0.962000,0.467000,0.448000,0.475000]
54+
4 [0.822000,0.185000,0.683000,0.211000,0.554000]
55+
5 [0.437000,0.167000,0.077000,0.428000,0.241000]
56+
6 [0.769000,0.926000,0.803000,0.015000,0.589000]
57+
7 [0.493000,0.641000,0.761000,0.942000,0.425000]
58+
8 [0.924000,0.275000,0.054000,0.073000,0.136000]
59+
9 [0.186000,0.696000,0.035000,0.668000,0.847000]
60+
10 [0.415000,0.609000,0.426000,0.988000,0.475000]
61+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
62+
id
63+
8
64+
5
65+
4
66+
drop table t1;
67+
#
268
# MDEV-35044 ALTER on a table with vector index attempts to bypass unsupported locking limitation, server crashes in THD::free_tmp_table_share
369
#
470
create table t (a int primary key, v blob not null, vector index(v));

mysql-test/main/vector2_notembedded.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
--source include/not_embedded.inc
22

3+
--echo #
4+
--echo # mysqldump
5+
--echo #
6+
create table t1 (id int auto_increment primary key, v blob not null, vector index (v));
7+
insert t1 (v) values (Vec_Fromtext('[0.418,0.809,0.823,0.598,0.033]')),
8+
(Vec_Fromtext('[0.687,0.789,0.496,0.574,0.917]')),
9+
(Vec_Fromtext('[0.333,0.962,0.467,0.448,0.475]')),
10+
(Vec_Fromtext('[0.822,0.185,0.683,0.211,0.554]')),
11+
(Vec_Fromtext('[0.437,0.167,0.077,0.428,0.241]')),
12+
(Vec_Fromtext('[0.769,0.926,0.803,0.015,0.589]')),
13+
(Vec_Fromtext('[0.493,0.641,0.761,0.942,0.425]')),
14+
(Vec_Fromtext('[0.924,0.275,0.054,0.073,0.136]')),
15+
(Vec_Fromtext('[0.186,0.696,0.035,0.668,0.847]')),
16+
(Vec_Fromtext('[0.415,0.609,0.426,0.988,0.475]'));
17+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
18+
replace_result InnoDB MyISAM;
19+
exec $MYSQL_DUMP --compact --hex-blob test t1;
20+
exec $MYSQL_DUMP --hex-blob test t1 > $MYSQL_TMP_DIR/vector.sql;
21+
exec $MYSQL test < $MYSQL_TMP_DIR/vector.sql;
22+
remove_file $MYSQL_TMP_DIR/vector.sql;
23+
show create table t1;
24+
select id, Vec_ToText(v) from t1;
25+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
26+
drop table t1;
27+
328
--echo #
429
--echo # MDEV-35044 ALTER on a table with vector index attempts to bypass unsupported locking limitation, server crashes in THD::free_tmp_table_share
530
--echo #
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
create table t1 (id int auto_increment primary key, v blob not null, vector index (v)) engine=innodb;
2+
insert t1 (v) values (Vec_Fromtext('[0.418,0.809,0.823,0.598,0.033]')),
3+
(Vec_Fromtext('[0.687,0.789,0.496,0.574,0.917]')),
4+
(Vec_Fromtext('[0.333,0.962,0.467,0.448,0.475]')),
5+
(Vec_Fromtext('[0.822,0.185,0.683,0.211,0.554]')),
6+
(Vec_Fromtext('[0.437,0.167,0.077,0.428,0.241]')),
7+
(Vec_Fromtext('[0.769,0.926,0.803,0.015,0.589]')),
8+
(Vec_Fromtext('[0.493,0.641,0.761,0.942,0.425]')),
9+
(Vec_Fromtext('[0.924,0.275,0.054,0.073,0.136]')),
10+
(Vec_Fromtext('[0.186,0.696,0.035,0.668,0.847]')),
11+
(Vec_Fromtext('[0.415,0.609,0.426,0.988,0.475]'));
12+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
13+
id
14+
8
15+
5
16+
4
17+
drop table t1;
18+
db.opt
19+
t1#i#01.ibd
20+
t1.frm
21+
t1.ibd
22+
# shutdown server
23+
# remove datadir
24+
# xtrabackup move back
25+
# restart
26+
show create table t1;
27+
Table Create Table
28+
t1 CREATE TABLE `t1` (
29+
`id` int(11) NOT NULL AUTO_INCREMENT,
30+
`v` blob NOT NULL,
31+
PRIMARY KEY (`id`),
32+
VECTOR KEY `v` (`v`)
33+
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
34+
select id, Vec_ToText(v) from t1;
35+
id Vec_ToText(v)
36+
1 [0.418000,0.809000,0.823000,0.598000,0.033000]
37+
2 [0.687000,0.789000,0.496000,0.574000,0.917000]
38+
3 [0.333000,0.962000,0.467000,0.448000,0.475000]
39+
4 [0.822000,0.185000,0.683000,0.211000,0.554000]
40+
5 [0.437000,0.167000,0.077000,0.428000,0.241000]
41+
6 [0.769000,0.926000,0.803000,0.015000,0.589000]
42+
7 [0.493000,0.641000,0.761000,0.942000,0.425000]
43+
8 [0.924000,0.275000,0.054000,0.073000,0.136000]
44+
9 [0.186000,0.696000,0.035000,0.668000,0.847000]
45+
10 [0.415000,0.609000,0.426000,0.988000,0.475000]
46+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
47+
id
48+
8
49+
5
50+
4
51+
drop table t1;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
create table t1 (id int auto_increment primary key, v blob not null, vector index (v)) engine=innodb;
2+
insert t1 (v) values (Vec_Fromtext('[0.418,0.809,0.823,0.598,0.033]')),
3+
(Vec_Fromtext('[0.687,0.789,0.496,0.574,0.917]')),
4+
(Vec_Fromtext('[0.333,0.962,0.467,0.448,0.475]')),
5+
(Vec_Fromtext('[0.822,0.185,0.683,0.211,0.554]')),
6+
(Vec_Fromtext('[0.437,0.167,0.077,0.428,0.241]')),
7+
(Vec_Fromtext('[0.769,0.926,0.803,0.015,0.589]')),
8+
(Vec_Fromtext('[0.493,0.641,0.761,0.942,0.425]')),
9+
(Vec_Fromtext('[0.924,0.275,0.054,0.073,0.136]')),
10+
(Vec_Fromtext('[0.186,0.696,0.035,0.668,0.847]')),
11+
(Vec_Fromtext('[0.415,0.609,0.426,0.988,0.475]'));
12+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
13+
14+
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
15+
let $backup_log=$MYSQLTEST_VARDIR/tmp/backup.log;
16+
17+
--disable_result_log
18+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
19+
exec $XTRABACKUP --prepare --target-dir=$targetdir;
20+
--enable_result_log
21+
22+
drop table t1;
23+
--list_files $targetdir/test
24+
--source include/restart_and_restore.inc
25+
26+
show create table t1;
27+
select id, Vec_ToText(v) from t1;
28+
select id from t1 order by vec_distance_euclidean(v, Vec_FromText('[1,0,0,0,0]')) limit 3;
29+
drop table t1;
30+
rmdir $targetdir;

0 commit comments

Comments
 (0)