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


Java MySqlSelectQueryBlock.getLimit方法代码示例

本文整理汇总了Java中com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.getLimit方法的典型用法代码示例。如果您正苦于以下问题:Java MySqlSelectQueryBlock.getLimit方法的具体用法?Java MySqlSelectQueryBlock.getLimit怎么用?Java MySqlSelectQueryBlock.getLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock的用法示例。


在下文中一共展示了MySqlSelectQueryBlock.getLimit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
		Limit limit=mysqlSelectQuery.getLimit();
		if(limit==null)
		{
			  //使用oracle的解析,否则会有部分oracle语法识别错误
			  OracleStatementParser oracleParser = new OracleStatementParser(getCtx().getSql());
			  SQLSelectStatement oracleStmt = (SQLSelectStatement) oracleParser.parseStatement();
               selectStmt= oracleStmt;
			  SQLSelectQuery oracleSqlSelectQuery = oracleStmt.getSelect().getQuery();
			  if(oracleSqlSelectQuery instanceof OracleSelectQueryBlock)
			  {
				  parseNativePageSql(oracleStmt, rrs, (OracleSelectQueryBlock) oracleSqlSelectQuery, schema);
			  }



		  }
		if(isNeedParseOrderAgg)
		{
			parseOrderAggGroupMysql(schema, selectStmt,rrs, mysqlSelectQuery);
			//更改canRunInReadDB属性
			if ((mysqlSelectQuery.isForUpdate() || mysqlSelectQuery.isLockInShareMode()) && rrs.isAutocommit() == false)
			{
				rrs.setCanRunInReadDB(false);
			}
		}

	}


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

示例2: visit

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
@Override
public boolean visit(MySqlSelectQueryBlock x) {
    SQLOrderBy orderBy = x.getOrderBy();
    SQLLimit limit = x.getLimit();

    if (limit != null && (orderBy == null || orderBy.getItems().size() == 0)) {
        boolean subQueryHasOrderBy = false;
        SQLTableSource from = x.getFrom();
        if (from instanceof SQLSubqueryTableSource) {
            SQLSubqueryTableSource subqueryTabSrc = (SQLSubqueryTableSource) from;
            SQLSelect select = subqueryTabSrc.getSelect();
            if (select.getQuery() instanceof SQLSelectQueryBlock) {
                SQLSelectQueryBlock subquery = (SQLSelectQueryBlock) select.getQuery();
                if (subquery.getOrderBy() != null && subquery.getOrderBy().getItems().size() > 0) {
                    subQueryHasOrderBy = true;
                }
            }
        }

        if (!subQueryHasOrderBy) {
            unorderedLimitCount++;
        }
    }
    return true;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:26,代码来源:PagerUtils.java

示例3: 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

示例4: limitMySqlQueryBlock

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private static boolean limitMySqlQueryBlock(MySqlSelectQueryBlock 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;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:31,代码来源:PagerUtils.java

示例5: tryAddLimit

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private void tryAddLimit(SchemaConfig schema, TableConfig tableConfig,
                         MySqlSelectQueryBlock mysqlSelectQuery) {
    if (schema.getDefaultMaxLimit() == -1) {
        return;
    } else if (mysqlSelectQuery.getLimit() != null) {
        return;
    } else if (!tableConfig.isNeedAddLimit()) {
        return;
    }
    SQLLimit limit = new SQLLimit();
    limit.setRowCount(new SQLIntegerExpr(schema.getDefaultMaxLimit()));
    mysqlSelectQuery.setLimit(limit);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:14,代码来源:DruidSelectParser.java

示例6: 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

示例7: visit

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public boolean visit(MySqlSelectQueryBlock sqlSelectQuery) {
    SQLTableSource from = sqlSelectQuery.getFrom();
    if (from != null) {
        visit(from);
        if (this.tableNode instanceof NoNameNode) {
            this.tableNode.setSql(SQLUtils.toMySqlString(sqlSelectQuery));
        }
    } else {
        this.tableNode = new NoNameNode(currentDb, SQLUtils.toMySqlString(sqlSelectQuery));
    }

    if (tableNode != null && (sqlSelectQuery.getDistionOption() == SQLSetQuantifier.DISTINCT || sqlSelectQuery.getDistionOption() == SQLSetQuantifier.DISTINCTROW)) {
        this.tableNode.setDistinct(true);
    }

    List<SQLSelectItem> items = sqlSelectQuery.getSelectList();
    if (items != null) {
        List<Item> selectItems = handleSelectItems(items);
        if (selectItems != null) {
            this.tableNode.select(selectItems);
        }
    }

    SQLExpr whereExpr = sqlSelectQuery.getWhere();
    if (whereExpr != null) {
        handleWhereCondition(whereExpr);
    }

    SQLOrderBy orderBy = sqlSelectQuery.getOrderBy();
    if (orderBy != null) {
        handleOrderBy(orderBy);
    }

    SQLSelectGroupByClause groupBy = sqlSelectQuery.getGroupBy();
    if (groupBy != null) {
        handleGroupBy(groupBy);
    }

    SQLLimit limit = sqlSelectQuery.getLimit();
    if (limit != null) {
        handleLimit(limit);
    }
    return true;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:45,代码来源:MySQLPlanNodeVisitor.java


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