summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-11-18 14:08:17 +0200
committerunknown <monty@hundin.mysql.fi>2001-11-18 14:08:17 +0200
commit421595c12e731bb50e6fe6f9985d950e023e4667 (patch)
tree3d0563b3a96cfaa7e8b9b687efcb6f1407f7f58b
parent7803c4432cb392ad69dc292038118465c9616121 (diff)
downloadmariadb-git-421595c12e731bb50e6fe6f9985d950e023e4667.tar.gz
Fixed bug in OPTIMIZE TABLE that reset index cardinality if it
was up to date. Docs/manual.texi: ChangeLog configure.in: Version number change mysql-test/r/myisam.result: Test of optimize table mysql-test/t/myisam.test: Test of optimize table
-rw-r--r--Docs/manual.texi8
-rw-r--r--configure.in2
-rw-r--r--mysql-test/r/myisam.result10
-rw-r--r--mysql-test/t/myisam.test12
-rw-r--r--sql/ha_myisam.cc38
5 files changed, 53 insertions, 17 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 0f234fcfd21..baa2baca2f7 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46844,6 +46844,14 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.45
@itemize @bullet
@item
+Fix a bug which could cause InnoDB to complain if it cannot find free blocks
+from the buffer cache during recovery.
+@item
+Fixed a bug in InnoDB insert buffer B-tree handling that could cause crashes.
+@item
+Fixed bug in @code{OPTIMIZE TABLE} that reset index cardinality if it
+was up to date.
+@item
Fixed problem with @code{t1 LEFT_JOIN t2 ... WHERE t2.date_column IS NULL} when
date_column was declared as @code{NOT NULL}.
@item
diff --git a/configure.in b/configure.in
index 6709c6be0fa..bccc323b7bd 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
-AM_INIT_AUTOMAKE(mysql, 3.23.44)
+AM_INIT_AUTOMAKE(mysql, 3.23.45)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 1152ca24f38..143802a4d05 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -10,3 +10,13 @@ Table Op Msg_type Msg_text
test.t1 repair status OK
Table Op Msg_type Msg_text
test.t1 check status OK
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
+t1 0 PRIMARY 1 a A 5 NULL NULL
+t1 1 b 1 b A 1 NULL NULL
+Table Op Msg_type Msg_text
+test.t1 optimize status Table is already up to date
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
+t1 0 PRIMARY 1 a A 5 NULL NULL
+t1 1 b 1 b A 1 NULL NULL
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 0dc7f84efc5..5b483b969bc 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -36,3 +36,15 @@ check table t1;
repair table t1;
check table t1;
drop table t1;
+
+#
+# Test bug: Two optimize in a row reset index cardinality
+#
+
+create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
+insert into t1 (b) values (1),(2),(2),(2),(2);
+optimize table t1;
+show index from t1;
+optimize table t1;
+show index from t1;
+drop table t1;
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index c5c29f3c8bc..fb98708c317 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -535,7 +535,7 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
{
int error=0;
- uint extra_testflag=0;
+ uint local_testflag=param.testflag;
bool optimize_done= !optimize, statistics_done=0;
char fixed_name[FN_REFLEN];
const char *old_proc_info=thd->proc_info;
@@ -565,19 +565,18 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
(!param.opt_rep_quick ||
!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))
{
- ulonglong key_map= ((param.testflag & T_CREATE_MISSING_KEYS) ?
+ ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?
((ulonglong) 1L << share->base.keys)-1 :
share->state.key_map);
+ uint testflag=param.testflag;
if (mi_test_if_sort_rep(file,file->state->records,key_map,0) &&
- (param.testflag & T_REP_BY_SORT))
+ (local_testflag & T_REP_BY_SORT))
{
- uint testflag=param.testflag;
- extra_testflag= T_STATISTICS;
+ local_testflag|= T_STATISTICS;
param.testflag|= T_STATISTICS; // We get this for free
thd->proc_info="Repair by sorting";
statistics_done=1;
error = mi_repair_by_sort(&param, file, fixed_name, param.opt_rep_quick);
- param.testflag=testflag;
}
else
{
@@ -585,22 +584,28 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
param.testflag &= ~T_REP_BY_SORT;
error= mi_repair(&param, file, fixed_name, param.opt_rep_quick);
}
+ param.testflag=testflag;
+ optimize_done=1;
}
if (!error)
{
- if ((param.testflag & T_SORT_INDEX) &&
+ if ((local_testflag & T_SORT_INDEX) &&
(share->state.changed & STATE_NOT_SORTED_PAGES))
{
optimize_done=1;
thd->proc_info="Sorting index";
error=mi_sort_index(&param,file,fixed_name);
}
- if (!statistics_done && (param.testflag & T_STATISTICS) &&
- (share->state.changed & STATE_NOT_ANALYZED))
+ if (!statistics_done && (local_testflag & T_STATISTICS))
{
- optimize_done=1;
- thd->proc_info="Analyzing";
- error = chk_key(&param, file);
+ if (share->state.changed & STATE_NOT_ANALYZED)
+ {
+ optimize_done=1;
+ thd->proc_info="Analyzing";
+ error = chk_key(&param, file);
+ }
+ else
+ local_testflag&= ~T_STATISTICS; // Don't update statistics
}
}
thd->proc_info="Saving state";
@@ -615,10 +620,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
file->save_state=file->s->state.state;
if (file->s->base.auto_key)
update_auto_increment_key(&param, file, 1);
- error = update_state_info(&param, file,
- UPDATE_TIME | UPDATE_OPEN_COUNT |
- ((param.testflag | extra_testflag) &
- T_STATISTICS ? UPDATE_STAT : 0));
+ if (optimize_done)
+ error = update_state_info(&param, file,
+ UPDATE_TIME | UPDATE_OPEN_COUNT |
+ (local_testflag &
+ T_STATISTICS ? UPDATE_STAT : 0));
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST);
if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT))