File tree Expand file tree Collapse file tree
integration/rust/tests/integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,3 +35,4 @@ pub mod timestamp_sorting;
3535pub mod tls_enforced;
3636pub mod tls_reload;
3737pub mod transaction_state;
38+ pub mod unrecognized_aggregate;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments