Bug #14090 The server stores junk in the TRG/TRN files
Submitted: 17 Oct 2005 22:49 Modified: 22 Nov 2005 17:22
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.16 BK source OS:Linux (SuSE 9.1)
Assigned to: Oleksandr Byelkin

[17 Oct 2005 22:49] Alexander Nozdrin
Description:
The MySQL server writes junk data in the names of the following attributes:
  - trigger parameters file (TRG), attribute "sql_mode":
    - string "sql_modes" is written with length 13 instead of 9;
  - in the trigger namespace file (TRN), attribute "trigger_table":
    - string "trigger_table" is written with length 15 instead of 13.

This happens because of the wrong definitions of File_option arrays
in sql/sql_trigger.cc:
  ...
  { (char *) "sql_modes", 13 },
  offsetof(class Table_triggers_list, definition_modes_list),
  FILE_OPTIONS_ULLLIST
  ...
  { (char *) "trigger_table", 15 },
  offsetof(struct st_trigname, trigger_table),
 FILE_OPTIONS_ESTRING

The problem is that fix of this bug breaks backward compatibility -- a database should be upgraded.

How to repeat:
Create a trigger, look into the corresponding TRG/TRN files.

Suggested fix:
Use STRING_WITH_LEN macro to define attribute names.
[30 Oct 2005 23:33] curt zirzow
Just to note, it appears this is a problem when  mysql responds with:

  Unexpected end of file while skipping unknown parameter 'sql_modes'

With mysqld shutdown removing these files and re-creating the the trigger definitions, will solve the issue.  This has only happened when moving from 5.0.13 to 5.0.15 as far as I know.
[11 Nov 2005 12:58] 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/32178
[12 Nov 2005 8:12] 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/32204
[15 Nov 2005 13:35] 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/32271
[15 Nov 2005 15:37] 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/32275
[20 Nov 2005 18:47] 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/32441
[21 Nov 2005 22:00] Oleksandr Byelkin
Thank you for bugreport! Bug is fixed and pushed to 5.0.17 repository.

Server understand wrong .TRGs, but it takes a bit more time, so better recreate triggers created in old versions.
[22 Nov 2005 17:22] Paul Dubois
Noted in 5.0.17 changelog.
[3 Dec 2005 17:17] Brian Schalme
This happened to me when upgrading from 5.0.15 to 5.0.16. Stopping MySQL, nuking the *.TRN and *.TRG files, starting MySQL, and re-creating the triggers solved the problem for me too.