MCPcopy Create free account
hub / github.com/bytebase/bytebase / skipAddLimit

Function skipAddLimit

backend/plugin/db/oracle/query.go:348–375  ·  view source on GitHub ↗

========== Skip Limit Logic for DUAL Queries ========== skipAddLimit checks if the statement needs a limit clause. For Oracle, we think the statement like "SELECT xxx FROM DUAL" does not need a limit clause. More details, xxx can not be a subquery.

(stmt string)

Source from the content-addressed store, hash-verified

346// For Oracle, we think the statement like "SELECT xxx FROM DUAL" does not need a limit clause.
347// More details, xxx can not be a subquery.
348func skipAddLimit(stmt string) (bool, error) {
349 list, err := plsqlparser.ParsePLSQLOmni(stmt)
350 if err != nil {
351 return false, err
352 }
353 if list == nil || len(list.Items) == 0 {
354 return false, nil
355 }
356 // Multiple statements should not skip limit
357 if len(list.Items) > 1 {
358 return false, nil
359 }
360 raw, ok := list.Items[0].(*oracleast.RawStmt)
361 if !ok {
362 return false, nil
363 }
364 selectStmt, ok := raw.Stmt.(*oracleast.SelectStmt)
365 if !ok {
366 return false, nil
367 }
368 if !isSimpleOracleSelect(selectStmt) {
369 return false, nil
370 }
371 if !isOracleSelectFromDual(selectStmt) {
372 return false, nil
373 }
374 return !hasOracleSubqueriesInSelection(selectStmt), nil
375}
376
377func isSimpleOracleSelect(selectStmt *oracleast.SelectStmt) bool {
378 return selectStmt.WithClause == nil &&

Callers 1

shouldSkipLimitFunction · 0.85

Calls 3

isSimpleOracleSelectFunction · 0.85
isOracleSelectFromDualFunction · 0.85

Tested by

no test coverage detected