From cfd4f628068dc44dfb832aefb632b6c2b7662aeb Mon Sep 17 00:00:00 2001 From: yuan li Date: Fri, 24 Oct 2025 14:38:49 +0800 Subject: [PATCH 1/2] add case conversion document --- CN/modules/ROOT/nav.adoc | 1 + CN/modules/ROOT/pages/master/5.2.adoc | 2 +- CN/modules/ROOT/pages/master/6.3.9.adoc | 49 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 CN/modules/ROOT/pages/master/6.3.9.adoc diff --git a/CN/modules/ROOT/nav.adoc b/CN/modules/ROOT/nav.adoc index d0f86121..c02caf95 100644 --- a/CN/modules/ROOT/nav.adoc +++ b/CN/modules/ROOT/nav.adoc @@ -27,6 +27,7 @@ **** xref:master/6.3.4.adoc[%TYPE、%ROWTYPE] **** xref:master/6.3.5.adoc[NLS 参数] **** xref:master/6.3.6.adoc[函数与存储过程] +**** xref:master/6.3.9.adoc[大小写转换] *** xref:master/6.4.adoc[国标GB18030] ** Oracle兼容功能列表 *** xref:master/7.1.adoc[1、框架设计] diff --git a/CN/modules/ROOT/pages/master/5.2.adoc b/CN/modules/ROOT/pages/master/5.2.adoc index 409992b9..cdde9528 100644 --- a/CN/modules/ROOT/pages/master/5.2.adoc +++ b/CN/modules/ROOT/pages/master/5.2.adoc @@ -35,7 +35,7 @@ export PG_CONFIG=/usr/local/ivorysql/ivorysql-4/bin/pg_config ** 拉取pg_vector源码 ``` -git clone --branch v0.6.2 https://github.com/pgvector/pgvector.git +git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git ``` ** 安装 pgvector diff --git a/CN/modules/ROOT/pages/master/6.3.9.adoc b/CN/modules/ROOT/pages/master/6.3.9.adoc new file mode 100644 index 00000000..f798bda9 --- /dev/null +++ b/CN/modules/ROOT/pages/master/6.3.9.adoc @@ -0,0 +1,49 @@ +:sectnums: +:sectnumlevels: 5 + +:imagesdir: ./_images + += 引用标识符大小写转换 + +== 目的 + +为了满足Oracle的引用标识符大小写兼容,ivorysql设计了三种引用标识符的大小写转换模式。 + +== 实现说明 + +如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c-->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。 + +这个新启动的后端进程会通过下面的代码将 `identifier_case_switch` 信息写入 `pg_control` 文件: + +``` +BootstrapModeMain() -> BootStrapXLOG(); + /* save database compatible level value */ + ControlFile->dbmode = bootstrap_database_mode; + ControlFile->casemode = identifier_case_switch; + + /* some additional ControlFile fields are set in WriteControlFile() */ + WriteControlFile(); +``` + +当用户使用 `pg_ctl` 命令启动数据库时,`postmaster` 进程会读取 `pg_control` 文件的内容,代码调用路径为: + +``` +PostmasterMain()-->SetCaseGucOption()-->GetCaseSwitchModeFromControl() +``` + +读取到参数值后调用 `SetConfigOption()` 函数进行赋值。 + +在每个新的后端进程开始的时候,由于是从 `postmaster` 进程 `fork` 而来,会自动拥有相同的 `ivorysql.identifier_case_switch` 参数值。首先处理 `startup` 包,其中如果包含 `database` 或者 `user` 这两个参数,则根据 `identifier_case_switch` 对参数值做相应的处理。 + +源代码为: + +``` +BackendMain()->BackendInitialize()-->ProcessStartupPacket() +``` + +另外,在处理用户的 SQL 语句时,如果包含标识符,也会进行同样的处理,代码分布在: + +``` +SplitIdentifierString(),quoteOneName() 和 SplitGUCList() 这几个函数中。 +``` + From c682e9ada6b447d32b1992a71a5cba813a1533a1 Mon Sep 17 00:00:00 2001 From: yuan li Date: Fri, 24 Oct 2025 15:30:39 +0800 Subject: [PATCH 2/2] Add english version of document --- CN/modules/ROOT/pages/master/6.3.9.adoc | 6 ++-- EN/modules/ROOT/nav.adoc | 1 + EN/modules/ROOT/pages/master/6.3.9.adoc | 48 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 EN/modules/ROOT/pages/master/6.3.9.adoc diff --git a/CN/modules/ROOT/pages/master/6.3.9.adoc b/CN/modules/ROOT/pages/master/6.3.9.adoc index f798bda9..89a8a8b9 100644 --- a/CN/modules/ROOT/pages/master/6.3.9.adoc +++ b/CN/modules/ROOT/pages/master/6.3.9.adoc @@ -11,7 +11,7 @@ == 实现说明 -如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c-->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。 +如果在数据库初始化时附加了参数 `-C`,值可以为 `normal/interchange/lowercase`,则代码中 `Intidb.c->main()` 函数会处理该参数,根据参数值设置全局变量 `caseswitchmode`。然后 `initdb` 命令会以 `-boot` 模式启动一个 `psotgres` 进程用于设置 `template1` 模板数据库,同时赋予参数 `-C ivorysql.identifier_case_switch=caseswitchmode` 给新进程。 这个新启动的后端进程会通过下面的代码将 `identifier_case_switch` 信息写入 `pg_control` 文件: @@ -42,8 +42,6 @@ BackendMain()->BackendInitialize()-->ProcessStartupPacket() ``` 另外,在处理用户的 SQL 语句时,如果包含标识符,也会进行同样的处理,代码分布在: - -``` SplitIdentifierString(),quoteOneName() 和 SplitGUCList() 这几个函数中。 -``` + diff --git a/EN/modules/ROOT/nav.adoc b/EN/modules/ROOT/nav.adoc index b046ca05..844fc02b 100644 --- a/EN/modules/ROOT/nav.adoc +++ b/EN/modules/ROOT/nav.adoc @@ -26,6 +26,7 @@ *** xref:master/6.3.4.adoc[%Type & %Rowtype] *** xref:master/6.3.5.adoc[NLS Parameters] *** xref:master/6.3.6.adoc[Function and stored procedure] +*** xref:master/6.3.9.adoc[Case Conversion] ** xref:master/6.4.adoc[GB18030 Character Set] * List of Oracle compatible features ** xref:master/7.1.adoc[1、Ivorysql frame design] diff --git a/EN/modules/ROOT/pages/master/6.3.9.adoc b/EN/modules/ROOT/pages/master/6.3.9.adoc new file mode 100644 index 00000000..3bba4eab --- /dev/null +++ b/EN/modules/ROOT/pages/master/6.3.9.adoc @@ -0,0 +1,48 @@ +:sectnums: +:sectnumlevels: 5 + +:imagesdir: ./_images + += Quoted Identifier Case Conversion + +== Purpose + +To meet Oracle's quoted identifier case compatibility requirements, IvorySQL has designed three case conversion modes for quoted identifiers. + +== Implementation Details + +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. + +This newly started backend process will write the `identifier_case_switch` information to the `pg_control` file through the following code: + +``` +BootstrapModeMain() -> BootStrapXLOG(); + /* save database compatible level value */ + ControlFile->dbmode = bootstrap_database_mode; + ControlFile->casemode = identifier_case_switch; + + /* some additional ControlFile fields are set in WriteControlFile() */ + WriteControlFile(); +``` + +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: + +``` +PostmasterMain()-->SetCaseGucOption()-->GetCaseSwitchModeFromControl() +``` + +After reading the parameter value, the `SetConfigOption()` function is called to assign the value. + +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`. + +The source code is: + +``` +BackendMain()->BackendInitialize()-->ProcessStartupPacket() +``` + +Additionally, when processing user SQL statements, if they contain identifiers, the same processing is performed. The code is distributed in: +SplitIdentifierString(), quoteOneName() and SplitGUCList() functions. + + +