• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MySqlSelectQueryBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MySqlSelectQueryBlock类属于com.alibaba.druid.sql.dialect.mysql.ast.statement包,在下文中一共展示了MySqlSelectQueryBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
		if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
			MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();

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

		} else if (sqlSelectQuery instanceof MySqlUnionQuery) { 
//			MySqlUnionQuery unionQuery = (MySqlUnionQuery)sqlSelectQuery;
//			MySqlSelectQueryBlock left = (MySqlSelectQueryBlock)unionQuery.getLeft();
//			MySqlSelectQueryBlock right = (MySqlSelectQueryBlock)unionQuery.getLeft();
//			System.out.println();
		}
	}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:22,代码来源:DruidSelectParser.java


示例2: parseOrderAggGroupMysql

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
protected void parseOrderAggGroupMysql(SchemaConfig schema, SQLStatement stmt, RouteResultset rrs, MySqlSelectQueryBlock mysqlSelectQuery)
	{
		MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
		stmt.accept(visitor);
//		rrs.setGroupByCols((String[])visitor.getGroupByColumns().toArray());
		if(!isNeedParseOrderAgg)
        {
            return;
        }
		Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt, rrs, mysqlSelectQuery);

		//setOrderByCols
		if(mysqlSelectQuery.getOrderBy() != null) {
			List<SQLSelectOrderByItem> orderByItems = mysqlSelectQuery.getOrderBy().getItems();
			rrs.setOrderByCols(buildOrderByCols(orderByItems,aliaColumns));
		}
        isNeedParseOrderAgg=false;
	}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:19,代码来源:DruidSelectParser.java


示例3: isNeedCache

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private boolean isNeedCache(SchemaConfig schema, RouteResultset rrs, 
			MySqlSelectQueryBlock mysqlSelectQuery, Map<String, Map<String, Set<ColumnRoutePair>>> allConditions) {
		if(ctx.getTables() == null || ctx.getTables().size() == 0 ) {
			return false;
		}
		TableConfig tc = schema.getTables().get(ctx.getTables().get(0));
		if(tc==null ||(ctx.getTables().size() == 1 && tc.isGlobalTable())
				) {//|| (ctx.getTables().size() == 1) && tc.getRule() == null && tc.getDataNodes().size() == 1
			return false;
		} else {
			//单表主键查询
			if(ctx.getTables().size() == 1) {
				String tableName = ctx.getTables().get(0);
				String primaryKey = schema.getTables().get(tableName).getPrimaryKey();
//				schema.getTables().get(ctx.getTables().get(0)).getParentKey() != null;
				if(ctx.getRouteCalculateUnit().getTablesAndConditions().get(tableName) != null
						&& ctx.getRouteCalculateUnit().getTablesAndConditions().get(tableName).get(primaryKey) != null 
						&& tc.getDataNodes().size() > 1) {//有主键条件
					return false;
				} 
			}
			return true;
		}
	}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:25,代码来源:DruidSelectParser.java


示例4: isConditionAlwaysTrue

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private boolean isConditionAlwaysTrue(SQLStatement statement) {
	SQLSelectStatement selectStmt = (SQLSelectStatement)statement;
	SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
	if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
		MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
		SQLExpr expr = mysqlSelectQuery.getWhere();
		
		Object o = WallVisitorUtils.getValue(expr);
		if(Boolean.TRUE.equals(o)) {
			return true;
		}
		return false;
	} else {//union
		return false;
	}
	
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:18,代码来源:DruidSelectParser.java


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


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


示例7: createSelectQueryBlock

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
protected SQLSelectQuery createSelectQueryBlock() {
    if (JdbcConstants.MYSQL.equals(dbType)) {
        return new MySqlSelectQueryBlock();
    }

    if (JdbcConstants.POSTGRESQL.equals(dbType)) {
        return new PGSelectQueryBlock();
    }

    if (JdbcConstants.SQL_SERVER.equals(dbType)) {
        return new SQLServerSelectQueryBlock();
    }

    if (JdbcConstants.ORACLE.equals(dbType)) {
        return new OracleSelectQueryBlock();
    }

    return new SQLSelectQueryBlock();
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:20,代码来源:SQLSelectBuilderImpl.java


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


示例9: parseJoinSelect

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
public JoinSelect parseJoinSelect(SQLQueryExpr sqlExpr) throws SqlParseException {

        MySqlSelectQueryBlock query = (MySqlSelectQueryBlock) sqlExpr.getSubQuery().getQuery();

        List<From> joinedFrom = findJoinedFrom(query.getFrom());
        if (joinedFrom.size() != 2)
            throw new RuntimeException("currently supports only 2 tables join");

        JoinSelect joinSelect = createBasicJoinSelectAccordingToTableSource((SQLJoinTableSource) query.getFrom());
        List<Hint> hints = parseHints(query.getHints());
        joinSelect.setHints(hints);
        String firstTableAlias = joinedFrom.get(0).getAlias();
        String secondTableAlias = joinedFrom.get(1).getAlias();
        Map<String, Where> aliasToWhere = splitAndFindWhere(query.getWhere(), firstTableAlias, secondTableAlias);
        Map<String, List<SQLSelectOrderByItem>> aliasToOrderBy = splitAndFindOrder(query.getOrderBy(), firstTableAlias, secondTableAlias);
        List<Condition> connectedConditions = getConditionsFlatten(joinSelect.getConnectedWhere());
        joinSelect.setConnectedConditions(connectedConditions);
        fillTableSelectedJoin(joinSelect.getFirstTable(), query, joinedFrom.get(0), aliasToWhere.get(firstTableAlias), aliasToOrderBy.get(firstTableAlias), connectedConditions);
        fillTableSelectedJoin(joinSelect.getSecondTable(), query, joinedFrom.get(1), aliasToWhere.get(secondTableAlias), aliasToOrderBy.get(secondTableAlias), connectedConditions);

        updateJoinLimit(query.getLimit(), joinSelect);

        //todo: throw error feature not supported:  no group bys on joins ?
        return joinSelect;
    }
 
开发者ID:mazhou,项目名称:es-sql,代码行数:26,代码来源:SqlParser.java


示例10: isSupportSelect

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private static boolean isSupportSelect(String stmt) {
    SQLStatementParser parser = new MySqlStatementParser(stmt);
    SQLStatement statement = parser.parseStatement();
    if (!(statement instanceof SQLSelectStatement)) {
        return false;
    }

    SQLSelectQuery sqlSelectQuery = ((SQLSelectStatement) statement).getSelect().getQuery();
    if (!(sqlSelectQuery instanceof MySqlSelectQueryBlock)) {
        return false;
    }
    MySqlSelectQueryBlock selectQueryBlock = (MySqlSelectQueryBlock) sqlSelectQuery;
    SQLTableSource mysqlFrom = selectQueryBlock.getFrom();
    if (mysqlFrom != null) {
        return false;
    }
    for (SQLSelectItem item : selectQueryBlock.getSelectList()) {
        SQLExpr selectItem = item.getExpr();
        if (!isVariantRef(selectItem)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:25,代码来源:SelectHandler.java


示例11: isNoSharding

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
public static boolean isNoSharding(ServerConnection source, SQLSelectQuery sqlSelectQuery, SQLStatement selectStmt, String contextSchema, StringPtr sqlSchema)
        throws SQLException {
    if (sqlSelectQuery instanceof MySqlSelectQueryBlock) {
        MySqlSelectQueryBlock mySqlSelectQueryBlock = (MySqlSelectQueryBlock) sqlSelectQuery;
        if (!isNoSharding(source, mySqlSelectQueryBlock.getFrom(), selectStmt, contextSchema, sqlSchema)) {
            return false;
        }
        if (mySqlSelectQueryBlock.getWhere() != null && !SchemaUtil.isNoSharding(source, mySqlSelectQueryBlock.getWhere(), contextSchema, sqlSchema)) {
            return false;
        }
        for (SQLSelectItem selectItem : mySqlSelectQueryBlock.getSelectList()) {
            if (!SchemaUtil.isNoSharding(source, selectItem.getExpr(), contextSchema, sqlSchema)) {
                return false;
            }
        }
        return true;
    } else if (sqlSelectQuery instanceof MySqlUnionQuery) {
        return isNoSharding(source, (MySqlUnionQuery) sqlSelectQuery, selectStmt, contextSchema, sqlSchema);
    } else {
        return false;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:23,代码来源:SchemaUtil.java


示例12: testGroupbyOrder

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
@Test
public void testGroupbyOrder() {
    MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 group by col1 desc,col2 asc ");
    SQLSelectGroupByClause groupBy = query.getGroupBy();
    int i = 0;
    for (SQLExpr p : groupBy.getItems()) {
        i++;
        String groupCol = "col" + i;
        MySqlOrderingExpr groupitem = (MySqlOrderingExpr) p;
        SQLExpr q = groupitem.getExpr();
        MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
        q.accept(v);
        Item item = v.getItem();
        Assert.assertEquals(true, groupCol.equals(item.getItemName()));
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:17,代码来源:TestMySQLItemVisitor.java


示例13: endVisit

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
@Override
public void endVisit(final MySqlSelectQueryBlock x) {
	//把缺失的orderby列补上,union太复杂暂时不支持
	if(isMasterSelect()){
 	if(!CollectionUtils.isEmpty(missOrderbyColumns)){
 		String orderby_columns="";
 		for(String columnName: missOrderbyColumns){
 			orderby_columns+= ", "+ columnName;
 		}
 		parseResult.getSqlBuilder().buildSQL("select_missing_columns", orderby_columns);
 	}
 	//增加一个limit东西限制查询大小
 	if(parseResult.getLimit()== null){
 		//print(" limit 9");
 	}
	}
	
	if(isEnableCollectMetadata()){
		finishCollectMetadata= true;
	}
	selectLayer--;
}
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:23,代码来源:MySQLSelectVisitor.java


示例14: getMethodValuesWithSubQueries

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private Object[] getMethodValuesWithSubQueries(SQLMethodInvokeExpr method) throws SqlParseException {
    List<Object> values = new ArrayList<>();
    boolean foundSubQuery = false;
    for(SQLExpr innerExpr : method.getParameters()){
        if(innerExpr instanceof SQLQueryExpr){
            foundSubQuery = true;
            Select select = parseSelect((MySqlSelectQueryBlock) ((SQLQueryExpr) innerExpr).getSubQuery().getQuery());
            values.add(new SubQueryExpression(select));
        }
        else {
            values.add(innerExpr);
        }

    }
    Object[] conditionValues ;
    if(foundSubQuery)
        conditionValues = values.toArray();
    else
        conditionValues = method.getParameters().toArray();
    return conditionValues;
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:22,代码来源:SqlParser.java


示例15: findOrderBy

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private void findOrderBy(MySqlSelectQueryBlock query, Select select) throws SqlParseException {
	SQLOrderBy orderBy = query.getOrderBy();

	if (orderBy == null) {
		return;
	}
	List<SQLSelectOrderByItem> items = orderBy.getItems();
	List<String> lists = new ArrayList<>();
	for (SQLSelectOrderByItem sqlSelectOrderByItem : items) {
		SQLExpr expr = sqlSelectOrderByItem.getExpr();
		lists.add(FieldMaker.makeField(expr, null,null).toString());
		if (sqlSelectOrderByItem.getType() == null) {
			sqlSelectOrderByItem.setType(SQLOrderingSpecification.ASC);
		}
		String type = sqlSelectOrderByItem.getType().toString();
		for (String name : lists) {
			name = name.replace("`", "");
			select.addOrderBy(name, type);
		}
		lists.clear();
	}

}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:24,代码来源:SqlParser.java


示例16: parseJoinSelect

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
public JoinSelect parseJoinSelect(SQLQueryExpr sqlExpr) throws SqlParseException {

        MySqlSelectQueryBlock query = (MySqlSelectQueryBlock) sqlExpr.getSubQuery().getQuery();

        List<From> joinedFrom = findJoinedFrom(query.getFrom());
        if(joinedFrom.size() != 2)
            throw new RuntimeException("currently supports only 2 tables join");

        JoinSelect joinSelect = createBasicJoinSelectAccordingToTableSource((SQLJoinTableSource) query.getFrom());
        List<Hint> hints = parseHints(query.getHints());
        joinSelect.setHints(hints);
        String firstTableAlias = joinedFrom.get(0).getAlias();
        String secondTableAlias = joinedFrom.get(1).getAlias();
        Map<String, Where> aliasToWhere = splitAndFindWhere(query.getWhere(), firstTableAlias, secondTableAlias);
        List<Condition> connectedConditions = getConditionsFlatten(joinSelect.getConnectedWhere());
        joinSelect.setConnectedConditions(connectedConditions);
        fillTableSelectedJoin(joinSelect.getFirstTable(), query, joinedFrom.get(0), aliasToWhere.get(firstTableAlias), connectedConditions);
        fillTableSelectedJoin(joinSelect.getSecondTable(), query, joinedFrom.get(1), aliasToWhere.get(secondTableAlias), connectedConditions);

        updateJoinLimit(query.getLimit(), joinSelect);

        //todo: throw error feature not supported:  no group bys on joins ?
        return joinSelect;
    }
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:25,代码来源:SqlParser.java


示例17: route

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
public void route(SystemConfig sysConfig, SchemaConfig schema,int sqlType, String realSQL, String charset, ServerConnection sc,	LayerCachePool cachePool) {
	int rs = ServerParse.parse(realSQL);
	this.sqltype = rs & 0xff;
	this.sysConfig=sysConfig; 
	this.schema=schema;
	this.charset=charset; 
	this.sc=sc;	
	this.cachePool=cachePool;		
	try {
	 //  RouteStrategy routes=RouteStrategyFactory.getRouteStrategy();	
	  // rrs =RouteStrategyFactory.getRouteStrategy().route(sysConfig, schema, sqlType2, realSQL,charset, sc, cachePool);		   
		MySqlStatementParser parser = new MySqlStatementParser(realSQL);			
		SQLStatement statement = parser.parseStatement();
		if(statement instanceof SQLSelectStatement) {
		   SQLSelectStatement st=(SQLSelectStatement)statement;
		   SQLSelectQuery sqlSelectQuery =st.getSelect().getQuery();
			if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
				MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)st.getSelect().getQuery();
				joinParser=new JoinParser(mysqlSelectQuery,realSQL);
				joinParser.parser();
			}	
		}
	   /*	
	   if (routes instanceof DruidMysqlRouteStrategy) {
		   SQLSelectStatement st=((DruidMysqlRouteStrategy) routes).getSQLStatement();
		   SQLSelectQuery sqlSelectQuery =st.getSelect().getQuery();
			if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
				MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)st.getSelect().getQuery();
				joinParser=new JoinParser(mysqlSelectQuery,realSQL);
				joinParser.parser();
			}
	   }
	   */
	} catch (Exception e) {
	
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:38,代码来源:ShareJoin.java


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


示例19: limitQueryBlock

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入依赖的package包/类
private static boolean limitQueryBlock(SQLSelect select, String dbType, int offset, int count, boolean check) {
    SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) select.getQuery();
    if (JdbcConstants.MYSQL.equals(dbType) || //
        JdbcConstants.MARIADB.equals(dbType) || //
        JdbcConstants.H2.equals(dbType)) {
        return limitMySqlQueryBlock((MySqlSelectQueryBlock) queryBlock, dbType, offset, count, check);
    }

    if (JdbcConstants.POSTGRESQL.equals(dbType)) {
        return limitPostgreSQLQueryBlock((PGSelectQueryBlock) queryBlock, dbType, offset, count, check);
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:14,代码来源:PagerUtils.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResourcesListImpl类代码示例发布时间:2022-05-22
下一篇:
Java JdbcUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap