2424//! )", &[]).unwrap();
2525//! let me = Person {
2626//! id: 0,
27- //! name: "Steven".to_string (),
27+ //! name: "Steven".to_owned (),
2828//! data: None
2929//! };
3030//! conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
4141//! }
4242//! }
4343//! ```
44- #![ doc( html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.10.0 " ) ]
44+ #![ doc( html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.10.1 " ) ]
4545#![ warn( missing_docs) ]
4646
4747extern crate bufstream;
@@ -52,6 +52,7 @@ extern crate phf;
5252extern crate rustc_serialize as serialize;
5353#[ cfg( feature = "unix_socket" ) ]
5454extern crate unix_socket;
55+ extern crate net2;
5556
5657use bufstream:: BufStream ;
5758use md5:: Md5 ;
@@ -67,6 +68,7 @@ use std::io::prelude::*;
6768use std:: marker:: Sync as StdSync ;
6869use std:: mem;
6970use std:: result;
71+ use std:: time:: Duration ;
7072#[ cfg( feature = "unix_socket" ) ]
7173use std:: path:: PathBuf ;
7274
@@ -455,10 +457,12 @@ impl InnerConnection {
455457
456458 fn setup_typeinfo_query ( & mut self ) -> result:: Result < ( ) , ConnectError > {
457459 match self . raw_prepare ( TYPEINFO_QUERY ,
458- "SELECT t.typname, t.typelem, r.rngsubtype \
460+ "SELECT t.typname, t.typelem, r.rngsubtype, n.nspname \
459461 FROM pg_catalog.pg_type t \
460462 LEFT OUTER JOIN pg_catalog.pg_range r \
461463 ON r.rngtypid = t.oid \
464+ INNER JOIN pg_catalog.pg_namespace n \
465+ ON t.typnamespace = n.oid \
462466 WHERE t.oid = $1") {
463467 Ok ( ..) => return Ok ( ( ) ) ,
464468 Err ( Error :: IoError ( e) ) => return Err ( ConnectError :: IoError ( e) ) ,
@@ -469,9 +473,11 @@ impl InnerConnection {
469473 }
470474
471475 match self . raw_prepare ( TYPEINFO_QUERY ,
472- "SELECT typname, typelem, NULL::OID \
473- FROM pg_catalog.pg_type \
474- WHERE oid = $1") {
476+ "SELECT t.typname, t.typelem, NULL::OID, n.nspname \
477+ FROM pg_catalog.pg_type t \
478+ INNER JOIN pg_catalog.pg_namespace n \
479+ ON t.typnamespace = n.oid \
480+ WHERE t.oid = $1") {
475481 Ok ( ..) => Ok ( ( ) ) ,
476482 Err ( Error :: IoError ( e) ) => Err ( ConnectError :: IoError ( e) ) ,
477483 Err ( Error :: DbError ( e) ) => Err ( ConnectError :: DbError ( e) ) ,
@@ -504,6 +510,24 @@ impl InnerConnection {
504510 }
505511 }
506512
513+ fn read_message_with_notification_timeout ( & mut self , timeout : Duration )
514+ -> std:: io:: Result < Option < BackendMessage > > {
515+ debug_assert ! ( !self . desynchronized) ;
516+ loop {
517+ match try_desync ! ( self , self . stream. read_message_timeout( timeout) ) {
518+ Some ( NoticeResponse { fields } ) => {
519+ if let Ok ( err) = DbError :: new_raw ( fields) {
520+ self . notice_handler . handle_notice ( err) ;
521+ }
522+ }
523+ Some ( ParameterStatus { parameter, value } ) => {
524+ self . parameters . insert ( parameter, value) ;
525+ }
526+ val => return Ok ( val)
527+ }
528+ }
529+ }
530+
507531 fn read_message ( & mut self ) -> std_io:: Result < BackendMessage > {
508532 loop {
509533 match try!( self . read_message_with_notification ( ) ) {
@@ -661,7 +685,7 @@ impl InnerConnection {
661685 }
662686
663687 fn get_type ( & mut self , oid : Oid ) -> Result < Type > {
664- if let Some ( ty) = Type :: new ( oid) {
688+ if let Some ( ty) = Type :: from_oid ( oid) {
665689 return Ok ( ty) ;
666690 }
667691
@@ -696,7 +720,7 @@ impl InnerConnection {
696720 }
697721 _ => bad_response ! ( self )
698722 }
699- let ( name, elem_oid, rngsubtype) : ( String , Oid , Option < Oid > ) =
723+ let ( name, elem_oid, rngsubtype, schema ) : ( String , Oid , Option < Oid > , String ) =
700724 match try!( self . read_message ( ) ) {
701725 DataRow { row } => {
702726 let ctx = SessionInfo :: new ( self ) ;
@@ -708,6 +732,9 @@ impl InnerConnection {
708732 & ctx) ) ,
709733 try!( FromSql :: from_sql_nullable ( & Type :: Oid ,
710734 row[ 2 ] . as_ref ( ) . map ( |r| & * * r) . as_mut ( ) ,
735+ & ctx) ) ,
736+ try!( FromSql :: from_sql_nullable ( & Type :: Name ,
737+ row[ 3 ] . as_ref ( ) . map ( |r| & * * r) . as_mut ( ) ,
711738 & ctx) ) )
712739 }
713740 ErrorResponse { fields } => {
@@ -735,7 +762,7 @@ impl InnerConnection {
735762 }
736763 } ;
737764
738- let type_ = Type :: Other ( Box :: new ( Other :: new ( name, oid, kind) ) ) ;
765+ let type_ = Type :: Other ( Box :: new ( Other :: new ( name, oid, kind, schema ) ) ) ;
739766 self . unknown_types . insert ( oid, type_. clone ( ) ) ;
740767 Ok ( type_)
741768 }
@@ -860,7 +887,7 @@ impl Connection {
860887 /// target: ConnectTarget::Unix(some_crazy_path),
861888 /// port: None,
862889 /// user: Some(UserInfo {
863- /// user: "postgres".to_string (),
890+ /// user: "postgres".to_owned (),
864891 /// password: None
865892 /// }),
866893 /// database: None,
@@ -911,7 +938,7 @@ impl Connection {
911938 self . conn . borrow_mut ( ) . prepare ( query, self )
912939 }
913940
914- /// Creates cached prepared statement.
941+ /// Creates a cached prepared statement.
915942 ///
916943 /// Like `prepare`, except that the statement is only prepared once over
917944 /// the lifetime of the connection and then cached. If the same statement
@@ -1337,7 +1364,7 @@ impl<'a> GenericConnection for Transaction<'a> {
13371364}
13381365
13391366trait OtherNew {
1340- fn new ( name : String , oid : Oid , kind : Kind ) -> Other ;
1367+ fn new ( name : String , oid : Oid , kind : Kind , schema : String ) -> Other ;
13411368}
13421369
13431370trait DbErrorNew {
@@ -1346,10 +1373,6 @@ trait DbErrorNew {
13461373 fn new < T > ( fields : Vec < ( u8 , String ) > ) -> Result < T > ;
13471374}
13481375
1349- trait TypeNew {
1350- fn new ( oid : Oid ) -> Option < Type > ;
1351- }
1352-
13531376trait RowsNew < ' a > {
13541377 fn new ( stmt : & ' a Statement < ' a > , data : Vec < Vec < Option < Vec < u8 > > > > ) -> Rows < ' a > ;
13551378}
0 commit comments