File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -599,6 +599,14 @@ impl Config {
599
599
self . replication_mode ( mode) ;
600
600
}
601
601
}
602
+ "max_backend_message_size" => {
603
+ let limit = value
604
+ . parse :: < usize > ( )
605
+ . map_err ( |_| Error :: config_parse ( Box :: new ( InvalidValue ( "max_backend_message_size" ) ) ) ) ?;
606
+ if limit > 0 {
607
+ self . max_backend_message_size ( limit) ;
608
+ }
609
+ }
602
610
key => {
603
611
return Err ( Error :: config_parse ( Box :: new ( UnknownOption (
604
612
key. to_string ( ) ,
Original file line number Diff line number Diff line change @@ -280,6 +280,30 @@ async fn query_raw_txt() {
280
280
assert ! ( rows[ 0 ] . body_len( ) > 0 ) ;
281
281
}
282
282
283
+ #[ tokio:: test]
284
+ async fn limit_max_backend_message_size ( ) {
285
+ let client = connect ( "user=postgres max_backend_message_size=10000" ) . await ;
286
+ let small: Vec < tokio_postgres:: Row > = client
287
+ . query_raw_txt ( "SELECT REPEAT('a', 20)" , [ ] )
288
+ . await
289
+ . unwrap ( )
290
+ . try_collect ( )
291
+ . await
292
+ . unwrap ( ) ;
293
+
294
+ assert_eq ! ( small. len( ) , 1 ) ;
295
+ assert_eq ! ( small[ 0 ] . as_text( 0 ) . unwrap( ) . unwrap( ) . len( ) , 20 ) ;
296
+
297
+ let large: Result < Vec < tokio_postgres:: Row > , Error > = client
298
+ . query_raw_txt ( "SELECT REPEAT('a', 2000000)" , [ ] )
299
+ . await
300
+ . unwrap ( )
301
+ . try_collect ( )
302
+ . await ;
303
+
304
+ assert ! ( large. is_err( ) ) ;
305
+ }
306
+
283
307
#[ tokio:: test]
284
308
async fn command_tag ( ) {
285
309
let client = connect ( "user=postgres" ) . await ;
You can’t perform that action at this time.
0 commit comments