File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,8 +150,6 @@ pub trait Connection: SimpleConnection + Sized + Send {
150150 where
151151 T : QueryFragment < Self :: Backend > + QueryId ;
152152
153- #[ doc( hidden) ]
154- fn silence_notices < F : FnOnce ( ) -> T , T > ( & self , f : F ) -> T ;
155153 #[ doc( hidden) ]
156154 fn transaction_manager ( & self ) -> & Self :: TransactionManager ;
157155}
Original file line number Diff line number Diff line change @@ -235,14 +235,12 @@ pub fn setup_database<Conn: Connection>(conn: &Conn) -> QueryResult<usize> {
235235}
236236
237237fn create_schema_migrations_table_if_needed < Conn : Connection > ( conn : & Conn ) -> QueryResult < usize > {
238- conn. silence_notices ( || {
239- conn. execute (
240- "CREATE TABLE IF NOT EXISTS __diesel_schema_migrations (
241- version VARCHAR(50) PRIMARY KEY NOT NULL,
242- run_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
243- )" ,
244- )
245- } )
238+ conn. execute (
239+ "CREATE TABLE IF NOT EXISTS __diesel_schema_migrations (\
240+ version VARCHAR(50) PRIMARY KEY NOT NULL,\
241+ run_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\
242+ )",
243+ )
246244}
247245
248246#[ doc( hidden) ]
Original file line number Diff line number Diff line change @@ -80,11 +80,6 @@ impl Connection for MysqlConnection {
8080 } )
8181 }
8282
83- #[ doc( hidden) ]
84- fn silence_notices < F : FnOnce ( ) -> T , T > ( & self , f : F ) -> T {
85- f ( )
86- }
87-
8883 #[ doc( hidden) ]
8984 fn execute_returning_count < T > ( & self , source : & T ) -> QueryResult < usize >
9085 where
Original file line number Diff line number Diff line change 55pub mod result;
66mod stmt;
77
8- use std:: ffi:: { CStr , CString } ;
8+ use std:: ffi:: CString ;
99use std:: os:: raw as libc;
1010
1111use connection:: * ;
@@ -88,16 +88,6 @@ impl Connection for PgConnection {
8888 . map ( |r| r. rows_affected ( ) )
8989 }
9090
91- #[ doc( hidden) ]
92- fn silence_notices < F : FnOnce ( ) -> T , T > ( & self , f : F ) -> T {
93- self . raw_connection
94- . set_notice_processor ( noop_notice_processor) ;
95- let result = f ( ) ;
96- self . raw_connection
97- . set_notice_processor ( default_notice_processor) ;
98- result
99- }
100-
10191 #[ doc( hidden) ]
10292 fn transaction_manager ( & self ) -> & Self :: TransactionManager {
10393 & self . transaction_manager
@@ -142,20 +132,14 @@ impl PgConnection {
142132 fn set_config_options ( & self ) -> QueryResult < ( ) > {
143133 self . execute ( "SET TIME ZONE 'UTC'" ) ?;
144134 self . execute ( "SET CLIENT_ENCODING TO 'UTF8'" ) ?;
135+ self . raw_connection
136+ . set_notice_processor ( noop_notice_processor) ;
145137 Ok ( ( ) )
146138 }
147139}
148140
149141extern "C" fn noop_notice_processor ( _: * mut libc:: c_void , _message : * const libc:: c_char ) { }
150142
151- extern "C" fn default_notice_processor ( _: * mut libc:: c_void , message : * const libc:: c_char ) {
152- use std:: io:: Write ;
153- let c_str = unsafe { CStr :: from_ptr ( message) } ;
154- :: std:: io:: stderr ( )
155- . write_all ( c_str. to_bytes ( ) )
156- . expect ( "Error writing to `stderr`" ) ;
157- }
158-
159143#[ cfg( test) ]
160144mod tests {
161145 extern crate dotenv;
Original file line number Diff line number Diff line change @@ -85,11 +85,6 @@ impl Connection for SqliteConnection {
8585 Ok ( self . raw_connection . rows_affected_by_last_query ( ) )
8686 }
8787
88- #[ doc( hidden) ]
89- fn silence_notices < F : FnOnce ( ) -> T , T > ( & self , f : F ) -> T {
90- f ( )
91- }
92-
9388 #[ doc( hidden) ]
9489 fn transaction_manager ( & self ) -> & Self :: TransactionManager {
9590 & self . transaction_manager
Original file line number Diff line number Diff line change @@ -61,11 +61,9 @@ impl Drop for Database {
6161 PgConnection :: establish( & postgres_url) ,
6262 "Couldn't connect to database"
6363 ) ;
64- conn. silence_notices ( || {
65- try_drop ! (
66- conn. execute( & format!( r#"DROP DATABASE IF EXISTS "{}""# , database) ) ,
67- "Couldn't drop database"
68- ) ;
69- } ) ;
64+ try_drop ! (
65+ conn. execute( & format!( r#"DROP DATABASE IF EXISTS "{}""# , database) ) ,
66+ "Couldn't drop database"
67+ ) ;
7068 }
7169}
You can’t perform that action at this time.
0 commit comments