File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 2626**** xref:master/6.3.2.adoc[OUT 参数]
2727**** xref:master/6.3.4.adoc[%TYPE、%ROWTYPE]
2828**** xref:master/6.3.5.adoc[NLS 参数]
29+ **** xref:master/6.3.6.adoc[大小写转换]
2930*** xref:master/6.4.adoc[国标GB18030]
3031** Oracle兼容功能列表
3132*** xref:master/7.1.adoc[1、框架设计]
Original file line number Diff line number Diff line change 1+ :sectnums:
2+ :sectnumlevels: 5
3+
4+ :imagesdir: ./_images
5+
6+ = 引用标识符大小写转换
7+
8+ == 目的
9+
10+ 为了满足Oracle的引用标识符大小写兼容,ivorysql设计了三种引用标识符的大小写转换模式。
11+
12+ == 实现说明
13+
14+ 如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c-->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。
15+
16+ 这个新启动的后端进程会通过下面的代码将 `identifier_case_switch` 信息写入 `pg_control` 文件:
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+ 当用户使用 `pg_ctl` 命令启动数据库时,`postmaster` 进程会读取 `pg_control` 文件的内容,代码调用路径为:
29+
30+ ```
31+ PostmasterMain()-->SetCaseGucOption()-->GetCaseSwitchModeFromControl()
32+ ```
33+
34+ 读取到参数值后调用 `SetConfigOption()` 函数进行赋值。
35+
36+ 在每个新的后端进程开始的时候,由于是从 `postmaster` 进程 `fork` 而来,会自动拥有相同的 `ivorysql.identifier_case_switch` 参数值。首先处理 `startup` 包,其中如果包含 `database` 或者 `user` 这两个参数,则根据 `identifier_case_switch` 对参数值做相应的处理。
37+
38+ 源代码为:
39+
40+ ```
41+ BackendMain()->BackendInitialize()-->ProcessStartupPacket()
42+ ```
43+
44+ 另外,在处理用户的 SQL 语句时,如果包含标识符,也会进行同样的处理,代码分布在:
45+
46+ ```
47+ SplitIdentifierString(),quoteOneName() 和 SplitGUCList() 这几个函数中。
48+ ```
49+
You can’t perform that action at this time.
0 commit comments