-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IGNITE-10580: SQL: Fixed incorrect re-use of cached connection for lo…
…cal queries. This closes #5592.
- Loading branch information
tledkov-gridgain
authored and
devozerov
committed
Dec 25, 2018
1 parent
2dabbd2
commit 86a815e
Showing
5 changed files
with
139 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
.../org/apache/ignite/internal/processors/query/SqlLocalQueryConnectionAndStatementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.ignite.internal.processors.query; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import org.apache.ignite.cache.query.FieldsQueryCursor; | ||
import org.apache.ignite.cache.query.SqlFieldsQuery; | ||
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** | ||
* Test for statement reuse. | ||
*/ | ||
@RunWith(JUnit4.class) | ||
public class SqlLocalQueryConnectionAndStatementTest extends GridCommonAbstractTest { | ||
/** {@inheritDoc} */ | ||
@Override public void beforeTestsStarted() throws Exception { | ||
super.beforeTestsStarted(); | ||
|
||
startGrids(1); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override protected void afterTestsStopped() throws Exception { | ||
stopAllGrids(); | ||
|
||
super.afterTestsStopped(); | ||
} | ||
|
||
/** | ||
*/ | ||
@Test | ||
public void testReplicated() { | ||
sql("CREATE TABLE repl_tbl (id LONG PRIMARY KEY, val LONG) WITH \"template=replicated\"").getAll(); | ||
|
||
for (int i = 0; i < 10; i++) | ||
sql("insert into repl_tbl(id,val) VALUES(" + i + "," + i + ")").getAll(); | ||
|
||
Iterator<List<?>> it0 = sql(new SqlFieldsQuery("SELECT * FROM repl_tbl where id > ?").setArgs(1)).iterator(); | ||
|
||
it0.next(); | ||
|
||
sql(new SqlFieldsQuery("SELECT * FROM repl_tbl where id > ?").setArgs(1)).getAll(); | ||
|
||
it0.next(); | ||
} | ||
|
||
/** | ||
*/ | ||
@Test | ||
public void testLocalQuery() { | ||
sql("CREATE TABLE tbl (id LONG PRIMARY KEY, val LONG)").getAll(); | ||
|
||
for (int i = 0; i < 10; i++) | ||
sql("insert into tbl(id,val) VALUES(" + i + "," + i + ")").getAll(); | ||
|
||
Iterator<List<?>> it0 = sql( | ||
new SqlFieldsQuery("SELECT * FROM tbl where id > ?") | ||
.setArgs(1) | ||
.setLocal(true)) | ||
.iterator(); | ||
|
||
it0.next(); | ||
|
||
sql(new SqlFieldsQuery("SELECT * FROM tbl where id > ?").setArgs(1).setLocal(true)).getAll(); | ||
|
||
it0.next(); | ||
} | ||
|
||
/** | ||
* @param sql SQL query. | ||
* @return Results. | ||
*/ | ||
private FieldsQueryCursor<List<?>> sql(String sql) { | ||
return sql(new SqlFieldsQuery(sql)); | ||
} | ||
|
||
/** | ||
* @param qry SQL query. | ||
* @return Results. | ||
*/ | ||
private FieldsQueryCursor<List<?>> sql(SqlFieldsQuery qry) { | ||
GridQueryProcessor qryProc = grid(0).context().query(); | ||
|
||
return qryProc.querySqlFields(qry, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters