Commit d513153f authored by Michael Widenius's avatar Michael Widenius

Merge of compatibility fixes

Fixed failing tests in sys_vars as we have now stricter checking of setting of variables.

mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_stats_on_metadata_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_strict_mode_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/rpl_semi_sync_master_enabled_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/r/rpl_semi_sync_slave_enabled_basic.result:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_stats_on_metadata_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_strict_mode_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test:
  One can now only assign 0 or 1 to boolean variables
mysys/my_getsystime.c:
  Merge + fixed bug that __NR_clock_gettime didn't work in 5.5
parents 635598f1 ca28d5fc
......@@ -49,7 +49,7 @@
TODO : Verify if FreeBSD & AIX stores ISO 10646 in wchar_t. */
#if !defined(__NetBSD__) && !defined(__sun) \
&& !(defined(__APPLE__) && defined(__MACH__)) \
&& !defined(__FreeBSD__) && !defined(_AIX)
&& !defined(__FreeBSD__) && !defined(_AIX) && !defined(__OpenBSD__)
#ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other
......
......@@ -64,7 +64,7 @@ static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#include "np/vis.h"
#ifdef __weak_alias
__weak_alias(strnunvisx,_strnunvisx)
__weak_alias(strnunvisx,_strnunvisx);
#endif
#if !HAVE_VIS
......
......@@ -77,7 +77,7 @@
#include <stdlib.h>
#ifdef __weak_alias
__weak_alias(strvisx,_strvisx)
__weak_alias(strvisx,_strvisx);
#endif
#if !HAVE_VIS || !HAVE_SVIS
......
......@@ -9,7 +9,9 @@ INSERT INTO bug_61209 VALUES (), ();
# Connection con1
SET SESSION auto_increment_increment=3;
SET SESSION auto_increment_offset=2;
SELECT GET_LOCK('a', 10);
SELECT GET_LOCK('a', 9);
GET_LOCK('a', 9)
1
# Connection con2
SET SESSION auto_increment_increment=3;
......@@ -17,14 +19,10 @@ SET SESSION auto_increment_offset=2;
INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL + GET_LOCK('a', 10));
# Connection con1 reap
GET_LOCK('a', 10)
1
INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL);
SELECT RELEASE_LOCK('a');
# Connection con2 reap
# Connection con1 reap
RELEASE_LOCK('a')
1
# Connection con2 reap
DROP TABLE bug_61209;
......@@ -29,7 +29,7 @@ INSERT INTO bug_61209 VALUES (), ();
--connection con1
SET SESSION auto_increment_increment=3;
SET SESSION auto_increment_offset=2;
send SELECT GET_LOCK('a', 10);
SELECT GET_LOCK('a', 9);
--echo
--echo # Connection con2
......@@ -41,20 +41,14 @@ send INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL + GET_LOCK('a', 10))
--echo
--echo # Connection con1 reap
--connection con1
reap;
INSERT INTO bug_61209 (a) VALUES (NULL), (NULL), (NULL);
send SELECT RELEASE_LOCK('a');
SELECT RELEASE_LOCK('a');
--echo
--echo # Connection con2 reap
--connection con2
reap;
--echo
--echo # Connection con1 reap
--connection con1
reap;
#
# Clean up
#
......
......@@ -4,17 +4,59 @@ create database mysqltest;
use mysqltest;
create table t1(a int) engine=aria;
insert into t1 values(1);
flush table t1;
create table t2 (a int) engine=aria;
INSERT INTO t2 VALUES (1),(2);
create table t3 (a int) engine=aria;
INSERT INTO t3 VALUES (1),(2);
create table t4 (a int) engine=aria;
INSERT INTO t4 VALUES (1),(2);
create table t5 (a int) engine=aria;
INSERT INTO t5 VALUES (1),(2);
flush tables;
create_rename_lsn has non-magic value
* shut down mysqld, removed logs, restarted it
select * from t1;
a
1
Warnings:
Error 1194 t1' is marked as crashed and should be repaired
Note 1194 Zerofilling moved table ./mysqltest/t1
flush table t1;
Status: changed,sorted index pages,zerofilled
insert into t1 values(2);
flush table t1;
create_rename_lsn has non-magic value
check table t2;
Table Op Msg_type Msg_text
mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system
mysqltest.t2 check error Corrupt
check table t2;
Table Op Msg_type Msg_text
mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system
mysqltest.t2 check error Corrupt
repair table t2;
Table Op Msg_type Msg_text
mysqltest.t2 repair status OK
check table t2;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
optimize table t3;
Table Op Msg_type Msg_text
mysqltest.t3 optimize Note Zerofilling moved table ./mysqltest/t3
mysqltest.t3 optimize status OK
analyze table t4;
Table Op Msg_type Msg_text
mysqltest.t4 analyze Note Zerofilling moved table ./mysqltest/t4
mysqltest.t4 analyze status OK
repair table t5;
Table Op Msg_type Msg_text
mysqltest.t5 repair status OK
check table t5;
Table Op Msg_type Msg_text
mysqltest.t5 check status OK
repair table t5;
Table Op Msg_type Msg_text
mysqltest.t5 repair status OK
check table t5;
Table Op Msg_type Msg_text
mysqltest.t5 check status OK
drop database mysqltest;
......@@ -22,9 +22,19 @@ connection default;
use mysqltest;
--enable_reconnect
# Create some tables for future tests
create table t1(a int) engine=aria;
insert into t1 values(1);
flush table t1;
create table t2 (a int) engine=aria;
INSERT INTO t2 VALUES (1),(2);
create table t3 (a int) engine=aria;
INSERT INTO t3 VALUES (1),(2);
create table t4 (a int) engine=aria;
INSERT INTO t4 VALUES (1),(2);
create table t5 (a int) engine=aria;
INSERT INTO t5 VALUES (1),(2);
flush tables;
# Check that table is not zerofilled, not movable
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
......@@ -46,6 +56,7 @@ EOF
disable_ps_protocol; # see aria-recover.test
replace_regex /Table.*t1/t1/ ;
replace_result \\ /;
select * from t1;
enable_ps_protocol;
flush table t1;
......@@ -80,4 +91,21 @@ perl;
close FILE;
EOF
#
# BUG#44422 "mysql_upgrade destroys Maria tables?"
# Check repair and optimize of moved table
#
check table t2;
check table t2;
repair table t2;
check table t2;
replace_result \\ /;
optimize table t3;
replace_result \\ /;
analyze table t4;
repair table t5;
check table t5;
repair table t5;
check table t5;
drop database mysqltest;
......@@ -73,8 +73,8 @@ set global innodb_adaptive_flushing=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_adaptive_flushing'
set global innodb_adaptive_flushing=2;
ERROR 42000: Variable 'innodb_adaptive_flushing' can't be set to the value of '2'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_adaptive_flushing=-3;
ERROR 42000: Variable 'innodb_adaptive_flushing' can't be set to the value of '-3'
select @@global.innodb_adaptive_flushing;
@@global.innodb_adaptive_flushing
1
......
......@@ -73,8 +73,8 @@ set global innodb_adaptive_hash_index=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_adaptive_hash_index'
set global innodb_adaptive_hash_index=2;
ERROR 42000: Variable 'innodb_adaptive_hash_index' can't be set to the value of '2'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_adaptive_hash_index=-3;
ERROR 42000: Variable 'innodb_adaptive_hash_index' can't be set to the value of '-3'
select @@global.innodb_adaptive_hash_index;
@@global.innodb_adaptive_hash_index
1
......
......@@ -73,8 +73,8 @@ set global innodb_large_prefix=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_large_prefix'
set global innodb_large_prefix=2;
ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of '2'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_large_prefix=-3;
ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of '-3'
select @@global.innodb_large_prefix;
@@global.innodb_large_prefix
1
......
......@@ -73,17 +73,17 @@ set global innodb_random_read_ahead=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead'
set global innodb_random_read_ahead=2;
ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '2'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_random_read_ahead=-3;
ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '-3'
select @@global.innodb_random_read_ahead;
@@global.innodb_random_read_ahead
1
0
select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
VARIABLE_NAME VARIABLE_VALUE
INNODB_RANDOM_READ_AHEAD ON
INNODB_RANDOM_READ_AHEAD OFF
select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
VARIABLE_NAME VARIABLE_VALUE
INNODB_RANDOM_READ_AHEAD ON
INNODB_RANDOM_READ_AHEAD OFF
set global innodb_random_read_ahead='AUTO';
ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of 'AUTO'
SET @@global.innodb_random_read_ahead = @start_global_value;
......
......@@ -73,8 +73,8 @@ set global innodb_stats_on_metadata=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_stats_on_metadata'
set global innodb_stats_on_metadata=2;
ERROR 42000: Variable 'innodb_stats_on_metadata' can't be set to the value of '2'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_stats_on_metadata=-3;
ERROR 42000: Variable 'innodb_stats_on_metadata' can't be set to the value of '-3'
select @@global.innodb_stats_on_metadata;
@@global.innodb_stats_on_metadata
1
......
......@@ -99,9 +99,10 @@ set global innodb_strict_mode='AUTO';
ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of 'AUTO'
set session innodb_strict_mode='AUTO';
ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of 'AUTO'
NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
set global innodb_strict_mode=-3;
ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of '-3'
set session innodb_strict_mode=-7;
ERROR 42000: Variable 'innodb_strict_mode' can't be set to the value of '-7'
select @@global.innodb_strict_mode;
@@global.innodb_strict_mode
1
......
......@@ -73,6 +73,7 @@ SELECT @@session.innodb_support_xa;
SET @@session.innodb_support_xa = FF;
ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'FF'
SET @@global.innodb_support_xa = -1;
ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of '-1'
SELECT @@global.innodb_support_xa;
@@global.innodb_support_xa
1
......
......@@ -55,6 +55,7 @@ SELECT @@global.innodb_table_locks;
1
'#--------------------FN_DYNVARS_046_04-------------------------#'
SET @@session.innodb_table_locks = -6;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '-6'
SET @@session.innodb_table_locks = 1.6;
ERROR 42000: Incorrect argument type to variable 'innodb_table_locks'
SET @@session.innodb_table_locks = "T";
......@@ -72,6 +73,7 @@ SELECT @@session.innodb_table_locks;
SET @@session.innodb_table_locks = FF;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'FF'
SET @@global.innodb_table_locks = -1;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '-1'
SET @@global.innodb_table_locks = 2;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of '2'
SET @@global.innodb_table_locks = "T";
......
......@@ -45,7 +45,7 @@ set session rpl_semi_sync_master_enabled=1;
ERROR HY000: Variable 'rpl_semi_sync_master_enabled' is a GLOBAL variable and should be set with SET GLOBAL
select @@global.rpl_semi_sync_master_enabled;
@@global.rpl_semi_sync_master_enabled
-1
1
select @@session.rpl_semi_sync_master_enabled;
ERROR HY000: Variable 'rpl_semi_sync_master_enabled' is a GLOBAL variable
show global variables like 'rpl_semi_sync_master_enabled';
......
......@@ -45,7 +45,7 @@ set session rpl_semi_sync_slave_enabled=1;
ERROR HY000: Variable 'rpl_semi_sync_slave_enabled' is a GLOBAL variable and should be set with SET GLOBAL
select @@global.rpl_semi_sync_slave_enabled;
@@global.rpl_semi_sync_slave_enabled
-1
1
select @@session.rpl_semi_sync_slave_enabled;
ERROR HY000: Variable 'rpl_semi_sync_slave_enabled' is a GLOBAL variable
show global variables like 'rpl_semi_sync_slave_enabled';
......
......@@ -54,7 +54,7 @@ set global innodb_adaptive_flushing=1.1;
set global innodb_adaptive_flushing=1e1;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_adaptive_flushing=2;
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_adaptive_flushing=-3;
select @@global.innodb_adaptive_flushing;
select * from information_schema.global_variables where variable_name='innodb_adaptive_flushing';
......
......@@ -54,7 +54,7 @@ set global innodb_adaptive_hash_index=1.1;
set global innodb_adaptive_hash_index=1e1;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_adaptive_hash_index=2;
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_adaptive_hash_index=-3;
select @@global.innodb_adaptive_hash_index;
select * from information_schema.global_variables where variable_name='innodb_adaptive_hash_index';
......
......@@ -54,7 +54,7 @@ set global innodb_large_prefix=1.1;
set global innodb_large_prefix=1e1;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_large_prefix=2;
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_large_prefix=-3;
select @@global.innodb_large_prefix;
select * from information_schema.global_variables where variable_name='innodb_large_prefix';
......
......@@ -54,7 +54,7 @@ set global innodb_random_read_ahead=1.1;
set global innodb_random_read_ahead=1e1;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_random_read_ahead=2;
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_random_read_ahead=-3;
select @@global.innodb_random_read_ahead;
select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
......
......@@ -54,7 +54,7 @@ set global innodb_stats_on_metadata=1.1;
set global innodb_stats_on_metadata=1e1;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_stats_on_metadata=2;
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_stats_on_metadata=-3;
select @@global.innodb_stats_on_metadata;
select * from information_schema.global_variables where variable_name='innodb_stats_on_metadata';
......
......@@ -68,8 +68,9 @@ set session innodb_strict_mode=2;
set global innodb_strict_mode='AUTO';
--error ER_WRONG_VALUE_FOR_VAR
set session innodb_strict_mode='AUTO';
--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_strict_mode=-3;
--error ER_WRONG_VALUE_FOR_VAR
set session innodb_strict_mode=-7;
select @@global.innodb_strict_mode;
select @@session.innodb_strict_mode;
......
......@@ -127,6 +127,7 @@ SET @@session.innodb_support_xa =
# for global
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.innodb_support_xa = -1;
SELECT @@global.innodb_support_xa;
......
......@@ -106,6 +106,7 @@ SELECT @@global.innodb_table_locks;
# for session
--error ER_WRONG_VALUE_FOR_VAR
SET @@session.innodb_table_locks = -6;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.innodb_table_locks = 1.6;
......@@ -127,6 +128,7 @@ SET @@session.innodb_table_locks =
# for global
--error ER_WRONG_VALUE_FOR_VAR
SET @@global.innodb_table_locks = -1;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.innodb_table_locks = 2;
......
......@@ -119,7 +119,6 @@ void my_time_init()
ulonglong my_getcputime()
{
#ifdef CLOCK_THREAD_CPUTIME_ID
#ifdef HAVE_CLOCK_GETTIME
struct timespec tp;
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp))
return 0;
......@@ -129,8 +128,6 @@ ulonglong my_getcputime()
if (syscall(__NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &tp))
return 0;
return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
#endif /* HAVE_CLOCK_GETTIME */
#else /* HAVE_THREAD_CPUTIME_ID */
#endif /* CLOCK_THREAD_CPUTIME_ID */
return 0;
#endif
}
......@@ -7,6 +7,7 @@
*/
#include <my_config.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <errno.h>
#include <poll.h>
......
......@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include "fatal.hpp"
......
......@@ -1259,7 +1259,7 @@ bool ha_partition::check_and_repair(THD *thd)
@retval FALSE Cannot be auto repaired
*/
bool ha_partition::auto_repair() const
bool ha_partition::auto_repair(int error) const
{
DBUG_ENTER("ha_partition::auto_repair");
......@@ -1267,7 +1267,7 @@ bool ha_partition::auto_repair() const
As long as we only support one storage engine per table,
we can use the first partition for this function.
*/
DBUG_RETURN(m_file[0]->auto_repair());
DBUG_RETURN(m_file[0]->auto_repair(error));
}
......
......@@ -1085,7 +1085,7 @@ public:
virtual int check(THD* thd, HA_CHECK_OPT *check_opt);
virtual int repair(THD* thd, HA_CHECK_OPT *check_opt);
virtual bool check_and_repair(THD *thd);
virtual bool auto_repair() const;
virtual bool auto_repair(int error) const;
virtual bool is_crashed() const;
private:
......
......@@ -2446,7 +2446,7 @@ public:
virtual uint checksum() const { return 0; }
virtual bool is_crashed() const { return 0; }
virtual bool auto_repair() const { return 0; }
virtual bool auto_repair(int error) const { return 0; }
void update_global_table_stats();
void update_global_index_stats();
......
......@@ -2782,6 +2782,7 @@ static void init_signals(void)
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
#ifdef HAVE_STACKTRACE
if (opt_stack_trace || (test_flags & TEST_CORE_ON_SIGNAL))
{
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
......@@ -2804,6 +2805,7 @@ static void init_signals(void)
sigaction(SIGILL, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
}
#endif
#ifdef HAVE_GETRLIMIT
if (test_flags & TEST_CORE_ON_SIGNAL)
......
......@@ -2385,11 +2385,11 @@ static int check_func_bool(THD *thd, struct st_mysql_sys_var *var,
{
if (value->val_int(value, &tmp) < 0)
goto err;
if (tmp > 1)
if (tmp != 0 && tmp != 1)
goto err;
result= (int) tmp;
}
*(my_bool *) save= -result;
*(my_bool *) save= result ? 1 : 0;
return 0;
err:
return 1;
......@@ -2579,7 +2579,7 @@ err:
static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,
void *tgt, const void *save)
{
*(my_bool *) tgt= *(my_bool *) save ? TRUE : FALSE;
*(my_bool *) tgt= *(my_bool *) save ? 1 : 0;
}
......
......@@ -2607,8 +2607,7 @@ partititon_err:
HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
{
/* Set a flag if the table is crashed and it can be auto. repaired */
share->crashed= ((ha_err == HA_ERR_CRASHED_ON_USAGE) &&
outparam->file->auto_repair() &&
share->crashed= (outparam->file->auto_repair(ha_err) &&
!(ha_open_flags & HA_OPEN_FOR_REPAIR));
switch (ha_err)
......
......@@ -126,7 +126,9 @@ public:
int free_share();
int init_archive_writer();
int init_archive_reader();
bool auto_repair() const { return 1; } // For the moment we just do this
// Always try auto_repair in case of HA_ERR_CRASHED_ON_USAGE
bool auto_repair(int error) const
{ return error == HA_ERR_CRASHED_ON_USAGE; }
int read_data_header(azio_stream *file_to_read);
void position(const uchar *record);
int info(uint);
......
......@@ -150,6 +150,8 @@ public:
int rnd_end();
int repair(THD* thd, HA_CHECK_OPT* check_opt);
/* This is required for SQL layer to know that we support autorepair */
bool auto_repair(int error) const
{ return error == HA_ERR_CRASHED_ON_USAGE; }
bool auto_repair() const { return 1; }
void position(const uchar *record);
int info(uint);
......
......@@ -58,6 +58,9 @@ C_MODE_END
ulong pagecache_division_limit, pagecache_age_threshold;
ulonglong pagecache_buffer_size;
const char *zerofill_error_msg=
"Table is from another system and must be zerofilled or repaired to be "
"usable on this system";
/**
As the auto-repair is initiated when opened from the SQL layer
......@@ -1152,7 +1155,15 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked)
}
if (!(file= maria_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYER)))
{
if (my_errno == HA_ERR_OLD_FILE)
{
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_CRASHED_ON_USAGE,
zerofill_error_msg);
}
return (my_errno ? my_errno : -1);
}
file->s->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_ref;
/* Set external_ref, mainly for temporary tables */
......@@ -1266,6 +1277,14 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
return HA_ADMIN_ALREADY_DONE;
maria_chk_init_for_check(&param, file);
if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
STATE_MOVED)
{
_ma_check_print_error(&param, "%s", zerofill_error_msg);
return HA_ADMIN_CORRUPT;
}
old_proc_info= thd_proc_info(thd, "Checking status");
thd_progress_init(thd, 3);
(void) maria_chk_status(&param, file); // Not fatal
......@@ -1633,7 +1652,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
{
DBUG_PRINT("info", ("Reseting crashed state"));
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS |
STATE_IN_REPAIR);
STATE_IN_REPAIR | STATE_MOVED);
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
}
/*
......@@ -2135,6 +2154,11 @@ bool ha_maria::check_and_repair(THD *thd)
if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
STATE_MOVED)
{
/* Remove error about crashed table */
thd->warning_info->clear_warning_info(thd->query_id);
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_CRASHED_ON_USAGE,
"Zerofilling moved table %s", table->s->path.str);
sql_print_information("Zerofilling moved table: '%s'",
table->s->path.str);
if (!(error= zerofill(thd, &check_opt)))
......
......@@ -152,8 +152,14 @@ public:
bool check_and_repair(THD * thd);
bool is_crashed() const;
bool is_changed() const;
bool auto_repair() const
{ return test(maria_recover_options & HA_RECOVER_ANY); }
bool auto_repair(int error) const
{
/* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) */
return ((test(maria_recover_options & HA_RECOVER_ANY) &&
error == HA_ERR_CRASHED_ON_USAGE) ||
error == HA_ERR_OLD_FILE);
}
int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int restore(THD * thd, HA_CHECK_OPT * check_opt);
int backup(THD * thd, HA_CHECK_OPT * check_opt);
......
......@@ -1002,8 +1002,6 @@ err:
tmp_name.length= strlen(name);
_ma_report_error(save_errno, &tmp_name);
}
if (save_errno == HA_ERR_OLD_FILE) /* uuid is different ? */
save_errno= HA_ERR_CRASHED_ON_USAGE; /* the code to trigger auto-repair */
switch (errpos) {
case 5:
if (data_file >= 0)
......
......@@ -140,7 +140,11 @@ class ha_myisam: public handler
int repair(THD* thd, HA_CHECK_OPT* check_opt);
bool check_and_repair(THD *thd);
bool is_crashed() const;
bool auto_repair() const { return myisam_recover_options != HA_RECOVER_OFF; }
bool auto_repair(int error) const
{
return (myisam_recover_options != HA_RECOVER_OFF &&
error == HA_ERR_CRASHED_ON_USAGE);
}
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt);
int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
......
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