From ac8e0cf99bb3e277677a68a599b0d432049e30ec Mon Sep 17 00:00:00 2001 From: zhangstar333 <2561612514@qq.com> Date: Fri, 18 Oct 2024 17:42:45 +0800 Subject: [PATCH 1/2] [doc](function)support bit_test function --- .../bitwise-functions/bit_test.md | 56 +++++++++++++++++++ .../bitwise-functions/bit_test.md | 56 +++++++++++++++++++ sidebars.json | 1 + 3 files changed, 113 insertions(+) create mode 100644 docs/sql-manual/sql-functions/bitwise-functions/bit_test.md create mode 100644 i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md diff --git a/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md b/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md new file mode 100644 index 0000000000000..69e2cfca410f2 --- /dev/null +++ b/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md @@ -0,0 +1,56 @@ +--- +{ +"title": "BIT_TEST", +"language": "en" +} +--- + + + +## bit_test +### description +#### Syntax + +`bit_test(Integer-type lhs, Integer-type rhs, '......')` + +"Convert the value of 'value' into binary form and return the value at the specified position 'pos', where 'pos' starts from 0 and goes from right to left. If there are multiple values for 'pos', combine the values at multiple 'pos' positions using the AND operator and return the final result. Integer ranges: TINYINT, SMALLINT, INT, BIGINT, LARGEINT." + +### example + +### example + +mysql [(none)]>SELECT bit_test(43, 1); ++-----------------+ +| bit_test(43, 1) | ++-----------------+ +| 1 | ++-----------------+ + +mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2); ++-----------------------------+ +| bit_test(43, 0, 1, 3, 5, 2) | ++-----------------------------+ +| 0 | ++-----------------------------+ +``` + +### keywords + + bit_test,bit_test_all diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md new file mode 100644 index 0000000000000..13a686075b49e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md @@ -0,0 +1,56 @@ +--- +{ +"title": "BIT_TEST", +"language": "zh-CN" +} +--- + + + +## bit_test +### description +#### Syntax + +`bit_test(Integer-type value, Integer-type pos, '......')` + +将value的值转换为二进制的形式,返回指定位置pos的值,pos从0开始,从右到左。 +如果pos 有多个值,则将多个pos位置上的值用与运算符结合起来,返回最终结果。 +整数范围:TINYINT、SMALLINT、INT、BIGINT、LARGEINT + +### example + +mysql [(none)]>SELECT bit_test(43, 1); ++-----------------+ +| bit_test(43, 1) | ++-----------------+ +| 1 | ++-----------------+ + +mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2); ++-----------------------------+ +| bit_test(43, 0, 1, 3, 5, 2) | ++-----------------------------+ +| 0 | ++-----------------------------+ +``` + +### keywords + + bit_test,bit_test_all diff --git a/sidebars.json b/sidebars.json index 52d7ab2bdbde3..a4d8a4134a8a1 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1063,6 +1063,7 @@ "label": "Bitwise Functions", "items": [ "sql-manual/sql-functions/bitwise-functions/bitand", + "sql-manual/sql-functions/bitwise-functions/bit_test", "sql-manual/sql-functions/bitwise-functions/bitor", "sql-manual/sql-functions/bitwise-functions/bitxor", "sql-manual/sql-functions/bitwise-functions/bitnot", From 289f7997906f1d3f92b00ac8abc98a3ce2f350ec Mon Sep 17 00:00:00 2001 From: zhangstar333 <2561612514@qq.com> Date: Mon, 21 Oct 2024 11:21:47 +0800 Subject: [PATCH 2/2] update --- .../sql-functions/bitwise-functions/bit_test.md | 13 +++++++++++-- .../sql-functions/bitwise-functions/bit_test.md | 10 +++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md b/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md index 69e2cfca410f2..dcb6a80c8aba3 100644 --- a/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md +++ b/docs/sql-manual/sql-functions/bitwise-functions/bit_test.md @@ -28,9 +28,11 @@ under the License. ### description #### Syntax -`bit_test(Integer-type lhs, Integer-type rhs, '......')` +`bit_test(Integer-type value, Integer-type pos, '......')` -"Convert the value of 'value' into binary form and return the value at the specified position 'pos', where 'pos' starts from 0 and goes from right to left. If there are multiple values for 'pos', combine the values at multiple 'pos' positions using the AND operator and return the final result. Integer ranges: TINYINT, SMALLINT, INT, BIGINT, LARGEINT." +"Convert the value of 'value' into binary form and return the value at the specified position 'pos', where 'pos' starts from 0 and goes from right to left. If there are multiple values for 'pos', combine the values at multiple 'pos' positions using the AND operator and return the final result. +If the value of pos is negative or exceeds the total number of bits in value, the result will be 0. +Integer value ranges: TINYINT, SMALLINT, INT, BIGINT, LARGEINT." ### example @@ -43,6 +45,13 @@ mysql [(none)]>SELECT bit_test(43, 1); | 1 | +-----------------+ +mysql [(none)]>select bit_test(43,-1); ++------------------+ +| bit_test(43, -1) | ++------------------+ +| 0 | ++------------------+ + mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2); +-----------------------------+ | bit_test(43, 0, 1, 3, 5, 2) | diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md index 13a686075b49e..4a140eb167636 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/bitwise-functions/bit_test.md @@ -32,7 +32,8 @@ under the License. 将value的值转换为二进制的形式,返回指定位置pos的值,pos从0开始,从右到左。 如果pos 有多个值,则将多个pos位置上的值用与运算符结合起来,返回最终结果。 -整数范围:TINYINT、SMALLINT、INT、BIGINT、LARGEINT +如果pos 的取值为负数或者超过value的bit位总数,则会返回结果为0. +整数value范围:TINYINT、SMALLINT、INT、BIGINT、LARGEINT ### example @@ -43,6 +44,13 @@ mysql [(none)]>SELECT bit_test(43, 1); | 1 | +-----------------+ +mysql [(none)]>select bit_test(43,-1); ++------------------+ +| bit_test(43, -1) | ++------------------+ +| 0 | ++------------------+ + mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2); +-----------------------------+ | bit_test(43, 0, 1, 3, 5, 2) |