Description:
This problem was observed when investigating details regarding bug#33094 and might be part of the same problem/solution.
In a scenario similar to the above bug when the name of the table contains extended characters and not the database (i.e. the name of the table appears with #mysql50# (and not the database as in bug#33094), an attempt to repair the table in 5.1 results in the following crash:
Version: '5.1.30-enterprise-commercial-advanced-debug-log' socket: '/tmp/systest/var/master/tmp/master.sock' port: 9306 MySQL Enterprise Server - Advanced Edition Debug (Commercial)
mysqld: sql_trigger.cc:1380: static bool Table_triggers_list::check_n_load(THD*, const char*, const char*, TABLE*, bool): Assertion `!((table_alias_charset)->coll->strcasecmp((table_alias_charset), (lex.query_tables->db), (db))) && !((table_alias_charset)->coll->strcasecmp((table_alias_charset), (lex.query_tables->table_name), (table_name)))' failed.
081207 7:31:06 - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 59974 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd: 0x8ccbd80
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xb51563b8 thread_stack 0x30000
/home/omer/mysql/bin_5130/bin/mysqld(my_print_stacktrace+0x21)[0x84e9351]
/home/omer/mysql/bin_5130/bin/mysqld(handle_segfault+0x263)[0x81f3a68]
[0xffffe420]
/lib/libc.so.6(abort+0x101)[0xb7dc61e1]
/lib/libc.so.6(__assert_fail+0xee)[0xb7dbdc1e]
/home/omer/mysql/bin_5130/bin/mysqld(_ZN19Table_triggers_list12check_n_loadEP3THDPKcS3_P8st_tableb+0xccc)[0x837e0e0]
/home/omer/mysql/bin_5130/bin/mysqld[0x82423a7]
/home/omer/mysql/bin_5130/bin/mysqld(_Z10open_tableP3THDP10TABLE_LISTP11st_mem_rootPbj+0xcd3)[0x8244706]
/home/omer/mysql/bin_5130/bin/mysqld(_Z11open_tablesP3THDPP10TABLE_LISTPjj+0x2ae)[0x8245367]
/home/omer/mysql/bin_5130/bin/mysqld(_Z28open_and_lock_tables_derivedP3THDP10TABLE_LISTb+0x91)[0x8245a2d]
/home/omer/mysql/bin_5130/bin/mysqld[0x8313d99]
/home/omer/mysql/bin_5130/bin/mysqld(_Z18mysql_repair_tableP3THDP10TABLE_LISTP15st_ha_check_opt+0xc2)[0x831590b]
/home/omer/mysql/bin_5130/bin/mysqld(_Z21mysql_execute_commandP3THD+0x2086)[0x82030a5]
/home/omer/mysql/bin_5130/bin/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x196)[0x820aa3c]
/home/omer/mysql/bin_5130/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xb41)[0x820bc29]
/home/omer/mysql/bin_5130/bin/mysqld(_Z10do_commandP3THD+0x2ad)[0x820ccc1]
/home/omer/mysql/bin_5130/bin/mysqld(handle_one_connection+0x3bf)[0x81fbf14]
/lib/libpthread.so.0[0xb7f45192]
/lib/libc.so.6(clone+0x5e)[0xb7e5e02e]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8cff088 = repair table `#mysql50#tb2_äük`
thd->thread_id=2
thd->killed=NOT_KILLED
How to repeat:
In 5.0 run the following sql:
set names utf8;
create database db_abc;
show databases;
use test;
create table log (msg varchar(120) character set 'utf8', i int);
use db_abc;
create table tb2_äük(i int);
create trigger auk after insert on tb2_äük for each row
insert into test.log values ("From trig äük value:", new.i);
insert into tb2_äük values (1), (2), (3);
# To confirm the insert worked
select * from db_abc.tb2_äük;
# To confirm that the trigger is working
select * from test.log;
Upgrade the system to 5.1 (live upgrade - do not dump and restore).
Run mysql_upgrade
The output will include
Warning : Triggers for table `db_abc`.`#mysql50#tb2_äük` have no creation context
Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?ük for each row
insert into test.log values ("From trig ????_äük value:' at line 1
error : Corrupt
And further down:
Repairing tables
db_abc.#mysql50#tb2_äük
Warning : Triggers for table `db_abc`.`#mysql50#tb2_äük` have no creation context
Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?ük for each row
insert into test.log values ("From trig ????_äük value:' at line 1
error : Corrupt
Try to repair the table manually:
mysql --user=root --port=9306 --protocol=tcp -e"set names utf8; use db_abc; repair table \`#mysql50#tb2_äük\`;"
results in the above crash.
The same is observed if trying to rename the table as in
mysql --user=root --port=9306 --protocol=tcp -e"set names utf8; use db_abc; rename table \`#mysql50#tb2_äük\` to \`tb2_äük\`;"
Trying to run
./mysqlcheck --check-upgrade --fix-db-names --fix-table-names --all-databases
returns
Failed to RENAME TABLE `#mysql50#tb2_��k` TO `tb2_��k`
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '�ük for each row
insert into test.log values ("From trig_äük value:' at line 1
but does not crash the server.
Note that as in bug#33094 if there is no trigger defined - no errors are observed
The problem is not observed when performing a dump/restore
Suggested fix:
Have the tables convert properly when triggers are present