1+ use fallible_iterator:: FallibleIterator ;
12use std:: io:: Read ;
23use tokio_postgres:: types:: Type ;
34use tokio_postgres:: NoTls ;
@@ -47,7 +48,9 @@ fn transaction_commit() {
4748 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
4849
4950 client
50- . batch_execute ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
51+ . simple_query ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
52+ . unwrap ( )
53+ . count ( )
5154 . unwrap ( ) ;
5255
5356 let mut transaction = client. transaction ( ) . unwrap ( ) ;
@@ -72,7 +75,9 @@ fn transaction_rollback() {
7275 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
7376
7477 client
75- . batch_execute ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
78+ . simple_query ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
79+ . unwrap ( )
80+ . count ( )
7681 . unwrap ( ) ;
7782
7883 let mut transaction = client. transaction ( ) . unwrap ( ) ;
@@ -96,7 +101,9 @@ fn transaction_drop() {
96101 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
97102
98103 client
99- . batch_execute ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
104+ . simple_query ( "CREATE TEMPORARY TABLE foo (id SERIAL PRIMARY KEY)" )
105+ . unwrap ( )
106+ . count ( )
100107 . unwrap ( ) ;
101108
102109 let mut transaction = client. transaction ( ) . unwrap ( ) ;
@@ -120,7 +127,9 @@ fn nested_transactions() {
120127 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
121128
122129 client
123- . batch_execute ( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" )
130+ . simple_query ( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" )
131+ . unwrap ( )
132+ . count ( )
124133 . unwrap ( ) ;
125134
126135 let mut transaction = client. transaction ( ) . unwrap ( ) ;
@@ -177,7 +186,9 @@ fn copy_in() {
177186 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
178187
179188 client
180- . batch_execute ( "CREATE TEMPORARY TABLE foo (id INT, name TEXT)" )
189+ . simple_query ( "CREATE TEMPORARY TABLE foo (id INT, name TEXT)" )
190+ . unwrap ( )
191+ . count ( )
181192 . unwrap ( ) ;
182193
183194 client
@@ -206,13 +217,12 @@ fn copy_out() {
206217 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
207218
208219 client
209- . batch_execute (
210- "
211- CREATE TEMPORARY TABLE foo (id INT, name TEXT);
212-
213- INSERT INTO foo (id, name) VALUES (1, 'steven'), (2, 'timothy');
214- " ,
220+ . simple_query (
221+ "CREATE TEMPORARY TABLE foo (id INT, name TEXT);
222+ INSERT INTO foo (id, name) VALUES (1, 'steven'), (2, 'timothy');" ,
215223 )
224+ . unwrap ( )
225+ . count ( )
216226 . unwrap ( ) ;
217227
218228 let mut reader = client
@@ -224,21 +234,20 @@ fn copy_out() {
224234
225235 assert_eq ! ( s, "1\t steven\n 2\t timothy\n " ) ;
226236
227- client. batch_execute ( "SELECT 1" ) . unwrap ( ) ;
237+ client. simple_query ( "SELECT 1" ) . unwrap ( ) . count ( ) . unwrap ( ) ;
228238}
229239
230240#[ test]
231241fn portal ( ) {
232242 let mut client = Client :: connect ( "host=localhost port=5433 user=postgres" , NoTls ) . unwrap ( ) ;
233243
234244 client
235- . batch_execute (
236- "
237- CREATE TEMPORARY TABLE foo (id INT);
238-
239- INSERT INTO foo (id) VALUES (1), (2), (3);
240- " ,
245+ . simple_query (
246+ "CREATE TEMPORARY TABLE foo (id INT);
247+ INSERT INTO foo (id) VALUES (1), (2), (3);" ,
241248 )
249+ . unwrap ( )
250+ . count ( )
242251 . unwrap ( ) ;
243252
244253 let mut transaction = client. transaction ( ) . unwrap ( ) ;
0 commit comments