From d43afc6dd99b8a8a0923e213a88f8859bccd5e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=AF=97=E7=84=B1?= <3372848903@qq.com> Date: Tue, 10 Nov 2026 13:59:31 +0000 Subject: [PATCH] docs(v5.6): document blob/clob/nclob/long_raw types and 6 built-in functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.8 Built-in data types lists only 14 types although src/include/catalog/pg_type.dat defines sys.blob (domain over bytea), sys.clob and sys.nclob (domains over text) and sys.long_raw (domain over bytea). The built-in function list is missing six functions declared in contrib/ivorysql_ora/src/builtin_functions/builtin_functions--1.0.sql: bitand (both overloads), lpad, rpad, regexp_count, to_clob and to_blob. The same list also contains rawtohex, which does not exist on this branch (grep over the 5.6 tree finds nothing and select rawtohex('abc'::bytea) fails; the function is master-only), so that row is dropped. Add the four types to the type table, the six functions to the function table, and a short section per function (syntax / parameters / return value / example) in both the CN and EN trees. Every example output was captured from an IvorySQL 5.6 instance built from tag IvorySQL_5.6 (initdb -m oracle), including to_clob and to_blob. Closes # Signed-off-by: 王诗焱 <3372848903@qq.com> --- CN/modules/ROOT/pages/7.8.adoc | 127 ++++++++++++++++++++++++++++++++- EN/modules/ROOT/pages/7.8.adoc | 125 +++++++++++++++++++++++++++++++- 2 files changed, 249 insertions(+), 3 deletions(-) diff --git a/CN/modules/ROOT/pages/7.8.adoc b/CN/modules/ROOT/pages/7.8.adoc index 9c3d170d..2b75067b 100644 --- a/CN/modules/ROOT/pages/7.8.adoc +++ b/CN/modules/ROOT/pages/7.8.adoc @@ -22,6 +22,10 @@ |interval day to second |raw |long +|blob +|clob +|nclob +|long_raw |==== == 内置函数类型 @@ -47,7 +51,6 @@ |rtrim |length |lengthb -|rawtohex |replace |regexp_replace |regexp_substr @@ -75,6 +78,12 @@ |compose |decompose |sys_context +|bitand +|lpad +|rpad +|regexp_count +|to_clob +|to_blob |==== == 内置函数说明 @@ -1150,4 +1159,118 @@ ivorysql=# select sys_context('USERENV','DB_NAME'); ivorysql (1 row) -``` \ No newline at end of file +``` + +=== `BITAND` 函数 +功能:对两个数值按二进制位执行逻辑与(AND)运算,返回运算结果。 +语法: +``` +bitand(number, number) +bitand(text, text) +``` +参数说明: +- 第一个参数、第二个参数:参与按位与运算的两个数值;以字符串形式传入时会先转换为 `number` 再参与运算。 +返回值:`number`,即按位与的运算结果。 +示例: +``` +select bitand(6, 3) from dual; + bitand +-------- + 2 +(1 row) +``` + +=== `LPAD` 函数 +功能:在字符串左侧填充指定字符,直到字符串达到目标长度。 +语法: +``` +lpad(varchar2, number [, varchar2]) +``` +参数说明: +- 第一个参数:待填充的字符串。 +- 第二个参数:返回字符串的目标长度。 +- 第三个参数:填充字符,缺省为空格。 +返回值:`varchar2`。 +示例: +``` +select lpad('abc', 6, '*') from dual; + lpad +-------- + ***abc +(1 row) +``` + +=== `RPAD` 函数 +功能:在字符串右侧填充指定字符,直到字符串达到目标长度。 +语法: +``` +rpad(varchar2, number [, varchar2]) +``` +参数说明: +- 第一个参数:待填充的字符串。 +- 第二个参数:返回字符串的目标长度。 +- 第三个参数:填充字符,缺省为空格。 +返回值:`varchar2`。 +示例: +``` +select rpad('abc', 6, '*') from dual; + rpad +-------- + abc*** +(1 row) +``` + +=== `REGEXP_COUNT` 函数 +功能:统计正则表达式在字符串中匹配的次数。 +语法: +``` +regexp_count(varchar2, varchar2 [, number [, varchar2]]) +``` +参数说明: +- 第一个参数:待匹配的字符串。 +- 第二个参数:正则表达式。 +- 第三个参数:开始搜索的位置,缺省为 1。 +- 第四个参数:匹配模式,缺省为 `'g'`。 +返回值:`int`,即匹配次数。 +示例: +``` +select regexp_count('abcabc', 'a') from dual; + regexp_count +-------------- + 2 +(1 row) +``` + +=== `TO_CLOB` 函数 +功能:将 `varchar2` 转换为 Oracle 兼容的 `clob` 数据类型。 +语法: +``` +to_clob(varchar2) +``` +返回值:`clob`。 +说明:`clob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `text`,因此可以直接参与字符串相关的运算与比较。 +示例: +``` +select to_clob('IvorySQL') from dual; + to_clob +---------- + IvorySQL +(1 row) +``` + +=== `TO_BLOB` 函数 +功能:将 `varchar2` 转换为 Oracle 兼容的 `blob` 数据类型。 +语法: +``` +to_blob(varchar2) +``` +返回值:`blob`。 +说明:`blob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `bytea`。 +示例: +``` +select to_blob('IvorySQL') from dual; + to_blob +-------------------- + I766f727953514c +(1 row) +``` diff --git a/EN/modules/ROOT/pages/7.8.adoc b/EN/modules/ROOT/pages/7.8.adoc index 8150dedf..b151a757 100644 --- a/EN/modules/ROOT/pages/7.8.adoc +++ b/EN/modules/ROOT/pages/7.8.adoc @@ -22,6 +22,10 @@ |interval day to second |raw |long +|blob +|clob +|nclob +|long_raw |==== == Built-in functions @@ -47,7 +51,6 @@ |rtrim |length |lengthb -|rawtohex |replace |regexp_replace |regexp_substr @@ -75,6 +78,12 @@ |compose |decompose |sys_context +|bitand +|lpad +|rpad +|regexp_count +|to_clob +|to_blob |==== == Built-in function descriptions @@ -1149,3 +1158,117 @@ ivorysql=# select sys_context('USERENV','DB_NAME'); (1 row) ``` + +=== `BITAND` function +function: Returns the bitwise AND of two numbers. +Syntax: +``` +bitand(number, number) +bitand(text, text) +``` +Parameters: +- First parameter, second parameter: the two numbers to be combined by the bitwise AND operator; values passed as strings are converted to `number` first. +Returns: `number`, the result of the bitwise AND. +Example: +``` +select bitand(6, 3) from dual; + bitand +-------- + 2 +(1 row) +``` + +=== `LPAD` function +function: Pads the left side of a string with the given characters until the string reaches the requested length. +Syntax: +``` +lpad(varchar2, number [, varchar2]) +``` +Parameters: +- First parameter: the string to be padded. +- Second parameter: the target length of the returned string. +- Third parameter: the padding characters, a space by default. +Returns: `varchar2`. +Example: +``` +select lpad('abc', 6, '*') from dual; + lpad +-------- + ***abc +(1 row) +``` + +=== `RPAD` function +function: Pads the right side of a string with the given characters until the string reaches the requested length. +Syntax: +``` +rpad(varchar2, number [, varchar2]) +``` +Parameters: +- First parameter: the string to be padded. +- Second parameter: the target length of the returned string. +- Third parameter: the padding characters, a space by default. +Returns: `varchar2`. +Example: +``` +select rpad('abc', 6, '*') from dual; + rpad +-------- + abc*** +(1 row) +``` + +=== `REGEXP_COUNT` function +function: Counts how many times a regular expression matches in a string. +Syntax: +``` +regexp_count(varchar2, varchar2 [, number [, varchar2]]) +``` +Parameters: +- First parameter: the string to be searched. +- Second parameter: the regular expression. +- Third parameter: the position where the search starts, 1 by default. +- Fourth parameter: the match parameter, `'g'` by default. +Returns: `int`, the number of matches. +Example: +``` +select regexp_count('abcabc', 'a') from dual; + regexp_count +-------------- + 2 +(1 row) +``` + +=== `TO_CLOB` function +function: Converts a `varchar2` value to the Oracle-compatible `clob` data type. +Syntax: +``` +to_clob(varchar2) +``` +Returns: `clob`. +Note: `clob` is a domain type in the `sys` schema whose base type is `text`, so the result can be used directly in string operations and comparisons. +Example: +``` +select to_clob('IvorySQL') from dual; + to_clob +---------- + IvorySQL +(1 row) +``` + +=== `TO_BLOB` function +function: Converts a `varchar2` value to the Oracle-compatible `blob` data type. +Syntax: +``` +to_blob(varchar2) +``` +Returns: `blob`. +Note: `blob` is a domain type in the `sys` schema whose base type is `bytea`. +Example: +``` +select to_blob('IvorySQL') from dual; + to_blob +-------------------- + I766f727953514c +(1 row) +```