sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

regression: upgrade to tokio-postgres 0.7.11 introduced regression on SimpleQueryMessage enum

lyang24 opened this issue · comments

Hey @sfackler, I noticed some strange behavior after upgrade to postgres 0.7.11 (postgres-types from 0.26->0.27, postgres-protocol from 0.66->0.67). For an example the query below will panic because the result from simple_query is rather RowDescription variant instead of SimpleQueryMessage::Row is this expected?

let _ = client
     .simple_query("CREATE TABLE test(b BLOB, ts TIMESTAMP TIME INDEX)")
     .await
     .unwrap();
 let _ = client
     .simple_query("INSERT INTO test VALUES(X'6162636b6c6d2aa954', 0)")
     .await
     .unwrap();
 let get_row = |mess: Vec<SimpleQueryMessage>| -> String {
     match &mess[0] {
         SimpleQueryMessage::Row(row) => row.get(0).unwrap().to_string(),
         _ => unreachable!(),
     }
 };

 let r = client.simple_query("SELECT b FROM test").await.unwrap();
 let b = get_row(r);
 assert_eq!(b, "\\x6162636b6c6d2aa954");

Yes, that is expected. SimpleQueryMessage is #[non_exhaustive] specifically so that new variants can be added, and consumers should expect that.