Repository: ignite Updated Branches: refs/heads/ignite-5075 54b693585 -> a7cd1b637
IGNITE-5391: CREATE INDEX and DROP INDEX are now allowed on non-sql caches again :-) Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c7638bc4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c7638bc4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c7638bc4 Branch: refs/heads/ignite-5075 Commit: c7638bc46c32234eb3a37c81a30f1cd1e5d9c984 Parents: fbcd474 Author: devozerov <[email protected]> Authored: Fri Jun 2 12:43:59 2017 +0300 Committer: devozerov <[email protected]> Committed: Fri Jun 2 12:43:59 2017 +0300 ---------------------------------------------------------------------- .../processors/query/GridQueryProcessor.java | 10 -------- .../query/h2/ddl/DdlStatementsProcessor.java | 26 +------------------- .../DynamicIndexAbstractBasicSelfTest.java | 22 +++++------------ 3 files changed, 7 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c7638bc4/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index bfbfb6c..fef7d4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -358,14 +358,6 @@ public class GridQueryProcessor extends GridProcessorAdapter { msg.onError(new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND, cacheName)); } - else if (!cacheDesc.sql()) { - if (log.isDebugEnabled()) - log.debug("Received schema propose discovery message, but cache was not created through " + - "CREATE TABLE command (will report error) [opId=" + opId + ", msg=" + msg + ']');; - - msg.onError(new SchemaOperationException("CREATE INDEX and DROP INDEX operations are only allowed on " + - "caches created with CREATE TABLE command [cacheName=" + cacheName + ']')); - } else { CacheConfiguration ccfg = cacheDesc.cacheConfiguration(); @@ -601,8 +593,6 @@ public class GridQueryProcessor extends GridProcessorAdapter { boolean nop = false; if (cacheExists) { - assert cacheDesc.sql(); - if (cacheRegistered) { // If cache is started, we perform validation against real schema. T3<QueryTypeDescriptorImpl, Boolean, SchemaOperationException> res = prepareChangeOnStartedCache(op); http://git-wip-us.apache.org/repos/asf/ignite/blob/c7638bc4/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java index 7051f09..04a0c62 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java @@ -28,8 +28,6 @@ import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.QueryCursorImpl; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.query.GridQueryProperty; @@ -46,7 +44,6 @@ import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser; import org.apache.ignite.internal.processors.query.h2.sql.GridSqlStatement; import org.apache.ignite.internal.processors.query.schema.SchemaOperationException; import org.apache.ignite.internal.util.future.GridFinishedFuture; -import org.apache.ignite.internal.util.typedef.internal.A; import org.h2.command.Prepared; import org.h2.command.ddl.CreateIndex; import org.h2.command.ddl.CreateTable; @@ -104,8 +101,6 @@ public class DdlStatementsProcessor { if (tbl == null) throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_NOT_FOUND, cmd.tableName()); - checkSqlCache(tbl.cache()); - assert tbl.rowDescriptor() != null; QueryIndex newIdx = new QueryIndex(); @@ -134,13 +129,11 @@ public class DdlStatementsProcessor { newIdx, cmd.ifNotExists()); } else if (stmt0 instanceof GridSqlDropIndex) { - GridSqlDropIndex cmd = (GridSqlDropIndex)stmt0; + GridSqlDropIndex cmd = (GridSqlDropIndex) stmt0; GridH2Table tbl = idx.dataTableForIndex(cmd.schemaName(), cmd.indexName()); if (tbl != null) { - checkSqlCache(tbl.cache()); - fut = ctx.query().dynamicIndexDrop(tbl.cacheName(), cmd.schemaName(), cmd.indexName(), cmd.ifExists()); } @@ -280,23 +273,6 @@ public class DdlStatementsProcessor { } /** - * Check that given context corresponds to an SQL cache. - * @param cctx Cache context. - * @throws SchemaOperationException if given context does not correspond to an SQL cache. - */ - private static void checkSqlCache(GridCacheContext cctx) throws SchemaOperationException { - A.notNull(cctx, "cctx"); - - DynamicCacheDescriptor desc = cctx.grid().context().cache().cacheDescriptor(cctx.cacheId()); - - assert desc != null; - - if (!desc.sql()) - throw new SchemaOperationException("CREATE INDEX and DROP INDEX operations are only allowed on caches " + - "created with CREATE TABLE command [cacheName=" + cctx.name() + ']'); - } - - /** * @param cmd Statement. * @return Whether {@code cmd} is a DDL statement we're able to handle. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/c7638bc4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java index cf83319..0b6b0ca 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java @@ -897,28 +897,18 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst } /** - * Test that operations fail on statically configured cache. + * Test that operations work on statically configured cache. * * @throws Exception If failed. */ - public void testFailOnNonSqlCache() throws Exception { + public void testNonSqlCache() throws Exception { final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1)); - assertSchemaException(new RunnableX() { - @Override public void run() throws Exception { - dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true); - } - }, "CREATE INDEX and DROP INDEX operations are only allowed on caches created with CREATE TABLE command " + - "[cacheName=cache_static]", IgniteQueryErrorCode.UNKNOWN); - - assertNoIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_2); + dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true); + assertIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1_ESCAPED)); - assertSchemaException(new RunnableX() { - @Override public void run() throws Exception { - dynamicIndexDrop(STATIC_CACHE_NAME, IDX_NAME_1, true); - } - }, "CREATE INDEX and DROP INDEX operations are only allowed on caches created with CREATE TABLE command " + - "[cacheName=cache_static]", IgniteQueryErrorCode.UNKNOWN); + dynamicIndexDrop(STATIC_CACHE_NAME, IDX_NAME_1, true); + assertNoIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_1); } /**
