Skip to content

Commit

Permalink
Merge 7c4758b into fa59a44
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Apr 7, 2024
2 parents fa59a44 + 7c4758b commit 270d61c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions odbc-api/src/connection.rs
Expand Up @@ -372,6 +372,11 @@ impl<'c> Connection<'c> {
self.connection.is_dead().into_result(&self.connection)
}

/// Network packet size in bytes. Requries driver support.
pub fn packet_size(&self) -> Result<u32, Error> {
self.connection.packet_size().into_result(&self.connection)
}

/// Get the name of the database management system used by the connection.
pub fn database_management_system_name(&self) -> Result<String, Error> {
let mut buf = Vec::new();
Expand Down
5 changes: 5 additions & 0 deletions odbc-api/src/handles/connection.rs
Expand Up @@ -383,6 +383,11 @@ impl<'c> Connection<'c> {
}
}

/// Networ packet size in bytes.
pub fn packet_size(&self) -> SqlResult<u32> {
unsafe { self.attribute_u32(ConnectionAttribute::PacketSize) }
}

/// # Safety
///
/// Caller must ensure connection attribute is numeric.
Expand Down
11 changes: 11 additions & 0 deletions odbc-api/tests/integration.rs
Expand Up @@ -125,6 +125,17 @@ fn connect_to_db(profile: &Profile) {
assert!(!conn.is_dead().unwrap())
}

#[test_case(MSSQL, 4096; "Microsoft SQL Server")]
#[test_case(MARIADB, 8192; "Maria DB")]
#[test_case(SQLITE_3, 16384; "SQLite 3")]
#[test_case(POSTGRES, 4096; "PostgreSQL")]
fn default_packet_size(profile: &Profile, expected_packet_size: u32) {
let conn = profile.connection().unwrap();
let actual_packet_size = conn.packet_size().unwrap();

assert_eq!(expected_packet_size, actual_packet_size)
}

#[test_case(MSSQL; "Microsoft SQL Server")]
fn describe_columns(profile: &Profile) {
let table_name = table_name!();
Expand Down

0 comments on commit 270d61c

Please sign in to comment.