| 117 | } |
| 118 | |
| 119 | func (p *Parser) scanOneStmt() (sql string, tokens []sqlSymType, done bool) { |
| 120 | var lval sqlSymType |
| 121 | tokens = p.tokBuf[:0] |
| 122 | |
| 123 | // Scan the first token. |
| 124 | for { |
| 125 | p.scanner.scan(&lval) |
| 126 | if lval.id == 0 { |
| 127 | return "", nil, true |
| 128 | } |
| 129 | if lval.id != ';' { |
| 130 | break |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | startPos := lval.pos |
| 135 | // We make the resulting token positions match the returned string. |
| 136 | lval.pos = 0 |
| 137 | tokens = append(tokens, lval) |
| 138 | for { |
| 139 | if lval.id == ERROR { |
| 140 | return p.scanner.in[startPos:], tokens, true |
| 141 | } |
| 142 | posBeforeScan := p.scanner.pos |
| 143 | p.scanner.scan(&lval) |
| 144 | if lval.id == 0 || lval.id == ';' { |
| 145 | return p.scanner.in[startPos:posBeforeScan], tokens, (lval.id == 0) |
| 146 | } |
| 147 | lval.pos -= startPos |
| 148 | tokens = append(tokens, lval) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | func (p *Parser) parseWithDepth(depth int, sql string, nakedIntType *types.T) (Statements, error) { |
| 153 | stmts := Statements(p.stmtBuf[:0]) |