Hi,

This thread made me see another possible 'problem', even with the fix in
the maximum cache size previously limited to 2GB, the command SET
CACHE_SIZE expects an integer value and in this case, the limit remains at
most 2GB. The new patch tries to fix this, I choose treat the setting value
as a String to avoid more changes in the code. Besides, I made no change in
the cache implementation for PageStore because it will be replaced by
MVStore in future, do you think this should be implemented in the
PageStore?

One last thing, if you accept the patch, the SQL Grammar documentation must
be updated too.

Regards,

Fred

2015-03-21 16:56 GMT-03:00 sim <sim...@mail.ru>:

> Thank you Fred.  Strangely, because when I was starting to play with cache
> size
> cache_max_size showed 16 and cache_size showed 15. Now it is not changing
> at all.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to h2-database+unsubscr...@googlegroups.com.
> To post to this group, send email to h2-database@googlegroups.com.
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/fred/Dropbox/h2-trunk/trunk/h2/src/main/org/h2
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: command/dml/Set.java
--- command/dml/Set.java Base (BASE)
+++ command/dml/Set.java Modificado Localmente (Baseado em LOCAL)
@@ -83,13 +83,14 @@
             break;
         }
         case SetTypes.CACHE_SIZE:
-            if (getIntValue() < 0) {
+            long cacheSize = getLongValue();
+            if (cacheSize < 0) {
                 throw DbException.getInvalidValueException("CACHE_SIZE",
-                        getIntValue());
+                        cacheSize);
             }
             session.getUser().checkAdmin();
-            database.setCacheSize(getIntValue());
-            addOrUpdateSetting(name, null, getIntValue());
+            database.setCacheSize(cacheSize);
+            addOrUpdateSetting(name, String.valueOf(cacheSize), 0);
             break;
         case SetTypes.CLUSTER: {
             if (Constants.CLUSTERING_ENABLED.equals(stringValue)) {
@@ -488,6 +489,11 @@
         return expression.getValue(session).getInt();
     }
 
+    private long getLongValue() {
+        expression = expression.optimize(session);
+        return expression.getValue(session).getLong();
+    }
+
     public void setInt(int value) {
         this.expression = ValueExpression.get(ValueInt.get(value));
     }
Index: engine/Database.java
--- engine/Database.java Base (BASE)
+++ engine/Database.java Modificado Localmente (Baseado em LOCAL)
@@ -169,7 +169,7 @@
     private volatile int checkpointAllowed;
     private volatile boolean checkpointRunning;
     private final Object reconnectSync = new Object();
-    private int cacheSize;
+    private long cacheSize;
     private int compactMode;
     private SourceCompiler compiler;
     private volatile boolean metaTablesInitialized;
@@ -1816,17 +1816,17 @@
         return traceSystem;
     }
 
-    public synchronized void setCacheSize(int kb) {
+    public synchronized void setCacheSize(long kb) {
         if (starting) {
             int max = MathUtils.convertLongToInt(Utils.getMemoryMax()) / 2;
             kb = Math.min(kb, max);
         }
         cacheSize = kb;
         if (pageStore != null) {
-            pageStore.getCache().setMaxMemory(kb);
+            pageStore.getCache().setMaxMemory((int)kb);
         }
         if (mvStore != null) {
-            mvStore.setCacheSize(Math.max(1, kb / 1024));
+            mvStore.setCacheSize(Math.max(1, kb));
         }
     }
 
@@ -2389,7 +2389,7 @@
         }
         if (pageStore == null) {
             pageStore = new PageStore(this, databaseName +
-                    Constants.SUFFIX_PAGE_FILE, accessModeData, cacheSize);
+                    Constants.SUFFIX_PAGE_FILE, accessModeData, (int)cacheSize);
             if (pageSize != Constants.DEFAULT_PAGE_SIZE) {
                 pageStore.setPageSize(pageSize);
             }
Index: mvstore/db/MVTableEngine.java
--- mvstore/db/MVTableEngine.java Base (BASE)
+++ mvstore/db/MVTableEngine.java Modificado Localmente (Baseado em LOCAL)
@@ -285,8 +285,8 @@
             return result;
         }
 
-        public void setCacheSize(int kb) {
-            store.setCacheSize(Math.max(1, kb / 1024));
+        public void setCacheSize(long kb) {
+            store.setCacheSize(Math.max(1, (int)(kb / 1024l)));
         }
 
         public InputStream getInputStream() {

Reply via email to