Bug #35903 OLD.(bit) gives the wrong data
Submitted: 8 Apr 2008 13:04 Modified: 8 Apr 2008 17:47
Reporter: Marco Janssen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S2 (Serious)
Version:5.0.32-Debian_7etch5-log OS:Linux
Assigned to: CPU Architecture:Any
Tags: bit, new, old, trigger, UPDATE

[8 Apr 2008 13:04] Marco Janssen
Description:
When you set a field in an update trigger like this,
NEW.bitfield2 = OLD.bitfield1
then OLD.bitfield1 shows the value of NEW.bitfield1 instead of the real and correct old value.

How to repeat:
DROP DATABASE IF EXISTS `MyTestDB`;
CREATE DATABASE `MyTestDB`;
USE `MyTestDB`;

CREATE TABLE `MyTestTable` (
  `id` int(11) NOT NULL auto_increment,
  `b1` bit(1) NOT NULL default '\0',
  `b2` bit(1) NOT NULL default '\0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO MyTestTable VALUES(1, 0, 0);
INSERT INTO MyTestTable VALUES(2, 0, 0);
INSERT INTO MyTestTable VALUES(3, 0, 0);

CREATE TRIGGER `MyBeforeUpdateTrigger` BEFORE UPDATE ON `MyTestTable`
  FOR EACH ROW BEGIN
  SET NEW.b2 = OLD.b1;
END;

When you edit b1 then b2 gets the new value of b1 instead of the old value as defined in the trigger.

Suggested fix:
OLD.B1 should be the old value like all other kind of fields.
[8 Apr 2008 15:00] MySQL Verification Team
Thank you for the bug report. Your reported version is quite older could
you please update to latest release and if still you get the same behavior
reported please print here the bad result and the expected one.
Thanks in advance.
[8 Apr 2008 16:16] Marco Janssen
I just downloaded the latest stable windows release (5.0.51a-community-nt) and there the bug seems to be fixed.

We are running on a Debian machine where the latest stable release is 5.0.32-Debian_7etch5-log. So I hope Debian will update the MySql server package soon.

Thank you for your time.
[8 Apr 2008 17:47] MySQL Verification Team
Thank you for the feedback. Closing since it was noticed already fixed in
released version.