From: Date: November 25 2008 7:22am Subject: bzr commit into mysql-5.0-bugteam branch (ramil:2724) Bug#40984 List-Archive: http://lists.mysql.com/commits/59747 X-Bug: 40984 Message-Id: <0KAV00CV6LP2HU20@fe-emea-10.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT #At file:///home/ram/mysql/b40984.5.1-bugteam/ 2724 Ramil Kalimullin 2008-11-25 Fix for bug#40984: backport fix from 39585 into 5.0 Problem: in 5.0 'check table for upgrade' doesn't detect incompatible collation changes made in 5.0.48. Fix: backport #39585 fix to 5.0 modified: sql/handler.cc sql/handler.h per-file messages: sql/handler.cc Fix for bug#40984: backport fix from 39585 into 5.0 - backport of #39585 fix sql/handler.h Fix for bug#40984: backport fix from 39585 into 5.0 - backport of #39585 fix === modified file 'sql/handler.cc' --- a/sql/handler.cc 2008-10-23 20:56:03 +0000 +++ b/sql/handler.cc 2008-11-25 06:22:02 +0000 @@ -1957,8 +1957,53 @@ bool handler::get_error_message(int erro } +/** + Check for incompatible collation changes. + + @retval + HA_ADMIN_NEEDS_UPGRADE Table may have data requiring upgrade. + @retval + 0 No upgrade required. +*/ + +int handler::check_collation_compatibility() +{ + ulong mysql_version= table->s->mysql_version; + + if (mysql_version < 50048) + { + KEY *key= table->key_info; + KEY *key_end= key + table->s->keys; + for (; key < key_end; key++) + { + KEY_PART_INFO *key_part= key->key_part; + KEY_PART_INFO *key_part_end= key_part + key->key_parts; + for (; key_part < key_part_end; key_part++) + { + if (!key_part->fieldnr) + continue; + Field *field= table->field[key_part->fieldnr - 1]; + uint cs_number= field->charset()->number; + if (mysql_version < 50048 && + (cs_number == 11 || /* ascii_general_ci - bug #29499, bug #27562 */ + cs_number == 41 || /* latin7_general_ci - bug #29461 */ + cs_number == 42 || /* latin7_general_cs - bug #29461 */ + cs_number == 20 || /* latin7_estonian_cs - bug #29461 */ + cs_number == 21 || /* latin2_hungarian_ci - bug #29461 */ + cs_number == 22 || /* koi8u_general_ci - bug #29461 */ + cs_number == 23 || /* cp1251_ukrainian_ci - bug #29461 */ + cs_number == 26)) /* cp1250_general_ci - bug #29461 */ + return HA_ADMIN_NEEDS_UPGRADE; + } + } + } + return 0; +} + + int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt) { + int error; KEY *keyinfo, *keyend; KEY_PART_INFO *keypart, *keypartend; @@ -1987,6 +2032,10 @@ int handler::ha_check_for_upgrade(HA_CHE } if (table->s->frm_version != FRM_VER_TRUE_VARCHAR) return HA_ADMIN_NEEDS_ALTER; + + if ((error= check_collation_compatibility())) + return error; + return check_for_upgrade(check_opt); } === modified file 'sql/handler.h' --- a/sql/handler.h 2008-03-21 15:23:17 +0000 +++ b/sql/handler.h 2008-11-25 06:22:02 +0000 @@ -787,6 +787,7 @@ protected: virtual int check_for_upgrade(HA_CHECK_OPT *check_opt) { return 0; } public: + int check_collation_compatibility(); int ha_check_for_upgrade(HA_CHECK_OPT *check_opt); int check_old_types(); /* to be actually called to get 'check()' functionality*/