summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-11-21 03:43:34 +0200
committerunknown <monty@donna.mysql.com>2000-11-21 03:43:34 +0200
commit7c881e34ef78cd541cb98738215c8f062024dbad (patch)
tree18fdf025bea7d918e304f45384902d822f68f2f6
parent675d1803db1ea6da10dda7ac05ec7800bf6a0d31 (diff)
downloadmariadb-git-7c881e34ef78cd541cb98738215c8f062024dbad.tar.gz
Fixed problem with auto-repair of MyISAM tables
Fixed bug in ISAM and MyISAM when updating from multiple-processes Docs/manual.texi: Updated changelog client/mysqladmin.c: Upgraded version number because the change of llstr() is visible extra/perror.c: Added new error message include/my_base.h: Added HA_ERR_CRASHED_ON_USAGE isam/rnext.c: Fixed bug when updating from multiple-processes isam/rprev.c: Fixed bug when updating from multiple-processes libmysql/libmysql.c: Fixed that mysql->options.client_flag was used properly myisam/mi_locking.c: Fixed bug when updating from multiple-processes myisam/mi_open.c: Fixed bug when updating from multiple-processes Added HA_ERR_CRASHED_ON_USAGE myisam/mi_rnext.c: Fixed bug when updating from multiple-processes myisam/mi_rprev.c: Fixed bug when updating from multiple-processes myisam/myisamchk.c: Added HA_ERR_CRASHED_ON_USAGE sql/sql_base.cc: Fixed problem with auto-repair of MyISAM tables sql/table.cc: Fixed problem with auto-repair of MyISAM tables
-rw-r--r--Docs/manual.texi34
-rw-r--r--client/mysqladmin.c2
-rw-r--r--extra/perror.c1
-rw-r--r--include/my_base.h1
-rw-r--r--isam/rnext.c5
-rw-r--r--isam/rprev.c5
-rw-r--r--libmysql/libmysql.c9
-rw-r--r--myisam/mi_locking.c1
-rw-r--r--myisam/mi_open.c5
-rw-r--r--myisam/mi_rnext.c7
-rw-r--r--myisam/mi_rprev.c5
-rw-r--r--myisam/myisamchk.c9
-rw-r--r--sql/sql_base.cc11
-rw-r--r--sql/table.cc3
14 files changed, 60 insertions, 38 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 4519fc486b8..9947e4494e9 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -28015,10 +28015,10 @@ Give a variable a value. @code{--help} lists variables.
Only update the default database. This is useful for skipping updates to
other database in the update log.
@cindex pager option
-@item --pager[=...]
-Output type. Default is your ENV variable PAGER. Valid pagers are less,
-more, cat [> filename], etc. See interactive help (\h) also. This
-option does not work in batch mode. Pager works only in UNIX.
+@item @code{--pager[=...]}
+Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
+pagers are less, more, cat [> filename], etc. See interactive help (\h)
+also. This option does not work in batch mode. Pager works only in UNIX.
@cindex password option
@item -p[password], --password[=...]
Password to use when connecting to server. If password is not given on
@@ -28148,12 +28148,11 @@ mysql> select * from mails where length(txt) < 300 limit 300,1\G
msg_nro: 3068
date: 2000-03-01 23:29:50
time_zone: +0200
-mail_from: Michael Widenius <monty@monty.pp.sci.fi>
- reply: monty@mysql.com
- mail_to: "Thimble Smith" <tim@mysql.com>
- cc: mysql_all@mysql.com
+mail_from: Monty
+ reply: monty@@no.spam.com
+ mail_to: "Thimble Smith" <tim@@no.spam.com>
sbj: UTF-8
- txt: >>>>> "Thimble" == Thimble Smith <tim@mysql.com> writes:
+ txt: >>>>> "Thimble" == Thimble Smith writes:
Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8
Thimble> or Unicode? Otherwise I'll put this on my TODO list and see what
@@ -28166,8 +28165,6 @@ Monty
file: inbox-jani-1
hash: 190402944
1 row in set (0.09 sec)
-
-mysql>
@end example
For logging, one can use the @code{tee} option. The @code{tee} can be
@@ -38808,11 +38805,16 @@ though, so Version 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.28
@itemize @bullet
@item
-Fixed a major performance bug in the table locking code when you
-constantly had a LOT of @code{SELECT} running on a table on which you
-also did a lot of @code{UPDATE} and @code{INSERT}. The symptom was that
-the @code{UPDATE} and @code{INSERT} queries was locked a long time
-while @code{SELECT} statements where executed without locks.
+Fixed crash when automatic repair of @code{MyISAM} table failed.
+@item
+Fixed a major performance bug in the table locking code when one
+constantly had a LOT of @code{SELECT}, @code{UPDATE} and @code{INSERT}
+statements running. The symptom was that the @code{UPDATE} and
+@code{INSERT} queries was locked a long time while new @code{SELECT}
+statements where executed without locks.
+@item
+When reading options_files with @code{mysql_options()} the
+@code{return-found-rows} option was ignored.
@item
One can now specify @code{interactive-timeout} in the option file that
is read by @code{mysql_options()}. This makes it possible to force
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index d5b2e73451e..4622e94eb9c 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -28,7 +28,7 @@
#include <my_pthread.h> /* because of signal() */
#endif
-#define ADMIN_VERSION "8.11"
+#define ADMIN_VERSION "8.12"
#define MAX_MYSQL_VAR 64
#define MAX_TIME_TO_WAIT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
diff --git a/extra/perror.c b/extra/perror.c
index ec523ecba0b..5fc1f75785b 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -66,6 +66,7 @@ static HA_ERRORS ha_errlist[]=
{ 142,"Unknown character set used"},
{ 143,"Conflicting table definition between MERGE and mapped table"},
{ 144,"Table is crashed and last repair failed"},
+ { 145,"Table was marked as crashed and should be repaired"},
{ 0,NullS },
};
diff --git a/include/my_base.h b/include/my_base.h
index 5c76b5a6bc3..5ab84fb3433 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -207,6 +207,7 @@ enum ha_base_keytype {
#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
#define HA_ERR_WRONG_TABLE_DEF 143
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */
+#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
/* Other constants */
diff --git a/isam/rnext.c b/isam/rnext.c
index ebe00fc2fa1..451624bb42b 100644
--- a/isam/rnext.c
+++ b/isam/rnext.c
@@ -27,7 +27,7 @@
int nisam_rnext(N_INFO *info, byte *buf, int inx)
{
- int error;
+ int error,changed;
uint flag;
DBUG_ENTER("nisam_rnext");
@@ -40,10 +40,11 @@ int nisam_rnext(N_INFO *info, byte *buf, int inx)
#ifndef NO_LOCKING
if (_nisam_readinfo(info,F_RDLCK,1)) DBUG_RETURN(-1);
#endif
+ changed=_nisam_test_if_changed(info);
if (!flag)
error=_nisam_search_first(info,info->s->keyinfo+inx,
info->s->state.key_root[inx]);
- else if (_nisam_test_if_changed(info) == 0)
+ else if (!changed)
error=_nisam_search_next(info,info->s->keyinfo+inx,info->lastkey,flag,
info->s->state.key_root[inx]);
else
diff --git a/isam/rprev.c b/isam/rprev.c
index 18b1e31502c..50f22c838fd 100644
--- a/isam/rprev.c
+++ b/isam/rprev.c
@@ -27,7 +27,7 @@
int nisam_rprev(N_INFO *info, byte *buf, int inx)
{
- int error;
+ int error,changed;
register uint flag;
DBUG_ENTER("nisam_rprev");
@@ -40,9 +40,10 @@ int nisam_rprev(N_INFO *info, byte *buf, int inx)
#ifndef NO_LOCKING
if (_nisam_readinfo(info,F_RDLCK,1)) DBUG_RETURN(-1);
#endif
+ changed=_nisam_test_if_changed(info);
if (!flag)
error=_nisam_search_last(info,info->s->keyinfo+inx,info->s->state.key_root[inx]);
- else if (_nisam_test_if_changed(info) == 0)
+ else if (!changed)
error=_nisam_search_next(info,info->s->keyinfo+inx,info->lastkey,flag,
info->s->state.key_root[inx]);
else
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index c48b3e61403..b7afcf8a25c 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1450,10 +1450,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
mysql->unix_socket=0;
strmov(mysql->server_version,(char*) net->read_pos+1);
mysql->port=port;
- mysql->client_flag=client_flag | mysql->options.client_flag;
- DBUG_PRINT("info",("Server version = '%s' capabilites: %ld status: %d",
- mysql->server_version,mysql->server_capabilities,
- mysql->server_status));
+ client_flag|=mysql->options.client_flag;
/* Send client information for access check */
client_flag|=CLIENT_CAPABILITIES;
@@ -1510,6 +1507,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
}
#endif /* HAVE_OPENSSL */
+ DBUG_PRINT("info",("Server version = '%s' capabilites: %ld status: %d client_flag: %d",
+ mysql->server_version,mysql->server_capabilities,
+ mysql->server_status, client_flag));
+
int3store(buff+2,max_allowed_packet);
if (user && user[0])
strmake(buff+5,user,32); /* Max user name */
diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c
index 45bb2cd7164..057efb96185 100644
--- a/myisam/mi_locking.c
+++ b/myisam/mi_locking.c
@@ -382,6 +382,7 @@ int _mi_test_if_changed(register MI_INFO *info)
share->state.unique != info->last_unique ||
share->state.update_count != info->last_loop)
{ /* Keyfile has changed */
+ DBUG_PRINT("info",("index file changed"));
if (share->state.process != share->this_process)
VOID(flush_key_blocks(share->kfile,FLUSH_RELEASE));
share->last_process=share->state.process;
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index c29a4a843ca..2eab33228dc 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -182,7 +182,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
{
DBUG_PRINT("error",("Table is marked as crashed"));
my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ?
- HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED);
+ HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED_ON_USAGE);
goto err;
}
/* Correct max_file_length based on length of sizeof_t */
@@ -732,7 +732,8 @@ char *mi_state_info_read(char *ptr, MI_STATE_INFO *state)
state->process= mi_uint4korr(ptr); ptr +=4;
state->unique = mi_uint4korr(ptr); ptr +=4;
state->status = mi_uint4korr(ptr); ptr +=4;
- ptr +=4; /* extra */
+ state->update_count=mi_uint4korr(ptr); ptr +=4;
+
for (i=0; i < keys; i++)
{
state->key_root[i]= mi_sizekorr(ptr); ptr +=8;
diff --git a/myisam/mi_rnext.c b/myisam/mi_rnext.c
index f7e7b61d934..f297740af60 100644
--- a/myisam/mi_rnext.c
+++ b/myisam/mi_rnext.c
@@ -25,7 +25,7 @@
int mi_rnext(MI_INFO *info, byte *buf, int inx)
{
- int error;
+ int error,changed;
uint flag;
DBUG_ENTER("mi_rnext");
@@ -39,10 +39,13 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
DBUG_RETURN(my_errno);
if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]);
+ changed=_mi_test_if_changed(info);
if (!flag)
+ {
error=_mi_search_first(info,info->s->keyinfo+inx,
info->s->state.key_root[inx]);
- else if (_mi_test_if_changed(info) == 0)
+ }
+ else if (!changed)
error=_mi_search_next(info,info->s->keyinfo+inx,info->lastkey,
info->lastkey_length,flag,
info->s->state.key_root[inx]);
diff --git a/myisam/mi_rprev.c b/myisam/mi_rprev.c
index 471eecc33f5..69d18b10287 100644
--- a/myisam/mi_rprev.c
+++ b/myisam/mi_rprev.c
@@ -25,7 +25,7 @@
int mi_rprev(MI_INFO *info, byte *buf, int inx)
{
- int error;
+ int error,changed;
register uint flag;
MYISAM_SHARE *share=info->s;
DBUG_ENTER("mi_rprev");
@@ -38,12 +38,13 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
if (_mi_readinfo(info,F_RDLCK,1))
DBUG_RETURN(my_errno);
+ changed=_mi_test_if_changed(info);
if (share->concurrent_insert)
rw_rdlock(&share->key_root_lock[inx]);
if (!flag)
error=_mi_search_last(info, share->keyinfo+inx,
share->state.key_root[inx]);
- else if (_mi_test_if_changed(info) == 0)
+ else if (!changed)
error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
info->lastkey_length,flag,
share->state.key_root[inx]);
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index b18f42bfb81..d045bf0018b 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -196,7 +196,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.36 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.37 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
@@ -502,8 +502,15 @@ static int myisamchk(MI_CHECK *param, my_string filename)
param->error_printed=1;
switch (my_errno) {
case HA_ERR_CRASHED:
+ case HA_ERR_WRONG_TABLE_DEF:
mi_check_print_error(param,"'%s' is not a MyISAM-table",filename);
break;
+ case HA_ERR_CRASHED_ON_USAGE:
+ mi_check_print_error(param,"'%s' is marked as crashed",filename);
+ break;
+ case HA_ERR_CRASHED_ON_REPAIR:
+ mi_check_print_error(param,"'%s' is marked as crashed after last repair",filename);
+ break;
case HA_ERR_OLD_FILE:
mi_check_print_error(param,"'%s' is a old type of MyISAM-table", filename);
break;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4a5f5e582f3..3560fc42d49 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1162,25 +1162,26 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
ha_open_options | HA_OPEN_FOR_REPAIR,
- entry) ||
+ entry) || ! entry->file ||
(entry->file->is_crashed() && entry->file->check_and_repair(thd)))
{
/* Give right error message */
thd->net.last_error[0]=0;
thd->net.last_errno=0;
- entry->file->print_error(HA_ERR_CRASHED,MYF(0));
+ my_error(ER_NOT_KEYFILE, MYF(0), name, my_errno);
sql_print_error("Error: Couldn't repair table: %s.%s",db,name);
- closefrm(entry);
+ if (entry->file)
+ closefrm(entry);
error=1;
}
else
{
- thd->net.last_error[0]=0; // Clear error message
+ thd->net.last_error[0]=0; // Clear error message
thd->net.last_errno=0;
}
- unlock_table_name(thd,&table_list);
if (locked)
pthread_mutex_lock(&LOCK_open); // Get back original lock
+ unlock_table_name(thd,&table_list);
if (error)
goto err;
}
diff --git a/sql/table.cc b/sql/table.cc
index bdc2c0f124e..c840b36da05 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -542,7 +542,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
{
/* Set a flag if the table is crashed and it can be auto. repaired */
- outparam->crashed=(err == HA_ERR_CRASHED &&
+ outparam->crashed=(err == HA_ERR_CRASHED_ON_USAGE &&
outparam->file->auto_repair() &&
!(ha_open_flags & HA_OPEN_FOR_REPAIR));
goto err_not_open; /* purecov: inspected */
@@ -569,6 +569,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
frm_error(error,outparam,name,ME_ERROR+ME_WAITTANG);
delete outparam->file;
outparam->file=0; // For easyer errorchecking
+ outparam->db_stat=0;
free_root(&outparam->mem_root,MYF(0));
my_free(outparam->table_name,MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN (error);