提交 6abf8cea 编写于 作者: T tristaZero

Merge branch 'dev' of ssh://github.com/shardingjdbc/sharding-jdbc into dev

......@@ -43,6 +43,7 @@
<module>sharding-sql-test</module>
<module>sharding-distribution</module>
<module>sharding-integration-test</module>
</modules>
<properties>
......@@ -503,6 +504,7 @@
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<excludes>
<exclude>**/*Tests.java</exclude>
<exclude>**/*Integrate*.java</exclude>
</excludes>
</configuration>
</plugin>
......
......@@ -27,7 +27,6 @@ import org.apache.shardingsphere.core.parse.sql.statement.dal.DALStatement;
import org.apache.shardingsphere.core.parse.sql.statement.dml.InsertStatement;
import org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.limit.Limit;
import org.junit.Before;
import org.junit.Test;
......@@ -61,10 +60,9 @@ public final class MergeEngineFactoryTest {
@Test
public void assertNewInstanceWithSelectStatement() throws SQLException {
SQLRouteResult routeResult = new SQLRouteResult(new SelectStatement());
routeResult.setLimit(new Limit());
assertThat(MergeEngineFactory.newInstance(DatabaseType.MySQL, null, routeResult, null, queryResults), instanceOf(DQLMergeEngine.class));
}
@Test
public void assertNewInstanceWithDALStatement() throws SQLException {
SQLRouteResult routeResult = new SQLRouteResult(new DALStatement());
......
......@@ -30,7 +30,6 @@ import org.apache.shardingsphere.core.parse.sql.context.selectitem.AggregationSe
import org.apache.shardingsphere.core.parse.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.limit.Limit;
import org.junit.Before;
import org.junit.Test;
......@@ -81,7 +80,6 @@ public final class GroupByMemoryMergedResultTest {
selectStatement.getGroupByItems().add(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.DESC, OrderDirection.ASC));
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
}
private ResultSet mockResultSet() throws SQLException {
......
......@@ -30,7 +30,6 @@ import org.apache.shardingsphere.core.parse.sql.context.selectitem.AggregationSe
import org.apache.shardingsphere.core.parse.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.limit.Limit;
import org.junit.Before;
import org.junit.Test;
......@@ -83,7 +82,6 @@ public final class GroupByStreamMergedResultTest {
selectStatement.getGroupByItems().add(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC));
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
}
private ResultSet mockResultSet() throws SQLException {
......
......@@ -25,7 +25,6 @@ import org.apache.shardingsphere.core.merge.dql.DQLMergeEngine;
import org.apache.shardingsphere.core.merge.fixture.TestQueryResult;
import org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.limit.Limit;
import org.junit.Before;
import org.junit.Test;
......@@ -54,7 +53,6 @@ public final class IteratorStreamMergedResultTest {
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
queryResults = Lists.<QueryResult>newArrayList(new TestQueryResult(resultSet), new TestQueryResult(mock(ResultSet.class)), new TestQueryResult(mock(ResultSet.class)));
routeResult = new SQLRouteResult(new SelectStatement());
routeResult.setLimit(new Limit());
}
@Test
......
......@@ -27,7 +27,6 @@ import org.apache.shardingsphere.core.merge.fixture.TestQueryResult;
import org.apache.shardingsphere.core.parse.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.limit.Limit;
import org.junit.Before;
import org.junit.Test;
......@@ -63,7 +62,6 @@ public final class OrderByStreamMergedResultTest {
selectStatement = new SelectStatement();
selectStatement.getOrderByItems().add(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC));
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
}
@Test
......
......@@ -49,12 +49,7 @@ public final class LimitExtractor implements OptionalSQLSegmentExtractor {
Optional<ParserRuleContext> limitNode = ExtractorUtils.findFirstChildNode(ancestorNode, RuleName.LIMIT_CLAUSE);
return limitNode.isPresent()
? Optional.of(new LimitSegment(limitNode.get().getStart().getStartIndex(), limitNode.get().getStop().getStopIndex(),
extractRowCount(limitNode.get(), parameterMarkerIndexes).orNull(), extractOffset(limitNode.get(), parameterMarkerIndexes).orNull())) : Optional.<LimitSegment>absent();
}
private Optional<LimitValueSegment> extractRowCount(final ParserRuleContext limitNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
Optional<ParserRuleContext> rowCountNode = ExtractorUtils.findFirstChildNode(limitNode, RuleName.LIMIT_ROW_COUNT);
return rowCountNode.isPresent() ? Optional.of(extractLimitValue(rowCountNode.get(), parameterMarkerIndexes)) : Optional.<LimitValueSegment>absent();
extractOffset(limitNode.get(), parameterMarkerIndexes).orNull(), extractRowCount(limitNode.get(), parameterMarkerIndexes).orNull())) : Optional.<LimitSegment>absent();
}
private Optional<LimitValueSegment> extractOffset(final ParserRuleContext limitNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
......@@ -62,6 +57,11 @@ public final class LimitExtractor implements OptionalSQLSegmentExtractor {
return offsetNode.isPresent() ? Optional.of(extractLimitValue(offsetNode.get(), parameterMarkerIndexes)) : Optional.<LimitValueSegment>absent();
}
private Optional<LimitValueSegment> extractRowCount(final ParserRuleContext limitNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
Optional<ParserRuleContext> rowCountNode = ExtractorUtils.findFirstChildNode(limitNode, RuleName.LIMIT_ROW_COUNT);
return rowCountNode.isPresent() ? Optional.of(extractLimitValue(rowCountNode.get(), parameterMarkerIndexes)) : Optional.<LimitValueSegment>absent();
}
private LimitValueSegment extractLimitValue(final ParserRuleContext limitValueNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
Optional<ParameterMarkerExpressionSegment> parameterMarkerExpression = parameterMarkerExpressionExtractor.extract(limitValueNode, parameterMarkerIndexes);
if (parameterMarkerExpression.isPresent()) {
......
......@@ -109,7 +109,7 @@ public final class SelectItemFiller implements SQLSegmentFiller<SelectItemSegmen
}
private void fillTopSegment(final TopSegment topSegment, final SelectStatement selectStatement) {
selectStatement.setLimit(new LimitSegment(topSegment.getStartIndex(), topSegment.getStopIndex(), topSegment.getTop(), null));
selectStatement.setLimit(new LimitSegment(topSegment.getStartIndex(), topSegment.getStopIndex(), null, topSegment.getTop()));
selectStatement.getItems().add(new CommonSelectItem("rownum", Optional.of(topSegment.getRowNumberAlias())));
}
}
......@@ -103,23 +103,23 @@ public final class ShardingRowNumberPredicateFiller implements SQLSegmentFiller<
for (PredicateSegment each : rowNumberPredicates) {
ExpressionSegment expression = ((PredicateCompareRightValue) each.getRightValue()).getExpression();
switch (((PredicateCompareRightValue) each.getRightValue()).getOperator()) {
case "<":
rowCount = createLimitValueSegment(expression, false);
break;
case "<=":
rowCount = createLimitValueSegment(expression, true);
break;
case ">":
offset = createLimitValueSegment(expression, false);
break;
case ">=":
offset = createLimitValueSegment(expression, true);
break;
case "<":
rowCount = createLimitValueSegment(expression, false);
break;
case "<=":
rowCount = createLimitValueSegment(expression, true);
break;
default:
break;
}
}
selectStatement.setLimit(new LimitSegment(-1, -1, rowCount, offset));
selectStatement.setLimit(new LimitSegment(-1, -1, offset, rowCount));
}
private LimitValueSegment createLimitValueSegment(final ExpressionSegment expression, final boolean boundOpened) {
......
......@@ -35,18 +35,9 @@ public final class LimitSegment implements SQLSegment {
private final int stopIndex;
private final LimitValueSegment rowCount;
private final LimitValueSegment offset;
/**
* Get row count.
*
* @return row count
*/
public Optional<LimitValueSegment> getRowCount() {
return Optional.fromNullable(rowCount);
}
private final LimitValueSegment rowCount;
/**
* Get offset.
......@@ -56,4 +47,13 @@ public final class LimitSegment implements SQLSegment {
public Optional<LimitValueSegment> getOffset() {
return Optional.fromNullable(offset);
}
/**
* Get row count.
*
* @return row count
*/
public Optional<LimitValueSegment> getRowCount() {
return Optional.fromNullable(rowCount);
}
}
......@@ -125,7 +125,6 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteWithoutChange() {
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT table_y.id FROM table_y WHERE table_y.id=?");
SQLRewriteEngine rewriteEngine = createSQLRewriteEngine(DatabaseType.MySQL, Collections.<Object>singletonList(1));
......@@ -141,7 +140,6 @@ public final class ShardingSQLRewriterTest {
selectStatement.addSQLToken(new TableToken(31, 37, "table_x", QuoteCharacter.NONE));
selectStatement.addSQLToken(new TableToken(47, 53, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT table_x.id, x.name FROM table_x x WHERE table_x.id=? AND x.name=?");
SQLRewriteEngine rewriteEngine = createSQLRewriteEngine(DatabaseType.MySQL, parameters);
......@@ -154,7 +152,6 @@ public final class ShardingSQLRewriterTest {
SelectItemsToken selectItemsToken = new SelectItemsToken(12, Arrays.asList("x.id as GROUP_BY_DERIVED_0", "x.name as ORDER_BY_DERIVED_0"));
selectStatement.addSQLToken(selectItemsToken);
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT x.age FROM table_x x GROUP BY x.id ORDER BY x.name");
SQLRewriteEngine rewriteEngine = createSQLRewriteEngine(DatabaseType.MySQL, Collections.emptyList());
......@@ -168,7 +165,6 @@ public final class ShardingSQLRewriterTest {
SelectItemsToken selectItemsToken = new SelectItemsToken(17, Arrays.asList("COUNT(x.age) as AVG_DERIVED_COUNT_0", "SUM(x.age) as AVG_DERIVED_SUM_0"));
selectStatement.addSQLToken(selectItemsToken);
routeResult = new SQLRouteResult(selectStatement);
routeResult.setLimit(new Limit());
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT AVG(x.age) FROM table_x x");
SQLRewriteEngine rewriteEngine = createSQLRewriteEngine(DatabaseType.MySQL, Collections.emptyList());
......@@ -339,14 +335,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForLimit() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(33, 33, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(17, 23, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(2, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(2, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT x.id FROM table_x x LIMIT 2, 2");
......@@ -356,14 +352,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForRowNum() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(119, 119, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(68, 74, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT * FROM (SELECT row_.*, rownum rownum_ FROM (SELECT x.id FROM table_x x) row_ WHERE rownum<=4) t WHERE t.rownum_>2");
......@@ -374,14 +370,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForTopAndRowNumber() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(123, 123, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(85, 91, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT * FROM (SELECT TOP(4) row_number() OVER (ORDER BY x.id) AS rownum_, x.id FROM table_x x) AS row_ WHERE row_.rownum_>2");
......@@ -392,9 +388,9 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForLimitForMemoryGroupBy() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(33, 33, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
ColumnSegment columnSegment = new ColumnSegment(0, 0, "id");
columnSegment.setOwner(new TableSegment(0, 0, "x"));
selectStatement.getOrderByItems().add(new ColumnOrderByItemSegment(0, 0, columnSegment, OrderDirection.ASC, OrderDirection.ASC));
......@@ -402,8 +398,8 @@ public final class ShardingSQLRewriterTest {
selectStatement.addSQLToken(new TableToken(17, 23, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT x.id FROM table_x x LIMIT 2, 2");
......@@ -413,9 +409,9 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForRowNumForMemoryGroupBy() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(119, 119, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(68, 74, "table_x", QuoteCharacter.NONE));
ColumnSegment columnSegment = new ColumnSegment(0, 0, "id");
columnSegment.setOwner(new TableSegment(0, 0, "x"));
......@@ -423,8 +419,8 @@ public final class ShardingSQLRewriterTest {
selectStatement.getGroupByItems().add(new ColumnOrderByItemSegment(0, 0, columnSegment, OrderDirection.DESC, OrderDirection.ASC));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT * FROM (SELECT row_.*, rownum rownum_ FROM (SELECT x.id FROM table_x x) row_ WHERE rownum<=4) t WHERE t.rownum_>2");
......@@ -435,9 +431,9 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForTopAndRowNumberForMemoryGroupBy() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(123, 123, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(85, 91, "table_x", QuoteCharacter.NONE));
ColumnSegment columnSegment = new ColumnSegment(0, 0, "id");
columnSegment.setOwner(new TableSegment(0, 0, "x"));
......@@ -445,8 +441,8 @@ public final class ShardingSQLRewriterTest {
selectStatement.getGroupByItems().add(new ColumnOrderByItemSegment(0, 0, columnSegment, OrderDirection.DESC, OrderDirection.ASC));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
routeResult.setRoutingResult(new RoutingResult());
selectStatement.setLogicSQL("SELECT * FROM (SELECT TOP(4) row_number() OVER (ORDER BY x.id) AS rownum_, x.id FROM table_x x) AS row_ WHERE row_.rownum_>2");
......@@ -457,14 +453,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForLimitForNotRewriteLimit() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(33, 33, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(36, 36, 2, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(17, 23, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
RoutingResult routingResult = new RoutingResult();
routingResult.getRoutingUnits().add(new RoutingUnit("ds"));
......@@ -476,14 +472,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForRowNumForNotRewriteLimit() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(119, 119, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(98, 98, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(68, 74, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
RoutingResult routingResult = new RoutingResult();
routingResult.getRoutingUnits().add(new RoutingUnit("ds"));
......@@ -496,14 +492,14 @@ public final class ShardingSQLRewriterTest {
@Test
public void assertRewriteForTopAndRowNumberForNotRewriteLimit() {
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
LimitValueSegment offsetSQLSegment = new NumberLiteralLimitValueSegment(123, 123, 2, true);
selectStatement.setLimit(new LimitSegment(0, 0, rowCountSQLSegment, offsetSQLSegment));
LimitValueSegment rowCountSQLSegment = new NumberLiteralLimitValueSegment(26, 26, 4, false);
selectStatement.setLimit(new LimitSegment(0, 0, offsetSQLSegment, rowCountSQLSegment));
selectStatement.addSQLToken(new TableToken(85, 91, "table_x", QuoteCharacter.NONE));
routeResult = new SQLRouteResult(selectStatement);
Limit limit = new Limit();
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
limit.setOffset(new LimitValue(2, -1, offsetSQLSegment));
limit.setRowCount(new LimitValue(4, -1, rowCountSQLSegment));
routeResult.setLimit(limit);
RoutingResult routingResult = new RoutingResult();
routingResult.getRoutingUnits().add(new RoutingUnit("ds"));
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>sharding-jdbc-test</module>
</modules>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere</artifactId>
<version>4.0.0-RC2-SNAPSHOT</version>
</parent>
<artifactId>sharding-integration-test</artifactId>
<name>${project.artifactId}</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/*Integrate*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-integration-test</artifactId>
<version>4.0.0-RC2-SNAPSHOT</version>
</parent>
<artifactId>sharding-jdbc-test</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-sql-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java7</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
</project>
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.apache.shardingsphere.dbtest.fixture.ConstantShardingKeyGenerator
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册