Commit b2c9d65b authored by unknown's avatar unknown

Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.0

into  zim.(none):/home/brian/mysql/mysql-5.0

parents 6e0222cb 8701728f
This diff is collapsed.
......@@ -1339,8 +1339,12 @@ SELECT * FROM t2;
TRUNCATE TABLE t2;
SELECT * FROM t2;
# Adding support for CHECK table
CHECK TABLE t2;
SELECT * FROM t2;
# Just test syntax, we will never know if the out put is right or wrong
# Just test syntax, we will never know if the output is right or wrong
# Must be the last test
INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
#
......
......@@ -1053,4 +1053,81 @@ int ha_archive::delete_all_rows()
DBUG_ENTER("ha_archive::delete_all_rows");
DBUG_RETURN(0);
}
/*
We just return state if asked.
*/
bool ha_archive::is_crashed() const
{
return share->crashed;
}
/*
Simple scan of the tables to make sure everything is ok.
*/
int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
{
int rc= 0;
byte *buf;
const char *old_proc_info=thd->proc_info;
ha_rows count= share->rows_recorded;
DBUG_ENTER("ha_archive::check");
thd->proc_info= "Checking table";
/* Flush any waiting data */
gzflush(share->archive_write, Z_SYNC_FLUSH);
/*
First we create a buffer that we can use for reading rows, and can pass
to get_row().
*/
if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME))))
rc= HA_ERR_OUT_OF_MEM;
/*
Now we will rewind the archive file so that we are positioned at the
start of the file.
*/
if (!rc)
read_data_header(archive);
if (!rc)
while (!(rc= get_row(archive, buf)))
count--;
my_free((char*)buf, MYF(0));
thd->proc_info= old_proc_info;
if ((rc && rc != HA_ERR_END_OF_FILE) || count)
{
share->crashed= FALSE;
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
else
{
DBUG_RETURN(HA_ADMIN_OK);
}
}
/*
Check and repair the table if needed.
*/
bool ha_archive::check_and_repair(THD *thd)
{
HA_CHECK_OPT check_opt;
DBUG_ENTER("ha_archive::check_and_repair");
check_opt.init();
if (check(thd, &check_opt) == HA_ADMIN_CORRUPT)
{
DBUG_RETURN(repair(thd, &check_opt));
}
else
{
DBUG_RETURN(HA_ADMIN_OK);
}
}
#endif /* HAVE_ARCHIVE_DB */
......@@ -103,6 +103,9 @@ public:
}
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
bool is_crashed() const;
int check(THD* thd, HA_CHECK_OPT* check_opt);
bool check_and_repair(THD *thd);
};
bool archive_db_init(void);
......
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