Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table name can be in multiple parts #58

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions src/tds/codec/token/token_col_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ impl TokenColMetaData {
let mut columns = Vec::with_capacity(column_count as usize);

if column_count > 0 && column_count < 0xffff {
/*// CekTable (Column Encryption Keys)
let cek_count = try!(self.read_u16::<LittleEndian>());
// TODO: Cek/encryption stuff not implemented yet
assert_eq!(cek_count, 0);*/

// read all metadata for each column
for _ in 0..column_count {
let base = BaseMetaDataColumn::decode(src).await?;
let col_name_len = src.read_u8().await?;
Expand Down Expand Up @@ -168,40 +162,37 @@ impl BaseMetaDataColumn {
TypeInfo::VarLenSized(VarLenType::Text, _, _) => {
src.read_u16_le().await?;
pimeys marked this conversation as resolved.
Show resolved Hide resolved
src.read_u16_le().await?;
src.read_u16_le().await?;
src.read_u8().await?;

let num_of_parts = src.read_u8().await?;

// table name
let len = src.read_u16_le().await?;
read_varchar(src, len).await?;
for _ in 0..num_of_parts {
let len = src.read_u16_le().await?;
read_varchar(src, len as usize).await?;
}
}
TypeInfo::VarLenSized(VarLenType::NText, _, _) => {
src.read_u8().await?;
let num_of_parts = src.read_u8().await?;

// table name
let len = src.read_u16_le().await?;
read_varchar(src, len as usize).await?;
for _ in 0..num_of_parts {
let len = src.read_u16_le().await?;
read_varchar(src, len as usize).await?;
}
}
TypeInfo::VarLenSized(VarLenType::Image, _, _) => {
src.read_u8().await?;
let num_of_parts = src.read_u8().await?;

// table name
let len = src.read_u16_le().await?;
read_varchar(src, len).await?;
for _ in 0..num_of_parts {
let len = src.read_u16_le().await?;
read_varchar(src, len as usize).await?;
}
}
_ => (),
}

// TODO: for type={text, ntext, and image} TABLENAME

/*// CryptoMetaData
let cmd_ordinal = try!(self.read_u16::<LittleEndian>());
let cmd_user_ty = try!(self.read_u32::<LittleEndian>());
let cmd_ty_info: TypeInfo = try!(self.unserialize(ctx));
let cmd_encryption_algo = try!(self.read_u8());
// TODO:
assert_eq!(cmd_encryption_algo, 0);
let cmd_algo_name = try!(self.read_varchar::<u8>());
let cmd_algo_type = try!(self.read_u8());
let cmd_norm_version = try!(self.read_u8());*/
Ok(BaseMetaDataColumn { flags, ty })
}
}