You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/05/07 15:21:45 UTC

[ignite] 37/41: GG-14999 SQL: Disallow new cache creation with non-default precision/scale fields on rolling upgrade

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch gg-18540
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit c9e802bae241afe8d06f1c529e9ac46466494443
Author: tledkov <tl...@gridgain.com>
AuthorDate: Mon May 6 12:56:25 2019 +0300

    GG-14999 SQL: Disallow new cache creation with non-default precision/scale fields on rolling upgrade
---
 .../processors/cache/GridCacheProcessor.java       | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 363b1a9..f4bff0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -167,6 +167,7 @@ import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.lifecycle.LifecycleAware;
 import org.apache.ignite.marshaller.Marshaller;
@@ -236,6 +237,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     private final boolean keepStaticCacheConfiguration = IgniteSystemProperties.getBoolean(
         IgniteSystemProperties.IGNITE_KEEP_STATIC_CACHE_CONFIGURATION);
 
+    /** Supports non default precision and scale for DECIMAL and VARCHAR types. */
+    private static final IgniteProductVersion PRECISION_SCALE_SINCE_VER = IgniteProductVersion.fromString("2.7.0");
+
     /** Shared cache context. */
     private GridCacheSharedContext<?, ?> sharedCtx;
 
@@ -685,7 +689,23 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     ", cacheType=" + cacheType + "]");
             }
         }
-    }
+
+        Collection<QueryEntity> ents = cc.getQueryEntities();
+
+        if (ctx.discovery().discoCache() != null) {
+            boolean nonDfltPrecScaleExists = ents.stream().anyMatch(
+                e -> !F.isEmpty(e.getFieldsPrecision()) || !F.isEmpty(e.getFieldsScale()));
+
+            if (nonDfltPrecScaleExists) {
+                ClusterNode oldestNode = ctx.discovery().discoCache().oldestServerNode();
+
+                if (PRECISION_SCALE_SINCE_VER.compareTo(oldestNode.version()) > 0) {
+                    throw new IgniteCheckedException("Non default precision and scale is supported since version 2.7. " +
+                        "The node with oldest version [node=" + oldestNode + ']');
+                }
+            }
+        }
+   }
 
     /**
      * @param ctx Context.