提交 80f69f1a authored 作者: noelgrandin's avatar noelgrandin

Make TRUNC and alias for TRUNCATE for compatibility with more databases.

Patch contributed by lukas.eder@gmail.com
上级 1f1226d1
...@@ -2785,7 +2785,7 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000) ...@@ -2785,7 +2785,7 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000)
" "
"Functions (Numeric)","TRUNCATE"," "Functions (Numeric)","TRUNCATE","
TRUNCATE(numeric, digitsInt) { TRUNC | TRUNCATE } (numeric, digitsInt)
"," ","
Truncates to a number of digits (to the next value closer to 0). Truncates to a number of digits (to the next value closer to 0).
This method returns a double. This method returns a double.
......
...@@ -22,6 +22,7 @@ Change Log ...@@ -22,6 +22,7 @@ Change Log
</li><li>The table INFORMATION_SCHEMA.FUNCTION_ALIASES now includes a column TYPE_NAME. </li><li>The table INFORMATION_SCHEMA.FUNCTION_ALIASES now includes a column TYPE_NAME.
</li><li>Issue 378: when using views, the wrong values were bound to a parameter in some cases. </li><li>Issue 378: when using views, the wrong values were bound to a parameter in some cases.
</li><li>Terrence Huang has translated the error messages to Chinese. Thanks a lot! </li><li>Terrence Huang has translated the error messages to Chinese. Thanks a lot!
</li><li>TRUNC was added as an alias for TRUNCATE
</li></ul> </li></ul>
<h2>Version 1.3.166 (2012-04-08)</h2> <h2>Version 1.3.166 (2012-04-08)</h2>
......
...@@ -201,6 +201,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -201,6 +201,8 @@ public class Function extends Expression implements FunctionCall {
addFunction("TAN", TAN, 1, Value.DOUBLE); addFunction("TAN", TAN, 1, Value.DOUBLE);
addFunction("TANH", TANH, 1, Value.DOUBLE); addFunction("TANH", TANH, 1, Value.DOUBLE);
addFunction("TRUNCATE", TRUNCATE, 2, Value.DOUBLE); addFunction("TRUNCATE", TRUNCATE, 2, Value.DOUBLE);
// same as TRUNCATE
addFunction("TRUNC", TRUNCATE, 2, Value.DOUBLE);
addFunction("HASH", HASH, 3, Value.BYTES); addFunction("HASH", HASH, 3, Value.BYTES);
addFunction("ENCRYPT", ENCRYPT, 3, Value.BYTES); addFunction("ENCRYPT", ENCRYPT, 3, Value.BYTES);
addFunction("DECRYPT", DECRYPT, 3, Value.BYTES); addFunction("DECRYPT", DECRYPT, 3, Value.BYTES);
......
...@@ -9253,6 +9253,12 @@ select truncate(null, null) en, truncate(1.99, 0) e1, truncate(-10.9, 0) em10 fr ...@@ -9253,6 +9253,12 @@ select truncate(null, null) en, truncate(1.99, 0) e1, truncate(-10.9, 0) em10 fr
> null 1.0 -10.0 > null 1.0 -10.0
> rows: 1 > rows: 1
select trunc(null, null) en, trunc(1.99, 0) e1, trunc(-10.9, 0) em10 from test;
> EN E1 EM10
> ---- --- -----
> null 1.0 -10.0
> rows: 1
select ascii(null) en, ascii('') en, ascii('Abc') e65 from test; select ascii(null) en, ascii('') en, ascii('Abc') e65 from test;
> EN EN E65 > EN EN E65
> ---- ---- --- > ---- ---- ---
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论