| 18 | const stmtErrFmt = "statement: %s" |
| 19 | |
| 20 | func getStatementWithResultLimit(statement string, limit int) string { |
| 21 | stmt, err := getStatementWithResultLimitInline(statement, limit) |
| 22 | if err != nil { |
| 23 | slog.Error("fail to add limit clause", slog.String("statement", statement), log.BBError(err)) |
| 24 | return fmt.Sprintf("SELECT * FROM (%s) LIMIT %d", util.TrimStatement(statement), limit) |
| 25 | } |
| 26 | return stmt |
| 27 | } |
| 28 | |
| 29 | // getStatementWithResultLimitInline rewrites the single statement so that its |
| 30 | // outermost query returns at most limitCount rows. The rewrite splices the |