(sql string, selectStmt *oracleast.SelectStmt, limitCount int)
| 253 | } |
| 254 | |
| 255 | func rewriteOracleSelectFetch(sql string, selectStmt *oracleast.SelectStmt, limitCount int) (string, error) { |
| 256 | target := rightmostOracleSetSelect(selectStmt) |
| 257 | if target.FetchFirst != nil { |
| 258 | return rewriteOracleFetchClause(sql, target.FetchFirst, limitCount) |
| 259 | } |
| 260 | if target.ForUpdate != nil && target.ForUpdate.Loc.Start > 0 && target.ForUpdate.Loc.Start <= len(sql) { |
| 261 | return sql[:target.ForUpdate.Loc.Start] + fmt.Sprintf("FETCH NEXT %d ROWS ONLY ", limitCount) + sql[target.ForUpdate.Loc.Start:], nil |
| 262 | } |
| 263 | |
| 264 | loc := oracleast.NodeLoc(target) |
| 265 | if loc.End < 0 || loc.End > len(sql) { |
| 266 | return "", errors.Errorf("invalid SELECT end position %d", loc.End) |
| 267 | } |
| 268 | return sql[:loc.End] + fmt.Sprintf(" FETCH NEXT %d ROWS ONLY", limitCount) + sql[loc.End:], nil |
| 269 | } |
| 270 | |
| 271 | func rightmostOracleSetSelect(selectStmt *oracleast.SelectStmt) *oracleast.SelectStmt { |
| 272 | if selectStmt.Op != oracleast.SETOP_NONE && selectStmt.Rarg != nil { |
no test coverage detected