looksMultiStatement returns true if body appears to contain more than one SQL statement. Not a full parser — handles the common shapes (line comments, block comments, single-quoted strings) and catches the case the no-transaction directive is most likely to trip on: a user writing `SET something; CR
(body string)
| 278 | // those would need a real parser. The directive isn't intended for |
| 279 | // those cases anyway — it's for single CONCURRENTLY-class statements. |
| 280 | func looksMultiStatement(body string) bool { |
| 281 | stripped := stripSQLCommentsAndStrings(body) |
| 282 | // A single statement (with optional trailing whitespace + semicolon) |
| 283 | // has zero ';' after we trim. A multi-statement script has 1+. |
| 284 | stripped = strings.TrimRight(stripped, "; \t\n\r") |
| 285 | return strings.Contains(stripped, ";") |
| 286 | } |
| 287 | |
| 288 | // stripSQLCommentsAndStrings removes -- line comments, /* */ block |
| 289 | // comments, and '...' single-quoted strings from the body. Used by |
no test coverage detected