Skip to content

Commit c682e9a

Browse files
committed
Add english version of document
1 parent cfd4f62 commit c682e9a

3 files changed

Lines changed: 51 additions & 4 deletions

File tree

CN/modules/ROOT/pages/master/6.3.9.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
== 实现说明
1313

14-
如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c-->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。
14+
如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。
1515

1616
这个新启动的后端进程会通过下面的代码将 `identifier_case_switch` 信息写入 `pg_control` 文件:
1717

@@ -42,8 +42,6 @@ BackendMain()->BackendInitialize()-->ProcessStartupPacket()
4242
```
4343

4444
另外,在处理用户的 SQL 语句时,如果包含标识符,也会进行同样的处理,代码分布在:
45-
46-
```
4745
SplitIdentifierString(),quoteOneName() 和 SplitGUCList() 这几个函数中。
48-
```
46+
4947

EN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*** xref:master/6.3.4.adoc[%Type & %Rowtype]
2727
*** xref:master/6.3.5.adoc[NLS Parameters]
2828
*** xref:master/6.3.6.adoc[Function and stored procedure]
29+
*** xref:master/6.3.9.adoc[Case Conversion]
2930
** xref:master/6.4.adoc[GB18030 Character Set]
3031
* List of Oracle compatible features
3132
** xref:master/7.1.adoc[1、Ivorysql frame design]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= Quoted Identifier Case Conversion
7+
8+
== Purpose
9+
10+
To meet Oracle's quoted identifier case compatibility requirements, IvorySQL has designed three case conversion modes for quoted identifiers.
11+
12+
== Implementation Details
13+
14+
If the parameter `-C` is appended during database initialization, with values of `normal/interchange/lowercase`, the `Intidb.c->main()` function in the code will process this parameter and set the global variable `caseswitchmode` according to the parameter value. Then the `initdb` command will start a `postgres` process in `-boot` mode to set up the `template1` template database, while passing the parameter `-C ivorysql.identifier_case_switch=caseswitchmode` to the new process.
15+
16+
This newly started backend process will write the `identifier_case_switch` information to the `pg_control` file through the following code:
17+
18+
```
19+
BootstrapModeMain() -> BootStrapXLOG();
20+
/* save database compatible level value */
21+
ControlFile->dbmode = bootstrap_database_mode;
22+
ControlFile->casemode = identifier_case_switch;
23+
24+
/* some additional ControlFile fields are set in WriteControlFile() */
25+
WriteControlFile();
26+
```
27+
28+
When a user starts the database using the `pg_ctl` command, the `postmaster` process will read the contents of the `pg_control` file. The code call path is:
29+
30+
```
31+
PostmasterMain()-->SetCaseGucOption()-->GetCaseSwitchModeFromControl()
32+
```
33+
34+
After reading the parameter value, the `SetConfigOption()` function is called to assign the value.
35+
36+
When each new backend process starts, since it is forked from the `postmaster` process, it automatically has the same `ivorysql.identifier_case_switch` parameter value. First, it processes the `startup` packet, and if it contains `database` or `user` parameters, the parameter values are processed accordingly based on `identifier_case_switch`.
37+
38+
The source code is:
39+
40+
```
41+
BackendMain()->BackendInitialize()-->ProcessStartupPacket()
42+
```
43+
44+
Additionally, when processing user SQL statements, if they contain identifiers, the same processing is performed. The code is distributed in:
45+
SplitIdentifierString(), quoteOneName() and SplitGUCList() functions.
46+
47+
48+

0 commit comments

Comments
 (0)