Fix null_bitmap size in MariaDb

This commit is contained in:
Daniel Akhterov 2019-12-05 19:39:28 -08:00
parent 6cac5383e3
commit fdd60eb9b1
3 changed files with 5 additions and 4 deletions

View File

@ -115,10 +115,11 @@ impl Executor for MariaDb {
let columns = self.result_column_defs().await?;
let capabilities = self.capabilities;
let mut row: Option<_> = None;
let mut row = None;
loop {
let packet = self.receive().await?;
if packet[0] == 0xFE && packet.len() < 0xFF_FF_FF {
// NOTE: It's possible for a ResultRow to start with 0xFE (which would normally signify end-of-rows)
// but it's not possible for an Ok/Eof to be larger than 0xFF_FF_FF.

View File

@ -41,7 +41,7 @@ impl ResultRow {
let mut values = Vec::with_capacity(columns.len());
for column_idx in 0..columns.len() {
if null[column_idx / 8] & (1 << (column_idx % 8)) != 0 {
if null[column_idx / 8] & (1 << (column_idx % 8) as u8) != 0 {
values.push(None);
} else {
match columns[column_idx].field_type {

View File

@ -37,10 +37,10 @@ impl QueryParameters for MariaDbQueryParameters {
let index = self.param_types.len();
self.param_types.push(metadata);
self.null_bitmap.resize(index / 8, 0);
self.null_bitmap.resize((index / 8) + 1, 0);
if let IsNull::Yes = value.encode(&mut self.params) {
self.null_bitmap[index / 8] &= 1 << index % 8;
self.null_bitmap[index / 8] &= (1 << index % 8) as u8;
}
}
}