(sql string, locEnd int)
| 134 | } |
| 135 | |
| 136 | func hasUnparsedTail(sql string, locEnd int) bool { |
| 137 | pos := locEnd |
| 138 | for pos < len(sql) { |
| 139 | for pos < len(sql) && (sql[pos] == ' ' || sql[pos] == '\t' || sql[pos] == '\n' || sql[pos] == '\r') { |
| 140 | pos++ |
| 141 | } |
| 142 | for pos < len(sql) && sql[pos] == ';' { |
| 143 | pos++ |
| 144 | } |
| 145 | for pos < len(sql) && (sql[pos] == ' ' || sql[pos] == '\t' || sql[pos] == '\n' || sql[pos] == '\r') { |
| 146 | pos++ |
| 147 | } |
| 148 | if pos >= len(sql) { |
| 149 | return false |
| 150 | } |
| 151 | if strings.HasPrefix(sql[pos:], "--") || strings.HasPrefix(sql[pos:], "#") { |
| 152 | nl := strings.IndexByte(sql[pos:], '\n') |
| 153 | if nl < 0 { |
| 154 | return false |
| 155 | } |
| 156 | pos += nl + 1 |
| 157 | continue |
| 158 | } |
| 159 | if strings.HasPrefix(sql[pos:], "/*") { |
| 160 | end := strings.Index(sql[pos:], "*/") |
| 161 | if end < 0 { |
| 162 | return false |
| 163 | } |
| 164 | pos += end + 2 |
| 165 | continue |
| 166 | } |
| 167 | return true |
| 168 | } |
| 169 | return false |
| 170 | } |
| 171 | |
| 172 | func rewriteSelectLimit(sql string, stmt *ast.SelectStmt, limitCount int) (string, error) { |
| 173 | if stmt.Limit != nil { |
no outgoing calls
no test coverage detected