mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix for bug #35392: Delete all statement does not execute properly
after few delete statements Problem: changing a file size might require that it must be unmapped beforehand. Fix: unmap the file before changing its size. mysql-test/r/temp_table.result: Fix for bug #35392: Delete all statement does not execute properly after few delete statements - test result. mysql-test/t/temp_table.test: Fix for bug #35392: Delete all statement does not execute properly after few delete statements - test case. storage/myisam/mi_delete_all.c: Fix for bug #35392: Delete all statement does not execute properly after few delete statements - unmap file before changing its size as it's required by SetEndOfFile() function (see my_chsize()). - as no other threads allowed to perform concurrent inserts when delete_all is called, mmap_lock locking removed.
This commit is contained in:
@@ -184,3 +184,14 @@ select * from t1;
|
|||||||
a
|
a
|
||||||
42
|
42
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
|
||||||
|
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
|
||||||
|
DELETE FROM t1 WHERE a=1;
|
||||||
|
SELECT count(*) FROM t1;
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
DELETE FROM t1;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
a b
|
||||||
|
DROP TABLE t1;
|
||||||
|
End of 5.1 tests
|
||||||
|
@@ -191,3 +191,17 @@ truncate t1;
|
|||||||
insert into t1 values (42);
|
insert into t1 values (42);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #35392: Delete all statement does not execute properly after
|
||||||
|
# few delete statements
|
||||||
|
#
|
||||||
|
CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20));
|
||||||
|
INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3');
|
||||||
|
DELETE FROM t1 WHERE a=1;
|
||||||
|
SELECT count(*) FROM t1;
|
||||||
|
DELETE FROM t1;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo End of 5.1 tests
|
||||||
|
@@ -53,15 +53,18 @@ int mi_delete_all_rows(MI_INFO *info)
|
|||||||
since it was locked then there may be key blocks in the key cache
|
since it was locked then there may be key blocks in the key cache
|
||||||
*/
|
*/
|
||||||
flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
|
flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
if (share->file_map)
|
||||||
|
_mi_unmap_file(info);
|
||||||
|
#endif
|
||||||
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
|
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
|
||||||
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) )
|
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) )
|
||||||
goto err;
|
goto err;
|
||||||
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
|
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
/* Resize mmaped area */
|
/* Map again */
|
||||||
rw_wrlock(&info->s->mmap_lock);
|
if (share->file_map)
|
||||||
mi_remap_file(info, (my_off_t)0);
|
mi_dynmap_file(info, (my_off_t) 0);
|
||||||
rw_unlock(&info->s->mmap_lock);
|
|
||||||
#endif
|
#endif
|
||||||
allow_break(); /* Allow SIGHUP & SIGINT */
|
allow_break(); /* Allow SIGHUP & SIGINT */
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
Reference in New Issue
Block a user