XtraDB 1.0.6-9编译错误的解决

1月 14th, 2010 | Posted by | Filed under 未分类

本文内容遵从CC版权协议, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明
网址: http://www.penglixun.com/database/xtradb_compile_error.html

今天 XtraDB Release 9 发布了,不过,竟然有编译错误,真是个杯具哇,不过还好,不是什么难解决的错误。

我下载的是 MySQL 5.1.42 和 XtraDB 1.0.6-9,把xtradb的解压文件覆盖mysql的storage/innobase,很Happy的去编译,想很快就能完成,结果一个Error让我郁闷了:
handler/i_s.cc: In function ‘int i_s_innodb_admin_command_fill(THD*,
TABLE_LIST*, COND*)’:
handler/i_s.cc:2995: warning: deprecated conversion from string
constant to ‘char*’
handler/i_s.cc:2991: warning: unused variable ‘cs’
handler/i_s.cc: At global scope:
handler/i_s.cc:2984: warning: unused parameter ‘cond’
make[2]: *** [libinnobase_a-i_s.o] Error 1
make[2]: Leaving directory `/home/plx/Downloads/mysql-5.1.42/storage/
innobase’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/plx/Downloads/mysql-5.1.42/storage’
make: *** [all-recursive] Error 1

我还以为我的GCC参数设置错了,去掉参数直接configure,还是一样的错误。
于是怀疑是不是xtradb本来的问题了,用我的GCC参数编译原版,一切正常,肯定就是xtradb的问题。
Google之无结果,百度之也无结果~

只能自己动手丰衣足食了,先到percona-discus讨论组提问,等待回答。
然后仔细看编译错误发现 真正的Error所在:
handler/i_s.cc: In function ‘int i_s_innodb_buffer_pool_pages_index_fill(THD*, TABLE_LIST*, COND*)’:
handler/i_s.cc:801: error: invalid conversion from ‘const char*’ to ‘char*’

查看了这一行代码:
if((p = strchr(index->table_name, ‘/’)))

于是去查看strchr的函数原型,得到:
extern char *strchr(char *s,char c);

那就判定是index->table_name是const char * 导致的。
于是很简单的加上const_cast,801行改为:
if((p = strchr(const_cast(index->table_name), ‘/’)))

再次编译,成功。

然后看到邮件组里XtraDB的开发人员Aleksandr Kuzminsky也回复我了,确认这是个BUG,然后修正方法跟我也差不多。
不过Aleksandr Kuzminsky也说了,这个问题会导致mysql-test无法通过。

这个版本的XtraDB算比较失败了,期待下一个版本。

目前还没有任何评论.