Bug #9492 Segmentation fault in mysqlcheck
Submitted: 30 Mar 2005 16:38 Modified: 28 Apr 2005 0:56
Reporter: Gregert Johnson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:4.0.18-standard OS:Linux (Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[30 Mar 2005 16:38] Gregert Johnson
Description:
The following use of mysqlcheck fails with a segmentation fault:

mysqlcheck --quick --fast --check-only-changed --auto-repair -u<user> -p<password> <dbname>

The failure occurs just after a merge table has been skipped with the message "error    : The handler for the table doesn't support check".

When "--auto-repair" is not specified the check proceeds without error.

When "--repair" is used in place of "--auto-repair" the failure does not occur, but the repair is performed for all tables, regardless of their check state.  Merge tables are skipped without incident, aside from the message "The handler for the table doesn't support repair".

How to repeat:
The command in questions always fails on several systems (both Linux and Windows).

Suggested fix:
Unknown.
[30 Mar 2005 17:47] Jorge del Conde
I was unable to reproduce this behaviour:

jorge-/home/jorge> mysqlcheck --quick --fast --check-only-changed --auto-repair -uroot test
test.TEST                                          OK
test.fighters                                      Table is already up to date
test.t                                             OK
test.t1                                            OK
test.test_text_pk                                  Table is already up to date
test.tmp                                           Table is already up to date
test.tmpx                                          OK
test.word                                          Table is already up to date
test.wordTuplePair                                 Table is already up to date
[30 Mar 2005 19:00] Gregert Johnson
The failure occurs only with MyISAM merge tables.  I did not see any such tables in M. del Conde's example.  When such a table is present in the database, mysqlcheck displays a "The handler for the table doesn't support repair" message.  With the --repair option the utility proceeds to the next table after displaying the message; with --auto-repair, the segmentation fault occurs.
[30 Mar 2005 22:56] Jorge del Conde
Thanks for your bug report.

Tested w/4.0.24

mysql> CREATE TABLE t1 (
    -> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    -> message CHAR(20));
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2 (
    ->  a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    -> message CHAR(20));
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 (message) VALUES ('Testing'),('table'),('t1');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> INSERT INTO t2 (message) VALUES ('Testing'),('table'),('t2');   
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> CREATE TABLE total (
    -> a INT NOT NULL AUTO_INCREMENT,
    -> message CHAR(20), INDEX(a))
    -> TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| A              |
| B              |
| foo            |
| t1             |
| t2             |
| t60            |
| t61            |
| t62            |
| total          |
+----------------+
9 rows in set (0.00 sec)

mysql> exit
Bye
jorge-/home/jorge>  mysqlcheck --quick --fast --check-only-changed --auto-repair -uroot test
test.A                                             Table is already up to date
test.B                                             Table is already up to date
test.foo                                           Table is already up to date
test.t1                                            Table is already up to date
test.t2                                            Table is already up to date
test.t60                                           Table is already up to date
test.t61                                           Table is already up to date
test.t62                                           Table is already up to date
test.total
error    : The handler for the table doesn't support check
Segmentation fault (core dumped)
jorge-/home/jorge>
[31 Mar 2005 19:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23542
[7 Apr 2005 0:18] Jim Winstead
Pushed, will be in 4.0.25, 4.1.12, and 5.0.5.
[28 Apr 2005 0:56] Paul DuBois
Noted in 4.0.25, 4.1.12, 5.0.5 changelogs.