mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
VECTOR indexes support for RENAME TABLE
Rename high-level indexes along with a table.
This commit is contained in:
parent
ebcbed6d74
commit
97e112fb82
4 changed files with 87 additions and 0 deletions
|
@ -321,3 +321,35 @@ t1 CREATE TABLE `t1` (
|
|||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
|
||||
drop table t1;
|
||||
db.opt
|
||||
# Test RENAME TABLE with vector index
|
||||
create table t1 (id int auto_increment primary key, v blob not null, vector index (v)) engine=MyISAM;
|
||||
db.opt
|
||||
t1#i#01.MYD
|
||||
t1#i#01.MYI
|
||||
t1.MYD
|
||||
t1.MYI
|
||||
t1.frm
|
||||
rename table t1 to t2;
|
||||
db.opt
|
||||
t2#i#01.MYD
|
||||
t2#i#01.MYI
|
||||
t2.MYD
|
||||
t2.MYI
|
||||
t2.frm
|
||||
create database test1;
|
||||
rename table test.t2 to test1.t1;
|
||||
db.opt
|
||||
t1#i#01.MYD
|
||||
t1#i#01.MYI
|
||||
t1.MYD
|
||||
t1.MYI
|
||||
t1.frm
|
||||
rename table test1.t2 to test1.t1;
|
||||
ERROR 42S02: Table 'test1.t2' doesn't exist
|
||||
db.opt
|
||||
t1#i#01.MYI
|
||||
t1.MYD
|
||||
t1.MYI
|
||||
t1.frm
|
||||
drop database test1;
|
||||
db.opt
|
||||
|
|
|
@ -121,3 +121,19 @@ replace_result InnoDB MyISAM;
|
|||
show create table t1;
|
||||
drop table t1;
|
||||
list_files $datadir/test;
|
||||
|
||||
--echo # Test RENAME TABLE with vector index
|
||||
create table t1 (id int auto_increment primary key, v blob not null, vector index (v)) engine=MyISAM;
|
||||
list_files $datadir/test;
|
||||
rename table t1 to t2;
|
||||
list_files $datadir/test;
|
||||
create database test1;
|
||||
rename table test.t2 to test1.t1;
|
||||
list_files $datadir/test1;
|
||||
|
||||
remove_file $datadir/test1/t1#i#01.MYD;
|
||||
--error ER_NO_SUCH_TABLE
|
||||
rename table test1.t2 to test1.t1;
|
||||
list_files $datadir/test1;
|
||||
drop database test1;
|
||||
list_files $datadir/test;
|
||||
|
|
|
@ -65,6 +65,7 @@ flush tables;
|
|||
rename table t2 to t0;
|
||||
db.opt
|
||||
t0.ARZ
|
||||
t0.frm
|
||||
t1.ARZ
|
||||
t1.frm
|
||||
#
|
||||
|
@ -83,6 +84,7 @@ flush tables;
|
|||
drop table t1;
|
||||
db.opt
|
||||
t0.ARZ
|
||||
t0.frm
|
||||
#
|
||||
# discover of table non-existence on drop
|
||||
#
|
||||
|
|
|
@ -5389,6 +5389,43 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db,
|
|||
}
|
||||
else
|
||||
log_query= true;
|
||||
|
||||
/* Rename high-level indexes */
|
||||
if (file && !error)
|
||||
{
|
||||
char idx_from[FN_REFLEN + 1], idx_to[FN_REFLEN + 1];
|
||||
char *idx_from_end= strmov(idx_from, from_base);
|
||||
char *idx_to_end= strmov(idx_to, to_base);
|
||||
TABLE_SHARE share;
|
||||
|
||||
init_tmp_table_share(thd, &share, new_db->str, 0, new_name->str, to, 1);
|
||||
if (!open_table_def(thd, &share, GTS_TABLE | GTS_USE_DISCOVERY))
|
||||
{
|
||||
for (uint i= share.keys; i < share.total_keys; i++)
|
||||
{
|
||||
my_snprintf(idx_from_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i);
|
||||
my_snprintf(idx_to_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i);
|
||||
if ((error= file->ha_rename_table(idx_from, idx_to)))
|
||||
{
|
||||
for (; i >= share.keys; i--)
|
||||
{
|
||||
my_snprintf(idx_from_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i);
|
||||
my_snprintf(idx_to_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i);
|
||||
file->ha_rename_table(idx_to, idx_from);
|
||||
}
|
||||
file->ha_rename_table(to_base, from_base);
|
||||
rename_file_ext(to, from, reg_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file->ha_rename_table(to_base, from_base);
|
||||
rename_file_ext(to, from, reg_ext);
|
||||
error= 1;
|
||||
}
|
||||
free_table_share(&share);
|
||||
}
|
||||
}
|
||||
if (!error && log_query && !(flags & (FN_TO_IS_TMP | FN_FROM_IS_TMP)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue