Below is the list of changes that have just been committed into a local
5.1 repository of istruewing. When istruewing does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-12-18 15:19:04+01:00, istruewing@stripped +3 -0
Bug#33222 - myisam-table drops rows when column is added
and a char-field > 128 exists
ALTERing a table with long char columns warned about corruptions
and left the altered table empty.
The problem was a signed/unsigned compare in MyISAM code. A
char to uchar change became necessary after the big byte to uchar
change.
mysql-test/r/myisam.result@stripped, 2007-12-18 15:19:02+01:00, istruewing@stripped +24
-0
Bug#33222 - myisam-table drops rows when column is added
and a char-field > 128 exists
Added test result.
mysql-test/t/myisam.test@stripped, 2007-12-18 15:19:02+01:00, istruewing@stripped +37 -0
Bug#33222 - myisam-table drops rows when column is added
and a char-field > 128 exists
Added test.
storage/myisam/mi_dynrec.c@stripped, 2007-12-18 15:19:02+01:00, istruewing@stripped +11
-9
Bug#33222 - myisam-table drops rows when column is added
and a char-field > 128 exists
char -> uchar became necessary after big byte -> uchar change.
diff -Nrup a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
--- a/mysql-test/r/myisam.result 2007-11-15 20:25:40 +01:00
+++ b/mysql-test/r/myisam.result 2007-12-18 15:19:02 +01:00
@@ -2001,4 +2001,28 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
+CREATE TABLE t1 (
+c1 int(11) NOT NULL AUTO_INCREMENT,
+c2 int(11) NOT NULL DEFAULT '0',
+c3 int(11) NOT NULL DEFAULT '0',
+c4 date DEFAULT NULL,
+c5 varchar(60) DEFAULT NULL,
+c6 char(250) DEFAULT NULL,
+c7 varchar(10) DEFAULT NULL,
+PRIMARY KEY (c1),
+KEY (c2),
+KEY (c3),
+KEY (c4),
+KEY (c5)
+) ENGINE=MyISAM AUTO_INCREMENT=79170 DEFAULT CHARSET=latin1;
+# INSERT 110 rows. Query log disabled.
+UPDATE t1 SET c6=REPEAT("X",128) WHERE c2=1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+110
+ALTER TABLE t1 ENGINE=MyISAM;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+110
+DROP TABLE t1;
End of 5.1 tests
diff -Nrup a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
--- a/mysql-test/t/myisam.test 2007-11-15 20:25:40 +01:00
+++ b/mysql-test/t/myisam.test 2007-12-18 15:19:02 +01:00
@@ -1261,5 +1261,42 @@ DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
DROP TABLE t1;
+#
+# Bug#33222 - myisam-table drops rows when column is added
+# and a char-field > 128 exists
+#
+CREATE TABLE t1 (
+ c1 int(11) NOT NULL AUTO_INCREMENT,
+ c2 int(11) NOT NULL DEFAULT '0',
+ c3 int(11) NOT NULL DEFAULT '0',
+ c4 date DEFAULT NULL,
+ c5 varchar(60) DEFAULT NULL,
+ c6 char(250) DEFAULT NULL,
+ c7 varchar(10) DEFAULT NULL,
+ PRIMARY KEY (c1),
+ KEY (c2),
+ KEY (c3),
+ KEY (c4),
+ KEY (c5)
+) ENGINE=MyISAM AUTO_INCREMENT=79170 DEFAULT CHARSET=latin1;
+#
+--disable_query_log
+let $count= 110;
+--echo # INSERT $count rows. Query log disabled.
+while ($count)
+{
+ INSERT INTO t1 (c2, c3, c4, c5, c6, c7) VALUES (
+ 1, 1, current_date, 'abcdefghijklmnopqrstuvwxyzZYXWVUTSRQPOMNLKJIHGFEDCBA',
+ 'abcdefghijklmnopqrstuvwxyzZYXWVUTSRQPOMNLKJIHGFEDCBA', 'abcdefghij');
+ dec $count;
+}
+--enable_query_log
+#
+UPDATE t1 SET c6=REPEAT("X",128) WHERE c2=1;
+SELECT COUNT(*) FROM t1;
+ALTER TABLE t1 ENGINE=MyISAM;
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff -Nrup a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
--- a/storage/myisam/mi_dynrec.c 2007-11-12 10:07:27 +01:00
+++ b/storage/myisam/mi_dynrec.c 2007-12-18 15:19:02 +01:00
@@ -1006,12 +1006,12 @@ uint _mi_rec_pack(MI_INFO *info, registe
{
if (rec->length > 255 && new_length > 127)
{
- to[0]=(char) ((new_length & 127)+128);
- to[1]=(char) (new_length >> 7);
+ to[0]= (uchar) ((new_length & 127)+128);
+ to[1]= (uchar) (new_length >> 7);
to+=2;
}
else
- *to++= (char) new_length;
+ *to++= (uchar) new_length;
memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length;
flag|=bit;
}
@@ -1045,7 +1045,7 @@ uint _mi_rec_pack(MI_INFO *info, registe
}
if ((bit= bit << 1) >= 256)
{
- *packpos++ = (char) (uchar) flag;
+ *packpos++ = (uchar) flag;
bit=1; flag=0;
}
}
@@ -1055,9 +1055,9 @@ uint _mi_rec_pack(MI_INFO *info, registe
}
}
if (bit != 1)
- *packpos= (char) (uchar) flag;
+ *packpos= (uchar) flag;
if (info->s->calc_checksum)
- *to++=(char) info->checksum;
+ *to++= (uchar) info->checksum;
DBUG_PRINT("exit",("packed length: %d",(int) (to-startpos)));
DBUG_RETURN((uint) (to-startpos));
} /* _mi_rec_pack */
@@ -1128,12 +1128,14 @@ my_bool _mi_rec_check(MI_INFO *info,cons
goto err;
if (rec->length > 255 && new_length > 127)
{
- if (to[0] != (char) ((new_length & 127)+128) ||
- to[1] != (char) (new_length >> 7))
+ /* purecov: begin inspected */
+ if (to[0] != (uchar) ((new_length & 127)+128) ||
+ to[1] != (uchar) (new_length >> 7))
goto err;
to+=2;
+ /* purecov: end */
}
- else if (*to++ != (char) new_length)
+ else if (*to++ != (uchar) new_length)
goto err;
to+=new_length;
}