summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <istruewing@stella.local>2008-01-14 17:59:45 +0100
committerunknown <istruewing@stella.local>2008-01-14 17:59:45 +0100
commitc3bf70215b4515c2fcf21bbb9a93aaf66d8c3faf (patch)
tree66d093fff78091b22e412f4965044fffc50d42a4 /storage
parentc7ee0f3e2ce1aafe950bd16caea1850913e01f3f (diff)
downloadmariadb-git-c3bf70215b4515c2fcf21bbb9a93aaf66d8c3faf.tar.gz
Bug#33222 - myisam-table drops rows when column is added
and a char-field > 128 exists CHECK TABLE (non-QUICK) and any form of repair table did wrongly rate records as corrupted under the following conditions: 1. The table has dynamic row format and 2. it has a CHAR like column > 127 bytes (but not VARCHAR) (for multi-byte character sets this could be less than 127 characters) and 3. it has records with > 127 bytes significant length in that column (a byte beyond byte position 127 must be non-space). Affected were the statements CHECK TABLE, REPAIR TABLE, OPTIMIZE TABLE, ALTER TABLE. CHECK TABLE reported and marked the table as crashed if any record was present that fulfilled condition 3. The other statements deleted these records. 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: Bug#33222 - myisam-table drops rows when column is added and a char-field > 128 exists Added test result. mysql-test/t/myisam.test: Bug#33222 - myisam-table drops rows when column is added and a char-field > 128 exists Added test. storage/myisam/mi_dynrec.c: 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. Fixed some small coding style violations near the changes.
Diffstat (limited to 'storage')
-rw-r--r--storage/myisam/mi_dynrec.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 9940cf62204..22fa3d18802 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -1006,12 +1006,12 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to,
{
if (rec->length > 255 && new_length > 127)
{
- to[0]=(char) ((new_length & 127)+128);
- to[1]=(char) (new_length >> 7);
- to+=2;
- }
- else
- *to++= (char) new_length;
+ to[0]= (uchar) ((new_length & 127) + 128);
+ to[1]= (uchar) (new_length >> 7);
+ to+=2;
+ }
+ else
+ *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, register uchar *to,
}
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, register uchar *to,
}
}
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,const uchar *record, uchar *rec_buff,
goto err;
if (rec->length > 255 && new_length > 127)
{
- if (to[0] != (char) ((new_length & 127)+128) ||
- to[1] != (char) (new_length >> 7))
- goto err;
- to+=2;
- }
- else if (*to++ != (char) new_length)
+ /* 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++ != (uchar) new_length)
goto err;
to+=new_length;
}