| 88 | } |
| 89 | |
| 90 | func getStatementWithResultLimit(statement string, limit int) string { |
| 91 | stmt, err := getStatementWithResultLimitInline(statement, limit) |
| 92 | if err != nil { |
| 93 | slog.Error("fail to add limit clause", slog.String("statement", statement), log.BBError(err)) |
| 94 | // MySQL 5.7 doesn't support WITH clause. |
| 95 | return fmt.Sprintf("SELECT * FROM (%s) result LIMIT %d;", util.TrimStatement(statement), limit) |
| 96 | } |
| 97 | return stmt |
| 98 | } |
| 99 | |
| 100 | func getStatementWithResultLimitInline(statement string, limitCount int) (string, error) { |
| 101 | if strings.TrimSpace(statement) == "" { |