Skip to content

Commit

Permalink
Merge pull request MaterializeInc#14161 from mjibson/pgtest-params
Browse files Browse the repository at this point in the history
pgtest: test invalid param binding
  • Loading branch information
maddyblue authored Aug 10, 2022
2 parents f7a0f43 + 82fb937 commit a2fa422
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/environmentd/tests/pgwire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tokio::runtime::Runtime;
use tokio::sync::mpsc;

use mz_ore::collections::CollectionExt;
use mz_ore::{assert_contains, task};
use mz_ore::task;
use mz_pgrepr::{Numeric, Record};

use crate::util::PostgresErrorExt;
Expand All @@ -43,11 +43,6 @@ fn test_bind_params() -> Result<(), Box<dyn Error>> {
let server = util::start_server(config)?;
let mut client = server.connect(postgres::NoTls)?;

match client.query("SELECT ROW(1, 2) = $1", &[&42_i32]) {
Ok(_) => panic!("query with invalid parameters executed successfully"),
Err(err) => assert_contains!(format!("{:?}", err.source()), "WrongType"),
}

match client.query("SELECT ROW(1, 2) = $1", &[&"(1,2)"]) {
Ok(_) => panic!("query with invalid parameters executed successfully"),
Err(err) => assert!(err.to_string().contains("no overload")),
Expand Down
14 changes: 14 additions & 0 deletions test/pgtest/params.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Test that invalid query params are rejected.

send
Parse {"query": "SELECT $1 + 1"}
Bind {"values": ["a"]}
Sync
----

until err_field_typs=S
ReadyForQuery
----
ParseComplete
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"}]}
ReadyForQuery {"status":"I"}

0 comments on commit a2fa422

Please sign in to comment.