本文整理汇总了Java中com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit方法的典型用法代码示例。如果您正苦于以下问题:Java MySqlSelectQueryBlock.Limit方法的具体用法?Java MySqlSelectQueryBlock.Limit怎么用?Java MySqlSelectQueryBlock.Limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock
的用法示例。
在下文中一共展示了MySqlSelectQueryBlock.Limit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public MySqlSelectQueryBlock.Limit parseLimit() {
if (lexer.token() == Token.LIMIT) {
lexer.nextToken();
MySqlSelectQueryBlock.Limit limit = new MySqlSelectQueryBlock.Limit();
SQLExpr temp = this.expr();
if (lexer.token() == (Token.COMMA)) {
limit.setOffset(temp);
lexer.nextToken();
limit.setRowCount(this.expr());
} else if (identifierEquals("OFFSET")) {
limit.setRowCount(temp);
lexer.nextToken();
limit.setOffset(this.expr());
} else {
limit.setRowCount(temp);
}
return limit;
}
return null;
}
示例2: statementParse
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
@Override
public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) {
SQLSelectStatement selectStmt = (SQLSelectStatement)stmt;
SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
//从mysql解析过来
if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
MySqlSelectQueryBlock.Limit limit=mysqlSelectQuery.getLimit();
if(limit==null)
{
sqlserverParse(schema, rrs);
}
if(isNeedParseOrderAgg)
{
parseOrderAggGroupMysql(schema, stmt,rrs, mysqlSelectQuery);
//更改canRunInReadDB属性
if ((mysqlSelectQuery.isForUpdate() || mysqlSelectQuery.isLockInShareMode()) && rrs.isAutocommit() == false)
{
rrs.setCanRunInReadDB(false);
}
}
}
}
示例3: findLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private void findLimit(MySqlSelectQueryBlock.Limit limit, Select select) {
if (limit == null) {
return;
}
select.setRowCount(Integer.parseInt(limit.getRowCount().toString()));
if (limit.getOffset() != null)
select.setOffset(Integer.parseInt(limit.getOffset().toString()));
}
示例4: parseLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
protected void parseLimit(ParseResult result, ExecutePlan plan, MySqlSelectQueryBlock mysqlSelectQuery){
MySqlSelectQueryBlock.Limit x = mysqlSelectQuery.getLimit();
if (x == null){
return;
}
Map<Integer, Object> overrideParameters = new HashMap<Integer, Object>(2);
int offset = 0;
if (null != x.getOffset()) {
if (x.getOffset() instanceof SQLNumericLiteralExpr) {
offset = ((SQLNumericLiteralExpr) x.getOffset()).getNumber().intValue();
SQLNumberExpr offsetExpr = new SQLNumberExpr();
offsetExpr.setNumber(0);
x.setOffset(offsetExpr);
} else {
offset = ((Number) parameters.get(((SQLVariantRefExpr) x.getOffset()).getIndex())).intValue();
overrideParameters.put(((SQLVariantRefExpr) x.getOffset()).getIndex() + 1, 0);
}
}
int rowCount;
if (x.getRowCount() instanceof SQLNumericLiteralExpr) {
rowCount = ((SQLNumericLiteralExpr) x.getRowCount()).getNumber().intValue();
SQLNumberExpr rowsExpr = new SQLNumberExpr();
rowsExpr.setNumber(rowCount + offset);
x.setRowCount(rowsExpr);
} else {
rowCount = ((Number) parameters.get(((SQLVariantRefExpr) x.getRowCount()).getIndex())).intValue();
overrideParameters.put(((SQLVariantRefExpr) x.getRowCount()).getIndex() + 1, rowCount + offset);
}
plan.setLimit(new Limit(offset, rowCount));
plan.setOverrideParameters(overrideParameters);
}
示例5: visit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
@Override
public boolean visit(MySqlSelectQueryBlock.Limit x) {
print0(ucase ? "LIMIT " : "limit ");
int offset = Integer.MIN_VALUE;
if (x.getOffset() != null) {
if (x.getOffset() instanceof SQLIntegerExpr) {
SQLIntegerExpr offsetExpr = (SQLIntegerExpr) x.getOffset();
offset = (Integer) offsetExpr.getValue();
offsetExpr.setNumber(0);
offsetExpr.accept(this);
} else {
x.getOffset().accept(this);
}
print0(", ");
}
int limit = Integer.MAX_VALUE;
if (x.getRowCount() instanceof SQLIntegerExpr) {
SQLIntegerExpr rowCountExpr = (SQLIntegerExpr) x.getRowCount();
if (offset != Integer.MIN_VALUE) {
limit = (Integer) rowCountExpr.getValue();
rowCountExpr.setNumber(offset + limit);
}
rowCountExpr.accept(this);
} else {
x.getRowCount().accept(this);
}
return false;
}
示例6: visit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
@Override
public boolean visit(MySqlSelectQueryBlock.Limit x) {
//如果嵌套子查询或第一个SQL解析完毕
if(!isEnableCollectMetadata()){
return super.visit(x);
}
print("LIMIT ");
//第一次解析
int offset = 0;
if (null != x.getOffset()) {
if (x.getOffset() instanceof SQLNumericLiteralExpr) {
offset = ((SQLNumericLiteralExpr) x.getOffset()).getNumber().intValue();
print("0, ");
} else {
offset = ((Number) getParameters().get(((SQLVariantRefExpr) x.getOffset()).getIndex())).intValue();
getParameters().set(((SQLVariantRefExpr) x.getOffset()).getIndex(), 0);
print("?, ");
}
}
int rowCount;
if (x.getRowCount() instanceof SQLNumericLiteralExpr) {
rowCount = ((SQLNumericLiteralExpr) x.getRowCount()).getNumber().intValue();
print(rowCount + offset);
} else {
rowCount = ((Number) getParameters().get(((SQLVariantRefExpr) x.getRowCount()).getIndex())).intValue();
getParameters().set(((SQLVariantRefExpr) x.getRowCount()).getIndex(), rowCount + offset);
print("?");
}
parseResult.setLimit(new Limit(offset, rowCount));
if(logger.isInfoEnabled()){
logger.info("Limit [offset: "+offset+",rowCount: "+rowCount+"]");
}
return false;
}
示例7: findLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private void findLimit(MySqlSelectQueryBlock.Limit limit, Select select) {
if (limit == null) {
return;
}
select.setRowCount(Integer.parseInt(limit.getRowCount().toString()));
if (limit.getOffset() != null)
select.setOffset(Integer.parseInt(limit.getOffset().toString()));
}
示例8: parseLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public MySqlSelectQueryBlock.Limit parseLimit() {
return ((ElasticSqlExprParser) this.exprParser).parseLimit();
}
示例9: updateJoinLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private void updateJoinLimit(MySqlSelectQueryBlock.Limit limit, JoinSelect joinSelect) {
if (limit != null && limit.getRowCount() != null) {
int sizeLimit = Integer.parseInt(limit.getRowCount().toString());
joinSelect.setTotalLimit(sizeLimit);
}
}
示例10: updateJoinLimit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private void updateJoinLimit(MySqlSelectQueryBlock.Limit limit, JoinSelect joinSelect) {
if(limit != null && limit.getRowCount()!= null) {
int sizeLimit = Integer.parseInt(limit.getRowCount().toString());
joinSelect.setTotalLimit(sizeLimit);
}
}