This repository was archived by the owner on Jan 14, 2025. It is now read-only.
File tree 3 files changed +32
-2
lines changed
3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -439,8 +439,10 @@ impl Client {
439
439
if let Some ( row_description) = row_description {
440
440
let mut it = row_description. fields ( ) ;
441
441
while let Some ( field) = it. next ( ) . map_err ( Error :: parse) ? {
442
+ // NB: for some types that function may send a query to the server. At least in
443
+ // raw text mode we don't need that info and can skip this.
442
444
let type_ = get_type ( & self . inner , field. type_oid ( ) ) . await ?;
443
- let column = Column :: new ( field. name ( ) . to_string ( ) , type_) ;
445
+ let column = Column :: new ( field. name ( ) . to_string ( ) , type_, field ) ;
444
446
columns. push ( column) ;
445
447
}
446
448
}
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ use crate::client::InnerClient;
2
2
use crate :: codec:: FrontendMessage ;
3
3
use crate :: connection:: RequestMessages ;
4
4
use crate :: types:: Type ;
5
- use postgres_protocol:: message:: frontend;
5
+ use postgres_protocol:: {
6
+ message:: { backend:: Field , frontend} ,
7
+ Oid ,
8
+ } ;
6
9
use postgres_types:: Format ;
7
10
use std:: {
8
11
fmt,
Original file line number Diff line number Diff line change @@ -351,6 +351,31 @@ async fn command_tag() {
351
351
assert_eq ! ( row_stream. command_tag( ) , Some ( "SELECT 3" . to_string( ) ) ) ;
352
352
}
353
353
354
+ #[ tokio:: test]
355
+ async fn column_extras ( ) {
356
+ let client = connect ( "user=postgres" ) . await ;
357
+
358
+ let rows: Vec < tokio_postgres:: Row > = client
359
+ . query_raw_txt ( "select relacl, relname from pg_class limit 1" , [ ] )
360
+ . await
361
+ . unwrap ( )
362
+ . try_collect ( )
363
+ . await
364
+ . unwrap ( ) ;
365
+
366
+ let column = rows[ 0 ] . columns ( ) . get ( 1 ) . unwrap ( ) ;
367
+ assert_eq ! ( column. name( ) , "relname" ) ;
368
+ assert_eq ! ( column. type_( ) , & Type :: NAME ) ;
369
+
370
+ assert ! ( column. table_oid( ) > 0 ) ;
371
+ assert_eq ! ( column. column_id( ) , 2 ) ;
372
+ assert_eq ! ( column. format( ) , 0 ) ;
373
+
374
+ assert_eq ! ( column. type_oid( ) , 19 ) ;
375
+ assert_eq ! ( column. type_size( ) , 64 ) ;
376
+ assert_eq ! ( column. type_modifier( ) , -1 ) ;
377
+ }
378
+
354
379
#[ tokio:: test]
355
380
async fn custom_composite ( ) {
356
381
let client = connect ( "user=postgres" ) . await ;
You can’t perform that action at this time.
0 commit comments