当前位置: 首页>>代码示例>>Java>>正文


Java MySqlSelectQueryBlock.Limit方法代码示例

本文整理汇总了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;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:24,代码来源:ElasticSqlExprParser.java

示例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);
			}
		}

	}


}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:29,代码来源:DruidSelectSqlServerParser.java

示例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()));
    }
 
开发者ID:mazhou,项目名称:es-sql,代码行数:12,代码来源:SqlParser.java

示例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);
}
 
开发者ID:tongbanjie,项目名称:baymax,代码行数:32,代码来源:MySqlSelectParser.java

示例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;
}
 
开发者ID:dianping,项目名称:zebra,代码行数:33,代码来源:DefaultSQLRewrite.java

示例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;
  }
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:36,代码来源:MySQLSelectVisitor.java

示例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()));
	}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:12,代码来源:SqlParser.java

示例8: parseLimit

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public MySqlSelectQueryBlock.Limit parseLimit() {
    return ((ElasticSqlExprParser) this.exprParser).parseLimit();
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:4,代码来源:ElasticSqlSelectParser.java

示例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);
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:7,代码来源:SqlParser.java

示例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);
     }
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:7,代码来源:SqlParser.java


注:本文中的com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。