async fn handle_query<'a, W: io::Write + Send>(
        &'a mut self,
        query: &'a str,
        results: QueryResultWriter<'a, W>,
    ) -> Result<(), io::Error> {
        match self.execute_query(query).await {
            Err(e) => {
                error!("Error during processing {}: {}", query, e.to_string());
                results.error(ErrorKind::ER_INTERNAL_ERROR, e.message.as_bytes())?;

                Ok(())
            }
            Ok(QueryResponse::Ok(status)) => {
                results.completed(0, 0, status)?;
                Ok(())
            }
            Ok(QueryResponse::ResultSet(_, data_frame)) => {
                let columns = data_frame
                    .get_columns()
                    .iter()
                    .map(|c| Column {
                        table: "result".to_string(), // TODO
                        column: c.get_name(),
                        coltype: c.get_type(),
                        colflags: c.get_flags(),
                    })
                    .collect::<Vec<_>>();

                let mut rw = results.start(&columns)?;

                for row in data_frame.get_rows().iter() {
                    for (_i, value) in row.values().iter().enumerate() {
                        match value {
                            dataframe::TableValue::String(s) => rw.write_col(s)?,
                            dataframe::TableValue::Timestamp(s) => rw.write_col(s.to_string())?,
                            dataframe::TableValue::Boolean(s) => rw.write_col(s.to_string())?,
                            dataframe::TableValue::Float64(s) => rw.write_col(s)?,
                            dataframe::TableValue::Int64(s) => rw.write_col(s)?,
                            dataframe::TableValue::Null => rw.write_col(Option::<String>::None)?,
                        }
                    }

                    rw.end_row()?;
                }

                rw.finish()?;

                Ok(())
            }
        }
    }
// This method write response back to client after execution
This method write response back to client after execution
This method write response back to client after execution
async fn handle_query<'a, W: io::Write + Send>(
        &'a mut self,
        query: &'a str,
        results: QueryResultWriter<'a, W>,
    ) -> Result<(), io::Error> {
        match self.execute_query(query).await {
            Err(e) => {
                error!("Error during processing {}: {}", query, e.to_string());
                results.error(ErrorKind::ER_INTERNAL_ERROR, e.message.as_bytes())?;
                Ok(())
            }
            Ok(QueryResponse::Ok(status)) => {
                results.completed(0, 0, status)?;
                Ok(())
            }
            Ok(QueryResponse::ResultSet(_, data_frame)) => {
                let columns = data_frame
                    .get_columns()
                    .iter()
                    .map(|c| Column {
                        table: "result".to_string(), // TODO
                        column: c.get_name(),
                        coltype: c.get_type(),
                        colflags: c.get_flags(),
                    })
                    .collect::<Vec<_>>();
                let mut rw = results.start(&columns)?;
                for row in data_frame.get_rows().iter() {
                    for (_i, value) in row.values().iter().enumerate() {
                        match value {
                            dataframe::TableValue::String(s) => rw.write_col(s)?,
                            dataframe::TableValue::Timestamp(s) => rw.write_col(s.to_string())?,
                            dataframe::TableValue::Boolean(s) => rw.write_col(s.to_string())?,
                            dataframe::TableValue::Float64(s) => rw.write_col(s)?,
                            dataframe::TableValue::Int64(s) => rw.write_col(s)?,
                            dataframe::TableValue::Null => rw.write_col(Option::<String>::None)?,
                        }
                    }
                    rw.end_row()?;
                }
                rw.finish()?;
                Ok(())
            }
        }
    }
async fn handle_query < ' a , W : io :: Write + Send > ( & ' a mut self , query : & ' a str , results : QueryResultWriter < ' a , W > , ) -> Result < ( ) , io :: Error > { match self . execute_query ( query ) . await { Err ( e ) => { error ! ( " " query e to_string ( ) ) ; results . error ( ErrorKind :: ER_INTERNAL_ERROR , e . message . as_bytes ( ) ) ? ; Ok ( ( ) ) } Ok ( QueryResponse :: Ok ( status ) ) => { results . completed ( 0 , 0 , status ) ? ; Ok ( ( ) ) } Ok ( QueryResponse :: ResultSet ( _ , data_frame ) ) => { let columns = data_frame . get_columns ( ) . iter ( ) . map ( | c | Column { table : " " . to_string ( ) , // TODO column : c . get_name ( ) , coltype : c . get_type ( ) , colflags : c . get_flags ( ) , } ) . collect :: < Vec < _ > > ( ) ; let mut rw = results . start ( & columns ) ? ; for row in data_frame . get_rows ( ) . iter ( ) { for ( _i , value ) in row . values ( ) . iter ( ) . enumerate ( ) { match value { dataframe :: TableValue :: String ( s ) => rw . write_col ( s ) ? , dataframe :: TableValue :: Timestamp ( s ) => rw . write_col ( s . to_string ( ) ) ? , dataframe :: TableValue :: Boolean ( s ) => rw . write_col ( s . to_string ( ) ) ? , dataframe :: TableValue :: Float64 ( s ) => rw . write_col ( s ) ? , dataframe :: TableValue :: Int64 ( s ) => rw . write_col ( s ) ? , dataframe :: TableValue :: Null => rw . write_col ( Option :: < String > :: None ) ? , } } rw . end_row ( ) ? ; } rw . finish ( ) ? ; Ok ( ( ) ) } } }
This method write response back to client after execution
This method write response back to client after execution
&'a mut self
query
&'a str
results
QueryResultWriter<'a, W>
&'a mut self
query
&'a str
results
QueryResultWriter<'a, W>