提交 a21876c1 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #397 from stevemcleod/bitget_function

Added BITGET function
......@@ -2796,6 +2796,17 @@ See also Java operator &.
BITAND(A, B)
"
"Functions (Numeric)","BITGET","
BITGET(long, int)
","
Returns true if and only if the first parameter has a bit set in the
position specified by the second parameter.
This method returns a boolean.
The second parameter is zero-indexed; the least significant bit has position 0.
","
BITGET(A, 1)
"
"Functions (Numeric)","BITOR","
BITOR(long, long)
","
......
......@@ -21,9 +21,11 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Added BITGET function
</li>
<li>Fixed bug in FilePathRetryOnInterrupt that caused infinite loop
</li>
<li>PR #389, Handle LocalTime with nanosecond resolution, patch by katzyn
</li>
<li>PR #389, Handle LocalTime with nanosecond resolution, patch by katzyn
</li>
<li>PR #382, Recover for "page store" H2 breaks LOBs consistency, patch by vitalus
</li>
......
......@@ -82,7 +82,8 @@ public class Function extends Expression implements FunctionCall {
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, LN = 39;
RANDOM_UUID = 35, COSH = 36, SINH = 37, TANH = 38, LN = 39,
BITGET=40;
public static final int ASCII = 50, BIT_LENGTH = 51, CHAR = 52,
CHAR_LENGTH = 53, CONCAT = 54, DIFFERENCE = 55, HEXTORAW = 56,
......@@ -208,6 +209,7 @@ public class Function extends Expression implements FunctionCall {
addFunction("ATAN", ATAN, 1, Value.DOUBLE);
addFunction("ATAN2", ATAN2, 2, Value.DOUBLE);
addFunction("BITAND", BITAND, 2, Value.LONG);
addFunction("BITGET", BITGET, 2, Value.BOOLEAN);
addFunction("BITOR", BITOR, 2, Value.LONG);
addFunction("BITXOR", BITXOR, 2, Value.LONG);
addFunction("CEILING", CEILING, 1, Value.DOUBLE);
......@@ -1208,6 +1210,9 @@ public class Function extends Expression implements FunctionCall {
case BITAND:
result = ValueLong.get(v0.getLong() & v1.getLong());
break;
case BITGET:
result = ValueBoolean.get((v0.getLong() & (1L << v1.getInt())) != 0);
break;
case BITOR:
result = ValueLong.get(v0.getLong() | v1.getLong());
break;
......
......@@ -3055,6 +3055,13 @@ select min(8=bitand(12, PARSE_INT2(SUBSTRING(random_uuid(), 20,1), 16))) from sy
> TRUE
> rows: 1
select BITGET(x, 0) AS IS_SET from system_range(1, 2);
> IS_SET
> ---------------------------------------------------------------------------
> TRUE
> FALSE
> rows: 2
drop alias PARSE_INT2;
> ok
......
......@@ -728,4 +728,4 @@ experiment throughout staging booth akkuzin observed maxinplace russian
ema sch bodewig forbid compat calc midway prohibit measuring playing kostya
pstmt rosenbaum pretending inverse safer lived blo sane othe multiplicative
introduces bcd nave picking templating clamp temporal berlin intermittently
pstat props
\ No newline at end of file
pstat props bitget travis
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论