private static boolean limitMySqlQueryBlock(SQLSelectQueryBlock queryBlock, String dbType, int offset, int count, boolean check) { SQLLimit limit = queryBlock.getLimit(); if (limit != null) { if (offset > 0) { limit.setOffset(new SQLIntegerExpr(offset)); } if (check && limit.getRowCount() instanceof SQLNumericLiteralExpr) { int rowCount = ((SQLNumericLiteralExpr) limit.getRowCount()).getNumber().intValue(); if (rowCount <= count && offset <= 0) { return false; } } else if (check && limit.getRowCount() instanceof SQLVariantRefExpr) { return false; } limit.setRowCount(new SQLIntegerExpr(count)); } if (limit == null) { limit = new SQLLimit(); if (offset > 0) { limit.setOffset(new SQLIntegerExpr(offset)); } limit.setRowCount(new SQLIntegerExpr(count)); queryBlock.setLimit(limit); } return true; }
public boolean visit(SQLLimit x) { print0(ucase ? "LIMIT " : "limit "); x.getRowCount().accept(this); if (x.getOffset() != null) { print0(ucase ? " OFFSET " : " offset "); x.getOffset().accept(this); } return false; }
@Override protected void accept0(SQLASTVisitor visitor) { if (visitor.visit(this)) { acceptChild(visitor, offset); acceptChild(visitor, rowCount); } visitor.endVisit(this); }
public void setFirst(SQLExpr first) { if (limit == null) { limit = new SQLLimit(); } this.limit.setRowCount(first); }
public SQLLimit(SQLExpr offset, SQLExpr rowCount) { this.setOffset(offset); this.setRowCount(rowCount); }
public SQLLimit clone() { SQLLimit x = new SQLLimit(); if (offset != null) { x.setOffset(offset.clone()); } if (rowCount != null) { x.setRowCount(rowCount.clone()); } return x; }
SQLExpr offset = limit.getOffset(); SQLExpr first = limit.getRowCount(); limit.accept(this);
public SQLExpr getFirst() { if (limit == null) { return null; } return limit.getRowCount(); }
@Override public boolean visit(MySqlShowErrorsStatement x) { if (x.isCount()) { print0(ucase ? "SHOW COUNT(*) ERRORS" : "show count(*) errors"); } else { print0(ucase ? "SHOW ERRORS" : "show errors"); if (x.getLimit() != null) { print(' '); x.getLimit().accept(this); } } return false; }
public void limit(int rowCount, int offset) { if (offset > 0) { throw new UnsupportedOperationException("not support offset"); } setLimit(new SQLLimit(new SQLIntegerExpr(rowCount))); } }
public SQLLimit(SQLExpr rowCount) { this.setRowCount(rowCount); }
public void setLimit(SQLLimit limit) { if (limit != null) { limit.setParent(this); } this.limit = limit; }
public SQLExpr getOffset() { if (limit == null) { return null; } return limit.getOffset(); }
public void setOffset(int offset) { this.setOffset(new SQLIntegerExpr(offset)); }
public MySqlDeleteStatement clone() { MySqlDeleteStatement x = new MySqlDeleteStatement(); cloneTo(x); x.lowPriority = lowPriority; x.quick = quick; x.ignore = ignore; if (using != null) { x.setUsing(using.clone()); } if (orderBy != null) { x.setOrderBy(orderBy.clone()); } if (limit != null) { x.setLimit(limit.clone()); } return x; }
public void limit(int rowCount, int offset) { SQLLimit limit = new SQLLimit(); limit.setRowCount(new SQLIntegerExpr(rowCount)); if (offset > 0) { limit.setOffset(new SQLIntegerExpr(offset)); } setLimit(limit); }
public void setFirst(SQLExpr first) { if (limit == null) { limit = new SQLLimit(); } this.limit.setRowCount(first); }
SQLExpr offset = limit.getOffset(); SQLExpr first = limit.getRowCount(); limit.accept(this);