Skip to content

Commit

Permalink
bugfix: Enum parsing
Browse files Browse the repository at this point in the history
Enum actually starts at 1. 0 seems to indicate some kind of invalid value?
  • Loading branch information
Codetector1374 committed Aug 8, 2024
1 parent 84ac80a commit 8c75ee2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/innodb/table/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ impl Field {
};

let num = self.parse_uint(buf, len);
assert!(
(num as usize) < values.len(),
"Enum Value is larger than expected?"
);
(FieldValue::String(values[num as usize].clone()), len)
if num == 0 {
(FieldValue::String("__ERROR__".to_owned()), len)
} else {
let variant_index = num - 1;
assert!(
(variant_index as usize) < values.len(),
"Enum Value is larger than expected? {} vs {}", variant_index, values.len()
);
(FieldValue::String(values[variant_index as usize].clone()), len)
}
}
#[allow(unreachable_patterns)]
_ => {
Expand Down

0 comments on commit 8c75ee2

Please sign in to comment.