Skip to content

Commit 266e495

Browse files
authored
Merge branch 'master' into pgroonga
2 parents 6ef89df + 7e8ce9f commit 266e495

File tree

6 files changed

+118
-0
lines changed

6 files changed

+118
-0
lines changed

CN/modules/ROOT/nav.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
**** xref:master/6.3.7.adoc[嵌套子函数]
3636
**** xref:master/6.3.8.adoc[Force View]
3737
**** xref:master/6.3.9.adoc[大小写转换]
38+
**** xref:master/6.3.10.adoc[sys_guid 函数]
3839
*** 内置函数
3940
**** xref:master/6.4.1.adoc[sys_context]
4041
**** xref:master/6.4.2.adoc[userenv]
@@ -59,6 +60,7 @@
5960
*** xref:master/7.17.adoc[17、NLS 参数]
6061
*** xref:master/7.18.adoc[18、Force View]
6162
*** xref:master/7.19.adoc[19、嵌套子函数]
63+
*** xref:master/7.20.adoc[20、sys_guid 函数]
6264
** IvorySQL贡献指南
6365
*** xref:master/8.1.adoc[社区贡献指南]
6466
*** xref:master/8.2.adoc[asciidoc语法快速参考]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= sys_guid() 函数
7+
8+
== 目的
9+
10+
IvorySQL的sys_guid() 是一个强大的随机数产生函数,它产生并返回一个由16个字节组成的数据库级别唯一的标识符(原始值)。
11+
12+
== 实现说明
13+
14+
IvorySQL的sys_guid()函数通过修改插件uuid-ossp的代码实现。为了充分利用uuid的多种基础库,采用如下逻辑:
15+
16+
1. 如果系统有uuid-ossp,就使用uuid_make();
17+
2. 如果系统有uuid-e2fs,就使用 uuid_generate_random();
18+
3. 否则就调用 arc4random();
19+
20+
同时修改代码使得IvorySQL能够自动载入uuid-ossp插件。
21+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= sys_guid() 函数
7+
8+
== 目的
9+
10+
IvorySQL的sys_guid() 是一个强大的随机数产生函数,它产生并返回一个由16个字节组成的数据库级别唯一的标识符(原始值)。
11+
12+
== 使用示例
13+
14+
```
15+
highgo=# select sys_guid() from dual;
16+
sys_guid
17+
------------------------------------
18+
\x3ed9426c8a093442a38bea09a74f44a1
19+
(1 row)
20+
```
21+
22+
== sys_guid函数在建表时可以作为主键
23+
24+
```
25+
create table student
26+
(
27+
student_id raw(16) default sys_guid() primary key,
28+
student_name varchar2(100) not null
29+
);
30+
```
31+
32+
== 新增数据时自动填充主键
33+
34+
```
35+
insert into student(student_name) values ('Steven');
36+
```

EN/modules/ROOT/nav.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*** xref:master/6.3.7.adoc[Nested Subfunctions]
3535
*** xref:master/6.3.8.adoc[Force View]
3636
*** xref:master/6.3.9.adoc[Case Conversion]
37+
*** xref:master/6.3.10.adoc[sys_guid Function]
3738
** Built-in Functions
3839
*** xref:master/6.4.1.adoc[sys_context]
3940
*** xref:master/6.4.2.adoc[userenv]
@@ -58,6 +59,7 @@
5859
** xref:master/7.17.adoc[17、NLS Parameters]
5960
** xref:master/7.18.adoc[18、Force View]
6061
** xref:master/7.19.adoc[19、Nested Subfunctions]
62+
** xref:master/7.20.adoc[20、sys_guid Function]
6163
* xref:master/8.adoc[Community contribution]
6264
* xref:master/9.adoc[Tool Reference]
6365
* xref:master/10.adoc[FAQ]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= sys_guid() function
7+
8+
== Purpose
9+
10+
IvorySQL's sys_guid() is a powerful random number generation function that generates and returns a 16-byte database-level unique identifier (raw value).
11+
12+
== Implementation Description
13+
14+
The sys_guid() function of IvorySQL is implemented by modifying the code of the uuid-ossp plugin. To make full use of various underlying libraries of uuid, the following logic is adopted:
15+
16+
1. If the uuid-ossp exists in the system, uuid_make() will be used;
17+
2. If the uuid-e2fs exists in the system, uuid_generate_random() will be used;
18+
3. Otherwise use arc4random();
19+
20+
Meanwhile modify the code so that IvorySQL can load uuid-ossp extension automatically.
21+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= sys_guid() function
7+
8+
== Purpose
9+
10+
IvorySQL's sys_guid() is a powerful random number generation function that generates and returns a 16-byte database-level unique identifier (raw value).
11+
12+
== Usage example
13+
14+
```
15+
highgo=# select sys_guid() from dual;
16+
sys_guid
17+
------------------------------------
18+
\x3ed9426c8a093442a38bea09a74f44a1
19+
(1 row)
20+
```
21+
22+
== The sys_guid function can generate default values for primary keys when creating a table
23+
24+
```
25+
create table student
26+
(
27+
student_id raw(16) default sys_guid() primary key,
28+
student_name varchar2(100) not null
29+
);
30+
```
31+
32+
== The primary key is automatically populated when new data is added
33+
34+
```
35+
insert into student(student_name) values ('Steven');
36+
```

0 commit comments

Comments
 (0)