diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java new file mode 100644 index 0000000000000..0f956beb5ee3b --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/AbstractJdbcTest.java @@ -0,0 +1,70 @@ +/* + * 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.calcite.jdbc; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.IgniteException; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * Abstract JDBC test. + */ +public abstract class AbstractJdbcTest extends GridCommonAbstractTest { + /** URL. */ + protected static final String URL = "jdbc:ignite:thin://127.0.0.1"; + + /** */ + protected void execute(Statement stmt, String sql) { + try { + stmt.execute(sql); + } + catch (SQLException e) { + throw new IgniteException(e.getMessage(), e); + } + } + + /** */ + protected List> executeQuery(Connection conn, String sql) throws SQLException { + return executeQuery(conn.createStatement(), sql); + } + + /** */ + protected List> executeQuery(Statement stmt, String sql) { + try (ResultSet rs = stmt.executeQuery(sql)) { + List> res = new ArrayList<>(); + while (rs.next()) { + List row = new ArrayList<>(); + + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) + row.add(rs.getObject(i)); + + res.add(row); + } + + return res; + } + catch (SQLException e) { + throw new IgniteException(e.getMessage(), e); + } + } +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java index 5b959edc3e558..3eee08e82a390 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcCrossEngineTest.java @@ -21,31 +21,23 @@ import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Statement; import java.sql.Time; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.UUID; import java.util.function.IntConsumer; -import org.apache.ignite.IgniteException; import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.SqlConfiguration; import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; /** * Cross check queries on experimental and non-experimental SQL engines. */ -public class JdbcCrossEngineTest extends GridCommonAbstractTest { - /** URL. */ - private static final String url = "jdbc:ignite:thin://127.0.0.1"; - +public class JdbcCrossEngineTest extends AbstractJdbcTest { /** Nodes count. */ private static final int nodesCnt = 3; @@ -76,7 +68,7 @@ public class JdbcCrossEngineTest extends GridCommonAbstractTest { startGrids(nodesCnt); for (int i = 0; i < engineNames.length; i++) { - conns[i] = DriverManager.getConnection(url + "?queryEngine=" + engineNames[i]); + conns[i] = DriverManager.getConnection(URL + "?queryEngine=" + engineNames[i]); conns[i].setSchema("PUBLIC"); stmts[i] = conns[i].createStatement(); @@ -203,36 +195,6 @@ private void checkInsertDefaultValue(String sqlType, String sqlVal, Object expec ); } - /** */ - private void execute(Statement stmt, String sql) { - try { - stmt.execute(sql); - } - catch (SQLException e) { - throw new IgniteException(e.getMessage(), e); - } - } - - /** */ - private List> executeQuery(Statement stmt, String sql) { - try (ResultSet rs = stmt.executeQuery(sql)) { - List> res = new ArrayList<>(); - while (rs.next()) { - List row = new ArrayList<>(); - - for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) - row.add(rs.getObject(i)); - - res.add(row); - } - - return res; - } - catch (SQLException e) { - throw new IgniteException(e.getMessage(), e); - } - } - /** */ private void crossCheck(IntConsumer consumer1, IntConsumer consumer2) { // Execute consumer1 on indexing engine, consumer2 on calcite engine. diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java new file mode 100644 index 0000000000000..687de37a8a2d2 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcLocalFlagTest.java @@ -0,0 +1,76 @@ +/* + * 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.calcite.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.util.List; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.SqlConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.junit.Test; + +/** */ +public class JdbcLocalFlagTest extends AbstractJdbcTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String instanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(instanceName); + + cfg.setSqlConfiguration(new SqlConfiguration() + .setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration().setDefault(true))); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() { + stopAllGrids(); + } + + /** */ + @Test + public void testLocalFlag() throws Exception { + IgniteEx ignite = startGrids(3); + + int keys = 100; + + sql(ignite, "CREATE TABLE test(id INT PRIMARY KEY, val VARCHAR)"); + + for (int i = 0; i < keys; i++) + sql(ignite, "INSERT INTO test(id, val) VALUES (?, ?)", i, "val" + i); + + try (Connection conn = DriverManager.getConnection(URL)) { + List> res = executeQuery(conn, "SELECT * FROM test"); + + assertEquals(keys, res.size()); + } + + try (Connection conn = DriverManager.getConnection(URL + "?local=true")) { + List> res = executeQuery(conn, "SELECT * FROM test"); + + assertTrue(keys > res.size()); + } + } + + /** */ + private List> sql(IgniteEx ignite, String sql, Object... args) { + return ignite.context().query().querySqlFields(new SqlFieldsQuery(sql).setArgs(args), false).getAll(); + } +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java index b9f1914f9e10d..72fd3786d9985 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IgniteCalciteTestSuite.java @@ -19,9 +19,6 @@ import org.apache.ignite.internal.processors.query.calcite.exec.LogicalRelImplementorTest; import org.apache.ignite.internal.processors.query.calcite.exec.NumericTypesPrecisionsTest; -import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcConnectionEnabledPropertyTest; -import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcSetClientInfoTest; -import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcThinTransactionalSelfTest; import org.apache.ignite.internal.processors.query.calcite.message.CalciteCommunicationMessageSerializationTest; import org.apache.ignite.internal.processors.query.calcite.sql.SqlCustomParserTest; import org.apache.ignite.internal.processors.query.calcite.sql.SqlReservedWordsTest; @@ -39,6 +36,7 @@ ExecutionTestSuite.class, IntegrationTestSuite.class, UtilTestSuite.class, + JdbcTestSuite.class, SqlCustomParserTest.class, SqlReservedWordsTest.class, @@ -51,10 +49,6 @@ SqlTransactionsIsolationTest.class, SqlTransactionsUnsupportedModesTest.class, - - JdbcThinTransactionalSelfTest.class, - JdbcSetClientInfoTest.class, - JdbcConnectionEnabledPropertyTest.class }) public class IgniteCalciteTestSuite { } diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java index 2754c4bc4177b..47f7480afaba3 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java @@ -85,8 +85,6 @@ import org.apache.ignite.internal.processors.query.calcite.integration.tpch.TpchScale001Test; import org.apache.ignite.internal.processors.query.calcite.integration.tpch.TpchScale010Test; import org.apache.ignite.internal.processors.query.calcite.integration.tpch.TpchScale100Test; -import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcCrossEngineTest; -import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcQueryTest; import org.apache.ignite.internal.processors.query.calcite.rules.JoinCommuteRulesTest; import org.apache.ignite.internal.processors.query.calcite.rules.JoinOrderOptimizationTest; import org.apache.ignite.internal.processors.query.calcite.rules.OrToUnionRuleTest; @@ -104,8 +102,6 @@ ProjectScanMergeRuleTest.class, CalciteQueryProcessorTest.class, CalciteErrorHandlilngIntegrationTest.class, - JdbcQueryTest.class, - JdbcCrossEngineTest.class, CalciteBasicSecondaryIndexIntegrationTest.class, CancelTest.class, DateTimeTest.class, diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java new file mode 100644 index 0000000000000..1e9a8c4f2e4df --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/JdbcTestSuite.java @@ -0,0 +1,42 @@ +/* + * 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.testsuites; + +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcConnectionEnabledPropertyTest; +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcCrossEngineTest; +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcLocalFlagTest; +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcQueryTest; +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcSetClientInfoTest; +import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcThinTransactionalSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Calcite JDBC tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + JdbcQueryTest.class, + JdbcCrossEngineTest.class, + JdbcThinTransactionalSelfTest.class, + JdbcSetClientInfoTest.class, + JdbcConnectionEnabledPropertyTest.class, + JdbcLocalFlagTest.class, +}) +public class JdbcTestSuite { +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java index 88ba966172bd1..1986e8b84cb58 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java @@ -52,7 +52,6 @@ @SuppressWarnings("ThrowableNotThrown") public class JdbcThinDataSourceSelfTest extends JdbcThinAbstractSelfTest { /** {@inheritDoc} */ - @SuppressWarnings("deprecation") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -141,6 +140,10 @@ public void testResetUrl() throws Exception { assertNull(ids.getSchema()); assertEquals(DFLT_LAZY, ids.isLazy()); assertTrue(ids.isCollocated()); + + ids.setUrl("jdbc:ignite:thin://127.0.0.1:10800?local=true"); + + assertTrue(ids.isLocal()); } /** @@ -161,6 +164,7 @@ public void testSqlHints() throws Exception { assertEquals(DFLT_LAZY, io.connectionProperties().isLazy()); assertFalse(io.connectionProperties().isDistributedJoins()); assertFalse(io.connectionProperties().isReplicatedOnly()); + assertFalse(io.connectionProperties().isLocal()); } } @@ -170,6 +174,7 @@ public void testSqlHints() throws Exception { ids.setLazy(!DFLT_LAZY); ids.setDistributedJoins(true); ids.setReplicatedOnly(true); + ids.setLocal(true); try (Connection conn = ids.getConnection()) { @@ -180,6 +185,7 @@ public void testSqlHints() throws Exception { assertEquals(!DFLT_LAZY, io.connectionProperties().isLazy()); assertTrue(io.connectionProperties().isDistributedJoins()); assertTrue(io.connectionProperties().isReplicatedOnly()); + assertTrue(io.connectionProperties().isLocal()); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDataSource.java b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDataSource.java index 7323471dd17cb..35302031940a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDataSource.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDataSource.java @@ -325,6 +325,20 @@ public void setLazy(boolean lazy) { props.setLazy(lazy); } + /** + * @return Local query flag. + */ + public boolean isLocal() { + return props.isLocal(); + } + + /** + * @param loc Local query flag. + */ + public void setLocal(boolean loc) { + props.setLocal(loc); + } + /** * @return Skip reducer on update flag. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java index 30b8809ab80b7..34e829be44442 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionProperties.java @@ -597,4 +597,14 @@ public void setPartitionAwarenessPartitionDistributionsCacheSize( * @param transactionLabel Transaction label. */ public void setTransactionLabel(String transactionLabel); + + /** + * @return Local flag. + */ + public boolean isLocal(); + + /** + * @param loc Local flag. + */ + public void setLocal(boolean loc); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java index 0b933d4261d11..a0f84fa74c8dc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/ConnectionPropertiesImpl.java @@ -76,6 +76,10 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa private final BooleanProperty replicatedOnly = new BooleanProperty( "replicatedOnly", "Specify if the all queries contain only replicated tables", false, false); + /** Local query property. */ + private final BooleanProperty loc = new BooleanProperty( + "local", "Whether this query should be executed on local node only", false, false); + /** Auto close server cursor property. */ private final BooleanProperty autoCloseServerCursor = new BooleanProperty( "autoCloseServerCursor", "Enable auto close server cursors when last piece of result set is retrieved. " + @@ -268,7 +272,7 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa /** Properties array. */ private final ConnectionProperty[] propsArr = { distributedJoins, enforceJoinOrder, collocated, replicatedOnly, autoCloseServerCursor, - tcpNoDelay, lazy, socketSendBuffer, socketReceiveBuffer, skipReducerOnUpdate, + tcpNoDelay, lazy, loc, socketSendBuffer, socketReceiveBuffer, skipReducerOnUpdate, sslMode, sslCipherSuites, sslProtocol, sslKeyAlgorithm, sslClientCertificateKeyStoreUrl, sslClientCertificateKeyStorePassword, sslClientCertificateKeyStoreType, sslTrustCertificateKeyStoreUrl, sslTrustCertificateKeyStorePassword, sslTrustCertificateKeyStoreType, @@ -726,6 +730,16 @@ public class ConnectionPropertiesImpl implements ConnectionProperties, Serializa this.transactionLabel.setValue(transactionLabel); } + /** {@inheritDoc} */ + @Override public boolean isLocal() { + return loc.value(); + } + + /** {@inheritDoc} */ + @Override public void setLocal(boolean loc) { + this.loc.setValue(loc); + } + /** * @param url URL connection. * @param props Environment properties. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java index 1ce478c7c8649..ac5314a9772cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java @@ -317,6 +317,14 @@ public JdbcThinConnection(ConnectionProperties connProps) throws SQLException { holdability = isTxAwareQueriesSupported ? CLOSE_CURSORS_AT_COMMIT : HOLD_CURSORS_OVER_COMMIT; txIsolation = defaultTransactionIsolation(); + + if (connProps.isLocal()) { + if (connProps.getAddresses().length != 1 + || connProps.getAddresses()[0].portFrom() != connProps.getAddresses()[0].portTo()) { + LOG.warning("Local flag is supposed to be used only when exactly one address is specified, " + + "otherwise the local query may be executed on an unexpected node"); + } + } } /** Create new binary context. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java index 330affaf7737b..e1f1cf88c7608 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java @@ -319,7 +319,12 @@ private HandshakeResult handshake(ClientListenerProtocolVersion ver) throws IOEx } } - writer.writeByteArray(ThinProtocolFeature.featuresAsBytes(enabledFeatures())); + EnumSet enabledFeatures = enabledFeatures(); + + if (!connProps.isLocal()) + enabledFeatures.remove(JdbcThinFeature.LOCAL_QUERIES); + + writer.writeByteArray(ThinProtocolFeature.featuresAsBytes(enabledFeatures)); } if (ver.compareTo(VER_2_13_0) >= 0) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java index 47a94f37d4d3e..dc64906d18a7a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java @@ -279,8 +279,10 @@ public JdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin } }; + boolean loc = features.contains(JdbcThinFeature.LOCAL_QUERIES); + handler = new JdbcRequestHandler(busyLock, snd, maxCursors, distributedJoins, enforceJoinOrder, - collocated, replicatedOnly, autoCloseCursors, lazyExec, skipReducerOnUpdate, qryEngine, + collocated, replicatedOnly, autoCloseCursors, lazyExec, loc, skipReducerOnUpdate, qryEngine, dataPageScanEnabled, updateBatchSize, concurrency, isolation, timeout, lb, ver, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java index cd5d908706280..3a4a8091183b9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java @@ -181,6 +181,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler, ClientT * @param replicatedOnly Replicated only flag. * @param autoCloseCursors Flag to automatically close server cursors. * @param lazy Lazy query execution flag. + * @param loc Local query flag. * @param skipReducerOnUpdate Skip reducer on update flag. * @param qryEngine Name of SQL query engine to use. * @param dataPageScanEnabled Enable scan data page mode. @@ -202,6 +203,7 @@ public JdbcRequestHandler( boolean replicatedOnly, boolean autoCloseCursors, boolean lazy, + boolean loc, boolean skipReducerOnUpdate, @Nullable String qryEngine, @Nullable Boolean dataPageScanEnabled, @@ -232,6 +234,7 @@ public JdbcRequestHandler( collocated, replicatedOnly, lazy, + loc, skipReducerOnUpdate, dataPageScanEnabled, updateBatchSize, @@ -1118,6 +1121,7 @@ private void setupQuery(SqlFieldsQueryEx qry, String schemaName) { qry.setCollocated(cliCtx.isCollocated()); qry.setReplicatedOnly(cliCtx.isReplicatedOnly()); qry.setLazy(cliCtx.isLazy()); + qry.setLocal(cliCtx.isLocal()); qry.setSchema(schemaName); qry.setQueryInitiatorId(connCtx.clientDescriptor()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcThinFeature.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcThinFeature.java index f4cd046fbd6ab..f531b72bdee78 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcThinFeature.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcThinFeature.java @@ -40,7 +40,10 @@ public enum JdbcThinFeature implements ThinProtocolFeature { TX_AWARE_QUERIES(4), /** Send {@link Connection#setClientInfo(String, String)} with messages. */ - CLIENT_INFO(5); + CLIENT_INFO(5), + + /** Execute local queries. */ + LOCAL_QUERIES(6); /** */ private static final EnumSet ALL_FEATURES_AS_ENUM_SET = EnumSet.allOf(JdbcThinFeature.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java index eada467a534e9..2b9c87a6fa447 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java @@ -162,6 +162,7 @@ public OdbcRequestHandler( collocated, replicatedOnly, lazy, + false, skipReducerOnUpdate, null, null, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java index 0e45c6177bcdb..481ea3674c8e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/SqlClientContext.java @@ -57,6 +57,9 @@ public class SqlClientContext implements AutoCloseable { /** Lazy query execution flag. */ private final boolean lazy; + /** Local query flag. */ + private final boolean loc; + /** Skip reducer on update flag. */ private final boolean skipReducerOnUpdate; @@ -126,6 +129,7 @@ public class SqlClientContext implements AutoCloseable { * @param collocated Collocated flag. * @param replicatedOnly Replicated caches only flag. * @param lazy Lazy query execution flag. + * @param loc Local query flag. * @param skipReducerOnUpdate Skip reducer on update flag. * @param dataPageScanEnabled Enable scan data page mode. * @param updateBatchSize Size of internal batch for DML queries. @@ -142,6 +146,7 @@ public SqlClientContext(GridKernalContext ctx, boolean collocated, boolean replicatedOnly, boolean lazy, + boolean loc, boolean skipReducerOnUpdate, @Nullable Boolean dataPageScanEnabled, @Nullable Integer updateBatchSize, @@ -158,6 +163,7 @@ public SqlClientContext(GridKernalContext ctx, this.collocated = collocated; this.replicatedOnly = replicatedOnly; this.lazy = lazy; + this.loc = loc; this.skipReducerOnUpdate = skipReducerOnUpdate; this.dataPageScanEnabled = dataPageScanEnabled; this.updateBatchSize = updateBatchSize; @@ -261,6 +267,13 @@ public boolean isLazy() { return lazy; } + /** + * @return Local query flag. + */ + public boolean isLocal() { + return loc; + } + /** * @return Skip reducer on update flag, */