Hi,
I created patch which solve one issue of the roadmap: 
PostgreSQL compatibility: LOG(x) is LOG10(x) and not LN(x).

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/rRID0Z0-mB0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

### Eclipse Workspace Patch 1.0
#P h2
Index: h2/src/main/org/h2/expression/Function.java
===================================================================
--- h2/src/main/org/h2/expression/Function.java	(revision 4114)
+++ h2/src/main/org/h2/expression/Function.java	(working copy)
@@ -74,7 +74,7 @@
             CEILING = 8, COS = 9, COT = 10, DEGREES = 11, EXP = 12, FLOOR = 13, LOG = 14, LOG10 = 15, MOD = 16,
             PI = 17, POWER = 18, RADIANS = 19, RAND = 20, ROUND = 21, ROUNDMAGIC = 22, SIGN = 23, SIN = 24, SQRT = 25,
             TAN = 26, TRUNCATE = 27, SECURE_RAND = 28, HASH = 29, ENCRYPT = 30, DECRYPT = 31, COMPRESS = 32,
-            EXPAND = 33, ZERO = 34, RANDOM_UUID = 35, COSH = 36, SINH = 37, TANH = 38;
+            EXPAND = 33, ZERO = 34, RANDOM_UUID = 35, COSH = 36, SINH = 37, TANH = 38, LN = 39;
 
     public static final int ASCII = 50, BIT_LENGTH = 51, CHAR = 52, CHAR_LENGTH = 53, CONCAT = 54, DIFFERENCE = 55,
             HEXTORAW = 56, INSERT = 57, INSTR = 58, LCASE = 59, LEFT = 60, LENGTH = 61, LOCATE = 62, LTRIM = 63,
@@ -182,7 +182,7 @@
         addFunction("EXP", EXP, 1, Value.DOUBLE);
         addFunction("FLOOR", FLOOR, 1, Value.DOUBLE);
         addFunction("LOG", LOG, 1, Value.DOUBLE);
-        addFunction("LN", LOG, 1, Value.DOUBLE);
+        addFunction("LN", LN, 1, Value.DOUBLE);
         addFunction("LOG10", LOG10, 1, Value.DOUBLE);
         addFunction("MOD", MOD, 2, Value.LONG);
         addFunction("PI", PI, 0, Value.DOUBLE);
@@ -495,9 +495,17 @@
         case FLOOR:
             result = ValueDouble.get(Math.floor(v0.getDouble()));
             break;
-        case LOG:
+        case LN:
             result = ValueDouble.get(Math.log(v0.getDouble()));
             break;
+        case LOG: {
+            final Mode mode = Mode.getInstance("PostgreSQL");
+            if( database.getMode().equals(mode) )
+                result = ValueDouble.get(log10(v0.getDouble()));
+            else
+                result = ValueDouble.get(Math.log(v0.getDouble()));
+            break;
+        }
         case LOG10:
             result = ValueDouble.get(log10(v0.getDouble()));
             break;
Index: h2/src/test/org/h2/test/testSimple.in.txt
===================================================================
--- h2/src/test/org/h2/test/testSimple.in.txt	(revision 4114)
+++ h2/src/test/org/h2/test/testSimple.in.txt	(working copy)
@@ -777,4 +777,15 @@
 insert into test1 values ('abcaaaa');
 delete from test1;
 drop table test1;
-@reconnect;
\ No newline at end of file
+@reconnect;
+
+SET MODE POSTGRESQL;
+select log(2);
+> 0.301029995663981;
+select ln(2);
+> 0.6931471805599453;
+SET MODE REGULAR;
+select log(2);
+> 0.6931471805599453;
+select log10(2);
+> 0.301029995663981;

Reply via email to