[MDEV-30915] ALTER TABLE .. ALGORITHM=COPY duplicates contents of multiple file table Created: 2023-03-23  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - Connect
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Andrew Hutchings
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If ALTER is performed with COPY algorithm (explicitly or implicitly) on a CONNECT table with (potentially) multiple underlying files, the contents of the underlying file gets duplicated.

Maybe it would be happening for non-multiple tables too, but MDEV-30909 (COPY algorithm is not supported) doesn't allow to check it.

INSTALL SONAME 'ha_connect';
 
let $MYSQLD_DATADIR= `select @@datadir`;
 
--write_file $MYSQLD_DATADIR/test/num1.csv
1
2
EOF
 
CREATE TABLE t (a int NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='num?.csv' MULTIPLE=1;
SELECT * FROM t;
ALTER TABLE t FORCE;
SELECT * FROM t;
 
ALTER TABLE t FORCE, ALGORITHM=COPY;
SELECT * FROM t;
 
--echo # File contents
--cat_file $MYSQLD_DATADIR/test/num1.csv
 
# Cleanup
DROP TABLE t;
UNINSTALL SONAME 'ha_connect';

10.4 ff3d4395

ALTER TABLE t FORCE;
Warnings:
Warning	1105	This is an outward table, table data were not modified.
SELECT * FROM t;
a
1
2
ALTER TABLE t FORCE, ALGORITHM=COPY;
SELECT * FROM t;
a
1
2
1
2
# File contents
1
2
1
2


Generated at Thu Feb 08 10:19:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.