[MDEV-10005] mysqlcheck doesn't correctly set default database in repair step Created: 2016-04-28  Updated: 2016-07-08  Resolved: 2016-07-08

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.1.11
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-9440 mysqlcheck -A --auto-repair selects w... Closed

 Description   

How to repeat:

  • create two databases test1 and test2
  • in test1 create a myisam table t1 and insert some data
  • in test2 create a table t2
  • mangle the t1.MYI file so that a REPAIR is needed, e.g. by truncating a few bytes of its end
  • run mysqlcheck --auto-repair --all-databases -v -v -v to get full query output

Output will be:

# Connecting to localhost...
Processing databases
information_schema
mysql
CHECK TABLE `column_stats` 
mysql.column_stats                                 OK
[...]
CHECK TABLE `user` 
mysql.user                                         OK
performance_schema
test
CHECK TABLE `t1` 
test.t1
warning  : Table is marked as crashed
error    : Size of indexfile is: 2048        Should be: 4096
error    : Corrupt
test2
CHECK TABLE `t2` 
test2.t2                                           OK
 
Repairing tables
REPAIR TABLE `t1` 
test2.t1
Error    : Table 'test2.t1' doesn't exist
status   : Operation failed
# Disconnecting from localhost...

So mysqlcheck correctly detected that test1.t1 needs to be repaired, then continued to scan database test2. In the repair phase it tried to repair table t1, but it didn't take care to change the default database to t1 or to use a fully qualified table name. So as the last database scanned was test2 this is still the default database for the connection, and REPAIR tries to repair test2.t1, not test1.t1

Looks as if --all-databases was only added as an afterthought, and not properly tested with tables that actually need a repair?



 Comments   
Comment by Elena Stepanova [ 2016-04-28 ]

It's most likely the same problem as MDEV-9440, but I'll assign the report to sanja to make sure of that.

Comment by Hartmut Holzgraefe [ 2016-04-29 ]

Yes, looks like a duplicate of MDEV-9440 indeed ... I probably overlooked that one as it only mentioned the -A short option name and not --all-databases

Generated at Thu Feb 08 07:38:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.