| 91 | type scan func() (string, int, error) |
| 92 | |
| 93 | func newDefaultScan(statement string) scan { |
| 94 | // Split the statement into lines to support some client commands like GO. |
| 95 | s := strings.Split(statement, string(lineEnd)) |
| 96 | byteOffset := 0 |
| 97 | scanner := func() (string, int, error) { |
| 98 | if len(s) > 0 { |
| 99 | z := s[0] |
| 100 | s = s[1:] |
| 101 | byteOffsetSnapshot := byteOffset |
| 102 | byteOffset += len(z) |
| 103 | if len(s) > 0 { |
| 104 | byteOffset += len(lineEnd) |
| 105 | } |
| 106 | return z, byteOffsetSnapshot, nil |
| 107 | } |
| 108 | return "", byteOffset, io.EOF |
| 109 | } |
| 110 | return scanner |
| 111 | } |
| 112 | |
| 113 | type Batcher struct { |
| 114 | // read provides the next chunk of runes. |