Skip to content

Commit d43afc6

Browse files
committed
docs(v5.6): document blob/clob/nclob/long_raw types and 6 built-in functions
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 #<ISSUE_NUMBER> Signed-off-by: 王诗焱 <3372848903@qq.com>
1 parent 7c3f4a6 commit d43afc6

2 files changed

Lines changed: 249 additions & 3 deletions

File tree

‎CN/modules/ROOT/pages/7.8.adoc‎

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
|interval day to second
2323
|raw
2424
|long
25+
|blob
26+
|clob
27+
|nclob
28+
|long_raw
2529
|====
2630

2731
== 内置函数类型
@@ -47,7 +51,6 @@
4751
|rtrim
4852
|length
4953
|lengthb
50-
|rawtohex
5154
|replace
5255
|regexp_replace
5356
|regexp_substr
@@ -75,6 +78,12 @@
7578
|compose
7679
|decompose
7780
|sys_context
81+
|bitand
82+
|lpad
83+
|rpad
84+
|regexp_count
85+
|to_clob
86+
|to_blob
7887
|====
7988

8089
== 内置函数说明
@@ -1150,4 +1159,118 @@ ivorysql=# select sys_context('USERENV','DB_NAME');
11501159
ivorysql
11511160
(1 row)
11521161
1153-
```
1162+
```
1163+
1164+
=== `BITAND` 函数
1165+
功能:对两个数值按二进制位执行逻辑与(AND)运算,返回运算结果。
1166+
语法:
1167+
```
1168+
bitand(number, number)
1169+
bitand(text, text)
1170+
```
1171+
参数说明:
1172+
- 第一个参数、第二个参数:参与按位与运算的两个数值;以字符串形式传入时会先转换为 `number` 再参与运算。
1173+
返回值:`number`,即按位与的运算结果。
1174+
示例:
1175+
```
1176+
select bitand(6, 3) from dual;
1177+
bitand
1178+
--------
1179+
2
1180+
(1 row)
1181+
```
1182+
1183+
=== `LPAD` 函数
1184+
功能:在字符串左侧填充指定字符,直到字符串达到目标长度。
1185+
语法:
1186+
```
1187+
lpad(varchar2, number [, varchar2])
1188+
```
1189+
参数说明:
1190+
- 第一个参数:待填充的字符串。
1191+
- 第二个参数:返回字符串的目标长度。
1192+
- 第三个参数:填充字符,缺省为空格。
1193+
返回值:`varchar2`。
1194+
示例:
1195+
```
1196+
select lpad('abc', 6, '*') from dual;
1197+
lpad
1198+
--------
1199+
***abc
1200+
(1 row)
1201+
```
1202+
1203+
=== `RPAD` 函数
1204+
功能:在字符串右侧填充指定字符,直到字符串达到目标长度。
1205+
语法:
1206+
```
1207+
rpad(varchar2, number [, varchar2])
1208+
```
1209+
参数说明:
1210+
- 第一个参数:待填充的字符串。
1211+
- 第二个参数:返回字符串的目标长度。
1212+
- 第三个参数:填充字符,缺省为空格。
1213+
返回值:`varchar2`。
1214+
示例:
1215+
```
1216+
select rpad('abc', 6, '*') from dual;
1217+
rpad
1218+
--------
1219+
abc***
1220+
(1 row)
1221+
```
1222+
1223+
=== `REGEXP_COUNT` 函数
1224+
功能:统计正则表达式在字符串中匹配的次数。
1225+
语法:
1226+
```
1227+
regexp_count(varchar2, varchar2 [, number [, varchar2]])
1228+
```
1229+
参数说明:
1230+
- 第一个参数:待匹配的字符串。
1231+
- 第二个参数:正则表达式。
1232+
- 第三个参数:开始搜索的位置,缺省为 1。
1233+
- 第四个参数:匹配模式,缺省为 `'g'`。
1234+
返回值:`int`,即匹配次数。
1235+
示例:
1236+
```
1237+
select regexp_count('abcabc', 'a') from dual;
1238+
regexp_count
1239+
--------------
1240+
2
1241+
(1 row)
1242+
```
1243+
1244+
=== `TO_CLOB` 函数
1245+
功能:将 `varchar2` 转换为 Oracle 兼容的 `clob` 数据类型。
1246+
语法:
1247+
```
1248+
to_clob(varchar2)
1249+
```
1250+
返回值:`clob`。
1251+
说明:`clob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `text`,因此可以直接参与字符串相关的运算与比较。
1252+
示例:
1253+
```
1254+
select to_clob('IvorySQL') from dual;
1255+
to_clob
1256+
----------
1257+
IvorySQL
1258+
(1 row)
1259+
```
1260+
1261+
=== `TO_BLOB` 函数
1262+
功能:将 `varchar2` 转换为 Oracle 兼容的 `blob` 数据类型。
1263+
语法:
1264+
```
1265+
to_blob(varchar2)
1266+
```
1267+
返回值:`blob`。
1268+
说明:`blob` 是 `sys` 模式下的域(domain)类型,底层数据类型为 `bytea`。
1269+
示例:
1270+
```
1271+
select to_blob('IvorySQL') from dual;
1272+
to_blob
1273+
--------------------
1274+
I766f727953514c
1275+
(1 row)
1276+
```

‎EN/modules/ROOT/pages/7.8.adoc‎

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
|interval day to second
2323
|raw
2424
|long
25+
|blob
26+
|clob
27+
|nclob
28+
|long_raw
2529
|====
2630

2731
== Built-in functions
@@ -47,7 +51,6 @@
4751
|rtrim
4852
|length
4953
|lengthb
50-
|rawtohex
5154
|replace
5255
|regexp_replace
5356
|regexp_substr
@@ -75,6 +78,12 @@
7578
|compose
7679
|decompose
7780
|sys_context
81+
|bitand
82+
|lpad
83+
|rpad
84+
|regexp_count
85+
|to_clob
86+
|to_blob
7887
|====
7988

8089
== Built-in function descriptions
@@ -1149,3 +1158,117 @@ ivorysql=# select sys_context('USERENV','DB_NAME');
11491158
(1 row)
11501159
11511160
```
1161+
1162+
=== `BITAND` function
1163+
function: Returns the bitwise AND of two numbers.
1164+
Syntax:
1165+
```
1166+
bitand(number, number)
1167+
bitand(text, text)
1168+
```
1169+
Parameters:
1170+
- First parameter, second parameter: the two numbers to be combined by the bitwise AND operator; values passed as strings are converted to `number` first.
1171+
Returns: `number`, the result of the bitwise AND.
1172+
Example:
1173+
```
1174+
select bitand(6, 3) from dual;
1175+
bitand
1176+
--------
1177+
2
1178+
(1 row)
1179+
```
1180+
1181+
=== `LPAD` function
1182+
function: Pads the left side of a string with the given characters until the string reaches the requested length.
1183+
Syntax:
1184+
```
1185+
lpad(varchar2, number [, varchar2])
1186+
```
1187+
Parameters:
1188+
- First parameter: the string to be padded.
1189+
- Second parameter: the target length of the returned string.
1190+
- Third parameter: the padding characters, a space by default.
1191+
Returns: `varchar2`.
1192+
Example:
1193+
```
1194+
select lpad('abc', 6, '*') from dual;
1195+
lpad
1196+
--------
1197+
***abc
1198+
(1 row)
1199+
```
1200+
1201+
=== `RPAD` function
1202+
function: Pads the right side of a string with the given characters until the string reaches the requested length.
1203+
Syntax:
1204+
```
1205+
rpad(varchar2, number [, varchar2])
1206+
```
1207+
Parameters:
1208+
- First parameter: the string to be padded.
1209+
- Second parameter: the target length of the returned string.
1210+
- Third parameter: the padding characters, a space by default.
1211+
Returns: `varchar2`.
1212+
Example:
1213+
```
1214+
select rpad('abc', 6, '*') from dual;
1215+
rpad
1216+
--------
1217+
abc***
1218+
(1 row)
1219+
```
1220+
1221+
=== `REGEXP_COUNT` function
1222+
function: Counts how many times a regular expression matches in a string.
1223+
Syntax:
1224+
```
1225+
regexp_count(varchar2, varchar2 [, number [, varchar2]])
1226+
```
1227+
Parameters:
1228+
- First parameter: the string to be searched.
1229+
- Second parameter: the regular expression.
1230+
- Third parameter: the position where the search starts, 1 by default.
1231+
- Fourth parameter: the match parameter, `'g'` by default.
1232+
Returns: `int`, the number of matches.
1233+
Example:
1234+
```
1235+
select regexp_count('abcabc', 'a') from dual;
1236+
regexp_count
1237+
--------------
1238+
2
1239+
(1 row)
1240+
```
1241+
1242+
=== `TO_CLOB` function
1243+
function: Converts a `varchar2` value to the Oracle-compatible `clob` data type.
1244+
Syntax:
1245+
```
1246+
to_clob(varchar2)
1247+
```
1248+
Returns: `clob`.
1249+
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.
1250+
Example:
1251+
```
1252+
select to_clob('IvorySQL') from dual;
1253+
to_clob
1254+
----------
1255+
IvorySQL
1256+
(1 row)
1257+
```
1258+
1259+
=== `TO_BLOB` function
1260+
function: Converts a `varchar2` value to the Oracle-compatible `blob` data type.
1261+
Syntax:
1262+
```
1263+
to_blob(varchar2)
1264+
```
1265+
Returns: `blob`.
1266+
Note: `blob` is a domain type in the `sys` schema whose base type is `bytea`.
1267+
Example:
1268+
```
1269+
select to_blob('IvorySQL') from dual;
1270+
to_blob
1271+
--------------------
1272+
I766f727953514c
1273+
(1 row)
1274+
```

0 commit comments

Comments
 (0)