@@ -413,7 +413,7 @@ impl WsResultSet {
413
413
}
414
414
415
415
fn stop_query ( & mut self ) {
416
- futures :: executor :: block_on ( self . rs . stop ( ) ) ;
416
+ taos_query :: block_in_place_or_global ( self . rs . stop ( ) ) ;
417
417
}
418
418
}
419
419
@@ -1089,4 +1089,49 @@ mod tests {
1089
1089
}
1090
1090
}
1091
1091
}
1092
+
1093
+ #[ test]
1094
+ fn test_stop_query ( ) {
1095
+ init_env ( ) ;
1096
+ unsafe {
1097
+ let taos = ws_connect_with_dsn ( b"http://localhost:6041\0 " as * const u8 as _ ) ;
1098
+ if taos. is_null ( ) {
1099
+ let code = ws_errno ( taos) ;
1100
+ assert ! ( code != 0 ) ;
1101
+ let str = ws_errstr ( taos) ;
1102
+ dbg ! ( CStr :: from_ptr( str ) ) ;
1103
+ }
1104
+ assert ! ( !taos. is_null( ) ) ;
1105
+
1106
+ macro_rules! execute {
1107
+ ( $sql: expr) => {
1108
+ let sql = $sql as * const u8 as _;
1109
+ let rs = ws_query( taos, sql) ;
1110
+ let code = ws_errno( rs) ;
1111
+ assert!( code == 0 , "{:?}" , CStr :: from_ptr( ws_errstr( rs) ) ) ;
1112
+ ws_free_result( rs) ;
1113
+ } ;
1114
+ }
1115
+
1116
+ execute ! ( b"drop database if exists ws_stop_query\0 " ) ;
1117
+ execute ! ( b"create database ws_stop_query keep 36500\0 " ) ;
1118
+ execute ! ( b"create table ws_stop_query.s1 (ts timestamp, v int, b binary(100))\0 " ) ;
1119
+
1120
+ let version = ws_get_server_info ( taos) ;
1121
+ dbg ! ( CStr :: from_ptr( version as _) ) ;
1122
+
1123
+ let res = ws_query ( taos, b"select count(*) from ws_stop_query.s1\0 " as * const u8 as _ ) ;
1124
+ let cols = ws_field_count ( res) ;
1125
+ dbg ! ( cols) ;
1126
+ let fields = ws_fetch_fields ( res) ;
1127
+
1128
+ for field in std:: slice:: from_raw_parts ( fields, cols as usize ) {
1129
+ dbg ! ( field) ;
1130
+ }
1131
+
1132
+ ws_stop_query ( res) ;
1133
+
1134
+ execute ! ( b"drop database if exists ws_stop_query\0 " ) ;
1135
+ }
1136
+ }
1092
1137
}
0 commit comments