Skip to content

Commit fb4cfe1

Browse files
committed
Add integration test
1 parent b7aa40f commit fb4cfe1

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

integration/rust/tests/integration/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ pub mod timestamp_sorting;
3535
pub mod tls_enforced;
3636
pub mod tls_reload;
3737
pub mod transaction_state;
38+
pub mod unrecognized_aggregate;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use rust::setup::{admin_sqlx, connections_sqlx};
2+
use sqlx::Executor;
3+
use std::assert_matches;
4+
5+
async fn define_custom_aggregate_fn() {
6+
for connection in connections_sqlx().await {
7+
connection
8+
.execute("DROP AGGREGATE IF EXISTS pgdog_sum (int4)")
9+
.await
10+
.unwrap();
11+
connection
12+
.execute("CREATE AGGREGATE pgdog_sum (int4) (sfunc = int4_sum, stype = bigint)")
13+
.await
14+
.unwrap();
15+
connection
16+
.execute("DROP TABLE IF EXISTS unrecognized_agg_test")
17+
.await
18+
.unwrap();
19+
connection
20+
.execute("CREATE TABLE unrecognized_agg_test (lol int4)")
21+
.await
22+
.unwrap();
23+
}
24+
admin_sqlx().await.execute("RELOAD").await.unwrap();
25+
}
26+
27+
#[tokio::test]
28+
async fn unrecognized_aggregate_function_errors_only_on_cross_shard_queries() {
29+
define_custom_aggregate_fn().await;
30+
let mut connections = connections_sqlx().await;
31+
let sharded = connections.pop().unwrap();
32+
let unsharded = connections.pop().unwrap();
33+
34+
let unsharded_query = unsharded
35+
.fetch_one("SELECT pgdog_sum(lol) FROM unrecognized_agg_test")
36+
.await;
37+
assert_matches!(unsharded_query, Ok(_));
38+
39+
let sharded_query = sharded
40+
.fetch_one("SELECT pgdog_sum(lol) FROM unrecognized_agg_test")
41+
.await;
42+
let err = sharded_query
43+
.err()
44+
.expect("unrecognized aggregate executed successfully");
45+
assert!(err.to_string().contains("pgdog_sum is not yet supported"));
46+
}

0 commit comments

Comments
 (0)