@@ -64,7 +64,7 @@ impl Client {
64
64
. handshake ( & config. username , & config. password )
65
65
. await
66
66
. inspect_err ( |e| {
67
- println ! ( "Failed to do handshake: {}" , filter_message( & e. to_string( ) ) ) ;
67
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
68
68
exit ( 1 )
69
69
} ) ;
70
70
@@ -83,10 +83,7 @@ impl Client {
83
83
. execute ( sql. to_string ( ) , None )
84
84
. await
85
85
. inspect_err ( |e| {
86
- println ! (
87
- "Failed to execute a sql: {}" ,
88
- filter_message( & e. to_string( ) )
89
- ) ;
86
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
90
87
exit ( 1 )
91
88
} ) ?;
92
89
let ticket = flight_info
@@ -100,16 +97,25 @@ impl Client {
100
97
Ok ( batches)
101
98
}
102
99
100
+ pub async fn execute_update ( & mut self , sql : & str ) -> Result < i64 > {
101
+ let affected_rows = self
102
+ . inner
103
+ . execute_update ( sql. to_string ( ) , None )
104
+ . await
105
+ . inspect_err ( |e| {
106
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
107
+ exit ( 1 )
108
+ } ) ?;
109
+ Ok ( affected_rows)
110
+ }
111
+
103
112
pub async fn prepare ( & mut self , sql : & str ) -> Result < PreparedStatement < Channel > > {
104
113
let prepared_stmt = self
105
114
. inner
106
115
. prepare ( sql. to_string ( ) , None )
107
116
. await
108
117
. inspect_err ( |e| {
109
- println ! (
110
- "Failed to execute a sql: {}" ,
111
- filter_message( & e. to_string( ) )
112
- ) ;
118
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
113
119
exit ( 1 )
114
120
} ) ?;
115
121
Ok ( prepared_stmt)
@@ -124,10 +130,7 @@ impl Client {
124
130
. set_parameters ( binding)
125
131
. context ( "Failed to bind a record batch to the prepared statement" ) ?;
126
132
let flight_info = prepared_stmt. execute ( ) . await . inspect_err ( |e| {
127
- println ! (
128
- "Failed to execute the prepared statement: {}" ,
129
- filter_message( & e. to_string( ) )
130
- ) ;
133
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
131
134
exit ( 1 )
132
135
} ) ?;
133
136
let ticket = flight_info
@@ -141,19 +144,20 @@ impl Client {
141
144
Ok ( batches)
142
145
}
143
146
147
+ pub async fn close_prepared ( & self , prepared_stmt : PreparedStatement < Channel > ) -> Result < ( ) > {
148
+ prepared_stmt
149
+ . close ( )
150
+ . await
151
+ . context ( "Failed to close a prepared statement" )
152
+ }
153
+
144
154
async fn do_get ( & mut self , ticket : Ticket ) -> Result < Vec < RecordBatch > > {
145
155
let stream = self . inner . do_get ( ticket) . await . inspect_err ( |e| {
146
- println ! (
147
- "Failed to perform do_get: {}" ,
148
- filter_message( & e. to_string( ) )
149
- ) ;
156
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
150
157
exit ( 1 )
151
158
} ) ?;
152
159
let batches = stream. try_collect :: < Vec < _ > > ( ) . await . inspect_err ( |e| {
153
- println ! (
154
- "Failed to consume flight record batch stream: {}" ,
155
- filter_message( & e. to_string( ) )
156
- ) ;
160
+ println ! ( "{}" , filter_message( & e. to_string( ) ) ) ;
157
161
exit ( 1 )
158
162
} ) ?;
159
163
if batches. is_empty ( ) {
0 commit comments