Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么OR条件下不进行聚合函数处理 #5

Closed
pingww opened this issue Feb 3, 2016 · 4 comments
Closed

为什么OR条件下不进行聚合函数处理 #5

pingww opened this issue Feb 3, 2016 · 4 comments

Comments

@pingww
Copy link

pingww commented Feb 3, 2016

if (sqlVisitor.getParseContext().isHasOrCondition()) {
result = new OrParser(sqlStatement, visitor).parse(); // 这里直接丢掉了聚合列的merge处理?
} else {
sqlVisitor.getParseContext().mergeCurrentConditionContext();
result = sqlVisitor.getParseContext().getParsedResult();
}

@terrymanu
Copy link
Member

or的处理是基于不包含or处理器之上的。mergeCurrentConditionContext这个方法不是为了处理merge聚合列,是为了生产和or统一的返回格式

@pingww
Copy link
Author

pingww commented Feb 17, 2016

@terrymanu ,我测了一下,有or条件的情况,没有做groupby、avg等分组聚合处理;or的处理是基于不包含or处理器之上的?这个哪里体现的,没有看到啊

@hanahmily hanahmily reopened this Feb 17, 2016
@hanahmily
Copy link
Contributor

@pingww 抱歉一开始没有好好理解你的问题。其实sharding-jdbc对or的结果集归并与其他归并方法相同。
com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement

    @Override
    public ResultSet executeQuery() throws SQLException {
        hasExecuted = true;
        setCurrentResultSet(ResultSetFactory.getResultSet(new PreparedStatementExecutor(getContext().getExecutorEngine(), getRoutedPreparedStatements()).executeQuery(), getMergeContext()));
        return getCurrentResultSet();
    }

...

private List<PreparedStatement> routeSQL(final List<Object> parameters) throws SQLException {
        List<PreparedStatement> result = new ArrayList<>();
        SQLRouteResult sqlRouteResult = getContext().getSqlRouteEngine().route(sql, parameters);
        MergeContext mergeContext = sqlRouteResult.getMergeContext();
        mergeContext.setExecutorEngine(getContext().getExecutorEngine());
        setMergeContext(mergeContext);
        for (SQLExecutionUnit each : sqlRouteResult.getExecutionUnits()) {
            PreparedStatement preparedStatement = generatePrepareStatement(getShardingConnection().getConnection(each.getDataSource()), each.getSql());
            replayMethodsInvovation(preparedStatement);
            setParameters(preparedStatement, parameters);
            result.add(preparedStatement);
        }
        return result;
    }

也就是不管当前sql是什么,流程都是 SqlRouterEngine-》SQLExecutionUnit -》 ResultSetFactory 。

如果你的示例不能执行归并,那么请把日志级别调整为trace然后发出来,我再进行跟踪。
谢谢

@pingww
Copy link
Author

pingww commented Mar 17, 2016

MergeContext 都是在MySQLSelectVisitor里面生成的,OR解析没有使用这个visitor,所以归并上下文为空。 @hanahmily

terrymanu pushed a commit that referenced this issue May 2, 2018
terrymanu pushed a commit that referenced this issue May 21, 2018
terrymanu pushed a commit that referenced this issue Oct 8, 2018
terrymanu pushed a commit that referenced this issue Jun 10, 2019
KomachiSion pushed a commit to KomachiSion/incubator-shardingsphere that referenced this issue Nov 25, 2019
Refactor MySQLPasswordEncryptor
xuup added a commit to xuup/shardingsphere that referenced this issue Jul 19, 2022
tianhao960 added a commit to tianhao960/shardingsphere that referenced this issue Aug 22, 2022
tuichenchuxin pushed a commit that referenced this issue Aug 23, 2022
* add createProcedure rule for oracle #1

* add createProcedure rule for oracle #2

* add createProcedure rule for oracle #3

* add createProcedure rule for oracle #4

* add createProcedure rule for oracle #5

* add createProcedure rule for oracle #6

* add createProcedure rule for oracle #6

* add createProcedure rule for oracle #7
strongduanmu pushed a commit that referenced this issue Aug 24, 2022
* add createProcedure rule for oracle #1

* add createProcedure rule for oracle #2

* add createProcedure rule for oracle #3

* add createProcedure rule for oracle #4

* add createProcedure rule for oracle #5

* add createProcedure rule for oracle #6

* add createProcedure rule for oracle #6

* add createProcedure rule for oracle #7

* add dropProcedure and alterProcedure rule for oracle

* add javadoc and final for ProcedureStatement
tianhao960 added a commit to tianhao960/shardingsphere that referenced this issue Sep 11, 2022
terrymanu pushed a commit that referenced this issue Sep 14, 2022
* add support for test parallel run

* refactor parallel test framework #2

* refactor parallel test framework #3

* refactor parallel test framework #4

* refactor parallel test framework #5

* refactor parallel test framework #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants