@@ -778,35 +778,6 @@ impl InnerConnection {
778
778
} )
779
779
}
780
780
781
- fn prepare_copy_in < ' a > ( & mut self , table : & str , rows : & [ & str ] , conn : & ' a Connection )
782
- -> Result < CopyInStatement < ' a > > {
783
- let mut query = vec ! [ ] ;
784
- let _ = write ! ( & mut query, "SELECT " ) ;
785
- let _ = util:: comma_join_quoted_idents ( & mut query, rows. iter ( ) . cloned ( ) ) ;
786
- let _ = write ! ( & mut query, " FROM " ) ;
787
- let _ = util:: write_quoted_ident ( & mut query, table) ;
788
- let query = String :: from_utf8 ( query) . unwrap ( ) ;
789
- let ( _, columns) = try!( self . raw_prepare ( "" , & query) ) ;
790
- let column_types = columns. into_iter ( ) . map ( |desc| desc. type_ ) . collect ( ) ;
791
-
792
- let mut query = vec ! [ ] ;
793
- let _ = write ! ( & mut query, "COPY " ) ;
794
- let _ = util:: write_quoted_ident ( & mut query, table) ;
795
- let _ = write ! ( & mut query, " (" ) ;
796
- let _ = util:: comma_join_quoted_idents ( & mut query, rows. iter ( ) . cloned ( ) ) ;
797
- let _ = write ! ( & mut query, ") FROM STDIN WITH (FORMAT binary)" ) ;
798
- let query = String :: from_utf8 ( query) . unwrap ( ) ;
799
- let stmt_name = self . make_stmt_name ( ) ;
800
- try!( self . raw_prepare ( & stmt_name, & query) ) ;
801
-
802
- Ok ( CopyInStatement {
803
- conn : conn,
804
- name : stmt_name,
805
- column_types : column_types,
806
- finished : false ,
807
- } )
808
- }
809
-
810
781
fn close_statement ( & mut self , name : & str , type_ : u8 ) -> Result < ( ) > {
811
782
try!( self . write_messages ( & [
812
783
Close {
@@ -1094,15 +1065,6 @@ impl Connection {
1094
1065
self . conn . borrow_mut ( ) . prepare_cached ( query, self )
1095
1066
}
1096
1067
1097
- /// Creates a new COPY FROM STDIN prepared statement.
1098
- ///
1099
- /// These statements provide a method to efficiently bulk-upload data to
1100
- /// the database.
1101
- pub fn prepare_copy_in < ' a > ( & ' a self , table : & str , rows : & [ & str ] )
1102
- -> Result < CopyInStatement < ' a > > {
1103
- self . conn . borrow_mut ( ) . prepare_copy_in ( table, rows, self )
1104
- }
1105
-
1106
1068
/// Begins a new transaction.
1107
1069
///
1108
1070
/// Returns a `Transaction` object which should be used instead of
@@ -1322,11 +1284,6 @@ impl<'conn> Transaction<'conn> {
1322
1284
self . conn . prepare_cached ( query)
1323
1285
}
1324
1286
1325
- /// Like `Connection::prepare_copy_in`.
1326
- pub fn prepare_copy_in ( & self , table : & str , cols : & [ & str ] ) -> Result < CopyInStatement < ' conn > > {
1327
- self . conn . prepare_copy_in ( table, cols)
1328
- }
1329
-
1330
1287
/// Like `Connection::execute`.
1331
1288
pub fn execute ( & self , query : & str , params : & [ & ToSql ] ) -> Result < u64 > {
1332
1289
self . conn . execute ( query, params)
@@ -2030,90 +1987,7 @@ impl<'trans, 'stmt> Iterator for LazyRows<'trans, 'stmt> {
2030
1987
}
2031
1988
}
2032
1989
2033
- /// A prepared `COPY FROM STDIN` statement.
2034
- pub struct CopyInStatement < ' a > {
2035
- conn : & ' a Connection ,
2036
- name : String ,
2037
- column_types : Vec < Type > ,
2038
- finished : bool ,
2039
- }
2040
-
2041
- impl < ' a > fmt:: Debug for CopyInStatement < ' a > {
2042
- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
2043
- DebugStruct :: new ( fmt, "CopyInStatement" )
2044
- . field ( "name" , & self . name )
2045
- . field ( "column_types" , & self . column_types )
2046
- . finish ( )
2047
- }
2048
- }
2049
-
2050
- impl < ' a > Drop for CopyInStatement < ' a > {
2051
- fn drop ( & mut self ) {
2052
- if !self . finished {
2053
- let _ = self . finish_inner ( ) ;
2054
- }
2055
- }
2056
- }
2057
-
2058
- /// An `Iterator` variant which returns borrowed values.
2059
- pub trait StreamIterator {
2060
- /// Returns the next value, or `None` if there is none.
2061
- fn next < ' a > ( & ' a mut self ) -> Option < & ' a ( ToSql + ' a ) > ;
2062
- }
2063
-
2064
- /// An adapter type implementing `StreamIterator` for a `Vec<Box<ToSql>>`.
2065
- pub struct VecStreamIterator < ' a > {
2066
- v : Vec < Box < ToSql + ' a > > ,
2067
- idx : usize ,
2068
- }
2069
-
2070
- impl < ' a > VecStreamIterator < ' a > {
2071
- /// Creates a new `VecStreamIterator`.
2072
- pub fn new ( v : Vec < Box < ToSql + ' a > > ) -> VecStreamIterator < ' a > {
2073
- VecStreamIterator {
2074
- v : v,
2075
- idx : 0 ,
2076
- }
2077
- }
2078
-
2079
- /// Returns the underlying `Vec`.
2080
- pub fn into_inner ( self ) -> Vec < Box < ToSql + ' a > > {
2081
- self . v
2082
- }
2083
- }
2084
-
2085
- impl < ' a > StreamIterator for VecStreamIterator < ' a > {
2086
- fn next < ' b > ( & ' b mut self ) -> Option < & ' b ( ToSql + ' b ) > {
2087
- match self . v . get_mut ( self . idx ) {
2088
- Some ( mut e) => {
2089
- self . idx += 1 ;
2090
- Some ( & mut * * e)
2091
- } ,
2092
- None => None ,
2093
- }
2094
- }
2095
- }
2096
-
2097
- impl < ' a > CopyInStatement < ' a > {
2098
- fn finish_inner ( & mut self ) -> Result < ( ) > {
2099
- let mut conn = self . conn . conn . borrow_mut ( ) ;
2100
- check_desync ! ( conn) ;
2101
- conn. close_statement ( & self . name , b'S' )
2102
- }
2103
-
2104
- /// Returns a slice containing the expected column types.
2105
- pub fn column_types ( & self ) -> & [ Type ] {
2106
- & self . column_types
2107
- }
2108
-
2109
- /// Executes the prepared statement.
2110
- ///
2111
- /// The `rows` argument is an `Iterator` returning `StreamIterator` values,
2112
- /// each one of which provides values for a row of input. This setup is
2113
- /// designed to allow callers to avoid having to maintain the entire row
2114
- /// set in memory.
2115
- ///
2116
- /// Returns the number of rows copied.
1990
+ /*
2117
1991
pub fn execute<I, J>(&self, rows: I) -> Result<u64>
2118
1992
where I: Iterator<Item=J>, J: StreamIterator {
2119
1993
let mut conn = self.conn.conn.borrow_mut();
@@ -2225,17 +2099,7 @@ impl<'a> CopyInStatement<'a> {
2225
2099
try!(conn.wait_for_ready());
2226
2100
Ok(num)
2227
2101
}
2228
-
2229
- /// Consumes the statement, clearing it from the Postgres session.
2230
- ///
2231
- /// Functionally identical to the `Drop` implementation of the
2232
- /// `CopyInStatement` except that it returns any error to the
2233
- /// caller.
2234
- pub fn finish ( mut self ) -> Result < ( ) > {
2235
- self . finished = true ;
2236
- self . finish_inner ( )
2237
- }
2238
- }
2102
+ */
2239
2103
2240
2104
/// A trait allowing abstraction over connections and transactions
2241
2105
pub trait GenericConnection {
@@ -2248,10 +2112,6 @@ pub trait GenericConnection {
2248
2112
/// Like `Connection::execute`.
2249
2113
fn execute ( & self , query : & str , params : & [ & ToSql ] ) -> Result < u64 > ;
2250
2114
2251
- /// Like `Connection::prepare_copy_in`.
2252
- fn prepare_copy_in < ' a > ( & ' a self , table : & str , columns : & [ & str ] )
2253
- -> Result < CopyInStatement < ' a > > ;
2254
-
2255
2115
/// Like `Connection::transaction`.
2256
2116
fn transaction < ' a > ( & ' a self ) -> Result < Transaction < ' a > > ;
2257
2117
@@ -2279,11 +2139,6 @@ impl GenericConnection for Connection {
2279
2139
self . transaction ( )
2280
2140
}
2281
2141
2282
- fn prepare_copy_in < ' a > ( & ' a self , table : & str , columns : & [ & str ] )
2283
- -> Result < CopyInStatement < ' a > > {
2284
- self . prepare_copy_in ( table, columns)
2285
- }
2286
-
2287
2142
fn batch_execute ( & self , query : & str ) -> Result < ( ) > {
2288
2143
self . batch_execute ( query)
2289
2144
}
@@ -2310,11 +2165,6 @@ impl<'a> GenericConnection for Transaction<'a> {
2310
2165
self . transaction ( )
2311
2166
}
2312
2167
2313
- fn prepare_copy_in < ' b > ( & ' b self , table : & str , columns : & [ & str ] )
2314
- -> Result < CopyInStatement < ' b > > {
2315
- self . prepare_copy_in ( table, columns)
2316
- }
2317
-
2318
2168
fn batch_execute ( & self , query : & str ) -> Result < ( ) > {
2319
2169
self . batch_execute ( query)
2320
2170
}
0 commit comments