Open weiguoz opened 5 years ago
Probably need to refactor runExtendedSQL in sqlflow.
runExtendedSQL
package sqlflowserver func runExtendedSQL(slct string, stream SQLFlow_RunServer) error { logChan := make(chan Log) go sqlflow.runExtendedSQL(slct, db, logChan) for { log, more := <- logChan if !more { break } if log.Err != nil { return log.Err } err := stream.Send(log) if err { close(logChan) return err } } return nil }
package sqlflow struct Log { Log string Err error } func runExtendedSQL(slct string, db *sql.DB, logChan chan Log) { // chan may be closed, need to recover defer func() { if x := recover(); x != nil { log.Printf("run time panic: %v", x) } }() logChan <- Log{"parsing...", nil} ... logChan <- Log{"verifying...", nil} ... logChan <- Log{"executing...", nil} ... close(logChan) }
Probably need to refactor
runExtendedSQL
in sqlflow.