// Do the real work to evaluate subquery. func (e *Evaluator) subqueryExec(v ast.SubqueryExec) bool { rowCount := 2 if e.multipleRows { rowCount = -1 } else if e.existRow { rowCount = 1 } rows, err := v.EvalRows(e.ctx, rowCount) if err != nil { e.err = errors.Trace(err) return false } if e.multipleRows || e.existRow { v.SetValue(rows) return true } switch len(rows) { case 0: v.SetValue(nil) case 1: v.SetValue(rows[0]) default: e.err = errors.New("Subquery returns more than 1 row") return false } return true }
// Do the real work to evaluate subquery. func (e *Evaluator) subqueryExec(v ast.SubqueryExec) bool { rowCount := 2 if e.multipleRows { rowCount = -1 } else if e.existRow { rowCount = 1 } rows, err := v.EvalRows(e.ctx, rowCount) if err != nil { e.err = errors.Trace(err) return false } if e.multipleRows || e.existRow { v.GetDatum().SetInterface(types.MakeDatums(rows...)) return true } switch len(rows) { case 0: v.GetDatum().SetNull() case 1: v.SetDatum(types.NewDatum(rows[0])) default: e.err = errors.New("Subquery returns more than 1 row") return false } return true }