Commit 374bd063 authored by Alexey Kopytov's avatar Alexey Kopytov

Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.

Conflicts:

Text conflict in mysql-test/r/partition.result
Text conflict in mysql-test/t/partition.test
Text conflict in storage/myisam/mi_dynrec.c
parents 87b98f63 8d0b9a8d
......@@ -12748,3 +12748,22 @@ SELECT * FROM t1;
ERROR HY000: Can't find file: 't1' (errno: 2)
DROP TABLE t1;
ERROR 42S02: Unknown table 't1'
#
# BUG#46565 - repair of partition fail for archive engine
#
# Installing corrupted table files for t1.
SELECT * FROM t1;
ERROR HY000: Table 't1' is marked as crashed and should be repaired
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair error Corrupt
SELECT * FROM t1;
ERROR HY000: Table 't1' is marked as crashed and should be repaired
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT * FROM t1;
a
1
2
DROP TABLE t1;
......@@ -2111,4 +2111,15 @@ COUNT(*)
0
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
#
# BUG#51868 - crash with myisam_use_mmap and partitioned myisam tables
#
SET GLOBAL myisam_use_mmap=1;
CREATE TABLE t1(a INT) PARTITION BY HASH(a) PARTITIONS 1;
INSERT INTO t1 VALUES(0);
FLUSH TABLE t1;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES(0);
DROP TABLE t1;
SET GLOBAL myisam_use_mmap=default;
End of 5.1 tests
This diff was suppressed by a .gitattributes entry.
......@@ -1669,3 +1669,26 @@ FLUSH TABLE t1;
SELECT * FROM t1;
--error ER_BAD_TABLE_ERROR
DROP TABLE t1;
--echo #
--echo # BUG#46565 - repair of partition fail for archive engine
--echo #
--echo # Installing corrupted table files for t1.
# bug46565 was created, filled and damaged as following:
# CREATE TABLE bug46565(a INT) ENGINE=archive;
# INSERT INTO bug46565 VALUES(1);
# FLUSH TABLE bug46565;
# INSERT INTO bug46565 VALUES(2),(3);
# FLUSH TABLE bug46565;
# dd if=bug46565.ARZ of=std_data/bug46565.ARZ bs=1 count=8670
copy_file std_data/bug46565.frm $MYSQLD_DATADIR/test/t1.frm;
copy_file std_data/bug46565.ARZ $MYSQLD_DATADIR/test/t1.ARZ;
--error ER_CRASHED_ON_USAGE
SELECT * FROM t1;
REPAIR TABLE t1;
--error ER_CRASHED_ON_USAGE
SELECT * FROM t1;
REPAIR TABLE t1 EXTENDED;
SELECT * FROM t1;
DROP TABLE t1;
......@@ -2118,4 +2118,17 @@ SET SESSION SQL_MODE=DEFAULT;
#SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
#
#DROP TABLE t1;
--echo #
--echo # BUG#51868 - crash with myisam_use_mmap and partitioned myisam tables
--echo #
SET GLOBAL myisam_use_mmap=1;
CREATE TABLE t1(a INT) PARTITION BY HASH(a) PARTITIONS 1;
INSERT INTO t1 VALUES(0);
FLUSH TABLE t1;
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES(0);
DROP TABLE t1;
SET GLOBAL myisam_use_mmap=default;
--echo End of 5.1 tests
......@@ -1895,7 +1895,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
/* INFO */
/* Lock THD mutex that protects its data when looking at it. */
pthread_mutex_lock(&tmp->LOCK_thd_data);
mysql_mutex_lock(&tmp->LOCK_thd_data);
if (tmp->query())
{
table->field[7]->store(tmp->query(),
......@@ -1903,7 +1903,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
tmp->query_length()), cs);
table->field[7]->set_notnull();
}
pthread_mutex_unlock(&tmp->LOCK_thd_data);
mysql_mutex_unlock(&tmp->LOCK_thd_data);
if (schema_table_store_record(thd, table))
{
......
......@@ -1324,13 +1324,12 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos)
/*
This method repairs the meta file. It does this by walking the datafile and
rewriting the meta file. Currently it does this by calling optimize with
the extended flag.
rewriting the meta file. If EXTENDED repair is requested, we attempt to
recover as much data as possible.
*/
int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
{
DBUG_ENTER("ha_archive::repair");
check_opt->flags= T_EXTEND;
int rc= optimize(thd, check_opt);
if (rc)
......@@ -1424,7 +1423,14 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
DBUG_PRINT("ha_archive", ("recovered %llu archive rows",
(unsigned long long)share->rows_recorded));
if (rc && rc != HA_ERR_END_OF_FILE)
/*
If REPAIR ... EXTENDED is requested, try to recover as much data
from data file as possible. In this case if we failed to read a
record, we assume EOF. This allows massive data loss, but we can
hardly do more with broken zlib stream. And this is the only way
to restore at least what is still recoverable.
*/
if (rc && rc != HA_ERR_END_OF_FILE && !(check_opt->flags & T_EXTEND))
goto error;
}
......
......@@ -76,7 +76,7 @@ static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG,
static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
"The buffer that is allocated when sorting the index when doing "
"a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL,
8192*1024, 4, ULONG_MAX, 1);
8192*1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), ULONG_MAX, 1);
static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG,
"Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE);
......
......@@ -55,7 +55,7 @@ int mi_delete_all_rows(MI_INFO *info)
flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED);
#ifdef HAVE_MMAP
if (share->file_map)
_mi_unmap_file(info);
mi_munmap_file(info);
#endif
if (mysql_file_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
mysql_file_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)))
......
......@@ -97,6 +97,34 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
madvise((char*) info->s->file_map, size, MADV_RANDOM);
#endif
info->s->mmaped_length= size;
info->s->file_read= mi_mmap_pread;
info->s->file_write= mi_mmap_pwrite;
DBUG_RETURN(0);
}
/*
Destroy mmaped area for MyISAM handler
SYNOPSIS
mi_munmap_file()
info MyISAM handler
RETURN
0 ok
!0 error.
*/
int mi_munmap_file(MI_INFO *info)
{
int ret;
DBUG_ENTER("mi_unmap_file");
if ((ret= my_munmap(info->s->file_map, info->s->mmaped_length)))
DBUG_RETURN(ret);
info->s->file_read= mi_nommap_pread;
info->s->file_write= mi_nommap_pwrite;
info->s->file_map= 0;
info->s->mmaped_length= 0;
DBUG_RETURN(0);
}
......@@ -115,8 +143,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size)
{
if (info->s->file_map)
{
(void) (my_munmap((char*) info->s->file_map,
(size_t) info->s->mmaped_length));
mi_munmap_file(info);
mi_dynmap_file(info, size);
}
}
......
......@@ -364,11 +364,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
DBUG_PRINT("warning",("mmap failed: errno: %d",errno));
error= my_errno= errno;
}
else
{
share->file_read= mi_mmap_pread;
share->file_write= mi_mmap_pwrite;
}
}
mysql_mutex_unlock(&share->intern_lock);
#endif
......
......@@ -767,6 +767,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *orn_name,
int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share);
my_bool mi_dynmap_file(MI_INFO *info, my_off_t size);
int mi_munmap_file(MI_INFO *info);
void mi_remap_file(MI_INFO *info, my_off_t size);
void _mi_report_crashed(MI_INFO *file, const char *message,
const char *sfile, uint sline);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment